[Quantproject-developers] QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Logging TesterFo
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2009-03-07 04:25:21
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Logging In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv23111/WalkForwardTesting/PairsTrading/Logging Modified Files: TesterForPairsTradingTestingPositions.cs Log Message: It now uses a PairsViewer object, to analyze the log Index: TesterForPairsTradingTestingPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Logging/TesterForPairsTradingTestingPositions.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TesterForPairsTradingTestingPositions.cs 28 Feb 2009 18:45:06 -0000 1.7 --- TesterForPairsTradingTestingPositions.cs 7 Mar 2009 04:25:05 -0000 1.8 *************** *** 96,158 **** #region Run ! #region getHistory ! ! #region addItemsToHistory ! private DateTime getFirstDateTime() ! { ! DateTime firstDateTime = ! HistoricalEndOfDayTimer.GetMarketOpen( ! this.dateTimeWhenThisObjectWasLogged.AddDays( 1 ) ); ! return firstDateTime; ! } ! private DateTime getLastDateTime() ! { ! DateTime firstDateTime = this.getFirstDateTime(); ! DateTime lastDateTime = ! HistoricalEndOfDayTimer.GetMarketClose( firstDateTime ); ! return lastDateTime; ! } ! private void addItemToHistory( ! WeightedPosition weightedPosition , DateTime dateTime , History history ) ! { ! try ! { ! double marketValue = this.historicalMarketValueProvider.GetMarketValue( ! weightedPosition.Ticker , dateTime ); ! history.Add( dateTime , marketValue ); ! } ! catch( TickerNotExchangedException tickerNotExchangedException ) ! { ! string toAvoidWarning = tickerNotExchangedException.Message; ! } ! } ! private void addItemsToHistory( WeightedPosition weightedPosition , History history ) ! { ! DateTime currentDateTime = this.getFirstDateTime(); ! DateTime lastDateTime = this.getLastDateTime(); ! while ( currentDateTime <= lastDateTime ) ! { ! this.addItemToHistory( weightedPosition , currentDateTime , history ); ! currentDateTime = currentDateTime.AddMinutes( 1 ); ! } ! } ! #endregion addItemsToHistory ! ! private History getHistory( WeightedPosition weightedPosition ) ! { ! History history = new History(); ! this.addItemsToHistory( weightedPosition , history ); ! return history; ! } ! #endregion getHistory ! private void showHistoriesPlots( ! History historyForFirstPosition , History historyForSecondPosition ) ! { ! HistoriesViewer historiesViewer = new HistoriesViewer(); ! historiesViewer.Add( historyForFirstPosition , Color.Green ); ! historiesViewer.Add( historyForSecondPosition , Color.Red ); ! historiesViewer.ShowDialog(); ! } public void Run() --- 96,158 ---- #region Run ! // #region getHistory ! // ! // #region addItemsToHistory ! // private DateTime getFirstDateTime() ! // { ! // DateTime firstDateTime = ! // HistoricalEndOfDayTimer.GetMarketOpen( ! // this.dateTimeWhenThisObjectWasLogged.AddDays( 1 ) ); ! // return firstDateTime; ! // } ! // private DateTime getLastDateTime() ! // { ! // DateTime firstDateTime = this.getFirstDateTime(); ! // DateTime lastDateTime = ! // HistoricalEndOfDayTimer.GetMarketClose( firstDateTime ); ! // return lastDateTime; ! // } ! // private void addItemToHistory( ! // WeightedPosition weightedPosition , DateTime dateTime , History history ) ! // { ! // try ! // { ! // double marketValue = this.historicalMarketValueProvider.GetMarketValue( ! // weightedPosition.Ticker , dateTime ); ! // history.Add( dateTime , marketValue ); ! // } ! // catch( TickerNotExchangedException tickerNotExchangedException ) ! // { ! // string toAvoidWarning = tickerNotExchangedException.Message; ! // } ! // } ! // private void addItemsToHistory( WeightedPosition weightedPosition , History history ) ! // { ! // DateTime currentDateTime = this.getFirstDateTime(); ! // DateTime lastDateTime = this.getLastDateTime(); ! // while ( currentDateTime <= lastDateTime ) ! // { ! // this.addItemToHistory( weightedPosition , currentDateTime , history ); ! // currentDateTime = currentDateTime.AddMinutes( 1 ); ! // } ! // } ! // #endregion addItemsToHistory ! // ! // private History getHistory( WeightedPosition weightedPosition ) ! // { ! // History history = new History(); ! // this.addItemsToHistory( weightedPosition , history ); ! // return history; ! // } ! // #endregion getHistory ! // private void showHistoriesPlots( ! // History historyForFirstPosition , History historyForSecondPosition ) ! // { ! // HistoriesViewer historiesViewer = new HistoriesViewer(); ! // historiesViewer.Add( historyForFirstPosition , Color.Green ); ! // historiesViewer.Add( historyForSecondPosition , Color.Red ); ! // historiesViewer.Show(); ! // } public void Run() *************** *** 160,168 **** this.historicalMarketValueProvider = new HistoricalBarProvider( new SimpleBarCache( 60 ) ); ! History historyForFirstPosition = this.getHistory( ! this.testingPositions.WeightedPositions[ 0 ] ); ! History historyForSecondPosition = this.getHistory( ! this.testingPositions.WeightedPositions[ 1 ] ); ! this.showHistoriesPlots( historyForFirstPosition , historyForSecondPosition ); } #endregion Run --- 160,173 ---- this.historicalMarketValueProvider = new HistoricalBarProvider( new SimpleBarCache( 60 ) ); ! new PairsViewer( ! this.historicalMarketValueProvider , ! this.testingPositions.WeightedPositions[ 0 ] , ! this.testingPositions.WeightedPositions[ 1 ] , ! this.dateTimeWhenThisObjectWasLogged ).Show(); ! // History historyForFirstPosition = this.getHistory( ! // this.testingPositions.WeightedPositions[ 0 ] ); ! // History historyForSecondPosition = this.getHistory( ! // this.testingPositions.WeightedPositions[ 1 ] ); ! // this.showHistoriesPlots( historyForFirstPosition , historyForSecondPosition ); } #endregion Run |