quantproject-developers Mailing List for QuantProject (Page 26)
Brought to you by:
glauco_1
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(7) |
Nov
(103) |
Dec
(67) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(52) |
Feb
(9) |
Mar
(69) |
Apr
(53) |
May
(80) |
Jun
(23) |
Jul
(24) |
Aug
(112) |
Sep
(9) |
Oct
|
Nov
(58) |
Dec
(93) |
| 2005 |
Jan
(90) |
Feb
(93) |
Mar
(61) |
Apr
(56) |
May
(37) |
Jun
(61) |
Jul
(55) |
Aug
(68) |
Sep
(25) |
Oct
(46) |
Nov
(41) |
Dec
(37) |
| 2006 |
Jan
(33) |
Feb
(7) |
Mar
(19) |
Apr
(27) |
May
(73) |
Jun
(49) |
Jul
(83) |
Aug
(66) |
Sep
(45) |
Oct
(16) |
Nov
(15) |
Dec
(7) |
| 2007 |
Jan
(14) |
Feb
(33) |
Mar
|
Apr
(21) |
May
|
Jun
(34) |
Jul
(18) |
Aug
(100) |
Sep
(39) |
Oct
(55) |
Nov
(12) |
Dec
(2) |
| 2008 |
Jan
(120) |
Feb
(133) |
Mar
(129) |
Apr
(104) |
May
(42) |
Jun
(2) |
Jul
(52) |
Aug
(99) |
Sep
(134) |
Oct
|
Nov
(137) |
Dec
(48) |
| 2009 |
Jan
(48) |
Feb
(55) |
Mar
(61) |
Apr
(3) |
May
(2) |
Jun
(1) |
Jul
|
Aug
(51) |
Sep
|
Oct
(7) |
Nov
|
Dec
|
| 2010 |
Jan
(7) |
Feb
(1) |
Mar
(145) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(8) |
Dec
|
| 2011 |
Jan
(78) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(88) |
Sep
(6) |
Oct
(1) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
(1) |
Mar
|
Apr
(6) |
May
(5) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2013 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
| 2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Glauco S. <gla...@us...> - 2008-12-10 19:37:26
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14170/b4_Business/a05_Timing Modified Files: IndexBasedHistoricalTimer.cs Log Message: the semantics has been slightly (but significantly) changed: - in the previous revision a NewDateTime was thrown out only if the benchmark was traded at that time - now the timer fetches all days when the benchmark is traded and for each of those days every daily time is thrown - thus, the current revision possibly throws out some more NewDateTime events Furthermore, parameters checking has been added Index: IndexBasedHistoricalTimer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing/IndexBasedHistoricalTimer.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** IndexBasedHistoricalTimer.cs 20 Nov 2008 20:46:55 -0000 1.4 --- IndexBasedHistoricalTimer.cs 10 Dec 2008 19:37:13 -0000 1.5 *************** *** 46,49 **** --- 46,59 ---- private int currentDateTimeIndex; + /// <summary> + /// + /// </summary> + /// <param name="indexTicker"></param> + /// <param name="firstDateTime"></param> + /// <param name="lastDateTime"></param> + /// <param name="dailyTimes">daily times: these times must be in strict ascending + /// order and they must be intraday (i.e. smaller than one hour after + /// market close)</param> + /// <param name="intervalFrameInSeconds"></param> public IndexBasedHistoricalTimer( string indexTicker , *************** *** 53,56 **** --- 63,67 ---- int intervalFrameInSeconds) { + this.checkParameters( dailyTimes ); this.indexTicker = indexTicker; this.firstDateTime = firstDateTime; *************** *** 60,142 **** } #region initializeTimer #region initialize_dateTimesToBeThrown ! #region addDateTimeAndIfTheCaseAddEndOfDayDateTime ! #region addOneHourAfterMarketCloseDateTimeIfTheCase ! #region isOneHourAfterMarktetCloseToBeInserted ! private bool isOneHourAfterMarktetCloseToBeInserted_withOneAdded( ! DateTime nextDateTimeToBeAdded ) { ! Date dateForLastDateTimeAdded = ! new Date( this.dateTimesToBeThrown[ this.dateTimesToBeThrown.Count - 1 ] ); ! Date dateForNextDateTimeToBeAdded = ! new Date( nextDateTimeToBeAdded ); ! bool isToBeInserted = ( dateForNextDateTimeToBeAdded > dateForLastDateTimeAdded ); ! return isToBeInserted; } ! private bool isOneHourAfterMarktetCloseToBeInserted( DateTime nextDateTimeToBeAdded ) { ! bool isToBeInserted = false; ! if ( this.dateTimesToBeThrown.Count > 0 ) ! // at least one DateTime has already been added ! isToBeInserted = isOneHourAfterMarktetCloseToBeInserted_withOneAdded( ! nextDateTimeToBeAdded ); ! return isToBeInserted; } ! #endregion isOneHourAfterMarktetCloseToBeInserted #region addOneHourAfterMarketCloseDateTime ! private DateTime getOneHourAfterMarketCloseForLastDateTimeAdded() { ! DateTime dateTimeForLastDateTimeAdded = ! this.dateTimesToBeThrown[ this.dateTimesToBeThrown.Count - 1 ]; ! DateTime oneHourAfterMarketCloseForLastDateTimeAdded = ! HistoricalEndOfDayTimer.GetOneHourAfterMarketClose( ! dateTimeForLastDateTimeAdded ); ! return oneHourAfterMarketCloseForLastDateTimeAdded; } ! private void addOneHourAfterMarketCloseDateTime( DateTime dateTime ) { ! DateTime oneHourAfterMarketCloseForLastDateTimeAdded = ! this.getOneHourAfterMarketCloseForLastDateTimeAdded(); ! this.dateTimesToBeThrown.Add( ! oneHourAfterMarketCloseForLastDateTimeAdded ); } ! #endregion addOneHourAfterMarketCloseDateTime ! private void addOneHourAfterMarketCloseDateTimeIfTheCase( ! DateTime nextDateTimeToBeAdded ) { ! if ( this.isOneHourAfterMarktetCloseToBeInserted( nextDateTimeToBeAdded ) ) ! this.addOneHourAfterMarketCloseDateTime( nextDateTimeToBeAdded ); } ! #endregion addOneHourAfterMarketCloseDateTimeIfTheCase ! private void addDateTimeAndIfTheCaseAddOneHourAfterMarketCloseDateTime( ! DateTime nextDateTimeToBeAdded ) { ! this.addOneHourAfterMarketCloseDateTimeIfTheCase( nextDateTimeToBeAdded ); ! this.dateTimesToBeThrown.Add( nextDateTimeToBeAdded ); } ! #endregion addDateTimeAndIfTheCaseAddEndOfDayDateTime private void initialize_dateTimesToBeThrown( ! History dateTimesToBeThrownHistory ) { this.dateTimesToBeThrown = new List< DateTime >(); ! foreach ( DateTime dateTime in dateTimesToBeThrownHistory.Keys ) ! this.addDateTimeAndIfTheCaseAddOneHourAfterMarketCloseDateTime( dateTime ); } private void initialize_dateTimesToBeThrown() { ! History dateTimesToBeThrownHistory = ! Bars.GetMarketDateTimes( ! this.indexTicker , this.firstDateTime , this.lastDateTime , ! this.dailyTimes, this.intervalFrameInSeconds ); ! this.initialize_dateTimesToBeThrown( dateTimesToBeThrownHistory ); } #endregion initialize_dateTimesToBeThrown --- 71,229 ---- } + private void checkParameters( List< Time > dailyTimes ) + { + Time.CheckStrictlyAscending( dailyTimes ); + } + #region initializeTimer #region initialize_dateTimesToBeThrown ! #region addDailyTimesAndIfTheCaseAddOneHourAfterMarketCloseDateTime ! // #region addDailyTimeAndIfTheCaseAddOneHourAfterMarketCloseDateTime ! // ! // #region addNextDateTimeAndIfTheCaseAddOneHourAfterMarketCloseDateTime ! // ! // #region addOneHourAfterMarketCloseDateTimeIfTheCase ! // ! //// #region isOneHourAfterMarktetCloseToBeInserted ! //// private bool isOneHourAfterMarktetCloseToBeInserted_withOneAdded( ! //// DateTime nextDateTimeToBeAdded ) ! //// { ! //// Date dateForLastDateTimeAdded = ! //// new Date( this.dateTimesToBeThrown[ this.dateTimesToBeThrown.Count - 1 ] ); ! //// Date dateForNextDateTimeToBeAdded = ! //// new Date( nextDateTimeToBeAdded ); ! //// bool isToBeInserted = ( dateForNextDateTimeToBeAdded > dateForLastDateTimeAdded ); ! //// return isToBeInserted; ! //// } ! //// private bool isOneHourAfterMarktetCloseToBeInserted( DateTime nextDateTimeToBeAdded ) ! //// { ! //// bool isToBeInserted = false; ! //// if ( this.dateTimesToBeThrown.Count > 0 ) ! //// // at least one DateTime has already been added ! //// isToBeInserted = isOneHourAfterMarktetCloseToBeInserted_withOneAdded( ! //// nextDateTimeToBeAdded ); ! //// return isToBeInserted; ! //// } ! //// #endregion isOneHourAfterMarktetCloseToBeInserted ! // ! // #region addOneHourAfterMarketCloseDateTime ! // private DateTime getOneHourAfterMarketCloseForLastDateTimeAdded() ! // { ! // DateTime dateTimeForLastDateTimeAdded = ! // this.dateTimesToBeThrown[ this.dateTimesToBeThrown.Count - 1 ]; ! // DateTime oneHourAfterMarketCloseForLastDateTimeAdded = ! // HistoricalEndOfDayTimer.GetOneHourAfterMarketClose( ! // dateTimeForLastDateTimeAdded ); ! // return oneHourAfterMarketCloseForLastDateTimeAdded; ! // } ! // private void addOneHourAfterMarketCloseDateTime( DateTime nextDateTimeToBeAdded ) ! // { ! // DateTime oneHourAfterMarketCloseForLastDateTimeAdded = ! // this.getOneHourAfterMarketCloseForLastDateTimeAdded(); ! // this.dateTimesToBeThrown.Add( ! // oneHourAfterMarketCloseForLastDateTimeAdded ); ! // } ! // #endregion addOneHourAfterMarketCloseDateTime ! // ! // private void addOneHourAfterMarketCloseDateTimeIfTheCase( ! // DateTime nextDateTimeToBeAdded ) ! // { ! // if ( this.isOneHourAfterMarktetCloseToBeInserted( nextDateTimeToBeAdded ) ) ! // this.addOneHourAfterMarketCloseDateTime( nextDateTimeToBeAdded ); ! // } ! // #endregion addOneHourAfterMarketCloseDateTimeIfTheCase ! // ! // private void addNextDateTimeAndIfTheCaseAddOneHourAfterMarketCloseDateTime( ! // DateTime nextDateTimeToBeAdded ) ! // { ! // this.addOneHourAfterMarketCloseDateTimeIfTheCase( nextDateTimeToBeAdded ); ! // this.dateTimesToBeThrown.Add( nextDateTimeToBeAdded ); ! // } ! // ! // #endregion addNextDateTimeAndIfTheCaseAddOneHourAfterMarketCloseDateTime ! // ! // private void addDailyTimeAndIfTheCaseAddOneHourAfterMarketCloseDateTime( ! // Time time , DateTime benchmarkMarketDay ) ! // { ! // DateTime nextDateTimeToBeAdded = Time.GetDateTimeFromMerge( ! // benchmarkMarketDay , time ); ! // this.addNextDateTimeAndIfTheCaseAddOneHourAfterMarketCloseDateTime( ! // nextDateTimeToBeAdded ); ! // } ! // #endregion addDailyTimeAndIfTheCaseAddOneHourAfterMarketCloseDateTime ! #region addDailyTimes ! private void addDailyTime( Time time , DateTime benchmarkMarketDay ) { ! DateTime dateTimeToBeAdded = Time.GetDateTimeFromMerge( ! benchmarkMarketDay , time ); ! this.dateTimesToBeThrown.Add( dateTimeToBeAdded ); } ! private void addDailyTimes( DateTime benchmarkMarketDay ) { ! foreach ( Time time in this.dailyTimes ) ! this.addDailyTime( time , benchmarkMarketDay ); } ! #endregion addDailyTimes #region addOneHourAfterMarketCloseDateTime ! ! #region checkAndAddOneHourAfterMarketCloseDateTime ! private void checkIfOneHourAfterMarketCloseDateTimeFollowsLastAddedDateTime( ! DateTime oneHourAfterMarketCloseDateTime ) { ! DateTime lastDateTimeAdded = this.dateTimesToBeThrown[ ! this.dateTimesToBeThrown.Count - 1 ]; ! if ( lastDateTimeAdded >= oneHourAfterMarketCloseDateTime ) ! throw new Exception( ! "dailyTimes given to this object's constructor cannot be " + ! "larger or equal to one hour after market close" ); } ! private void checkAndAddOneHourAfterMarketCloseDateTime( ! DateTime oneHourAfterMarketCloseDateTime ) { ! this.checkIfOneHourAfterMarketCloseDateTimeFollowsLastAddedDateTime( ! oneHourAfterMarketCloseDateTime ); ! this.dateTimesToBeThrown.Add( oneHourAfterMarketCloseDateTime ); } ! #endregion checkAndAddOneHourAfterMarketCloseDateTime ! private void addOneHourAfterMarketCloseDateTime( DateTime benchmarkMarketDay ) { ! DateTime oneHourAfterMarketCloseDateTime = ! HistoricalEndOfDayTimer.GetOneHourAfterMarketClose( ! benchmarkMarketDay ); ! this.checkAndAddOneHourAfterMarketCloseDateTime( oneHourAfterMarketCloseDateTime ); } ! #endregion addOneHourAfterMarketCloseDateTime ! private void addDailyTimesAndOneHourAfterMarketCloseDateTime( ! DateTime benchmarkMarketDay ) { ! this.addDailyTimes( benchmarkMarketDay ); ! this.addOneHourAfterMarketCloseDateTime( benchmarkMarketDay ); } ! #endregion addDailyTimesAndIfTheCaseAddOneHourAfterMarketCloseDateTime private void initialize_dateTimesToBeThrown( ! History benchmarkMarketDays ) { this.dateTimesToBeThrown = new List< DateTime >(); ! foreach ( DateTime benchmarkMarketDay in benchmarkMarketDays.Keys ) ! this.addDailyTimesAndOneHourAfterMarketCloseDateTime( ! benchmarkMarketDay ); } private void initialize_dateTimesToBeThrown() { ! History benchmarkMarketDays = ! Quotes.GetMarketDays( ! this.indexTicker , this.firstDateTime , this.lastDateTime ); ! // Bars.GetMarketDateTimes( ! // this.indexTicker , this.firstDateTime , this.lastDateTime , ! // this.dailyTimes, this.intervalFrameInSeconds ); ! this.initialize_dateTimesToBeThrown( benchmarkMarketDays ); } #endregion initialize_dateTimesToBeThrown |
|
From: Glauco S. <gla...@us...> - 2008-12-10 19:31:29
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13886/b4_Business/a05_Timing Modified Files: HistoricalEndOfDayTimer.cs Log Message: a new method public static bool IsMarketTime( DateTime dateTime ) has been added Index: HistoricalEndOfDayTimer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing/HistoricalEndOfDayTimer.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** HistoricalEndOfDayTimer.cs 20 Nov 2008 20:43:43 -0000 1.11 --- HistoricalEndOfDayTimer.cs 10 Dec 2008 19:31:16 -0000 1.12 *************** *** 193,196 **** --- 193,212 ---- } + /// <summary> + /// true iif instruments are exchanged at dateTime + /// </summary> + /// <param name="dateTime"></param> + /// <returns></returns> + public static bool IsMarketTime( DateTime dateTime ) + { + bool isMarketTime = + ( + ( dateTime >= HistoricalEndOfDayTimer.GetMarketOpen( dateTime ) ) && + ( dateTime <= HistoricalEndOfDayTimer.GetMarketClose( dateTime ) ) + ); + return isMarketTime; + } + + #region GetNextMarketStatusSwitch // private void getNextMarketStatusSwitch_checkParameters( |
|
From: Glauco S. <gla...@us...> - 2008-12-10 19:29:38
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13766/b4_Business/a2_Strategies Modified Files: BasicStrategyForBacktester.cs Log Message: a log message has been improved: now the current simulated time is shown also Index: BasicStrategyForBacktester.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/BasicStrategyForBacktester.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** BasicStrategyForBacktester.cs 22 Nov 2008 18:19:08 -0000 1.3 --- BasicStrategyForBacktester.cs 10 Dec 2008 19:29:27 -0000 1.4 *************** *** 186,190 **** string message = "Number of Eligible tickers: " + eligibleTickers.Count + ! " - " + DateTime.Now.ToString(); NewMessageEventArgs newMessageEventArgs = --- 186,192 ---- string message = "Number of Eligible tickers: " + eligibleTickers.Count + ! " - Simulated time: " + ! this.account.Timer.GetCurrentDateTime().ToString() + ! " - Real time: " + DateTime.Now.ToString(); NewMessageEventArgs newMessageEventArgs = *************** *** 246,249 **** --- 248,255 ---- if ( this.areOptimalWeightedPositionsToBeUpdated() ) this.updateOptimalTestingPositions(); + if ( ( dateTime.Month == 3 ) && ( dateTime.Day == 15 ) ) + { + ; + } if ( this.arePositionsToBeClosed() ) AccountManager.ClosePositions( this.account ); |
|
From: Glauco S. <gla...@us...> - 2008-12-10 19:28:47
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/General In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13709/b7_Scripts/General Modified Files: BasicScriptForBacktesting.cs Log Message: a new method protected virtual void doThisBeforeAnythingElse() has been added. Override this method if you need to do anything that will be used the other abstract methods (that are invoked later); this method is invoked before all the other methods Index: BasicScriptForBacktesting.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/General/BasicScriptForBacktesting.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** BasicScriptForBacktesting.cs 29 Sep 2008 21:17:03 -0000 1.4 --- BasicScriptForBacktesting.cs 10 Dec 2008 19:28:35 -0000 1.5 *************** *** 58,61 **** --- 58,62 ---- public BasicScriptForBacktesting() { + this.doThisBeforeAnythingElse(); string pathForTheMainFolderWhereScriptsResultsAreToBeSaved = this.getPathForTheMainFolderWhereScriptsResultsAreToBeSaved(); *************** *** 72,75 **** --- 73,86 ---- fullPathFileNameForMain ); } + + /// <summary> + /// override this method if you need to do anything that will be used + /// by the other abstract methods (that are invoked later); this method + /// is invoked before all the other methods + /// </summary> + protected virtual void doThisBeforeAnythingElse() + { + ; + } /// <summary> |
|
From: Glauco S. <gla...@us...> - 2008-12-10 19:27:32
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13638/b4_Business/a1_Financial/a2_Accounting/h5_Reporting Modified Files: AccountReport.cs Log Message: an HistoricalAdjustedQuoteProvider is used to compute the portfolio value, if the current DateTime is out of market time Index: AccountReport.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/AccountReport.cs,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** AccountReport.cs 29 Sep 2008 21:13:46 -0000 1.23 --- AccountReport.cs 10 Dec 2008 19:27:19 -0000 1.24 *************** *** 63,66 **** --- 63,68 ---- private Tables.Summary summary; private Tables.StatisticsSummary statisticsSummary; + + private HistoricalMarketValueProvider historicalAdjustedQuoteProvider; public string Name *************** *** 161,164 **** --- 163,168 ---- this.historicalMarketValueProvider = historicalMarketValueProvider; this.dateTimeSelectorForEquityLine = dateTimeSelectorForEquityLine; + + this.historicalAdjustedQuoteProvider = new HistoricalAdjustedQuoteProvider(); } *************** *** 185,194 **** #region setRows private void addBalanceItems ( DateTime dateTime , DataRow dataRow ) { dataRow[ "AccountCash" ] = this.accountCopy.CashAmount; ! dataRow[ "PortfolioValue" ] = this.accountCopy.Portfolio.GetMarketValue( ! dateTime , this.historicalMarketValueProvider ); dataRow[ "AccountValue" ] = (double)dataRow[ "AccountCash" ] + --- 189,217 ---- #region setRows + + #region addBalanceItems + + private double getMarketValue( DateTime dateTime ) + { + double marketValue = double.MinValue; + if ( HistoricalEndOfDayTimer.IsMarketTime( dateTime ) ) + // market is open + marketValue = this.accountCopy.Portfolio.GetMarketValue( + dateTime , this.historicalMarketValueProvider ); + else + // instruments are not exchanged at dateTime + marketValue = this.accountCopy.Portfolio.GetMarketValue( + dateTime , this.historicalAdjustedQuoteProvider ); + return marketValue; + } + private void addBalanceItems ( DateTime dateTime , DataRow dataRow ) { dataRow[ "AccountCash" ] = this.accountCopy.CashAmount; ! dataRow[ "PortfolioValue" ] = this.getMarketValue( dateTime ); ! // this.accountCopy.Portfolio.GetMarketValue( ! // dateTime , this.historicalAdjustedQuoteProvider ); ! // dateTime , this.historicalMarketValueProvider ); dataRow[ "AccountValue" ] = (double)dataRow[ "AccountCash" ] + *************** *** 198,201 **** --- 221,225 ---- this.accountCopy.Transactions.TotalAddedCash; } + #endregion addBalanceItems #region setRows_addRowsForTransactionsBefore_nextDateTimeForEquityLine *************** *** 206,220 **** bool isToBeAdded = false; if ( indexForTheNextTransactionToBeAdded < ! this.account.Transactions.Count ) // not all transactions have been added, yet { DateTime dateTimeForTheNextTransactionToBeAdded = ! (DateTime)this.account.Transactions.GetKey( ! indexForTheNextTransactionToBeAdded ); isToBeAdded = ( dateTimeForTheNextTransactionToBeAdded <= nextDateTimeForEquityLine ); } return isToBeAdded; ! } #region addRowsForTransactionsAtTheGivenDateTime --- 230,244 ---- bool isToBeAdded = false; if ( indexForTheNextTransactionToBeAdded < ! this.account.Transactions.Count ) // not all transactions have been added, yet { DateTime dateTimeForTheNextTransactionToBeAdded = ! (DateTime)this.account.Transactions.GetKey( ! indexForTheNextTransactionToBeAdded ); isToBeAdded = ( dateTimeForTheNextTransactionToBeAdded <= nextDateTimeForEquityLine ); } return isToBeAdded; ! } #region addRowsForTransactionsAtTheGivenDateTime *************** *** 234,238 **** if ( transaction.Commission != null ) dataRow[ "Commission" ] = transaction.Commission.Value; ! addBalanceItems( transaction.DateTime , dataRow ); this.detailedDataTable.Rows.Add( dataRow ); } --- 258,262 ---- if ( transaction.Commission != null ) dataRow[ "Commission" ] = transaction.Commission.Value; ! this.addBalanceItems( transaction.DateTime , dataRow ); this.detailedDataTable.Rows.Add( dataRow ); } |
|
From: Marco M. <mi...@us...> - 2008-11-30 22:52:09
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv28981/Downloader Modified Files: TickerDownloader.cs WebDownloader.cs Log Message: Downloading tickers from Yahoo has been moved to a separate thread: so, the downloader form can be explored by the user also during downloading. The downloader form has been enriched with other information. Only the parameters showed by default by the form have been succesfully tested. Index: WebDownloader.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/WebDownloader.cs,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** WebDownloader.cs 2 Jul 2006 20:04:15 -0000 1.21 --- WebDownloader.cs 30 Nov 2008 22:52:04 -0000 1.22 *************** *** 23,27 **** { public OleDbConnection OleDbConnection1 = ConnectionProvider.OleDbConnection; - private System.Windows.Forms.Button button1; public System.Windows.Forms.DataGrid dataGrid1; private System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter1; --- 23,26 ---- *************** *** 30,53 **** private System.Data.OleDb.OleDbCommand oleDbUpdateCommand1; private System.Data.OleDb.OleDbCommand oleDbDeleteCommand1; [...1240 lines suppressed...] ! void WebDownloaderPaint(object sender, PaintEventArgs e) ! { ! if( this.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ] != null) ! this.webDownloaderPaint_refreshTableForGrid(); ! } ! ! void WebDownloaderFormClosing(object sender, FormClosingEventArgs e) ! { ! if (this.downloadingInProgress) ! { ! e.Cancel = true; ! MessageBox.Show("You can't close the form if downloading is still in progress!"); ! } ! else ! { ! e.Cancel = false; ! } ! } ! } } Index: TickerDownloader.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/TickerDownloader.cs,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** TickerDownloader.cs 3 Sep 2006 13:45:57 -0000 1.21 --- TickerDownloader.cs 30 Nov 2008 22:52:04 -0000 1.22 *************** *** 1,3 **** --- 1,4 ---- using System; + using System.Threading; using System.Data; using System.IO; *************** *** 17,24 **** private System.Data.OleDb.OleDbConnection oleDbConnection1; private WebDownloader p_myForm; ! private DataRow p_currentDataTickerRow; ! private string p_quTicker; ! private int p_numRows; ! private DateTime INITIAL_DATE = ConstantsProvider.InitialDateTimeForDownload; private DateTime startDate; private DateTime endDate = DateTime.Today; --- 18,33 ---- private System.Data.OleDb.OleDbConnection oleDbConnection1; private WebDownloader p_myForm; ! private int numOfTickersToDownload; ! private bool checkBoxIsDicotomicSearchActivated; ! private bool isCheckCloseToCloseSelected; ! private bool isOverWriteSelected; ! private bool isComputeCloseToCloseRatioSelected; ! private bool isOnlyAfterLastQuoteSelected; ! private bool isOnlyAddMissingSelected; ! private bool isOverWriteYesSelected; ! private bool isSingleQuoteSelected; ! private DateTime selectedDateForSingleQuote; ! private string currentTicker; ! private DateTime INITIAL_DATE; private DateTime startDate; private DateTime endDate = DateTime.Today; *************** *** 27,43 **** private int endYear = DateTime.Now.Year; private int numberOfQuotesInDatabase; ! private DataTable downloadedValuesFromSource = new DataTable("quotes"); private OleDbSingleTableAdapter adapter; private Stream stream; private StreamReader streamReader; ! public TickerDownloader( WebDownloader myForm, DataRow currentDataTickerRow, string quTicker , int numRows ) { ! this.startDate = this.INITIAL_DATE; ! p_myForm = myForm; ! p_currentDataTickerRow = currentDataTickerRow; ! p_quTicker = quTicker; ! p_numRows = numRows; this.oleDbConnection1 = myForm.OleDbConnection1; this.adapter = new OleDbSingleTableAdapter("SELECT * FROM quotes WHERE 1=2", this.downloadedValuesFromSource); --- 36,69 ---- private int endYear = DateTime.Now.Year; private int numberOfQuotesInDatabase; ! private DataTable downloadedValuesFromSource; private OleDbSingleTableAdapter adapter; private Stream stream; private StreamReader streamReader; + private HttpWebResponse httpWebResponse; ! ! private void tickerDownloader_copyPropertiesFromForm( WebDownloader myForm ) { ! this.startDate = myForm.StartingDate; ! numOfTickersToDownload = this.p_myForm.DsTickerCurrentlyDownloaded.Tables["Tickers"].Rows.Count; ! checkBoxIsDicotomicSearchActivated = myForm.checkBoxIsDicotomicSearchActivated.Checked; ! isCheckCloseToCloseSelected = myForm.IsCheckCloseToCloseSelected; ! isOverWriteSelected = myForm.IsOverWriteYesSelected; ! isComputeCloseToCloseRatioSelected = myForm.IsComputeCloseToCloseRatioSelected; ! isOnlyAfterLastQuoteSelected = myForm.IsOnlyAfterLastQuoteSelected; ! isOnlyAddMissingSelected = myForm.IsOnlyAddMissingSelected; ! isOverWriteYesSelected = myForm.IsOverWriteYesSelected; ! isSingleQuoteSelected = myForm.IsSingleQuoteSelected; ! selectedDateForSingleQuote = myForm.SelectedDateForSingleQuote; ! } ! ! ! public TickerDownloader( WebDownloader myForm ) ! { ! this.INITIAL_DATE = ConstantsProvider.InitialDateTimeForDownload; ! p_myForm = myForm; ! this.tickerDownloader_copyPropertiesFromForm( myForm ); this.oleDbConnection1 = myForm.OleDbConnection1; + this.downloadedValuesFromSource = new DataTable("quotes"); this.adapter = new OleDbSingleTableAdapter("SELECT * FROM quotes WHERE 1=2", this.downloadedValuesFromSource); *************** *** 63,103 **** lock( p_myForm.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ] ) { ! string columnName = p_myForm.DsTickerCurrentlyDownloaded.Tables["Tickers"].Columns[0].ColumnName; ! DataRow[] myRows = p_myForm.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ].Select( columnName + "='" + p_quTicker + "'" ); ! myRows[ 0 ][ "currentState" ] = newState; ! p_myForm.dataGrid1.Refresh(); } } ! private void updateCurrentStatusAdjustedClose(string status ) { lock( p_myForm.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ] ) { ! string columnName = p_myForm.DsTickerCurrentlyDownloaded.Tables["Tickers"].Columns[0].ColumnName; ! DataRow[] myRows = p_myForm.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ].Select( columnName + "='" + p_quTicker + "'" ); ! myRows[ 0 ][ "adjustedClose" ] = status; ! p_myForm.dataGrid1.Refresh(); } } ! private void updateCurrentStatusAdjustedCloseToCloseRatio(string status ) { lock( p_myForm.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ] ) { ! string columnName = p_myForm.DsTickerCurrentlyDownloaded.Tables["Tickers"].Columns[0].ColumnName; ! DataRow[] myRows = p_myForm.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ].Select(columnName + "='" + p_quTicker + "'" ); ! myRows[ 0 ][ "adjCloseToCloseRatio" ] = status; ! p_myForm.dataGrid1.Refresh(); } } private void updateCurrentStatusDatabaseUpdated(string status ) { lock( p_myForm.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ] ) { ! string columnName = p_myForm.DsTickerCurrentlyDownloaded.Tables["Tickers"].Columns[0].ColumnName; ! DataRow[] myRows = p_myForm.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ].Select(columnName + "='" + p_quTicker + "'" ); ! myRows[ 0 ][ "databaseUpdated" ] = status; ! p_myForm.dataGrid1.Refresh(); } } --- 89,146 ---- lock( p_myForm.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ] ) { ! p_myForm.CurrentStateForCurrentUpdatingTicker = newState; ! p_myForm.Invalidate(); ! // string columnName = p_myForm.DsTickerCurrentlyDownloaded.Tables["Tickers"].Columns[0].ColumnName; ! // DataRow[] myRows = p_myForm.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ].Select( columnName + "='" + p_quTicker + "'" ); ! // myRows[ 0 ][ "currentState" ] = newState; ! // p_myForm.dataGrid1.Refresh(); } } ! private void updateCurrentStatusAdjustedClose( string status ) { lock( p_myForm.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ] ) { ! p_myForm.AdjustedCloseInfoForCurrentUpdatingTicker = status; ! p_myForm.Invalidate(); ! // string columnName = p_myForm.DsTickerCurrentlyDownloaded.Tables["Tickers"].Columns[0].ColumnName; ! // DataRow[] myRows = p_myForm.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ].Select( columnName + "='" + p_quTicker + "'" ); ! // myRows[ 0 ][ "adjustedClose" ] = status; ! // p_myForm.dataGrid1.Refresh(); } } ! private void updateCurrentStatusAdjustedCloseToCloseRatio( string status ) { lock( p_myForm.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ] ) { ! p_myForm.AdjCloseToCloseRatioInfoForCurrentUpdatingTicker = status; ! p_myForm.Invalidate(); ! // string columnName = p_myForm.DsTickerCurrentlyDownloaded.Tables["Tickers"].Columns[0].ColumnName; ! // DataRow[] myRows = p_myForm.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ].Select(columnName + "='" + p_quTicker + "'" ); ! // myRows[ 0 ][ "adjCloseToCloseRatio" ] = status; ! // p_myForm.dataGrid1.Refresh(); } } + private void updateCurrentLastQuoteInDB(string status ) + { + lock( p_myForm.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ] ) + { + p_myForm.LastQuoteInDBForCurrentUpdatingTicker = status; + p_myForm.Invalidate(); + } + } + private void updateCurrentStatusDatabaseUpdated(string status ) { lock( p_myForm.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ] ) { ! p_myForm.DatabaseUpdatedInfoForCurrentUpdatingTicker = status; ! p_myForm.Invalidate(); ! // string columnName = p_myForm.DsTickerCurrentlyDownloaded.Tables["Tickers"].Columns[0].ColumnName; ! // DataRow[] myRows = p_myForm.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ].Select(columnName + "='" + p_quTicker + "'" ); ! // myRows[ 0 ][ "databaseUpdated" ] = status; ! // p_myForm.dataGrid1.Refresh(); } } *************** *** 109,113 **** System.Data.OleDb.OleDbCommand odc = new System.Data.OleDb.OleDbCommand(); odc.CommandText = "insert into faultyTickers ( ftTicker , ftDateTime ) " + ! "values ( '" + p_quTicker + "' , #" + DateTime.Now.Month + "/" + DateTime.Now.Day + "/" + --- 152,156 ---- System.Data.OleDb.OleDbCommand odc = new System.Data.OleDb.OleDbCommand(); odc.CommandText = "insert into faultyTickers ( ftTicker , ftDateTime ) " + ! "values ( '" + currentTicker + "' , #" + DateTime.Now.Month + "/" + DateTime.Now.Day + "/" + *************** *** 200,204 **** DataRow myRow =this.downloadedValuesFromSource.NewRow(); ! myRow[ "quTicker" ] = this.p_quTicker; myRow[ "quDate" ]=DateTime.Parse( LineIn[0] ); myRow[ "quOpen" ]=Double.Parse( LineIn[1] ); --- 243,247 ---- DataRow myRow =this.downloadedValuesFromSource.NewRow(); ! myRow[ "quTicker" ] = this.currentTicker; myRow[ "quDate" ]=DateTime.Parse( LineIn[0] ); myRow[ "quOpen" ]=Double.Parse( LineIn[1] ); *************** *** 220,234 **** try { - this.p_myForm.Refresh(); this.setStreamsFromYahoo(currBeginDate, currEndDate); this.addCurrentStreamToTable(); if(this.streamReader!=null) this.streamReader.Close(); else return; ! this.updateCurrentStatus(currEndDate.ToShortDateString()); ! ! //this.updateCurrentStatus( d + "/" + e + "/" + f ); ! } catch (Exception exception) { --- 263,278 ---- try { this.setStreamsFromYahoo(currBeginDate, currEndDate); this.addCurrentStreamToTable(); + this.updateCurrentStatus(currEndDate.ToShortDateString()); if(this.streamReader!=null) + { this.streamReader.Close(); + this.stream.Close(); + this.httpWebResponse.Close(); + } else return; ! } catch (Exception exception) { *************** *** 285,373 **** } ! private void addTickerTo_gridDataSet() ! { ! DataRow newRow = p_myForm.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ].NewRow(); ! newRow[ 0 ] = p_quTicker; ! newRow[ "currentState" ] = "Searching ..."; ! newRow[ "databaseUpdated" ] = "No"; ! newRow[ "adjustedClose"] = "..."; ! newRow[ "adjCloseToCloseRatio"] = "..."; ! try ! { ! p_myForm.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ].Rows.Add( newRow ); ! p_myForm.labelNumberOfTickersToDownload.Text = ! Convert.ToString(Convert.ToInt16(p_myForm.labelNumberOfTickersToDownload.Text) - 1); ! } ! catch (Exception ex) ! { ! string notUsed = ex.ToString(); ! //MessageBox.Show( ex.ToString() ); ! } ! p_myForm.dataGrid1.Refresh(); ! } private void resetStartDateIfNecessary() { ! if(this.p_myForm.checkBoxIsDicotomicSearchActivated.Checked == true) this.startDate = firstAvailableDateOnYahoo(this.INITIAL_DATE, this.endDate); } ! private void downloadTickerBeforeFirstQuote() { ! this.endDate = Quotes.GetFirstQuoteDate(this.p_quTicker); this.resetStartDateIfNecessary(); this.checkForNewAdjustedAndContinueOrStop(); } ! private bool getResponseForRepeatedChecks(int numberOfRepeatedChecks) { bool response = false; QuantProject.Data.DataTables.Quotes tickerQuotes = ! new QuantProject.Data.DataTables.Quotes(this.p_quTicker); ! for(int i = 1; i< this.numberOfQuotesInDatabase; i += this.numberOfQuotesInDatabase/numberOfRepeatedChecks) { DateTime dateToCheck = tickerQuotes.GetPrecedingDate(this.startDate, i); ! response = ! Quotes.IsAdjustedCloseChanged(this.p_quTicker, dateToCheck, ! this.adjustedCloseFromSource(dateToCheck)); } return response; } private void checkForNewAdjustedAndContinueOrStop() { try { ! if(this.getResponseForRepeatedChecks(ConstantsProvider.NumberOfCheckToPerformOnAdjustedValues)) { this.updateCurrentStatusAdjustedClose("Changed!"); ! if (Quotes.IsAdjustedCloseToCloseRatioChanged(this.p_quTicker, ! this.getTableOfDownloadedValues(Quotes.GetFirstQuoteDate(this.p_quTicker), ! Quotes.GetLastQuoteDate(this.p_quTicker))) && ! this.p_myForm.IsCheckCloseToCloseSelected) { ! this.updateCurrentStatusAdjustedCloseToCloseRatio("Changed at " + Quotes.DateWithDifferentCloseToClose); ! //stop } ! else { ! if(this.p_myForm.IsCheckCloseToCloseSelected) ! this.updateCurrentStatusAdjustedCloseToCloseRatio("OK"); ! else ! this.updateCurrentStatusAdjustedCloseToCloseRatio("Not Checked"); ! this.updateAdjustedClose(); ! this.updateCurrentStatusAdjustedClose("Updated!"); ! this.downloadedValuesFromSource = this.getTableOfDownloadedValues(Quotes.GetLastQuoteDate(this.p_quTicker), ! DateTime.Now); ! this.commitDownloadedValuesToDatabase(); ! } } ! else ! //download is executed { ! this.downloadedValuesFromSource = this.getTableOfDownloadedValues(); ! this.commitDownloadedValuesToDatabase(); ! this.updateCurrentStatusAdjustedClose("OK"); } } --- 329,464 ---- } ! // private void addTickerTo_gridDataSet() ! // { ! // ! // DataRow newRow = p_myForm.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ].NewRow(); ! // newRow[ 0 ] = p_quTicker; ! // newRow[ "currentState" ] = "Searching ..."; ! // newRow[ "databaseUpdated" ] = "No"; ! // newRow[ "adjustedClose"] = "..."; ! // newRow[ "adjCloseToCloseRatio"] = "..."; ! // try ! // { ! // p_myForm.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ].Rows.Add( newRow ); ! // p_myForm.labelNumberOfTickersToDownload.Text = ! // Convert.ToString(Convert.ToInt16(p_myForm.labelNumberOfTickersToDownload.Text) - 1); ! // } ! // catch (Exception ex) ! // { ! // string notUsed = ex.ToString(); ! // //MessageBox.Show( ex.ToString() ); ! // } ! // p_myForm.dataGrid1.Refresh(); ! // } private void resetStartDateIfNecessary() { ! if(this.checkBoxIsDicotomicSearchActivated == true) this.startDate = firstAvailableDateOnYahoo(this.INITIAL_DATE, this.endDate); } ! private void downloadTickers_downloadTickerBeforeFirstQuote() { ! this.endDate = Quotes.GetFirstQuoteDate(this.currentTicker); this.resetStartDateIfNecessary(); this.checkForNewAdjustedAndContinueOrStop(); } ! private bool isAdjustedCloseChanged(int numberOfRepeatedChecks) { bool response = false; + QuantProject.Data.DataTables.Quotes tickerQuotes = ! new QuantProject.Data.DataTables.Quotes(this.currentTicker); ! // for( ! int i = 1; ! // i < this.numberOfQuotesInDatabase && response == false; ! // i += this.numberOfQuotesInDatabase/numberOfRepeatedChecks) { DateTime dateToCheck = tickerQuotes.GetPrecedingDate(this.startDate, i); ! float adjustedCloseFromSource = float.MaxValue; ! try{ ! adjustedCloseFromSource = this.getAdjustedCloseFromSource(dateToCheck); ! this.httpWebResponse.Close(); ! } ! catch(Exception ex){ ! string notUsed = ex.ToString(); ! } ! response = ! Quotes.IsAdjustedCloseChanged( this.currentTicker, dateToCheck, ! adjustedCloseFromSource ); } + return response; } + private void checkForNewAdjustedAndContinueOrStop_dummy() + { + System.Threading.Thread.Sleep(500); + this.updateCurrentStatusAdjustedCloseToCloseRatio("OK"); + this.updateCurrentStatusAdjustedClose("Updated!"); + this.updateCurrentStatusAdjustedClose("OK"); + this.updateCurrentStatus("Yes"); + } + private void checkForNewAdjustedAndContinueOrStop_writeNoQuoteFoundMessageIfTheCase() + { + if(this.downloadedValuesFromSource.Rows.Count == 0) + this.updateCurrentStatus("No quote found"); + } + + private void checkForNewAdjustedAndContinueOrStop_downloadNewQuotesAndCommit() + { + DateTime lastQuoteDateInDB = Quotes.GetLastQuoteDate(this.currentTicker); + this.updateCurrentLastQuoteInDB(lastQuoteDateInDB.ToShortDateString()); + this.downloadedValuesFromSource = + this.getTableOfDownloadedValues( lastQuoteDateInDB , + DateTime.Now ); + this.checkForNewAdjustedAndContinueOrStop_writeNoQuoteFoundMessageIfTheCase(); + this.commitDownloadedValuesToDatabase(); + } + private void checkForNewAdjustedAndContinueOrStop() { try { ! bool adjCloseToCloseRatioChanged = false; ! if ( this.isCheckCloseToCloseSelected ) ! adjCloseToCloseRatioChanged = Quotes.IsAdjustedCloseToCloseRatioChanged( this.currentTicker, ! this.getTableOfDownloadedValues(Quotes.GetFirstQuoteDate(this.currentTicker), ! Quotes.GetLastQuoteDate(this.currentTicker))); ! if(this.isAdjustedCloseChanged(ConstantsProvider.NumberOfCheckToPerformOnAdjustedValues)) { this.updateCurrentStatusAdjustedClose("Changed!"); ! if( !this.isCheckCloseToCloseSelected ) ! //it is necessary to download values first for past adjusted values to be updated ! this.downloadedValuesFromSource = this.getTableOfDownloadedValues(Quotes.GetFirstQuoteDate(this.currentTicker), ! Quotes.GetLastQuoteDate(this.currentTicker)); ! //else values have been already downloaded for checking adjCloseToCloseRatios ! if (this.isCheckCloseToCloseSelected && adjCloseToCloseRatioChanged ) { ! this.updateCurrentStatusAdjustedCloseToCloseRatio("Changed at " + Quotes.DateWithDifferentCloseToClose); ! //stop downloading ticker if the close to close ratio has changed } ! else if ( this.isCheckCloseToCloseSelected && !adjCloseToCloseRatioChanged ) ! //adjusted close changed, but the close to close ratio ! // has not been changed { ! this.updateCurrentStatusAdjustedCloseToCloseRatio("OK"); ! this.updateAdjustedClose(); ! this.checkForNewAdjustedAndContinueOrStop_downloadNewQuotesAndCommit(); ! } ! else if ( !isCheckCloseToCloseSelected ) ! { ! this.updateCurrentStatusAdjustedCloseToCloseRatio("Not Checked"); ! this.updateAdjustedClose(); ! this.checkForNewAdjustedAndContinueOrStop_downloadNewQuotesAndCommit(); ! } } ! else//adjusted close has not been changed ! //download is executed directly { ! this.updateCurrentStatusAdjustedClose("Not changed"); ! this.checkForNewAdjustedAndContinueOrStop_downloadNewQuotesAndCommit(); } } *************** *** 383,391 **** foreach(DataRow row in this.downloadedValuesFromSource.Rows) { ! Quotes.UpdateAdjustedClose(this.p_quTicker, (DateTime)row[Quotes.Date], (float)row[Quotes.AdjustedClose]); } } ! private void downloadTickerForTheSelectedDate(DateTime date) { this.startDate = date; --- 474,483 ---- foreach(DataRow row in this.downloadedValuesFromSource.Rows) { ! Quotes.UpdateAdjustedClose(this.currentTicker, (DateTime)row[Quotes.Date], (float)row[Quotes.AdjustedClose]); } + this.updateCurrentStatusAdjustedClose("Updated"); } ! private void downloadTickers_downloadTickerForTheSelectedDate(DateTime date) { this.startDate = date; *************** *** 394,405 **** } ! private void downloadTickerAfterLastQuote() { ! this.startDate = Quotes.GetLastQuoteDate(this.p_quTicker); this.endDate = DateTime.Today; this.checkForNewAdjustedAndContinueOrStop(); } ! private float adjustedCloseFromSource(DateTime adjustedCloseDate) { string Line; --- 486,502 ---- } ! private void downloadTickers_downloadTickerAfterLastQuote() { ! this.startDate = Quotes.GetLastQuoteDate(this.currentTicker); ! this.updateCurrentLastQuoteInDB(this.startDate.ToShortDateString()); this.endDate = DateTime.Today; + //this.checkForNewAdjustedAndContinueOrStop_dummy(); + // this.resetStartDateIfNecessary(); + // this.downloadedValuesFromSource = this.getTableOfDownloadedValues(); + // this.commitDownloadedValuesToDatabase(); this.checkForNewAdjustedAndContinueOrStop(); } ! private float getAdjustedCloseFromSource(DateTime adjustedCloseDate) { string Line; *************** *** 417,436 **** private void commitDownloadedValuesToDatabase() { ! if(this.p_myForm.IsOverWriteYesSelected) { foreach(DataRow row in this.downloadedValuesFromSource.Rows) ! Quotes.Delete(this.p_quTicker, (DateTime)row["quDate"]); } ! if(this.p_myForm.IsComputeCloseToCloseRatioSelected) QuantProject.DataAccess.Tables.Quotes.ComputeCloseToCloseValues(this.downloadedValuesFromSource); this.adapter.OleDbDataAdapter.ContinueUpdateOnError = true; int rowsUpdated = this.adapter.OleDbDataAdapter.Update(this.downloadedValuesFromSource); if(rowsUpdated > 0) ! this.updateCurrentStatusDatabaseUpdated("YES"); else ! this.updateCurrentStatus("Not found updatable quotes"); } ! private void resetAndImportTicker() { this.resetStartDateIfNecessary(); --- 514,550 ---- private void commitDownloadedValuesToDatabase() { ! if(this.isOverWriteYesSelected) { foreach(DataRow row in this.downloadedValuesFromSource.Rows) ! Quotes.Delete(this.currentTicker, (DateTime)row["quDate"]); } ! if(this.isComputeCloseToCloseRatioSelected) QuantProject.DataAccess.Tables.Quotes.ComputeCloseToCloseValues(this.downloadedValuesFromSource); this.adapter.OleDbDataAdapter.ContinueUpdateOnError = true; int rowsUpdated = this.adapter.OleDbDataAdapter.Update(this.downloadedValuesFromSource); if(rowsUpdated > 0) ! this.updateCurrentStatusDatabaseUpdated("Added " + rowsUpdated.ToString() + " rows"); else ! this.updateCurrentStatusDatabaseUpdated("No row added"); } ! private void downloadTickers_refreshIndexOfCurrentTicker( int indexOfCurrentUpdatingTicker ) ! { ! lock(p_myForm.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ]) ! { ! p_myForm.IndexOfCurrentUpdatingTicker = indexOfCurrentUpdatingTicker; ! } ! } ! ! private void downloadTickers_refreshCurrentTicker( int indexOfCurrentUpdatingTicker ) ! { ! lock(p_myForm.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ]) ! { ! this.currentTicker = ! (string)p_myForm.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ].Rows[ indexOfCurrentUpdatingTicker ][0]; ! } ! } ! ! private void downloadTickers_resetAndImportTicker() { this.resetStartDateIfNecessary(); *************** *** 438,520 **** this.commitDownloadedValuesToDatabase(); } ! ! public void DownloadTicker() { ! // update grid in webdownloader form ! Cursor.Current = Cursors.WaitCursor; ! addTickerTo_gridDataSet(); ! this.numberOfQuotesInDatabase = Quotes.GetNumberOfQuotes(this.p_quTicker); ! if(this.numberOfQuotesInDatabase < 1) ! // ticker's quotes are downloaded for the first time ! { ! this.resetAndImportTicker(); ! } ! // in all these cases some ticker's quotes are in the database ! // and the options choosen by the user in the web downloader form are checked ! else if(this.p_myForm.IsOnlyAfterLastQuoteSelected && ! this.numberOfQuotesInDatabase >= 1) ! { ! this.downloadTickerAfterLastQuote(); ! } ! else if(this.p_myForm.IsBeforeAndAfterSelected && ! this.numberOfQuotesInDatabase >= 1) ! { ! this.downloadTickerBeforeFirstQuote(); ! this.downloadTickerAfterLastQuote(); ! } ! else if(this.p_myForm.IsOverWriteNoSelected && ! this.numberOfQuotesInDatabase >= 1) ! { ! this.resetStartDateIfNecessary(); ! this.checkForNewAdjustedAndContinueOrStop(); ! } ! else if(this.p_myForm.IsOverWriteYesSelected && ! this.numberOfQuotesInDatabase >= 1) ! { ! this.resetAndImportTicker(); ! } ! else if(this.p_myForm.IsSingleQuoteSelected) ! { ! if(Quotes.GetTickerQuotes(this.p_quTicker, ! this.p_myForm.SelectedDateForSingleQuote, ! this.p_myForm.SelectedDateForSingleQuote).Rows.Count == 0) ! //there's no quote for the ticker at the given date ! this.downloadTickerForTheSelectedDate(this.p_myForm.SelectedDateForSingleQuote); ! } ! Cursor.Current = Cursors.Default; ! ! // ticker's quotes are downloaded for the first time or ! // the user has chosen to download all quotes ! ! ! } ! public void DownloadTicker(DateTime startingDate) { ! this.INITIAL_DATE = startingDate; ! this.DownloadTicker(); } ! ! private bool isAtLeastOneDateAvailable(StreamReader streamReader, int daysToBeTested) { string Line; ! if(streamReader == null) ! return false; ! Line = streamReader.ReadLine(); ! // column headers are read ! Line = streamReader.ReadLine(); ! //actual values are read ! bool isOneDateAvailableInNextDaysToBeTested = false; ! int numDays = 1; ! while(numDays < daysToBeTested) ! { ! if(Line != null) ! { ! isOneDateAvailableInNextDaysToBeTested = true; ! numDays = daysToBeTested + 1; ! } ! numDays++; } ! return isOneDateAvailableInNextDaysToBeTested; } --- 552,637 ---- this.commitDownloadedValuesToDatabase(); } ! ! private void downloadTickers_setInfoCurrentStatusToDefault() { ! this.updateCurrentLastQuoteInDB("..."); ! this.updateCurrentStatus("..."); ! this.updateCurrentStatusDatabaseUpdated("..."); ! this.updateCurrentStatusAdjustedClose("..."); ! this.updateCurrentStatusAdjustedCloseToCloseRatio("..."); ! } ! ! ! public void DownloadTickers() { ! for( int i = 0; i < this.numOfTickersToDownload; i++ ) ! { ! this.downloadTickers_setInfoCurrentStatusToDefault(); ! this.downloadTickers_refreshCurrentTicker( i ); ! this.downloadTickers_refreshIndexOfCurrentTicker( i ); ! this.numberOfQuotesInDatabase = Quotes.GetNumberOfQuotes(this.currentTicker); ! if(this.numberOfQuotesInDatabase < 1) ! // ticker's quotes are downloaded for the first time ! { ! this.downloadTickers_resetAndImportTicker(); ! } ! // in all these cases some ticker's quotes are in the database ! // and the options choosen by the user in the web downloader form are checked ! else if(this.isOnlyAfterLastQuoteSelected && ! this.numberOfQuotesInDatabase >= 1) ! { ! this.downloadTickers_downloadTickerAfterLastQuote(); ! } ! else if(this.isOnlyAddMissingSelected && ! this.numberOfQuotesInDatabase >= 1) ! { ! this.resetStartDateIfNecessary(); ! this.checkForNewAdjustedAndContinueOrStop(); ! } ! else if(this.isOverWriteYesSelected && ! this.numberOfQuotesInDatabase >= 1) ! { ! this.downloadTickers_resetAndImportTicker(); ! } ! else if(this.isSingleQuoteSelected) ! { ! if(Quotes.GetTickerQuotes(this.currentTicker, ! this.selectedDateForSingleQuote, ! this.selectedDateForSingleQuote).Rows.Count == 0) ! //there's no quote for the ticker at the given date ! this.downloadTickers_downloadTickerForTheSelectedDate(this.p_myForm.SelectedDateForSingleQuote); ! } ! p_myForm.Invalidate(); ! Thread.Sleep(200); ! } ! this.p_myForm.DownloadingInProgress = false; } ! private bool isAtLeastOneDateAvailable(StreamReader streamReader, int daysToBeTested) { + bool returnValue = false; string Line; ! try{ ! Line = streamReader.ReadLine(); ! // column headers are read ! Line = streamReader.ReadLine(); ! //actual values are read ! ! int numDays = 1; ! while(numDays < daysToBeTested) ! { ! if(Line != null) ! { ! returnValue = true; ! numDays = daysToBeTested + 1; ! } ! numDays++; ! } } ! catch (Exception exception) ! { ! string notUsed = exception.ToString(); ! } ! return returnValue; } *************** *** 575,586 **** int f = endDate.Year; HttpWebRequest Req; - HttpWebResponse hwr; string url; url = "http:" + "//ichart.yahoo.com/table.csv?a=" ! + a + "&b=" + b + "&c=" + c +"&d=" + d + "&e=" + e + "&f=" + f + "&s=" + p_quTicker + "&y=0&g=d&ignore=.csv"; ! //url = "http:" + "//table.finance.yahoo.com/table.csv?a=" ! // + a + "&b=" + b + "&c=" + c +"&d=" + d + "&e=" + e + "&f=" + f + "&s=" + p_quTicker + "&y=0&g=d&ignore=.csv"; int numTrials = 1; ! while(numTrials < 5) { try --- 692,703 ---- int f = endDate.Year; HttpWebRequest Req; string url; url = "http:" + "//ichart.yahoo.com/table.csv?a=" ! + a + "&b=" + b + "&c=" + c +"&d=" + d + "&e=" + e + "&f=" + f + "&s=" + currentTicker + "&y=0&g=d&ignore=.csv"; ! // url = "http:" + "//table.finance.yahoo.com/table.csv?a=" ! // + a + "&b=" + b + "&c=" + c +"&d=" + d + "&e=" + e + "&f=" + f + "&s=" + currentTicker + "&y=0&g=d&ignore=.csv"; int numTrials = 1; ! int maxNumTrials = 3; ! while( numTrials < maxNumTrials ) { try *************** *** 589,604 **** Req.Method = "GET"; Req.Timeout = ConstantsProvider.TimeOutValue; ! hwr = (HttpWebResponse)Req.GetResponse(); ! this.stream = hwr.GetResponseStream(); this.streamReader = new StreamReader(this.stream); ! numTrials = 6; } - catch (Exception exception) { string notUsed = exception.ToString(); numTrials++; ! if(numTrials==5) ! FaultyTickers.AddOrUpdate(this.p_quTicker, DateTime.Now.Date); // to add faulty tickers to database table //throw new Exception("It has not been possible to set streams from Yahoo: \n\n" + --- 706,720 ---- Req.Method = "GET"; Req.Timeout = ConstantsProvider.TimeOutValue; ! this.httpWebResponse = (HttpWebResponse)Req.GetResponse(); ! this.stream = this.httpWebResponse.GetResponseStream(); this.streamReader = new StreamReader(this.stream); ! numTrials = maxNumTrials; } catch (Exception exception) { string notUsed = exception.ToString(); numTrials++; ! if( numTrials == maxNumTrials ) ! FaultyTickers.AddOrUpdate(this.currentTicker, DateTime.Now.Date); // to add faulty tickers to database table //throw new Exception("It has not been possible to set streams from Yahoo: \n\n" + *************** *** 616,619 **** --- 732,741 ---- bool response = false; response = this.isAtLeastOneDateAvailable(this.streamReader,daysOfTheTimeWindow ); + if( response == true ) + this.updateCurrentStatus("Found quotes from " + initialDateOfTheTimeWindow.ToShortDateString() + + " to " + initialDateOfTheTimeWindow.AddDays(daysOfTheTimeWindow).ToShortDateString() ); + else // response == false + this.updateCurrentStatus("No quote found"); + return response; } |
|
From: Marco M. <mi...@us...> - 2008-11-30 22:42:42
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/UserForms In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv28110/Downloader/OpenTickDownloader/UserForms Modified Files: OTWebDownloader.cs Log Message: HistoricalDataProvider has been replaced by HistoricalQuotesProvider Index: OTWebDownloader.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/UserForms/OTWebDownloader.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** OTWebDownloader.cs 22 Aug 2008 22:57:43 -0000 1.5 --- OTWebDownloader.cs 30 Nov 2008 22:42:37 -0000 1.6 *************** *** 360,364 **** 0}); this.numberOfBars.Name = "numberOfBars"; ! this.numberOfBars.Size = new System.Drawing.Size(38, 20); this.numberOfBars.TabIndex = 24; this.numberOfBars.Value = new decimal(new int[] { --- 360,364 ---- 0}); this.numberOfBars.Name = "numberOfBars"; ! this.numberOfBars.Size = new System.Drawing.Size(59, 20); this.numberOfBars.TabIndex = 24; this.numberOfBars.Value = new decimal(new int[] { |
|
From: Marco M. <mi...@us...> - 2008-11-30 22:42:42
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/QuotesEditor/RangeToRange In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv28110/Downloader/QuotesEditor/RangeToRange Modified Files: RangeToRangeChart.cs Log Message: HistoricalDataProvider has been replaced by HistoricalQuotesProvider Index: RangeToRangeChart.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/QuotesEditor/RangeToRange/RangeToRangeChart.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RangeToRangeChart.cs 27 Aug 2004 21:41:24 -0000 1.2 --- RangeToRangeChart.cs 30 Nov 2008 22:42:38 -0000 1.3 *************** *** 2,6 **** using System.Drawing; using QuantProject.ADT.Histories; ! using QuantProject.Data.DataProviders; using QuantProject.Presentation.Charting; --- 2,6 ---- using System.Drawing; using QuantProject.ADT.Histories; ! using QuantProject.Data.DataProviders.Quotes; using QuantProject.Presentation.Charting; *************** *** 21,27 **** protected override void addHistories() { ! History lowHistory = HistoricalDataProvider.GetLowHistory( ((QuotesEditor)this.FindForm()).Ticker ); this.add( lowHistory , Color.Green ); ! History highHistory = HistoricalDataProvider.GetHighHistory( ((QuotesEditor)this.FindForm()).Ticker ); this.add( highHistory , Color.Blue ); } --- 21,27 ---- protected override void addHistories() { ! History lowHistory = HistoricalQuotesProvider.GetLowHistory( ((QuotesEditor)this.FindForm()).Ticker ); this.add( lowHistory , Color.Green ); ! History highHistory = HistoricalQuotesProvider.GetHighHistory( ((QuotesEditor)this.FindForm()).Ticker ); this.add( highHistory , Color.Blue ); } |
|
From: Marco M. <mi...@us...> - 2008-11-30 22:42:42
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/OTManagement In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv28110/Downloader/OpenTickDownloader/OTManagement Modified Files: OTManager.cs Log Message: HistoricalDataProvider has been replaced by HistoricalQuotesProvider Index: OTManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/OTManagement/OTManager.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** OTManager.cs 20 Jul 2008 20:36:44 -0000 1.2 --- OTManager.cs 30 Nov 2008 22:42:37 -0000 1.3 *************** *** 309,312 **** --- 309,313 ---- { OTManager.oTClient.addHost( "feed1.opentick.com" , 10010 ); + //OTManager.oTClient.addHost( "delayed1.opentick.com" , 10010 ); // string username = // System.Configuration.ConfigurationManager.AppSettings[ |
|
From: Marco M. <mi...@us...> - 2008-11-30 22:42:41
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/QuotesEditor In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv28110/Downloader/QuotesEditor Modified Files: QuotesChart.cs QuotesEditor.cs Log Message: HistoricalDataProvider has been replaced by HistoricalQuotesProvider Index: QuotesChart.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/QuotesEditor/QuotesChart.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** QuotesChart.cs 3 Apr 2005 00:02:53 -0000 1.6 --- QuotesChart.cs 30 Nov 2008 22:42:38 -0000 1.7 *************** *** 26,30 **** using NPlot.Windows; using QuantProject.ADT.Histories; ! using QuantProject.Data.DataProviders; using QuantProject.Presentation.Charting; --- 26,30 ---- using NPlot.Windows; using QuantProject.ADT.Histories; ! using QuantProject.Data.DataProviders.Quotes; using QuantProject.Presentation.Charting; *************** *** 45,49 **** this.ticker = value; this.Clear(); ! this.Add( HistoricalDataProvider.GetAdjustedCloseHistory( this.ticker ) ); } } --- 45,49 ---- this.ticker = value; this.Clear(); ! this.Add( HistoricalQuotesProvider.GetAdjustedCloseHistory( this.ticker ) ); } } Index: QuotesEditor.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/QuotesEditor/QuotesEditor.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** QuotesEditor.cs 29 Mar 2005 14:57:30 -0000 1.10 --- QuotesEditor.cs 30 Nov 2008 22:42:38 -0000 1.11 *************** *** 10,14 **** using QuantProject.Business.Validation; using QuantProject.Data; ! using QuantProject.Data.DataProviders; using QuantProject.Data.DataTables; --- 10,14 ---- using QuantProject.Business.Validation; using QuantProject.Data; ! using QuantProject.Data.DataProviders.Quotes; using QuantProject.Data.DataTables; *************** *** 117,121 **** private void getTickerQuotes() { ! this.tickerQuotes = HistoricalDataProvider.GetTickerQuotes( this.textBoxTicker.Text ); } --- 117,121 ---- private void getTickerQuotes() { ! this.tickerQuotes = HistoricalQuotesProvider.GetTickerQuotes( this.textBoxTicker.Text ); } |
|
From: Marco M. <mi...@us...> - 2008-11-30 22:42:41
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/QuotesEditor/CloseToClose In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv28110/Downloader/QuotesEditor/CloseToClose Modified Files: CloseToCloseChart.cs Log Message: HistoricalDataProvider has been replaced by HistoricalQuotesProvider Index: CloseToCloseChart.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/QuotesEditor/CloseToClose/CloseToCloseChart.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CloseToCloseChart.cs 29 Mar 2005 14:57:31 -0000 1.6 --- CloseToCloseChart.cs 30 Nov 2008 22:42:37 -0000 1.7 *************** *** 26,30 **** using QuantProject.ADT; using QuantProject.ADT.Histories; ! using QuantProject.Data.DataProviders; using QuantProject.Presentation.Charting; --- 26,30 ---- using QuantProject.ADT; using QuantProject.ADT.Histories; ! using QuantProject.Data.DataProviders.Quotes; using QuantProject.Presentation.Charting; *************** *** 42,46 **** protected override void addHistories() { ! History lowHistory = HistoricalDataProvider.GetCloseHistory( ((QuotesEditor)this.FindForm()).Ticker ); this.add( lowHistory , Color.Green ); } --- 42,46 ---- protected override void addHistories() { ! History lowHistory = HistoricalQuotesProvider.GetCloseHistory( ((QuotesEditor)this.FindForm()).Ticker ); this.add( lowHistory , Color.Green ); } |
|
From: Marco M. <mi...@us...> - 2008-11-30 22:40:13
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv27871/b1_ADT Modified Files: ConstantsProvider.cs Log Message: Changed initial parameters for the yahoo quotes downloader Index: ConstantsProvider.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/ConstantsProvider.cs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** ConstantsProvider.cs 29 Aug 2007 10:08:39 -0000 1.20 --- ConstantsProvider.cs 30 Nov 2008 22:40:09 -0000 1.21 *************** *** 17,22 **** public static int PrecedingDaysForVisualValidation = 20; public static int DaysForMovingAverageForSuspiciousRatioValidation = 20; ! public static DateTime InitialDateTimeForDownload = new DateTime(1985,1,1); ! public static int TimeOutValue = 15000; public static int NumberOfCheckToPerformOnAdjustedValues = 3; public static double MaxDifferenceForAdjustedValues = 0.01; --- 17,22 ---- public static int PrecedingDaysForVisualValidation = 20; public static int DaysForMovingAverageForSuspiciousRatioValidation = 20; ! public static DateTime InitialDateTimeForDownload = new DateTime(1995,1,1); ! public static int TimeOutValue = 10000; public static int NumberOfCheckToPerformOnAdjustedValues = 3; public static double MaxDifferenceForAdjustedValues = 0.01; |
|
From: Glauco S. <gla...@us...> - 2008-11-24 21:06:58
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv27874/b4_Business/a05_Timing Modified Files: Timer.cs Log Message: the property IsDone's meaning has been slightly changed (now the timer is considered to be done when the script stops it, also) Index: Timer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing/Timer.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Timer.cs 20 Nov 2008 20:44:14 -0000 1.2 --- Timer.cs 24 Nov 2008 21:06:49 -0000 1.3 *************** *** 49,53 **** public bool IsDone { ! get { return this.isDone(); } } #endregion IsDone --- 49,53 ---- public bool IsDone { ! get { return ( this.hasTheTimerBeenStopped || this.isDone() ); } } #endregion IsDone |
|
From: Glauco S. <gla...@us...> - 2008-11-24 21:05:22
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv27757/b2_DataAccess Modified Files: SQLBuilder.cs Log Message: bug fixed: now the script works with an English OS Index: SQLBuilder.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/SQLBuilder.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SQLBuilder.cs 12 Nov 2008 20:37:28 -0000 1.3 --- SQLBuilder.cs 24 Nov 2008 21:05:12 -0000 1.4 *************** *** 125,129 **** { string filterForDailyTime = ! "(Format([baDateTimeForOpen],'hh:mm:ss')" + SQLBuilder.getSqlStringForComparisonOperator( sqlComparisonOperator ) + SQLBuilder.GetTimeConstant( time ) + ")"; --- 125,129 ---- { string filterForDailyTime = ! "(Format([baDateTimeForOpen],'hh.mm.ss')" + SQLBuilder.getSqlStringForComparisonOperator( sqlComparisonOperator ) + SQLBuilder.GetTimeConstant( time ) + ")"; |
|
From: Glauco S. <gla...@us...> - 2008-11-24 21:04:42
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv27660/b7_Scripts/WalkForwardTesting/PairsTrading Modified Files: PairsTradingMain.cs Log Message: minor changes to the script's parameters Index: PairsTradingMain.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/PairsTradingMain.cs,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** PairsTradingMain.cs 20 Nov 2008 20:56:34 -0000 1.22 --- PairsTradingMain.cs 24 Nov 2008 21:04:33 -0000 1.23 *************** *** 124,128 **** string tickersGroupId = "SP500"; // uncomment the following line for a faster script ! tickersGroupId = "fastTest"; // IEligiblesSelector eligiblesSelector = --- 124,128 ---- string tickersGroupId = "SP500"; // uncomment the following line for a faster script ! // tickersGroupId = "fastTest"; // IEligiblesSelector eligiblesSelector = *************** *** 276,282 **** // uncomment the following two lines for a faster script firstDateTime = new DateTime( 2006 , 2 , 1 ); ! lastDateTime = new DateTime( 2006 , 2 , 15 ); ! double maxRunningHours = 0.05; EndOfDayStrategyBackTester endOfDayStrategyBackTester = --- 276,282 ---- // uncomment the following two lines for a faster script firstDateTime = new DateTime( 2006 , 2 , 1 ); ! lastDateTime = new DateTime( 2006 , 2 , 12 ); ! double maxRunningHours = 1; EndOfDayStrategyBackTester endOfDayStrategyBackTester = *************** *** 302,306 **** protected override string getCustomSmallTextForFolderName() { ! return "pairsTrdng"; } --- 302,306 ---- protected override string getCustomSmallTextForFolderName() { ! return "pairsTrdngIntrdy_13_14_15"; } |
|
From: Glauco S. <gla...@us...> - 2008-11-24 21:03:54
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv27574/b4_Business/a2_Strategies Modified Files: EndOfDayStrategyBackTester.cs Log Message: the code to manage the last date time of the script has been slightly changed Index: EndOfDayStrategyBackTester.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/EndOfDayStrategyBackTester.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** EndOfDayStrategyBackTester.cs 22 Nov 2008 18:26:20 -0000 1.14 --- EndOfDayStrategyBackTester.cs 24 Nov 2008 21:03:42 -0000 1.15 *************** *** 62,66 **** private DateTime startingTimeForScript; private Timer timer; ! private DateTime actualLastDateTime; private Account account; private AccountReport accountReport; --- 62,66 ---- private DateTime startingTimeForScript; private Timer timer; ! private DateTime lastDateTimeThrownOutByTheTimer; private Account account; private AccountReport accountReport; *************** *** 96,100 **** { this.checkThisPropertyRequiresBacktestIsCompleted(); ! return this.actualLastDateTime; } } --- 96,100 ---- { this.checkThisPropertyRequiresBacktestIsCompleted(); ! return this.lastDateTimeThrownOutByTheTimer; } } *************** *** 142,146 **** ExtendedDateTime.GetShortDescriptionForFileName( this.firstDateTime ) + "_to_" + ! ExtendedDateTime.GetShortDescriptionForFileName( this.actualLastDateTime ) + "_annlRtrn_" + this.AccountReport.Summary.AnnualSystemPercentageReturn.FormattedValue + "_maxDD_" + this.AccountReport.Summary.MaxEquityDrawDown.FormattedValue + --- 142,146 ---- ExtendedDateTime.GetShortDescriptionForFileName( this.firstDateTime ) + "_to_" + ! ExtendedDateTime.GetShortDescriptionForFileName( this.lastDateTimeThrownOutByTheTimer ) + "_annlRtrn_" + this.AccountReport.Summary.AnnualSystemPercentageReturn.FormattedValue + "_maxDD_" + this.AccountReport.Summary.MaxEquityDrawDown.FormattedValue + *************** *** 196,200 **** this.backTestLog = new BackTestLog( backTestID , firstDateTime , lastDateTime , benchmark ); ! this.actualLastDateTime = DateTime.MinValue; this.realDateTimeWhenTheBackTestIsStopped = DateTime.MinValue; } --- 196,200 ---- this.backTestLog = new BackTestLog( backTestID , firstDateTime , lastDateTime , benchmark ); ! this.lastDateTimeThrownOutByTheTimer = DateTime.MinValue; this.realDateTimeWhenTheBackTestIsStopped = DateTime.MinValue; } *************** *** 298,305 **** private void completeTheScript() { this.realDateTimeWhenTheBackTestIsStopped = DateTime.Now; this.accountReport = this.account.CreateReport( "" , 1 , ! this.actualLastDateTime , this.benchmark.Ticker , this.historicalMarketValueProvider ); this.accountReport.Name = this.Description; --- 298,306 ---- private void completeTheScript() { + this.timer.Stop(); this.realDateTimeWhenTheBackTestIsStopped = DateTime.Now; this.accountReport = this.account.CreateReport( "" , 1 , ! this.lastDateTimeThrownOutByTheTimer , this.benchmark.Ticker , this.historicalMarketValueProvider ); this.accountReport.Name = this.Description; *************** *** 350,359 **** #endregion isTimeToStop ! #region stopTheScript private void stopTheScript( DateTime currentDateTime ) { // this.actualLastDateTime = // ExtendedDateTime.Min( this.lastDateTime , currentDateTime ); ! this.actualLastDateTime = ExtendedDateTime.Min( this.lastDateTime , this.timer.GetCurrentDateTime() ); --- 351,360 ---- #endregion isTimeToStop ! #region stopTheScriptIfTheCase private void stopTheScript( DateTime currentDateTime ) { // this.actualLastDateTime = // ExtendedDateTime.Min( this.lastDateTime , currentDateTime ); ! this.lastDateTimeThrownOutByTheTimer = ExtendedDateTime.Min( this.lastDateTime , this.timer.GetCurrentDateTime() ); *************** *** 378,382 **** // } // } ! #endregion stopTheScript private void notifyProgress( --- 379,383 ---- // } // } ! #endregion stopTheScriptIfTheCase private void notifyProgress( *************** *** 399,402 **** --- 400,404 ---- // ( ( IEndOfDayTimer )sender ).GetCurrentTime(); // DateTime currentDateTime = currentEndOfDayDateTime.DateTime; + this.lastDateTimeThrownOutByTheTimer = dateTime; if ( this.isTimeToStop( dateTime ) ) this.stopTheScript( dateTime ); |
|
From: Marco M. <mi...@us...> - 2008-11-23 17:18:42
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv16130/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator Modified Files: PVO_OTCMain.cs Log Message: Updated parameters for the PVO_OTCMain (minor changes) Index: PVO_OTCMain.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/PVO_OTCMain.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** PVO_OTCMain.cs 12 Nov 2008 20:42:39 -0000 1.9 --- PVO_OTCMain.cs 23 Nov 2008 17:18:36 -0000 1.10 *************** *** 63,68 **** public PVO_OTCMain() { ! this.benchmark = new Benchmark( "^GSPC" ); ! this.historicalQuoteProvider = new HistoricalAdjustedQuoteProvider(); --- 63,68 ---- public PVO_OTCMain() { ! //this.benchmark = new Benchmark( "^GSPC" ); ! this.benchmark = new Benchmark( "MSFTHour" ); this.historicalQuoteProvider = new HistoricalAdjustedQuoteProvider(); *************** *** 86,89 **** --- 86,97 ---- int maxNumberOfMostLiquidTickersToBeChosen = 150; int numDaysForVolatility = 10; + + // IEligiblesSelector eligiblesSelector = + // new ByPriceMostLiquidQuotedAtEachDateTime( + // tickersGroupId , temporizedGroup , + // maxNumberOfEligiblesToBeChosen , + // numDaysForAverageRawOpenPriceComputation , + // minPrice , maxPrice, this.benchmark.Ticker ); + // IEligiblesSelector eligiblesSelector = new ByPriceMostLiquidLessVolatileOTCAlwaysQuoted( *************** *** 157,170 **** protected override IStrategyForBacktester getStrategyForBacktester() { ! int inSampleDays = 25; // uncomment the following line for a faster script //inSampleDays = 50; ! int numDaysBetweenEachOptimization = 1; int numOfClosingsBeforeExit = 0; int minNumOfEligiblesForValidOptimization = 20; ! double oversoldThreshold = 0.0025; ! double overboughtThreshold = 0.0025; ! double oversoldThresholdMAX = 0.05; ! double overboughtThresholdMAX = 0.05; IStrategyForBacktester strategyForBacktester // = new PVO_OTCStrategyLessCorrelated(eligiblesSelector ,inSampleChooser , --- 165,179 ---- protected override IStrategyForBacktester getStrategyForBacktester() { ! //int inSampleDays = 90; ! int inSampleDays = 6; // uncomment the following line for a faster script //inSampleDays = 50; ! int numDaysBetweenEachOptimization = 5; int numOfClosingsBeforeExit = 0; int minNumOfEligiblesForValidOptimization = 20; ! double oversoldThreshold = 0.0075; ! double overboughtThreshold = 0.0075; ! double oversoldThresholdMAX = 0.02; ! double overboughtThresholdMAX = 0.02; IStrategyForBacktester strategyForBacktester // = new PVO_OTCStrategyLessCorrelated(eligiblesSelector ,inSampleChooser , *************** *** 189,195 **** double cashToStart = 25000; ! DateTime firstDateTime = new DateTime( 2004 , 1 , 1 ); ! DateTime lastDateTime = new DateTime( 2008 , 4, 28 ); ! double maxRunningHours = 10; HistoricalMarketValueProvider quoteProviderForBackTester = this.historicalQuoteProvider; --- 198,204 ---- double cashToStart = 25000; ! DateTime firstDateTime = new DateTime( 2007 , 1 , 1 ); ! DateTime lastDateTime = new DateTime( 2007 , 1, 31 ); ! double maxRunningHours = 0.40; HistoricalMarketValueProvider quoteProviderForBackTester = this.historicalQuoteProvider; |
|
From: Marco M. <mi...@us...> - 2008-11-23 17:15:50
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv15946/b7_Scripts Modified Files: Scripts_SD.csproj Log Message: Added script files for the PVO strategy intraday; removed from the project old scripts' files. Index: Scripts_SD.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/Scripts_SD.csproj,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** Scripts_SD.csproj 17 Nov 2008 19:47:51 -0000 1.33 --- Scripts_SD.csproj 23 Nov 2008 17:15:43 -0000 1.34 *************** *** 47,52 **** </ItemGroup> <ItemGroup> - <Compile Include="ArbitrageTesting\OverReactionHypothesis\DoubleOverReaction_OTC\EndOfDayTimerHandlerDOR_OTC.cs" /> - <Compile Include="ArbitrageTesting\OverReactionHypothesis\DoubleOverReaction_OTC\RunDOR_OTC.cs" /> <Compile Include="AssemblyInfo.cs" /> <Compile Include="EvaluatingOptimizationTechnique\TechnicalAnalysis\RunTestingOptimizationExtremeCounterTrend.cs" /> --- 47,50 ---- *************** *** 87,90 **** --- 85,90 ---- <Compile Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\PVOPositionsStatus.cs" /> <Compile Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\PVOStrategy.cs" /> + <Compile Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\PVOStrategyIntraday.cs" /> + <Compile Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\PVOStrategyIntradayMain.cs" /> <Compile Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\PVO_CTOLogItem.cs" /> <Compile Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\PVO_CTOMain.cs" /> *************** *** 248,254 **** <Compile Include="WalkForwardTesting\WalkForwardLag\WFLagGenomesDebugger\WFLagRunGenomesDebugger.cs" /> <Compile Include="WalkForwardTesting\WalkForwardLag\WFLagGenomesDebugger\WFLagSharpeRatioComputer.cs" /> - <Compile Include="TechnicalAnalysisTesting\TrendFollowing\ImmediateTrendFollower\EndOfDayTimerHandlerITF.cs" /> - <Compile Include="TechnicalAnalysisTesting\TrendFollowing\ImmediateTrendFollower\GenomeManagerITF.cs" /> - <Compile Include="TechnicalAnalysisTesting\TrendFollowing\ImmediateTrendFollower\RunImmediateTrendFollower.cs" /> <Compile Include="WalkForwardTesting\WalkForwardLag\WFLagGenomeManagerWithWeights.cs" /> <Compile Include="WalkForwardTesting\WalkForwardLag\WFLagWeightedPositions.cs" /> --- 248,251 ---- *************** *** 268,279 **** <Compile Include="WalkForwardTesting\WalkForwardLag\WFLagNewChosenPositionsEventArgs.cs" /> <Compile Include="WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\IWFLagWeightedPositionsChooser.cs" /> - <Compile Include="ArbitrageTesting\OverReactionHypothesis\SimpleOHTest\EndOfDayTimerHandlerSimpleOHTest.cs" /> - <Compile Include="ArbitrageTesting\OverReactionHypothesis\SimpleOHTest\RunSimpleOHTest.cs" /> - <Compile Include="TechnicalAnalysisTesting\TrendFollowing\BestAndWorst\EndOfDayTimerHandlerBWFollower.cs" /> - <Compile Include="TechnicalAnalysisTesting\TrendFollowing\BestAndWorst\RunBestAndWorstFollower.cs" /> <Compile Include="TickerSelectionTesting\RunEfficientOTC_WorstAtNightPortfolio.cs" /> <Compile Include="TickerSelectionTesting\EndOfDayTimerHandlerOTC_WorstAtNight.cs" /> - <Compile Include="ArbitrageTesting\OverReactionHypothesis\DoubleOverReaction_WeekEndBounce\EndOfDayTimerHandlerDOR_WeekEndBounce.cs" /> - <Compile Include="ArbitrageTesting\OverReactionHypothesis\DoubleOverReaction_WeekEndBounce\RunDOR_WeekEndBounce.cs" /> <Compile Include="TickerSelectionTesting\EndOfDayTimerHandlerCTO_WorstAtDay.cs" /> <Compile Include="TickerSelectionTesting\RunEfficientCTO_WorstAtDayPortfolio.cs" /> --- 265,270 ---- *************** *** 281,289 **** <Compile Include="WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio\WFLagGenomeManagerForFixedPortfolioWithNormalDrivingAndPortfolio.cs" /> <Compile Include="WalkForwardTesting\WalkForwardLag\WFLagMeaningForUndecodableGenomes.cs" /> - <Compile Include="TechnicalAnalysisTesting\TrendFollowing\OTC_CTOTrendFollower\EndOfDayTimerHandlerOTC_CTOTrendFollower.cs" /> - <Compile Include="TechnicalAnalysisTesting\TrendFollowing\OTC_CTOTrendFollower\RunEfficientOTC_CTOTrendFollower.cs" /> </ItemGroup> <ItemGroup> - <Folder Include="ArbitrageTesting\OverReactionHypothesis\DoubleOverReaction_OTC" /> <Folder Include="EvaluatingOptimizationTechnique\" /> <Folder Include="EvaluatingOptimizationTechnique\EfficientPortfolio\" /> --- 272,277 ---- *************** *** 344,349 **** <Folder Include="WalkForwardTesting\WalkForwardLag\WFLagLogDebugger" /> <Folder Include="WalkForwardTesting\WalkForwardLag\WFLagGenomesDebugger" /> - <Folder Include="TechnicalAnalysisTesting\TrendFollowing" /> - <Folder Include="TechnicalAnalysisTesting\TrendFollowing\ImmediateTrendFollower" /> <Folder Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators" /> <Folder Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator" /> --- 332,335 ---- *************** *** 352,361 **** <Folder Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\BiasedPVO" /> <Folder Include="WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers" /> - <Folder Include="ArbitrageTesting\OverReactionHypothesis" /> - <Folder Include="ArbitrageTesting\OverReactionHypothesis\SimpleOHTest" /> - <Folder Include="TechnicalAnalysisTesting\TrendFollowing\BestAndWorst" /> - <Folder Include="ArbitrageTesting\OverReactionHypothesis\DoubleOverReaction_WeekEndBounce" /> <Folder Include="WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio" /> - <Folder Include="TechnicalAnalysisTesting\TrendFollowing\OTC_CTOTrendFollower" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> --- 338,342 ---- |
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv15842/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator Added Files: PVOStrategyIntraday.cs PVOStrategyIntradayMain.cs Log Message: Added script files for the PVO strategy intraday --- NEW FILE: PVOStrategyIntraday.cs --- /* QuantProject - Quantitative Finance Library PVOStrategyIntraday.cs Copyright (C) 2008 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Data; using System.Collections; using QuantProject.ADT; using QuantProject.ADT.Histories; using QuantProject.ADT.Messaging; using QuantProject.ADT.Timing; using QuantProject.Business.Financial.Accounting; using QuantProject.Business.Financial.Instruments; using QuantProject.Business.Financial.Ordering; using QuantProject.Business.Timing; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.InSample; using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Strategies.Logging; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Strategies.ReturnsManagement.Time; using QuantProject.Business.DataProviders; using QuantProject.Business.Strategies.TickersRelationships; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.Optimizing.Decoding; using QuantProject.Data; using QuantProject.Data.DataProviders; using QuantProject.Data.Selectors; using QuantProject.Data.DataTables; using QuantProject.ADT.Optimizing.Genetic; using QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator.InSampleChoosers; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; using QuantProject.Scripts.WalkForwardTesting.LinearCombination; namespace QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator { /// <summary> /// Implements MarketOpenEventHandler and MarketCloseEventHandler /// These handlers contain the core strategy for the Portfolio Value /// Oscillator /// </summary> [Serializable] public class PVOStrategyIntraday : IStrategyForBacktester { public event NewLogItemEventHandler NewLogItem; public event NewMessageEventHandler NewMessage; //initialized by the constructor protected int inSampleDays; protected int numDaysBetweenEachOptimization; protected IInSampleChooser inSampleChooser; protected IEligiblesSelector eligiblesSelector; protected Benchmark benchmark; protected HistoricalMarketValueProvider historicalMarketValueProviderForInSample; protected HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample; protected double oversoldThreshold; protected double overboughtThreshold; protected double oversoldThresholdMAX; protected double overboughtThresholdMAX; //initialized after constructor's call protected int numDaysElapsedSinceLastOptimization; protected ReturnsManager returnsManager; protected TestingPositions[] chosenPVOPositions; //chosen in sample: these are the eligible positions for out //of sample testing protected PVOPositions positionsForOutOfSample; protected PVOPositionsStatus positionsForOutOfSampleStatus; protected DateTime lastTimerDateTimeAfterLastExit; protected DateTime lastOptimizationDateTime; protected Account account; public Account Account { get { return this.account; } set { this.account = value; } } private int minimumNumberOfEligiblesForValidOptimization; // private bool optimalPositionsHaveBeenUpdated; protected Time timeForCheckingCrossingThresholds_begin; protected Time timeForCheckingCrossingThresholds_end; protected Time timeForEntry; protected Time timeForExit; private string description_GetDescriptionForChooser() { if(this.inSampleChooser == null) return "ConstantChooser"; else return this.inSampleChooser.Description; } public string Description { get { string description = "PVO_OTC\n" + "Tickers_" + "2\n" + "_inSampleDays_" + this.inSampleDays.ToString() + "\n" + this.eligiblesSelector.Description + "\n" + "oversoldThreshold_" + this.oversoldThreshold.ToString() + "\n" + "overboughtThreshold_" + this.overboughtThreshold.ToString() + "\n" + this.description_GetDescriptionForChooser() + "\n" + "Optimization each " + this.numDaysBetweenEachOptimization.ToString() + " days"; return description; } } public bool StopBacktestIfMaxRunningHoursHasBeenReached { get { return true; } } private void pvoStrategyIntraday_checkTimeParameters() { ;// to do } private void pvoStrategyIntraday(IEligiblesSelector eligiblesSelector, int minimumNumberOfEligiblesForValidOptimization, int inSampleDays, Benchmark benchmark, int numDaysBetweenEachOptimization, double oversoldThreshold, double overboughtThreshold, double oversoldThresholdMAX, double overboughtThresholdMAX, HistoricalMarketValueProvider historicalMarketValueProviderForInSample, HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample, Time timeForCheckingCrossingThresholds_begin, Time timeForCheckingCrossingThresholds_end, Time timeForEntry, Time timeForExit) { this.eligiblesSelector = eligiblesSelector; this.minimumNumberOfEligiblesForValidOptimization = minimumNumberOfEligiblesForValidOptimization; this.inSampleDays = inSampleDays; this.benchmark = benchmark; this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; this.oversoldThreshold = oversoldThreshold; this.overboughtThreshold = overboughtThreshold; this.oversoldThresholdMAX = oversoldThresholdMAX; this.overboughtThresholdMAX = overboughtThresholdMAX; this.historicalMarketValueProviderForInSample = historicalMarketValueProviderForInSample; this.historicalMarketValueProviderForOutOfSample = historicalMarketValueProviderForOutOfSample; this.timeForCheckingCrossingThresholds_begin = timeForCheckingCrossingThresholds_begin; this.timeForCheckingCrossingThresholds_end = timeForCheckingCrossingThresholds_end; this.timeForEntry = timeForEntry; this.timeForExit = timeForExit; this.lastOptimizationDateTime = DateTime.MinValue; this.pvoStrategyIntraday_checkTimeParameters(); // this.optimalPositionsHaveBeenUpdated = false; } public PVOStrategyIntraday(IEligiblesSelector eligiblesSelector, int minimumNumberOfEligiblesForValidOptimization, IInSampleChooser inSampleChooser, int inSampleDays, Benchmark benchmark, int numDaysBetweenEachOptimization, double oversoldThreshold, double overboughtThreshold, double oversoldThresholdMAX, double overboughtThresholdMAX, HistoricalMarketValueProvider historicalMarketValueProviderForInSample, HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample, Time timeForCheckingCrossingThresholds_begin, Time timeForCheckingCrossingThresholds_end, Time timeForEntry, Time timeForExit) { this.pvoStrategyIntraday(eligiblesSelector, minimumNumberOfEligiblesForValidOptimization, inSampleDays , benchmark , numDaysBetweenEachOptimization , oversoldThreshold, overboughtThreshold, oversoldThresholdMAX, overboughtThresholdMAX, historicalMarketValueProviderForInSample, historicalMarketValueProviderForOutOfSample, timeForCheckingCrossingThresholds_begin, timeForCheckingCrossingThresholds_end, timeForEntry, timeForExit); this.inSampleChooser = inSampleChooser; } public PVOStrategyIntraday(IEligiblesSelector eligiblesSelector, int minimumNumberOfEligiblesForValidOptimization, IInSampleChooser inSampleChooser, int inSampleDays, Benchmark benchmark, int numDaysBetweenEachOptimization, double oversoldThreshold, double overboughtThreshold, HistoricalMarketValueProvider historicalMarketValueProviderForInSample, HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample, Time timeForCheckingCrossingThresholds_begin, Time timeForCheckingCrossingThresholds_end, Time timeForEntry, Time timeForExit) { this.pvoStrategyIntraday(eligiblesSelector, minimumNumberOfEligiblesForValidOptimization, inSampleDays , benchmark , numDaysBetweenEachOptimization , oversoldThreshold, overboughtThreshold, double.MaxValue, double.MaxValue, historicalMarketValueProviderForInSample, historicalMarketValueProviderForOutOfSample, timeForCheckingCrossingThresholds_begin, timeForCheckingCrossingThresholds_end, timeForEntry, timeForExit); this.inSampleChooser = inSampleChooser; } public PVOStrategyIntraday(IEligiblesSelector eligiblesSelector, int minimumNumberOfEligiblesForValidOptimization, TestingPositions[] chosenPVOPositions, int inSampleDays, Benchmark benchmark, int numDaysBetweenEachOptimization, double oversoldThreshold, double overboughtThreshold, double oversoldThresholdMAX, double overboughtThresholdMAX, HistoricalMarketValueProvider historicalMarketValueProviderForInSample, HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample, Time timeForCheckingCrossingThresholds_begin, Time timeForCheckingCrossingThresholds_end, Time timeForEntry, Time timeForExit) { this.pvoStrategyIntraday(eligiblesSelector, minimumNumberOfEligiblesForValidOptimization, inSampleDays , benchmark , numDaysBetweenEachOptimization , oversoldThreshold, overboughtThreshold, oversoldThresholdMAX, overboughtThresholdMAX, historicalMarketValueProviderForInSample, historicalMarketValueProviderForOutOfSample, timeForCheckingCrossingThresholds_begin, timeForCheckingCrossingThresholds_end, timeForEntry, timeForExit); this.chosenPVOPositions = chosenPVOPositions; } public PVOStrategyIntraday(IEligiblesSelector eligiblesSelector, int minimumNumberOfEligiblesForValidOptimization, TestingPositions[] chosenPVOPositions, int inSampleDays, Benchmark benchmark, int numDaysBetweenEachOptimization, double oversoldThreshold, double overboughtThreshold, HistoricalMarketValueProvider historicalMarketValueProviderForInSample, HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample, Time timeForCheckingCrossingThresholds_begin, Time timeForCheckingCrossingThresholds_end, Time timeForEntry, Time timeForExit) { this.pvoStrategyIntraday(eligiblesSelector, minimumNumberOfEligiblesForValidOptimization, inSampleDays , benchmark , numDaysBetweenEachOptimization , oversoldThreshold, overboughtThreshold, double.MaxValue, double.MaxValue, historicalMarketValueProviderForInSample, historicalMarketValueProviderForOutOfSample, timeForCheckingCrossingThresholds_begin, timeForCheckingCrossingThresholds_end, timeForEntry, timeForExit); this.chosenPVOPositions = chosenPVOPositions; } #region marketOpenEventHandler // protected virtual DateTime getBeginOfOscillatingPeriod(IndexBasedEndOfDayTimer timer) // { // DateTime beginOfOscillatingPeriod = // HistoricalEndOfDayTimer.GetMarketClose( // (DateTime)timer.IndexQuotes.Rows[timer.CurrentDateArrayPosition-1]["quDate"] ); // return beginOfOscillatingPeriod; //// return new EndOfDayDateTime( (DateTime)timer.IndexQuotes.Rows[timer.CurrentDateArrayPosition-1]["quDate"], //// EndOfDaySpecificTime.MarketClose ); // } // // private PVOPositionsStatus marketOpenEventHandler_openPositions_getStatus(IndexBasedEndOfDayTimer timer) // { // DateTime today = timer.GetCurrentDateTime(); // DateTime beginOfOscillatingPeriod = // this.getBeginOfOscillatingPeriod(timer); // PVOPositionsStatus currentStatus = // PVOPositionsStatus.InTheMiddle; // for(int i = 0; i<this.chosenPVOPositions.Length; i++) // { // if(this.chosenPVOPositions[i] != null) // currentStatus = // ((PVOPositions)this.chosenPVOPositions[i]).GetStatus(beginOfOscillatingPeriod, today, // this.benchmark.Ticker, this.historicalMarketValueProviderForInSample, // this.oversoldThresholdMAX, this.overboughtThresholdMAX); // if(currentStatus == PVOPositionsStatus.Oversold || // currentStatus == PVOPositionsStatus.Overbought ) // { // this.positionsForOutOfSample = (PVOPositions)this.chosenPVOPositions[i]; // i = this.chosenPVOPositions.Length;//exit from for // } // } // return currentStatus; // } // // protected void marketOpenEventHandler_openPositions(IndexBasedEndOfDayTimer timer) // { // PVOPositionsStatus pvoPositionsStatus = PVOPositionsStatus.InTheMiddle; // if(timer.CurrentDateArrayPosition >= 1) // pvoPositionsStatus = // this.marketOpenEventHandler_openPositions_getStatus(timer); // switch (pvoPositionsStatus) // { // case PVOPositionsStatus.Overbought: // { // #region manage Overbought case // this.positionsForOutOfSample.WeightedPositions.Reverse(); // try // { // AccountManager.OpenPositions( this.positionsForOutOfSample.WeightedPositions, // this.account ); // } // catch(Exception ex) // { // string forBreakpoint = ex.Message; forBreakpoint = forBreakpoint + ""; // } // finally // { // this.positionsForOutOfSample.WeightedPositions.Reverse(); // } // #endregion // break; // } // case PVOPositionsStatus.Oversold: // { // AccountManager.OpenPositions( this.positionsForOutOfSample.WeightedPositions, // this.account ); // break; // } // case PVOPositionsStatus.InTheMiddle://that is // { //pvoPositionsForOutOfSample has not been set // // break; // } // default: // { // //it should never been reached // break; // } // } // } // // protected void marketOpenEventHandler( // Object sender , DateTime dateTime ) // { // if ( this.account.Portfolio.Count == 0 && // this.chosenPVOPositions != null && // this.optimalPositionsHaveBeenUpdated == true) // //portfolio is empty and optimization has // //been already successfully launched // { // try{ // this.marketOpenEventHandler_openPositions( (IndexBasedEndOfDayTimer)sender ); // } // catch(TickerNotExchangedException ex) // { // string forBreakpoint = ex.Message; forBreakpoint = forBreakpoint + ""; // } // } // } #endregion #region newDateTimeEventHandler_closePositions private void newDateTimeEventHandler_closePositions() { AccountManager.ClosePositions( this.account ); } #endregion newDateTimeEventHandler_closePositions #region newDateTimeEventHandler_openPositions private void newDateTimeEventHandler_openPositions() { switch (this.positionsForOutOfSampleStatus) { case PVOPositionsStatus.Overbought: { #region manage Overbought case this.positionsForOutOfSample.WeightedPositions.Reverse(); try { AccountManager.OpenPositions( this.positionsForOutOfSample.WeightedPositions, this.account ); } catch(Exception ex) { string forBreakpoint = ex.Message; forBreakpoint = forBreakpoint + ""; } finally { this.positionsForOutOfSample.WeightedPositions.Reverse(); } #endregion break; } case PVOPositionsStatus.Oversold: { AccountManager.OpenPositions( this.positionsForOutOfSample.WeightedPositions, this.account ); break; } case PVOPositionsStatus.InTheMiddle://that is { //pvoPositionsForOutOfSample has not been set break; } default: { //it should never been reached break; } } } #endregion newDateTimeEventHandler_openPositions #region newDateTimeEventHandler_updateStatus private void newDateTimeEventHandler_setPositionsAndStatus() { DateTime beginOfOscillatingPeriod = Time.GetDateTimeFromMerge(this.now() , this.timeForCheckingCrossingThresholds_begin); DateTime endOfOscillatingPeriod = Time.GetDateTimeFromMerge(this.now() , this.timeForCheckingCrossingThresholds_end); for(int i = 0; i<this.chosenPVOPositions.Length; i++) { if(this.chosenPVOPositions[i] != null) this.positionsForOutOfSampleStatus = ((PVOPositions)this.chosenPVOPositions[i]).GetStatus(beginOfOscillatingPeriod, endOfOscillatingPeriod, this.benchmark.Ticker, this.historicalMarketValueProviderForOutOfSample, this.oversoldThresholdMAX, this.overboughtThresholdMAX); if(this.positionsForOutOfSampleStatus == PVOPositionsStatus.Oversold || this.positionsForOutOfSampleStatus == PVOPositionsStatus.Overbought ) { this.positionsForOutOfSample = (PVOPositions)this.chosenPVOPositions[i]; i = this.chosenPVOPositions.Length;//exit from for } } } #endregion newDateTimeEventHandler_updateStatus public virtual void NewDateTimeEventHandler( Object sender , DateTime dateTime ) { Time currentTime = new Time( dateTime ); if( timeForCheckingCrossingThresholds_end == currentTime ) this.newDateTimeEventHandler_setPositionsAndStatus(); else if( timeForEntry == currentTime ) this.newDateTimeEventHandler_openPositions(); else if( timeForExit == currentTime ) this.newDateTimeEventHandler_closePositions(); else if( currentTime > timeForExit ) this.newDateTimeEventHandler_updateTestingPositions( dateTime ); } #region UpdateTestingPositions protected void updateTestingPositions(DateTime currentDateTime) { History history = this.benchmark.GetEndOfDayHistory( HistoricalEndOfDayTimer.GetMarketOpen( currentDateTime.AddDays( -this.inSampleDays ) ) , HistoricalEndOfDayTimer.GetMarketClose( currentDateTime ) ); EligibleTickers eligibles = this.eligiblesSelector.GetEligibleTickers(history); this.updateReturnsManager(history.FirstDateTime, history.LastDateTime); if( ( this.eligiblesSelector is DummyEligibleSelector && this.inSampleChooser != null ) || ( eligibles.Count > this.minimumNumberOfEligiblesForValidOptimization && this.inSampleChooser != null ) ) { this.chosenPVOPositions = (TestingPositions[])inSampleChooser.AnalyzeInSample(eligibles, this.returnsManager); this.updateTestingPositions_updateThresholds(); this.logOptimizationInfo(eligibles); // this.optimalPositionsHaveBeenUpdated = true; } // else // { // this.optimalPositionsHaveBeenUpdated = false; // } } private bool optimalTestingPositionsAreToBeUpdated() { bool areToBeUpdated = false; if(this.inSampleChooser != null) { DateTime dateTimeForNextOptimization = this.lastOptimizationDateTime.AddDays( this.numDaysBetweenEachOptimization ); areToBeUpdated = ( ( ( this.account.Portfolio.Count == 0 ) && ( ( this.lastOptimizationDateTime == DateTime.MinValue ) ) ) || ( this.now() >= dateTimeForNextOptimization ) ); } return areToBeUpdated; } private void newDateTimeEventHandler_updateTestingPositions( DateTime dateTime ) { this.lastTimerDateTimeAfterLastExit = dateTime; this.numDaysElapsedSinceLastOptimization++; //OLD - numDaysBetweenEachOptimization --> market days // if( this.account.Transactions.Count <= 1 || // (this.numDaysElapsedSinceLastOptimization == // this.numDaysBetweenEachOptimization) ) //num days without optimization has elapsed or //no transaction, except for adding cash, has been executed //NEW - numDaysBetweenEachOptimization --> calendar days if ( this.optimalTestingPositionsAreToBeUpdated() ) { this.updateTestingPositions( dateTime ); //sets tickers to be chosen next time this.numDaysElapsedSinceLastOptimization = 0; this.lastOptimizationDateTime = this.now(); } } #endregion UpdateTestingPositions private DateTime now() { return this.account.Timer.GetCurrentDateTime(); } protected virtual void updateReturnsManager(DateTime firstDateTime, DateTime lastDayDateTime) { ReturnIntervals returnIntervals = new DailyOpenToCloseIntervals( firstDateTime, lastDayDateTime, this.benchmark.Ticker ); if( this.inSampleChooser is PVOCorrelationChooser ) { switch ( ((PVOCorrelationChooser)this.inSampleChooser).IntervalsType ) { case IntervalsType.CloseToCloseIntervals: returnIntervals = new CloseToCloseIntervals(firstDateTime, lastDayDateTime, this.benchmark.Ticker, ((PVOCorrelationChooser)this.inSampleChooser).ReturnIntervalLength); break; case IntervalsType.OpenToOpenIntervals: returnIntervals = new OpenToOpenIntervals(firstDateTime, lastDayDateTime, this.benchmark.Ticker, ((PVOCorrelationChooser)this.inSampleChooser).ReturnIntervalLength); break; case IntervalsType.CloseToOpenIntervals: returnIntervals = new CloseToOpenIntervals(firstDateTime, lastDayDateTime, this.benchmark.Ticker); break; case IntervalsType.OpenToCloseIntervals: returnIntervals = new DailyOpenToCloseIntervals(firstDateTime, lastDayDateTime, this.benchmark.Ticker ); break; case IntervalsType.OpenToCloseCloseToOpenIntervals: returnIntervals = new OpenToCloseCloseToOpenIntervals( firstDateTime, lastDayDateTime, this.benchmark.Ticker); break; default: // it should never be reached returnIntervals = new DailyOpenToCloseIntervals(firstDateTime, lastDayDateTime, this.benchmark.Ticker ); break; } } this.returnsManager = new ReturnsManager( returnIntervals , this.historicalMarketValueProviderForInSample); } private double getLogItem_getFitnessOfLast() { double returnValue = 0.0; for(int i = 1; i<=this.chosenPVOPositions.Length; i++) { if(this.chosenPVOPositions[this.chosenPVOPositions.Length - i] != null) { returnValue = this.chosenPVOPositions[this.chosenPVOPositions.Length - i].FitnessInSample; i = this.chosenPVOPositions.Length + 1; //exit from for } } return returnValue; } private string getLogItem_getHashCodeForTickerCompositionForLast() { string returnValue = "not set"; for(int i = 1; i<=this.chosenPVOPositions.Length; i++) { if(this.chosenPVOPositions[this.chosenPVOPositions.Length - i] != null) { returnValue = this.chosenPVOPositions[this.chosenPVOPositions.Length - i].HashCodeForTickerComposition; i = this.chosenPVOPositions.Length + 1; //exit from for } } return returnValue; } private PVO_OTCLogItem getLogItem( EligibleTickers eligibleTickers ) { PVO_OTCLogItem logItem = new PVO_OTCLogItem( this.now() , this.inSampleDays ); logItem.BestPVOPositionsInSample = this.chosenPVOPositions; logItem.NumberOfEligibleTickers = eligibleTickers.Count; logItem.FitnessOfFirst = this.chosenPVOPositions[0].FitnessInSample; logItem.FitnessOfLast = this.getLogItem_getFitnessOfLast(); // logItem.GenerationOfFirst = // ((IGeneticallyOptimizable)this.chosenPVOPositions[0]).Generation; // logItem.GenerationOfLast = // ((IGeneticallyOptimizable)this.chosenPVOPositions[this.chosenPVOPositions.Length - 1]).Generation; logItem.ThresholdsOfFirst = ((PVOPositions)this.chosenPVOPositions[0]).OversoldThreshold.ToString() + ";" + ((PVOPositions)this.chosenPVOPositions[0]).OverboughtThreshold.ToString(); logItem.ThresholdsOfLast = logItem.ThresholdsOfFirst; // ((PVOPositions)this.chosenPVOPositions[this.chosenPVOPositions.Length - 1]).OversoldThreshold.ToString() + ";" + // ((PVOPositions)this.chosenPVOPositions[this.chosenPVOPositions.Length - 1]).OverboughtThreshold.ToString(); logItem.TickersOfFirst = this.chosenPVOPositions[0].HashCodeForTickerComposition; logItem.TickersOfLast = this.getLogItem_getHashCodeForTickerCompositionForLast(); return logItem; } private void raiseNewLogItem( EligibleTickers eligibleTickers ) { PVO_OTCLogItem logItem = this.getLogItem( eligibleTickers ); NewLogItemEventArgs newLogItemEventArgs = new NewLogItemEventArgs( logItem ); this.NewLogItem( this , newLogItemEventArgs ); } private void notifyMessage( EligibleTickers eligibleTickers ) { string message = "Number of Eligible tickers: " + eligibleTickers.Count; NewMessageEventArgs newMessageEventArgs = new NewMessageEventArgs( message ); if ( this.NewMessage != null ) this.NewMessage( this , newMessageEventArgs ); } private void logOptimizationInfo( EligibleTickers eligibleTickers ) { if(eligibleTickers.Count > 0) this.raiseNewLogItem( eligibleTickers ); this.notifyMessage( eligibleTickers ); } private void updateTestingPositions_updateThresholds() { for(int i = 0; i<this.chosenPVOPositions.Length; i++) { if(this.chosenPVOPositions[i] != null) { ((PVOPositions)this.chosenPVOPositions[i]).OversoldThreshold = this.oversoldThreshold; ((PVOPositions)this.chosenPVOPositions[i]).OverboughtThreshold = this.overboughtThreshold; } } } } } --- NEW FILE: PVOStrategyIntradayMain.cs --- /* QuantProject - Quantitative Finance Library PVOStrategyIntradayMain.cs Copyright (C) 2008 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Collections; using System.Collections.Generic; using System.IO; using QuantProject.ADT; using QuantProject.ADT.FileManaging; using QuantProject.ADT.Timing; using QuantProject.Business.DataProviders; using QuantProject.Data.DataProviders.Bars.Caching; using QuantProject.Business.Strategies; using QuantProject.Business.Financial.Accounting.AccountProviding; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.EquityEvaluation; using QuantProject.Business.Strategies.InSample; using QuantProject.Business.Strategies.Logging; using QuantProject.Business.Strategies.Optimizing.Decoding; using QuantProject.Business.Strategies.Optimizing.FitnessEvaluation; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Strategies.ReturnsManagement.Time; using QuantProject.Business.Strategies.ReturnsManagement.Time.IntervalsSelectors; using QuantProject.Business.Timing; using QuantProject.Presentation; using QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator.InSampleChoosers; using QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator.Decoding; using QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator.FitnessEvaluators; using QuantProject.Scripts.General; using QuantProject.Scripts.General.Logging; using QuantProject.Scripts.General.Reporting; namespace QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator { /// <summary> /// Entry point for the PVOStrategyIntradayMain. If any strategy /// parameter had to be changed, this is the place where it should /// be done /// </summary> public class PVOStrategyIntradayMain : BasicScriptForBacktesting { private Benchmark benchmark; private HistoricalMarketValueProvider historicalMarketValueProviderForInSample; private HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample; private Time timeForCheckingCrossingThreshold_begin; private Time timeForCheckingCrossingThreshold_end; private Time timeForEntry; private Time timeForExit; private Timer timerForBackTester; private DateTime firstDateTime; private DateTime lastDateTime; private int intervalFrameInSeconds; public PVOStrategyIntradayMain() { //this.benchmark = new Benchmark( "^GSPC" ); this.timeForCheckingCrossingThreshold_begin = new Time("10:00:00"); this.timeForCheckingCrossingThreshold_end = new Time("11:00:00"); this.timeForEntry = this.timeForCheckingCrossingThreshold_end; // new Time("11:01:00"); this.timeForExit = new Time("12:00:00"); this.firstDateTime = new DateTime( 2007 , 1 , 1 ); this.lastDateTime = new DateTime( 2007 , 1, 31 ); this.intervalFrameInSeconds = 60; this.benchmark = new Benchmark( "MSFT" ); this.historicalMarketValueProviderForInSample = new HistoricalAdjustedQuoteProvider(); this.historicalMarketValueProviderForOutOfSample = this.getHistoricalBarProvider(); this.timerForBackTester = new IndexBasedHistoricalTimer(this.benchmark.Ticker, this.firstDateTime, this.lastDateTime , this.getDailyTimes(), this.intervalFrameInSeconds); // definition for the Fitness Evaluator // IEquityEvaluator equityEvaluator = new SharpeRatio(); } protected override IEligiblesSelector getEligiblesSelector() { int maxNumberOfEligiblesToBeChosen = 100; string tickersGroupId = "SP500"; bool temporizedGroup = true; int numDaysForAverageRawOpenPriceComputation = 10; double minPrice = 30; double maxPrice = 75; int maxNumberOfMostLiquidTickersToBeChosen = 150; int numDaysForVolatility = 10; // IEligiblesSelector eligiblesSelector = // new ByPriceMostLiquidQuotedAtEachDateTime( // tickersGroupId , temporizedGroup , // maxNumberOfEligiblesToBeChosen , // numDaysForAverageRawOpenPriceComputation , // minPrice , maxPrice, intervalFrameInSeconds , // this.benchmark.Ticker ); // IEligiblesSelector eligiblesSelector = new ByPriceMostLiquidLessVolatileOTCAlwaysQuoted( tickersGroupId , temporizedGroup , maxNumberOfEligiblesToBeChosen , maxNumberOfMostLiquidTickersToBeChosen , numDaysForAverageRawOpenPriceComputation , numDaysForVolatility , minPrice , maxPrice ); // IEligiblesSelector eligiblesSelector = // new ByPriceMostLiquidAlwaysQuoted( // tickersGroupId , temporizedGroup , // maxNumberOfEligiblesToBeChosen , // numDaysForAverageRawOpenPriceComputation , // minPrice , maxPrice ); // IEligiblesSelector eligiblesSelector = // new ByPriceLessVolatileOTCAlwaysQuoted( // tickersGroupId , temporizedGroup , // maxNumberOfEligiblesToBeChosen , // numDaysForAverageRawOpenPriceComputation , // minPrice , maxPrice ); // eligiblesSelector = // new DummyEligibleSelector(); // return eligiblesSelector; } protected override IInSampleChooser getInSampleChooser() { // parameters for the genetic optimizer // double crossoverRate = 0.85; // double mutationRate = 0.02; // double elitismRate = 0.001; // int populationSizeForGeneticOptimizer = 3000; // int generationNumberForGeneticOptimizer = 4; // int seedForRandomGenerator = // QuantProject.ADT.ConstantsProvider.SeedForRandomGenerator; // IDecoderForTestingPositions decoderForWeightedPositions = // new DecoderForPairsTradingTestingPositionsWithBalancedWeights(); double maxCorrelationAllowed = 0.96; int numberOfBestTestingPositionsToBeReturned = 100; numberOfBestTestingPositionsToBeReturned = 100; bool balancedWeightsOnVolatilityBase = true; float minimumAbsoluteReturnValue = 0.000001f; float maximumAbsoluteReturnValue = 100000f; //correlation is computed only for returns //between minimum and maximum // IInSampleChooser inSampleChooser = // new PVO_OTCCorrelationChooser(numberOfBestTestingPositionsToBeReturned, // maxCorrelationAllowed , balancedWeightsOnVolatilityBase, // minimumAbsoluteReturnValue , maximumAbsoluteReturnValue, this.benchmark.Ticker); // IInSampleChooser inSampleChooser = // new PVO_OTCCTOCorrelationChooser(numberOfBestTestingPositionsToBeReturned, // maxCorrelationAllowed , balancedWeightsOnVolatilityBase, // minimumAbsoluteReturnValue , maximumAbsoluteReturnValue, this.benchmark.Ticker); IInSampleChooser inSampleChooser = new PVO_CTCCorrelationChooser(numberOfBestTestingPositionsToBeReturned, 1 , maxCorrelationAllowed , balancedWeightsOnVolatilityBase, minimumAbsoluteReturnValue , maximumAbsoluteReturnValue, this.benchmark.Ticker); // //office // inSampleChooser = // new PVOChooserFromSavedBackTestLog( // @"C:\Utente\MarcoVarie\Vari\qP\LogArchive\2008_08_06_16_57_34_PVO_OTC_from_2003_06_01_to_2008_04_28_annlRtrn_3,34_maxDD_11,36\2008_08_06_16_57_34_PVO_OTC_from_2003_06_01_to_2008_04_28_annlRtrn_3,34_maxDD_11,36.qpL", // numberOfBestTestingPositionsToBeReturned); //home // inSampleChooser = // new PVOChooserFromSavedBackTestLog( // @"C:\Utente\MarcoVarie\Vari\qP\LogArchive\2008_05_04_18_54_45_PVO_OTC_from_2006_01_01_to_2008_04_28_annlRtrn_93.08_maxDD_5.18\2008_05_04_18_54_45_PVO_OTC_from_2006_01_01_to_2008_04_28_annlRtrn_93.08_maxDD_5.18.qpL", // numberOfBestTestingPositionsToBeReturned); return inSampleChooser; } protected override IStrategyForBacktester getStrategyForBacktester() { //int inSampleDays = 90; int inSampleDays = 10; int numDaysBetweenEachOptimization = 5; int minNumOfEligiblesForValidOptimization = 20; double oversoldThreshold = 0.0075; double overboughtThreshold = 0.0075; double oversoldThresholdMAX = 0.02; double overboughtThresholdMAX = 0.02; IStrategyForBacktester strategyForBacktester // = new PVO_OTCStrategyLessCorrelated(eligiblesSelector ,inSampleChooser , // inSampleDays , benchmark , numDaysBetweenEachOptimization , // oversoldThreshold , overboughtThreshold , historicalQuoteProvider); // = new PVOStrategyIntraday(eligiblesSelector , minNumOfEligiblesForValidOptimization, inSampleChooser , inSampleDays , benchmark , numDaysBetweenEachOptimization , oversoldThreshold , overboughtThreshold , oversoldThresholdMAX , overboughtThresholdMAX , historicalMarketValueProviderForInSample, historicalMarketValueProviderForOutOfSample, timeForCheckingCrossingThreshold_begin, timeForCheckingCrossingThreshold_end, timeForEntry, timeForExit); return strategyForBacktester; } #region getHistoricalBarProvider #region getBarCache private List<Time> getDailyTimes() { List<Time> dailyTimes = new List<Time>(); dailyTimes.Add(this.timeForCheckingCrossingThreshold_begin); dailyTimes.Add(this.timeForCheckingCrossingThreshold_end); if(this.timeForEntry > this.timeForCheckingCrossingThreshold_end) dailyTimes.Add(this.timeForEntry); dailyTimes.Add(this.timeForExit); return dailyTimes; } private IBarCache getBarCache() { List<Time> dailyTimes = this.getDailyTimes(); IBarCache barCache = new DailyBarCache( this.intervalFrameInSeconds , dailyTimes ); return barCache; } #endregion getBarCache private HistoricalBarProvider getHistoricalBarProvider() { IBarCache barCache = getBarCache(); HistoricalBarProvider historicalBarProvider = new HistoricalBarProvider( barCache ); return historicalBarProvider; } #endregion getHistoricalBarProvider protected override EndOfDayStrategyBackTester getEndOfDayStrategyBackTester() { string backTestId = "PVOIntraday"; IAccountProvider accountProvider; accountProvider = new SimpleAccountProvider(); // double fixedPercentageSlippage = 0.05; // accountProvider = // new InteractiveBrokerAccountProvider(fixedPercentageSlippage); double cashToStart = 25000; double maxRunningHours = 0.40; HistoricalMarketValueProvider quoteProviderForBackTester = this.historicalMarketValueProviderForOutOfSample; // quoteProviderForBackTester = // new HistoricalRawQuoteProvider(); EndOfDayStrategyBackTester endOfDayStrategyBackTester = new EndOfDayStrategyBackTester( backTestId , this.timerForBackTester, this.strategyForBacktester , quoteProviderForBackTester , accountProvider , firstDateTime , lastDateTime , this.benchmark , cashToStart , maxRunningHours ); return endOfDayStrategyBackTester; } protected override string getPathForTheMainFolderWhereScriptsResultsAreToBeSaved() { string pathForTheMainFolderWhereScriptsResultsAreToBeSaved = System.Configuration.ConfigurationManager.AppSettings["LogArchive"]; return pathForTheMainFolderWhereScriptsResultsAreToBeSaved; } protected override string getCustomSmallTextForFolderName() { return "PVOIntraday"; } protected override string getFullPathFileNameForMain() { string returnValue; string fullPathFileNameForMainAtHome = @"C:\Quant\QuantProject\b7_Scripts\TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\PVOStrategyIntradayMain.cs"; if( File.Exists(fullPathFileNameForMainAtHome) ) returnValue = fullPathFileNameForMainAtHome; else returnValue = @"C:\Utente\MarcoVarie\Vari\qP\QuantProject\b7_Scripts\TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\PVOStrategyIntradayMain.cs"; return returnValue; } } } |
|
From: Glauco S. <gla...@us...> - 2008-11-22 18:27:44
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataProviders In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4038/b3_Data/DataProviders Modified Files: IDataStreamer.cs Log Message: the event NewQuote was not used so it has been commented out Index: IDataStreamer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataProviders/IDataStreamer.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IDataStreamer.cs 13 Dec 2004 01:48:45 -0000 1.3 --- IDataStreamer.cs 22 Nov 2008 18:27:38 -0000 1.4 *************** *** 37,41 **** public interface IDataStreamer { ! event NewQuoteEventHandler NewQuote; double GetCurrentBid( string ticker ); double GetCurrentAsk( string ticker ); --- 37,41 ---- public interface IDataStreamer { ! // event NewQuoteEventHandler NewQuote; double GetCurrentBid( string ticker ); double GetCurrentAsk( string ticker ); |
|
From: Glauco S. <gla...@us...> - 2008-11-22 18:26:55
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3990/b4_Business/a07_DataProviders Modified Files: HistoricalQuoteProvider.cs Log Message: the [Serializable] attribute has been added Index: HistoricalQuoteProvider.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders/HistoricalQuoteProvider.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** HistoricalQuoteProvider.cs 20 Nov 2008 20:35:03 -0000 1.8 --- HistoricalQuoteProvider.cs 22 Nov 2008 18:26:47 -0000 1.9 *************** *** 28,33 **** { /// <summary> ! /// To be extended by those HistoricalMarketValueProvider who will use the Quote table /// </summary> public abstract class HistoricalQuoteProvider : HistoricalMarketValueProvider { --- 28,34 ---- { /// <summary> ! /// Description of HistoricalQuoteProvider. /// </summary> + [Serializable] public abstract class HistoricalQuoteProvider : HistoricalMarketValueProvider { |
|
From: Glauco S. <gla...@us...> - 2008-11-22 18:26:31
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3967/b4_Business/a2_Strategies Modified Files: EndOfDayStrategyBackTester.cs Log Message: bug fixed: the timer's GetCurrentDateTime() method was invoked after the timer was stopped Index: EndOfDayStrategyBackTester.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/EndOfDayStrategyBackTester.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** EndOfDayStrategyBackTester.cs 20 Nov 2008 20:55:36 -0000 1.13 --- EndOfDayStrategyBackTester.cs 22 Nov 2008 18:26:20 -0000 1.14 *************** *** 298,308 **** private void completeTheScript() { - this.actualLastDateTime = - ExtendedDateTime.Min( - this.lastDateTime , this.timer.GetCurrentDateTime() ); this.realDateTimeWhenTheBackTestIsStopped = DateTime.Now; this.accountReport = this.account.CreateReport( "" , 1 , ! this.timer.GetCurrentDateTime() , this.benchmark.Ticker , this.historicalMarketValueProvider ); this.accountReport.Name = this.Description; --- 298,305 ---- private void completeTheScript() { this.realDateTimeWhenTheBackTestIsStopped = DateTime.Now; this.accountReport = this.account.CreateReport( "" , 1 , ! this.actualLastDateTime , this.benchmark.Ticker , this.historicalMarketValueProvider ); this.accountReport.Name = this.Description; *************** *** 358,362 **** // this.actualLastDateTime = // ExtendedDateTime.Min( this.lastDateTime , currentDateTime ); ! this.timer.Stop(); --- 355,361 ---- // this.actualLastDateTime = // ExtendedDateTime.Min( this.lastDateTime , currentDateTime ); ! this.actualLastDateTime = ! ExtendedDateTime.Min( ! this.lastDateTime , this.timer.GetCurrentDateTime() ); this.timer.Stop(); |
|
From: Glauco S. <gla...@us...> - 2008-11-22 18:25:28
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataProviders/Bars/Caching In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3936/b3_Data/DataProviders/Bars/Caching Modified Files: DailyBarCache.cs Log Message: code has been added to handle an expected exception Index: DailyBarCache.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataProviders/Bars/Caching/DailyBarCache.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DailyBarCache.cs 20 Nov 2008 20:41:30 -0000 1.3 --- DailyBarCache.cs 22 Nov 2008 18:25:22 -0000 1.4 *************** *** 270,274 **** indexFor_dateTimesForMissingBarsToBeAdded++; } ! return dateTimesIn_barOpenValues; } private List< DateTime > getDateTimesForMissingBarsToBeAdded( --- 270,274 ---- indexFor_dateTimesForMissingBarsToBeAdded++; } ! return dateTimesForMissingBarsToBeAdded; } private List< DateTime > getDateTimesForMissingBarsToBeAdded( *************** *** 393,397 **** --- 393,404 ---- { // forces bar caching + try + { this.GetMarketValue( ticker , dateTime ); + } + catch ( MissingBarException missingBarException ) + { + string doNothing = missingBarException.Message; doNothing += ""; + } bool wasExchanged = this.barOpenValues.ContainsBar( ticker , dateTime ); return wasExchanged; |
|
From: Glauco S. <gla...@us...> - 2008-11-22 18:24:15
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagDebugger/WFLagDebugPositions In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3868/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagDebugger/WFLagDebugPositions Modified Files: WFLagDebugPositions.cs Log Message: - HistoricalEndOfDayDataStreamer has been replaced by HistoricalDataStreamer.cs - HistoricalEndOfDayOrderExecutor has been replaced by HistoricalOrderExecutor Index: WFLagDebugPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagDebugger/WFLagDebugPositions/WFLagDebugPositions.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** WFLagDebugPositions.cs 29 Sep 2008 21:20:54 -0000 1.7 --- WFLagDebugPositions.cs 22 Nov 2008 18:24:08 -0000 1.8 *************** *** 100,106 **** this.account = new Account( "WFLagDebugPositions" , this.endOfDayTimer , ! new HistoricalEndOfDayDataStreamer( this.endOfDayTimer , this.historicalQuoteProvider ) , ! new HistoricalEndOfDayOrderExecutor( this.endOfDayTimer , this.historicalQuoteProvider ) ); } --- 100,106 ---- this.account = new Account( "WFLagDebugPositions" , this.endOfDayTimer , ! new HistoricalDataStreamer( this.endOfDayTimer , this.historicalQuoteProvider ) , ! new HistoricalOrderExecutor( this.endOfDayTimer , this.historicalQuoteProvider ) ); } |
|
From: Glauco S. <gla...@us...> - 2008-11-22 18:24:15
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardMultiOneRank/ReportDebugger In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3868/b7_Scripts/WalkForwardTesting/WalkForwardMultiOneRank/ReportDebugger Modified Files: WFMultiOneRankDebugInSample.cs Log Message: - HistoricalEndOfDayDataStreamer has been replaced by HistoricalDataStreamer.cs - HistoricalEndOfDayOrderExecutor has been replaced by HistoricalOrderExecutor Index: WFMultiOneRankDebugInSample.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardMultiOneRank/ReportDebugger/WFMultiOneRankDebugInSample.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** WFMultiOneRankDebugInSample.cs 29 Sep 2008 21:21:25 -0000 1.4 --- WFMultiOneRankDebugInSample.cs 22 Nov 2008 18:24:08 -0000 1.5 *************** *** 76,82 **** this.account = new Account( "WFMultiOneRankDebugInSample" , this.endOfDayTimer , ! new HistoricalEndOfDayDataStreamer( this.endOfDayTimer , this.historicalMarketValueProvider ) , ! new HistoricalEndOfDayOrderExecutor( this.endOfDayTimer , this.historicalMarketValueProvider ) ); } --- 76,82 ---- this.account = new Account( "WFMultiOneRankDebugInSample" , this.endOfDayTimer , ! new HistoricalDataStreamer( this.endOfDayTimer , this.historicalMarketValueProvider ) , ! new HistoricalOrderExecutor( this.endOfDayTimer , this.historicalMarketValueProvider ) ); } |