Christ, is it what they pay stupid money for working in Banks?
-------------------------------------------------------
8:01 - 9:00 20% [i.e each minute is 1/3 %]
9:01 - 10:00 40% [i.e each minute is 2/3 %]
10:01 - 11:00 30% [i.e each minute is 1/2 %]
11:01 - 12:00 10% [i.e each minute is 1/6 %]
-------------------------------------------------------
1) you need simple function - CalcTradingRatio that accepts the following arguements:
a) %-tage of trading in given period
b) period start time, ie 8:01
c) period end time, ie 9:00
d) current time: this can be
d1) INSIDE period - in this case you calculation and return fraction of parameter a)
d2) BEFORE period starts (ie smaller then b) - return 0
d3) AFTER period ends - return full value a)
2) macro function that calls 1) for all periods:
string sCurTime="8:55";
int iTradingDone=0;
iTradingDone+=CalcTradingRatio("20","8:01","9:00",sCurTime);
iTradingDone+=CalcTradingRatio("40","9:01","10:00",sCurTime);
iTradingDone+=CalcTradingRatio("30","10:01","11:00",sCurTime);
iTradingDone+=CalcTradingRatio("10","11:01","12:00",sCurTime);