quantproject-developers Mailing List for QuantProject (Page 39)
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-08-18 21:05:45
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/Selectors In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv8964/Selectors Modified Files: SelectorByAverageCloseToOpenPerformance.cs SelectorByCloseToCloseLinearCorrelation.cs SelectorByCloseToOpenVolatility.cs Log Message: - the code has been cleaned up to avoid warnings - standard indentation has been applied Index: SelectorByAverageCloseToOpenPerformance.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/Selectors/SelectorByAverageCloseToOpenPerformance.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SelectorByAverageCloseToOpenPerformance.cs 7 Jan 2006 10:50:40 -0000 1.1 --- SelectorByAverageCloseToOpenPerformance.cs 18 Aug 2008 21:05:39 -0000 1.2 *************** *** 87,97 **** { row["AverageCloseToOpenPerformance"] = -1000000.0; ! row["AverageCloseToOpenPerformance"] = ! this.getTableOfSelectedTickers_getTickersFromTable_getAverageCTOForTicker((string)row[0]); } catch(Exception ex) ! {ex=ex;} } ! DataTable tableToReturn = ExtendedDataTable.CopyAndSort(this.setOfTickersToBeSelected, "AverageCloseToOpenPerformance>-1000000.0", --- 87,99 ---- { row["AverageCloseToOpenPerformance"] = -1000000.0; ! row["AverageCloseToOpenPerformance"] = ! this.getTableOfSelectedTickers_getTickersFromTable_getAverageCTOForTicker((string)row[0]); } catch(Exception ex) ! { ! string forBreakpoint = ex.Message; forBreakpoint = forBreakpoint + ""; ! } } ! DataTable tableToReturn = ExtendedDataTable.CopyAndSort(this.setOfTickersToBeSelected, "AverageCloseToOpenPerformance>-1000000.0", Index: SelectorByCloseToCloseLinearCorrelation.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/Selectors/SelectorByCloseToCloseLinearCorrelation.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SelectorByCloseToCloseLinearCorrelation.cs 14 Jan 2008 23:18:47 -0000 1.3 --- SelectorByCloseToCloseLinearCorrelation.cs 18 Aug 2008 21:05:40 -0000 1.4 *************** *** 127,141 **** try { ! rowToAdd["PearsonCorrelationCoefficient"] = ! QuantProject.ADT.Statistics.BasicFunctions.PearsonCorrelationCoefficient( ! tickersAdjCloses[j],tickersAdjCloses[i]); } catch(Exception ex) { ! ex = ex; } finally { ! setOfTickers.Rows.Add(rowToAdd); } } --- 127,141 ---- try { ! rowToAdd["PearsonCorrelationCoefficient"] = ! QuantProject.ADT.Statistics.BasicFunctions.PearsonCorrelationCoefficient( ! tickersAdjCloses[j],tickersAdjCloses[i]); } catch(Exception ex) { ! string forBreakpoint = ex.Message; forBreakpoint = forBreakpoint + ""; } finally { ! setOfTickers.Rows.Add(rowToAdd); } } Index: SelectorByCloseToOpenVolatility.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/Selectors/SelectorByCloseToOpenVolatility.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SelectorByCloseToOpenVolatility.cs 14 Aug 2008 23:28:37 -0000 1.2 --- SelectorByCloseToOpenVolatility.cs 18 Aug 2008 21:05:40 -0000 1.3 *************** *** 84,105 **** this.setOfTickersToBeSelected.Columns.Add("CloseToOpenStandardDeviation", System.Type.GetType("System.Double")); double CTOStdDev; ! foreach(DataRow row in this.setOfTickersToBeSelected.Rows) { ! try ! { ! row["CloseToOpenStandardDeviation"] = -1000000.0; ! CTOStdDev = this.getTableOfSelectedTickers_getTickersFromTable_getCTOStdDevForTicker((string)row[0]); ! if( !Double.IsInfinity(CTOStdDev) && !Double.IsNaN(CTOStdDev) ) ! row["CloseToOpenStandardDeviation"] = CTOStdDev; ! ! } ! catch(Exception ex) ! {ex=ex;} } ! DataTable tableToReturn = ! ExtendedDataTable.CopyAndSort(this.setOfTickersToBeSelected, ! "CloseToOpenStandardDeviation>-1000000.0", ! "CloseToOpenStandardDeviation", ! this.isOrderedInASCMode); ExtendedDataTable.DeleteRows(tableToReturn, this.maxNumOfReturnedTickers); return tableToReturn; --- 84,107 ---- this.setOfTickersToBeSelected.Columns.Add("CloseToOpenStandardDeviation", System.Type.GetType("System.Double")); double CTOStdDev; ! foreach(DataRow row in this.setOfTickersToBeSelected.Rows) { ! try ! { ! row["CloseToOpenStandardDeviation"] = -1000000.0; ! CTOStdDev = this.getTableOfSelectedTickers_getTickersFromTable_getCTOStdDevForTicker((string)row[0]); ! if( !Double.IsInfinity(CTOStdDev) && !Double.IsNaN(CTOStdDev) ) ! row["CloseToOpenStandardDeviation"] = CTOStdDev; ! ! } ! catch(Exception ex) ! { ! string forBreakpoint = ex.Message; forBreakpoint = forBreakpoint + ""; ! } } ! DataTable tableToReturn = ! ExtendedDataTable.CopyAndSort(this.setOfTickersToBeSelected, ! "CloseToOpenStandardDeviation>-1000000.0", ! "CloseToOpenStandardDeviation", ! this.isOrderedInASCMode); ExtendedDataTable.DeleteRows(tableToReturn, this.maxNumOfReturnedTickers); return tableToReturn; |
|
From: Glauco S. <gla...@us...> - 2008-08-18 21:05:44
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataTables In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv8964/DataTables Modified Files: Quotes.cs Log Message: - the code has been cleaned up to avoid warnings - standard indentation has been applied Index: Quotes.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataTables/Quotes.cs,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** Quotes.cs 14 Aug 2008 23:22:49 -0000 1.36 --- Quotes.cs 18 Aug 2008 21:05:39 -0000 1.37 *************** *** 225,229 **** } catch(Exception ex) ! {ex=ex;} } DataTable getTickersByVolatility = ExtendedDataTable.CopyAndSort(setOfTickers, --- 225,229 ---- } catch(Exception ex) ! { string forBreakpoint = ex.Message; forBreakpoint = forBreakpoint + ""; } } DataTable getTickersByVolatility = ExtendedDataTable.CopyAndSort(setOfTickers, *************** *** 302,314 **** { row["AverageOpenToClosePerformance"] = -1000000.0; ! row["AverageOpenToClosePerformance"] = ! QuantProject.DataAccess.Tables.Quotes.GetAverageOpenToClosePerformance((string)row[0], ! firstQuoteDate, ! lastQuoteDate); } catch(Exception ex) ! {ex=ex;} } ! string maxAbsValue = maxAbsoluteAverageOTCPerformance.ToString(new System.Globalization.CultureInfo("en-US")); DataTable tableToReturn = ExtendedDataTable.CopyAndSort(setOfTickers, --- 302,316 ---- { row["AverageOpenToClosePerformance"] = -1000000.0; ! row["AverageOpenToClosePerformance"] = ! QuantProject.DataAccess.Tables.Quotes.GetAverageOpenToClosePerformance((string)row[0], ! firstQuoteDate, ! lastQuoteDate); } catch(Exception ex) ! { ! string forBreakpoint = ex.Message; forBreakpoint = forBreakpoint + ""; ! } } ! string maxAbsValue = maxAbsoluteAverageOTCPerformance.ToString(new System.Globalization.CultureInfo("en-US")); DataTable tableToReturn = ExtendedDataTable.CopyAndSort(setOfTickers, *************** *** 1127,1138 **** returnValue = DataAccess.Tables.Quotes.GetAdjustedClose(this.Ticker, ! firstCurrentDate.AddDays( ! -daysBeforeCurrent) ); ! } ! catch(Exception ex){ex = ex;} ! finally{ ! daysBeforeCurrent++; ! } } } --- 1129,1143 ---- returnValue = DataAccess.Tables.Quotes.GetAdjustedClose(this.Ticker, ! firstCurrentDate.AddDays( ! -daysBeforeCurrent) ); ! } ! catch(Exception ex) ! { ! string forBreakpoint = ex.Message; forBreakpoint = forBreakpoint + ""; ! } ! finally{ ! daysBeforeCurrent++; ! } } } |
|
From: Glauco S. <gla...@us...> - 2008-08-18 21:04:00
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv7945/Downloader/OpenTickDownloader Modified Files: BarQueueFiller.cs Log Message: Code has been cleaned up to avoid warnings Index: BarQueueFiller.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/BarQueueFiller.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BarQueueFiller.cs 20 Jul 2008 20:29:19 -0000 1.2 --- BarQueueFiller.cs 18 Aug 2008 21:03:52 -0000 1.3 *************** *** 236,240 **** this.fillQueue_setEventHandlers(); this.fillQueue_requestBarsForEachMarketDay(); - string forBreakpoint = "temp"; } #endregion fillQueue --- 236,239 ---- |
|
From: Marco M. <mi...@us...> - 2008-08-18 01:54:42
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/TickerSelectors In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv29302/Downloader/TickerSelectors Modified Files: TickerSelectorForm.cs Log Message: Added new parameter to SelectorByAverageOpenToClosePerformance's constructor Index: TickerSelectorForm.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/TickerSelectors/TickerSelectorForm.cs,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** TickerSelectorForm.cs 17 Sep 2006 21:49:43 -0000 1.21 --- TickerSelectorForm.cs 17 Aug 2008 22:20:12 -0000 1.22 *************** *** 667,675 **** returnValue = new SelectorByAverageOpenToClosePerformance(this.textBoxGroupID.Text, this.checkBoxASCMode.Checked, this.dateTimePickerFirstDate.Value, ! this.dateTimePickerLastDate.Value, Int32.Parse(this.textBoxMaxNumOfReturnedTickers.Text)); else returnValue = new SelectorByAverageOpenToClosePerformance(this.tableOfSelectedTickers, this.checkBoxASCMode.Checked, this.dateTimePickerFirstDate.Value, ! this.dateTimePickerLastDate.Value, Int32.Parse(this.textBoxMaxNumOfReturnedTickers.Text)); } else if (this.comboBoxAvailableSelectionRules.Text == "AverageCloseToOpenPerformance") --- 667,675 ---- returnValue = new SelectorByAverageOpenToClosePerformance(this.textBoxGroupID.Text, this.checkBoxASCMode.Checked, this.dateTimePickerFirstDate.Value, ! this.dateTimePickerLastDate.Value, 0.08, Int32.Parse(this.textBoxMaxNumOfReturnedTickers.Text)); else returnValue = new SelectorByAverageOpenToClosePerformance(this.tableOfSelectedTickers, this.checkBoxASCMode.Checked, this.dateTimePickerFirstDate.Value, ! this.dateTimePickerLastDate.Value, 0.08, Int32.Parse(this.textBoxMaxNumOfReturnedTickers.Text)); } else if (this.comboBoxAvailableSelectionRules.Text == "AverageCloseToOpenPerformance") |
|
From: Glauco S. <gla...@us...> - 2008-08-16 19:53:49
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv25434/b7_Scripts Modified Files: Scripts_SD.csproj Log Message: WalkForwardTesting\FixedLengthTwoPhases\FixedLengthTwoPhasesLogItem.cs has been removed Index: Scripts_SD.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/Scripts_SD.csproj,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** Scripts_SD.csproj 16 Aug 2008 19:25:15 -0000 1.30 --- Scripts_SD.csproj 16 Aug 2008 19:53:42 -0000 1.31 *************** *** 106,110 **** <Compile Include="TickerSelectionTesting\RunEfficientCTCPortfolio.cs" /> <Compile Include="TickerSelectionTesting\RunEfficientCTOPortfolio.cs" /> - <Compile Include="WalkForwardTesting\FixedLengthTwoPhases\FixedLengthTwoPhasesLogItem.cs" /> <Compile Include="WalkForwardTesting\FixedLengthTwoPhases\FixedLengthTwoPhasesMain.cs" /> <Compile Include="WalkForwardTesting\FixedLengthTwoPhases\FixedLengthTwoPhasesStrategy.cs" /> --- 106,109 ---- |
|
From: Glauco S. <gla...@us...> - 2008-08-16 19:41:00
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardMultiOneRank/ReportDebugger In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv6649/b7_Scripts/WalkForwardTesting/WalkForwardMultiOneRank/ReportDebugger Modified Files: WFMultiOneRankDebugInSample.cs Log Message: Removed some code, to avoid a warning Index: WFMultiOneRankDebugInSample.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardMultiOneRank/ReportDebugger/WFMultiOneRankDebugInSample.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** WFMultiOneRankDebugInSample.cs 11 Dec 2005 18:06:18 -0000 1.2 --- WFMultiOneRankDebugInSample.cs 16 Aug 2008 19:40:55 -0000 1.3 *************** *** 39,43 **** private DateTime firstDateTime; private DateTime lastDateTime; - private int numberDaysForInSampleOptimization; private string benchmark; --- 39,42 ---- *************** *** 55,60 **** this.firstDateTime = firstDateTime; this.lastDateTime = lastDateTime; ! this.numberDaysForInSampleOptimization = ! numberDaysForInSampleOptimization; this.benchmark = benchmark; --- 54,58 ---- this.firstDateTime = firstDateTime; this.lastDateTime = lastDateTime; ! this.benchmark = benchmark; |
|
From: Glauco S. <gla...@us...> - 2008-08-16 19:40:16
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Logging In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv5594/b7_Scripts/WalkForwardTesting/PairsTrading/Logging Modified Files: TesterForPairsTradingTestingPositions.cs Log Message: A new name space is included now, because the SimpleStrategy has been moved to the QuantProject.Scripts.General.Strategies namespace Index: TesterForPairsTradingTestingPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Logging/TesterForPairsTradingTestingPositions.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TesterForPairsTradingTestingPositions.cs 3 May 2008 17:55:03 -0000 1.3 --- TesterForPairsTradingTestingPositions.cs 16 Aug 2008 19:40:06 -0000 1.4 *************** *** 34,37 **** --- 34,38 ---- using QuantProject.Business.Timing; using QuantProject.Presentation.Reporting.WindowsForm; + using QuantProject.Scripts.General.Strategies; namespace QuantProject.Scripts.WalkForwardTesting.PairsTrading |
|
From: Glauco S. <gla...@us...> - 2008-08-16 19:38:45
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv3654/b7_Scripts/WalkForwardTesting/PairsTrading Modified Files: PairsTradingMain.cs Log Message: Minor changes have been applied, in order to test the strategy with different parameters Index: PairsTradingMain.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/PairsTradingMain.cs,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** PairsTradingMain.cs 17 May 2008 18:10:41 -0000 1.16 --- PairsTradingMain.cs 16 Aug 2008 19:38:41 -0000 1.17 *************** *** 62,66 **** public PairsTradingMain() { ! this.benchmark = new Benchmark( "BMC" ); this.historicalQuoteProviderForInSample = --- 62,66 ---- public PairsTradingMain() { ! this.benchmark = new Benchmark( "CCE" ); this.historicalQuoteProviderForInSample = *************** *** 69,79 **** this.historicalQuoteProviderForChosingPositionsOutOfSample = new HistoricalAdjustedQuoteProvider(); ! this.historicalQuoteProviderForChosingPositionsOutOfSample = ! new HistoricalRawQuoteProvider(); this.historicalQuoteProviderForTheBacktesterAccount = new HistoricalRawQuoteProvider(); ! this.historicalQuoteProviderForTheBacktesterAccount = ! new HistoricalAdjustedQuoteProvider(); // definition for the Fitness Evaluator --- 69,79 ---- this.historicalQuoteProviderForChosingPositionsOutOfSample = new HistoricalAdjustedQuoteProvider(); ! // this.historicalQuoteProviderForChosingPositionsOutOfSample = ! // new HistoricalRawQuoteProvider(); this.historicalQuoteProviderForTheBacktesterAccount = new HistoricalRawQuoteProvider(); ! // this.historicalQuoteProviderForTheBacktesterAccount = ! // new HistoricalAdjustedQuoteProvider(); // definition for the Fitness Evaluator *************** *** 173,178 **** new OddIntervalsSelector( 1 , 1 , this.benchmark ); // uncomment the following statement in order to test a CTO strategy (out of sample) ! intervalsSelectorForOutOfSample = ! new EvenIntervalsSelector( 1 , 1 , this.benchmark ); IIntervalsSelector intervalsSelectorForInSample = new OddIntervalsSelector( 1 , 1 , this.benchmark ); --- 173,178 ---- new OddIntervalsSelector( 1 , 1 , this.benchmark ); // uncomment the following statement in order to test a CTO strategy (out of sample) ! // intervalsSelectorForOutOfSample = ! // new EvenIntervalsSelector( 1 , 1 , this.benchmark ); IIntervalsSelector intervalsSelectorForInSample = new OddIntervalsSelector( 1 , 1 , this.benchmark ); *************** *** 224,235 **** DateTime firstDateTime = new DateTime( 2001 , 1 , 1 ); ! firstDateTime = new DateTime( 2005 , 1 , 1 ); DateTime lastDateTime = new DateTime( 2008 , 4 , 30 ); // uncomment the following two lines for a faster script ! // firstDateTime = new DateTime( 2001 , 1 , 1 ); ! // lastDateTime = new DateTime( 2001 , 1 , 31 ); ! double maxRunningHours = 8; EndOfDayStrategyBackTester endOfDayStrategyBackTester = --- 224,235 ---- DateTime firstDateTime = new DateTime( 2001 , 1 , 1 ); ! firstDateTime = new DateTime( 2006 , 8 , 1 ); DateTime lastDateTime = new DateTime( 2008 , 4 , 30 ); // uncomment the following two lines for a faster script ! // firstDateTime = new DateTime( 2007 , 1 , 1 ); ! // lastDateTime = new DateTime( 2007 , 1 , 31 ); ! double maxRunningHours = 1; EndOfDayStrategyBackTester endOfDayStrategyBackTester = |
|
From: Glauco S. <gla...@us...> - 2008-08-16 19:36:11
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv787/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases Modified Files: FixedLengthTwoPhasesStrategy.cs Log Message: This class now extends the SymmetricEndOfDayStrategyForBacktester class Index: FixedLengthTwoPhasesStrategy.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases/FixedLengthTwoPhasesStrategy.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** FixedLengthTwoPhasesStrategy.cs 11 May 2008 19:00:50 -0000 1.7 --- FixedLengthTwoPhasesStrategy.cs 16 Aug 2008 19:35:59 -0000 1.8 *************** *** 44,101 **** /// first phase, then goes with the opposite for the second phase /// </summary> ! public class FixedLengthTwoPhasesStrategy : IEndOfDayStrategyForBacktester { ! public event NewLogItemEventHandler NewLogItem; ! public event NewMessageEventHandler NewMessage; ! ! private int numberOfPortfolioPositions; ! private int numDaysBeetweenEachOtpimization; ! private int numDaysForInSampleOptimization; ! private Benchmark benchmark; ! private IIntervalsSelector intervalsSelector; ! private IEligiblesSelector eligiblesSelector; ! private IInSampleChooser inSampleChooser; ! ! private DateTime lastOptimizationDateTime; ! private ReturnIntervals returnIntervals; ! private IHistoricalQuoteProvider historicalQuoteProvider; ! ! private Account account; ! // private bool arePositionsToBeClosed; ! // private bool arePositionsToBeOpened; ! private WeightedPositions bestWeightedPositionsInSample; ! ! public Account Account ! { ! get { return this.account; } ! set { this.account = value; } ! } ! ! ! public bool StopBacktestIfMaxRunningHoursHasBeenReached ! { ! get ! { ! return this.isInsampleOptimizationNeeded(); ! } ! } ! public string Description ! { ! get ! { ! string descriptionForLogFileName = ! "Strtgy_fltp_" + ! "nmDysBtwnOptmztns_" + ! this.numDaysBeetweenEachOtpimization.ToString() + "_" + ! this.eligiblesSelector.Description + "_" + ! this.inSampleChooser.Description + ! "_oS_longOnly"; ! return descriptionForLogFileName; ! } ! } public FixedLengthTwoPhasesStrategy( int numberOfPortfolioPositions , ! int numDaysBeetweenEachOtpimization , int numDaysForInSampleOptimization , Benchmark benchmark , --- 44,64 ---- /// first phase, then goes with the opposite for the second phase /// </summary> ! public class FixedLengthTwoPhasesStrategy : ! SymmetricEndOfDayStrategyForBacktester { ! // private int numberOfPortfolioPositions; ! // private Benchmark benchmark; ! // private IIntervalsSelector intervalsSelector; ! // ! // private IHistoricalQuoteProvider historicalQuoteProvider; ! // ! // private Account account; ! // private WeightedPositions bestWeightedPositionsInSample; ! ! private RankBasedOutOfSampleChooser outOfSampleChooser; public FixedLengthTwoPhasesStrategy( int numberOfPortfolioPositions , ! int numDaysBetweenEachOtpimization , int numDaysForInSampleOptimization , Benchmark benchmark , *************** *** 103,134 **** IEligiblesSelector eligiblesSelector , IInSampleChooser inSampleChooser , ! IHistoricalQuoteProvider historicalQuoteProvider ! ) { ! this.numberOfPortfolioPositions = numberOfPortfolioPositions; ! this.numDaysBeetweenEachOtpimization = numDaysBeetweenEachOtpimization; ! this.numDaysForInSampleOptimization = numDaysForInSampleOptimization; ! this.benchmark = benchmark; ! this.intervalsSelector = intervalsSelector; ! this.eligiblesSelector = eligiblesSelector; ! this.inSampleChooser = inSampleChooser; ! this.historicalQuoteProvider = historicalQuoteProvider; ! this.returnIntervals = ! new ReturnIntervals( this.intervalsSelector ); - // this.arePositionsToBeClosed = false; - // this.arePositionsToBeOpened = false; } ! #region MarketOpenEventHandler ! private bool marketOpenEventHandler_arePositionsToBeClosed() { bool arePositionsToBeClosed = ( ! ( this.account.Portfolio.Count > 0 ) && ( this.now().IsEqualTo( this.lastIntervalAppended().Begin ) ) ); return arePositionsToBeClosed; } ! #region marketOpenEventHandler_arePositionsToBeOpened private bool lastAppendedIntervalIsALongPeriod() { --- 66,108 ---- IEligiblesSelector eligiblesSelector , IInSampleChooser inSampleChooser , ! IHistoricalQuoteProvider historicalQuoteProvider , ! RankBasedOutOfSampleChooser outOfSampleChooser ! ) : ! base( ! numDaysBetweenEachOtpimization , ! numDaysForInSampleOptimization , ! intervalsSelector , ! intervalsSelector , ! eligiblesSelector , ! inSampleChooser , ! historicalQuoteProvider ) { ! this.outOfSampleChooser = outOfSampleChooser; ! // this.numberOfPortfolioPositions = numberOfPortfolioPositions; ! // this.numDaysBetweenEachOtpimization = numDaysBetweenEachOtpimization; ! // this.numDaysForInSampleOptimization = numDaysForInSampleOptimization; ! // this.benchmark = benchmark; ! // this.intervalsSelector = intervalsSelector; ! // this.eligiblesSelector = eligiblesSelector; ! // this.inSampleChooser = inSampleChooser; ! // this.historicalQuoteProvider = historicalQuoteProvider; ! // this.returnIntervals = ! // new ReturnIntervals( this.intervalsSelector ); } ! ! protected override bool arePositionsToBeClosed() { bool arePositionsToBeClosed = ( ! ( this.Account.Portfolio.Count > 0 ) && ( this.now().IsEqualTo( this.lastIntervalAppended().Begin ) ) ); return arePositionsToBeClosed; } ! ! #region arePositionsToBeOpened ! ! #region currentTimeBeginsALongPeriod private bool lastAppendedIntervalIsALongPeriod() { *************** *** 146,344 **** return ( beginsTheLastInterval && lastIntervalIsALongPeriod ); } ! private bool marketOpenEventHandler_arePositionsToBeOpened() { bool arePositionsToBeOpened = ( ! ( this.bestWeightedPositionsInSample != null ) && ( this.currentTimeBeginsALongPeriod() ) ); return arePositionsToBeOpened; } ! #endregion marketOpenEventHandler_arePositionsToBeOpened ! public void MarketOpenEventHandler( ! Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) ! { ! this.updateReturnIntervals(); ! if ( this.marketOpenEventHandler_arePositionsToBeClosed() ) ! AccountManager.ClosePositions( this.account ); ! if ( this.marketOpenEventHandler_arePositionsToBeOpened() ) ! AccountManager.OpenPositions( this.bestWeightedPositionsInSample , ! this.account ); ! } ! #endregion MarketOpenEventHandler ! public void FiveMinutesBeforeMarketCloseEventHandler( ! Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) ! { ! } ! #region MarketCloseEventHandler ! private bool marketCloseEventHandler_arePositionsToBeClosed() ! { ! return marketOpenEventHandler_arePositionsToBeClosed(); ! } ! private bool marketCloseEventHandler_arePositionsToBeOpened() ! { ! // this strategy goes long only ! return false; ! } ! public void MarketCloseEventHandler( ! Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) ! { ! this.updateReturnIntervals(); ! if ( this.marketCloseEventHandler_arePositionsToBeClosed() ) ! AccountManager.ClosePositions( this.account ); ! if ( this.marketCloseEventHandler_arePositionsToBeOpened() ) ! { ! this.bestWeightedPositionsInSample.Reverse(); ! AccountManager.OpenPositions( ! this.bestWeightedPositionsInSample , ! this.account ); ! this.bestWeightedPositionsInSample.Reverse(); ! } ! } ! #endregion MarketCloseEventHandler ! #region OneHourAfterMarketCloseEventHandler ! private bool optimalWeightedPositionsAreToBeUpdated() ! { ! TimeSpan timeSpanSinceLastOptimization = ! this.now().DateTime - this.lastOptimizationDateTime; ! bool areToBeUpdated = ( timeSpanSinceLastOptimization.Days >= ! this.numDaysBeetweenEachOtpimization ); ! return areToBeUpdated; ! } ! #region getInSampleReturnIntervals ! private EndOfDayDateTime getInSampleReturnIntervals_getFirstDate() ! { ! DateTime firstDateTime = this.now().DateTime.AddDays( ! -this.numDaysForInSampleOptimization ); ! EndOfDayDateTime firstDate = new EndOfDayDateTime( ! firstDateTime , EndOfDaySpecificTime.MarketOpen ); ! return firstDate; ! } ! private ReturnIntervals getInSampleReturnIntervals() ! { ! EndOfDayDateTime firstDate = ! this.getInSampleReturnIntervals_getFirstDate(); ! EndOfDayDateTime lastDate = ! new EndOfDayDateTime( this.now().DateTime , ! EndOfDaySpecificTime.MarketClose ); ! ReturnIntervals inSampleReturnIntervals = ! new ReturnIntervals( this.intervalsSelector ); ! inSampleReturnIntervals.AppendFirstInterval( firstDate ); ! if ( inSampleReturnIntervals.LastEndOfDayDateTime.IsLessThan( ! lastDate ) ) ! inSampleReturnIntervals.AppendIntervalsButDontGoBeyondLastDate( ! lastDate ); ! return inSampleReturnIntervals; ! } ! #endregion getInSampleReturnIntervals ! private void notifyMessage( EligibleTickers eligibleTickers ) { ! string message = "Number of Eligible tickers: " + ! eligibleTickers.Count; ! NewMessageEventArgs newMessageEventArgs = ! new NewMessageEventArgs( message ); ! if ( this.NewMessage != null ) ! this.NewMessage( this , newMessageEventArgs ); } ! #region logOptimizationInfo ! private void outputMessage( string message ) { ! MessageManager.DisplayMessage( message , ! "FixedLengthUpDown.Txt" ); } ! private FixedLengthTwoPhasesLogItem getLogItem( EligibleTickers eligibleTickers ) { ! FixedLengthTwoPhasesLogItem logItem = ! new FixedLengthTwoPhasesLogItem( this.now() ); ! logItem.BestWeightedPositionsInSample = ! this.bestWeightedPositionsInSample; ! logItem.NumberOfEligibleTickers = ! eligibleTickers.Count; return logItem; } - private void raiseNewLogItem( EligibleTickers eligibleTickers ) - { - FixedLengthTwoPhasesLogItem logItem = - this.getLogItem( eligibleTickers ); - NewLogItemEventArgs newLogItemEventArgs = - new NewLogItemEventArgs( logItem ); - this.NewLogItem( this , newLogItemEventArgs ); - } - private void logOptimizationInfo( EligibleTickers eligibleTickers ) - { - this.raiseNewLogItem( eligibleTickers ); - } - #endregion logOptimizationInfo - private void updateOptimalWeightedPositions_actually() - { - ReturnIntervals inSampleReturnIntervals = - this.getInSampleReturnIntervals(); - EligibleTickers eligibleTickers = - this.eligiblesSelector.GetEligibleTickers( - inSampleReturnIntervals.BordersHistory ); - ReturnsManager returnsManager = new ReturnsManager( - inSampleReturnIntervals , this.historicalQuoteProvider ); - this.bestWeightedPositionsInSample = - (WeightedPositions)this.inSampleChooser.AnalyzeInSample( - eligibleTickers , returnsManager ); ! this.notifyMessage( eligibleTickers ); ! this.logOptimizationInfo( eligibleTickers ); ! } ! private void updateOptimalWeightedPositions() ! { ! this.updateOptimalWeightedPositions_actually(); ! this.lastOptimizationDateTime = this.now().DateTime; ! FixedLengthTwoPhasesLogItem logItem = ! new FixedLengthTwoPhasesLogItem( this.now() ); ! logItem.BestWeightedPositionsInSample = this.bestWeightedPositionsInSample; ! // this.wFLagWeightedPositionsChooser.WFLagChosenPositions , ! // this.wFLagWeightedPositionsChooser.GenerationWhenChosenPositionsWereFound , ! // this.now().DateTime ); ! // this.NewChosenPositions( ! // this , new WFLagNewChosenPositionsEventArgs( ! // wFLagLogItem ) ); ! } ! public void OneHourAfterMarketCloseEventHandler( ! Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) ! { ! if ( this.optimalWeightedPositionsAreToBeUpdated() ) ! this.updateOptimalWeightedPositions(); ! } ! #endregion OneHourAfterMarketCloseEventHandler ! public bool isInsampleOptimizationNeeded() ! { ! DateTime dateTimeForNextOptimization = ! this.lastOptimizationDateTime.AddDays( ! this.numDaysBeetweenEachOtpimization ); ! bool returnValue = ! ( ( ( this.account.Portfolio.Count == 0 ) ! && ( ( this.lastOptimizationDateTime == DateTime.MinValue ) ) ) || ! ( this.now().DateTime >= dateTimeForNextOptimization ) ); ! return returnValue; ! } ! private void updateReturnIntervals() ! { ! EndOfDayDateTime currentEndOfDayDateTime = ! this.account.EndOfDayTimer.GetCurrentTime(); ! if ( this.returnIntervals.Count == 0 ) ! // no interval has been added yet ! this.returnIntervals.AppendFirstInterval( ! currentEndOfDayDateTime ); ! else ! // at least one interval has already been added ! if ( this.returnIntervals.LastEndOfDayDateTime.IsLessThanOrEqualTo( ! currentEndOfDayDateTime ) ) ! this.returnIntervals.AppendIntervalsToGoJustBeyond( ! currentEndOfDayDateTime ); ! } ! private EndOfDayDateTime now() ! { ! return this.account.EndOfDayTimer.GetCurrentTime(); ! } ! private ReturnInterval lastIntervalAppended() ! { ! ReturnInterval lastInterval = ! this.returnIntervals[ this.returnIntervals.Count - 1 ]; ! return lastInterval; ! } } } --- 120,363 ---- return ( beginsTheLastInterval && lastIntervalIsALongPeriod ); } ! #endregion currentTimeBeginsALongPeriod ! ! protected override bool arePositionsToBeOpened() { bool arePositionsToBeOpened = ( ! ( this.bestTestingPositionsInSample != null ) && ( this.currentTimeBeginsALongPeriod() ) ); return arePositionsToBeOpened; } ! #endregion arePositionsToBeOpened ! ! protected override WeightedPositions getPositionsToBeOpened() { ! WeightedPositions weightedPositions = ! this.outOfSampleChooser.GetPositionsToBeOpened( ! this.bestTestingPositionsInSample ); ! return weightedPositions; } ! ! protected override string getTextIdentifier() { ! return "FLTP"; } ! ! protected override LogItem getLogItem( EligibleTickers eligibleTickers ) { ! FLTPLogItem logItem = ! new FLTPLogItem( ! this.now() , ! this.bestTestingPositionsInSample , ! this.numDaysForInSampleOptimization , ! eligibleTickers.Count ); return logItem; } ! // #region MarketOpenEventHandler ! // private bool marketOpenEventHandler_arePositionsToBeClosed() ! // { ! // bool arePositionsToBeClosed = ( ! // ( this.account.Portfolio.Count > 0 ) && ! // ( this.now().IsEqualTo( ! // this.lastIntervalAppended().Begin ) ) ); ! // return arePositionsToBeClosed; ! // } ! // #region marketOpenEventHandler_arePositionsToBeOpened ! // private bool marketOpenEventHandler_arePositionsToBeOpened() ! // { ! // bool arePositionsToBeOpened = ( ! // ( this.bestWeightedPositionsInSample != null ) && ! // ( this.currentTimeBeginsALongPeriod() ) ); ! // return arePositionsToBeOpened; ! // } ! // #endregion marketOpenEventHandler_arePositionsToBeOpened ! // public void MarketOpenEventHandler( ! // Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) ! // { ! // this.updateReturnIntervals(); ! // if ( this.marketOpenEventHandler_arePositionsToBeClosed() ) ! // AccountManager.ClosePositions( this.account ); ! // if ( this.marketOpenEventHandler_arePositionsToBeOpened() ) ! // AccountManager.OpenPositions( this.bestWeightedPositionsInSample , ! // this.account ); ! // } ! // #endregion MarketOpenEventHandler ! ! ! // #region MarketCloseEventHandler ! // private bool marketCloseEventHandler_arePositionsToBeClosed() ! // { ! // return marketOpenEventHandler_arePositionsToBeClosed(); ! // } ! // private bool marketCloseEventHandler_arePositionsToBeOpened() ! // { ! // // this strategy goes long only ! // return false; ! // } ! // public void MarketCloseEventHandler( ! // Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) ! // { ! // this.updateReturnIntervals(); ! // if ( this.marketCloseEventHandler_arePositionsToBeClosed() ) ! // AccountManager.ClosePositions( this.account ); ! // if ( this.marketCloseEventHandler_arePositionsToBeOpened() ) ! // { ! // this.bestWeightedPositionsInSample.Reverse(); ! // AccountManager.OpenPositions( ! // this.bestWeightedPositionsInSample , ! // this.account ); ! // this.bestWeightedPositionsInSample.Reverse(); ! // } ! // } ! // #endregion MarketCloseEventHandler ! ! // #region OneHourAfterMarketCloseEventHandler ! // private bool optimalWeightedPositionsAreToBeUpdated() ! // { ! // TimeSpan timeSpanSinceLastOptimization = ! // this.now().DateTime - this.lastOptimizationDateTime; ! // bool areToBeUpdated = ( timeSpanSinceLastOptimization.Days >= ! // this.numDaysBetweenEachOtpimization ); ! // return areToBeUpdated; ! // } ! // #region getInSampleReturnIntervals ! // private EndOfDayDateTime getInSampleReturnIntervals_getFirstDate() ! // { ! // DateTime firstDateTime = this.now().DateTime.AddDays( ! // -this.numDaysForInSampleOptimization ); ! // EndOfDayDateTime firstDate = new EndOfDayDateTime( ! // firstDateTime , EndOfDaySpecificTime.MarketOpen ); ! // return firstDate; ! // } ! // private ReturnIntervals getInSampleReturnIntervals() ! // { ! // EndOfDayDateTime firstDate = ! // this.getInSampleReturnIntervals_getFirstDate(); ! // EndOfDayDateTime lastDate = ! // new EndOfDayDateTime( this.now().DateTime , ! // EndOfDaySpecificTime.MarketClose ); ! // ReturnIntervals inSampleReturnIntervals = ! // new ReturnIntervals( this.intervalsSelector ); ! // inSampleReturnIntervals.AppendFirstInterval( firstDate ); ! // if ( inSampleReturnIntervals.LastEndOfDayDateTime.IsLessThan( ! // lastDate ) ) ! // inSampleReturnIntervals.AppendIntervalsButDontGoBeyondLastDate( ! // lastDate ); ! // return inSampleReturnIntervals; ! // } ! // #endregion getInSampleReturnIntervals ! // private void notifyMessage( EligibleTickers eligibleTickers ) ! // { ! // string message = "Number of Eligible tickers: " + ! // eligibleTickers.Count; ! // NewMessageEventArgs newMessageEventArgs = ! // new NewMessageEventArgs( message ); ! // if ( this.NewMessage != null ) ! // this.NewMessage( this , newMessageEventArgs ); ! // } ! // #region logOptimizationInfo ! // private void outputMessage( string message ) ! // { ! // MessageManager.DisplayMessage( message , ! // "FixedLengthUpDown.Txt" ); ! // } ! // private FixedLengthTwoPhasesLogItem getLogItem( EligibleTickers eligibleTickers ) ! // { ! // FixedLengthTwoPhasesLogItem logItem = ! // new FixedLengthTwoPhasesLogItem( this.now() ); ! // logItem.BestWeightedPositionsInSample = ! // this.bestWeightedPositionsInSample; ! // logItem.NumberOfEligibleTickers = ! // eligibleTickers.Count; ! // return logItem; ! // } ! // private void raiseNewLogItem( EligibleTickers eligibleTickers ) ! // { ! // FixedLengthTwoPhasesLogItem logItem = ! // this.getLogItem( eligibleTickers ); ! // NewLogItemEventArgs newLogItemEventArgs = ! // new NewLogItemEventArgs( logItem ); ! // this.NewLogItem( this , newLogItemEventArgs ); ! // } ! // private void logOptimizationInfo( EligibleTickers eligibleTickers ) ! // { ! // this.raiseNewLogItem( eligibleTickers ); ! // } ! // #endregion logOptimizationInfo ! // private void updateOptimalWeightedPositions_actually() ! // { ! // ReturnIntervals inSampleReturnIntervals = ! // this.getInSampleReturnIntervals(); ! // EligibleTickers eligibleTickers = ! // this.eligiblesSelector.GetEligibleTickers( ! // inSampleReturnIntervals.BordersHistory ); ! // ReturnsManager returnsManager = new ReturnsManager( ! // inSampleReturnIntervals , this.historicalQuoteProvider ); ! // this.bestWeightedPositionsInSample = ! // (WeightedPositions)this.inSampleChooser.AnalyzeInSample( ! // eligibleTickers , returnsManager ); ! // ! // this.notifyMessage( eligibleTickers ); ! // this.logOptimizationInfo( eligibleTickers ); ! // } ! // private void updateOptimalWeightedPositions() ! // { ! // this.updateOptimalWeightedPositions_actually(); ! // this.lastOptimizationDateTime = this.now().DateTime; ! // FixedLengthTwoPhasesLogItem logItem = ! // new FixedLengthTwoPhasesLogItem( this.now() ); ! // logItem.BestWeightedPositionsInSample = this.bestWeightedPositionsInSample; ! //// this.wFLagWeightedPositionsChooser.WFLagChosenPositions , ! //// this.wFLagWeightedPositionsChooser.GenerationWhenChosenPositionsWereFound , ! //// this.now().DateTime ); ! //// this.NewChosenPositions( ! //// this , new WFLagNewChosenPositionsEventArgs( ! //// wFLagLogItem ) ); ! // } ! // public void OneHourAfterMarketCloseEventHandler( ! // Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) ! // { ! // if ( this.optimalWeightedPositionsAreToBeUpdated() ) ! // this.updateOptimalWeightedPositions(); ! // } ! // #endregion OneHourAfterMarketCloseEventHandler ! ! // public bool isInsampleOptimizationNeeded() ! // { ! // DateTime dateTimeForNextOptimization = ! // this.lastOptimizationDateTime.AddDays( ! // this.numDaysBetweenEachOtpimization ); ! // bool returnValue = ! // ( ( ( this.account.Portfolio.Count == 0 ) ! // && ( ( this.lastOptimizationDateTime == DateTime.MinValue ) ) ) || ! // ( this.now().DateTime >= dateTimeForNextOptimization ) ); ! // return returnValue; ! // } ! // private void updateReturnIntervals() ! // { ! // EndOfDayDateTime currentEndOfDayDateTime = ! // this.account.EndOfDayTimer.GetCurrentTime(); ! // if ( this.returnIntervals.Count == 0 ) ! // // no interval has been added yet ! // this.returnIntervals.AppendFirstInterval( ! // currentEndOfDayDateTime ); ! // else ! // // at least one interval has already been added ! // if ( this.returnIntervals.LastEndOfDayDateTime.IsLessThanOrEqualTo( ! // currentEndOfDayDateTime ) ) ! // this.returnIntervals.AppendIntervalsToGoJustBeyond( ! // currentEndOfDayDateTime ); ! // } ! // private EndOfDayDateTime now() ! // { ! // return this.account.EndOfDayTimer.GetCurrentTime(); ! // } ! // private ReturnInterval lastIntervalAppended() ! // { ! // ReturnInterval lastInterval = ! // this.returnIntervals[ this.returnIntervals.Count - 1 ]; ! // return lastInterval; ! // } } } |
|
From: Glauco S. <gla...@us...> - 2008-08-16 19:35:46
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases/InSampleChoosers/Genetic In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv334/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases/InSampleChoosers/Genetic Modified Files: FixedLengthTwoPhasesGeneticChooser.cs Log Message: This class now extends the QuantProject.Business.Strategies.InSample.GeneticChooser class Index: FixedLengthTwoPhasesGeneticChooser.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases/InSampleChoosers/Genetic/FixedLengthTwoPhasesGeneticChooser.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** FixedLengthTwoPhasesGeneticChooser.cs 1 Apr 2008 21:30:11 -0000 1.6 --- FixedLengthTwoPhasesGeneticChooser.cs 16 Aug 2008 19:35:08 -0000 1.7 *************** *** 33,36 **** --- 33,37 ---- using QuantProject.Business.Strategies.Optimizing.Decoding; using QuantProject.Business.Strategies.Optimizing.FitnessEvaluation; + using QuantProject.Business.Strategies.Optimizing.GenomeManagers; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Timing; *************** *** 41,80 **** /// In sample analyzer for the walk forward fixed length two phases strategy /// </summary> ! public class FixedLengthTwoPhasesGeneticChooser : IInSampleChooser { - public event NewProgressEventHandler NewProgress; - public event NewMessageEventHandler NewMessage; - private int numberOfPortfolioPositions; - private int inSampleDays; - private Benchmark benchmark; - private IDecoderForWeightedPositions decoderForWeightedPositions; - private IFitnessEvaluator fitnessEvaluator; - private IHistoricalQuoteProvider historicalQuoteProvider; - private double crossoverRate; - private double mutationRate; - private double elitismRate; - private int populationSizeForGeneticOptimizer; - private int generationNumberForGeneticOptimizer; - private int seedForRandomGenerator; - - private GeneticOptimizer geneticOptimizer; - - - public string Description - { - get - { - string description = "IsChsr_genetic_" + - "longOnly_" + - "gnrtnSz_" + this.populationSizeForGeneticOptimizer + - "_gnrtnNmbr_" + this.generationNumberForGeneticOptimizer + - this.decoderForWeightedPositions.Description; - return description; - } - } public FixedLengthTwoPhasesGeneticChooser( ! int numberOfPortfolioPositions , int inSampleDays , Benchmark benchmark , ! IDecoderForWeightedPositions decoderForWeightedPositions , IFitnessEvaluator fitnessEvaluator , IHistoricalQuoteProvider historicalQuoteProvider , --- 42,53 ---- /// In sample analyzer for the walk forward fixed length two phases strategy /// </summary> ! public class FixedLengthTwoPhasesGeneticChooser : GeneticChooser { public FixedLengthTwoPhasesGeneticChooser( ! int numberOfPortfolioPositions , ! int numberOfBestTestingPositionsToBeReturned , ! Benchmark benchmark , ! IDecoderForTestingPositions decoderForTestingPositions , IFitnessEvaluator fitnessEvaluator , IHistoricalQuoteProvider historicalQuoteProvider , *************** *** 82,223 **** int populationSizeForGeneticOptimizer , int generationNumberForGeneticOptimizer , ! int seedForRandomGenerator ) { - this.numberOfPortfolioPositions = numberOfPortfolioPositions; - this.inSampleDays = inSampleDays; - this.benchmark = benchmark; - this.decoderForWeightedPositions = decoderForWeightedPositions; - this.fitnessEvaluator = fitnessEvaluator; - this.historicalQuoteProvider = historicalQuoteProvider; - this.crossoverRate = crossoverRate; - this.mutationRate = mutationRate; - this.elitismRate = elitismRate; - this.populationSizeForGeneticOptimizer = populationSizeForGeneticOptimizer; - this.generationNumberForGeneticOptimizer = - generationNumberForGeneticOptimizer; - this.seedForRandomGenerator = seedForRandomGenerator; } ! #region AnalyzeInSample ! private void analyzeInSample_checkParameters( EligibleTickers eligibleTickers , ReturnsManager returnsManager ) { ! if ( eligibleTickers.Count < this.numberOfPortfolioPositions ) ! throw new Exception( "Eligilbe tickers for driving positions contains " + ! "only " + eligibleTickers.Count + ! " elements, while the number of portfolio positions is " + ! this.numberOfPortfolioPositions ); ! } ! #region newGenerationEventHandler ! private void sendNewProgress( NewGenerationEventArgs e ) ! { ! if ( this.NewProgress != null ) ! this.NewProgress( this , ! new NewProgressEventArgs( e.GenerationCounter , e.GenerationNumber ) ); ! } ! #region sendNewMessage ! private string getProgressMessage( ! int generationCounter , int generationNumber ) ! { ! string progressMessage = ! generationCounter.ToString() + " / " + ! generationNumber.ToString() + ! " - " + ! DateTime.Now.ToString(); ! return progressMessage; ! } ! private void sendNewMessage( NewGenerationEventArgs e ) ! { ! string message = this.getProgressMessage( ! e.GenerationCounter , e.GenerationNumber ); ! NewMessageEventArgs newMessageEventArgs = ! new NewMessageEventArgs( message ); ! if( this.NewMessage != null ) ! this.NewMessage( this , newMessageEventArgs ); ! } ! #endregion sendNewMessage ! private void newGenerationEventHandler( ! object sender , NewGenerationEventArgs e ) ! { ! // // comment out this line if no debug is done ! // WFLagGenerationDebugger wFLagGenerationDebugger = ! // new WFLagGenerationDebugger( ! // e.Generation , ! // this.timeWhenChosePositionsIsRequested.DateTime , ! // this.NumberDaysForInSampleOptimization , ! // this.benchmark ); ! // wFLagGenerationDebugger.Debug(); ! this.sendNewProgress( e ); ! this.sendNewMessage( e ); ! } ! #endregion newGenerationEventHandler ! private void checkIfBestGenomeIsDecodable( ! IGenomeManager genomeManager , Genome genome ) ! { ! object genomeMeaning = genomeManager.Decode( genome ); ! if ( !(genomeMeaning is WeightedPositions) ) ! throw new Exception( "The genome is not a WeightedPositions. " + ! "It should happen only if the genome is undecodable. This " + ! "should never happen for the best genome." ); } ! ! private WeightedPositions getBestWeightedPositionsInSample( ! EligibleTickers eligibleTickers , ! ReturnsManager returnsManager ! ) { ! FixedLengthTwoPhasesGenomeManager genomeManager = ! new FixedLengthTwoPhasesGenomeManager( ! this.numberOfPortfolioPositions , ! eligibleTickers , ! returnsManager , ! this.decoderForWeightedPositions , ! this.fitnessEvaluator , ! QuantProject.ADT.ConstantsProvider.SeedForRandomGenerator ); ! ! this.geneticOptimizer = new GeneticOptimizer( ! this.crossoverRate , ! this.mutationRate , ! this.elitismRate , ! this.populationSizeForGeneticOptimizer , ! this.generationNumberForGeneticOptimizer , ! genomeManager , ! this.seedForRandomGenerator ); ! ! this.geneticOptimizer.NewGeneration += ! new NewGenerationEventHandler( this.newGenerationEventHandler ); ! ! this.geneticOptimizer.Run( false ); ! ! // this.generation = geneticOptimizer.BestGenome.Generation; ! ! this.checkIfBestGenomeIsDecodable( ! genomeManager , this.geneticOptimizer.BestGenome ); ! ! WeightedPositions bestWeightedPositionsInSample = ! (WeightedPositions)genomeManager.Decode( this.geneticOptimizer.BestGenome ); ! ! return bestWeightedPositionsInSample; } - /// <summary> - /// Returns the best WeightedPositions with respect to the in sample data - /// </summary> - /// <param name="eligibleTickers"></param> - /// <param name="currentOutOfSampleEndOfDayDateTime"></param> - /// <returns></returns> - public object AnalyzeInSample( - EligibleTickers eligibleTickers , - ReturnsManager returnsManager ) - { - this.analyzeInSample_checkParameters( eligibleTickers , - returnsManager ); - WeightedPositions bestWeightedPositionsInSample = - this.getBestWeightedPositionsInSample( eligibleTickers , - returnsManager ); - return bestWeightedPositionsInSample; - } - #endregion AnalyzeInSample } } --- 55,99 ---- int populationSizeForGeneticOptimizer , int generationNumberForGeneticOptimizer , ! int seedForRandomGenerator ) : ! base( ! numberOfPortfolioPositions , ! numberOfBestTestingPositionsToBeReturned , ! benchmark , ! decoderForTestingPositions , ! fitnessEvaluator , ! historicalQuoteProvider , ! crossoverRate , ! mutationRate , ! elitismRate , ! populationSizeForGeneticOptimizer , ! generationNumberForGeneticOptimizer , ! seedForRandomGenerator ) { } ! ! ! ! protected override IGenomeManager getGenomeManager( EligibleTickers eligibleTickers , ReturnsManager returnsManager ) { ! GenomeManagerWithDuplicateGenes genomeManagerWithDuplicateGenes = ! new GenomeManagerWithDuplicateGenes( ! this.numberOfPortfolioPositions , ! eligibleTickers , ! returnsManager , ! this.decoderForTestingPositions , ! this.fitnessEvaluator , ! GenomeManagerType.ShortAndLong , ! this.seedForRandomGenerator ); ! return genomeManagerWithDuplicateGenes; } ! ! protected override string getHashCodeForGenome( Genome genome ) { ! return ((FLTPTestingPositions)(genome.Meaning)).HashCodeForTickerComposition; } } } |
|
From: Glauco S. <gla...@us...> - 2008-08-16 19:32:22
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases/InSampleChoosers In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv28831/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases/InSampleChoosers Modified Files: FixedLengthTwoPhasesFitnessEvaluator.cs Log Message: Now the expected meaning is a TestingPositions (it was a WeightedPositions in the previous revision) Index: FixedLengthTwoPhasesFitnessEvaluator.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases/InSampleChoosers/FixedLengthTwoPhasesFitnessEvaluator.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FixedLengthTwoPhasesFitnessEvaluator.cs 10 Feb 2008 14:18:53 -0000 1.2 --- FixedLengthTwoPhasesFitnessEvaluator.cs 16 Aug 2008 19:32:17 -0000 1.3 *************** *** 26,29 **** --- 26,30 ---- using QuantProject.Business.Strategies.EquityEvaluation; using QuantProject.Business.Strategies.Optimizing.FitnessEvaluation; + using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Strategies.ReturnsManagement; *************** *** 35,38 **** --- 36,41 ---- public class FixedLengthTwoPhasesFitnessEvaluator : IFitnessEvaluator { + private const double fitnessForInvalidCandidate = -1000d; + private IEquityEvaluator equityEvaluator; *************** *** 51,55 **** --- 54,65 ---- this.equityEvaluator = equityEvaluator; } + #region GetFitnessValue + private void getFitnessValue_checkParameters( object meaning ) + { + if ( !( meaning is TestingPositions ) ) + throw new Exception( + "The meaning should always be a TestingPositions!" ); + } /// <summary> /// This private method is written in compact mode, in order *************** *** 90,110 **** return fitnessValue; } ! public double GetFitnessValue( object meaning , ReturnsManager returnsManager ) { double fitnessValue; ! if ( meaning is WeightedPositions ) ! { // for the current optimization's candidate, // all positions's tickers are distinct - WeightedPositions weightedPositions = - (WeightedPositions)meaning; fitnessValue = this.getFitnessValue( weightedPositions , returnsManager ); ! } ! else ! { ! // the current optimization's candidate contains ! // two genes that decode to the same tickers ! fitnessValue = -0.4; ! } return fitnessValue; } --- 100,124 ---- return fitnessValue; } ! private double getFitnessValue( TestingPositions testingPositions , ! ReturnsManager returnsManager ) { double fitnessValue; ! WeightedPositions weightedPositions = testingPositions.WeightedPositions; ! if ( weightedPositions == null ) ! // the current optimization's candidate contains ! // two genes that decode to the same tickers ! fitnessValue = fitnessForInvalidCandidate; ! else // for the current optimization's candidate, // all positions's tickers are distinct fitnessValue = this.getFitnessValue( weightedPositions , returnsManager ); ! return fitnessValue; ! } ! ! public double GetFitnessValue( object meaning , ReturnsManager returnsManager ) ! { ! this.getFitnessValue_checkParameters( meaning ); ! double fitnessValue = ! this.getFitnessValue( (TestingPositions)meaning , returnsManager ); return fitnessValue; } |
|
From: Glauco S. <gla...@us...> - 2008-08-16 19:30:24
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/ArbitrageTesting/OverReactionHypothesis/DoubleOverReaction_OTC In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv26577/b7_Scripts/ArbitrageTesting/OverReactionHypothesis/DoubleOverReaction_OTC Modified Files: EndOfDayTimerHandlerDOR_OTC.cs Log Message: The code has been changed to avoid a warning Index: EndOfDayTimerHandlerDOR_OTC.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/ArbitrageTesting/OverReactionHypothesis/DoubleOverReaction_OTC/EndOfDayTimerHandlerDOR_OTC.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** EndOfDayTimerHandlerDOR_OTC.cs 29 Aug 2007 09:43:30 -0000 1.2 --- EndOfDayTimerHandlerDOR_OTC.cs 16 Aug 2008 19:30:11 -0000 1.3 *************** *** 190,194 **** } catch(Exception ex) ! {ex = ex;} } } --- 190,194 ---- } catch(Exception ex) ! {int dummy = 1; dummy++;} } } |
|
From: Glauco S. <gla...@us...> - 2008-08-16 19:28:07
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/EndOfDayStrategies In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv22668/b4_Business/a2_Strategies/EndOfDayStrategies Modified Files: BasicEndOfDayStrategyForBacktester.cs Log Message: The text for the log has been slightly improved Index: BasicEndOfDayStrategyForBacktester.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/EndOfDayStrategies/BasicEndOfDayStrategyForBacktester.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** BasicEndOfDayStrategyForBacktester.cs 11 May 2008 16:37:31 -0000 1.6 --- BasicEndOfDayStrategyForBacktester.cs 16 Aug 2008 19:28:02 -0000 1.7 *************** *** 241,245 **** { string message = "Number of Eligible tickers: " + ! eligibleTickers.Count; NewMessageEventArgs newMessageEventArgs = new NewMessageEventArgs( message ); --- 241,247 ---- { string message = "Number of Eligible tickers: " + ! eligibleTickers.Count + ! " - " + ! DateTime.Now.ToString(); NewMessageEventArgs newMessageEventArgs = new NewMessageEventArgs( message ); |
|
From: Glauco S. <gla...@us...> - 2008-08-16 19:27:02
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv21126/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases Modified Files: FixedLengthTwoPhasesMain.cs Log Message: Not the class extends BasicScriptForBacktesting (all changes have been applied for this goal) Index: FixedLengthTwoPhasesMain.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases/FixedLengthTwoPhasesMain.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** FixedLengthTwoPhasesMain.cs 11 May 2008 19:00:20 -0000 1.8 --- FixedLengthTwoPhasesMain.cs 16 Aug 2008 19:26:57 -0000 1.9 *************** *** 19,23 **** 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; --- 19,23 ---- 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; *************** *** 38,41 **** --- 38,42 ---- using QuantProject.Business.Timing; using QuantProject.Presentation; + using QuantProject.Scripts.General; using QuantProject.Scripts.General.Logging; using QuantProject.Scripts.General.Reporting; *************** *** 49,138 **** /// be done /// </summary> ! public class FixedLengthTwoPhasesMain { public FixedLengthTwoPhasesMain() { } ! #region Run ! private MessageManager setMessageManager( ! IEligiblesSelector eligiblesSelector , ! IInSampleChooser inSampleChooser , ! IEndOfDayStrategy endOfDayStrategy , ! EndOfDayStrategyBackTester endOfDayStrategyBackTester ) ! { ! MessageManager messageManager = ! new MessageManager( "FixedLengthUpDown.Txt" ); ! messageManager.Monitor( eligiblesSelector ); ! messageManager.Monitor( inSampleChooser ); ! // messageManager.Monitor( endOfDayStrategy ); ! messageManager.Monitor( endOfDayStrategyBackTester ); ! return messageManager; ! } ! ! // TO DO check if you can add this to QuantProject.Presentation.Reporting.WindowsForm.Report ! // as a public method or as a new constructor ! // private void showReport( ! // DateTime lastDateTimeRequestedForTheScript , ! // EndOfDayStrategyBackTester endOfDayStrategyBackTester ) ! // { ! //// DateTime lastReportDateTime = ExtendedDateTime.Min( ! //// lastDateTimeRequestedForTheScript , ! //// endOfDayStrategyBackTester.EndOfDayTimer.GetCurrentTime().DateTime ); ! // DateTime lastReportDateTime = ! // endOfDayStrategyBackTester.ActualLastDateTime; ! // Report report = new Report( ! // endOfDayStrategyBackTester.AccountReport , ! // true ); ! // report.Create( endOfDayStrategyBackTester.DescriptionForLogFileName , 1 , ! // new EndOfDayDateTime( lastReportDateTime , ! // EndOfDaySpecificTime.OneHourAfterMarketClose ) , ! // endOfDayStrategyBackTester.Benchmark.Ticker ); ! // report.Show(); ! // } ! private void saveLog( BackTestLog backTestLog , ! string suggestedLogFileName ) { ! string defaultFolderPath = ! "C:\\qpReports\\"; ! // this.wFLagLog.TransactionHistory = this.account.Transactions; ! LogArchiver.Save( backTestLog , ! suggestedLogFileName , defaultFolderPath ); ! } ! public void Run1() ! { ! BackTestLog backTestLog = LogArchiver.Load( "C:\\qpReports\\" ); ! LogViewer logViewer = ! new LogViewer( backTestLog ); ! logViewer.Show(); } ! ! public void Run() { ! string backTestId = "WFFLTP"; ! double cashToStart = 30000; ! ! // int numberOfPortfolioPositions = 2; ! // int inSampleDays = 90; ! // string tickersGroupId = "SP500"; ! // uncomment the following three lines for faster scripts ! int numberOfPortfolioPositions = 2; ! int inSampleDays = 30; ! string tickersGroupId = "fastTest"; ! ! Benchmark benchmark = new Benchmark( "MSFT" ); ! int maxNumberOfEligiblesToBeChosen = 100; ! IDecoderForWeightedPositions decoderForWeightedPositions ! = new DecoderForBalancedWeightedPositions(); ! IHistoricalQuoteProvider historicalQuoteProvider = ! new HistoricalAdjustedQuoteProvider(); // definition for the Fitness Evaluator ! IEquityEvaluator equityEvaluator = new SharpeRatio(); IFitnessEvaluator fitnessEvaluator = ! new FixedLengthTwoPhasesFitnessEvaluator( equityEvaluator ); // parameters for the genetic optimizer --- 50,124 ---- /// be done /// </summary> ! public class FixedLengthTwoPhasesMain : BasicScriptForBacktesting { + private Benchmark benchmark; + private int numberOfPortfolioPositions; + private IHistoricalQuoteProvider historicalQuoteProviderForInSample; + private IHistoricalQuoteProvider + historicalQuoteProviderForTheBacktesterAccount; + public FixedLengthTwoPhasesMain() { + this.benchmark = new Benchmark( "CCE" ); + this.numberOfPortfolioPositions = 1; + this.historicalQuoteProviderForInSample = + new HistoricalRawQuoteProvider(); + this.historicalQuoteProviderForTheBacktesterAccount = + new HistoricalRawQuoteProvider(); } ! ! protected override IEligiblesSelector getEligiblesSelector() { ! string tickersGroupId = "SP500"; ! // uncomment the following line for a faster script ! tickersGroupId = "fastTest"; ! ! int maxNumberOfEligibleTickersToBeChosen = 100; ! int maxNumberOfMostLiquidTickersToBeChosen = ! maxNumberOfEligibleTickersToBeChosen + 50; ! int numOfDaysForAverageOpenRawPriceComputation = 10; ! int numOfDaysForVolatilityComputation = 10; ! double minPrice = 20; ! double maxPrice = 75; + IEligiblesSelector eligiblesSelector = + new ByPriceMostLiquidAlwaysQuoted( + tickersGroupId , + true , + maxNumberOfEligibleTickersToBeChosen , + numOfDaysForAverageOpenRawPriceComputation , + minPrice , + maxPrice ); + eligiblesSelector = + new ByPriceMostLiquidLessVolatileOTCAlwaysQuoted( + tickersGroupId , + true , + maxNumberOfEligibleTickersToBeChosen , + maxNumberOfMostLiquidTickersToBeChosen , + numOfDaysForAverageOpenRawPriceComputation , + numOfDaysForVolatilityComputation , + minPrice , + maxPrice ); + // uncomment the following line for a (logbased) log based in sample chooser + // eligiblesSelector = new DummyEligibleSelector(); ! return eligiblesSelector; } ! ! protected override IInSampleChooser getInSampleChooser() { ! int numberOfBestTestingPositionsToBeReturned = 20; ! // uncomment the following line for a faster script ! numberOfBestTestingPositionsToBeReturned = 2; ! IDecoderForTestingPositions decoderForWeightedPositions = ! new DecoderForFLTPTestingPositionsWithBalancedWeights(); // definition for the Fitness Evaluator ! IEquityEvaluator equityEvaluator = new SharpeRatio(); IFitnessEvaluator fitnessEvaluator = ! new FixedLengthTwoPhasesFitnessEvaluator( ! equityEvaluator ); // parameters for the genetic optimizer *************** *** 140,204 **** double mutationRate = 0.02; double elitismRate = 0.001; ! int populationSizeForGeneticOptimizer = 3000; ! int generationNumberForGeneticOptimizer = 5; int seedForRandomGenerator = QuantProject.ADT.ConstantsProvider.SeedForRandomGenerator; IInSampleChooser inSampleChooser = new FixedLengthTwoPhasesGeneticChooser( ! numberOfPortfolioPositions , inSampleDays , benchmark , ! decoderForWeightedPositions , fitnessEvaluator , ! historicalQuoteProvider , ! crossoverRate , mutationRate , elitismRate , ! populationSizeForGeneticOptimizer , generationNumberForGeneticOptimizer , ! seedForRandomGenerator ); IIntervalsSelector intervalsSelector = new FixedLengthTwoPhasesIntervalsSelector( 1 , 1 , benchmark ); ! // IEligiblesSelector eligiblesSelector = ! // new MostLiquidAndLessVolatile( ! // tickersGroupId , maxNumberOfEligiblesToBeChosen ); ! IEligiblesSelector eligiblesSelector = ! new ByPriceMostLiquidLessVolatileOTCAlwaysQuoted( ! tickersGroupId , ! true , ! maxNumberOfEligiblesToBeChosen , ! maxNumberOfEligiblesToBeChosen + 50 , ! 10 , 10 , 20 , 75 ); ! FixedLengthTwoPhasesStrategy fixedLengthTwoPhasesStrategy = new FixedLengthTwoPhasesStrategy( ! numberOfPortfolioPositions , ! 7 , 90 , benchmark , intervalsSelector , ! eligiblesSelector , inSampleChooser , historicalQuoteProvider ); ! DateTime firstDateTime = new DateTime( 2001 , 1 , 2 ); ! DateTime lastDateTime = new DateTime( 2001 , 1 , 6 ); ! double maxRunningHours = 7; EndOfDayStrategyBackTester endOfDayStrategyBackTester = new EndOfDayStrategyBackTester( ! backTestId , fixedLengthTwoPhasesStrategy , ! historicalQuoteProvider , ! new SimpleAccountProvider(), firstDateTime , ! lastDateTime , benchmark , cashToStart , maxRunningHours ); ! ! // TO DO check if you can do this assign in the EndOfDayStrategyBackTester ! // constructor ! fixedLengthTwoPhasesStrategy.Account = endOfDayStrategyBackTester.Account; ! ! MessageManager messageManager = this.setMessageManager( ! eligiblesSelector , inSampleChooser , ! fixedLengthTwoPhasesStrategy , endOfDayStrategyBackTester ); ! endOfDayStrategyBackTester.Run(); ! BackTesterReportViewer.ShowReport( lastDateTime , ! endOfDayStrategyBackTester ); ! this.saveLog( ! endOfDayStrategyBackTester.Log , ! endOfDayStrategyBackTester.Description ); } ! #endregion Run } } --- 126,242 ---- double mutationRate = 0.02; double elitismRate = 0.001; ! int populationSizeForGeneticOptimizer = 10000; ! int generationNumberForGeneticOptimizer = 1; int seedForRandomGenerator = QuantProject.ADT.ConstantsProvider.SeedForRandomGenerator; IInSampleChooser inSampleChooser = new FixedLengthTwoPhasesGeneticChooser( ! this.numberOfPortfolioPositions , ! numberOfBestTestingPositionsToBeReturned , ! benchmark , ! decoderForWeightedPositions , fitnessEvaluator , ! this.historicalQuoteProviderForInSample , ! crossoverRate , mutationRate , elitismRate , ! populationSizeForGeneticOptimizer , generationNumberForGeneticOptimizer , ! seedForRandomGenerator ); ! // inSampleChooser = ! // new PairsTradingBruteForceChooser( ! // numberOfBestTestingPositionsToBeReturned , ! // decoderForWeightedPositions , ! // fitnessEvaluator ); + // uncomment the following line for a (logbased) log based in sample chooser + // inSampleChooser = + // new PairsTradingChooserFromSavedBackTestLog( + // @"C:\qpReports\pairsTrading\2008_05_08_23_49_18_pairsTrdng_from_2005_01_01_to_2008_04_30_annlRtrn_90.70_maxDD_5.43\2008_05_08_23_49_18_pairsTrdng_from_2005_01_01_to_2008_04_30_annlRtrn_90.70_maxDD_5.43.qpL", + // numberOfBestTestingPositionsToBeReturned); + + return inSampleChooser; + } + + protected override IEndOfDayStrategyForBacktester getEndOfDayStrategy() + { + // int numberOfPortfolioPositions = 2; + int numDaysForInSampleOptimization = 180; + // uncomment the following line for a faster script + numDaysForInSampleOptimization = 5; + numDaysForInSampleOptimization = 45; + + int numDaysBetweenEachOtpimization = 3; + IIntervalsSelector intervalsSelector = new FixedLengthTwoPhasesIntervalsSelector( 1 , 1 , benchmark ); ! RankBasedOutOfSampleChooser outOfSampleChooser = ! new RankBasedOutOfSampleChooser( 0 ); FixedLengthTwoPhasesStrategy fixedLengthTwoPhasesStrategy = new FixedLengthTwoPhasesStrategy( ! this.numberOfPortfolioPositions , ! numDaysBetweenEachOtpimization , ! numDaysForInSampleOptimization , ! benchmark , intervalsSelector , ! eligiblesSelector , inSampleChooser , ! this.historicalQuoteProviderForInSample , ! outOfSampleChooser ); ! // IEndOfDayStrategyForBacktester endOfDayStrategyForBacktester = ! // new PairsTradingStrategy( ! // 7 , inSampleDays , intervalsSelector , ! // eligiblesSelector , inSampleChooser , ! // this.historicalQuoteProviderForInSample , ! // this.historicalQuoteProviderForChosingPositionsOutOfSample , ! // 0.006 , 0.99 , 0.006 , 0.99 ); ! // endOfDayStrategyForBacktester = ! // new LongOnlyPairsTradingStrategy( ! // 7 , inSampleDays , intervalsSelector , ! // eligiblesSelector , inSampleChooser , ! // this.historicalQuoteProviderForInSample , ! // this.historicalQuoteProviderForChosingPositionsOutOfSample , ! // 0.006 , 0.02 , 0.006 , 0.02 ); ! return fixedLengthTwoPhasesStrategy; ! } ! ! protected override EndOfDayStrategyBackTester ! getEndOfDayStrategyBackTester() ! { ! string backTestId = "FixedLengthTwoPhases"; ! IAccountProvider accountProvider = new SimpleAccountProvider(); ! double cashToStart = 30000; ! DateTime firstDateTime = new DateTime( 2006 , 1 , 2 ); ! DateTime lastDateTime = new DateTime( 2006 , 1 , 6 ); ! ! double maxRunningHours = 1; ! EndOfDayStrategyBackTester endOfDayStrategyBackTester = new EndOfDayStrategyBackTester( ! backTestId , this.endOfDayStrategy , ! this.historicalQuoteProviderForTheBacktesterAccount , ! accountProvider , ! firstDateTime , lastDateTime , ! this.benchmark , cashToStart , maxRunningHours ); ! return endOfDayStrategyBackTester; } ! ! protected override string getPathForTheMainFolderWhereScriptsResultsAreToBeSaved() ! { ! string pathForTheMainFolderWhereScriptsResultsAreToBeSaved = ! "C:\\qpReports\\fixedLengthTwoPhases\\"; ! return pathForTheMainFolderWhereScriptsResultsAreToBeSaved; ! } ! ! protected override string getCustomSmallTextForFolderName() ! { ! return "fltp"; ! } ! ! protected override string getFullPathFileNameForMain() ! { ! string fullPathFileNameForMain = ! @"C:\QuantProject\QuantProject\b7_Scripts\WalkForwardTesting\FixedLengthTwoPhases\FixedLengthTwoPhasesMain.cs"; ! return fullPathFileNameForMain; ! } } } |
|
From: Glauco S. <gla...@us...> - 2008-08-16 19:25:20
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv18748/b7_Scripts Modified Files: Scripts_SD.csproj Log Message: - WalkForwardTesting\PairsTrading\Logging\SimpleStrategy.cs has been moved to General\Strategies\SimpleStrategy.cs - WalkForwardTesting\FixedLengthTwoPhases\FLTPTestingPositions.cs has been added - WalkForwardTesting\FixedLengthTwoPhases\InSampleChoosers\Decoding\DecoderForFLTPTestingPositionsWithBalancedWeights.cs has been added - WalkForwardTesting\FixedLengthTwoPhases\InSampleChoosers\Genetic\FixedLengthTwoPhasesGenomeManager.cs has been removed - WalkForwardTesting\FixedLengthTwoPhases\Logging\FixedLengthTwoPhasesLogItem.cs has been replaced by WalkForwardTesting\FixedLengthTwoPhases\Logging\FLTPLogItem.cs - WalkForwardTesting\FixedLengthTwoPhases\Logging\FLTPSimpleStrategy.cs has been added - WalkForwardTesting\FixedLengthTwoPhases\Logging\TesterForFLTPTestingPositions.cs has been added - WalkForwardTesting\FixedLengthTwoPhases\OutOfSampleChoosers\RankBasedOutOfSampleChooser.cs has been added Index: Scripts_SD.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/Scripts_SD.csproj,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** Scripts_SD.csproj 14 Aug 2008 23:44:43 -0000 1.29 --- Scripts_SD.csproj 16 Aug 2008 19:25:15 -0000 1.30 *************** *** 55,58 **** --- 55,59 ---- <Compile Include="General\Logging\DummyTesterForTestingPositions.cs" /> <Compile Include="General\Reporting\BackTesterReportViewer.cs" /> + <Compile Include="General\Strategies\SimpleStrategy.cs" /> <Compile Include="MyTradingSystem.cs" /> <Compile Include="CallingReportsForRunScripts\ShowReportFromFile.cs" /> *************** *** 108,115 **** <Compile Include="WalkForwardTesting\FixedLengthTwoPhases\FixedLengthTwoPhasesMain.cs" /> <Compile Include="WalkForwardTesting\FixedLengthTwoPhases\FixedLengthTwoPhasesStrategy.cs" /> <Compile Include="WalkForwardTesting\FixedLengthTwoPhases\InSampleChoosers\FixedLengthTwoPhasesFitnessEvaluator.cs" /> <Compile Include="WalkForwardTesting\FixedLengthTwoPhases\InSampleChoosers\Genetic\FixedLengthTwoPhasesGeneticChooser.cs" /> ! <Compile Include="WalkForwardTesting\FixedLengthTwoPhases\InSampleChoosers\Genetic\FixedLengthTwoPhasesGenomeManager.cs" /> ! <Compile Include="WalkForwardTesting\FixedLengthTwoPhases\Logging\FixedLengthTwoPhasesLogItem.cs" /> <Compile Include="WalkForwardTesting\MSFTwalkForward\TsMSFTwalkForward.cs" /> <Compile Include="WalkForwardTesting\PairsTrading\InSample\InSampleChoosers\BruteForce\PairsTradingBruteForceChooser.cs" /> --- 109,120 ---- <Compile Include="WalkForwardTesting\FixedLengthTwoPhases\FixedLengthTwoPhasesMain.cs" /> <Compile Include="WalkForwardTesting\FixedLengthTwoPhases\FixedLengthTwoPhasesStrategy.cs" /> + <Compile Include="WalkForwardTesting\FixedLengthTwoPhases\FLTPTestingPositions.cs" /> + <Compile Include="WalkForwardTesting\FixedLengthTwoPhases\InSampleChoosers\Decoding\DecoderForFLTPTestingPositionsWithBalancedWeights.cs" /> <Compile Include="WalkForwardTesting\FixedLengthTwoPhases\InSampleChoosers\FixedLengthTwoPhasesFitnessEvaluator.cs" /> <Compile Include="WalkForwardTesting\FixedLengthTwoPhases\InSampleChoosers\Genetic\FixedLengthTwoPhasesGeneticChooser.cs" /> ! <Compile Include="WalkForwardTesting\FixedLengthTwoPhases\Logging\FLTPLogItem.cs" /> ! <Compile Include="WalkForwardTesting\FixedLengthTwoPhases\Logging\FLTPSimpleStrategy.cs" /> ! <Compile Include="WalkForwardTesting\FixedLengthTwoPhases\Logging\TesterForFLTPTestingPositions.cs" /> ! <Compile Include="WalkForwardTesting\FixedLengthTwoPhases\OutOfSampleChoosers\RankBasedOutOfSampleChooser.cs" /> <Compile Include="WalkForwardTesting\MSFTwalkForward\TsMSFTwalkForward.cs" /> <Compile Include="WalkForwardTesting\PairsTrading\InSample\InSampleChoosers\BruteForce\PairsTradingBruteForceChooser.cs" /> *************** *** 120,124 **** <Compile Include="WalkForwardTesting\PairsTrading\InSample\PairsTradingFitnessEvaluator.cs" /> <Compile Include="WalkForwardTesting\PairsTrading\Logging\PairsTradingLogItem.cs" /> - <Compile Include="WalkForwardTesting\PairsTrading\Logging\SimpleStrategy.cs" /> <Compile Include="WalkForwardTesting\PairsTrading\Logging\TesterForPairsTradingTestingPositions.cs" /> <Compile Include="WalkForwardTesting\PairsTrading\OutOfSampleChoosers\OutOfSampleChooser.cs" /> --- 125,128 ---- *************** *** 284,287 **** --- 288,292 ---- <Folder Include="EvaluatingOptimizationTechnique\EfficientPortfolio\" /> <Folder Include="BackTesting" /> + <Folder Include="General\Strategies" /> <Folder Include="TechnicalAnalysisTesting\Oscillators\ExtremeCounterTrend" /> <Folder Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\Decoding" /> *************** *** 296,301 **** --- 301,308 ---- <Folder Include="WalkForwardTesting\FixedLengthTwoPhases" /> <Folder Include="WalkForwardTesting\FixedLengthTwoPhases\InSampleChoosers" /> + <Folder Include="WalkForwardTesting\FixedLengthTwoPhases\InSampleChoosers\Decoding" /> <Folder Include="WalkForwardTesting\FixedLengthTwoPhases\InSampleChoosers\Genetic" /> <Folder Include="WalkForwardTesting\FixedLengthTwoPhases\Logging" /> + <Folder Include="WalkForwardTesting\FixedLengthTwoPhases\OutOfSampleChoosers" /> <Folder Include="WalkForwardTesting\PairsTrading" /> <Folder Include="WalkForwardTesting\PairsTrading\InSample" /> |
|
From: Glauco S. <gla...@us...> - 2008-08-16 19:21:47
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Logging In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv14152 Removed Files: SimpleStrategy.cs Log Message: It has been moved to General\Strategies\SimpleStrategy.cs --- SimpleStrategy.cs DELETED --- |
|
From: Glauco S. <gla...@us...> - 2008-08-16 19:20:18
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases/OutOfSampleChoosers In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv12319 Added Files: RankBasedOutOfSampleChooser.cs Log Message: Given the in sample TestingPositions candidates, this class selects the positions to be opened. It selects the i_th best element, where i is given by the rank value (zero based) --- NEW FILE: RankBasedOutOfSampleChooser.cs --- /* QuantProject - Quantitative Finance Library RankBasedOutOfSampleChooser.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 System.Collections; using QuantProject.ADT.Collections; using QuantProject.Business.DataProviders; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Strategies.ReturnsManagement.Time; using QuantProject.Business.Timing; namespace QuantProject.Scripts.WalkForwardTesting.FixedLengthTwoPhases { /// <summary> /// Given the in sample TestingPositions candidates, /// this class selects the positions to be opened. /// It selects the i_th best element, where i is given /// by the rank value (zero based) /// </summary> public class RankBasedOutOfSampleChooser { private int rank; public RankBasedOutOfSampleChooser( int rank ) { this.rank = rank; } #region GetPositionsToBeOpened private void getPositionsToBeOpened_checkParameters( TestingPositions[] bestTestingPositionsInSample ) { if ( bestTestingPositionsInSample.Length <= this.rank ) throw new Exception( "The out of sample chooser was set to " + "return the best position ranked " + this.rank + " but bestTestingPositionsInSample contains " + "just " + bestTestingPositionsInSample.Length + "elements!" ); } /// <summary> /// Selects the WeghtedPositions to actually be opened /// </summary> /// <param name="bestTestingPositionsInSample">most correlated couples, /// in sample</param> /// <param name="outOfSampleReturnIntervals">return intervals for /// the current backtest</param> /// <param name="minThreshold">min requested inefficiency</param> /// <param name="maxThreshold">max allowed inefficiency</param> /// <param name="inSampleReturnsManager"></param> /// <returns></returns> public WeightedPositions GetPositionsToBeOpened( TestingPositions[] bestTestingPositionsInSample ) { this.getPositionsToBeOpened_checkParameters( bestTestingPositionsInSample ); WeightedPositions positionsToBeOpened = bestTestingPositionsInSample[ this.rank ].WeightedPositions; return positionsToBeOpened; } #endregion GetPositionsToBeOpened } } |
|
From: Glauco S. <gla...@us...> - 2008-08-16 19:19:36
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases/OutOfSampleChoosers In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv11342/OutOfSampleChoosers Log Message: Directory /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases/OutOfSampleChoosers added to the repository |
|
From: Glauco S. <gla...@us...> - 2008-08-16 19:18:56
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases/Logging In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv9978/Logging Added Files: TesterForFLTPTestingPositions.cs Log Message: Tests a FLTPTestingPositions object --- NEW FILE: TesterForFLTPTestingPositions.cs --- /* QuantProject - Quantitative Finance Library TesterForFLTPTestingPositions.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 System.Drawing; using QuantProject.Business.DataProviders; using QuantProject.Business.Financial.Accounting.AccountProviding; using QuantProject.Business.Financial.Accounting.Reporting; using QuantProject.Business.Scripting; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Strategies.ReturnsManagement.Time.IntervalsSelectors; using QuantProject.Business.Timing; using QuantProject.Presentation.Reporting.WindowsForm; using QuantProject.Scripts.General.Reporting; namespace QuantProject.Scripts.WalkForwardTesting.FixedLengthTwoPhases { [Serializable] /// <summary> /// Tests a FLTPTestingPositions object /// </summary> public class TesterForFLTPTestingPositions : IExecutable { private FLTPTestingPositions testingPositions; private int numberOfInSampleDays; private EndOfDayDateTime endOfDayDateTimeWhenThisObjectWasLogged; /// <summary> /// Generation when the TestingPositions object has been created /// (if genetically optimized) /// </summary> public int Generation { get { return this.testingPositions.Generation; } } public double FitnessInSample { get { return this.testingPositions.FitnessInSample; } } public string ShortDescription { get { return this.testingPositions.WeightedPositions.Description; } } // public PairsTradingTestingPositions TestingPositions // { // get { return this.testingPositions; } // } public TesterForFLTPTestingPositions( TestingPositions testingPositions , int numberOfInSampleDays , EndOfDayDateTime endOfDayDateTimeWhenThisObjectWasLogged ) { this.checkParameters( testingPositions ); this.testingPositions = (FLTPTestingPositions)testingPositions; this.numberOfInSampleDays = numberOfInSampleDays; this.endOfDayDateTimeWhenThisObjectWasLogged = endOfDayDateTimeWhenThisObjectWasLogged; } private void checkParameters( TestingPositions testingPositions ) { if ( ! ( testingPositions is FLTPTestingPositions ) ) throw new Exception( "The given testingPositions is NOT a " + "FLTPTestingPositions!" ); } #region Run private AccountReport getAccountReport( WeightedPositions weightedPositions , IIntervalsSelector intervalsSelector , IHistoricalQuoteProvider historicalQuoteProvider , Benchmark benchmark , double cashToStart ) { FLTPSimpleStrategy fLTPSimpleStrategy = new FLTPSimpleStrategy( weightedPositions , intervalsSelector , historicalQuoteProvider ); IAccountProvider accountProvider = new SimpleAccountProvider(); DateTime firstDateTime = this.endOfDayDateTimeWhenThisObjectWasLogged.DateTime.AddDays( - this.numberOfInSampleDays ); DateTime lastDateTime = this.endOfDayDateTimeWhenThisObjectWasLogged.DateTime; double maxRunningHours = 0.3; EndOfDayStrategyBackTester endOfDayStrategyBackTester = new EndOfDayStrategyBackTester( "SimpleFLTP" , fLTPSimpleStrategy , historicalQuoteProvider , accountProvider , firstDateTime , lastDateTime , 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 = // new WeightedPositions( weights , tickers ); // return weightedPositions; // } public void Run() { // 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 ); // uncomment the following line if the optimization // was made on both phases intervalsSelector = new FixedLengthTwoPhasesIntervalsSelector( 1 , 1 , benchmark ); IEligiblesSelector eligiblesSelector = new DummyEligibleSelector(); WeightedPositions weightedPositions = this.testingPositions.WeightedPositions; AccountReport accountReport = this.getAccountReport( weightedPositions , intervalsSelector , historicalQuoteProvider , benchmark , 30000 ); Report report = new Report( accountReport , 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(); } #endregion Run } } |
|
From: Glauco S. <gla...@us...> - 2008-08-16 19:14:52
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases/Logging In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv3245/Logging Added Files: FLTPSimpleStrategy.cs Log Message: Strategy without optimization, that implements the Fixed Length Two Phases strategy for a given, fixed WeightedPositions object --- NEW FILE: FLTPSimpleStrategy.cs --- /* QuantProject - Quantitative Finance Library FLTPSimpleStrategy.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.DataProviders; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.InSample; using QuantProject.Business.Strategies.Logging; using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Strategies.ReturnsManagement.Time.IntervalsSelectors; using QuantProject.Scripts.General.Strategies; namespace QuantProject.Scripts.WalkForwardTesting.FixedLengthTwoPhases { /// <summary> /// Strategy without optimization, that implements the /// Fixed Length Two Phases strategy for a given, fixed /// WeightedPositions object /// </summary> public class FLTPSimpleStrategy : SimpleStrategy { public FLTPSimpleStrategy( WeightedPositions weightedPositions , IIntervalsSelector intervalsSelector , IHistoricalQuoteProvider historicalQuoteProvider ) : base( weightedPositions , intervalsSelector , historicalQuoteProvider ) { } #region getPositionsToBeOpened private bool isCurrentIntervalOddInterval() { bool isOddInterval = ( this.returnIntervals.Count % 2 == 1 ); return isOddInterval; } protected override WeightedPositions getPositionsToBeOpened() { WeightedPositions positionsToBeOpened; if ( this.isCurrentIntervalOddInterval() ) // the current interval is an odd interval (first, third, ...) positionsToBeOpened = this.weightedPositions; else // the current interval is an even interval (second, fourth, ...) positionsToBeOpened = this.weightedPositions.Opposite; return positionsToBeOpened; } #endregion getPositionsToBeOpened protected override string getTextIdentifier() { return "FLTPSmplStrtgy"; } } } |
|
From: Glauco S. <gla...@us...> - 2008-08-16 19:14:09
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases/Logging In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv2093/Logging Added Files: FLTPLogItem.cs Log Message: Log item for the Fixed Length Two Phases strategy --- NEW FILE: FLTPLogItem.cs --- /* QuantProject - Quantitative Finance Library FLTPLogItem.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.Strategies; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.InSample; using QuantProject.Business.Strategies.Logging; using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Timing; using QuantProject.Presentation; //using QuantProject.Presentation.Reporting.WindowsForm; //using QuantProject.Scripts.General.Reporting; namespace QuantProject.Scripts.WalkForwardTesting.FixedLengthTwoPhases { /// <summary> /// Log item for the Fixed Length Two Phases strategy /// </summary> [Serializable] public class FLTPLogItem : LogItem { private TesterForFLTPTestingPositions[] testersForBestTestingPositionsInSample; private int numberOfInSampleDays; private int numberOfEligibleTickers; public int NumberOfEligibleTickers { get { return this.numberOfEligibleTickers; } } /// <summary> /// Log item for the Pairs Trading strategy /// </summary> /// <param name="endOfDayDateTime"></param> /// <param name="bestTestingPositionsInSample"></param> /// <param name="numInSampleDays">number of days used for /// in sample optimization</param> /// <param name="numberOfEligibleTickers"></param> public FLTPLogItem( EndOfDayDateTime now , TestingPositions[] bestTestingPositionsInSample , int numberOfInSampleDays , int numberOfEligibleTickers ) : base( now ) { // this.bestTestingPositionsInSample = bestTestingPositionsInSample; this.numberOfInSampleDays = numberOfInSampleDays; this.numberOfEligibleTickers = numberOfEligibleTickers; this.setTestersForFLTPTestingPositions( bestTestingPositionsInSample , now ); } #region setTestersForPairstTradingTestingPositions private void setTestersForFLTPTestingPositions_checkParameters( TestingPositions testingPositions ) { if ( ! ( testingPositions is FLTPTestingPositions ) ) throw new Exception( "TestingPositions are all expected to be " + "FLTPTestingPositions. But the current TestingPositions " + "is not a FLTPTestingPositions!" ); } private void setTestersForFLTPTestingPositions( int currentIndex , TestingPositions testingPositions , EndOfDayDateTime now ) { this.setTestersForFLTPTestingPositions_checkParameters( testingPositions ); this.testersForBestTestingPositionsInSample[ currentIndex ] = new TesterForFLTPTestingPositions( testingPositions , this.numberOfInSampleDays , now ); } private void setTestersForFLTPTestingPositions( TestingPositions[] bestTestingPositionsInSample , EndOfDayDateTime now ) { this.testersForBestTestingPositionsInSample = new TesterForFLTPTestingPositions[ bestTestingPositionsInSample.Length ]; for ( int i = 0 ; i < bestTestingPositionsInSample.Length ; i++ ) this.setTestersForFLTPTestingPositions( i , bestTestingPositionsInSample[ i ] , now ); } #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() { QuantProject.Presentation.ExecutablesListViewer executablesListViewer = new ExecutablesListViewer( this.testersForBestTestingPositionsInSample ); executablesListViewer.Show(); } } } |
|
From: Glauco S. <gla...@us...> - 2008-08-16 19:13:14
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv1266 Removed Files: FixedLengthTwoPhasesLogItem.cs Log Message: It has been replaced by the class FLTPLogItem --- FixedLengthTwoPhasesLogItem.cs DELETED --- |
|
From: Glauco S. <gla...@us...> - 2008-08-16 19:13:12
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases/Logging In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv1266/Logging Removed Files: FixedLengthTwoPhasesLogItem.cs Log Message: It has been replaced by the class FLTPLogItem --- FixedLengthTwoPhasesLogItem.cs DELETED --- |
|
From: Glauco S. <gla...@us...> - 2008-08-16 19:10:06
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases/InSampleChoosers/Decoding In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv28903 Added Files: DecoderForFLTPTestingPositionsWithBalancedWeights.cs Log Message: Decoder for the Fixed Length Two Phases strategy --- NEW FILE: DecoderForFLTPTestingPositionsWithBalancedWeights.cs --- /* QuantProject - Quantitative Finance Library DecoderForFLTPTestingPositionsWithBalancedWeights.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.Strategies; using QuantProject.Business.Strategies.Optimizing.Decoding; using QuantProject.Business.Strategies.OutOfSample; namespace QuantProject.Scripts.WalkForwardTesting.FixedLengthTwoPhases { /// <summary> /// Decoder for the Fixed Length Two Phases strategy /// </summary> public class DecoderForFLTPTestingPositionsWithBalancedWeights : DecoderForTestingPositionsWithBalancedWeights { public DecoderForFLTPTestingPositionsWithBalancedWeights() { } protected override TestingPositions getMeaningForUndecodable() { return new FLTPTestingPositions(); } protected override TestingPositions getTestingPositions(double[] weights, string[] tickers) { WeightedPositions weightedPositions = new WeightedPositions( weights , tickers ); FLTPTestingPositions fLTPTestingPositions = new FLTPTestingPositions( weightedPositions ); return fLTPTestingPositions; } } } |
|
From: Glauco S. <gla...@us...> - 2008-08-16 19:09:38
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases/InSampleChoosers/Decoding In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv28439/Decoding Log Message: Directory /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases/InSampleChoosers/Decoding added to the repository |