quantproject-developers Mailing List for QuantProject (Page 40)
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-16 19:08:06
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv26057 Added Files: FLTPTestingPositions.cs Log Message: TestingPositions for the Fixed Length Two Phases strategy --- NEW FILE: FLTPTestingPositions.cs --- /* QuantProject - Quantitative Finance Library FLTPTestingPositions.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.OutOfSample; namespace QuantProject.Scripts.WalkForwardTesting.FixedLengthTwoPhases { /// <summary> /// TestingPositions for the Fixed Length Two Phases strategy /// </summary> [Serializable] public class FLTPTestingPositions : TestingPositions , IGeneticallyOptimizable { private int generation; public int Generation { get { return this.generation; } set { this.generation = value; } } // creates an empty TestingPositions: to be used to give a meaning with // FLTPTestingPositions type to undecodables public FLTPTestingPositions() : base() { } public FLTPTestingPositions( WeightedPositions weightedPositions ) : base( weightedPositions ) { this.generation = -999; } } } |
|
From: Glauco S. <gla...@us...> - 2008-08-16 19:06:20
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/General/Strategies In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv24050 Added Files: SimpleStrategy.cs Log Message: Strategy without optimization, that opens positions when a new interval begins and closes positions when the interval ends --- NEW FILE: SimpleStrategy.cs --- /* QuantProject - Quantitative Finance Library SimpleStrategy.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; namespace QuantProject.Scripts.General.Strategies { /// <summary> /// Strategy without optimization, that opens positions when a new /// interval begins and closes positions when the interval ends /// </summary> public class SimpleStrategy : SymmetricEndOfDayStrategyForBacktester { protected WeightedPositions weightedPositions; public SimpleStrategy( WeightedPositions weightedPositions , IIntervalsSelector intervalsSelector , IHistoricalQuoteProvider historicalQuoteProvider ) : base( 999 , 1 , intervalsSelector , intervalsSelector , new DummyEligibleSelector() , new DummyInSampleChooser() , historicalQuoteProvider ) { this.weightedPositions = weightedPositions; } protected override bool arePositionsToBeClosed() { // true iif the current EndOfDayDateTime falls on the end of either the last // interval or the second last interval bool arePositionsToBeClosed = ( ( this.Account.Portfolio.Count > 0 ) && ( this.returnIntervals[ this.returnIntervals.Count - 1 ].End.IsEqualTo( this.now() ) || ( ( this.returnIntervals.Count > 1 ) && ( this.returnIntervals[ this.returnIntervals.Count - 2 ].End.IsEqualTo( this.now() ) ) ) ) ); return arePositionsToBeClosed; } // protected override bool marketCloseEventHandler_arePositionsToBeClosed() // { // return this.marketOpenEventHandler_arePositionsToBeClosed(); // } protected override bool arePositionsToBeOpened() { // true iif the current EndOfDayDateTime falls on the begin of the last // interval bool arePositionsToBeOpened = ( ( this.Account.Portfolio.Count == 0 ) && this.returnIntervals[ this.returnIntervals.Count - 1 ].Begin.IsEqualTo( this.now() ) ); return arePositionsToBeOpened; } // protected override bool marketCloseEventHandler_arePositionsToBeOpened() // { // return this.marketOpenEventHandler_arePositionsToBeOpened(); // } protected override WeightedPositions getPositionsToBeOpened() { return this.weightedPositions; } // protected override // WeightedPositions marketCloseEventHandler_getPositionsToBeOpened() // { // return this.marketOpenEventHandler_getPositionsToBeOpened(); // } protected override LogItem getLogItem( EligibleTickers eligibleTickers ) { DummyLogItem logItem = new DummyLogItem( this.now() ); return logItem; } protected override string getTextIdentifier() { return "SmplStrtgy"; } } } |
|
From: Glauco S. <gla...@us...> - 2008-08-16 19:05:28
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/General/Strategies In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv22806/Strategies Log Message: Directory /cvsroot/quantproject/QuantProject/b7_Scripts/General/Strategies added to the repository |
|
From: Glauco S. <gla...@us...> - 2008-08-16 19:03:33
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases/InSampleChoosers/Genetic In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv19076 Removed Files: FixedLengthTwoPhasesGenomeManager.cs Log Message: The generic GenomeManagerWithDuplicateGenes is used, now --- FixedLengthTwoPhasesGenomeManager.cs DELETED --- |
|
From: Marco M. <mi...@us...> - 2008-08-15 04:53:07
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv17557/b4_Business/a2_Strategies/returnsManagement/time Modified Files: IntervalsType.cs Log Message: Changed names for the enumerations Index: IntervalsType.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time/IntervalsType.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IntervalsType.cs 25 Apr 2008 17:24:04 -0000 1.1 --- IntervalsType.cs 14 Aug 2008 23:24:35 -0000 1.2 *************** *** 31,39 **** public enum IntervalsType { ! CloseToCloseIntervals_OneDay, ! CloseToCloseIntervals_TwoDays, ! CloseToCloseIntervals_FiveDays, ! CloseToOpenIntervals, ! DailyOpenToCloseIntervals, OpenToCloseCloseToOpenIntervals } --- 31,38 ---- public enum IntervalsType { ! OpenToOpenIntervals, ! CloseToCloseIntervals, ! CloseToOpenIntervals, ! OpenToCloseIntervals, OpenToCloseCloseToOpenIntervals } |
|
From: Marco M. <mi...@us...> - 2008-08-15 04:53:05
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv17993/b7_Scripts/WalkForwardTesting/LinearCombination Modified Files: MainForm.cs Log Message: Fixed minor bug Index: MainForm.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination/MainForm.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** MainForm.cs 14 Jan 2008 23:41:44 -0000 1.11 --- MainForm.cs 14 Aug 2008 23:25:19 -0000 1.12 *************** *** 86,90 **** this.portfolioType = portfolioType; } ! /// <summary> /// Clean up any resources being used. --- 86,97 ---- this.portfolioType = portfolioType; } ! public MainForm() ! { ! // ! // Required for Windows Form Designer support ! // ! InitializeComponent(); ! } ! /// <summary> /// Clean up any resources being used. *************** *** 268,272 **** this.optimizationOutput = (OptimizationOutput)visualObjectArchiver.Load( ! "Load best genomes" , "bgn" , "Load Genomes"); if ( this.optimizationOutput.Count == 0 ) throw new Exception( "The loaded optimization output contains no element!" ); --- 275,279 ---- this.optimizationOutput = (OptimizationOutput)visualObjectArchiver.Load( ! "bgn", "Load best genomes" , "Load Genomes"); if ( this.optimizationOutput.Count == 0 ) throw new Exception( "The loaded optimization output contains no element!" ); |
|
From: Marco M. <mi...@us...> - 2008-08-15 04:53:05
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv19183/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator Modified Files: PVO_OTCLogItem.cs PVO_OTCMain.cs PVO_OTCStrategy.cs PVO_OTCStrategyLessCorrelated.cs PVOLogItem.cs PVOMain.cs PVOPositions.cs PVOPositionsStatus.cs PVOStrategy.cs Log Message: Minor changes for the some files implementing the PVO strategy Index: PVOStrategy.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/PVOStrategy.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PVOStrategy.cs 8 Apr 2008 21:59:09 -0000 1.4 --- PVOStrategy.cs 14 Aug 2008 23:28:06 -0000 1.5 *************** *** 92,96 **** protected double currentAccountValue; protected double previousAccountValue; ! private string description_GetDescriptionForChooser() { --- 92,100 ---- protected double currentAccountValue; protected double previousAccountValue; ! protected double oversoldThreshold; ! protected double overboughtThreshold; ! protected double oversoldThresholdMAX; ! protected double overboughtThresholdMAX; ! private string description_GetDescriptionForChooser() { *************** *** 129,132 **** --- 133,140 ---- Benchmark benchmark, int numDaysBetweenEachOptimization, + double oversoldThreshold, + double overboughtThreshold, + double oversoldThresholdMAX, + double overboughtThresholdMAX, HistoricalQuoteProvider historicalQuoteProvider, double maxAcceptableCloseToCloseDrawdown, *************** *** 142,146 **** this.maxAcceptableCloseToCloseDrawdown = maxAcceptableCloseToCloseDrawdown; this.minimumAcceptableGain = minimumAcceptableGain; ! this.stopLossConditionReached = false; this.currentAccountValue = 0.0; --- 150,157 ---- this.maxAcceptableCloseToCloseDrawdown = maxAcceptableCloseToCloseDrawdown; this.minimumAcceptableGain = minimumAcceptableGain; ! this.oversoldThreshold = oversoldThreshold; ! this.overboughtThreshold = overboughtThreshold; ! this.oversoldThresholdMAX = oversoldThresholdMAX; ! this.overboughtThresholdMAX = overboughtThresholdMAX; this.stopLossConditionReached = false; this.currentAccountValue = 0.0; *************** *** 157,160 **** --- 168,175 ---- Benchmark benchmark, int numDaysBetweenEachOptimization, + double oversoldThreshold, + double overboughtThreshold, + double oversoldThresholdMAX, + double overboughtThresholdMAX, HistoricalQuoteProvider historicalQuoteProvider, double maxAcceptableCloseToCloseDrawdown, *************** *** 164,167 **** --- 179,184 ---- this.pvoStrategy(eligiblesSelector, inSampleDays , numDaysForOscillatingPeriod , numberOfTickersToBeChosen , benchmark , numDaysBetweenEachOptimization , + oversoldThreshold, overboughtThreshold, + oversoldThresholdMAX, overboughtThresholdMAX, historicalQuoteProvider , maxAcceptableCloseToCloseDrawdown , minimumAcceptableGain ); *************** *** 170,173 **** --- 187,213 ---- public PVOStrategy(IEligiblesSelector eligiblesSelector, + IInSampleChooser inSampleChooser, + int inSampleDays, + int numDaysForOscillatingPeriod, + int numberOfTickersToBeChosen, + Benchmark benchmark, + int numDaysBetweenEachOptimization, + double oversoldThreshold, + double overboughtThreshold, + HistoricalQuoteProvider historicalQuoteProvider, + double maxAcceptableCloseToCloseDrawdown, + double minimumAcceptableGain) + + { + this.pvoStrategy(eligiblesSelector, inSampleDays , numDaysForOscillatingPeriod , + numberOfTickersToBeChosen , benchmark , numDaysBetweenEachOptimization , + oversoldThreshold, overboughtThreshold, + double.MaxValue, double.MaxValue, + historicalQuoteProvider , maxAcceptableCloseToCloseDrawdown , + minimumAcceptableGain ); + this.inSampleChooser = inSampleChooser; + } + + public PVOStrategy(IEligiblesSelector eligiblesSelector, TestingPositions[] chosenPVOPositions, int inSampleDays, *************** *** 176,179 **** --- 216,223 ---- Benchmark benchmark, int numDaysBetweenEachOptimization, + double oversoldThreshold, + double overboughtThreshold, + double oversoldThresholdMAX, + double overboughtThresholdMAX, HistoricalQuoteProvider historicalQuoteProvider, double maxAcceptableCloseToCloseDrawdown, *************** *** 183,186 **** --- 227,255 ---- this.pvoStrategy(eligiblesSelector, inSampleDays , numDaysForOscillatingPeriod , numberOfTickersToBeChosen , benchmark , numDaysBetweenEachOptimization , + oversoldThreshold, overboughtThreshold, + oversoldThresholdMAX, overboughtThresholdMAX, + historicalQuoteProvider , maxAcceptableCloseToCloseDrawdown , + minimumAcceptableGain ); + this.chosenPVOPositions = chosenPVOPositions; + } + + public PVOStrategy(IEligiblesSelector eligiblesSelector, + TestingPositions[] chosenPVOPositions, + int inSampleDays, + int numDaysForOscillatingPeriod, + int numberOfTickersToBeChosen, + Benchmark benchmark, + int numDaysBetweenEachOptimization, + double oversoldThreshold, + double overboughtThreshold, + HistoricalQuoteProvider historicalQuoteProvider, + double maxAcceptableCloseToCloseDrawdown, + double minimumAcceptableGain) + + { + this.pvoStrategy(eligiblesSelector, inSampleDays , numDaysForOscillatingPeriod , + numberOfTickersToBeChosen , benchmark , numDaysBetweenEachOptimization , + oversoldThreshold, overboughtThreshold, + double.MaxValue , double.MaxValue , historicalQuoteProvider , maxAcceptableCloseToCloseDrawdown , minimumAcceptableGain ); *************** *** 233,237 **** EndOfDayDateTime beginOfOscillatingPeriod = this.getBeginOfOscillatingPeriod(timer); PVOPositionsStatus pvoPositionsStatus = ! this.pvoPositionsForOutOfSample.GetStatus(beginOfOscillatingPeriod, today , this.benchmark.Ticker, this.historicalQuoteProvider); if(pvoPositionsStatus == PVOPositionsStatus.Overbought && this.portfolioHasBeenOversold) --- 302,307 ---- EndOfDayDateTime beginOfOscillatingPeriod = this.getBeginOfOscillatingPeriod(timer); PVOPositionsStatus pvoPositionsStatus = ! this.pvoPositionsForOutOfSample.GetStatus(beginOfOscillatingPeriod, today , this.benchmark.Ticker, this.historicalQuoteProvider, ! double.MaxValue, double.MaxValue); if(pvoPositionsStatus == PVOPositionsStatus.Overbought && this.portfolioHasBeenOversold) *************** *** 258,262 **** currentStatus = ((PVOPositions)this.chosenPVOPositions[i]).GetStatus(beginOfOscillatingPeriod, today, ! this.benchmark.Ticker, this.historicalQuoteProvider); if(currentStatus == PVOPositionsStatus.Oversold || currentStatus == PVOPositionsStatus.Overbought ) --- 328,333 ---- currentStatus = ((PVOPositions)this.chosenPVOPositions[i]).GetStatus(beginOfOscillatingPeriod, today, ! this.benchmark.Ticker, this.historicalQuoteProvider, ! double.MaxValue, double.MaxValue); if(currentStatus == PVOPositionsStatus.Oversold || currentStatus == PVOPositionsStatus.Overbought ) *************** *** 363,367 **** try{ this.marketCloseEventHandler_updateStopLossAndTakeProfitConditions(); ! this.marketCloseEventHandler_closePositionsIfNeeded(); if( this.chosenPVOPositions != null ) //PVOPositions have been chosen by the chooser --- 434,438 ---- try{ this.marketCloseEventHandler_updateStopLossAndTakeProfitConditions(); ! //this.marketCloseEventHandler_closePositionsIfNeeded(); if( this.chosenPVOPositions != null ) //PVOPositions have been chosen by the chooser *************** *** 371,375 **** //positions are opened only if thresholds are reached else//there are some opened positions ! this.marketCloseEventHandler_reverseIfNeeded((IndexBasedEndOfDayTimer)sender); } } --- 442,447 ---- //positions are opened only if thresholds are reached else//there are some opened positions ! this.marketCloseEventHandler_closePositionsIfNeeded(); ! //this.marketCloseEventHandler_reverseIfNeeded((IndexBasedEndOfDayTimer)sender); } } *************** *** 436,439 **** --- 508,521 ---- this.NewMessage( this , newMessageEventArgs ); } + private void updateTestingPositions_updateThresholds() + { + for(int i = 0; i<this.chosenPVOPositions.Length; i++) + { + ((PVOPositions)this.chosenPVOPositions[i]).OversoldThreshold = + this.oversoldThreshold; + ((PVOPositions)this.chosenPVOPositions[i]).OverboughtThreshold = + this.overboughtThreshold; + } + } private void logOptimizationInfo( EligibleTickers eligibleTickers ) { *************** *** 456,459 **** --- 538,542 ---- if(this.inSampleChooser != null) this.chosenPVOPositions = (TestingPositions[])inSampleChooser.AnalyzeInSample(eligibles, this.returnsManager ); + this.updateTestingPositions_updateThresholds(); this.logOptimizationInfo(eligibles); } Index: PVO_OTCLogItem.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/PVO_OTCLogItem.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PVO_OTCLogItem.cs 26 Apr 2008 09:52:44 -0000 1.3 --- PVO_OTCLogItem.cs 14 Aug 2008 23:28:06 -0000 1.4 *************** *** 84,88 **** positionsToTest = this.bestPVOPositionsInSample; PVO_OTCStrategy strategy = ! new PVO_OTCStrategy(eligiblesSelector, positionsToTest, inSampleDays, benchmark , --- 84,88 ---- positionsToTest = this.bestPVOPositionsInSample; PVO_OTCStrategy strategy = ! new PVO_OTCStrategy(eligiblesSelector, 1, positionsToTest, inSampleDays, benchmark , Index: PVO_OTCMain.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/PVO_OTCMain.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PVO_OTCMain.cs 26 Apr 2008 09:53:54 -0000 1.5 --- PVO_OTCMain.cs 14 Aug 2008 23:28:06 -0000 1.6 *************** *** 63,67 **** public PVO_OTCMain() { ! this.benchmark = new Benchmark( "BMC" ); this.historicalQuoteProvider = --- 63,67 ---- public PVO_OTCMain() { ! this.benchmark = new Benchmark( "^GSPC" ); this.historicalQuoteProvider = *************** *** 74,87 **** protected override IEligiblesSelector getEligiblesSelector() { - int maxNumberOfEligiblesToBeChosen = 100; string tickersGroupId = "SP500"; - // uncomment the following line for a faster script - //tickersGroupId = "fastTest"; - - // this.eligiblesSelector = - // new MostLiquidAndLessVolatile( - // tickersGroupId , - // maxNumberOfEligiblesToBeChosen ); bool temporizedGroup = true; --- 74,81 ---- protected override IEligiblesSelector getEligiblesSelector() { + int maxNumberOfEligiblesToBeChosen = 100; + string tickersGroupId = "SP500"; bool temporizedGroup = true; *************** *** 90,93 **** --- 84,97 ---- double maxPrice = 75; + int maxNumberOfMostLiquidTickersToBeChosen = 150; + int numDaysForVolatility = 10; + IEligiblesSelector eligiblesSelector = + new ByPriceMostLiquidLessVolatileOTCAlwaysQuoted( + tickersGroupId , temporizedGroup , + maxNumberOfEligiblesToBeChosen , + maxNumberOfMostLiquidTickersToBeChosen , + numDaysForAverageRawOpenPriceComputation , + numDaysForVolatility , + minPrice , maxPrice ); // IEligiblesSelector eligiblesSelector = // new ByPriceMostLiquidAlwaysQuoted( *************** *** 96,108 **** // numDaysForAverageRawOpenPriceComputation , // minPrice , maxPrice ); ! IEligiblesSelector eligiblesSelector = ! new ByPriceLessVolatileOTCAlwaysQuoted( ! tickersGroupId , temporizedGroup , ! maxNumberOfEligiblesToBeChosen , ! numDaysForAverageRawOpenPriceComputation , ! minPrice , maxPrice ); // eligiblesSelector = // new DummyEligibleSelector(); ! return eligiblesSelector; } --- 100,112 ---- // numDaysForAverageRawOpenPriceComputation , // minPrice , maxPrice ); ! // IEligiblesSelector eligiblesSelector = ! // new ByPriceLessVolatileOTCAlwaysQuoted( ! // tickersGroupId , temporizedGroup , ! // maxNumberOfEligiblesToBeChosen , ! // numDaysForAverageRawOpenPriceComputation , ! // minPrice , maxPrice ); // eligiblesSelector = // new DummyEligibleSelector(); ! // return eligiblesSelector; } *************** *** 123,128 **** double maxCorrelationAllowed = 0.96; ! int numberOfBestTestingPositionsToBeReturned = 200; ! numberOfBestTestingPositionsToBeReturned = 200; bool balancedWeightsOnVolatilityBase = true; float minimumAbsoluteReturnValue = 0.000001f; --- 127,132 ---- double maxCorrelationAllowed = 0.96; ! int numberOfBestTestingPositionsToBeReturned = 100; ! numberOfBestTestingPositionsToBeReturned = 100; bool balancedWeightsOnVolatilityBase = true; float minimumAbsoluteReturnValue = 0.000001f; *************** *** 130,150 **** //correlation is computed only for returns //between minimum and maximum - IInSampleChooser inSampleChooser = - new PVO_OTCCorrelationChooser(numberOfBestTestingPositionsToBeReturned, - maxCorrelationAllowed , balancedWeightsOnVolatilityBase, - minimumAbsoluteReturnValue , maximumAbsoluteReturnValue); // IInSampleChooser inSampleChooser = ! // new PVO_OTCCTOCorrelationChooser(numberOfBestTestingPositionsToBeReturned, // maxCorrelationAllowed , balancedWeightsOnVolatilityBase, ! // minimumAbsoluteReturnValue , maximumAbsoluteReturnValue); // //office // inSampleChooser = // new PVOChooserFromSavedBackTestLog( ! // @"C:\Utente\MarcoVarie\Vari\qP\LogArchive\2008_04_14_18_21_45_PVO_OTC_from_2001_01_01_to_2004_12_31_annlRtrn_182,80_maxDD_8,57\2008_04_14_18_21_45_PVO_OTC_from_2001_01_01_to_2004_12_31_annlRtrn_182,80_maxDD_8,57.qpL", // numberOfBestTestingPositionsToBeReturned); //home // inSampleChooser = // new PVOChooserFromSavedBackTestLog( ! // @"C:\Utente\MarcoVarie\Vari\qP\LogArchive\2008_04_13_12_03_16_PVO_OTC_from_2001_01_01_to_2004_12_31_annlRtrn_183.39_maxDD_8.71\2008_04_13_12_03_16_PVO_OTC_from_2001_01_01_to_2004_12_31_annlRtrn_183.39_maxDD_8.71.qpL", // numberOfBestTestingPositionsToBeReturned); return inSampleChooser; --- 134,154 ---- //correlation is computed only for returns //between minimum and maximum // IInSampleChooser inSampleChooser = ! // new PVO_OTCCorrelationChooser(numberOfBestTestingPositionsToBeReturned, // maxCorrelationAllowed , balancedWeightsOnVolatilityBase, ! // minimumAbsoluteReturnValue , maximumAbsoluteReturnValue, this.benchmark.Ticker); ! IInSampleChooser inSampleChooser = ! new PVO_OTCCTOCorrelationChooser(numberOfBestTestingPositionsToBeReturned, ! maxCorrelationAllowed , balancedWeightsOnVolatilityBase, ! minimumAbsoluteReturnValue , maximumAbsoluteReturnValue, this.benchmark.Ticker); // //office // inSampleChooser = // new PVOChooserFromSavedBackTestLog( ! // @"C:\Utente\MarcoVarie\Vari\qP\LogArchive\2008_08_06_16_57_34_PVO_OTC_from_2003_06_01_to_2008_04_28_annlRtrn_3,34_maxDD_11,36\2008_08_06_16_57_34_PVO_OTC_from_2003_06_01_to_2008_04_28_annlRtrn_3,34_maxDD_11,36.qpL", // numberOfBestTestingPositionsToBeReturned); //home // inSampleChooser = // new PVOChooserFromSavedBackTestLog( ! // @"C:\Utente\MarcoVarie\Vari\qP\LogArchive\2008_05_04_18_54_45_PVO_OTC_from_2006_01_01_to_2008_04_28_annlRtrn_93.08_maxDD_5.18\2008_05_04_18_54_45_PVO_OTC_from_2006_01_01_to_2008_04_28_annlRtrn_93.08_maxDD_5.18.qpL", // numberOfBestTestingPositionsToBeReturned); return inSampleChooser; *************** *** 153,163 **** protected override IEndOfDayStrategyForBacktester getEndOfDayStrategy() { ! int inSampleDays = 180; // uncomment the following line for a faster script //inSampleDays = 50; ! int numDaysBetweenEachOptimization = 5; int numOfClosingsBeforeExit = 0; ! double oversoldThreshold = 0.01; ! double overboughtThreshold = 0.01; IEndOfDayStrategyForBacktester endOfDayStrategy // = new PVO_OTCStrategyLessCorrelated(eligiblesSelector ,inSampleChooser , --- 157,170 ---- protected override IEndOfDayStrategyForBacktester getEndOfDayStrategy() { ! int inSampleDays = 25; // uncomment the following line for a faster script //inSampleDays = 50; ! int numDaysBetweenEachOptimization = 1; int numOfClosingsBeforeExit = 0; ! int minNumOfEligiblesForValidOptimization = 20; ! double oversoldThreshold = 0.0025; ! double overboughtThreshold = 0.0025; ! double oversoldThresholdMAX = 0.05; ! double overboughtThresholdMAX = 0.05; IEndOfDayStrategyForBacktester endOfDayStrategy // = new PVO_OTCStrategyLessCorrelated(eligiblesSelector ,inSampleChooser , *************** *** 165,171 **** // oversoldThreshold , overboughtThreshold , historicalQuoteProvider); // ! = new PVO_OTCStrategy(eligiblesSelector ,inSampleChooser , inSampleDays , benchmark , numDaysBetweenEachOptimization , ! numOfClosingsBeforeExit, oversoldThreshold , overboughtThreshold , historicalQuoteProvider); return endOfDayStrategy; } --- 172,180 ---- // oversoldThreshold , overboughtThreshold , historicalQuoteProvider); // ! = new PVO_OTCStrategy(eligiblesSelector , ! minNumOfEligiblesForValidOptimization, inSampleChooser , inSampleDays , benchmark , numDaysBetweenEachOptimization , ! numOfClosingsBeforeExit, oversoldThreshold , overboughtThreshold , ! oversoldThresholdMAX , overboughtThresholdMAX , historicalQuoteProvider); return endOfDayStrategy; } *************** *** 173,181 **** { string backTestId = "PVO_OTC"; ! IAccountProvider accountProvider = new SimpleAccountProvider(); ! double cashToStart = 30000; ! DateTime firstDateTime = new DateTime( 2001 , 1 , 1 ); ! DateTime lastDateTime = new DateTime( 2004 , 12, 31 ); double maxRunningHours = 10; HistoricalQuoteProvider quoteProviderForBackTester = --- 182,194 ---- { string backTestId = "PVO_OTC"; ! IAccountProvider accountProvider; ! accountProvider = new SimpleAccountProvider(); ! // double fixedPercentageSlippage = 0.05; ! // accountProvider = ! // new InteractiveBrokerAccountProvider(fixedPercentageSlippage); ! double cashToStart = 25000; ! DateTime firstDateTime = new DateTime( 2004 , 1 , 1 ); ! DateTime lastDateTime = new DateTime( 2008 , 4, 28 ); double maxRunningHours = 10; HistoricalQuoteProvider quoteProviderForBackTester = Index: PVOLogItem.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/PVOLogItem.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PVOLogItem.cs 8 Apr 2008 21:55:33 -0000 1.3 --- PVOLogItem.cs 14 Aug 2008 23:28:06 -0000 1.4 *************** *** 191,194 **** --- 191,196 ---- numberOfPortfolioPositions , benchmark , int.MaxValue , + ((PVOPositions)positionsToTest[0]).OversoldThreshold, + ((PVOPositions)positionsToTest[0]).OverboughtThreshold, historicalQuoteProviderForStrategy , maxAcceptableCloseToCloseDrawdown , minimumAcceptableGain ); Index: PVOPositionsStatus.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/PVOPositionsStatus.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PVOPositionsStatus.cs 9 Mar 2008 22:49:24 -0000 1.1 --- PVOPositionsStatus.cs 14 Aug 2008 23:28:06 -0000 1.2 *************** *** 35,39 **** InTheMiddle, Overbought, ! TooDistantFromThresholds } } --- 35,39 ---- InTheMiddle, Overbought, ! OverMaximumThresholds } } Index: PVO_OTCStrategy.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/PVO_OTCStrategy.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PVO_OTCStrategy.cs 26 Apr 2008 09:51:23 -0000 1.4 --- PVO_OTCStrategy.cs 14 Aug 2008 23:28:06 -0000 1.5 *************** *** 71,74 **** --- 71,76 ---- protected double oversoldThreshold; protected double overboughtThreshold; + protected double oversoldThresholdMAX; + protected double overboughtThresholdMAX; //initialized after constructor's call protected int numDaysElapsedSinceLastOptimization; *************** *** 88,91 **** --- 90,95 ---- private int numOfClosingsToCrossBeforeExit; private int numOfClosingsWithOpenPositions; + private int minimumNumberOfEligiblesForValidOptimization; + private bool optimalPositionsHaveBeenUpdated; private string description_GetDescriptionForChooser() *************** *** 123,127 **** private void pvo_otcStrategy(IEligiblesSelector eligiblesSelector, ! int inSampleDays, Benchmark benchmark, int numDaysBetweenEachOptimization, --- 127,132 ---- private void pvo_otcStrategy(IEligiblesSelector eligiblesSelector, ! int minimumNumberOfEligiblesForValidOptimization, ! int inSampleDays, Benchmark benchmark, int numDaysBetweenEachOptimization, *************** *** 129,136 **** --- 134,145 ---- double oversoldThreshold, double overboughtThreshold, + double oversoldThresholdMAX, + double overboughtThresholdMAX, HistoricalQuoteProvider historicalQuoteProvider) { this.numOfClosingsWithOpenPositions = 0; this.eligiblesSelector = eligiblesSelector; + this.minimumNumberOfEligiblesForValidOptimization = + minimumNumberOfEligiblesForValidOptimization; this.inSampleDays = inSampleDays; this.benchmark = benchmark; *************** *** 139,146 **** --- 148,159 ---- this.oversoldThreshold = oversoldThreshold; this.overboughtThreshold = overboughtThreshold; + this.oversoldThresholdMAX = oversoldThresholdMAX; + this.overboughtThresholdMAX = overboughtThresholdMAX; this.historicalQuoteProvider = historicalQuoteProvider; + this.optimalPositionsHaveBeenUpdated = false; } public PVO_OTCStrategy(IEligiblesSelector eligiblesSelector, + int minimumNumberOfEligiblesForValidOptimization, IInSampleChooser inSampleChooser, int inSampleDays, *************** *** 150,163 **** double oversoldThreshold, double overboughtThreshold, HistoricalQuoteProvider historicalQuoteProvider) { ! this.pvo_otcStrategy(eligiblesSelector, inSampleDays , benchmark , numDaysBetweenEachOptimization , numOfClosingsToCrossBeforeExit, oversoldThreshold, overboughtThreshold, historicalQuoteProvider); this.inSampleChooser = inSampleChooser; } - public PVO_OTCStrategy(IEligiblesSelector eligiblesSelector, TestingPositions[] chosenPVOPositions, int inSampleDays, --- 163,200 ---- double oversoldThreshold, double overboughtThreshold, + double oversoldThresholdMAX, + double overboughtThresholdMAX, HistoricalQuoteProvider historicalQuoteProvider) { ! this.pvo_otcStrategy(eligiblesSelector, minimumNumberOfEligiblesForValidOptimization, ! inSampleDays , benchmark , numDaysBetweenEachOptimization , numOfClosingsToCrossBeforeExit, oversoldThreshold, overboughtThreshold, + oversoldThresholdMAX, overboughtThresholdMAX, + historicalQuoteProvider); + this.inSampleChooser = inSampleChooser; + } + + public PVO_OTCStrategy(IEligiblesSelector eligiblesSelector, + int minimumNumberOfEligiblesForValidOptimization, + IInSampleChooser inSampleChooser, + int inSampleDays, + Benchmark benchmark, + int numDaysBetweenEachOptimization, + int numOfClosingsToCrossBeforeExit, + double oversoldThreshold, + double overboughtThreshold, + HistoricalQuoteProvider historicalQuoteProvider) + + { + this.pvo_otcStrategy(eligiblesSelector, minimumNumberOfEligiblesForValidOptimization, + inSampleDays , benchmark , numDaysBetweenEachOptimization , + numOfClosingsToCrossBeforeExit, oversoldThreshold, overboughtThreshold, + double.MaxValue, double.MaxValue, historicalQuoteProvider); this.inSampleChooser = inSampleChooser; } public PVO_OTCStrategy(IEligiblesSelector eligiblesSelector, + int minimumNumberOfEligiblesForValidOptimization, TestingPositions[] chosenPVOPositions, int inSampleDays, *************** *** 167,177 **** double oversoldThreshold, double overboughtThreshold, HistoricalQuoteProvider historicalQuoteProvider) { ! this.pvo_otcStrategy(eligiblesSelector, inSampleDays , benchmark , numDaysBetweenEachOptimization , ! numOfClosingsToCrossBeforeExit, oversoldThreshold, overboughtThreshold, historicalQuoteProvider); this.chosenPVOPositions = chosenPVOPositions; } #region MarketOpenEventHandler --- 204,241 ---- double oversoldThreshold, double overboughtThreshold, + double oversoldThresholdMAX, + double overboughtThresholdMAX, HistoricalQuoteProvider historicalQuoteProvider) { ! this.pvo_otcStrategy(eligiblesSelector, minimumNumberOfEligiblesForValidOptimization, ! inSampleDays , benchmark , numDaysBetweenEachOptimization , ! numOfClosingsToCrossBeforeExit, ! oversoldThreshold, overboughtThreshold, ! oversoldThresholdMAX, overboughtThresholdMAX, ! historicalQuoteProvider); this.chosenPVOPositions = chosenPVOPositions; } + public PVO_OTCStrategy(IEligiblesSelector eligiblesSelector, + int minimumNumberOfEligiblesForValidOptimization, + TestingPositions[] chosenPVOPositions, + int inSampleDays, + Benchmark benchmark, + int numDaysBetweenEachOptimization, + int numOfClosingsToCrossBeforeExit, + double oversoldThreshold, + double overboughtThreshold, + HistoricalQuoteProvider historicalQuoteProvider) + + { + this.pvo_otcStrategy(eligiblesSelector, minimumNumberOfEligiblesForValidOptimization, + inSampleDays , benchmark , numDaysBetweenEachOptimization , + numOfClosingsToCrossBeforeExit, + oversoldThreshold, overboughtThreshold, + double.MaxValue, double.MaxValue, + historicalQuoteProvider); + this.chosenPVOPositions = chosenPVOPositions; + } + #region MarketOpenEventHandler *************** *** 195,199 **** currentStatus = ((PVOPositions)this.chosenPVOPositions[i]).GetStatus(beginOfOscillatingPeriod, today, ! this.benchmark.Ticker, this.historicalQuoteProvider); if(currentStatus == PVOPositionsStatus.Oversold || currentStatus == PVOPositionsStatus.Overbought ) --- 259,264 ---- currentStatus = ((PVOPositions)this.chosenPVOPositions[i]).GetStatus(beginOfOscillatingPeriod, today, ! this.benchmark.Ticker, this.historicalQuoteProvider, ! this.oversoldThresholdMAX, this.overboughtThresholdMAX); if(currentStatus == PVOPositionsStatus.Oversold || currentStatus == PVOPositionsStatus.Overbought ) *************** *** 257,263 **** { if ( this.account.Portfolio.Count == 0 && ! this.chosenPVOPositions != null ) //portfolio is empty and optimization has ! //been already launched { try{ --- 322,329 ---- { if ( this.account.Portfolio.Count == 0 && ! this.chosenPVOPositions != null && ! this.optimalPositionsHaveBeenUpdated == true) //portfolio is empty and optimization has ! //been already successfully launched { try{ *************** *** 308,322 **** switch ( ((PVOCorrelationChooser)this.inSampleChooser).IntervalsType ) { ! case IntervalsType.CloseToCloseIntervals_OneDay: ! returnIntervals = new CloseToCloseIntervals(firstEndOfDayDateTime, lastEndOfDayDateTime, ! this.benchmark.Ticker, 1); ! break; ! case IntervalsType.CloseToCloseIntervals_TwoDays: returnIntervals = new CloseToCloseIntervals(firstEndOfDayDateTime, lastEndOfDayDateTime, ! this.benchmark.Ticker, 2); break; ! case IntervalsType.CloseToCloseIntervals_FiveDays: ! returnIntervals = new CloseToCloseIntervals(firstEndOfDayDateTime, lastEndOfDayDateTime, ! this.benchmark.Ticker, 5); break; case IntervalsType.CloseToOpenIntervals: --- 374,384 ---- switch ( ((PVOCorrelationChooser)this.inSampleChooser).IntervalsType ) { ! case IntervalsType.CloseToCloseIntervals: returnIntervals = new CloseToCloseIntervals(firstEndOfDayDateTime, lastEndOfDayDateTime, ! this.benchmark.Ticker, ((PVOCorrelationChooser)this.inSampleChooser).ReturnIntervalLength); break; ! case IntervalsType.OpenToOpenIntervals: ! returnIntervals = new OpenToOpenIntervals(firstEndOfDayDateTime, lastEndOfDayDateTime, ! this.benchmark.Ticker, ((PVOCorrelationChooser)this.inSampleChooser).ReturnIntervalLength); break; case IntervalsType.CloseToOpenIntervals: *************** *** 324,328 **** this.benchmark.Ticker); break; ! case IntervalsType.DailyOpenToCloseIntervals: returnIntervals = new DailyOpenToCloseIntervals(firstEndOfDayDateTime, lastEndOfDayDateTime, this.benchmark.Ticker ); --- 386,390 ---- this.benchmark.Ticker); break; ! case IntervalsType.OpenToCloseIntervals: returnIntervals = new DailyOpenToCloseIntervals(firstEndOfDayDateTime, lastEndOfDayDateTime, this.benchmark.Ticker ); *************** *** 344,348 **** } ! private PVO_OTCLogItem getLogItem( EligibleTickers eligibleTickers ) { --- 406,437 ---- } ! ! private double getLogItem_getFitnessOfLast() ! { ! double returnValue = 0.0; ! for(int i = 1; i<=this.chosenPVOPositions.Length; i++) ! { ! if(this.chosenPVOPositions[this.chosenPVOPositions.Length - i] != null) ! { ! returnValue = this.chosenPVOPositions[this.chosenPVOPositions.Length - i].FitnessInSample; ! i = this.chosenPVOPositions.Length + 1; //exit from for ! } ! } ! return returnValue; ! } ! private string getLogItem_getHashCodeForTickerCompositionForLast() ! { ! string returnValue = "not set"; ! for(int i = 1; i<=this.chosenPVOPositions.Length; i++) ! { ! if(this.chosenPVOPositions[this.chosenPVOPositions.Length - i] != null) ! { ! returnValue = this.chosenPVOPositions[this.chosenPVOPositions.Length - i].HashCodeForTickerComposition; ! i = this.chosenPVOPositions.Length + 1; //exit from for ! } ! } ! return returnValue; ! } ! private PVO_OTCLogItem getLogItem( EligibleTickers eligibleTickers ) { *************** *** 355,360 **** logItem.FitnessOfFirst = this.chosenPVOPositions[0].FitnessInSample; ! logItem.FitnessOfLast = ! this.chosenPVOPositions[this.chosenPVOPositions.Length - 1].FitnessInSample; // logItem.GenerationOfFirst = // ((IGeneticallyOptimizable)this.chosenPVOPositions[0]).Generation; --- 444,449 ---- logItem.FitnessOfFirst = this.chosenPVOPositions[0].FitnessInSample; ! logItem.FitnessOfLast = this.getLogItem_getFitnessOfLast(); ! // logItem.GenerationOfFirst = // ((IGeneticallyOptimizable)this.chosenPVOPositions[0]).Generation; *************** *** 364,374 **** ((PVOPositions)this.chosenPVOPositions[0]).OversoldThreshold.ToString() + ";" + ((PVOPositions)this.chosenPVOPositions[0]).OverboughtThreshold.ToString(); ! logItem.ThresholdsOfLast = ! ((PVOPositions)this.chosenPVOPositions[this.chosenPVOPositions.Length - 1]).OversoldThreshold.ToString() + ";" + ! ((PVOPositions)this.chosenPVOPositions[this.chosenPVOPositions.Length - 1]).OverboughtThreshold.ToString(); logItem.TickersOfFirst = this.chosenPVOPositions[0].HashCodeForTickerComposition; ! logItem.TickersOfLast = ! this.chosenPVOPositions[this.chosenPVOPositions.Length - 1].HashCodeForTickerComposition; return logItem; } --- 453,463 ---- ((PVOPositions)this.chosenPVOPositions[0]).OversoldThreshold.ToString() + ";" + ((PVOPositions)this.chosenPVOPositions[0]).OverboughtThreshold.ToString(); ! logItem.ThresholdsOfLast = logItem.ThresholdsOfFirst; ! // ((PVOPositions)this.chosenPVOPositions[this.chosenPVOPositions.Length - 1]).OversoldThreshold.ToString() + ";" + ! // ((PVOPositions)this.chosenPVOPositions[this.chosenPVOPositions.Length - 1]).OverboughtThreshold.ToString(); logItem.TickersOfFirst = this.chosenPVOPositions[0].HashCodeForTickerComposition; ! logItem.TickersOfLast = this.getLogItem_getHashCodeForTickerCompositionForLast(); ! return logItem; } *************** *** 392,396 **** private void logOptimizationInfo( EligibleTickers eligibleTickers ) { ! this.raiseNewLogItem( eligibleTickers ); this.notifyMessage( eligibleTickers ); } --- 481,487 ---- private void logOptimizationInfo( EligibleTickers eligibleTickers ) { ! if(eligibleTickers.Count > 0) ! this.raiseNewLogItem( eligibleTickers ); ! this.notifyMessage( eligibleTickers ); } *************** *** 400,407 **** for(int i = 0; i<this.chosenPVOPositions.Length; i++) { ! ((PVOPositions)this.chosenPVOPositions[i]).OversoldThreshold = ! this.oversoldThreshold; ! ((PVOPositions)this.chosenPVOPositions[i]).OverboughtThreshold = ! this.overboughtThreshold; } } --- 491,501 ---- for(int i = 0; i<this.chosenPVOPositions.Length; i++) { ! if(this.chosenPVOPositions[i] != null) ! { ! ((PVOPositions)this.chosenPVOPositions[i]).OversoldThreshold = ! this.oversoldThreshold; ! ((PVOPositions)this.chosenPVOPositions[i]).OverboughtThreshold = ! this.overboughtThreshold; ! } } } *************** *** 419,427 **** this.updateReturnsManager(endOfDayHistory.FirstEndOfDayDateTime, endOfDayHistory.LastEndOfDayDateTime); ! if(this.inSampleChooser != null) this.chosenPVOPositions = (TestingPositions[])inSampleChooser.AnalyzeInSample(eligibles, this.returnsManager); ! this.updateTestingPositions_updateThresholds(); ! this.logOptimizationInfo(eligibles); ! } private bool optimalTestingPositionsAreToBeUpdated() --- 513,531 ---- this.updateReturnsManager(endOfDayHistory.FirstEndOfDayDateTime, endOfDayHistory.LastEndOfDayDateTime); ! if( ( this.eligiblesSelector is DummyEligibleSelector && ! this.inSampleChooser != null ) || ! ( eligibles.Count > this.minimumNumberOfEligiblesForValidOptimization && ! this.inSampleChooser != null ) ) ! { this.chosenPVOPositions = (TestingPositions[])inSampleChooser.AnalyzeInSample(eligibles, this.returnsManager); ! this.updateTestingPositions_updateThresholds(); ! this.logOptimizationInfo(eligibles); ! this.optimalPositionsHaveBeenUpdated = true; ! } ! else ! { ! this.optimalPositionsHaveBeenUpdated = false; ! } ! } private bool optimalTestingPositionsAreToBeUpdated() Index: PVOMain.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/PVOMain.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PVOMain.cs 8 Apr 2008 22:00:01 -0000 1.4 --- PVOMain.cs 14 Aug 2008 23:28:06 -0000 1.5 *************** *** 44,47 **** --- 44,48 ---- using QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator.Decoding; using QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator.FitnessEvaluators; + using QuantProject.Scripts.General; using QuantProject.Scripts.General.Logging; using QuantProject.Scripts.General.Reporting; *************** *** 55,238 **** /// be done /// </summary> ! public class PVOMain { ! private string strategyIdentifier; ! private string fileNameWithoutExt; ! private string dirNameWhereToSaveResults; ! ! public PVOMain() ! { ! this.strategyIdentifier = "PVO"; ! } ! private void setFileNamesAndDirectory(EndOfDayStrategyBackTester endOfDayStrategyBackTester) { ! if(this.fileNameWithoutExt == null) ! { ! this.fileNameWithoutExt = this.strategyIdentifier + "_" + ! DateTime.Now.Hour.ToString().PadLeft(2,'0') + "_" + ! DateTime.Now.Minute.ToString().PadLeft(2,'0') + "_" + ! DateTime.Now.Second.ToString().PadLeft(2,'0'); ! this.dirNameWhereToSaveResults = System.Configuration.ConfigurationSettings.AppSettings["LogArchive"] + ! "\\" + fileNameWithoutExt + "\\"; ! ! if( !Directory.Exists(dirNameWhereToSaveResults) ) ! Directory.CreateDirectory(dirNameWhereToSaveResults); ! } } ! ! #region Run ! private MessageManager setMessageManager( ! IEligiblesSelector eligiblesSelector , ! IInSampleChooser inSampleChooser , ! IEndOfDayStrategy endOfDayStrategy , ! EndOfDayStrategyBackTester endOfDayStrategyBackTester ) { - this.setFileNamesAndDirectory(endOfDayStrategyBackTester); ! string fullPathFileNameForMessagesLog = dirNameWhereToSaveResults + ! this.fileNameWithoutExt + ! "LogMessages.txt"; ! MessageManager messageManager = ! new MessageManager( fullPathFileNameForMessagesLog ); ! messageManager.Monitor( eligiblesSelector ); ! messageManager.Monitor( inSampleChooser ); ! // messageManager.Monitor( endOfDayStrategy ); ! messageManager.Monitor( endOfDayStrategyBackTester ); ! return messageManager; ! } ! //Saves (in silent mode): ! //- a log file where the In Sample Analysis are ! // stored; ! //- a report; ! //- a txt file with a full description of the ! // strategy's features ! private void saveScriptResults( EndOfDayStrategyBackTester endOfDayStrategyBackTester ) { ! this.setFileNamesAndDirectory(endOfDayStrategyBackTester); ! string fullPathFileNameForLog = dirNameWhereToSaveResults + ! this.fileNameWithoutExt + ".qpL"; ! string fullPathFileNameForReport = dirNameWhereToSaveResults + ! this.fileNameWithoutExt + ".qpR"; ! string fullPathFileNameForParametersLog = dirNameWhereToSaveResults + ! this.fileNameWithoutExt + "_Parameters.txt"; ! ObjectArchiver.Archive(endOfDayStrategyBackTester.Log, ! fullPathFileNameForLog); ! ObjectArchiver.Archive(endOfDayStrategyBackTester.AccountReport, ! fullPathFileNameForReport); ! StreamWriter w = File.AppendText(fullPathFileNameForParametersLog); ! w.WriteLine ("\n---\r\n"); ! w.WriteLine ( endOfDayStrategyBackTester.Description ); ! w.WriteLine ("\n---\r\n"); ! w.Flush(); ! w.Close(); ! } ! public void Run() { ! //general ! DateTime firstDateTime = new DateTime( 2000 , 6 , 1 ); ! DateTime lastDateTime = new DateTime( 2001 , 6 , 1 ); ! double maxRunningHours = 5; ! Benchmark benchmark = new Benchmark( "^GSPC" ); ! // definition for the Fitness Evaluator (for ! // objects that use it) ! IEquityEvaluator equityEvaluator = new SharpeRatio(); ! //cash and portfolio type ! double cashToStart = 30000; ! int numberOfPortfolioPositions = 4; ! ! // parameters for the in sample Chooser ! // double crossoverRate = 0.85; ! // double mutationRate = 0.02; ! // double elitismRate = 0.001; ! // int populationSizeForGeneticOptimizer = 500; ! // int generationNumberForGeneticOptimizer = 10; ! int numberOfBestTestingPositionsToBeReturnedInSample = 5; ! int seedForRandomGenerator = ! QuantProject.ADT.ConstantsProvider.SeedForRandomGenerator; ! int numDaysBetweenEachOptimization = 15; ! // int minLevelForOversoldThreshold = 50; ! // int maxLevelForOversoldThreshold = 100; ! // int minLevelForOverboughtThreshold = 50; ! // int maxLevelForOverboughtThreshold = 100; ! int divisorForThresholdComputation = 10000; ! int numDaysForOscillatingPeriodForChooser = 1; //for genetic optimization ! bool symmetricalThresholds = true; ! // bool overboughtMoreThanOversoldForFixedPortfolio = false; ! double maxAcceptableCloseToCloseDrawdown = 0.03; ! double minimumAcceptableGain = 0.008; ! IDecoderForTestingPositions decoderForTestingPositions ! = new BasicDecoderForPVOPositions(symmetricalThresholds, divisorForThresholdComputation , ! numDaysForOscillatingPeriodForChooser); ! IFitnessEvaluator fitnessEvaluator = ! new PVOFitnessEvaluator( equityEvaluator ); ! HistoricalQuoteProvider historicalQuoteProviderForBackTester, ! historicalQuoteProviderForInSampleChooser, ! historicalQuoteProviderForStrategy; ! historicalQuoteProviderForBackTester = new HistoricalAdjustedQuoteProvider(); - historicalQuoteProviderForInSampleChooser = historicalQuoteProviderForBackTester; - historicalQuoteProviderForStrategy = historicalQuoteProviderForInSampleChooser; - - // IInSampleChooser inSampleChooser = - // new PVOGeneticChooser(numDaysForOscillatingPeriodForChooser , - // numberOfPortfolioPositions , numberOfBestTestingPositionsToBeReturnedInSample, - // benchmark, decoderForTestingPositions , fitnessEvaluator , - // historicalQuoteProviderForInSampleChooser , - // crossoverRate , mutationRate , elitismRate , - // populationSizeForGeneticOptimizer , generationNumberForGeneticOptimizer , - // seedForRandomGenerator , minLevelForOversoldThreshold , - // maxLevelForOversoldThreshold , minLevelForOverboughtThreshold , - // maxLevelForOverboughtThreshold , divisorForThresholdComputation , - // symmetricalThresholds , overboughtMoreThanOversoldForFixedPortfolio ); - double maxCorrelationValue = 0.96; - bool balancedWeights = false; - IInSampleChooser inSampleChooser = - new PVO_CTCCorrelationChooser(numberOfBestTestingPositionsToBeReturnedInSample, - numDaysForOscillatingPeriodForChooser, - maxCorrelationValue, balancedWeights); - //parameters for eligiblesSelector - bool temporizedGroup = true; - double minRawOpenPrice = 25; - double maxRawOpenPrice = 500; - int numDaysForAverageOpenRawPrice = 20; - string tickersGroupId = "SP500"; - int maxNumberOfEligiblesToBeChosen = 100; - IEligiblesSelector eligiblesSelector = - new ByPriceMostLiquidAlwaysQuoted( - tickersGroupId , temporizedGroup, maxNumberOfEligiblesToBeChosen, - numDaysForAverageOpenRawPrice , - minRawOpenPrice , maxRawOpenPrice ); - //strategyParameters - int inSampleDays = 120; - int numDaysForOscillatingPeriodForOutOfSampleChoosing = - numDaysForOscillatingPeriodForChooser; - PVOStrategy strategy = - new PVOStrategy(eligiblesSelector, - inSampleChooser, inSampleDays, - numDaysForOscillatingPeriodForOutOfSampleChoosing, - numberOfPortfolioPositions , benchmark , - numDaysBetweenEachOptimization , - historicalQuoteProviderForStrategy , - maxAcceptableCloseToCloseDrawdown , minimumAcceptableGain ); - EndOfDayStrategyBackTester endOfDayStrategyBackTester = new EndOfDayStrategyBackTester( ! this.strategyIdentifier , strategy , ! historicalQuoteProviderForBackTester , ! new SimpleAccountProvider(), firstDateTime , ! lastDateTime , benchmark , cashToStart , maxRunningHours ); ! MessageManager messageManager = this.setMessageManager( ! eligiblesSelector , inSampleChooser , ! strategy , endOfDayStrategyBackTester ); ! endOfDayStrategyBackTester.Run(); ! this.saveScriptResults(endOfDayStrategyBackTester); } ! #endregion Run ! } } --- 56,238 ---- /// be done /// </summary> ! public class PVOMain : BasicScriptForBacktesting { ! private Benchmark benchmark; ! private HistoricalQuoteProvider historicalQuoteProvider; ! public PVOMain() { ! this.benchmark = new Benchmark( "BMC" ); ! ! this.historicalQuoteProvider = ! new HistoricalAdjustedQuoteProvider(); ! ! // definition for the Fitness Evaluator ! // IEquityEvaluator equityEvaluator = new SharpeRatio(); } ! ! protected override IEligiblesSelector getEligiblesSelector() { ! int maxNumberOfEligiblesToBeChosen = 100; ! ! string tickersGroupId = "SP500"; ! bool temporizedGroup = true; ! int numDaysForAverageRawOpenPriceComputation = 10; ! double minPrice = 30; ! double maxPrice = 75; ! ! int maxNumberOfMostLiquidTickersToBeChosen = 150; ! int numDaysForVolatility = 10; ! IEligiblesSelector eligiblesSelector = ! new ByPriceMostLiquidLessVolatileCTCAlwaysQuoted( ! tickersGroupId , temporizedGroup , ! maxNumberOfEligiblesToBeChosen , ! maxNumberOfMostLiquidTickersToBeChosen , ! numDaysForAverageRawOpenPriceComputation , ! numDaysForVolatility , ! minPrice , maxPrice ); ! // IEligiblesSelector eligiblesSelector = ! // new ByPriceMostLiquidAlwaysQuoted( ! // tickersGroupId , temporizedGroup , ! // maxNumberOfEligiblesToBeChosen , ! // numDaysForAverageRawOpenPriceComputation , ! // minPrice , maxPrice ); ! // IEligiblesSelector eligiblesSelector = ! // new ByPriceLessVolatileOTCAlwaysQuoted( ! // tickersGroupId , temporizedGroup , ! // maxNumberOfEligiblesToBeChosen , ! // numDaysForAverageRawOpenPriceComputation , ! // minPrice , maxPrice ); ! eligiblesSelector = ! new DummyEligibleSelector(); ! // ! return eligiblesSelector; ! } ! ! protected override IInSampleChooser getInSampleChooser() { ! // parameters for the genetic optimizer ! // double crossoverRate = 0.85; ! // double mutationRate = 0.02; ! // double elitismRate = 0.001; ! // int populationSizeForGeneticOptimizer = 3000; ! // int generationNumberForGeneticOptimizer = 4; ! // int seedForRandomGenerator = ! // QuantProject.ADT.ConstantsProvider.SeedForRandomGenerator; ! // IDecoderForTestingPositions decoderForWeightedPositions = ! // new DecoderForPairsTradingTestingPositionsWithBalancedWeights(); ! ! double maxCorrelationAllowed = 0.96; ! int numberOfBestTestingPositionsToBeReturned = 50; ! numberOfBestTestingPositionsToBeReturned = 10; ! bool balancedWeightsOnVolatilityBase = true; ! float minimumAbsoluteReturnValue = 0.000001f; ! float maximumAbsoluteReturnValue = 100000f; ! int closeToCloseIntervalLengthForCorrelation = 2; ! //correlation is computed only for returns ! //between minimum and maximum ! IInSampleChooser inSampleChooser = ! // new PVO_CTCCorrelationChooser(numberOfBestTestingPositionsToBeReturned, ! // closeToCloseIntervalLengthForCorrelation , maxCorrelationAllowed , balancedWeightsOnVolatilityBase, ! // minimumAbsoluteReturnValue , maximumAbsoluteReturnValue, this.benchmark.Ticker ); ! new PVO_CTCStrongCorrelationChooser(numberOfBestTestingPositionsToBeReturned, ! maxCorrelationAllowed , minimumAbsoluteReturnValue , maximumAbsoluteReturnValue, ! balancedWeightsOnVolatilityBase, this.benchmark.Ticker ); ! // IInSampleChooser inSampleChooser = ! // new PVO_OTCCTOCorrelationChooser(numberOfBestTestingPositionsToBeReturned, ! // maxCorrelationAllowed , balancedWeightsOnVolatilityBase, ! // minimumAbsoluteReturnValue , maximumAbsoluteReturnValue); ! // //office ! // inSampleChooser = ! // new PVOChooserFromSavedBackTestLog( ! // @"C:\Utente\MarcoVarie\Vari\qP\LogArchive\2008_05_23_15_46_38_PVO_CTC_from_2001_01_01_to_2001_12_31_annlRtrn_8,61_maxDD_17,21\2008_05_23_15_46_38_PVO_CTC_from_2001_01_01_to_2001_12_31_annlRtrn_8,61_maxDD_17,21.qpL", ! // numberOfBestTestingPositionsToBeReturned); ! //home ! inSampleChooser = ! new PVOChooserFromSavedBackTestLog( ! @"C:\Utente\MarcoVarie\Vari\qP\LogArchive\2008_06_03_18_33_29_PVO_CTC_from_2001_01_01_to_2004_12_31_annlRtrn_4.72_maxDD_13.57\2008_06_03_18_33_29_PVO_CTC_from_2001_01_01_to_2004_12_31_annlRtrn_4.72_maxDD_13.57.qpL", ! numberOfBestTestingPositionsToBeReturned); ! return inSampleChooser; ! } ! ! protected override IEndOfDayStrategyForBacktester getEndOfDayStrategy() { ! int inSampleDays = 180; ! // uncomment the following line for a faster script ! //inSampleDays = 50; ! int numDaysBetweenEachOptimization = 5; ! double oversoldThreshold = 0.002; ! double overboughtThreshold = 0.002; ! double oversoldThresholdMAX = 0.02; ! double overboughtThresholdMAX = 0.02; ! double maxAcceptableDrawDown = 0.01; ! double minimumAcceptableGain = 0.002; ! int closeToCloseIntervalLength = 1; ! IEndOfDayStrategyForBacktester endOfDayStrategy ! // = new PVO_OTCStrategyLessCorrelated(eligiblesSelector ,inSampleChooser , ! // inSampleDays , benchmark , numDaysBetweenEachOptimization , ! // oversoldThreshold , overboughtThreshold , historicalQuoteProvider); ! // ! = new PVOStrategy(eligiblesSelector , inSampleChooser , ! inSampleDays , closeToCloseIntervalLength , 2 , benchmark , numDaysBetweenEachOptimization , ! oversoldThreshold , overboughtThreshold , ! oversoldThresholdMAX , overboughtThresholdMAX , historicalQuoteProvider, ! maxAcceptableDrawDown, minimumAcceptableGain ); ! return endOfDayStrategy; ! } ! protected override EndOfDayStrategyBackTester getEndOfDayStrategyBackTester() ! { ! string backTestId = "PVO_CTC"; ! IAccountProvider accountProvider; ! accountProvider = new SimpleAccountProvider(); ! // double fixedPercentageSlippage = 0.05; ! // accountProvider = ! // new InteractiveBrokerAccountProvider(fixedPercentageSlippage); ! double cashToStart = 25000; ! ! DateTime firstDateTime = new DateTime( 2001 , 1 , 1 ); ! DateTime lastDateTime = new DateTime( 2004 , 12, 31 ); ! double maxRunningHours = 8; ! HistoricalQuoteProvider quoteProviderForBackTester = ! this.historicalQuoteProvider; ! quoteProviderForBackTester = new HistoricalAdjustedQuoteProvider(); EndOfDayStrategyBackTester endOfDayStrategyBackTester = new EndOfDayStrategyBackTester( ! backTestId , this.endOfDayStrategy , ! quoteProviderForBackTester , accountProvider , ! firstDateTime , lastDateTime , ! this.benchmark , cashToStart , maxRunningHours ); ! return endOfDayStrategyBackTester; ! } ! protected override string getPathForTheMainFolderWhereScriptsResultsAreToBeSaved() ! { ! string pathForTheMainFolderWhereScriptsResultsAreToBeSaved = ! System.Configuration.ConfigurationSettings.AppSettings["LogArchive"]; ! return pathForTheMainFolderWhereScriptsResultsAreToBeSaved; } ! protected override string getCustomSmallTextForFolderName() ! { ! return "PVO_CTC"; ! } ! ! protected override string getFullPathFileNameForMain() ! { ! string returnValue; ! string fullPathFileNameForMainAtHome = ! @"C:\Quant\QuantProject\b7_Scripts\TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\PVOMain.cs"; ! if( File.Exists(fullPathFileNameForMainAtHome) ) ! returnValue = fullPathFileNameForMainAtHome; ! else ! returnValue = ! @"C:\Utente\MarcoVarie\Vari\qP\QuantProject\b7_Scripts\TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\PVOMain.cs"; ! ! return returnValue; ! } } } Index: PVOPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/PVOPositions.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PVOPositions.cs 20 Apr 2008 17:21:28 -0000 1.2 --- PVOPositions.cs 14 Aug 2008 23:28:06 -0000 1.3 *************** *** 59,63 **** set{this.overboughtThreshold = value;} } ! public int NumDaysForOscillatingPeriod { get{return this.numDaysForOscillatingPeriod;} --- 59,63 ---- set{this.overboughtThreshold = value;} } ! public int NumDaysForOscillatingPeriod { get{return this.numDaysForOscillatingPeriod;} *************** *** 75,80 **** public PVOPositions Copy() { ! return new PVOPositions(this.WeightedPositions,this.OversoldThreshold, ! this.overboughtThreshold, this.numDaysForOscillatingPeriod); } --- 75,82 ---- public PVOPositions Copy() { ! return new PVOPositions(this.WeightedPositions, ! this.OversoldThreshold, ! this.overboughtThreshold, ! this.numDaysForOscillatingPeriod); } *************** *** 126,130 **** string benchmark, HistoricalQuoteProvider quoteProvider, ! double maxCoefficientOfCrossingThresholds) { PVOPositionsStatus returnValue; --- 128,133 ---- string benchmark, HistoricalQuoteProvider quoteProvider, ! double maxOversoldThreshold, ! double maxOverboughtThreshold) { PVOPositionsStatus returnValue; *************** *** 134,145 **** quoteProvider); if(oscillatingPeriodReturn >= this.overboughtThreshold && ! oscillatingPeriodReturn <= maxCoefficientOfCrossingThresholds*this.overboughtThreshold) returnValue = PVOPositionsStatus.Overbought; else if(oscillatingPeriodReturn <= -this.oversoldThreshold && ! Math.Abs(oscillatingPeriodReturn)<=maxCoefficientOfCrossingThresholds*this.oversoldThreshold) returnValue = PVOPositionsStatus.Oversold; ! else if ( Math.Abs(oscillatingPeriodReturn) > maxCoefficientOfCrossingThresholds*this.oversoldThreshold || ! oscillatingPeriodReturn > maxCoefficientOfCrossingThresholds*this.overboughtThreshold ) ! returnValue = PVOPositionsStatus.TooDistantFromThresholds; else returnValue = PVOPositionsStatus.InTheMiddle; --- 137,148 ---- quoteProvider); if(oscillatingPeriodReturn >= this.overboughtThreshold && ! oscillatingPeriodReturn <= maxOverboughtThreshold) returnValue = PVOPositionsStatus.Overbought; else if(oscillatingPeriodReturn <= -this.oversoldThreshold && ! Math.Abs(oscillatingPeriodReturn) <= maxOversoldThreshold) returnValue = PVOPositionsStatus.Oversold; ! else if ( Math.Abs(oscillatingPeriodReturn) > maxOversoldThreshold || ! oscillatingPeriodReturn > maxOverboughtThreshold ) ! returnValue = PVOPositionsStatus.OverMaximumThresholds; else returnValue = PVOPositionsStatus.InTheMiddle; *************** *** 148,162 **** } - public PVOPositionsStatus GetStatus(EndOfDayDateTime beginOfPeriod, - EndOfDayDateTime endOfPeriod, - string benchmark, - HistoricalQuoteProvider quoteProvider) - { - return this.GetStatus(beginOfPeriod, endOfPeriod , - benchmark, quoteProvider, 10000.0); - //a very high maxCoefficientOfCrossingThresholds is given: - //so the status TooDistantFromThresholds should never been reached - } - public bool AreAllTickersMovingTogetherUpOrDown(EndOfDayDateTime beginOfPeriod, EndOfDayDateTime endOfPeriod, --- 151,154 ---- Index: PVO_OTCStrategyLessCorrelated.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/PVO_OTCStrategyLessCorrelated.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PVO_OTCStrategyLessCorrelated.cs 26 Apr 2008 09:13:11 -0000 1.1 --- PVO_OTCStrategyLessCorrelated.cs 14 Aug 2008 23:28:06 -0000 1.2 *************** *** 187,191 **** currentStatus = ((PVOPositions)this.chosenPVOPositions[i]).GetStatus(beginOfOscillatingPeriod, today, ! this.benchmark.Ticker, this.historicalQuoteProvider); if(currentStatus == PVOPositionsStatus.Oversold || currentStatus == PVOPositionsStatus.Overbought ) --- 187,192 ---- currentStatus = ((PVOPositions)this.chosenPVOPositions[i]).GetStatus(beginOfOscillatingPeriod, today, ! this.benchmark.Ticker, this.historicalQuoteProvider, ! double.MaxValue, double.MaxValue); if(currentStatus == PVOPositionsStatus.Oversold || currentStatus == PVOPositionsStatus.Overbought ) |
|
From: Marco M. <mi...@us...> - 2008-08-15 03:53:20
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16669/b2_DataAccess/Tables Modified Files: Quotes.cs Log Message: SelectorByAverageOpenToClosePerformance can now select tickers with a given maximum absolute average OTC performance, for a given period. Index: Quotes.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables/Quotes.cs,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** Quotes.cs 8 Apr 2008 21:38:41 -0000 1.33 --- Quotes.cs 14 Aug 2008 23:22:49 -0000 1.34 *************** *** 579,582 **** --- 579,583 ---- DateTime firstQuoteDate, DateTime lastQuoteDate, + double maxAbsoluteAverageOTCPerformance, long maxNumOfReturnedTickers) { *************** *** 591,594 **** --- 592,597 ---- SQLBuilder.GetDateConstant(lastQuoteDate) + "GROUP BY tickers.tiTicker, tickers.tiCompanyName " + + "HAVING Avg(quotes.quClose/quotes.quOpen - 1) <= " + maxAbsoluteAverageOTCPerformance + + " AND Avg(quotes.quClose/quotes.quOpen - 1) >= -" + maxAbsoluteAverageOTCPerformance + " " + "ORDER BY Avg(quotes.quClose/quotes.quOpen)"; string sortDirection = " DESC"; *************** *** 782,786 **** { ! DataTable dt; string sql = "SELECT quotes.quTicker, " + "StDev(quotes.quAdjustedCloseToCloseRatio) AS AdjCloseToCloseStandDev " + --- 785,790 ---- { ! double adjCloseToCloseStdDev = 0.0; ! DataTable dt; string sql = "SELECT quotes.quTicker, " + "StDev(quotes.quAdjustedCloseToCloseRatio) AS AdjCloseToCloseStandDev " + *************** *** 791,798 **** " GROUP BY quotes.quTicker"; dt = SqlExecutor.GetDataTable( sql ); ! if(dt.Rows.Count==0) ! return 0; ! else ! return (double)dt.Rows[0]["AdjCloseToCloseStandDev"]; } --- 795,804 ---- " GROUP BY quotes.quTicker"; dt = SqlExecutor.GetDataTable( sql ); ! ! if( dt.Rows.Count > 0 && ! DBNull.Value != dt.Rows[0]["AdjCloseToCloseStandDev"] ) ! adjCloseToCloseStdDev = (double)dt.Rows[0]["AdjCloseToCloseStandDev"]; ! ! return adjCloseToCloseStdDev; } |
|
From: Marco M. <mi...@us...> - 2008-08-15 03:53:19
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/StatisticsSummaryRows In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv15468/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/StatisticsSummaryRows Modified Files: AverageReturnOnDayOfWeekWithOpenPositions.cs Log Message: Added try-catch block for avoiding run time error if no returns are available for a specific day of the week. Index: AverageReturnOnDayOfWeekWithOpenPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/StatisticsSummaryRows/AverageReturnOnDayOfWeekWithOpenPositions.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AverageReturnOnDayOfWeekWithOpenPositions.cs 25 Apr 2008 17:11:41 -0000 1.1 --- AverageReturnOnDayOfWeekWithOpenPositions.cs 14 Aug 2008 21:36:09 -0000 1.2 *************** *** 100,104 **** } } ! this.rowValue = this.getRowValue(totalNumberOfSpecificDayOfWeek, sumOfReturnsOnSpecificDayOfWeek); } } --- 100,111 ---- } } ! try ! { ! this.rowValue = this.getRowValue(totalNumberOfSpecificDayOfWeek, sumOfReturnsOnSpecificDayOfWeek); ! } ! catch (Exception ex) ! { ! ex = ex; // to avoid compilation warning; ! } } } |
|
From: Marco M. <mi...@us...> - 2008-08-15 03:53:16
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/TickersRelationships In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv17318/b4_Business/a2_Strategies/TickersRelationships Modified Files: TickersPearsonCorrelation.cs Log Message: Property CorrelationValue can be written now Index: TickersPearsonCorrelation.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/TickersRelationships/TickersPearsonCorrelation.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TickersPearsonCorrelation.cs 14 Jan 2008 23:02:30 -0000 1.1 --- TickersPearsonCorrelation.cs 14 Aug 2008 21:40:44 -0000 1.2 *************** *** 57,60 **** --- 57,64 ---- return this.correlationValue; } + set + { + this.correlationValue = value; + } } |
|
From: Marco M. <mi...@us...> - 2008-08-15 03:53:14
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/Selectors In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16669/b3_Data/Selectors Modified Files: SelectorByAverageOpenToClosePerformance.cs Log Message: SelectorByAverageOpenToClosePerformance can now select tickers with a given maximum absolute average OTC performance, for a given period. Index: SelectorByAverageOpenToClosePerformance.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/Selectors/SelectorByAverageOpenToClosePerformance.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SelectorByAverageOpenToClosePerformance.cs 7 Jan 2006 10:56:09 -0000 1.2 --- SelectorByAverageOpenToClosePerformance.cs 14 Aug 2008 23:22:49 -0000 1.3 *************** *** 35,39 **** public class SelectorByAverageOpenToClosePerformance : TickerSelector, ITickerSelector { ! public SelectorByAverageOpenToClosePerformance(DataTable setOfTickersToBeSelected, --- 35,39 ---- public class SelectorByAverageOpenToClosePerformance : TickerSelector, ITickerSelector { ! private double maxAbsoluteAverageOTCPerformance; public SelectorByAverageOpenToClosePerformance(DataTable setOfTickersToBeSelected, *************** *** 41,44 **** --- 41,45 ---- DateTime firstQuoteDate, DateTime lastQuoteDate, + double maxAbsoluteAverageOTCPerformance, long maxNumOfReturnedTickers): base(setOfTickersToBeSelected, *************** *** 48,52 **** maxNumOfReturnedTickers) { ! } public SelectorByAverageOpenToClosePerformance(string groupID, --- 49,55 ---- maxNumOfReturnedTickers) { ! if(maxAbsoluteAverageOTCPerformance < 0.0) ! throw new Exception("maxAbsoluteAverageOTCPerformance has to be non negative!"); ! this.maxAbsoluteAverageOTCPerformance = maxAbsoluteAverageOTCPerformance; } public SelectorByAverageOpenToClosePerformance(string groupID, *************** *** 54,57 **** --- 57,61 ---- DateTime firstQuoteDate, DateTime lastQuoteDate, + double maxAbsoluteAverageOTCPerformance, long maxNumOfReturnedTickers): base(groupID, *************** *** 61,65 **** maxNumOfReturnedTickers) { ! } --- 65,71 ---- maxNumOfReturnedTickers) { ! if(maxAbsoluteAverageOTCPerformance < 0.0) ! throw new Exception("maxAbsoluteAverageOTCPerformance has to be non negative!"); ! this.maxAbsoluteAverageOTCPerformance = maxAbsoluteAverageOTCPerformance; } *************** *** 71,74 **** --- 77,81 ---- this.groupID, this.firstQuoteDate, this.lastQuoteDate, + this.maxAbsoluteAverageOTCPerformance, this.maxNumOfReturnedTickers); else *************** *** 77,80 **** --- 84,88 ---- this.firstQuoteDate, this.lastQuoteDate, + this.maxAbsoluteAverageOTCPerformance, this.maxNumOfReturnedTickers); } |
|
From: Marco M. <mi...@us...> - 2008-08-15 02:53:07
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataTables In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16669/b3_Data/DataTables Modified Files: Quotes.cs Log Message: SelectorByAverageOpenToClosePerformance can now select tickers with a given maximum absolute average OTC performance, for a given period. Index: Quotes.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataTables/Quotes.cs,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** Quotes.cs 14 Jan 2008 23:34:22 -0000 1.35 --- Quotes.cs 14 Aug 2008 23:22:49 -0000 1.36 *************** *** 181,192 **** if(!setOfTickers.Columns.Contains("AdjCloseToCloseStandDev")) setOfTickers.Columns.Add("AdjCloseToCloseStandDev", System.Type.GetType("System.Double")); ! foreach(DataRow row in setOfTickers.Rows) { ! row["AdjCloseToCloseStandDev"] = ! QuantProject.DataAccess.Tables.Quotes.GetAdjustedCloseToCloseStandardDeviation((string)row[0], firstQuoteDate, lastQuoteDate); } ! DataTable getTickersByVolatility = ExtendedDataTable.CopyAndSort(setOfTickers,"AdjCloseToCloseStandDev", orderByASC); ExtendedDataTable.DeleteRows(getTickersByVolatility, maxNumOfReturnedTickers); return getTickersByVolatility; --- 181,199 ---- if(!setOfTickers.Columns.Contains("AdjCloseToCloseStandDev")) setOfTickers.Columns.Add("AdjCloseToCloseStandDev", System.Type.GetType("System.Double")); ! double CTCStdDev; ! foreach(DataRow row in setOfTickers.Rows) { ! row["AdjCloseToCloseStandDev"] = -1000000.0; ! CTCStdDev = QuantProject.DataAccess.Tables.Quotes.GetAdjustedCloseToCloseStandardDeviation((string)row[0], firstQuoteDate, lastQuoteDate); + if( !Double.IsInfinity(CTCStdDev) && !Double.IsNaN(CTCStdDev) ) + row["AdjCloseToCloseStandDev"] = CTCStdDev; } ! DataTable getTickersByVolatility = ! ExtendedDataTable.CopyAndSort(setOfTickers, ! "AdjCloseToCloseStandDev>-1000000.0", ! "AdjCloseToCloseStandDev", ! orderByASC); ExtendedDataTable.DeleteRows(getTickersByVolatility, maxNumOfReturnedTickers); return getTickersByVolatility; *************** *** 205,217 **** if(!setOfTickers.Columns.Contains("OpenToCloseStandDev")) setOfTickers.Columns.Add("OpenToCloseStandDev", System.Type.GetType("System.Double")); ! foreach(DataRow row in setOfTickers.Rows) { try { row["OpenToCloseStandDev"] = -1000000.0; ! row["OpenToCloseStandDev"] = ! QuantProject.DataAccess.Tables.Quotes.GetOpenToCloseStandardDeviation((string)row[0], ! firstQuoteDate, ! lastQuoteDate); } catch(Exception ex) --- 212,226 ---- if(!setOfTickers.Columns.Contains("OpenToCloseStandDev")) setOfTickers.Columns.Add("OpenToCloseStandDev", System.Type.GetType("System.Double")); ! double OTCStdDev; ! foreach(DataRow row in setOfTickers.Rows) { try { row["OpenToCloseStandDev"] = -1000000.0; ! OTCStdDev = QuantProject.DataAccess.Tables.Quotes.GetOpenToCloseStandardDeviation((string)row[0], ! firstQuoteDate, ! lastQuoteDate); ! if( !Double.IsInfinity(OTCStdDev) && !Double.IsNaN(OTCStdDev) ) ! row["OpenToCloseStandDev"] = OTCStdDev; } catch(Exception ex) *************** *** 283,286 **** --- 292,296 ---- DateTime firstQuoteDate, DateTime lastQuoteDate, + double maxAbsoluteAverageOTCPerformance, long maxNumOfReturnedTickers) { *************** *** 300,305 **** {ex=ex;} } DataTable tableToReturn = ExtendedDataTable.CopyAndSort(setOfTickers, ! "AverageOpenToClosePerformance>-1000000.0", "AverageOpenToClosePerformance", orderByASC); --- 310,318 ---- {ex=ex;} } + string maxAbsValue = + maxAbsoluteAverageOTCPerformance.ToString(new System.Globalization.CultureInfo("en-US")); DataTable tableToReturn = ExtendedDataTable.CopyAndSort(setOfTickers, ! "AverageOpenToClosePerformance<=" + maxAbsValue + ! " AND AverageOpenToClosePerformance>=-" + maxAbsValue, "AverageOpenToClosePerformance", orderByASC); |
|
From: Marco M. <mi...@us...> - 2008-08-15 01:53:07
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/Selectors In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv19289/b3_Data/Selectors Modified Files: SelectorByCloseToOpenVolatility.cs Log Message: Fixed minor bug Index: SelectorByCloseToOpenVolatility.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/Selectors/SelectorByCloseToOpenVolatility.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SelectorByCloseToOpenVolatility.cs 7 Jan 2006 10:50:40 -0000 1.1 --- SelectorByCloseToOpenVolatility.cs 14 Aug 2008 23:28:37 -0000 1.2 *************** *** 83,93 **** if(!this.setOfTickersToBeSelected.Columns.Contains("CloseToOpenStandardDeviation")) this.setOfTickersToBeSelected.Columns.Add("CloseToOpenStandardDeviation", System.Type.GetType("System.Double")); ! foreach(DataRow row in this.setOfTickersToBeSelected.Rows) { try { row["CloseToOpenStandardDeviation"] = -1000000.0; ! row["CloseToOpenStandardDeviation"] = ! this.getTableOfSelectedTickers_getTickersFromTable_getCTOStdDevForTicker((string)row[0]); } catch(Exception ex) --- 83,96 ---- if(!this.setOfTickersToBeSelected.Columns.Contains("CloseToOpenStandardDeviation")) 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) |
|
From: Marco M. <mi...@us...> - 2008-08-15 01:53:05
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Eligibles In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv22776/b4_Business/a2_Strategies/Eligibles Added Files: ByPriceMostLiquidLessVolatileCTCAlwaysQuoted.cs ByPriceMostLiquidLessVolatileCTOAlwaysQuoted.cs Log Message: Added EligibleSelectors that consider CTC and CTO volatility --- NEW FILE: ByPriceMostLiquidLessVolatileCTCAlwaysQuoted.cs --- /* QuantProject - Quantitative Finance Library ByPriceMostLiquidLessVolatileCTCAlwaysQuoted.cs Copyright (C) 2008 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Data; using QuantProject.ADT.Messaging; using QuantProject.Business.Strategies.ReturnsManagement.Time; using QuantProject.Business.Timing; using QuantProject.Data.Selectors; namespace QuantProject.Business.Strategies.Eligibles { /// <summary> /// Implements IEligiblesSelector for selecting a given max number of tickers through /// the following step-by-step selecting process: /// -step 0: all tickers belonging to a given group /// are selected (the group can be "temporized": that is tickers /// are returned depending on the time the selection is requested: /// the group SP 500 should be like that); /// -step 1: from tickers selected by step 0, the ones that have /// the average raw open price falling in a given range (for the last given number of days) /// are selected; /// -step 2: from tickers selected by step 1, the most liquid /// are selected (not more than maxNumberOfMostLiquidTickersToBeChosen); /// -step 3: from tickers selected by step 2, the ones that are /// less volatile (CTC returns in the last /// numOfDaysForVolatilityComputation days /// are analyzed) are selected /// (not more than maxNumberOfEligibleTickersToBeChosen); /// -step 4: from tickers selected by step 3, the ones that are /// always quoted at all market days are selected /// (not more than maxNumberOfEligibleTickersToBeChosen); /// </summary> public class ByPriceMostLiquidLessVolatileCTCAlwaysQuoted : IEligiblesSelector { public event NewMessageEventHandler NewMessage; private bool temporizedGroup; private string tickersGroupID; private int maxNumberOfEligibleTickersToBeChosen; private int maxNumberOfMostLiquidTickersToBeChosen; private int numOfDaysForAverageOpenRawPriceComputation; private int numOfDaysForVolatilityComputation; private double minPrice; private double maxPrice; public string Description { get{ return "ByPriceMostLiquidLessVolatileCTCAlwaysQuoted"; } } private void byPriceMostLiquidLessVolatileCTCAlwaysQuoted_checkParameters() { if(this.maxNumberOfMostLiquidTickersToBeChosen <= this.maxNumberOfEligibleTickersToBeChosen) throw new Exception("The set of the most liquid tickers has to " + "be greater than the final set of eligibles tickers!"); } public ByPriceMostLiquidLessVolatileCTCAlwaysQuoted( string tickersGroupID , bool temporizedGroup, int maxNumberOfEligibleTickersToBeChosen, int maxNumberOfMostLiquidTickersToBeChosen, int numOfDaysForAverageOpenRawPriceComputation, int numOfDaysForVolatilityComputation, double minPrice, double maxPrice) { this.temporizedGroup = temporizedGroup; this.tickersGroupID = tickersGroupID; this.maxNumberOfEligibleTickersToBeChosen = maxNumberOfEligibleTickersToBeChosen; this.maxNumberOfMostLiquidTickersToBeChosen = maxNumberOfMostLiquidTickersToBeChosen; this.numOfDaysForAverageOpenRawPriceComputation = numOfDaysForAverageOpenRawPriceComputation; this.numOfDaysForVolatilityComputation = numOfDaysForVolatilityComputation; this.minPrice = minPrice; this.maxPrice = maxPrice; this.byPriceMostLiquidLessVolatileCTCAlwaysQuoted_checkParameters(); } private EligibleTickers getEligibleTickers_actually( EndOfDayHistory endOfDayHistory ) { DateTime currentDate = endOfDayHistory.LastEndOfDayDateTime.DateTime; SelectorByGroup group; if(this.temporizedGroup) //the group is "temporized": returned set of tickers // depends on time group = new SelectorByGroup(this.tickersGroupID, currentDate); else//the group is not temporized group = new SelectorByGroup(this.tickersGroupID); DataTable tickersFromGroup = group.GetTableOfSelectedTickers(); int numOfTickersInGroupAtCurrentDate = tickersFromGroup.Rows.Count; SelectorByAverageRawOpenPrice byPrice = new SelectorByAverageRawOpenPrice(tickersFromGroup,false, currentDate.AddDays(-this.numOfDaysForAverageOpenRawPriceComputation), currentDate, numOfTickersInGroupAtCurrentDate, this.minPrice,this.maxPrice, 0.00001, double.MaxValue); DataTable dataTableByPrice = byPrice.GetTableOfSelectedTickers(); SelectorByLiquidity mostLiquidSelector = new SelectorByLiquidity( dataTableByPrice , false, endOfDayHistory.FirstEndOfDayDateTime.DateTime, currentDate, this.maxNumberOfMostLiquidTickersToBeChosen); DataTable dataTableMostLiquid = mostLiquidSelector.GetTableOfSelectedTickers(); SelectorByCloseToCloseVolatility lessVolatileSelector = new SelectorByCloseToCloseVolatility( dataTableMostLiquid , true, currentDate.AddDays(-this.numOfDaysForVolatilityComputation), currentDate, this.maxNumberOfEligibleTickersToBeChosen); DataTable dataTableLessVolatile = lessVolatileSelector.GetTableOfSelectedTickers(); // DataSet dataSet = new DataSet(); // dataSet.Tables.Add( dataTableLessVolatile ); // dataSet.WriteXml( "c:\\qpReports\\pairsTrading\\eligiblesCon_ByPriceMostLiquidLessVolatileOTCAlwaysQuoted.xml" ); SelectorByQuotationAtEachMarketDay quotedAtEachMarketDayFromLastSelection = new SelectorByQuotationAtEachMarketDay( dataTableLessVolatile , false, endOfDayHistory.History, this.maxNumberOfEligibleTickersToBeChosen); DataTable dataTableToBeReturned = quotedAtEachMarketDayFromLastSelection.GetTableOfSelectedTickers(); return new EligibleTickers( dataTableToBeReturned ); } private void getEligibleTickers_sendNewMessage( EligibleTickers eligibleTickers ) { string message = "Number of Eligible tickers: " + eligibleTickers.Count; NewMessageEventArgs newMessageEventArgs = new NewMessageEventArgs( message ); if(this.NewMessage != null) this.NewMessage( this , newMessageEventArgs ); } /// <summary> /// Returns the eligible tickers /// </summary> /// <returns></returns> public EligibleTickers GetEligibleTickers( EndOfDayHistory endOfDayHistory ) { EligibleTickers eligibleTickers = this.getEligibleTickers_actually( endOfDayHistory ); this.getEligibleTickers_sendNewMessage( eligibleTickers ); return eligibleTickers; } } } --- NEW FILE: ByPriceMostLiquidLessVolatileCTOAlwaysQuoted.cs --- /* QuantProject - Quantitative Finance Library ByPriceMostLiquidLessVolatileCTOAlwaysQuoted.cs Copyright (C) 2008 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Data; using QuantProject.ADT.Messaging; using QuantProject.Business.Strategies.ReturnsManagement.Time; using QuantProject.Business.Timing; using QuantProject.Data.Selectors; namespace QuantProject.Business.Strategies.Eligibles { /// <summary> /// Implements IEligiblesSelector for selecting a given max number of tickers through /// the following step-by-step selecting process: /// -step 0: all tickers belonging to a given group /// are selected (the group can be "temporized": that is tickers /// are returned depending on the time the selection is requested: /// the group SP 500 should be like that); /// -step 1: from tickers selected by step 0, the ones that have /// the average raw open price falling in a given range (for the last given number of days) /// are selected; /// -step 2: from tickers selected by step 1, the most liquid /// are selected (not more than maxNumberOfMostLiquidTickersToBeChosen); /// -step 3: from tickers selected by step 2, the ones that are /// less volatile (CTO returns in the last /// numOfDaysForVolatilityComputation days /// are analyzed) are selected /// (not more than maxNumberOfEligibleTickersToBeChosen); /// -step 4: from tickers selected by step 3, the ones that are /// always quoted at all market days are selected /// (not more than maxNumberOfEligibleTickersToBeChosen); /// </summary> public class ByPriceMostLiquidLessVolatileCTOAlwaysQuoted : IEligiblesSelector { public event NewMessageEventHandler NewMessage; private bool temporizedGroup; private string tickersGroupID; private int maxNumberOfEligibleTickersToBeChosen; private int maxNumberOfMostLiquidTickersToBeChosen; private int numOfDaysForAverageOpenRawPriceComputation; private int numOfDaysForVolatilityComputation; private double minPrice; private double maxPrice; public string Description { get{ return "ByPriceMostLiquidLessVolatileCTOAlwaysQuoted"; } } private void byPriceMostLiquidLessVolatileCTOAlwaysQuoted_checkParameters() { if(this.maxNumberOfMostLiquidTickersToBeChosen <= this.maxNumberOfEligibleTickersToBeChosen) throw new Exception("The set of the most liquid tickers has to " + "be greater than the final set of eligibles tickers!"); } public ByPriceMostLiquidLessVolatileCTOAlwaysQuoted( string tickersGroupID , bool temporizedGroup, int maxNumberOfEligibleTickersToBeChosen, int maxNumberOfMostLiquidTickersToBeChosen, int numOfDaysForAverageOpenRawPriceComputation, int numOfDaysForVolatilityComputation, double minPrice, double maxPrice) { this.temporizedGroup = temporizedGroup; this.tickersGroupID = tickersGroupID; this.maxNumberOfEligibleTickersToBeChosen = maxNumberOfEligibleTickersToBeChosen; this.maxNumberOfMostLiquidTickersToBeChosen = maxNumberOfMostLiquidTickersToBeChosen; this.numOfDaysForAverageOpenRawPriceComputation = numOfDaysForAverageOpenRawPriceComputation; this.numOfDaysForVolatilityComputation = numOfDaysForVolatilityComputation; this.minPrice = minPrice; this.maxPrice = maxPrice; this.byPriceMostLiquidLessVolatileCTOAlwaysQuoted_checkParameters(); } private EligibleTickers getEligibleTickers_actually( EndOfDayHistory endOfDayHistory ) { DateTime currentDate = endOfDayHistory.LastEndOfDayDateTime.DateTime; SelectorByGroup group; if(this.temporizedGroup) //the group is "temporized": returned set of tickers // depends on time group = new SelectorByGroup(this.tickersGroupID, currentDate); else//the group is not temporized group = new SelectorByGroup(this.tickersGroupID); DataTable tickersFromGroup = group.GetTableOfSelectedTickers(); int numOfTickersInGroupAtCurrentDate = tickersFromGroup.Rows.Count; SelectorByAverageRawOpenPrice byPrice = new SelectorByAverageRawOpenPrice(tickersFromGroup,false, currentDate.AddDays(-this.numOfDaysForAverageOpenRawPriceComputation), currentDate, numOfTickersInGroupAtCurrentDate, this.minPrice,this.maxPrice, 0.00001, double.MaxValue); DataTable dataTableByPrice = byPrice.GetTableOfSelectedTickers(); SelectorByLiquidity mostLiquidSelector = new SelectorByLiquidity( dataTableByPrice , false, endOfDayHistory.FirstEndOfDayDateTime.DateTime, currentDate, this.maxNumberOfMostLiquidTickersToBeChosen); DataTable dataTableMostLiquid = mostLiquidSelector.GetTableOfSelectedTickers(); SelectorByCloseToOpenVolatility lessVolatileSelector = new SelectorByCloseToOpenVolatility( dataTableMostLiquid , true, currentDate.AddDays(-this.numOfDaysForVolatilityComputation), currentDate, this.maxNumberOfEligibleTickersToBeChosen); DataTable dataTableLessVolatile = lessVolatileSelector.GetTableOfSelectedTickers(); // DataSet dataSet = new DataSet(); // dataSet.Tables.Add( dataTableLessVolatile ); // dataSet.WriteXml( "c:\\qpReports\\pairsTrading\\eligiblesCon_ByPriceMostLiquidLessVolatileCTOAlwaysQuoted.xml" ); SelectorByQuotationAtEachMarketDay quotedAtEachMarketDayFromLastSelection = new SelectorByQuotationAtEachMarketDay( dataTableLessVolatile , false, endOfDayHistory.History, this.maxNumberOfEligibleTickersToBeChosen); DataTable dataTableToBeReturned = quotedAtEachMarketDayFromLastSelection.GetTableOfSelectedTickers(); return new EligibleTickers( dataTableToBeReturned ); } private void getEligibleTickers_sendNewMessage( EligibleTickers eligibleTickers ) { string message = "Number of Eligible tickers: " + eligibleTickers.Count; NewMessageEventArgs newMessageEventArgs = new NewMessageEventArgs( message ); if(this.NewMessage != null) this.NewMessage( this , newMessageEventArgs ); } /// <summary> /// Returns the eligible tickers /// </summary> /// <returns></returns> public EligibleTickers GetEligibleTickers( EndOfDayHistory endOfDayHistory ) { EligibleTickers eligibleTickers = this.getEligibleTickers_actually( endOfDayHistory ); this.getEligibleTickers_sendNewMessage( eligibleTickers ); return eligibleTickers; } } } |
|
From: Marco M. <mi...@us...> - 2008-08-15 00:53:06
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/InSampleChoosers In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv19183/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/InSampleChoosers Modified Files: PVO_CTCCorrelationChooser.cs PVO_OTCCorrelationChooser.cs PVO_OTCCTOCorrelationChooser.cs PVOCorrelationChooser.cs Log Message: Minor changes for the some files implementing the PVO strategy Index: PVO_OTCCorrelationChooser.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/InSampleChoosers/PVO_OTCCorrelationChooser.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PVO_OTCCorrelationChooser.cs 26 Apr 2008 09:53:14 -0000 1.3 --- PVO_OTCCorrelationChooser.cs 14 Aug 2008 23:28:06 -0000 1.4 *************** *** 61,70 **** bool balancedWeightsOnVolatilityBase, float minimumAbsoluteReturnValue, ! float maximumAbsoluteReturnValue) : base(numberOfBestTestingPositionsToBeReturned, 1, maxCorrelationValue, balancedWeightsOnVolatilityBase, ! IntervalsType.DailyOpenToCloseIntervals) { this.minimumAbsoluteReturnValue = minimumAbsoluteReturnValue; --- 61,72 ---- bool balancedWeightsOnVolatilityBase, float minimumAbsoluteReturnValue, ! float maximumAbsoluteReturnValue, ! string benchmark) : base(numberOfBestTestingPositionsToBeReturned, 1, maxCorrelationValue, balancedWeightsOnVolatilityBase, ! IntervalsType.OpenToCloseIntervals, ! benchmark) { this.minimumAbsoluteReturnValue = minimumAbsoluteReturnValue; Index: PVOCorrelationChooser.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/InSampleChoosers/PVOCorrelationChooser.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PVOCorrelationChooser.cs 26 Apr 2008 09:41:26 -0000 1.5 --- PVOCorrelationChooser.cs 14 Aug 2008 23:28:06 -0000 1.6 *************** *** 54,57 **** --- 54,58 ---- protected bool balancedWeightsOnVolatilityBase; protected IntervalsType intervalsType; + protected string benchmark; public virtual string Description *************** *** 78,81 **** --- 79,90 ---- } + public int ReturnIntervalLength + { + get + { + return this.numDaysForOscillatingPeriod; + } + } + /// <summary> /// PVOCorrelationChooser to be used for *************** *** 99,103 **** double maxCorrelationValue, bool balancedWeightsOnVolatilityBase, ! IntervalsType intervalsType) { this.numberOfBestTestingPositionsToBeReturned = numberOfBestTestingPositionsToBeReturned; --- 108,113 ---- double maxCorrelationValue, bool balancedWeightsOnVolatilityBase, ! IntervalsType intervalsType, ! string benchmark) { this.numberOfBestTestingPositionsToBeReturned = numberOfBestTestingPositionsToBeReturned; *************** *** 106,109 **** --- 116,120 ---- this.balancedWeightsOnVolatilityBase = balancedWeightsOnVolatilityBase; this.intervalsType = intervalsType; + this.benchmark = benchmark; } Index: PVO_OTCCTOCorrelationChooser.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/InSampleChoosers/PVO_OTCCTOCorrelationChooser.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PVO_OTCCTOCorrelationChooser.cs 26 Apr 2008 09:17:47 -0000 1.1 --- PVO_OTCCTOCorrelationChooser.cs 14 Aug 2008 23:28:06 -0000 1.2 *************** *** 61,70 **** bool balancedWeightsOnVolatilityBase, float minimumAbsoluteReturnValue, ! float maximumAbsoluteReturnValue) : base(numberOfBestTestingPositionsToBeReturned, 1, maxCorrelationValue, balancedWeightsOnVolatilityBase, ! IntervalsType.OpenToCloseCloseToOpenIntervals) { this.minimumAbsoluteReturnValue = minimumAbsoluteReturnValue; --- 61,72 ---- bool balancedWeightsOnVolatilityBase, float minimumAbsoluteReturnValue, ! float maximumAbsoluteReturnValue, ! string benchmark) : base(numberOfBestTestingPositionsToBeReturned, 1, maxCorrelationValue, balancedWeightsOnVolatilityBase, ! IntervalsType.OpenToCloseCloseToOpenIntervals, ! benchmark) { this.minimumAbsoluteReturnValue = minimumAbsoluteReturnValue; Index: PVO_CTCCorrelationChooser.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/InSampleChoosers/PVO_CTCCorrelationChooser.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PVO_CTCCorrelationChooser.cs 26 Apr 2008 09:53:14 -0000 1.3 --- PVO_CTCCorrelationChooser.cs 14 Aug 2008 23:28:06 -0000 1.4 *************** *** 44,47 **** --- 44,52 ---- public class PVO_CTCCorrelationChooser : PVOCorrelationChooser { + private float minimumAbsoluteReturnValue; + private float maximumAbsoluteReturnValue; + //correlation is computed only for returns + //between minimum and maximum + /// <summary> /// PVO_CTCCorrelationChooser to be used for *************** *** 55,66 **** int closeToCloseReturnIntervalLength, double maxCorrelationValue, ! bool balancedWeightsOnVolatilityBase) : base(numberOfBestTestingPositionsToBeReturned, closeToCloseReturnIntervalLength, maxCorrelationValue, balancedWeightsOnVolatilityBase, ! IntervalsType.CloseToCloseIntervals_OneDay) { ! } --- 60,76 ---- int closeToCloseReturnIntervalLength, double maxCorrelationValue, ! bool balancedWeightsOnVolatilityBase, ! float minimumAbsoluteReturnValue, ! float maximumAbsoluteReturnValue, ! string benchmark) : base(numberOfBestTestingPositionsToBeReturned, closeToCloseReturnIntervalLength, maxCorrelationValue, balancedWeightsOnVolatilityBase, ! IntervalsType.CloseToCloseIntervals, ! benchmark) { ! this.minimumAbsoluteReturnValue = minimumAbsoluteReturnValue; ! this.maximumAbsoluteReturnValue = maximumAbsoluteReturnValue; } *************** *** 73,77 **** new CloseToCloseCorrelationProvider(eligibleTickers.Tickers, firstDate, lastDate, this.numDaysForOscillatingPeriod, ! 0.0001f, 0.5f, "^GSPC"); } } --- 83,89 ---- new CloseToCloseCorrelationProvider(eligibleTickers.Tickers, firstDate, lastDate, this.numDaysForOscillatingPeriod, ! this.minimumAbsoluteReturnValue, ! this.maximumAbsoluteReturnValue, ! this.benchmark); } } |
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv19721/b7_Scripts/TickerSelectionTesting Modified Files: EndOfDayTimerHandler.cs EndOfDayTimerHandlerOTC.cs EndOfDayTimerHandlerOTCTest.cs RunEfficientOTCPortfolio.cs Log Message: Minor changes for the old files implementing the OTC strategy Index: EndOfDayTimerHandlerOTCTest.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerOTCTest.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** EndOfDayTimerHandlerOTCTest.cs 7 Jan 2006 10:35:39 -0000 1.1 --- EndOfDayTimerHandlerOTCTest.cs 14 Aug 2008 23:29:40 -0000 1.2 *************** *** 53,57 **** PortfolioType portfolioType, int numDaysBetweenEachOptimization): base(tickerGroupID, numberOfEligibleTickers, ! numberOfTickersToBeChosen, numDaysForLiquidity, account, generationNumberForGeneticOptimizer, populationSizeForGeneticOptimizer, --- 53,57 ---- PortfolioType portfolioType, int numDaysBetweenEachOptimization): base(tickerGroupID, numberOfEligibleTickers, ! numberOfTickersToBeChosen, 10, numDaysForLiquidity, account, generationNumberForGeneticOptimizer, populationSizeForGeneticOptimizer, Index: EndOfDayTimerHandler.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandler.cs,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** EndOfDayTimerHandler.cs 12 Mar 2008 22:09:05 -0000 1.27 --- EndOfDayTimerHandler.cs 14 Aug 2008 23:29:40 -0000 1.28 *************** *** 91,95 **** } private void endOfDayTimerHandler_initializeBasic(string tickerGroupID, int numberOfEligibleTickers, ! int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, int generationNumberForGeneticOptimizer, int populationSizeForGeneticOptimizer, --- 91,96 ---- } private void endOfDayTimerHandler_initializeBasic(string tickerGroupID, int numberOfEligibleTickers, ! int numberOfTickersToBeChosen, ! int numDaysForOptimizationPeriod, int generationNumberForGeneticOptimizer, int populationSizeForGeneticOptimizer, *************** *** 108,112 **** } public EndOfDayTimerHandler(string tickerGroupID, int numberOfEligibleTickers, ! int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, Account account, int generationNumberForGeneticOptimizer, int populationSizeForGeneticOptimizer, --- 109,114 ---- } public EndOfDayTimerHandler(string tickerGroupID, int numberOfEligibleTickers, ! int numberOfTickersToBeChosen, ! int numDaysForOptimizationPeriod, Account account, int generationNumberForGeneticOptimizer, int populationSizeForGeneticOptimizer, *************** *** 115,119 **** { this.endOfDayTimerHandler_initializeBasic(tickerGroupID, numberOfEligibleTickers, ! numberOfTickersToBeChosen, numDaysForOptimizationPeriod, generationNumberForGeneticOptimizer, populationSizeForGeneticOptimizer, --- 117,122 ---- { this.endOfDayTimerHandler_initializeBasic(tickerGroupID, numberOfEligibleTickers, ! numberOfTickersToBeChosen, ! numDaysForOptimizationPeriod, generationNumberForGeneticOptimizer, populationSizeForGeneticOptimizer, *************** *** 124,128 **** } public EndOfDayTimerHandler(string tickerGroupID, int numberOfEligibleTickers, ! int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, int generationNumberForGeneticOptimizer, int populationSizeForGeneticOptimizer, --- 127,132 ---- } public EndOfDayTimerHandler(string tickerGroupID, int numberOfEligibleTickers, ! int numberOfTickersToBeChosen, ! int numDaysForOptimizationPeriod, int generationNumberForGeneticOptimizer, int populationSizeForGeneticOptimizer, *************** *** 131,135 **** { this.endOfDayTimerHandler_initializeBasic(tickerGroupID, numberOfEligibleTickers, ! numberOfTickersToBeChosen, numDaysForOptimizationPeriod, generationNumberForGeneticOptimizer, populationSizeForGeneticOptimizer, --- 135,140 ---- { this.endOfDayTimerHandler_initializeBasic(tickerGroupID, numberOfEligibleTickers, ! numberOfTickersToBeChosen, ! numDaysForOptimizationPeriod, generationNumberForGeneticOptimizer, populationSizeForGeneticOptimizer, *************** *** 211,214 **** --- 216,237 ---- halfPeriodDays, portfolioType)); } + + protected void addGenomesToBestGenomes( Genome[] genomes, + DateTime firstOptimizationDate, + DateTime secondOptimizationDate, + int eligibleTickers, int halfPeriodDays, + PortfolioType portfolioType, + int createdGenerations) + { + foreach(Genome genome in genomes) + if(genome != null) + this.addGenomeToBestGenomes(genome, + firstOptimizationDate, + secondOptimizationDate, + eligibleTickers, halfPeriodDays, + portfolioType, + createdGenerations); + } + protected void addGenomeToBestGenomes(Genome genome, DateTime firstOptimizationDate, Index: EndOfDayTimerHandlerOTC.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerOTC.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** EndOfDayTimerHandlerOTC.cs 14 Jan 2008 23:32:31 -0000 1.7 --- EndOfDayTimerHandlerOTC.cs 14 Aug 2008 23:29:40 -0000 1.8 *************** *** 46,52 **** { protected int seedForRandomGenerator; ! public EndOfDayTimerHandlerOTC(string tickerGroupID, int numberOfEligibleTickers, ! int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, Account account, int generationNumberForGeneticOptimizer, int populationSizeForGeneticOptimizer, --- 46,55 ---- { protected int seedForRandomGenerator; ! private int numberOfGenomesToSaveForEachOptimization; ! public EndOfDayTimerHandlerOTC(string tickerGroupID, int numberOfEligibleTickers, ! int numberOfTickersToBeChosen, ! int numberOfGenomesToSaveForEachOptimization, ! int numDaysForOptimizationPeriod, Account account, int generationNumberForGeneticOptimizer, int populationSizeForGeneticOptimizer, *************** *** 61,64 **** --- 64,68 ---- { this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; + this.numberOfGenomesToSaveForEachOptimization = numberOfGenomesToSaveForEachOptimization; this.numDaysElapsedSinceLastOptimization = 0; this.seedForRandomGenerator = ConstantsProvider.SeedForRandomGenerator; *************** *** 106,122 **** currentDate, this.numberOfEligibleTickers, ! 35); DataTable tickersByPrice = byPrice.GetTableOfSelectedTickers(); ! SelectorByOpenCloseCorrelationToBenchmark tickersLessCorrelatedToBenchmark = ! new SelectorByOpenCloseCorrelationToBenchmark(tickersByPrice, ! "^GSPC",true, ! currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, ! tickersByPrice.Rows.Count/2); ! return tickersLessCorrelatedToBenchmark.GetTableOfSelectedTickers(); } ! protected virtual void setTickers(DateTime currentDate, bool setGenomeCounter) --- 110,134 ---- currentDate, this.numberOfEligibleTickers, ! 25); DataTable tickersByPrice = byPrice.GetTableOfSelectedTickers(); ! SelectorByAverageOpenToClosePerformance tickersByOTCPerformance = ! new SelectorByAverageOpenToClosePerformance(tickersByPrice, ! false, currentDate.AddDays(-15), ! currentDate, 0.05, ! this.numberOfEligibleTickers); ! ! return tickersByOTCPerformance.GetTableOfSelectedTickers(); ! // SelectorByOpenCloseCorrelationToBenchmark tickersLessCorrelatedToBenchmark = ! // new SelectorByOpenCloseCorrelationToBenchmark(tickersByOTCPerformance.GetTableOfSelectedTickers(), ! // "^GSPC",true, ! // currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, ! // tickersByPrice.Rows.Count/2); ! // ! // return tickersLessCorrelatedToBenchmark.GetTableOfSelectedTickers(); } ! protected virtual void setTickers(DateTime currentDate, bool setGenomeCounter) *************** *** 153,164 **** GO.MutationRate = 0.10; GO.Run(false); ! this.addGenomeToBestGenomes( ! GO.BestGenome, ! currentDate.AddDays(-this.numDaysForOptimizationPeriod), ! currentDate, ! setOfTickersToBeOptimized.Rows.Count, ! -1, ! this.portfolioType, ! GO.GenerationCounter); this.chosenWeightedPositions = new WeightedPositions( ((GenomeMeaning)GO.BestGenome.Meaning).TickersPortfolioWeights, new SignedTickers( ((GenomeMeaning)GO.BestGenome.Meaning).Tickers) ); --- 165,199 ---- GO.MutationRate = 0.10; GO.Run(false); ! int populationSize = GO.PopulationSize; ! Genome[] genomesForLog = ! new Genome[this.numberOfGenomesToSaveForEachOptimization]; ! int numOfGenomesAdded = 0; ! double fitnessOfPreviousCombination = 0.0; ! for(int i = 0; ! numOfGenomesAdded < this.numberOfGenomesToSaveForEachOptimization && ! i < populationSize - 1; ! i++) ! { ! if( i == 0 || ! ( ((Genome)GO.CurrentGeneration[populationSize - i - 1]).Fitness < ! fitnessOfPreviousCombination ) ) ! //it is the best genome or the current genome is different from - and ! //so it has to be strictly less of - the previous scanned genome ! { ! fitnessOfPreviousCombination = ! ((Genome)GO.CurrentGeneration[populationSize - i - 1]).Fitness; ! genomesForLog[numOfGenomesAdded] = ! (Genome)GO.CurrentGeneration[populationSize - i - 1]; ! numOfGenomesAdded++; ! } ! } ! this.addGenomesToBestGenomes( ! genomesForLog, ! currentDate.AddDays(-this.numDaysForOptimizationPeriod), ! currentDate, ! setOfTickersToBeOptimized.Rows.Count, ! -1, ! this.portfolioType, ! GO.GenerationCounter); this.chosenWeightedPositions = new WeightedPositions( ((GenomeMeaning)GO.BestGenome.Meaning).TickersPortfolioWeights, new SignedTickers( ((GenomeMeaning)GO.BestGenome.Meaning).Tickers) ); Index: RunEfficientOTCPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunEfficientOTCPortfolio.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RunEfficientOTCPortfolio.cs 29 Aug 2007 10:04:27 -0000 1.3 --- RunEfficientOTCPortfolio.cs 14 Aug 2008 23:29:40 -0000 1.4 *************** *** 102,105 **** --- 102,106 ---- this.numberOfEligibleTickers, this.numberOfTickersToBeChosen, + 10, this.numDaysForOptimizationPeriod, this.account, |
|
From: Marco M. <mi...@us...> - 2008-08-14 23:44:47
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv26437/b7_Scripts Modified Files: b7_Scripts.csproj Scripts_SD.csproj Log Message: Updated SD project's files Index: Scripts_SD.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/Scripts_SD.csproj,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** Scripts_SD.csproj 17 May 2008 14:54:48 -0000 1.28 --- Scripts_SD.csproj 14 Aug 2008 23:44:43 -0000 1.29 *************** *** 74,79 **** --- 74,82 ---- <Compile Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\InSampleChoosers\PVOGeneticChooser.cs" /> <Compile Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\InSampleChoosers\PVO_CTCCorrelationChooser.cs" /> + <Compile Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\InSampleChoosers\PVO_CTCStrongCorrelationChooser.cs" /> + <Compile Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\InSampleChoosers\PVO_CTOCorrelationChooser.cs" /> <Compile Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\InSampleChoosers\PVO_OTCCorrelationChooser.cs" /> <Compile Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\InSampleChoosers\PVO_OTCCTOCorrelationChooser.cs" /> + <Compile Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\InSampleChoosers\PVO_OTOCorrelationChooser.cs" /> <Compile Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\PVOGenomeManager.cs" /> <Compile Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\PVOLogItem.cs" /> *************** *** 82,85 **** --- 85,91 ---- <Compile Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\PVOPositionsStatus.cs" /> <Compile Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\PVOStrategy.cs" /> + <Compile Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\PVO_CTOLogItem.cs" /> + <Compile Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\PVO_CTOMain.cs" /> + <Compile Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\PVO_CTOStrategy.cs" /> <Compile Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\PVO_OTCLogItem.cs" /> <Compile Include="TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\PVO_OTCMain.cs" /> Index: b7_Scripts.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/b7_Scripts.csproj,v retrieving revision 1.98 retrieving revision 1.99 diff -C2 -d -r1.98 -r1.99 *** b7_Scripts.csproj 11 May 2008 18:59:13 -0000 1.98 --- b7_Scripts.csproj 14 Aug 2008 23:44:43 -0000 1.99 *************** *** 340,343 **** --- 340,358 ---- /> <File + RelPath = "TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\PVO_CTOLogItem.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\PVO_CTOMain.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\PVO_CTOStrategy.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\PVO_OTCLogItem.cs" SubType = "Code" *************** *** 430,433 **** --- 445,453 ---- /> <File + RelPath = "TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\InSampleChoosers\PVO_CTOCorrelationChooser.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\InSampleChoosers\PVO_OTCCorrelationChooser.cs" SubType = "Code" *************** *** 440,443 **** --- 460,468 ---- /> <File + RelPath = "TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\InSampleChoosers\PVO_OTOCorrelationChooser.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\InSampleChoosers\PVOChooserFromSavedBackTestLog.cs" SubType = "Code" |
|
From: Marco M. <mi...@us...> - 2008-08-14 23:44:46
|
Update of /cvsroot/quantproject/QuantProject/b4_Business In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv26437/b4_Business Modified Files: b4_Business.csproj Business_SD.csproj Log Message: Updated SD project's files Index: Business_SD.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/Business_SD.csproj,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** Business_SD.csproj 25 May 2008 16:00:28 -0000 1.27 --- Business_SD.csproj 14 Aug 2008 23:44:43 -0000 1.28 *************** *** 75,78 **** --- 75,80 ---- <Compile Include="a2_Strategies\Benchmark.cs" /> <Compile Include="a2_Strategies\Eligibles\ByPriceLessVolatileOTCAlwaysQuoted.cs" /> + <Compile Include="a2_Strategies\Eligibles\ByPriceMostLiquidLessVolatileCTCAlwaysQuoted.cs" /> + <Compile Include="a2_Strategies\Eligibles\ByPriceMostLiquidLessVolatileCTOAlwaysQuoted.cs" /> <Compile Include="a2_Strategies\Eligibles\ByPriceMostLiquidLessVolatileOTCAlwaysQuoted.cs" /> <Compile Include="a2_Strategies\Eligibles\DummyEligibleSelector.cs" /> *************** *** 112,115 **** --- 114,118 ---- <Compile Include="a2_Strategies\returnsManagement\time\IntervalsType.cs" /> <Compile Include="a2_Strategies\returnsManagement\time\OpenToCloseCloseToOpenIntervals.cs" /> + <Compile Include="a2_Strategies\returnsManagement\time\OpenToOpenIntervals.cs" /> <Compile Include="a2_Strategies\returnsManagement\time\ReturnInterval.cs" /> <Compile Include="a2_Strategies\returnsManagement\time\ReturnIntervals.cs" /> *************** *** 119,126 **** --- 122,131 ---- <Compile Include="a2_Strategies\returnsManagement\time\selectors\OddIntervalsSelector.cs" /> <Compile Include="a2_Strategies\TickersRelationships\CloseToCloseCorrelationProvider.cs" /> + <Compile Include="a2_Strategies\TickersRelationships\CloseToOpenCorrelationProvider.cs" /> <Compile Include="a2_Strategies\TickersRelationships\CorrelationProvider.cs" /> <Compile Include="a2_Strategies\TickersRelationships\MissingCorrelationException.cs" /> <Compile Include="a2_Strategies\TickersRelationships\OpenToCloseCloseToOpenCorrelationProvider.cs" /> <Compile Include="a2_Strategies\TickersRelationships\OpenToCloseCorrelationProvider.cs" /> + <Compile Include="a2_Strategies\TickersRelationships\OpenToOpenCorrelationProvider.cs" /> <Compile Include="a2_Strategies\TickersRelationships\TickersPearsonCorrelation.cs" /> <Compile Include="a4_Scripting\IExecutable.cs" /> Index: b4_Business.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/b4_Business.csproj,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** b4_Business.csproj 17 May 2008 18:02:48 -0000 1.69 --- b4_Business.csproj 14 Aug 2008 23:44:42 -0000 1.70 *************** *** 740,743 **** --- 740,753 ---- /> <File + RelPath = "a2_Strategies\Eligibles\ByPriceMostLiquidLessVolatileCTCAlwaysQuoted.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "a2_Strategies\Eligibles\ByPriceMostLiquidLessVolatileCTOAlwaysQuoted.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "a2_Strategies\Eligibles\ByPriceMostLiquidLessVolatileOTCAlwaysQuoted.cs" SubType = "Code" *************** *** 935,938 **** --- 945,953 ---- /> <File + RelPath = "a2_Strategies\returnsManagement\time\OpenToOpenIntervals.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "a2_Strategies\returnsManagement\time\ReturnInterval.cs" SubType = "Code" *************** *** 970,973 **** --- 985,993 ---- /> <File + RelPath = "a2_Strategies\TickersRelationships\CloseToOpenCorrelationProvider.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "a2_Strategies\TickersRelationships\CorrelationProvider.cs" SubType = "Code" *************** *** 990,993 **** --- 1010,1018 ---- /> <File + RelPath = "a2_Strategies\TickersRelationships\OpenToOpenCorrelationProvider.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "a2_Strategies\TickersRelationships\TickersPearsonCorrelation.cs" SubType = "Code" |
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/InSampleChoosers In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv25974/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/InSampleChoosers Added Files: PVO_CTOCorrelationChooser.cs PVO_OTOCorrelationChooser.cs Log Message: Added choosers for the PVO strategy based on CTO and OTO (OpenToOpen) correlations --- NEW FILE: PVO_CTOCorrelationChooser.cs --- /* QuantProject - Quantitative Finance Library PVO_CTOCorrelationChooser.cs Copyright (C) 2008 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Collections; using QuantProject.ADT; using QuantProject.ADT.Messaging; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.TickersRelationships; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Strategies.ReturnsManagement.Time; using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator.InSampleChoosers; namespace QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator.InSampleChoosers { /// <summary> /// PVO_CTOCorrelationChooser to be used for /// in sample optimization /// By means of correlation, the AnalyzeInSample method returns the /// requested number of PVOPositions (positions for the PVO strategy) /// </summary> public class PVO_CTOCorrelationChooser : PVOCorrelationChooser { private float minimumAbsoluteReturnValue; private float maximumAbsoluteReturnValue; //correlation is computed only for returns //between minimum and maximum /// <summary> /// PVO_CTOCorrelationChooser to be used for /// in sample optimization /// </summary> /// <param name="numberOfBestTestingPositionsToBeReturned"> /// The number of PVOPositions that the /// AnalyzeInSample method will return /// </param> public PVO_CTOCorrelationChooser(int numberOfBestTestingPositionsToBeReturned, double maxCorrelationValue, bool balancedWeightsOnVolatilityBase, float minimumAbsoluteReturnValue, float maximumAbsoluteReturnValue, string benchmark) : base(numberOfBestTestingPositionsToBeReturned, 1, maxCorrelationValue, balancedWeightsOnVolatilityBase, IntervalsType.CloseToOpenIntervals, benchmark) { this.minimumAbsoluteReturnValue = minimumAbsoluteReturnValue; this.maximumAbsoluteReturnValue = maximumAbsoluteReturnValue; } protected override void setCorrelationProvider(EligibleTickers eligibleTickers , ReturnsManager returnsManager) { this.correlationProvider = new CloseToOpenCorrelationProvider(eligibleTickers.Tickers, returnsManager, this.minimumAbsoluteReturnValue , this.maximumAbsoluteReturnValue); } } } --- NEW FILE: PVO_OTOCorrelationChooser.cs --- /* QuantProject - Quantitative Finance Library PVO_OTOCorrelationChooser.cs Copyright (C) 2008 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Collections; using QuantProject.ADT; using QuantProject.ADT.Messaging; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.TickersRelationships; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Strategies.ReturnsManagement.Time; using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator.InSampleChoosers; namespace QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator.InSampleChoosers { /// <summary> /// PVO_OTOCorrelationChooser to be used for /// in sample optimization /// By means of correlation, the AnalyzeInSample method returns the /// requested number of PVOPositions (positions for the PVO strategy) /// </summary> public class PVO_OTOCorrelationChooser : PVOCorrelationChooser { private float minimumAbsoluteReturnValue; private float maximumAbsoluteReturnValue; //correlation is computed only for returns //between minimum and maximum /// <summary> /// PVO_OTOCorrelationChooser to be used for /// in sample optimization /// </summary> /// <param name="numberOfBestTestingPositionsToBeReturned"> /// The number of PVOPositions that the /// AnalyzeInSample method will return /// </param> public PVO_OTOCorrelationChooser(int numberOfBestTestingPositionsToBeReturned, int openToOpenReturnIntervalLength, double maxCorrelationValue, bool balancedWeightsOnVolatilityBase, float minimumAbsoluteReturnValue, float maximumAbsoluteReturnValue, string benchmark) : base(numberOfBestTestingPositionsToBeReturned, openToOpenReturnIntervalLength, maxCorrelationValue, balancedWeightsOnVolatilityBase, IntervalsType.OpenToOpenIntervals, benchmark) { this.minimumAbsoluteReturnValue = minimumAbsoluteReturnValue; this.maximumAbsoluteReturnValue = maximumAbsoluteReturnValue; } protected override void setCorrelationProvider(EligibleTickers eligibleTickers , ReturnsManager returnsManager) { DateTime firstDate = returnsManager.ReturnIntervals[0].Begin.DateTime; DateTime lastDate = returnsManager.ReturnIntervals.LastEndOfDayDateTime.DateTime; this.correlationProvider = new OpenToOpenCorrelationProvider(eligibleTickers.Tickers, firstDate, lastDate, this.numDaysForOscillatingPeriod, minimumAbsoluteReturnValue, maximumAbsoluteReturnValue, this.benchmark); } } } |
|
From: Marco M. <mi...@us...> - 2008-08-14 23:41:53
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/InSampleChoosers In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv25144/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/InSampleChoosers Added Files: PVO_CTCStrongCorrelationChooser.cs Log Message: Added PVO_CTCStrongCorrelationChooser. Strong correlation is defined as the average CTC correlation at 1, 2 and 3 days. --- NEW FILE: PVO_CTCStrongCorrelationChooser.cs --- /* QuantProject - Quantitative Finance Library PVO_CTCStrongCorrelationChooser.cs Copyright (C) 2008 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Collections; using QuantProject.ADT; using QuantProject.ADT.Messaging; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.InSample; using QuantProject.Business.Strategies.TickersRelationships; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Strategies.ReturnsManagement.Time; using QuantProject.Business.Strategies.OutOfSample; namespace QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator.InSampleChoosers { /// <summary> /// PVO_CTCStrongCorrelationChooser to be used for /// in sample optimization /// By means of correlation, the AnalyzeInSample method returns the /// requested number of PVOPositions (positions for the PVO strategy) /// </summary> public class PVO_CTCStrongCorrelationChooser : IInSampleChooser { public event NewProgressEventHandler NewProgress; public event NewMessageEventHandler NewMessage; protected int numberOfBestTestingPositionsToBeReturned; protected int numDaysForOscillatingPeriod; protected double maxCorrelationValue; //correlations greater than this value are discarded private float minimumAbsoluteReturnValue; private float maximumAbsoluteReturnValue; //tickers'returns out of these limits are discarded protected bool balancedWeightsOnVolatilityBase; protected IntervalsType intervalsType; protected string benchmark; public virtual string Description { get { string description = "StrongCTCCrrltChsr"; return description; } } public IntervalsType IntervalsType { get { return this.intervalsType; } } public int ReturnIntervalLength { get { return this.numDaysForOscillatingPeriod; } } /// <summary> /// PVO_CTCStrongCorrelationChooser to be used for /// in sample optimization /// In this implementation, PVOPositions with the highest /// strong correlation are returned. /// Strong correlation is defined as the average /// CTC correlation at 1, 2 and 3 days. /// </summary> /// <param name="numberOfBestTestingPositionsToBeReturned"> /// The number of PVOPositions that the /// AnalyzeInSample method will return /// </param> /// <param name="numDaysForOscillatingPeriod"> /// Interval's length of the return for the PVOPosition /// to be checked out of sample, in order to update the /// status for the PVOPosition itself /// </param> /// <param name="maxCorrelationValue"> /// Correlations higher than given maxCorrelationValue are discarded /// (for avoiding analyzing tickers corresponding to the same stock) /// </param> public PVO_CTCStrongCorrelationChooser(int numberOfBestTestingPositionsToBeReturned, double maxCorrelationValue, float minimumAbsoluteReturnValue, float maximumAbsoluteReturnValue, bool balancedWeightsOnVolatilityBase, string benchmark) { this.numberOfBestTestingPositionsToBeReturned = numberOfBestTestingPositionsToBeReturned; this.numDaysForOscillatingPeriod = 1; this.maxCorrelationValue = maxCorrelationValue; this.minimumAbsoluteReturnValue = minimumAbsoluteReturnValue; this.maximumAbsoluteReturnValue = maximumAbsoluteReturnValue; this.balancedWeightsOnVolatilityBase = balancedWeightsOnVolatilityBase; this.intervalsType = IntervalsType.CloseToCloseIntervals; this.benchmark = benchmark; } #region AnalyzeInSample private void analyzeInSample_checkParameters( EligibleTickers eligibleTickers , ReturnsManager returnsManager ) { if ( eligibleTickers.Count < 2 ) throw new Exception( "Eligible tickers for driving positions contains " + "only " + eligibleTickers.Count + " elements, while NumberOfDrivingPositions is 2"); if (this.maxCorrelationValue < 0.0 || this.maxCorrelationValue > 1.0 ) throw new OutOfRangeException( "maxCorrelationValue", 0.0, 1.0); } protected PVOPositions getTestingPositions(SignedTickers signedTickers, ReturnsManager returnsManager) { WeightedPositions weightedPositions; if(this.balancedWeightsOnVolatilityBase == true) weightedPositions = new WeightedPositions(WeightedPositions.GetBalancedWeights(signedTickers, returnsManager), signedTickers.Tickers); else//just equal weights weightedPositions = new WeightedPositions(signedTickers); return new PVOPositions(weightedPositions, 0.0, 0.0, this.numDaysForOscillatingPeriod ); } private TickersPearsonCorrelation[] getBestTestingPositionsInSample_getAverageCorrelationsAt1_2_3_Days( EligibleTickers eligibleTickers , ReturnsManager returnsManager ) { TickersPearsonCorrelation[] averageCorrelations; TickersPearsonCorrelation[] correlations_1Day; DateTime firstDate = returnsManager.ReturnIntervals[0].Begin.DateTime; DateTime lastDate = returnsManager.ReturnIntervals.LastEndOfDayDateTime.DateTime; CloseToCloseCorrelationProvider correlationProviderCTC_1 = new CloseToCloseCorrelationProvider(eligibleTickers.Tickers, firstDate, lastDate, 1 , this.minimumAbsoluteReturnValue, this.maximumAbsoluteReturnValue, this.benchmark); CloseToCloseCorrelationProvider correlationProviderCTC_2 = new CloseToCloseCorrelationProvider(eligibleTickers.Tickers, firstDate, lastDate, 2 , this.minimumAbsoluteReturnValue, this.maximumAbsoluteReturnValue, this.benchmark); CloseToCloseCorrelationProvider correlationProviderCTC_3 = new CloseToCloseCorrelationProvider(eligibleTickers.Tickers, firstDate, lastDate, 3 , this.minimumAbsoluteReturnValue, this.maximumAbsoluteReturnValue, this.benchmark); correlations_1Day = correlationProviderCTC_1.GetOrderedTickersPearsonCorrelations(); averageCorrelations = correlations_1Day; for(int i = 0; i<averageCorrelations.Length; i++) { averageCorrelations[i].CorrelationValue = ( averageCorrelations[i].CorrelationValue + correlationProviderCTC_2.GetPearsonCorrelation( averageCorrelations[i].FirstTicker,averageCorrelations[i].SecondTicker) + correlationProviderCTC_3.GetPearsonCorrelation( averageCorrelations[i].FirstTicker,averageCorrelations[i].SecondTicker) ) / 3.0; } Array.Sort(averageCorrelations); return averageCorrelations; } private TestingPositions[] getBestTestingPositionsInSample( EligibleTickers eligibleTickers , ReturnsManager returnsManager ) { //this.setCorrelationProvider(eligibleTickers , returnsManager); TestingPositions[] bestTestingPositions = new TestingPositions[this.numberOfBestTestingPositionsToBeReturned]; TickersPearsonCorrelation[] averageCorrelations = this.getBestTestingPositionsInSample_getAverageCorrelationsAt1_2_3_Days( eligibleTickers , returnsManager); int addedTestingPositions = 0; int counter = 0; while(addedTestingPositions < this.numberOfBestTestingPositionsToBeReturned && counter < averageCorrelations.Length) { if(averageCorrelations[averageCorrelations.Length - 1 - counter].CorrelationValue < this.maxCorrelationValue) { SignedTickers signedTickers = new SignedTickers("-"+averageCorrelations[averageCorrelations.Length - 1 - counter].FirstTicker + ";" + averageCorrelations[averageCorrelations.Length - 1 - counter].SecondTicker); bestTestingPositions[addedTestingPositions] = this.getTestingPositions(signedTickers, returnsManager); ((PVOPositions)bestTestingPositions[addedTestingPositions]).FitnessInSample = averageCorrelations[averageCorrelations.Length - 1 - counter].CorrelationValue; addedTestingPositions++; } counter++; } return bestTestingPositions; } /// <summary> /// Returns the best TestingPositions with respect to the in sample data /// </summary> /// <param name="eligibleTickers"></param> /// <returns></returns> public object AnalyzeInSample( EligibleTickers eligibleTickers , ReturnsManager returnsManager ) { if ( this.NewMessage != null ) this.NewMessage( this , new NewMessageEventArgs( "New Correlation Analysis" ) ); if ( this.NewProgress != null ) this.NewProgress( this , new NewProgressEventArgs( 1 , 1 ) ); this.analyzeInSample_checkParameters( eligibleTickers , returnsManager ); TestingPositions[] bestTestingPositionsInSample = this.getBestTestingPositionsInSample( eligibleTickers , returnsManager ); return bestTestingPositionsInSample; } #endregion } } |
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv23698/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator Added Files: PVO_CTOLogItem.cs PVO_CTOMain.cs PVO_CTOStrategy.cs Log Message: Added PVO_CTO strategy (PVO by night) --- NEW FILE: PVO_CTOLogItem.cs --- /* QuantProject - Quantitative Finance Library PVO_CTOLogItem.cs Copyright (C) 2008 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.Business.DataProviders; using QuantProject.Business.Strategies; using QuantProject.Business.Financial.Accounting.AccountProviding; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.InSample; using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Strategies.Logging; using QuantProject.Business.Strategies.ReturnsManagement.Time; using QuantProject.Business.Strategies.ReturnsManagement.Time.IntervalsSelectors; using QuantProject.Business.Timing; using QuantProject.Scripts.General.Reporting; namespace QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator { /// <summary> /// LogItem for the PVO_CTO strategy /// portfolio value oscillator strategy /// </summary> [Serializable] public class PVO_CTOLogItem : PVOLogItem { public PVO_CTOLogItem(EndOfDayDateTime endOfDayDateTime, int numberOfInSampleDays) : base( endOfDayDateTime , numberOfInSampleDays ) { } protected override void runStrategyClickEventHandler(object sender, System.EventArgs e) { //general int inSampleDays = 90; DateTime firstDateTime = this.SimulatedCreationTime.DateTime.AddDays(-inSampleDays); DateTime lastDateTime = this.SimulatedCreationTime.DateTime; double maxRunningHours = 1; Benchmark benchmark = new Benchmark( "^GSPC" ); // definition for the Fitness Evaluator (for // objects that use it) int numberOfPortfolioPositions = this.BestPVOPositionsInSample[0].WeightedPositions.Count; //cash and portfolio type double cashToStart = 25000; HistoricalQuoteProvider historicalQuoteProviderForBackTester, historicalQuoteProviderForInSampleChooser, historicalQuoteProviderForStrategy; historicalQuoteProviderForBackTester = new HistoricalAdjustedQuoteProvider(); historicalQuoteProviderForInSampleChooser = historicalQuoteProviderForBackTester; historicalQuoteProviderForStrategy = historicalQuoteProviderForInSampleChooser; IEligiblesSelector eligiblesSelector = new DummyEligibleSelector(); //strategyParameters TestingPositions[] positionsToTest = new TestingPositions[this.bestPVOPositionsInSample.Length]; positionsToTest = this.bestPVOPositionsInSample; PVO_CTOStrategy strategy = new PVO_CTOStrategy(eligiblesSelector, positionsToTest, inSampleDays, benchmark , int.MaxValue , 0 , ((PVOPositions)positionsToTest[0]).OversoldThreshold, ((PVOPositions)positionsToTest[0]).OverboughtThreshold, historicalQuoteProviderForStrategy); EndOfDayStrategyBackTester endOfDayStrategyBackTester = new EndOfDayStrategyBackTester( "PVO_CTO" , strategy , historicalQuoteProviderForBackTester , new SimpleAccountProvider(), firstDateTime , lastDateTime , benchmark , cashToStart , maxRunningHours ); // TO DO check if you can do this assign in the EndOfDayStrategyBackTester // constructor strategy.Account = endOfDayStrategyBackTester.Account; endOfDayStrategyBackTester.Run(); BackTesterReportViewer.ShowReport( lastDateTime , endOfDayStrategyBackTester ); } } } --- NEW FILE: PVO_CTOMain.cs --- /* QuantProject - Quantitative Finance Library PVO_CTOMain.cs Copyright (C) 2008 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Collections; using System.IO; using QuantProject.ADT; using QuantProject.ADT.FileManaging; using QuantProject.Business.DataProviders; using QuantProject.Business.Strategies; using QuantProject.Business.Financial.Accounting.AccountProviding; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.EquityEvaluation; using QuantProject.Business.Strategies.InSample; using QuantProject.Business.Strategies.Logging; using QuantProject.Business.Strategies.Optimizing.Decoding; using QuantProject.Business.Strategies.Optimizing.FitnessEvaluation; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Strategies.ReturnsManagement.Time; using QuantProject.Business.Strategies.ReturnsManagement.Time.IntervalsSelectors; using QuantProject.Business.Timing; using QuantProject.Presentation; using QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator.InSampleChoosers; using QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator.Decoding; using QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator.FitnessEvaluators; using QuantProject.Scripts.General; using QuantProject.Scripts.General.Logging; using QuantProject.Scripts.General.Reporting; namespace QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator { /// <summary> /// Entry point for the PVO_OTC strategy. If any strategy /// parameter had to be changed, this is the place where it should /// be done /// </summary> public class PVO_CTOMain : BasicScriptForBacktesting { private Benchmark benchmark; private HistoricalQuoteProvider historicalQuoteProvider; public PVO_CTOMain() { this.benchmark = new Benchmark( "BMC" ); this.historicalQuoteProvider = new HistoricalAdjustedQuoteProvider(); // definition for the Fitness Evaluator // IEquityEvaluator equityEvaluator = new SharpeRatio(); } protected override IEligiblesSelector getEligiblesSelector() { int maxNumberOfEligiblesToBeChosen = 100; string tickersGroupId = "SP500"; bool temporizedGroup = true; int numDaysForAverageRawOpenPriceComputation = 10; double minPrice = 30; double maxPrice = 75; int maxNumberOfMostLiquidTickersToBeChosen = 150; int numDaysForVolatility = 10; IEligiblesSelector eligiblesSelector = new ByPriceMostLiquidLessVolatileCTOAlwaysQuoted( tickersGroupId , temporizedGroup , maxNumberOfEligiblesToBeChosen , maxNumberOfMostLiquidTickersToBeChosen , numDaysForAverageRawOpenPriceComputation , numDaysForVolatility , minPrice , maxPrice ); // IEligiblesSelector eligiblesSelector = // new ByPriceMostLiquidAlwaysQuoted( // tickersGroupId , temporizedGroup , // maxNumberOfEligiblesToBeChosen , // numDaysForAverageRawOpenPriceComputation , // minPrice , maxPrice ); // IEligiblesSelector eligiblesSelector = // new ByPriceLessVolatileOTCAlwaysQuoted( // tickersGroupId , temporizedGroup , // maxNumberOfEligiblesToBeChosen , // numDaysForAverageRawOpenPriceComputation , // minPrice , maxPrice ); eligiblesSelector = new DummyEligibleSelector(); // return eligiblesSelector; } protected override IInSampleChooser getInSampleChooser() { // parameters for the genetic optimizer // double crossoverRate = 0.85; // double mutationRate = 0.02; // double elitismRate = 0.001; // int populationSizeForGeneticOptimizer = 3000; // int generationNumberForGeneticOptimizer = 4; // int seedForRandomGenerator = // QuantProject.ADT.ConstantsProvider.SeedForRandomGenerator; // IDecoderForTestingPositions decoderForWeightedPositions = // new DecoderForPairsTradingTestingPositionsWithBalancedWeights(); double maxCorrelationAllowed = 0.96; int numberOfBestTestingPositionsToBeReturned = 100; numberOfBestTestingPositionsToBeReturned = 100; bool balancedWeightsOnVolatilityBase = true; int returnIntervalLength = 1; float minimumAbsoluteReturnValue = 0.000001f; float maximumAbsoluteReturnValue = 100000f; //correlation is computed only for returns //between minimum and maximum IInSampleChooser inSampleChooser = new PVO_CTCCorrelationChooser(numberOfBestTestingPositionsToBeReturned, returnIntervalLength, maxCorrelationAllowed , balancedWeightsOnVolatilityBase, minimumAbsoluteReturnValue , maximumAbsoluteReturnValue, this.benchmark.Ticker); // IInSampleChooser inSampleChooser = // new PVO_OTOCorrelationChooser(numberOfBestTestingPositionsToBeReturned, // returnIntervalLength, maxCorrelationAllowed , balancedWeightsOnVolatilityBase, // minimumAbsoluteReturnValue , maximumAbsoluteReturnValue); // IInSampleChooser inSampleChooser = // new PVO_OTCCorrelationChooser(numberOfBestTestingPositionsToBeReturned, // maxCorrelationAllowed , balancedWeightsOnVolatilityBase, // minimumAbsoluteReturnValue , maximumAbsoluteReturnValue); // IInSampleChooser inSampleChooser = // new PVO_CTOCorrelationChooser(numberOfBestTestingPositionsToBeReturned, // maxCorrelationAllowed , balancedWeightsOnVolatilityBase, // minimumAbsoluteReturnValue , maximumAbsoluteReturnValue); // IInSampleChooser inSampleChooser = // new PVO_OTCCTOCorrelationChooser(numberOfBestTestingPositionsToBeReturned, // maxCorrelationAllowed , balancedWeightsOnVolatilityBase, // minimumAbsoluteReturnValue , maximumAbsoluteReturnValue); // //office // inSampleChooser = // new PVOChooserFromSavedBackTestLog( // @"C:\Utente\MarcoVarie\Vari\qP\LogArchive\2008_05_02_15_55_32_PVO_OTC_from_2001_01_01_to_2008_04_28_annlRtrn_101,19_maxDD_6,30\2008_05_02_15_55_32_PVO_OTC_from_2001_01_01_to_2008_04_28_annlRtrn_101,19_maxDD_6,30.qpL", // numberOfBestTestingPositionsToBeReturned); //office - CTO // inSampleChooser = // new PVOChooserFromSavedBackTestLog( // @"C:\Utente\MarcoVarie\Vari\qP\LogArchive\2008_05_14_10_12_30_PVO_CTO_from_2001_01_01_to_2004_12_31_annlRtrn_16,08_maxDD_8,34\2008_05_14_10_12_30_PVO_CTO_from_2001_01_01_to_2004_12_31_annlRtrn_16,08_maxDD_8,34.qpL", // numberOfBestTestingPositionsToBeReturned); //home inSampleChooser = new PVOChooserFromSavedBackTestLog( @"C:\Utente\MarcoVarie\Vari\qP\LogArchive\2008_05_18_12_13_22_PVO_CTO_from_2006_01_01_to_2008_04_28_annlRtrn_4.15_maxDD_17.07\2008_05_18_12_13_22_PVO_CTO_from_2006_01_01_to_2008_04_28_annlRtrn_4.15_maxDD_17.07.qpL", numberOfBestTestingPositionsToBeReturned); return inSampleChooser; } protected override IEndOfDayStrategyForBacktester getEndOfDayStrategy() { int inSampleDays = 180; // uncomment the following line for a faster script //inSampleDays = 50; int numDaysBetweenEachOptimization = 5; int numOfClosingsBeforeExit = 0; int minNumOfEligiblesForValidOptimization = 10; double oversoldThreshold = 0.007; double overboughtThreshold = 0.007; double oversoldThresholdMAX = 0.02; double overboughtThresholdMAX = 0.02; IEndOfDayStrategyForBacktester endOfDayStrategy = new PVO_OTCStrategy(eligiblesSelector , minNumOfEligiblesForValidOptimization, inSampleChooser , inSampleDays , benchmark , numDaysBetweenEachOptimization , numOfClosingsBeforeExit, oversoldThreshold , overboughtThreshold , oversoldThresholdMAX , overboughtThresholdMAX , historicalQuoteProvider); return endOfDayStrategy; } protected override EndOfDayStrategyBackTester getEndOfDayStrategyBackTester() { string backTestId = "PVO_CTO"; IAccountProvider accountProvider; accountProvider = new SimpleAccountProvider(); // double fixedPercentageSlippage = 0.05; // accountProvider = // new InteractiveBrokerAccountProvider(fixedPercentageSlippage); double cashToStart = 25000; DateTime firstDateTime = new DateTime( 2006 , 1 , 1 ); DateTime lastDateTime = new DateTime( 2008 , 4, 28 ); double maxRunningHours = 3; HistoricalQuoteProvider quoteProviderForBackTester = this.historicalQuoteProvider; quoteProviderForBackTester = new HistoricalAdjustedQuoteProvider(); EndOfDayStrategyBackTester endOfDayStrategyBackTester = new EndOfDayStrategyBackTester( backTestId , this.endOfDayStrategy , quoteProviderForBackTester , accountProvider , firstDateTime , lastDateTime , this.benchmark , cashToStart , maxRunningHours ); return endOfDayStrategyBackTester; } protected override string getPathForTheMainFolderWhereScriptsResultsAreToBeSaved() { string pathForTheMainFolderWhereScriptsResultsAreToBeSaved = System.Configuration.ConfigurationSettings.AppSettings["LogArchive"]; return pathForTheMainFolderWhereScriptsResultsAreToBeSaved; } protected override string getCustomSmallTextForFolderName() { return "PVO_CTO"; } protected override string getFullPathFileNameForMain() { string returnValue; string fullPathFileNameForMainAtHome = @"C:\Quant\QuantProject\b7_Scripts\TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\PVO_CTOMain.cs"; if( File.Exists(fullPathFileNameForMainAtHome) ) returnValue = fullPathFileNameForMainAtHome; else returnValue = @"C:\Utente\MarcoVarie\Vari\qP\QuantProject\b7_Scripts\TechnicalAnalysisTesting\Oscillators\FixedLevelOscillators\PortfolioValueOscillator\PVO_CTOMain.cs"; return returnValue; } } } --- NEW FILE: PVO_CTOStrategy.cs --- /* QuantProject - Quantitative Finance Library PVO_CTOStrategy.cs Copyright (C) 2008 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Data; using System.Collections; using QuantProject.ADT; using QuantProject.ADT.Messaging; using QuantProject.Business.Financial.Accounting; using QuantProject.Business.Financial.Instruments; using QuantProject.Business.Financial.Ordering; using QuantProject.Business.Timing; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.InSample; using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Strategies.Logging; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Strategies.ReturnsManagement.Time; using QuantProject.Business.DataProviders; using QuantProject.Business.Strategies.TickersRelationships; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.Optimizing.Decoding; using QuantProject.Data; using QuantProject.Data.DataProviders; using QuantProject.Data.Selectors; using QuantProject.Data.DataTables; using QuantProject.ADT.Optimizing.Genetic; using QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator.InSampleChoosers; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; using QuantProject.Scripts.WalkForwardTesting.LinearCombination; namespace QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator { /// <summary> /// Implements MarketOpenEventHandler and MarketCloseEventHandler /// These handlers contain the core strategy for the Portfolio Value /// Oscillator /// </summary> [Serializable] public class PVO_CTOStrategy : IEndOfDayStrategyForBacktester { public event NewLogItemEventHandler NewLogItem; public event NewMessageEventHandler NewMessage; //initialized by the constructor protected int inSampleDays; protected int numDaysBetweenEachOptimization; protected IInSampleChooser inSampleChooser; protected IEligiblesSelector eligiblesSelector; protected Benchmark benchmark; protected HistoricalQuoteProvider historicalQuoteProvider; protected double oversoldThreshold; protected double overboughtThreshold; protected double oversoldThresholdMAX; protected double overboughtThresholdMAX; //initialized after constructor's call protected int numDaysElapsedSinceLastOptimization; protected ReturnsManager returnsManager; protected TestingPositions[] chosenPVOPositions; //chosen in sample: these are the eligible positions for out //of sample testing protected PVOPositions pvoPositionsForOutOfSample; protected DateTime lastCloseDate; protected DateTime lastOptimizationDateTime; protected Account account; public Account Account { get { return this.account; } set { this.account = value; } } private int numOfOpeningsToCrossBeforeExit; private int numOfOpeningsWithOpenPositions; private string description_GetDescriptionForChooser() { if(this.inSampleChooser == null) return "ConstantChooser"; else return this.inSampleChooser.Description; } public string Description { get { string description = "PVO_CTO\n" + "Tickers_" + "2\n" + "_inSampleDays_" + this.inSampleDays.ToString() + "\n" + this.eligiblesSelector.Description + "\n" + "oversoldThreshold_" + this.oversoldThreshold.ToString() + "\n" + "overboughtThreshold_" + this.overboughtThreshold.ToString() + "\n" + this.description_GetDescriptionForChooser() + "\n" + "Optimization each " + this.numDaysBetweenEachOptimization.ToString() + " days"; return description; } } public bool StopBacktestIfMaxRunningHoursHasBeenReached { get { return true; } } private void pvo_ctoStrategy(IEligiblesSelector eligiblesSelector, int inSampleDays, Benchmark benchmark, int numDaysBetweenEachOptimization, int numOfOpeningsToCrossBeforeExit, double oversoldThreshold, double overboughtThreshold, double oversoldThresholdMAX, double overboughtThresholdMAX, HistoricalQuoteProvider historicalQuoteProvider) { this.numOfOpeningsWithOpenPositions = 0; this.eligiblesSelector = eligiblesSelector; this.inSampleDays = inSampleDays; this.benchmark = benchmark; this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; this.numOfOpeningsToCrossBeforeExit = numOfOpeningsToCrossBeforeExit; this.oversoldThreshold = oversoldThreshold; this.overboughtThreshold = overboughtThreshold; this.oversoldThresholdMAX = oversoldThresholdMAX; this.overboughtThresholdMAX = overboughtThresholdMAX; this.historicalQuoteProvider = historicalQuoteProvider; } public PVO_CTOStrategy(IEligiblesSelector eligiblesSelector, IInSampleChooser inSampleChooser, int inSampleDays, Benchmark benchmark, int numDaysBetweenEachOptimization, int numOfOpeningsToCrossBeforeExit, double oversoldThreshold, double overboughtThreshold, double oversoldThresholdMAX, double overboughtThresholdMAX, HistoricalQuoteProvider historicalQuoteProvider) { this.pvo_ctoStrategy(eligiblesSelector, inSampleDays , benchmark , numDaysBetweenEachOptimization , numOfOpeningsToCrossBeforeExit, oversoldThreshold, overboughtThreshold, oversoldThresholdMAX, overboughtThresholdMAX, historicalQuoteProvider); this.inSampleChooser = inSampleChooser; } public PVO_CTOStrategy(IEligiblesSelector eligiblesSelector, IInSampleChooser inSampleChooser, int inSampleDays, Benchmark benchmark, int numDaysBetweenEachOptimization, int numOfOpeningsToCrossBeforeExit, double oversoldThreshold, double overboughtThreshold, HistoricalQuoteProvider historicalQuoteProvider) { this.pvo_ctoStrategy(eligiblesSelector, inSampleDays , benchmark , numDaysBetweenEachOptimization , numOfOpeningsToCrossBeforeExit, oversoldThreshold, overboughtThreshold, double.MaxValue, double.MaxValue, historicalQuoteProvider); this.inSampleChooser = inSampleChooser; } public PVO_CTOStrategy(IEligiblesSelector eligiblesSelector, TestingPositions[] chosenPVOPositions, int inSampleDays, Benchmark benchmark, int numDaysBetweenEachOptimization, int numOfOpeningsToCrossBeforeExit, double oversoldThreshold, double overboughtThreshold, double oversoldThresholdMAX, double overboughtThresholdMAX, HistoricalQuoteProvider historicalQuoteProvider) { this.pvo_ctoStrategy(eligiblesSelector, inSampleDays , benchmark , numDaysBetweenEachOptimization , numOfOpeningsToCrossBeforeExit, oversoldThreshold, overboughtThreshold, oversoldThresholdMAX, overboughtThresholdMAX, historicalQuoteProvider); this.chosenPVOPositions = chosenPVOPositions; } public PVO_CTOStrategy(IEligiblesSelector eligiblesSelector, TestingPositions[] chosenPVOPositions, int inSampleDays, Benchmark benchmark, int numDaysBetweenEachOptimization, int numOfOpeningsToCrossBeforeExit, double oversoldThreshold, double overboughtThreshold, HistoricalQuoteProvider historicalQuoteProvider) { this.pvo_ctoStrategy(eligiblesSelector, inSampleDays , benchmark , numDaysBetweenEachOptimization , numOfOpeningsToCrossBeforeExit, oversoldThreshold, overboughtThreshold, double.MaxValue, double.MaxValue, historicalQuoteProvider); this.chosenPVOPositions = chosenPVOPositions; } public virtual void MarketOpenEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { if(this.account.Portfolio.Count > 0) { this.numOfOpeningsWithOpenPositions++; if(this.numOfOpeningsWithOpenPositions > this.numOfOpeningsToCrossBeforeExit) { AccountManager.ClosePositions(this.account); this.numOfOpeningsWithOpenPositions = 0; } } } public void FiveMinutesBeforeMarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { } private EndOfDayDateTime now() { return this.account.EndOfDayTimer.GetCurrentTime(); } protected virtual EndOfDayDateTime getBeginOfOscillatingPeriod(IndexBasedEndOfDayTimer timer) { return new EndOfDayDateTime( (DateTime)timer.IndexQuotes.Rows[timer.CurrentDateArrayPosition]["quDate"], EndOfDaySpecificTime.MarketOpen ); } #region MarketCloseEventHandler private PVOPositionsStatus marketCloseEventHandler_openPositions_getStatus(IndexBasedEndOfDayTimer timer) { EndOfDayDateTime today = timer.GetCurrentTime(); EndOfDayDateTime beginOfOscillatingPeriod = this.getBeginOfOscillatingPeriod(timer); PVOPositionsStatus currentStatus = PVOPositionsStatus.InTheMiddle; for(int i = 0; i<this.chosenPVOPositions.Length; i++) { if(this.chosenPVOPositions[i] != null) currentStatus = ((PVOPositions)this.chosenPVOPositions[i]).GetStatus(beginOfOscillatingPeriod, today, this.benchmark.Ticker, this.historicalQuoteProvider, this.oversoldThresholdMAX, this.overboughtThresholdMAX); if(currentStatus == PVOPositionsStatus.Oversold || currentStatus == PVOPositionsStatus.Overbought ) { this.pvoPositionsForOutOfSample = (PVOPositions)this.chosenPVOPositions[i]; i = this.chosenPVOPositions.Length;//exit from for } } return currentStatus; } protected void marketCloseEventHandler_openPositions(IndexBasedEndOfDayTimer timer) { PVOPositionsStatus pvoPositionsStatus = PVOPositionsStatus.InTheMiddle; if(timer.CurrentDateArrayPosition >= 1) pvoPositionsStatus = this.marketCloseEventHandler_openPositions_getStatus(timer); switch (pvoPositionsStatus) { case PVOPositionsStatus.Overbought: { #region manage Overbought case this.pvoPositionsForOutOfSample.WeightedPositions.Reverse(); try { AccountManager.OpenPositions( this.pvoPositionsForOutOfSample.WeightedPositions, this.account ); } catch(Exception ex) { ex = ex; } finally { this.pvoPositionsForOutOfSample.WeightedPositions.Reverse(); } #endregion break; } case PVOPositionsStatus.Oversold: { AccountManager.OpenPositions( this.pvoPositionsForOutOfSample.WeightedPositions, this.account ); break; } case PVOPositionsStatus.InTheMiddle://that is { //pvoPositionsForOutOfSample has not been set break; } default: { //it should never been reached break; } } } public virtual void MarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { if ( this.account.Portfolio.Count == 0 && this.chosenPVOPositions != null ) //portfolio is empty and optimization has //been already launched { try{ this.marketCloseEventHandler_openPositions( (IndexBasedEndOfDayTimer)sender ); } catch(TickerNotExchangedException ex) {ex=ex;} } } #endregion #region OneHourAfterMarketCloseEventHandler protected virtual void updateReturnsManager(EndOfDayDateTime firstEndOfDayDateTime, EndOfDayDateTime lastEndOfDayDateTime) { ReturnIntervals returnIntervals = new CloseToOpenIntervals( firstEndOfDayDateTime, lastEndOfDayDateTime, this.benchmark.Ticker ); if( this.inSampleChooser is PVOCorrelationChooser ) { switch ( ((PVOCorrelationChooser)this.inSampleChooser).IntervalsType ) { case IntervalsType.CloseToCloseIntervals: returnIntervals = new CloseToCloseIntervals(firstEndOfDayDateTime, lastEndOfDayDateTime, this.benchmark.Ticker, ((PVOCorrelationChooser)this.inSampleChooser).ReturnIntervalLength); break; case IntervalsType.OpenToOpenIntervals: returnIntervals = new OpenToOpenIntervals(firstEndOfDayDateTime, lastEndOfDayDateTime, this.benchmark.Ticker, ((PVOCorrelationChooser)this.inSampleChooser).ReturnIntervalLength); break; case IntervalsType.CloseToOpenIntervals: returnIntervals = new CloseToOpenIntervals(firstEndOfDayDateTime, lastEndOfDayDateTime, this.benchmark.Ticker); break; case IntervalsType.OpenToCloseIntervals: returnIntervals = new DailyOpenToCloseIntervals(firstEndOfDayDateTime, lastEndOfDayDateTime, this.benchmark.Ticker ); break; case IntervalsType.OpenToCloseCloseToOpenIntervals: returnIntervals = new OpenToCloseCloseToOpenIntervals( firstEndOfDayDateTime, lastEndOfDayDateTime, this.benchmark.Ticker); break; default: // it should never be reached returnIntervals = new DailyOpenToCloseIntervals(firstEndOfDayDateTime, lastEndOfDayDateTime, this.benchmark.Ticker ); break; } } this.returnsManager = new ReturnsManager( returnIntervals , this.historicalQuoteProvider); } private PVO_CTOLogItem getLogItem( EligibleTickers eligibleTickers ) { PVO_CTOLogItem logItem = new PVO_CTOLogItem( this.now() , this.inSampleDays ); logItem.BestPVOPositionsInSample = this.chosenPVOPositions; logItem.NumberOfEligibleTickers = eligibleTickers.Count; logItem.FitnessOfFirst = this.chosenPVOPositions[0].FitnessInSample; logItem.FitnessOfLast = this.chosenPVOPositions[this.chosenPVOPositions.Length - 1].FitnessInSample; // logItem.GenerationOfFirst = // ((IGeneticallyOptimizable)this.chosenPVOPositions[0]).Generation; // logItem.GenerationOfLast = // ((IGeneticallyOptimizable)this.chosenPVOPositions[this.chosenPVOPositions.Length - 1]).Generation; logItem.ThresholdsOfFirst = ((PVOPositions)this.chosenPVOPositions[0]).OversoldThreshold.ToString() + ";" + ((PVOPositions)this.chosenPVOPositions[0]).OverboughtThreshold.ToString(); logItem.ThresholdsOfLast = ((PVOPositions)this.chosenPVOPositions[this.chosenPVOPositions.Length - 1]).OversoldThreshold.ToString() + ";" + ((PVOPositions)this.chosenPVOPositions[this.chosenPVOPositions.Length - 1]).OverboughtThreshold.ToString(); logItem.TickersOfFirst = this.chosenPVOPositions[0].HashCodeForTickerComposition; logItem.TickersOfLast = this.chosenPVOPositions[this.chosenPVOPositions.Length - 1].HashCodeForTickerComposition; return logItem; } private void raiseNewLogItem( EligibleTickers eligibleTickers ) { PVO_CTOLogItem logItem = this.getLogItem( eligibleTickers ); NewLogItemEventArgs newLogItemEventArgs = new NewLogItemEventArgs( logItem ); this.NewLogItem( this , newLogItemEventArgs ); } 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 ); } private void logOptimizationInfo( EligibleTickers eligibleTickers ) { this.raiseNewLogItem( eligibleTickers ); this.notifyMessage( eligibleTickers ); } private void updateTestingPositions_updateThresholds() { for(int i = 0; i<this.chosenPVOPositions.Length; i++) { ((PVOPositions)this.chosenPVOPositions[i]).OversoldThreshold = this.oversoldThreshold; ((PVOPositions)this.chosenPVOPositions[i]).OverboughtThreshold = this.overboughtThreshold; } } protected virtual void updateTestingPositions(DateTime currentDate) { EndOfDayHistory endOfDayHistory = this.benchmark.GetEndOfDayHistory( new EndOfDayDateTime(currentDate.AddDays(-this.inSampleDays), EndOfDaySpecificTime.MarketOpen), new EndOfDayDateTime(currentDate, EndOfDaySpecificTime.MarketClose)); EligibleTickers eligibles = this.eligiblesSelector.GetEligibleTickers(endOfDayHistory); try{ this.updateReturnsManager(endOfDayHistory.FirstEndOfDayDateTime, endOfDayHistory.LastEndOfDayDateTime); if(this.inSampleChooser != null) this.chosenPVOPositions = (TestingPositions[])inSampleChooser.AnalyzeInSample(eligibles, this.returnsManager); this.updateTestingPositions_updateThresholds(); this.logOptimizationInfo(eligibles); } catch(TickerNotExchangedException ex) { ex = ex;} } private bool optimalTestingPositionsAreToBeUpdated() { bool areToBeUpdated = false; if(this.inSampleChooser != null) { DateTime dateTimeForNextOptimization = this.lastOptimizationDateTime.AddDays( this.numDaysBetweenEachOptimization ); areToBeUpdated = ( ( ( this.account.Portfolio.Count == 0 ) && ( ( this.lastOptimizationDateTime == DateTime.MinValue ) ) ) || ( this.now().DateTime >= dateTimeForNextOptimization ) ); } return areToBeUpdated; } /// <summary> /// Handles a "One hour after market close" event. /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> public virtual void OneHourAfterMarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { this.lastCloseDate = endOfDayTimingEventArgs.EndOfDayDateTime.DateTime; this.numDaysElapsedSinceLastOptimization++; //OLD - numDaysBetweenEachOptimization --> market days // if( this.account.Transactions.Count <= 1 || // (this.numDaysElapsedSinceLastOptimization == // this.numDaysBetweenEachOptimization) ) //num days without optimization has elapsed or //no transaction, except for adding cash, has been executed //NEW - numDaysBetweenEachOptimization --> calendar days if ( this.optimalTestingPositionsAreToBeUpdated() ) { this.updateTestingPositions(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime); //sets tickers to be chosen next Market Close event this.numDaysElapsedSinceLastOptimization = 0; this.lastOptimizationDateTime = this.now().DateTime; } } #endregion } } |
|
From: Marco M. <mi...@us...> - 2008-08-14 23:37:37
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv23251/b4_Business/a2_Strategies/returnsManagement/time Added Files: OpenToOpenIntervals.cs Log Message: Added OpenToOpenIntervals --- NEW FILE: OpenToOpenIntervals.cs --- /* QuantProject - Quantitative Finance Library OpenToOpenIntervals.cs Copyright (C) 2008 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.Business.Timing; namespace QuantProject.Business.Strategies.ReturnsManagement.Time { /// <summary> /// Open to Open intervals to be used to compute open to open returns /// </summary> public class OpenToOpenIntervals : ReturnIntervals { /// <summary> /// Creates the open to open intervals for the given benchmark, from /// the first EndOfDayDateTime to the last EndOfDayDateTime /// </summary> /// <param name="firstEndOfDayDateTime"></param> /// <param name="lastEndOfDayDateTime"></param> /// <param name="benchmark"></param> public OpenToOpenIntervals( EndOfDayDateTime firstEndOfDayDateTime , EndOfDayDateTime lastEndOfDayDateTime , string benchmark ) : base( firstEndOfDayDateTime , lastEndOfDayDateTime , benchmark ) { } /// <summary> /// Creates the open to open intervals for the given benchmark, from /// the first EndOfDayDateTime to the last EndOfDayDateTime: /// each interval begins at a given market day "i" and ends at /// market day "i + intervalLength" /// </summary> /// <param name="firstEndOfDayDateTime"></param> /// <param name="lastEndOfDayDateTime"></param> /// <param name="benchmark"></param> /// <param name="intervalLength"></param> public OpenToOpenIntervals( EndOfDayDateTime firstEndOfDayDateTime , EndOfDayDateTime lastEndOfDayDateTime , string benchmark , int intervalLength ) : base( firstEndOfDayDateTime , lastEndOfDayDateTime , benchmark , intervalLength) { } private void addInterval( int i ) { DateTime dateTimeForIntervalBegin = (DateTime)this.marketDaysForBenchmark.GetKey( i ); DateTime dateTimeForIntervalEnd = (DateTime)this.marketDaysForBenchmark.GetKey( i + this.intervalLength ); ReturnInterval returnInterval = new ReturnInterval( new EndOfDayDateTime( dateTimeForIntervalBegin , EndOfDaySpecificTime.MarketOpen ) , new EndOfDayDateTime( dateTimeForIntervalEnd , EndOfDaySpecificTime.MarketOpen ) ); this.Add( returnInterval ); } protected override void setIntervals() { for( int i = 0 ; i < this.marketDaysForBenchmark.Count - this.intervalLength; i = i + this.intervalLength ) this.addInterval( i ); } } } |
|
From: Marco M. <mi...@us...> - 2008-08-14 23:37:16
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/TickersRelationships In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv23220/b4_Business/a2_Strategies/TickersRelationships Added Files: OpenToOpenCorrelationProvider.cs Log Message: Added OpenToOpenCorrelationProvider --- NEW FILE: OpenToOpenCorrelationProvider.cs --- /* QuantProject - Quantitative Finance Library OpenToOpenCorrelationProvider.cs Copyright (C) 2008 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Data; using System.Collections; using QuantProject.ADT.Statistics; using QuantProject.Business.DataProviders; using QuantProject.Business.Timing; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Strategies.ReturnsManagement.Time; namespace QuantProject.Business.Strategies.TickersRelationships { /// <summary> /// Class that provides open to open correlation's indexes two by two within a /// given set of tickers /// </summary> [Serializable] public class OpenToOpenCorrelationProvider : CorrelationProvider { private int openToOpenIntervalLength; /// <summary> /// Creates the provider for the open to open correlation /// </summary> /// <param name="tickersToAnalyze">Array of tickers to be analyzed</param> /// <param name="startDate"></param> /// <param name="endDate"></param> /// <param name="openToOpenIntervalLength">Length of the open To open /// interval return</param> /// <param name="minimumAbsoluteReturnValue">Both current tickers' returns /// have to be greater than minimumAbsoluteReturnValue for being considered /// significant and so computed in the correlation formula</param> /// <param name="maximumAbsoluteReturnValue">Both current tickers' returns /// have to be less than maximumAbsoluteReturnValue</param> /// <param name="benchmark">The benchmark used for computation /// of returns</param> public OpenToOpenCorrelationProvider(string[] tickersToAnalyze, DateTime startDate, DateTime endDate, int openToOpenIntervalLength, float minimumAbsoluteReturnValue, float maximumAbsoluteReturnValue, string benchmark) : base(tickersToAnalyze, startDate, endDate, openToOpenIntervalLength, minimumAbsoluteReturnValue, maximumAbsoluteReturnValue, benchmark) { this.openToOpenIntervalLength = openToOpenIntervalLength; } /// <summary> /// Creates the provider for the open to open correlation /// </summary> /// <param name="tickersToAnalyze">Array of tickers to be analyzed</param> /// <param name="returnsManager"></param> /// <param name="minimumAbsoluteReturnValue">Both current tickers' returns /// have to be greater than minimumAbsoluteReturnValue for being considered /// significant and so computed in the correlation formula</param> /// <param name="maximumAbsoluteReturnValue">Both current tickers' returns /// have to be less than maximumAbsoluteReturnValue</param> public OpenToOpenCorrelationProvider( string[] tickersToAnalyze, ReturnsManager returnsManager, float minimumAbsoluteReturnValue, float maximumAbsoluteReturnValue ): base(tickersToAnalyze, returnsManager, minimumAbsoluteReturnValue, maximumAbsoluteReturnValue) { } protected override void setEndOfDayDatesTime(DateTime startDate, DateTime endDate) { this.firstEndOfDayDateTime = new EndOfDayDateTime(startDate, EndOfDaySpecificTime.MarketOpen); this.lastEndOfDayDateTime = new EndOfDayDateTime(endDate, EndOfDaySpecificTime.MarketOpen); } protected override void setReturnsManager() { OpenToOpenIntervals openToOpenIntervals = new OpenToOpenIntervals(this.firstEndOfDayDateTime, this.lastEndOfDayDateTime, this.benchmark, this.openToOpenIntervalLength); this.returnsManager = new ReturnsManager(openToOpenIntervals, new HistoricalAdjustedQuoteProvider() ); } } // end of class } |
|
From: Marco M. <mi...@us...> - 2008-08-14 23:37:02
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/TickersRelationships In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv22809/b4_Business/a2_Strategies/TickersRelationships Added Files: CloseToOpenCorrelationProvider.cs Log Message: Added CloseToOpenCorrelationProvider --- NEW FILE: CloseToOpenCorrelationProvider.cs --- /* QuantProject - Quantitative Finance Library CloseToOpenCorrelationProvider.cs Copyright (C) 2008 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Data; using System.Collections; using QuantProject.ADT.Statistics; using QuantProject.Business.DataProviders; using QuantProject.Business.Timing; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Strategies.ReturnsManagement.Time; namespace QuantProject.Business.Strategies.TickersRelationships { /// <summary> /// Class that provides close to open correlation's indexes two by two within a /// given set of tickers /// </summary> [Serializable] public class CloseToOpenCorrelationProvider : CorrelationProvider { /// <summary> /// Creates the provider for the close to open correlation /// </summary> /// <param name="tickersToAnalyze">Array of tickers to be analyzed</param> /// <param name="startDate"></param> /// <param name="endDate"></param> /// <param name="minimumAbsoluteReturnValue">Both current tickers' returns /// have to be greater than minimumAbsoluteReturnValue for being considered /// significant and so computed in the correlation formula</param> /// <param name="maximumAbsoluteReturnValue">Both current tickers' returns /// have to be less than maximumAbsoluteReturnValue</param> /// <param name="benchmark">The benchmark used for computation /// of returns</param> public CloseToOpenCorrelationProvider(string[] tickersToAnalyze, DateTime startDate, DateTime endDate, float minimumAbsoluteReturnValue, float maximumAbsoluteReturnValue, string benchmark) : base(tickersToAnalyze, startDate, endDate, minimumAbsoluteReturnValue, maximumAbsoluteReturnValue, benchmark) { } /// <summary> /// Creates the provider for the close to open correlation /// </summary> /// <param name="tickersToAnalyze">Array of tickers to be analyzed</param> /// <param name="returnsManager"></param> /// <param name="minimumAbsoluteReturnValue">Both current tickers' returns /// have to be greater than minimumAbsoluteReturnValue for being considered /// significant and so computed in the correlation formula</param> /// <param name="maximumAbsoluteReturnValue">Both current tickers' returns /// have to be less than maximumAbsoluteReturnValue</param> public CloseToOpenCorrelationProvider( string[] tickersToAnalyze, ReturnsManager returnsManager, float minimumAbsoluteReturnValue, float maximumAbsoluteReturnValue ) : base(tickersToAnalyze, returnsManager, minimumAbsoluteReturnValue, maximumAbsoluteReturnValue) { } protected override void setEndOfDayDatesTime(DateTime startDate, DateTime endDate) { this.firstEndOfDayDateTime = new EndOfDayDateTime(startDate, EndOfDaySpecificTime.MarketClose); this.lastEndOfDayDateTime = new EndOfDayDateTime(endDate, EndOfDaySpecificTime.MarketOpen); } protected override void setReturnsManager() { CloseToOpenIntervals closeToOpenIntervals = new CloseToOpenIntervals(this.firstEndOfDayDateTime, this.lastEndOfDayDateTime, this.benchmark); this.returnsManager = new ReturnsManager(closeToOpenIntervals, new HistoricalAdjustedQuoteProvider() ); } } // end of class } |
|
From: Marco M. <mi...@us...> - 2008-08-01 20:04:45
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/UserForms In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv3403/OpenTickDownloader/UserForms Modified Files: OTWebDownloader.cs Log Message: Fixed minor bug in OT Web Downloader form: minutes can be set to 0 now. Index: OTWebDownloader.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/UserForms/OTWebDownloader.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** OTWebDownloader.cs 20 Jul 2008 20:38:39 -0000 1.3 --- OTWebDownloader.cs 29 Jul 2008 22:38:17 -0000 1.4 *************** *** 321,329 **** 0, 0}); - this.fromMin.Minimum = new decimal(new int[] { - 1, - 0, - 0, - 0}); this.fromMin.Name = "fromMin"; this.fromMin.Size = new System.Drawing.Size(45, 20); --- 321,324 ---- *************** *** 603,606 **** --- 598,602 ---- new DownloadingCompletedEventHandler(this.refreshForm_atDownloadedCompleted); this.buttonDownloadQuotesOfSelectedTickers.Enabled = false; + //tickerDownloader.DownloadTickers(); this.downloadThread = new Thread( tickerDownloader.DownloadTickers ); this.downloadThread.Start(); *************** *** 630,636 **** private void refreshForm_atDownloadedStarted(object sender, DownloadingStartedEventArgs eventArgs) { ! this.textForStartingDownloadingTimeLabel = ! "Downloading started at: " + eventArgs.StartingDateTime.ToString(); ! this.downloadingInProgress = true; } private void refreshForm_atDownloadedCompleted(object sender, DownloadingCompletedEventArgs eventArgs) --- 626,632 ---- private void refreshForm_atDownloadedStarted(object sender, DownloadingStartedEventArgs eventArgs) { ! this.textForStartingDownloadingTimeLabel = ! "Downloading started at: " + eventArgs.StartingDateTime.ToString(); ! this.downloadingInProgress = true; } private void refreshForm_atDownloadedCompleted(object sender, DownloadingCompletedEventArgs eventArgs) |