[Quantproject-developers] QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Logging TesterFo
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2008-03-19 23:31:06
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Logging In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv17050/b7_Scripts/WalkForwardTesting/PairsTrading/Logging Modified Files: TesterForPairsTradingTestingPositions.cs Log Message: - first bug fixed: now each of the two positions' weight is given the proper sign - second bug fixed: the cash to start the second position is always positive, now (sometimes it happened to be negative, in the previous revision) Index: TesterForPairsTradingTestingPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Logging/TesterForPairsTradingTestingPositions.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TesterForPairsTradingTestingPositions.cs 13 Mar 2008 19:33:14 -0000 1.1 --- TesterForPairsTradingTestingPositions.cs 19 Mar 2008 23:31:02 -0000 1.2 *************** *** 112,124 **** benchmark , cashToStart , maxRunningHours ); ! simpleStrategy.Account = endOfDayStrategyBackTester.Account; endOfDayStrategyBackTester.Run(); return endOfDayStrategyBackTester.AccountReport; } private WeightedPositions getWeightedPositions( WeightedPosition weightedPosition ) { ! double[] weights = { 1 }; string[] tickers = { weightedPosition.Ticker }; WeightedPositions weightedPositions = --- 112,134 ---- benchmark , cashToStart , maxRunningHours ); ! // simpleStrategy.Account = endOfDayStrategyBackTester.Account; endOfDayStrategyBackTester.Run(); return endOfDayStrategyBackTester.AccountReport; } + private double getWeightedPositions_getWeight( + WeightedPosition weightedPosition ) + { + double weight = 1; + if ( weightedPosition.IsShort ) + // the current WeightedPosition is short in the couple correlation + weight = -1; + return weight; + } private WeightedPositions getWeightedPositions( WeightedPosition weightedPosition ) { ! // double[] weights = { 1 }; ! double[] weights = { this.getWeightedPositions_getWeight( weightedPosition ) }; string[] tickers = { weightedPosition.Ticker }; WeightedPositions weightedPositions = *************** *** 159,164 **** historicalQuoteProvider , benchmark , ! 30000 * weightedPositions[ 1 ].Weight / ! weightedPositions[ 0 ].Weight ); Report report = --- 169,174 ---- historicalQuoteProvider , benchmark , ! Math.Abs( 30000 * weightedPositions[ 1 ].Weight / ! weightedPositions[ 0 ].Weight ) ); Report report = |