[Quantproject-developers] QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading PairsTradingMain
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2009-02-28 18:42:21
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv24351/b7_Scripts/WalkForwardTesting/PairsTrading Modified Files: PairsTradingMain.cs Log Message: The new PairsTradingIntradayStrategy is called Index: PairsTradingMain.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/PairsTradingMain.cs,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** PairsTradingMain.cs 18 Feb 2009 20:05:34 -0000 1.28 --- PairsTradingMain.cs 28 Feb 2009 18:42:14 -0000 1.29 *************** *** 71,78 **** this.historicalMarketValueProviderForInSample = ! new HistoricalRawQuoteProvider(); this.historicalMarketValueProviderForChosingPositionsOutOfSample = ! this.getHistoricalBarProvider(); // this.historicalMarketValueProviderForChosingPositionsOutOfSample = // new HistoricalAdjustedQuoteProvider(); --- 71,78 ---- this.historicalMarketValueProviderForInSample = ! new HistoricalAdjustedQuoteProvider(); this.historicalMarketValueProviderForChosingPositionsOutOfSample = ! this.getHistoricalMarketValueProviderForChosingPositionsOutOfSample(); // this.historicalMarketValueProviderForChosingPositionsOutOfSample = // new HistoricalAdjustedQuoteProvider(); *************** *** 81,85 **** this.historicalMarketValueProviderForTheBacktesterAccount = ! this.historicalMarketValueProviderForChosingPositionsOutOfSample; // this.historicalMarketValueProviderForTheBacktesterAccount = // new HistoricalRawQuoteProvider(); --- 81,85 ---- this.historicalMarketValueProviderForTheBacktesterAccount = ! this.getHistoricalMarketValueProviderForTheBacktesterAccount(); // this.historicalMarketValueProviderForTheBacktesterAccount = // new HistoricalRawQuoteProvider(); *************** *** 98,101 **** --- 98,103 ---- } + #region getHistoricalMarketValueProviderForChosingPositionsOutOfSample + #region getHistoricalBarProvider *************** *** 117,122 **** private IBarCache getBarCache() { ! List< Time > dailyTimes = this.getDailyTimes(); ! IBarCache barCache = new DailyBarCache( 60 , dailyTimes ); return barCache; } --- 119,125 ---- private IBarCache getBarCache() { ! // List< Time > dailyTimes = this.getDailyTimes(); ! // IBarCache barCache = new DailyBarCache( 60 , dailyTimes ); ! IBarCache barCache = new SimpleBarCache( 60 ); return barCache; } *************** *** 126,134 **** { IBarCache barCache = getBarCache(); ! HistoricalBarProvider historicalBarProvider = ! new HistoricalBarProvider( barCache ); return historicalBarProvider; } #endregion getHistoricalBarProvider protected override IEligiblesSelector getEligiblesSelector() --- 129,158 ---- { IBarCache barCache = getBarCache(); ! HistoricalBarProvider historicalBarProvider = new HistoricalBarProvider( barCache ); return historicalBarProvider; } #endregion getHistoricalBarProvider + + private HistoricalMarketValueProvider + getHistoricalMarketValueProviderForChosingPositionsOutOfSample() + { + HistoricalBarProvider historicalBarProvider = + this.getHistoricalBarProvider(); + // HistoricalMarketValueProviderWithQuoteBackupOnClose + // historicalMarketValueProviderForChosingPositionsOutOfSample = + // new HistoricalMarketValueProviderWithQuoteBackupOnClose( historicalBarProvider ); + return historicalBarProvider; + } + #endregion getHistoricalMarketValueProviderForChosingPositionsOutOfSample + + private HistoricalMarketValueProvider + getHistoricalMarketValueProviderForTheBacktesterAccount() + { + HistoricalMarketValueProviderWithQuoteBackupOnClose + historicalMarketValueProviderForTheBacktesterAccount = + new HistoricalMarketValueProviderWithQuoteBackupOnClose( + this.historicalMarketValueProviderForChosingPositionsOutOfSample ); + return historicalMarketValueProviderForTheBacktesterAccount; + } protected override IEligiblesSelector getEligiblesSelector() *************** *** 138,142 **** string tickersGroupId = "SP500"; // uncomment the following line for a faster script ! tickersGroupId = "fastTest"; // IEligiblesSelector eligiblesSelector = --- 162,166 ---- string tickersGroupId = "SP500"; // uncomment the following line for a faster script ! // tickersGroupId = "fastTest"; // IEligiblesSelector eligiblesSelector = *************** *** 168,172 **** int numberOfBestTestingPositionsToBeReturned = 50; // uncomment the following line for a faster script ! numberOfBestTestingPositionsToBeReturned = 10; IDecoderForTestingPositions decoderForWeightedPositions = --- 192,196 ---- int numberOfBestTestingPositionsToBeReturned = 50; // uncomment the following line for a faster script ! // numberOfBestTestingPositionsToBeReturned = 10; IDecoderForTestingPositions decoderForWeightedPositions = *************** *** 237,247 **** OutOfSampleChooser outOfSampleChooser = new OutOfSampleChooserForSingleLongAndShort( ! 0.01 , 0.03 , 0.01 , 0.03 ); // outOfSampleChooser = // new OutOfSampleChooserForExactNumberOfBestLongPositions( // 2 , 0.006 , 0.99 , 0.006 , 0.99 ); outOfSampleChooser = new OutOfSampleChooserForAlreadyClosing( ! 0.01 , 0.03 , 0.01 , 0.03 , 4 ); IStrategyForBacktester strategyForBacktester = --- 261,274 ---- OutOfSampleChooser outOfSampleChooser = new OutOfSampleChooserForSingleLongAndShort( ! this.firstTimeToTestInefficiency , 0.01 , 0.03 , 0.01 , 0.03 ); // outOfSampleChooser = // new OutOfSampleChooserForExactNumberOfBestLongPositions( // 2 , 0.006 , 0.99 , 0.006 , 0.99 ); + IInefficiencyCorrectionDetector inefficiencyCorrectionDetector = + new ConsecutiveMinutesOfCorrectionDetector( + this.historicalMarketValueProviderForChosingPositionsOutOfSample , 4 ); outOfSampleChooser = new OutOfSampleChooserForAlreadyClosing( ! 0.006 , 0.03 , 0.006 , 0.03 , inefficiencyCorrectionDetector ); IStrategyForBacktester strategyForBacktester = *************** *** 254,257 **** --- 281,288 ---- outOfSampleChooser ); + IExitStrategy exitStrategy = new TakeProfitStrategyOrOnMarketClose( + outOfSampleChooser.MinThresholdForGoingLong / 2 , + this.historicalMarketValueProviderForChosingPositionsOutOfSample ); + strategyForBacktester = new PairsTradingIntradayStrategy( *************** *** 264,277 **** this.historicalMarketValueProviderForInSample , this.historicalMarketValueProviderForChosingPositionsOutOfSample , ! outOfSampleChooser ); ! // qui!!! ! // strategyForBacktester = ! // new PairsTradingAfterClosingStrategy( ! // 7 , inSampleDays , ! // intervalsSelectorForInSample , ! // eligiblesSelector , inSampleChooser , ! // this.historicalMarketValueProviderForInSample , ! // this.historicalMarketValueProviderForChosingPositionsOutOfSample , ! // outOfSampleChooser ); return strategyForBacktester; } --- 295,302 ---- this.historicalMarketValueProviderForInSample , this.historicalMarketValueProviderForChosingPositionsOutOfSample , ! outOfSampleChooser , exitStrategy , ! new Time( 10 , 0 , 0 ) , ! new Time( 15 , 30 , 0 ) ! ); return strategyForBacktester; } *************** *** 302,308 **** firstDateTime = new DateTime( 2006 , 1 , 2 ); // lastDateTime = new DateTime( 2007 , 12 , 31 ); ! lastDateTime = new DateTime( 2006 , 1 , 31 ); ! double maxRunningHours = 2.5; EndOfDayStrategyBackTester endOfDayStrategyBackTester = --- 327,333 ---- firstDateTime = new DateTime( 2006 , 1 , 2 ); // lastDateTime = new DateTime( 2007 , 12 , 31 ); ! lastDateTime = new DateTime( 2006 , 12 , 31 ); ! double maxRunningHours = 11; EndOfDayStrategyBackTester endOfDayStrategyBackTester = *************** *** 322,326 **** { string pathForTheMainFolderWhereScriptsResultsAreToBeSaved = ! "C:\\qpReports\\pairsTrading\\"; return pathForTheMainFolderWhereScriptsResultsAreToBeSaved; } --- 347,351 ---- { string pathForTheMainFolderWhereScriptsResultsAreToBeSaved = ! @"T:\senzaBackup\qpReports\pairsTrading\"; return pathForTheMainFolderWhereScriptsResultsAreToBeSaved; } *************** *** 349,353 **** { string fullPathFileNameForMain = ! @"C:\QuantProject\QuantProject\b7_Scripts\WalkForwardTesting\PairsTrading\PairsTradingMain.cs"; return fullPathFileNameForMain; } --- 374,378 ---- { string fullPathFileNameForMain = ! @"T:\QuantProject\QuantProject\b7_Scripts\WalkForwardTesting\PairsTrading\PairsTradingMain.cs"; return fullPathFileNameForMain; } |