[Quantproject-developers] QuantProject/b7_Scripts/SimpleTesting/OneRank OneRank.cs,1.4,1.5
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2004-12-26 17:44:02
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/SimpleTesting/OneRank In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6597/b7_Scripts/SimpleTesting/OneRank Modified Files: OneRank.cs Log Message: - the static method MaxBuyableShares has been added - bug fixed: it was AddHours, now it is AddDays Index: OneRank.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/SimpleTesting/OneRank/OneRank.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** OneRank.cs 20 Dec 2004 00:14:03 -0000 1.4 --- OneRank.cs 26 Dec 2004 17:43:53 -0000 1.5 *************** *** 40,43 **** --- 40,50 ---- private DateTime lastDateTime; + + public static long MaxBuyableShares( string ticker , double cashAmount, IDataStreamer dataStreamer ) + { + return Convert.ToInt64( + Math.Floor( cashAmount / dataStreamer.GetCurrentAsk( ticker ) ) ); + } + private void marketOpenEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) *************** *** 54,58 **** this.account.Key ); EndOfDayDateTime yesterdayAtClose = new ! EndOfDayDateTime( this.account.EndOfDayTimer.GetCurrentTime().DateTime.AddHours( - 1 ) , EndOfDaySpecificTime.MarketClose ); double yesterdayMarketValueAtClose = HistoricalDataProvider.GetMarketValue( --- 61,65 ---- this.account.Key ); EndOfDayDateTime yesterdayAtClose = new ! EndOfDayDateTime( this.account.EndOfDayTimer.GetCurrentTime().DateTime.AddDays( - 1 ) , EndOfDaySpecificTime.MarketClose ); double yesterdayMarketValueAtClose = HistoricalDataProvider.GetMarketValue( *************** *** 64,70 **** // today close is higher than yesterday close and no position // is kept in portfolio, yet ! sharesToBeBought = Convert.ToInt64( ! Math.Floor( this.account.CashAmount / ! this.account.DataStreamer.GetCurrentAsk( this.account.Key ) ) ); this.account.AddOrder( new Order( OrderType.MarketBuy , new Instrument( this.account.Key ) , sharesToBeBought ) ); --- 71,76 ---- // today close is higher than yesterday close and no position // is kept in portfolio, yet ! sharesToBeBought = MaxBuyableShares( this.account.Key , ! this.account.CashAmount , this.account.DataStreamer ); this.account.AddOrder( new Order( OrderType.MarketBuy , new Instrument( this.account.Key ) , sharesToBeBought ) ); |