quantproject-developers Mailing List for QuantProject (Page 44)
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-05-11 18:55:22
|
Update of /cvsroot/quantproject/QuantProject/b4_Business In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv4736/b4_Business Modified Files: b4_Business.csproj Log Message: a2_Strategies\Eligibles\MostLiquidAndLessVolatile.cs has been removed. The class ByPriceMostLiquidLessVolatileOTCAlwaysQuoted should be used, instead Index: b4_Business.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/b4_Business.csproj,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** b4_Business.csproj 4 May 2008 22:43:57 -0000 1.67 --- b4_Business.csproj 11 May 2008 18:55:18 -0000 1.68 *************** *** 760,768 **** /> <File - RelPath = "a2_Strategies\Eligibles\MostLiquidAndLessVolatile.cs" - SubType = "Code" - BuildAction = "Compile" - /> - <File RelPath = "a2_Strategies\EndOfDayStrategies\BasicEndOfDayStrategyForBacktester.cs" SubType = "Code" --- 760,763 ---- |
|
From: Glauco S. <gla...@us...> - 2008-05-11 18:54:48
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Eligibles In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv4312 Removed Files: MostLiquidAndLessVolatile.cs Log Message: ByPriceMostLiquidLessVolatileOTCAlwaysQuoted should be used, instead --- MostLiquidAndLessVolatile.cs DELETED --- |
|
From: Glauco S. <gla...@us...> - 2008-05-11 18:53:11
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Collections In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv3469/b1_ADT/Collections Removed Files: StringArrayManager.cs Log Message: Array.Copy() is used now. --- StringArrayManager.cs DELETED --- |
|
From: Glauco S. <gla...@us...> - 2008-05-11 18:52:12
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv3060/b1_ADT Modified Files: b1_ADT.csproj Log Message: Collections\StringArrayManager.cs has been removed. The standard method Array.Copy() is used now. Index: b1_ADT.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/b1_ADT.csproj,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** b1_ADT.csproj 27 Apr 2008 17:36:54 -0000 1.31 --- b1_ADT.csproj 11 May 2008 18:52:06 -0000 1.32 *************** *** 183,191 **** /> <File - RelPath = "Collections\StringArrayManager.cs" - SubType = "Code" - BuildAction = "Compile" - /> - <File RelPath = "FileManaging\ObjectArchiver.cs" SubType = "Code" --- 183,186 ---- |
|
From: Glauco S. <gla...@us...> - 2008-05-11 17:52:13
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/InSample In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv17291/b7_Scripts/WalkForwardTesting/PairsTrading/InSample Modified Files: PairsTradingFitnessEvaluator.cs Log Message: The method PearsonCorrelationCoefficient with multipliers is not used anymore. Now the PearsonCorrelationCoefficient without wheigts is used: the result is then multiplied by the signs of the weights of the positions. Index: PairsTradingFitnessEvaluator.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/InSample/PairsTradingFitnessEvaluator.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PairsTradingFitnessEvaluator.cs 20 Apr 2008 17:12:35 -0000 1.3 --- PairsTradingFitnessEvaluator.cs 11 May 2008 17:52:09 -0000 1.4 *************** *** 90,98 **** float[] secondPositionReturns = returnsManager.GetReturns( secondPosition.Ticker ); double fitnessValue = BasicFunctions.PearsonCorrelationCoefficient( ! this.getMultiplierForReturns( firstPosition ) , firstPositionReturns , ! this.getMultiplierForReturns( secondPosition ) , secondPositionReturns ); ! // double fitnessValue = BasicFunctions.PearsonCorrelationCoefficient( ! // firstPositionReturns , secondPositionReturns ); return fitnessValue; } --- 90,103 ---- float[] secondPositionReturns = returnsManager.GetReturns( secondPosition.Ticker ); + // double fitnessValueOld = BasicFunctions.PearsonCorrelationCoefficient( + // this.getMultiplierForReturns( firstPosition ) , firstPositionReturns , + // this.getMultiplierForReturns( secondPosition ) , secondPositionReturns ); double fitnessValue = BasicFunctions.PearsonCorrelationCoefficient( ! firstPositionReturns , secondPositionReturns ); ! fitnessValue = fitnessValue * ! this.getMultiplierForReturns( firstPosition ) * ! this.getMultiplierForReturns( secondPosition ); ! // if ( fitnessValue != fitnessValueOld ) ! // fitnessValueNew +=0; return fitnessValue; } |
|
From: Glauco S. <gla...@us...> - 2008-05-11 17:50:32
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Statistics In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16368/b1_ADT/Statistics Modified Files: BasicFunctions.cs Log Message: The method that computes the PearsonCorrelationCoefficient with multipliers has been commented out Index: BasicFunctions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Statistics/BasicFunctions.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** BasicFunctions.cs 20 Apr 2008 17:09:16 -0000 1.12 --- BasicFunctions.cs 11 May 2008 17:50:22 -0000 1.13 *************** *** 274,341 **** } ! #region PearsonCorrelationCoefficient with multipliers ! static private void checkMultiplierIsNonZero( double multiplier ) ! { ! if ( multiplier == 0 ) ! throw new Exception( "A multiplier cannot be zero!" ); ! } ! static private void pearsonCorrelationCoefficient_checkParameters( ! double firstArrayMultiplier , float[] firstDataVariable, ! double secondArrayMultiplier , float[] secondDataVariable ) ! { ! BasicFunctions.checkLengthOfDataVariables(firstDataVariable, secondDataVariable); ! checkMultiplierIsNonZero( firstArrayMultiplier ); ! checkMultiplierIsNonZero( secondArrayMultiplier ); ! } ! /// <summary> ! /// Computes the Pearson's Correlation Coefficient for two weighted arrays ! /// </summary> ! /// <param name="firstMultiplier">multiplies each value of the ! /// first data set</param> ! /// <param name="firstDataVariable">first data set</param> ! /// <param name="secondMultiplier">multiplies each value of the second ! /// data set</param> ! /// <param name="secondDataVariable">second data set</param> ! /// <returns></returns> ! static public double PearsonCorrelationCoefficient( ! double firstMultiplier , float[] firstDataVariable, ! double secondMultiplier , float[] secondDataVariable ) ! { ! pearsonCorrelationCoefficient_checkParameters( ! firstMultiplier , firstDataVariable, ! secondMultiplier , secondDataVariable ); ! int n = firstDataVariable.Length; ! double sumOfProduct = 0.0, sumOfFirst = 0.0, sumOfSecond = 0.0, ! sumOfSquaredFirst = 0.0, sumOfSquaredSecond = 0.0; ! double currentValueFromFirstDataSet , currentValueFromSecondDataSet; ! for(int i = 0; i < n; i++) ! { ! currentValueFromFirstDataSet = firstMultiplier * firstDataVariable[i]; ! currentValueFromSecondDataSet = secondMultiplier * secondDataVariable[i]; ! sumOfFirst += currentValueFromFirstDataSet; ! sumOfSecond += currentValueFromSecondDataSet; ! sumOfProduct += currentValueFromFirstDataSet * currentValueFromSecondDataSet; ! sumOfSquaredFirst += ! currentValueFromFirstDataSet * currentValueFromFirstDataSet; ! sumOfSquaredSecond += ! currentValueFromSecondDataSet * currentValueFromSecondDataSet; ! } ! double n1 = n*sumOfProduct; ! double n2 = sumOfFirst*sumOfSecond; ! double numerator = n*sumOfProduct - sumOfFirst*sumOfSecond; ! double d1 = n*sumOfSquaredFirst; ! double d2 = sumOfFirst*sumOfFirst; ! double d3 = n*sumOfSquaredSecond; ! double d4 = sumOfSecond*sumOfSecond; ! double d5 = d1 - d2; ! double d6 = d3 - d4; ! double a1 = (n*sumOfSquaredFirst - sumOfFirst*sumOfFirst); ! double a2 = (n*sumOfSquaredSecond - sumOfSecond*sumOfSecond); ! ! return (n*sumOfProduct - sumOfFirst*sumOfSecond)/ ! Math.Sqrt( (n*sumOfSquaredFirst - sumOfFirst*sumOfFirst)* ! (n*sumOfSquaredSecond - sumOfSecond*sumOfSecond) ); ! } ! #endregion PearsonCorrelationCoefficient with multipliers --- 274,341 ---- } ! // #region PearsonCorrelationCoefficient with multipliers ! // static private void checkMultiplierIsNonZero( double multiplier ) ! // { ! // if ( multiplier == 0 ) ! // throw new Exception( "A multiplier cannot be zero!" ); ! // } ! // static private void pearsonCorrelationCoefficient_checkParameters( ! // double firstArrayMultiplier , float[] firstDataVariable, ! // double secondArrayMultiplier , float[] secondDataVariable ) ! // { ! // BasicFunctions.checkLengthOfDataVariables(firstDataVariable, secondDataVariable); ! // checkMultiplierIsNonZero( firstArrayMultiplier ); ! // checkMultiplierIsNonZero( secondArrayMultiplier ); ! // } ! // /// <summary> ! // /// Computes the Pearson's Correlation Coefficient for two weighted arrays ! // /// </summary> ! // /// <param name="firstMultiplier">multiplies each value of the ! // /// first data set</param> ! // /// <param name="firstDataVariable">first data set</param> ! // /// <param name="secondMultiplier">multiplies each value of the second ! // /// data set</param> ! // /// <param name="secondDataVariable">second data set</param> ! // /// <returns></returns> ! // static public double PearsonCorrelationCoefficient( ! // double firstMultiplier , float[] firstDataVariable, ! // double secondMultiplier , float[] secondDataVariable ) ! // { ! // pearsonCorrelationCoefficient_checkParameters( ! // firstMultiplier , firstDataVariable, ! // secondMultiplier , secondDataVariable ); ! // int n = firstDataVariable.Length; ! // double sumOfProduct = 0.0, sumOfFirst = 0.0, sumOfSecond = 0.0, ! // sumOfSquaredFirst = 0.0, sumOfSquaredSecond = 0.0; ! // double currentValueFromFirstDataSet , currentValueFromSecondDataSet; ! // for(int i = 0; i < n; i++) ! // { ! // currentValueFromFirstDataSet = firstMultiplier * firstDataVariable[i]; ! // currentValueFromSecondDataSet = secondMultiplier * secondDataVariable[i]; ! // sumOfFirst += currentValueFromFirstDataSet; ! // sumOfSecond += currentValueFromSecondDataSet; ! // sumOfProduct += currentValueFromFirstDataSet * currentValueFromSecondDataSet; ! // sumOfSquaredFirst += ! // currentValueFromFirstDataSet * currentValueFromFirstDataSet; ! // sumOfSquaredSecond += ! // currentValueFromSecondDataSet * currentValueFromSecondDataSet; ! // } ! // double n1 = n*sumOfProduct; ! // double n2 = sumOfFirst*sumOfSecond; ! // double numerator = n*sumOfProduct - sumOfFirst*sumOfSecond; ! // double d1 = n*sumOfSquaredFirst; ! // double d2 = sumOfFirst*sumOfFirst; ! // double d3 = n*sumOfSquaredSecond; ! // double d4 = sumOfSecond*sumOfSecond; ! // double d5 = d1 - d2; ! // double d6 = d3 - d4; ! // double a1 = (n*sumOfSquaredFirst - sumOfFirst*sumOfFirst); ! // double a2 = (n*sumOfSquaredSecond - sumOfSecond*sumOfSecond); ! // ! // return (n*sumOfProduct - sumOfFirst*sumOfSecond)/ ! // Math.Sqrt( (n*sumOfSquaredFirst - sumOfFirst*sumOfFirst)* ! // (n*sumOfSquaredSecond - sumOfSecond*sumOfSecond) ); ! // } ! // #endregion PearsonCorrelationCoefficient with multipliers |
|
From: Glauco S. <gla...@us...> - 2008-05-11 17:01:10
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Logging In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv28160/b7_Scripts/WalkForwardTesting/PairsTrading/Logging Modified Files: SimpleStrategy.cs Log Message: Now two IIntervalSelector(s) are used: one to create in sample intervals; one to be used by the strategy out of sample Index: SimpleStrategy.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Logging/SimpleStrategy.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SimpleStrategy.cs 30 Mar 2008 15:58:50 -0000 1.3 --- SimpleStrategy.cs 11 May 2008 17:01:05 -0000 1.4 *************** *** 45,49 **** IIntervalsSelector intervalsSelector , IHistoricalQuoteProvider historicalQuoteProvider ) : ! base( 999 , 1 , intervalsSelector , new DummyEligibleSelector() , new DummyInSampleChooser() , --- 45,49 ---- IIntervalsSelector intervalsSelector , IHistoricalQuoteProvider historicalQuoteProvider ) : ! base( 999 , 1 , intervalsSelector , intervalsSelector , new DummyEligibleSelector() , new DummyInSampleChooser() , |
|
From: Glauco S. <gla...@us...> - 2008-05-11 16:56:47
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Strategies In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv26020/b7_Scripts/WalkForwardTesting/PairsTrading/Strategies Modified Files: PairsTradingStrategy.cs Log Message: Now two IIntervalSelector(s) are used: one to create in sample intervals; one to be used by the strategy out of sample Index: PairsTradingStrategy.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Strategies/PairsTradingStrategy.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PairsTradingStrategy.cs 27 Apr 2008 17:53:49 -0000 1.2 --- PairsTradingStrategy.cs 11 May 2008 16:56:43 -0000 1.3 *************** *** 57,61 **** int numDaysBeetweenEachOtpimization , int numDaysForInSampleOptimization , ! IIntervalsSelector intervalsSelector , IEligiblesSelector eligiblesSelector , IInSampleChooser inSampleChooser , --- 57,62 ---- int numDaysBeetweenEachOtpimization , int numDaysForInSampleOptimization , ! IIntervalsSelector intervalsSelectorForInSample , ! IIntervalsSelector intervalsSelectorForOutOfSample , IEligiblesSelector eligiblesSelector , IInSampleChooser inSampleChooser , *************** *** 67,71 **** numDaysBeetweenEachOtpimization , numDaysForInSampleOptimization , ! intervalsSelector , eligiblesSelector , inSampleChooser , --- 68,73 ---- numDaysBeetweenEachOtpimization , numDaysForInSampleOptimization , ! intervalsSelectorForInSample , ! intervalsSelectorForOutOfSample , eligiblesSelector , inSampleChooser , |
|
From: Glauco S. <gla...@us...> - 2008-05-11 16:56:21
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/EndOfDayStrategies In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv25973/b4_Business/a2_Strategies/EndOfDayStrategies Modified Files: SymmetricEndOfDayStrategyForBacktester.cs Log Message: Now two IIntervalSelector(s) are used: one to create in sample intervals; one to be used by the strategy out of sample Index: SymmetricEndOfDayStrategyForBacktester.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/EndOfDayStrategies/SymmetricEndOfDayStrategyForBacktester.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SymmetricEndOfDayStrategyForBacktester.cs 13 Apr 2008 16:23:54 -0000 1.1 --- SymmetricEndOfDayStrategyForBacktester.cs 11 May 2008 16:56:17 -0000 1.2 *************** *** 45,49 **** int numDaysBeetweenEachOtpimization , int numDaysForInSampleOptimization , ! IIntervalsSelector intervalsSelector , IEligiblesSelector eligiblesSelector , IInSampleChooser inSampleChooser , --- 45,50 ---- int numDaysBeetweenEachOtpimization , int numDaysForInSampleOptimization , ! IIntervalsSelector intervalsSelectorForInSample , ! IIntervalsSelector intervalsSelectorForOutOfSample , IEligiblesSelector eligiblesSelector , IInSampleChooser inSampleChooser , *************** *** 52,56 **** numDaysBeetweenEachOtpimization , numDaysForInSampleOptimization , ! intervalsSelector , eligiblesSelector , inSampleChooser , --- 53,58 ---- numDaysBeetweenEachOtpimization , numDaysForInSampleOptimization , ! intervalsSelectorForInSample , ! intervalsSelectorForOutOfSample , eligiblesSelector , inSampleChooser , |
|
From: Glauco S. <gla...@us...> - 2008-05-11 16:54:38
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv25113/b7_Scripts/WalkForwardTesting/PairsTrading Modified Files: PairsTradingMain.cs Log Message: Added code in order to: - use two IIntervalsSelector(s): one to create intervals for in sample optimizations; one to create the intervals to be used by the strategy, out of sample - use an OTC-CTO in sample optimization (markte close to market open correlation is considered also); the code now is commented out: uncomment it if you want CTO optimization also Index: PairsTradingMain.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/PairsTradingMain.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** PairsTradingMain.cs 3 May 2008 17:55:44 -0000 1.13 --- PairsTradingMain.cs 11 May 2008 16:54:33 -0000 1.14 *************** *** 69,73 **** new HistoricalAdjustedQuoteProvider(); this.historicalQuoteProviderForTheBacktesterAccount = ! this.historicalQuoteProviderForInSample; // definition for the Fitness Evaluator --- 69,73 ---- new HistoricalAdjustedQuoteProvider(); this.historicalQuoteProviderForTheBacktesterAccount = ! new HistoricalRawQuoteProvider(); // definition for the Fitness Evaluator *************** *** 93,100 **** maxNumberOfEligiblesToBeChosen , 10 , 20 , 75 ); // uncomment the following line for a (logbased) log based in sample chooser ! eligiblesSelector = new DummyEligibleSelector(); return eligiblesSelector; --- 93,107 ---- maxNumberOfEligiblesToBeChosen , 10 , 20 , 75 ); + eligiblesSelector = + new ByPriceMostLiquidLessVolatileOTCAlwaysQuoted( + tickersGroupId , + true , + maxNumberOfEligiblesToBeChosen , + maxNumberOfEligiblesToBeChosen + 50 , + 10 , 10 , 20 , 75 ); // uncomment the following line for a (logbased) log based in sample chooser ! // eligiblesSelector = new DummyEligibleSelector(); return eligiblesSelector; *************** *** 141,148 **** // uncomment the following line for a (logbased) log based in sample chooser ! inSampleChooser = ! new PairsTradingChooserFromSavedBackTestLog( ! @"C:\qpReports\pairsTrading\longOnly\2008_04_27_4_41_53_pairsTrdng2Long_from_2001_01_01_to_2004_12_31_annlRtrn_128.52_maxDD_25.70\2008_04_27_4_41_53_pairsTrdng_from_2001_01_01_to_2004_12_31_annlRtrn_128.52_maxDD_25.70.qpL", ! numberOfBestTestingPositionsToBeReturned); --- 148,155 ---- // uncomment the following line for a (logbased) log based in sample chooser ! // inSampleChooser = ! // new PairsTradingChooserFromSavedBackTestLog( ! // @"C:\qpReports\pairsTrading\longOnly\2008_04_27_4_41_53_pairsTrdng2Long_from_2001_01_01_to_2004_12_31_annlRtrn_128.52_maxDD_25.70\2008_04_27_4_41_53_pairsTrdng_from_2001_01_01_to_2004_12_31_annlRtrn_128.52_maxDD_25.70.qpL", ! // numberOfBestTestingPositionsToBeReturned); *************** *** 157,173 **** // inSampleDays = 60; ! IIntervalsSelector intervalsSelector = new OddIntervalsSelector( 1 , 1 , this.benchmark ); OutOfSampleChooser outOfSampleChooser = new OutOfSampleChooserForSingleLongAndShort( ! 0.006 , 0.99 , 0.006 , 0.99 ); ! outOfSampleChooser = ! new OutOfSampleChooserForExactNumberOfBestLongPositions( ! 2 , 0.006 , 0.99 , 0.006 , 0.99 ); IEndOfDayStrategyForBacktester endOfDayStrategyForBacktester = new PairsTradingStrategy( ! 7 , inSampleDays , intervalsSelector , eligiblesSelector , inSampleChooser , this.historicalQuoteProviderForInSample , --- 164,190 ---- // inSampleDays = 60; ! IIntervalsSelector intervalsSelectorForOutOfSample = new OddIntervalsSelector( 1 , 1 , this.benchmark ); + IIntervalsSelector intervalsSelectorForInSample = + intervalsSelectorForOutOfSample; + + // uncomment the following two statements in order to use an + // OTC-CTO in sample optimization (night is considered also) + // intervalsSelectorForInSample = + // new FixedLengthTwoPhasesIntervalsSelector( 1 , 1 , this.benchmark ); + // this.historicalQuoteProviderForInSample = + // new HistoricalAdjustedQuoteProvider(); OutOfSampleChooser outOfSampleChooser = new OutOfSampleChooserForSingleLongAndShort( ! 0.006 , 0.02 , 0.006 , 0.02 ); ! // outOfSampleChooser = ! // new OutOfSampleChooserForExactNumberOfBestLongPositions( ! // 2 , 0.006 , 0.99 , 0.006 , 0.99 ); IEndOfDayStrategyForBacktester endOfDayStrategyForBacktester = new PairsTradingStrategy( ! 7 , inSampleDays , ! intervalsSelectorForInSample , intervalsSelectorForOutOfSample , eligiblesSelector , inSampleChooser , this.historicalQuoteProviderForInSample , *************** *** 197,206 **** double cashToStart = 30000; ! DateTime firstDateTime = new DateTime( 2001 , 1 , 1 ); ! DateTime lastDateTime = new DateTime( 2004 , 12 , 31 ); // uncomment the following line for a faster script // lastDateTime = new DateTime( 2001 , 1 , 31 ); ! double maxRunningHours = 7; EndOfDayStrategyBackTester endOfDayStrategyBackTester = --- 214,223 ---- double cashToStart = 30000; ! DateTime firstDateTime = new DateTime( 2005 , 1 , 1 ); ! DateTime lastDateTime = new DateTime( 2008 , 4 , 30 ); // uncomment the following line for a faster script // lastDateTime = new DateTime( 2001 , 1 , 31 ); ! double maxRunningHours = 8; EndOfDayStrategyBackTester endOfDayStrategyBackTester = |
|
From: Glauco S. <gla...@us...> - 2008-05-11 16:39:33
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/OutOfSampleChoosers In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv18367/b7_Scripts/WalkForwardTesting/PairsTrading/OutOfSampleChoosers Modified Files: OutOfSampleChooserForExactNumberOfBestLongPositions.cs Log Message: Some commented code has been added: comment it out in order to test a strategy where only the second best long position is chosen Index: OutOfSampleChooserForExactNumberOfBestLongPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/OutOfSampleChoosers/OutOfSampleChooserForExactNumberOfBestLongPositions.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OutOfSampleChooserForExactNumberOfBestLongPositions.cs 27 Apr 2008 17:43:58 -0000 1.1 --- OutOfSampleChooserForExactNumberOfBestLongPositions.cs 11 May 2008 16:39:28 -0000 1.2 *************** *** 100,103 **** --- 100,109 ---- string[] tickers = StringArrayManager.SubArray( longPositionTickers , 0 , this.exactNumberOfBestLongPositionsToBeReturned ); + + // comment out the following three lines to select only the second best long ticker + // weights = new double[ 1 ]; weights[ 0 ] = 1; + // tickers = new String[ 1 ]; + // Array.Copy( longPositionTickers , 1 , tickers , 0 , 1 ); + WeightedPositions weightedPositionsToOpened = new WeightedPositions( weights , tickers ); |
|
From: Glauco S. <gla...@us...> - 2008-05-11 16:37:39
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/EndOfDayStrategies In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv17535/b4_Business/a2_Strategies/EndOfDayStrategies Modified Files: BasicEndOfDayStrategyForBacktester.cs Log Message: Now two IIntervalSelector(s) are used: one to create in sample intervals; one to be used by the strategy out of sample Index: BasicEndOfDayStrategyForBacktester.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/EndOfDayStrategies/BasicEndOfDayStrategyForBacktester.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** BasicEndOfDayStrategyForBacktester.cs 27 Apr 2008 17:49:01 -0000 1.5 --- BasicEndOfDayStrategyForBacktester.cs 11 May 2008 16:37:31 -0000 1.6 *************** *** 51,55 **** protected int numDaysBeetweenEachOtpimization; protected int numDaysForInSampleOptimization; ! protected IIntervalsSelector intervalsSelector; protected IEligiblesSelector eligiblesSelector; protected IInSampleChooser inSampleChooser; --- 51,56 ---- protected int numDaysBeetweenEachOtpimization; protected int numDaysForInSampleOptimization; ! protected IIntervalsSelector intervalsSelectorForInSample; ! protected IIntervalsSelector intervalsSelectorForOutOfSample; protected IEligiblesSelector eligiblesSelector; protected IInSampleChooser inSampleChooser; *************** *** 108,112 **** int numDaysBeetweenEachOtpimization , int numDaysForInSampleOptimization , ! IIntervalsSelector intervalsSelector , IEligiblesSelector eligiblesSelector , IInSampleChooser inSampleChooser , --- 109,114 ---- int numDaysBeetweenEachOtpimization , int numDaysForInSampleOptimization , ! IIntervalsSelector intervalsSelectorForInSample , ! IIntervalsSelector intervalsSelectorForOutOfSample , IEligiblesSelector eligiblesSelector , IInSampleChooser inSampleChooser , *************** *** 116,120 **** this.numDaysBeetweenEachOtpimization = numDaysBeetweenEachOtpimization; this.numDaysForInSampleOptimization = numDaysForInSampleOptimization; ! this.intervalsSelector = intervalsSelector; this.eligiblesSelector = eligiblesSelector; this.inSampleChooser = inSampleChooser; --- 118,123 ---- this.numDaysBeetweenEachOtpimization = numDaysBeetweenEachOtpimization; this.numDaysForInSampleOptimization = numDaysForInSampleOptimization; ! this.intervalsSelectorForInSample = intervalsSelectorForInSample; ! this.intervalsSelectorForOutOfSample = intervalsSelectorForOutOfSample; this.eligiblesSelector = eligiblesSelector; this.inSampleChooser = inSampleChooser; *************** *** 123,127 **** this.returnIntervals = ! new ReturnIntervals( this.intervalsSelector ); } --- 126,130 ---- this.returnIntervals = ! new ReturnIntervals( this.intervalsSelectorForOutOfSample ); } *************** *** 218,222 **** EndOfDaySpecificTime.MarketClose ); ReturnIntervals inSampleReturnIntervals = ! new ReturnIntervals( this.intervalsSelector ); inSampleReturnIntervals.AppendFirstInterval( firstDate ); if ( inSampleReturnIntervals.LastEndOfDayDateTime.IsLessThan( --- 221,225 ---- EndOfDaySpecificTime.MarketClose ); ReturnIntervals inSampleReturnIntervals = ! new ReturnIntervals( this.intervalsSelectorForInSample ); inSampleReturnIntervals.AppendFirstInterval( firstDate ); if ( inSampleReturnIntervals.LastEndOfDayDateTime.IsLessThan( |
|
From: Marco M. <mi...@us...> - 2008-05-04 22:46:40
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Eligibles In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv3850/a2_Strategies/Eligibles Modified Files: ByPriceMostLiquidLessVolatileOTCAlwaysQuoted.cs Log Message: Updated summary comment to the class Index: ByPriceMostLiquidLessVolatileOTCAlwaysQuoted.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Eligibles/ByPriceMostLiquidLessVolatileOTCAlwaysQuoted.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ByPriceMostLiquidLessVolatileOTCAlwaysQuoted.cs 4 May 2008 22:43:30 -0000 1.1 --- ByPriceMostLiquidLessVolatileOTCAlwaysQuoted.cs 4 May 2008 22:46:33 -0000 1.2 *************** *** 34,41 **** /// Implements IEligiblesSelector for selecting a given max number of tickers through /// the following step-by-step selecting process: ! /// -step 1: all tickers belonging to a given group /// are selected (the group can be "temporized": that is tickers /// are returned depending on the time the selection is requested: /// the group SP 500 should be like that); /// -step 2: from tickers selected by step 1, the most liquid /// are selected (not more than maxNumberOfMostLiquidTickersToBeChosen); --- 34,44 ---- /// Implements IEligiblesSelector for selecting a given max number of tickers through /// the following step-by-step selecting process: ! /// -step 0: all tickers belonging to a given group /// are selected (the group can be "temporized": that is tickers /// are returned depending on the time the selection is requested: /// the group SP 500 should be like that); + /// -step 1: from tickers selected by step 0, the ones that have + /// the average raw open price falling in a given range (for the last given number of days) + /// are selected; /// -step 2: from tickers selected by step 1, the most liquid /// are selected (not more than maxNumberOfMostLiquidTickersToBeChosen); |
|
From: Marco M. <mi...@us...> - 2008-05-04 22:44:11
|
Update of /cvsroot/quantproject/QuantProject/b4_Business In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv2344 Modified Files: b4_Business.csproj Business_SD.csproj Log Message: Added ByPriceMostLiquidLessVolatileOTCAlwaysQuoted. Index: Business_SD.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/Business_SD.csproj,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** Business_SD.csproj 26 Apr 2008 09:57:00 -0000 1.24 --- Business_SD.csproj 4 May 2008 22:43:57 -0000 1.25 *************** *** 75,78 **** --- 75,79 ---- <Compile Include="a2_Strategies\Benchmark.cs" /> <Compile Include="a2_Strategies\Eligibles\ByPriceLessVolatileOTCAlwaysQuoted.cs" /> + <Compile Include="a2_Strategies\Eligibles\ByPriceMostLiquidLessVolatileOTCAlwaysQuoted.cs" /> <Compile Include="a2_Strategies\Eligibles\DummyEligibleSelector.cs" /> <Compile Include="a2_Strategies\Eligibles\ByPriceMostLiquidAlwaysQuoted.cs" /> Index: b4_Business.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/b4_Business.csproj,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** b4_Business.csproj 26 Apr 2008 09:56:59 -0000 1.66 --- b4_Business.csproj 4 May 2008 22:43:57 -0000 1.67 *************** *** 740,743 **** --- 740,748 ---- /> <File + RelPath = "a2_Strategies\Eligibles\ByPriceMostLiquidLessVolatileOTCAlwaysQuoted.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "a2_Strategies\Eligibles\DummyEligibleSelector.cs" SubType = "Code" |
|
From: Marco M. <mi...@us...> - 2008-05-04 22:43:35
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Eligibles In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv2300/a2_Strategies/Eligibles Added Files: ByPriceMostLiquidLessVolatileOTCAlwaysQuoted.cs Log Message: Added ByPriceMostLiquidLessVolatileOTCAlwaysQuoted: this class Implements IEligiblesSelector for selecting a given max number of tickers through the following step-by-step selecting process: -step 0: all tickers belonging to a given group are selected (the group can be "temporized": that is tickers are returned depending on the time the selection is requested: the group SP 500 should be like that); -step 1: from tickers selected by step 0, the ones that have the average raw open price falling in a given range (for the last given number of days) are selected; -step 2: from tickers selected by step 1, the most liquid are selected (not more than maxNumberOfMostLiquidTickersToBeChosen); -step 3: from tickers selected by step 2, the ones that are less volatile (OTC returns in the last numOfDaysForVolatilityComputation days are analyzed) are selected (not more than maxNumberOfEligibleTickersToBeChosen); -step 4: from tickers selected by step 3, the ones that are always quoted at all market days are selected (not more than maxNumberOfEligibleTickersToBeChosen); --- NEW FILE: ByPriceMostLiquidLessVolatileOTCAlwaysQuoted.cs --- /* QuantProject - Quantitative Finance Library ByPriceMostLiquidLessVolatileOTCAlwaysQuoted.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 QuantProject.ADT.Messaging; using QuantProject.Business.Strategies.ReturnsManagement.Time; using QuantProject.Business.Timing; using QuantProject.Data.Selectors; namespace QuantProject.Business.Strategies.Eligibles { /// <summary> /// Implements IEligiblesSelector for selecting a given max number of tickers through /// the following step-by-step selecting process: /// -step 1: all tickers belonging to a given group /// are selected (the group can be "temporized": that is tickers /// are returned depending on the time the selection is requested: /// the group SP 500 should be like that); /// -step 2: from tickers selected by step 1, the most liquid /// are selected (not more than maxNumberOfMostLiquidTickersToBeChosen); /// -step 3: from tickers selected by step 2, the ones that are /// less volatile (OTC returns in the last /// numOfDaysForVolatilityComputation days /// are analyzed) are selected /// (not more than maxNumberOfEligibleTickersToBeChosen); /// -step 4: from tickers selected by step 3, the ones that are /// always quoted at all market days are selected /// (not more than maxNumberOfEligibleTickersToBeChosen); /// </summary> public class ByPriceMostLiquidLessVolatileOTCAlwaysQuoted : IEligiblesSelector { public event NewMessageEventHandler NewMessage; private bool temporizedGroup; private string tickersGroupID; private int maxNumberOfEligibleTickersToBeChosen; private int maxNumberOfMostLiquidTickersToBeChosen; private int numOfDaysForAverageOpenRawPriceComputation; private int numOfDaysForVolatilityComputation; private double minPrice; private double maxPrice; public string Description { get{ return "ByPriceMostLiquidLessVolatileOTCAlwaysQuoted"; } } private void byPriceMostLiquidLessVolatileOTCAlwaysQuoted_checkParameters() { if(this.maxNumberOfMostLiquidTickersToBeChosen <= this.maxNumberOfEligibleTickersToBeChosen) throw new Exception("The set of the most liquid tickers has to " + "be greater than the final set of eligibles tickers!"); } public ByPriceMostLiquidLessVolatileOTCAlwaysQuoted( string tickersGroupID , bool temporizedGroup, int maxNumberOfEligibleTickersToBeChosen, int maxNumberOfMostLiquidTickersToBeChosen, int numOfDaysForAverageOpenRawPriceComputation, int numOfDaysForVolatilityComputation, double minPrice, double maxPrice) { this.temporizedGroup = temporizedGroup; this.tickersGroupID = tickersGroupID; this.maxNumberOfEligibleTickersToBeChosen = maxNumberOfEligibleTickersToBeChosen; this.maxNumberOfMostLiquidTickersToBeChosen = maxNumberOfMostLiquidTickersToBeChosen; this.numOfDaysForAverageOpenRawPriceComputation = numOfDaysForAverageOpenRawPriceComputation; this.numOfDaysForVolatilityComputation = numOfDaysForVolatilityComputation; this.minPrice = minPrice; this.maxPrice = maxPrice; this.byPriceMostLiquidLessVolatileOTCAlwaysQuoted_checkParameters(); } private EligibleTickers getEligibleTickers_actually( EndOfDayHistory endOfDayHistory ) { DateTime currentDate = endOfDayHistory.LastEndOfDayDateTime.DateTime; SelectorByGroup group; if(this.temporizedGroup) //the group is "temporized": returned set of tickers // depends on time group = new SelectorByGroup(this.tickersGroupID, currentDate); else//the group is not temporized group = new SelectorByGroup(this.tickersGroupID); DataTable tickersFromGroup = group.GetTableOfSelectedTickers(); int numOfTickersInGroupAtCurrentDate = tickersFromGroup.Rows.Count; SelectorByAverageRawOpenPrice byPrice = new SelectorByAverageRawOpenPrice(tickersFromGroup,false, currentDate.AddDays(-this.numOfDaysForAverageOpenRawPriceComputation), currentDate, numOfTickersInGroupAtCurrentDate, this.minPrice,this.maxPrice, 0.00001, double.MaxValue); DataTable dataTableByPrice = byPrice.GetTableOfSelectedTickers(); SelectorByLiquidity mostLiquidSelector = new SelectorByLiquidity( dataTableByPrice , false, endOfDayHistory.FirstEndOfDayDateTime.DateTime, currentDate, this.maxNumberOfMostLiquidTickersToBeChosen); DataTable dataTableMostLiquid = mostLiquidSelector.GetTableOfSelectedTickers(); SelectorByOpenToCloseVolatility lessVolatileSelector = new SelectorByOpenToCloseVolatility( dataTableMostLiquid , true, currentDate.AddDays(-this.numOfDaysForVolatilityComputation), currentDate, this.maxNumberOfEligibleTickersToBeChosen); DataTable dataTableLessVolatile = lessVolatileSelector.GetTableOfSelectedTickers(); // DataSet dataSet = new DataSet(); // dataSet.Tables.Add( dataTableLessVolatile ); // dataSet.WriteXml( "c:\\qpReports\\pairsTrading\\eligiblesCon_ByPriceMostLiquidLessVolatileOTCAlwaysQuoted.xml" ); SelectorByQuotationAtEachMarketDay quotedAtEachMarketDayFromLastSelection = new SelectorByQuotationAtEachMarketDay( dataTableLessVolatile , false, endOfDayHistory.History, this.maxNumberOfEligibleTickersToBeChosen); DataTable dataTableToBeReturned = quotedAtEachMarketDayFromLastSelection.GetTableOfSelectedTickers(); return new EligibleTickers( dataTableToBeReturned ); } private void getEligibleTickers_sendNewMessage( EligibleTickers eligibleTickers ) { string message = "Number of Eligible tickers: " + eligibleTickers.Count; NewMessageEventArgs newMessageEventArgs = new NewMessageEventArgs( message ); if(this.NewMessage != null) this.NewMessage( this , newMessageEventArgs ); } /// <summary> /// Returns the eligible tickers /// </summary> /// <returns></returns> public EligibleTickers GetEligibleTickers( EndOfDayHistory endOfDayHistory ) { EligibleTickers eligibleTickers = this.getEligibleTickers_actually( endOfDayHistory ); this.getEligibleTickers_sendNewMessage( eligibleTickers ); return eligibleTickers; } } } |
|
From: Glauco S. <gla...@us...> - 2008-05-03 18:56:47
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv7198/b7_Scripts/WalkForwardTesting/PairsTrading Modified Files: PairsTradingMain.cs Log Message: Some code has been added, in order to use a PairsTradingChooserFromSavedBackTestLog Index: PairsTradingMain.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/PairsTradingMain.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** PairsTradingMain.cs 27 Apr 2008 17:50:53 -0000 1.12 --- PairsTradingMain.cs 3 May 2008 17:55:44 -0000 1.13 *************** *** 93,96 **** --- 93,101 ---- maxNumberOfEligiblesToBeChosen , 10 , 20 , 75 ); + + + // uncomment the following line for a (logbased) log based in sample chooser + eligiblesSelector = new DummyEligibleSelector(); + return eligiblesSelector; } *************** *** 133,136 **** --- 138,150 ---- decoderForWeightedPositions , fitnessEvaluator ); + + + // uncomment the following line for a (logbased) log based in sample chooser + inSampleChooser = + new PairsTradingChooserFromSavedBackTestLog( + @"C:\qpReports\pairsTrading\longOnly\2008_04_27_4_41_53_pairsTrdng2Long_from_2001_01_01_to_2004_12_31_annlRtrn_128.52_maxDD_25.70\2008_04_27_4_41_53_pairsTrdng_from_2001_01_01_to_2004_12_31_annlRtrn_128.52_maxDD_25.70.qpL", + numberOfBestTestingPositionsToBeReturned); + + return inSampleChooser; } |
|
From: Glauco S. <gla...@us...> - 2008-05-03 18:56:46
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Logging In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv6086/b7_Scripts/WalkForwardTesting/PairsTrading/Logging Modified Files: PairsTradingLogItem.cs Log Message: The public method GetTestingPositions() has been added Index: PairsTradingLogItem.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Logging/PairsTradingLogItem.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PairsTradingLogItem.cs 30 Mar 2008 15:47:50 -0000 1.4 --- PairsTradingLogItem.cs 3 May 2008 17:54:28 -0000 1.5 *************** *** 128,215 **** } #endregion setTestersForPairstTradingTestingPositions ! // private AccountReport getAccountReport( ! // WeightedPositions weightedPositions , ! // IIntervalsSelector intervalsSelector , ! // IHistoricalQuoteProvider historicalQuoteProvider , ! // Benchmark benchmark , ! // double cashToStart ) ! // { ! // SimpleStrategy simpleStrategy = ! // new SimpleStrategy( weightedPositions , ! // intervalsSelector , historicalQuoteProvider ); ! // ! // DateTime firstDateTime = this.simulatedCreationTime.DateTime.AddDays( -90 ); ! // DateTime lastDateTime = this.simulatedCreationTime.DateTime; ! // double maxRunningHours = 0.3; ! // EndOfDayStrategyBackTester endOfDayStrategyBackTester = ! // new EndOfDayStrategyBackTester( ! // "SinglePosition" , simpleStrategy , ! // historicalQuoteProvider , firstDateTime , ! // lastDateTime , 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 = ! // new WeightedPositions( weights , tickers ); ! // return weightedPositions; ! // } ! // public void Run3() ! // { ! //// string backTestId = "SimplePairsTrading"; ! //// double cashToStart = 30000; ! // ! // Benchmark benchmark = new Benchmark( "MSFT" ); ! // ! // IHistoricalQuoteProvider historicalQuoteProvider = ! // new HistoricalAdjustedQuoteProvider(); ! // ! //// IInSampleChooser inSampleChooser = ! //// (IInSampleChooser)new ConstantWeightedPositionsChooser( ! //// this.BestWeightedPositionsInSample ); ! // ! // IIntervalsSelector intervalsSelector = ! // new OddIntervalsSelector( 1 , 1 , benchmark ); ! // IEligiblesSelector eligiblesSelector = new DummyEligibleSelector(); ! // ! // WeightedPositions weightedPositions = ! // this.bestTestingPositionsInSample[ 0 ].WeightedPositions; ! // ! // WeightedPositions firstPosition = ! // this.getWeightedPositions( weightedPositions[ 0 ] ); ! // WeightedPositions secondPosition = ! // this.getWeightedPositions( weightedPositions[ 1 ] ); ! // AccountReport accountReportForFirstPosition = ! // this.getAccountReport( firstPosition , intervalsSelector , ! // historicalQuoteProvider , ! // benchmark , 30000 ); ! // AccountReport accountReportForSecondPosition = ! // this.getAccountReport( secondPosition , intervalsSelector , ! // historicalQuoteProvider , ! // benchmark , ! // 30000 * weightedPositions[ 1 ].Weight / ! // weightedPositions[ 0 ].Weight ); ! // ! // Report report = ! // new Report( accountReportForFirstPosition , false ); ! // EndOfDayDateTime lastEndOfDayDateTimeForReport = ! // new EndOfDayDateTime( ! // accountReportForFirstPosition.EquityLine.LastDateTime , ! // EndOfDaySpecificTime.OneHourAfterMarketClose ); ! // ! //// report.Create( "PearsonDebug" , 1 , ! //// lastEndOfDayDateTimeForReport , ! //// benchmark.Ticker , false ); ! // report.AddEquityLine( accountReportForSecondPosition.EquityLine , ! // Color.Brown ); ! // report.ShowDialog(); ! // } public override void Run() { --- 128,150 ---- } #endregion setTestersForPairstTradingTestingPositions ! ! /// <summary> ! /// We don't use a property instead of this method, ! /// to avoid it being shown in the log viewer list ! /// (it would be meaningless in the grid) ! /// </summary> ! public PairsTradingTestingPositions[] ! GetTestingPositions() ! { ! PairsTradingTestingPositions[] testingPositions = ! new PairsTradingTestingPositions[ ! this.testersForBestTestingPositionsInSample.Length ]; ! for ( int i = 0 ; ! i < this.testersForBestTestingPositionsInSample.Length ; i++ ) ! testingPositions[ i ] = ! this.testersForBestTestingPositionsInSample[ i ].TestingPositions; ! return testingPositions; ! } ! public override void Run() { |
|
From: Glauco S. <gla...@us...> - 2008-05-03 18:56:46
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv5032/b7_Scripts Modified Files: Scripts_SD.csproj Log Message: WalkForwardTesting\PairsTrading\InSample\InSampleChoosers\PairsTradingChooserFromSavedBackTestLog.cs has been added Index: Scripts_SD.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/Scripts_SD.csproj,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** Scripts_SD.csproj 28 Apr 2008 21:17:07 -0000 1.26 --- Scripts_SD.csproj 3 May 2008 17:53:48 -0000 1.27 *************** *** 111,114 **** --- 111,115 ---- <Compile Include="WalkForwardTesting\PairsTrading\InSample\InSampleChoosers\Genetic\DecoderForPairsTradingTestingPositionsWithBalancedWeights.cs" /> <Compile Include="WalkForwardTesting\PairsTrading\InSample\InSampleChoosers\Genetic\PairsTradingGeneticChooser.cs" /> + <Compile Include="WalkForwardTesting\PairsTrading\InSample\InSampleChoosers\PairsTradingChooserFromSavedBackTestLog.cs" /> <Compile Include="WalkForwardTesting\PairsTrading\InSample\PairsTradingFitnessEvaluator.cs" /> <Compile Include="WalkForwardTesting\PairsTrading\Logging\PairsTradingLogItem.cs" /> |
|
From: Glauco S. <gla...@us...> - 2008-05-03 18:56:40
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv4394/b7_Scripts Modified Files: b7_Scripts.csproj Log Message: WalkForwardTesting\PairsTrading\InSample\InSampleChoosers\PairsTradingChooserFromSavedBackTestLog.cs has been added Index: b7_Scripts.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/b7_Scripts.csproj,v retrieving revision 1.96 retrieving revision 1.97 diff -C2 -d -r1.96 -r1.97 *** b7_Scripts.csproj 27 Apr 2008 17:45:52 -0000 1.96 --- b7_Scripts.csproj 3 May 2008 17:53:16 -0000 1.97 *************** *** 930,933 **** --- 930,938 ---- /> <File + RelPath = "WalkForwardTesting\PairsTrading\InSample\InSampleChoosers\PairsTradingChooserFromSavedBackTestLog.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "WalkForwardTesting\PairsTrading\InSample\InSampleChoosers\BruteForce\PairsTradingBruteForceChooser.cs" SubType = "Code" |
|
From: Glauco S. <gla...@us...> - 2008-05-03 18:56:40
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/InSample/InSampleChoosers In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv2944/b7_Scripts/WalkForwardTesting/PairsTrading/InSample/InSampleChoosers Added Files: PairsTradingChooserFromSavedBackTestLog.cs Log Message: IInSampleChooser for returning PairsTradingPositions already saved in a BackTestLog saved to disk --- NEW FILE: PairsTradingChooserFromSavedBackTestLog.cs --- /* QuantProject - Quantitative Finance Library PairsTradingChooserFromSavedBackTestLog.cs Copyright (C) 2008 Glauco Siliprandi 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 QuantProject.Business.Timing; using QuantProject.Business.Strategies.InSample; using QuantProject.Business.Strategies.OutOfSample; namespace QuantProject.Scripts.WalkForwardTesting.PairsTrading { /// <summary> /// IInSampleChooser for returning PairsTradingPositions /// already saved in a BackTestLog saved to disk /// </summary> public class PairsTradingChooserFromSavedBackTestLog : BasicChooserFromSavedBackTestLog { public PairsTradingChooserFromSavedBackTestLog( string backTestLogFullPath , int numberOfBestTestingPositionsToBeReturned ) : base( backTestLogFullPath , numberOfBestTestingPositionsToBeReturned ) { int maxNumberOfTestingPositionsFromBackTestLogItems = ((PairsTradingLogItem)this.backTestLog[0]).GetTestingPositions().Length; if(numberOfBestTestingPositionsToBeReturned > maxNumberOfTestingPositionsFromBackTestLogItems) throw new Exception("Number of TestingPositions to be returned " + "is too high for the given BackTestLog"); } #region getTestingPositionsFromBackTestLog private void getTestingPositionsFromBackTestLog_checkParameters( EndOfDayDateTime currentOutOfSampleEndOfDayDateTime ) { if ( currentOutOfSampleEndOfDayDateTime.IsLessThan( this.backTestLog[ 0 ].SimulatedCreationTime ) ) throw new Exception( "The backTestLog doesn't contain any log item produced before the " + "requested DateTime!" ); } private int getIndexForLastLogItemProducedBeforeCurrentOutOfSampleEndOfDayDateTime( EndOfDayDateTime lastReturnsManagerDate ) { int currentIndexForLogItem = 1; while ( ( currentIndexForLogItem < this.backTestLog.Count ) && ( this.backTestLog[ currentIndexForLogItem ].SimulatedCreationTime.IsLessThanOrEqualTo( lastReturnsManagerDate ) ) ) currentIndexForLogItem++; int indexForLastLogItemProducedBeforeLastReturnsManagerDate; if ( currentIndexForLogItem >= this.backTestLog.Count ) // all the items in the log have a SimulatedCreationTime that's // less than or equal to lastReturnsManagerDate, thus the last // log item produced before lastReturnsManagerDate is the last in the log indexForLastLogItemProducedBeforeLastReturnsManagerDate = this.backTestLog.Count - 1; else // currentIndexForLogItem points to the first log item with a // SimulatedCreationTime that's greater than lastReturnsManagerDate // thus the last log item produced before lastReturnsManagerDate is // the previous one indexForLastLogItemProducedBeforeLastReturnsManagerDate = currentIndexForLogItem - 1; return indexForLastLogItemProducedBeforeLastReturnsManagerDate; } private TestingPositions[] getTestingPositions( int indexForLastLogItemProducedBeforeCurrentOutOfSampleEndOfDayDateTime ) { TestingPositions[] testingPositionsToBeReturned = new TestingPositions[ this.numberOfBestTestingPositionsToBeReturned ]; PairsTradingTestingPositions[] bestTestingPositionsInSample = ((PairsTradingLogItem)this.backTestLog[ indexForLastLogItemProducedBeforeCurrentOutOfSampleEndOfDayDateTime ] ).GetTestingPositions(); Array.Copy( bestTestingPositionsInSample , 0 , testingPositionsToBeReturned , 0 , testingPositionsToBeReturned.Length ); return testingPositionsToBeReturned; } private TestingPositions[] getTestingPositionsFromBackTestLog_withCurrentOutOfSampleEODDateTime( EndOfDayDateTime currentOutOfSampleEndOfDayDateTime ) { this.getTestingPositionsFromBackTestLog_checkParameters( currentOutOfSampleEndOfDayDateTime ); int indexForLastLogItemProducedBeforeCurrentOutOfSampleEndOfDayDateTime = this.getIndexForLastLogItemProducedBeforeCurrentOutOfSampleEndOfDayDateTime( currentOutOfSampleEndOfDayDateTime ); TestingPositions[] testingPositions = this.getTestingPositions( indexForLastLogItemProducedBeforeCurrentOutOfSampleEndOfDayDateTime ); return testingPositions; } protected override TestingPositions[] getTestingPositionsFromBackTestLog( EndOfDayDateTime lastReturnsManagerDate ) { EndOfDayDateTime currentOutOfSampleEndOfDayDateTime = new EndOfDayDateTime( lastReturnsManagerDate.DateTime , EndOfDaySpecificTime.OneHourAfterMarketClose ); TestingPositions[] testingPositions = this.getTestingPositionsFromBackTestLog_withCurrentOutOfSampleEODDateTime( currentOutOfSampleEndOfDayDateTime ); // TestingPositions[] testingPositions = // new TestingPositions[ this.numberOfBestTestingPositionsToBeReturned ]; // for( int i = 0; // i < this.backTestLog.Count; // i++ ) // { // if( this.backTestLog[i].SimulatedCreationTime.DateTime == // lastInSampleDateOfOptimizedTestingPositions.DateTime ) // { // Array.Copy( ((PVOLogItem)this.backTestLog[i]).BestPVOPositionsInSample , // 0, testingPositions, 0, numberOfBestTestingPositionsToBeReturned ); // i = this.backTestLog.Count; // } // } return testingPositions; } #endregion getTestingPositionsFromBackTestLog } } |
|
From: Glauco S. <gla...@us...> - 2008-05-03 18:56:39
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Logging In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv6441/b7_Scripts/WalkForwardTesting/PairsTrading/Logging Modified Files: TesterForPairsTradingTestingPositions.cs Log Message: The property TestingPositions has been added Index: TesterForPairsTradingTestingPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Logging/TesterForPairsTradingTestingPositions.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TesterForPairsTradingTestingPositions.cs 19 Mar 2008 23:31:02 -0000 1.2 --- TesterForPairsTradingTestingPositions.cs 3 May 2008 17:55:03 -0000 1.3 *************** *** 66,69 **** --- 66,73 ---- get { return this.testingPositions.WeightedPositions.Description; } } + public PairsTradingTestingPositions TestingPositions + { + get { return this.testingPositions; } + } public TesterForPairsTradingTestingPositions( TestingPositions testingPositions , |
|
From: Glauco S. <gla...@us...> - 2008-04-28 21:17:12
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv19325/b7_Scripts Modified Files: Scripts_SD.csproj Log Message: - WalkForwardTesting\PairsTrading\Strategies\LongOnlyPairsTradingStrategy.cs has been removed - WalkForwardTesting\PairsTrading\OutOfSampleChoosers\ has been added - WalkForwardTesting\PairsTrading\OutOfSampleChoosers\OutOfSampleChooser.cs has been added - WalkForwardTesting\PairsTrading\OutOfSampleChoosers\OutOfSampleChooserForExactNumberOfBestLongPositions.cs has been added - WalkForwardTesting\PairsTrading\OutOfSampleChoosers\OutOfSampleChooserForSingleLongAndShort.cs has been added - WalkForwardTesting\PairsTrading\OutOfSampleChoosers\OutOfSampleChooserForSingleLongPosition.cs has been added Index: Scripts_SD.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/Scripts_SD.csproj,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** Scripts_SD.csproj 26 Apr 2008 09:57:00 -0000 1.25 --- Scripts_SD.csproj 28 Apr 2008 21:17:07 -0000 1.26 *************** *** 115,122 **** <Compile Include="WalkForwardTesting\PairsTrading\Logging\SimpleStrategy.cs" /> <Compile Include="WalkForwardTesting\PairsTrading\Logging\TesterForPairsTradingTestingPositions.cs" /> <Compile Include="WalkForwardTesting\PairsTrading\PairsTradingMain.cs" /> <Compile Include="WalkForwardTesting\PairsTrading\PairsTradingTestingPositions.cs" /> <Compile Include="WalkForwardTesting\PairsTrading\Strategies\PairsTradingStrategy.cs" /> - <Compile Include="WalkForwardTesting\PairsTrading\Strategies\LongOnlyPairsTradingStrategy.cs" /> <Compile Include="WalkForwardTesting\WalkForwardLag\RunSimpleLag.cs" /> <Compile Include="WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\BruteForce\WFLagBruteForceWeightedPositionsChooserForBalancedFixedPortfolioAndBalancedDriving.cs" /> --- 115,125 ---- <Compile Include="WalkForwardTesting\PairsTrading\Logging\SimpleStrategy.cs" /> <Compile Include="WalkForwardTesting\PairsTrading\Logging\TesterForPairsTradingTestingPositions.cs" /> + <Compile Include="WalkForwardTesting\PairsTrading\OutOfSampleChoosers\OutOfSampleChooser.cs" /> + <Compile Include="WalkForwardTesting\PairsTrading\OutOfSampleChoosers\OutOfSampleChooserForExactNumberOfBestLongPositions.cs" /> + <Compile Include="WalkForwardTesting\PairsTrading\OutOfSampleChoosers\OutOfSampleChooserForSingleLongAndShort.cs" /> + <Compile Include="WalkForwardTesting\PairsTrading\OutOfSampleChoosers\OutOfSampleChooserForSingleLongPosition.cs" /> <Compile Include="WalkForwardTesting\PairsTrading\PairsTradingMain.cs" /> <Compile Include="WalkForwardTesting\PairsTrading\PairsTradingTestingPositions.cs" /> <Compile Include="WalkForwardTesting\PairsTrading\Strategies\PairsTradingStrategy.cs" /> <Compile Include="WalkForwardTesting\WalkForwardLag\RunSimpleLag.cs" /> <Compile Include="WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\BruteForce\WFLagBruteForceWeightedPositionsChooserForBalancedFixedPortfolioAndBalancedDriving.cs" /> *************** *** 295,298 **** --- 298,302 ---- <Folder Include="WalkForwardTesting\PairsTrading\InSample\InSampleChoosers\Genetic" /> <Folder Include="WalkForwardTesting\PairsTrading\Logging" /> + <Folder Include="WalkForwardTesting\PairsTrading\OutOfSampleChoosers" /> <Folder Include="WalkForwardTesting\PairsTrading\Strategies" /> <Folder Include="WalkForwardTesting\WalkForwardLag\WeightedPositionsChoosers\BruteForce" /> |
|
From: Glauco S. <gla...@us...> - 2008-04-28 21:12:28
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16971/b1_ADT Modified Files: ADT_SD.csproj Log Message: Collections\StringArrayManager.cs has been added Index: ADT_SD.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/ADT_SD.csproj,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ADT_SD.csproj 1 Apr 2008 21:14:31 -0000 1.8 --- ADT_SD.csproj 28 Apr 2008 21:12:21 -0000 1.9 *************** *** 49,52 **** --- 49,53 ---- <Compile Include="BarComponent.cs" /> <Compile Include="Collections\IntArrayManager.cs" /> + <Compile Include="Collections\StringArrayManager.cs" /> <Compile Include="ConstantsProvider.cs" /> <Compile Include="ExtendedDataTable.cs" /> |
|
From: Glauco S. <gla...@us...> - 2008-04-27 17:54:44
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv23477/b4_Business/a2_Strategies/returnsManagement/time Modified Files: ReturnIntervals.cs Log Message: The read only property public ReturnInterval LastInterval has been added Index: ReturnIntervals.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time/ReturnIntervals.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ReturnIntervals.cs 2 Mar 2008 14:52:26 -0000 1.7 --- ReturnIntervals.cs 27 Apr 2008 17:54:39 -0000 1.8 *************** *** 71,74 **** --- 71,86 ---- } } + public ReturnInterval LastInterval + { + get + { + if ( this.Count == 0 ) + throw new Exception( "LastInterval " + + "cannot be used when ReturnIntervals has " + + "no ReturnInterval added yet!" ); + ReturnInterval lastInterval = this[ this.Count - 1 ]; + return lastInterval; + } + } /// <summary> /// The EndOfDayHistory made up by queuing all |
|
From: Glauco S. <gla...@us...> - 2008-04-27 17:53:58
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Strategies In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv22769/b7_Scripts/WalkForwardTesting/PairsTrading/Strategies Modified Files: PairsTradingStrategy.cs Log Message: A new parameter of type OutOfSampleChooser has been added, so that now, the same strategy, can take different decision based upon differen OutOfSampleChooser(s) Index: PairsTradingStrategy.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Strategies/PairsTradingStrategy.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PairsTradingStrategy.cs 20 Apr 2008 16:31:13 -0000 1.1 --- PairsTradingStrategy.cs 27 Apr 2008 17:53:49 -0000 1.2 *************** *** 44,55 **** // private WeightedPositions positionsToBeOpened; ! private double ! minThresholdForGoingLong, ! maxThresholdForGoingLong, ! minThresholdForGoingShort, ! maxThresholdForGoingShort; private IHistoricalQuoteProvider historicalQuoteProviderForChosingPositionsOutOfSample; public PairsTradingStrategy( --- 44,56 ---- // private WeightedPositions positionsToBeOpened; ! // private double ! // minThresholdForGoingLong, ! // maxThresholdForGoingLong, ! // minThresholdForGoingShort, ! // maxThresholdForGoingShort; private IHistoricalQuoteProvider historicalQuoteProviderForChosingPositionsOutOfSample; + private OutOfSampleChooser outOfSampleChooser; public PairsTradingStrategy( *************** *** 62,69 **** IHistoricalQuoteProvider historicalQuoteProviderForChosingPositionsOutOfSample , ! double minThresholdForGoingLong , ! double maxThresholdForGoingLong , ! double minThresholdForGoingShort , ! double maxThresholdForGoingShort ) : base( numDaysBeetweenEachOtpimization , --- 63,67 ---- IHistoricalQuoteProvider historicalQuoteProviderForChosingPositionsOutOfSample , ! OutOfSampleChooser outOfSampleChooser ) : base( numDaysBeetweenEachOtpimization , *************** *** 74,84 **** historicalQuoteProviderForInSample ) { ! this.minThresholdForGoingLong = minThresholdForGoingLong; ! this.maxThresholdForGoingLong = maxThresholdForGoingLong; ! this.minThresholdForGoingShort = minThresholdForGoingShort; ! this.maxThresholdForGoingShort = maxThresholdForGoingShort; this.historicalQuoteProviderForChosingPositionsOutOfSample = ! historicalQuoteProviderForChosingPositionsOutOfSample; } --- 72,83 ---- historicalQuoteProviderForInSample ) { ! // this.minThresholdForGoingLong = minThresholdForGoingLong; ! // this.maxThresholdForGoingLong = maxThresholdForGoingLong; ! // this.minThresholdForGoingShort = minThresholdForGoingShort; ! // this.maxThresholdForGoingShort = maxThresholdForGoingShort; this.historicalQuoteProviderForChosingPositionsOutOfSample = ! historicalQuoteProviderForChosingPositionsOutOfSample; ! this.outOfSampleChooser = outOfSampleChooser; } *************** *** 129,340 **** } ! #region getPositionsToBeOpened ! #region getReturnsManagerForLastSecondPhaseInterval ! private EndOfDayDateTime ! getIntervalBeginForLastSecondPhaseInterval() ! { ! // this method will be invoked only if (this.returnIntervals.Count >= 2) ! int secondLastIntervalIndex = ! this.returnIntervals.Count - 2; ! ReturnInterval secondLastInterval = ! this.returnIntervals[ secondLastIntervalIndex ]; ! return secondLastInterval.End; ! } ! private EndOfDayDateTime ! getIntervalEndForLastSecondPhaseInterval() ! { ! return this.lastIntervalAppended().Begin; ! } ! private ReturnInterval ! getReturnIntervalForLastSecondPhaseInterval() ! { ! EndOfDayDateTime intervalBegin = ! this.getIntervalBeginForLastSecondPhaseInterval(); ! EndOfDayDateTime intervalEnd = ! this.getIntervalEndForLastSecondPhaseInterval(); ! ReturnInterval returnIntervalForLastSecondPhaseInterval = ! new ReturnInterval( intervalBegin , intervalEnd ); ! return returnIntervalForLastSecondPhaseInterval; ! } ! private ReturnIntervals ! getReturnIntervalsForLastSecondPhaseInterval() ! { ! ReturnInterval returnIntervalForLastSecondPhaseInterval = ! this.getReturnIntervalForLastSecondPhaseInterval(); ! ReturnIntervals returnIntervalsForLastSecondPhaseInterval = ! new ReturnIntervals( returnIntervalForLastSecondPhaseInterval ); ! return returnIntervalsForLastSecondPhaseInterval; ! } ! private ReturnsManager getReturnsManagerForLastSecondPhaseInterval() ! { ! ReturnIntervals returnIntervals = ! this.getReturnIntervalsForLastSecondPhaseInterval(); // ReturnsManager returnsManager = // new ReturnsManager( returnIntervals , ! // this.historicalAdjustedQuoteProvider ); ! ReturnsManager returnsManager = ! new ReturnsManager( returnIntervals , ! this.historicalQuoteProviderForChosingPositionsOutOfSample ); ! return returnsManager; ! } ! #endregion getReturnsManagerForLastSecondPhaseInterval ! private double getReturnForTheLastSecondPhaseInterval( ! ReturnsManager returnsManager , ! WeightedPositions weightedPositions ) ! { ! // returnsManager should contain a single ReturnInterval, and ! // this ReturnInterval should be the last second phase interval ! double returnForTheLastSecondPhaseInterval = ! weightedPositions.GetReturn( 0 , returnsManager ); ! return returnForTheLastSecondPhaseInterval; ! } ! ! /// <summary> ! /// Inverts one of the two positions ! /// </summary> ! /// <param name="weightedPositions"></param> ! /// <returns></returns> ! private WeightedPositions getCandidateForPortfolio( ! WeightedPositions weightedPositions ) ! { ! double[] weights = new double[ 2 ]; ! weights[ 0 ] = ((WeightedPosition)weightedPositions[ 0 ]).Weight; ! weights[ 1 ] = -((WeightedPosition)weightedPositions[ 1 ]).Weight; ! string[] tickers = new String[ 2 ]; ! tickers[ 0 ] = ((WeightedPosition)weightedPositions[ 0 ]).Ticker; ! tickers[ 1 ] = ((WeightedPosition)weightedPositions[ 1 ]).Ticker; ! WeightedPositions candidateForPortfolio = ! new WeightedPositions( weights , tickers ); ! return candidateForPortfolio; ! } ! // if the currentWeightedPositions' return satisfies the thresholds ! // then this method returns the WeightedPositions to be opened. ! // Otherwise (currentWeightedPositions' return does NOT ! // satisfy the thresholds) this method returns null ! private WeightedPositions ! getPositionsToBeOpenedWithRespectToCurrentWeightedPositions( ! ReturnsManager returnsManager , ! WeightedPositions currentWeightedPositions ) ! { ! WeightedPositions weightedPositionsToBeOpened = null; ! try ! { ! double returnForTheLastSecondPhaseInterval = ! this.getReturnForTheLastSecondPhaseInterval( ! returnsManager , ! currentWeightedPositions ); ! if ( ( returnForTheLastSecondPhaseInterval >= ! this.minThresholdForGoingLong ) && ! ( returnForTheLastSecondPhaseInterval <= ! this.maxThresholdForGoingLong ) ) ! // it looks like there has been an inefficiency that ! // might be recovered, by going short ! weightedPositionsToBeOpened = currentWeightedPositions.Opposite; ! if ( ( -returnForTheLastSecondPhaseInterval >= ! this.minThresholdForGoingShort ) && ! ( -returnForTheLastSecondPhaseInterval <= ! this.maxThresholdForGoingShort ) ) ! // it looks like there has been an inefficiency that ! // might be recovered, by going long ! weightedPositionsToBeOpened = currentWeightedPositions; ! } ! catch( TickerNotExchangedException ex ) ! { ! string dummy = ex.Message; ! } ! return weightedPositionsToBeOpened; ! } ! private WeightedPositions ! getPositionsToBeOpenedWithRespectToCurrentWeightedPositions( ! ReturnsManager returnsManager , ! int currentTestingPositionsIndex ) ! { ! WeightedPositions currentWeightedPositions = ! this.bestTestingPositionsInSample[ currentTestingPositionsIndex ].WeightedPositions; ! WeightedPositions candidateForPortfolio = ! this.getCandidateForPortfolio( currentWeightedPositions ); ! WeightedPositions weightedPositionsToBeOpended = ! this.getPositionsToBeOpenedWithRespectToCurrentWeightedPositions( ! returnsManager , candidateForPortfolio ); ! return weightedPositionsToBeOpended; ! } ! protected WeightedPositions getPositionsToBeOpened( ! ReturnsManager returnsManager ) ! { ! WeightedPositions weightedPositionsToBeOpended = null; ! int currentTestingPositionsIndex = 0; ! while ( ( weightedPositionsToBeOpended == null ) ! && ( currentTestingPositionsIndex < this.bestTestingPositionsInSample.Length ) ) ! { ! weightedPositionsToBeOpended = ! this.getPositionsToBeOpenedWithRespectToCurrentWeightedPositions( ! returnsManager , currentTestingPositionsIndex ); ! currentTestingPositionsIndex++; ! } ! return weightedPositionsToBeOpended; ! } ! private WeightedPositions ! getPositionsToBeOpened_withAtLeastASecondPhaseInterval_actually() ! { ! ReturnsManager returnsManager = ! this.getReturnsManagerForLastSecondPhaseInterval(); ! WeightedPositions weightedPositions = ! this.getPositionsToBeOpened( returnsManager ); ! return weightedPositions; ! } ! /// <summary> ! /// To be overriden if a subset of the positions has to be returned ! /// </summary> ! /// <param name="weightedPositions"></param> ! /// <returns></returns> ! protected virtual WeightedPositions selectWeightedPositions( ! WeightedPositions weightedPositions ) ! { ! return weightedPositions; ! } ! private WeightedPositions ! getPositionsToBeOpened_withAtLeastASecondPhaseInterval() ! { ! WeightedPositions weightedPositions = ! this.getPositionsToBeOpened_withAtLeastASecondPhaseInterval_actually(); ! WeightedPositions weightedPositionsToBeReturned = null; ! if ( weightedPositions != null ) ! // at least one of the BestTestingPositions shows an inefficiency ! // above the threshold ! weightedPositionsToBeReturned = ! selectWeightedPositions( weightedPositions ); ! return weightedPositionsToBeReturned; ! } ! protected override WeightedPositions getPositionsToBeOpened() ! { ! WeightedPositions weightedPositions = null; ! if ( this.returnIntervals.Count >= 2 ) ! // at least a second phase interval exists ! weightedPositions = ! this.getPositionsToBeOpened_withAtLeastASecondPhaseInterval(); ! return weightedPositions; ! } ! #endregion ! ! // protected override WeightedPositions marketOpenEventHandler_getPositionsToBeOpened() // { ! // return this.getPositionsToBeOpened(); // } // ! // protected override WeightedPositions marketCloseEventHandler_getPositionsToBeOpened() // { ! // return this.getPositionsToBeOpened(); // } ! // ! // protected override bool marketOpenEventHandler_arePositionsToBeClosed() // { ! // return this.arePositionsToBeClosed(); // } ! // ! // protected override bool marketCloseEventHandler_arePositionsToBeClosed() // { ! // return this.arePositionsToBeClosed(); // } protected override LogItem getLogItem( EligibleTickers eligibleTickers ) { --- 128,330 ---- } ! // #region getPositionsToBeOpened ! // #region getReturnsManagerForLastSecondPhaseInterval ! // private EndOfDayDateTime ! // getIntervalBeginForLastSecondPhaseInterval() ! // { ! // // this method will be invoked only if (this.returnIntervals.Count >= 2) ! // int secondLastIntervalIndex = ! // this.returnIntervals.Count - 2; ! // ReturnInterval secondLastInterval = ! // this.returnIntervals[ secondLastIntervalIndex ]; ! // return secondLastInterval.End; ! // } ! // private EndOfDayDateTime ! // getIntervalEndForLastSecondPhaseInterval() ! // { ! // return this.lastIntervalAppended().Begin; ! // } ! // private ReturnInterval ! // getReturnIntervalForLastSecondPhaseInterval() ! // { ! // EndOfDayDateTime intervalBegin = ! // this.getIntervalBeginForLastSecondPhaseInterval(); ! // EndOfDayDateTime intervalEnd = ! // this.getIntervalEndForLastSecondPhaseInterval(); ! // ReturnInterval returnIntervalForLastSecondPhaseInterval = ! // new ReturnInterval( intervalBegin , intervalEnd ); ! // return returnIntervalForLastSecondPhaseInterval; ! // } ! // private ReturnIntervals ! // getReturnIntervalsForLastSecondPhaseInterval() ! // { ! // ReturnInterval returnIntervalForLastSecondPhaseInterval = ! // this.getReturnIntervalForLastSecondPhaseInterval(); ! // ReturnIntervals returnIntervalsForLastSecondPhaseInterval = ! // new ReturnIntervals( returnIntervalForLastSecondPhaseInterval ); ! // return returnIntervalsForLastSecondPhaseInterval; ! // } ! // private ReturnsManager getReturnsManagerForLastSecondPhaseInterval() ! // { ! // ReturnIntervals returnIntervals = ! // this.getReturnIntervalsForLastSecondPhaseInterval(); ! //// ReturnsManager returnsManager = ! //// new ReturnsManager( returnIntervals , ! //// this.historicalAdjustedQuoteProvider ); // ReturnsManager returnsManager = // new ReturnsManager( returnIntervals , ! // this.historicalQuoteProviderForChosingPositionsOutOfSample ); ! // return returnsManager; ! // } ! // #endregion getReturnsManagerForLastSecondPhaseInterval ! // private double getReturnForTheLastSecondPhaseInterval( ! // ReturnsManager returnsManager , ! // WeightedPositions weightedPositions ) // { ! // // returnsManager should contain a single ReturnInterval, and ! // // this ReturnInterval should be the last second phase interval ! // double returnForTheLastSecondPhaseInterval = ! // weightedPositions.GetReturn( 0 , returnsManager ); ! // return returnForTheLastSecondPhaseInterval; // } // ! // /// <summary> ! // /// Inverts one of the two positions ! // /// </summary> ! // /// <param name="weightedPositions"></param> ! // /// <returns></returns> ! // private WeightedPositions getCandidateForPortfolio( ! // WeightedPositions weightedPositions ) // { ! // double[] weights = new double[ 2 ]; ! // weights[ 0 ] = ((WeightedPosition)weightedPositions[ 0 ]).Weight; ! // weights[ 1 ] = -((WeightedPosition)weightedPositions[ 1 ]).Weight; ! // string[] tickers = new String[ 2 ]; ! // tickers[ 0 ] = ((WeightedPosition)weightedPositions[ 0 ]).Ticker; ! // tickers[ 1 ] = ((WeightedPosition)weightedPositions[ 1 ]).Ticker; ! // WeightedPositions candidateForPortfolio = ! // new WeightedPositions( weights , tickers ); ! // return candidateForPortfolio; // } ! // // if the currentWeightedPositions' return satisfies the thresholds ! // // then this method returns the WeightedPositions to be opened. ! // // Otherwise (currentWeightedPositions' return does NOT ! // // satisfy the thresholds) this method returns null ! // private WeightedPositions ! // getPositionsToBeOpenedWithRespectToCurrentWeightedPositions( ! // ReturnsManager returnsManager , ! // WeightedPositions currentWeightedPositions ) // { ! // WeightedPositions weightedPositionsToBeOpened = null; ! // try ! // { ! // double returnForTheLastSecondPhaseInterval = ! // this.getReturnForTheLastSecondPhaseInterval( ! // returnsManager , ! // currentWeightedPositions ); ! // if ( ( returnForTheLastSecondPhaseInterval >= ! // this.minThresholdForGoingLong ) && ! // ( returnForTheLastSecondPhaseInterval <= ! // this.maxThresholdForGoingLong ) ) ! // // it looks like there has been an inefficiency that ! // // might be recovered, by going short ! // weightedPositionsToBeOpened = currentWeightedPositions.Opposite; ! // if ( ( -returnForTheLastSecondPhaseInterval >= ! // this.minThresholdForGoingShort ) && ! // ( -returnForTheLastSecondPhaseInterval <= ! // this.maxThresholdForGoingShort ) ) ! // // it looks like there has been an inefficiency that ! // // might be recovered, by going long ! // weightedPositionsToBeOpened = currentWeightedPositions; ! // } ! // catch( TickerNotExchangedException ex ) ! // { ! // string dummy = ex.Message; ! // } ! // return weightedPositionsToBeOpened; // } ! // private WeightedPositions ! // getPositionsToBeOpenedWithRespectToCurrentWeightedPositions( ! // ReturnsManager returnsManager , ! // int currentTestingPositionsIndex ) // { ! // WeightedPositions currentWeightedPositions = ! // this.bestTestingPositionsInSample[ currentTestingPositionsIndex ].WeightedPositions; ! // WeightedPositions candidateForPortfolio = ! // this.getCandidateForPortfolio( currentWeightedPositions ); ! // WeightedPositions weightedPositionsToBeOpended = ! // this.getPositionsToBeOpenedWithRespectToCurrentWeightedPositions( ! // returnsManager , candidateForPortfolio ); ! // return weightedPositionsToBeOpended; ! // } ! // protected WeightedPositions getPositionsToBeOpened( ! // ReturnsManager returnsManager ) ! // { ! // WeightedPositions weightedPositionsToBeOpended = null; ! // int currentTestingPositionsIndex = 0; ! // while ( ( weightedPositionsToBeOpended == null ) ! // && ( currentTestingPositionsIndex < this.bestTestingPositionsInSample.Length ) ) ! // { ! // weightedPositionsToBeOpended = ! // this.getPositionsToBeOpenedWithRespectToCurrentWeightedPositions( ! // returnsManager , currentTestingPositionsIndex ); ! // currentTestingPositionsIndex++; ! // } ! // return weightedPositionsToBeOpended; ! // } ! // private WeightedPositions ! // getPositionsToBeOpened_withAtLeastASecondPhaseInterval_actually() ! // { ! // ReturnsManager returnsManager = ! // this.getReturnsManagerForLastSecondPhaseInterval(); ! // WeightedPositions weightedPositions = ! // this.getPositionsToBeOpened( returnsManager ); ! // return weightedPositions; ! // } ! // /// <summary> ! // /// To be overriden if a subset of the positions has to be returned ! // /// </summary> ! // /// <param name="weightedPositions"></param> ! // /// <returns></returns> ! // protected virtual WeightedPositions selectWeightedPositions( ! // WeightedPositions weightedPositions ) ! // { ! // return weightedPositions; // } + // private WeightedPositions + // getPositionsToBeOpened_withAtLeastASecondPhaseInterval() + // { + // WeightedPositions weightedPositions = + // this.getPositionsToBeOpened_withAtLeastASecondPhaseInterval_actually(); + // WeightedPositions weightedPositionsToBeReturned = null; + // if ( weightedPositions != null ) + // // at least one of the BestTestingPositions shows an inefficiency + // // above the threshold + // weightedPositionsToBeReturned = + // selectWeightedPositions( weightedPositions ); + // return weightedPositionsToBeReturned; + // } + // protected override WeightedPositions getPositionsToBeOpened() + // { + // WeightedPositions weightedPositions = null; + // if ( this.returnIntervals.Count >= 2 ) + // // at least a second phase interval exists + // weightedPositions = + // this.getPositionsToBeOpened_withAtLeastASecondPhaseInterval(); + // return weightedPositions; + // } + // #endregion + protected override WeightedPositions getPositionsToBeOpened() + { + WeightedPositions weightedPositions = + this.outOfSampleChooser.GetPositionsToBeOpened( + this.bestTestingPositionsInSample , + this.returnIntervals , + this.historicalQuoteProviderForChosingPositionsOutOfSample , + this.inSampleReturnsManager ); + return weightedPositions; + } + protected override LogItem getLogItem( EligibleTickers eligibleTickers ) { |