quantproject-developers Mailing List for QuantProject (Page 104)
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: Marco M. <mi...@us...> - 2005-07-31 19:53:53
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15756/b7_Scripts Modified Files: b7_Scripts.csproj Log Message: Moved specific methods for the GenomeManagerForTheEfficientPortfolio from GenomeManagement to the new GenomeManipulator class, created in the namespace QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; - modified MixGenesWithoutDuplicates, that now tries to mix all genes of the two parents in offspring (without duplication) Index: b7_Scripts.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/b7_Scripts.csproj,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** b7_Scripts.csproj 27 Jul 2005 22:23:14 -0000 1.33 --- b7_Scripts.csproj 31 Jul 2005 19:53:44 -0000 1.34 *************** *** 219,222 **** --- 219,227 ---- /> <File + RelPath = "TickerSelectionTesting\GenomeManipulator.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "TickerSelectionTesting\PortfolioType.cs" SubType = "Code" |
|
From: Glauco S. <gla...@us...> - 2005-07-29 13:39:43
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29727/b7_Scripts/WalkForwardTesting/LinearCombination Modified Files: MainForm.cs Log Message: - the new GenomeRepresentation structure is handled Index: MainForm.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination/MainForm.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MainForm.cs 25 Jul 2005 22:52:02 -0000 1.3 --- MainForm.cs 29 Jul 2005 13:39:35 -0000 1.4 *************** *** 155,161 **** protected DataTable getSetOfTickersToBeOptimized_quickly() { ! DataTable returnValue = ! new QuantProject.Data.DataTables.Tickers_tickerGroups( "test" ); ! returnValue.Columns[ 0 ].ColumnName = "tiTicker"; return returnValue; } --- 155,161 ---- protected DataTable getSetOfTickersToBeOptimized_quickly() { ! SelectorByGroup selectorByGroup = ! new SelectorByGroup( "20020106" ); ! DataTable returnValue = selectorByGroup.GetTableOfSelectedTickers(); return returnValue; } *************** *** 192,196 **** // this is the first generation created and this.bestGenomes is still empty this.bestGenomes.Add( new GenomeRepresentation( ! (Genome)generation[ generation.Count - 1 ] ) ); for ( int i=0 ; i < generation.Count ; i++ ) if ( ((Genome)generation[ i ]).Fitness > --- 192,199 ---- // this is the first generation created and this.bestGenomes is still empty this.bestGenomes.Add( new GenomeRepresentation( ! (Genome)generation[ generation.Count - 1 ] , ! this.firstDate , ! this.lastDate , ! newGenerationEventArgs.GenerationCounter ) ); for ( int i=0 ; i < generation.Count ; i++ ) if ( ((Genome)generation[ i ]).Fitness > *************** *** 199,203 **** // generation[ i ] is a genome better than the best already stored this.bestGenomes.Add( new GenomeRepresentation( ! (Genome)generation[ i ] ) ); } private void writeOptimizedGenomesToDisk() --- 202,209 ---- // generation[ i ] is a genome better than the best already stored this.bestGenomes.Add( new GenomeRepresentation( ! (Genome)generation[ i ] , ! this.firstDate , ! this.lastDate , ! newGenerationEventArgs.GenerationCounter ) ); } private void writeOptimizedGenomesToDisk() *************** *** 218,225 **** { this.bestGenomes = new ArrayList(); - // DataTable setOfTickersToBeOptimized = - // this.getSetOfTickersToBeOptimized_quickly(); DataTable setOfTickersToBeOptimized = ! this.getSetOfTickersToBeOptimized(); // DataTable setOfTickersToBeOptimized = // this.getSetOfTickersToBeOptimized(); --- 224,229 ---- { this.bestGenomes = new ArrayList(); DataTable setOfTickersToBeOptimized = ! this.getSetOfTickersToBeOptimized_quickly(); // DataTable setOfTickersToBeOptimized = // this.getSetOfTickersToBeOptimized(); |
|
From: Glauco S. <gla...@us...> - 2005-07-29 13:36:38
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29183/b7_Scripts/WalkForwardTesting/LinearCombination Modified Files: GenomeRepresentation.cs Log Message: - the private member genome has been removed: much simpler serialization now - the public member FirstOptimizationDate has been added - the public member LastOptimizationDate has been added Index: GenomeRepresentation.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination/GenomeRepresentation.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** GenomeRepresentation.cs 23 Jul 2005 17:58:43 -0000 1.1 --- GenomeRepresentation.cs 29 Jul 2005 13:36:28 -0000 1.2 *************** *** 34,38 **** public class GenomeRepresentation { ! private Genome genome; public string SignedTickers --- 34,42 ---- public class GenomeRepresentation { ! private double fitness; ! private string signedTickers; ! private int generationCounter; ! private DateTime firstOptimizationDate; ! private DateTime lastOptimizationDate; public string SignedTickers *************** *** 40,54 **** get { ! string signedTickers = ""; ! foreach ( string geneValue in (string[])genome.Meaning ) ! signedTickers += geneValue + ";"; ! signedTickers = signedTickers.Substring( 0 , ! signedTickers.Length - 1 ); ! return signedTickers; } } public double Fitness { ! get { return this.genome.Fitness; } } --- 44,68 ---- get { ! return this.signedTickers; } } public double Fitness { ! get { return this.fitness; } ! } ! public DateTime FirstOptimizationDate ! { ! get { return this.firstOptimizationDate; } ! } ! public DateTime LastOptimizationDate ! { ! get { return this.lastOptimizationDate; } ! } ! /// <summary> ! /// Number of the first generation containing the genome ! /// </summary> ! public int GenerationCounter ! { ! get { return this.generationCounter; } } *************** *** 76,82 **** return returnValue; } ! public GenomeRepresentation( Genome genome ) { ! this.genome = genome; } } --- 90,124 ---- return returnValue; } ! private string getSignedTickers( Genome genome ) { ! string signedTickers = ""; ! foreach ( string geneValue in (string[])genome.Meaning ) ! signedTickers += geneValue + ";"; ! signedTickers = signedTickers.Substring( 0 , ! signedTickers.Length - 1 ); ! return signedTickers; ! } ! private void genomeRepresentation( Genome genome , ! DateTime firstOptimizationDate , DateTime lastOptimizationDate , ! int generationCounter ) ! { ! this.fitness = genome.Fitness; ! this.signedTickers = this.getSignedTickers( genome ); ! this.firstOptimizationDate = firstOptimizationDate; ! this.lastOptimizationDate = lastOptimizationDate; ! this.generationCounter = generationCounter; ! } ! public GenomeRepresentation( Genome genome , ! DateTime firstOptimizationDate , DateTime lastOptimizationDate ) ! { ! this.genomeRepresentation( genome , ! firstOptimizationDate , lastOptimizationDate , -1 ); ! } ! public GenomeRepresentation( Genome genome , ! DateTime firstOptimizationDate , DateTime lastOptimizationDate , ! int generationCounter ) ! { ! this.genomeRepresentation( genome , firstOptimizationDate , ! lastOptimizationDate , generationCounter ); } } |
|
From: Glauco S. <gla...@us...> - 2005-07-29 13:32:47
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28345/b7_Scripts/WalkForwardTesting/LinearCombination Modified Files: TestDisplayer.cs Log Message: - better exception handling - first date and last date now are handled for each genome (and can be different and automatically computed for each genome) - both right click and left click is handled now: * left click resets the first date and last date to the in sample optimization date for the selected genome * right click keeps the date displacements visually chosen by the user; right click starts the backtest also Index: TestDisplayer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination/TestDisplayer.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TestDisplayer.cs 23 Jul 2005 18:10:33 -0000 1.2 --- TestDisplayer.cs 29 Jul 2005 13:32:34 -0000 1.3 *************** *** 45,48 **** --- 45,50 ---- // Glauco code private ArrayList bestGenomes; + private System.Windows.Forms.Label label1; + private GenomeRepresentation lastSelectedGenomeRepresentation; private void testdisplayer() *************** *** 53,56 **** --- 55,61 ---- ArrayList bestGenomes ) { + if ( bestGenomes.Count == 0 ) + throw new Exception( "bestGenomes is empty! It should contain " + + "a genome, at least." ); // // Required for Windows Form Designer support *************** *** 59,64 **** // Glauco code ! this.dtpFirstDate.Value = firstDate; ! this.dtpLastDate.Value = lastDate; this.bestGenomes = bestGenomes; this.testdisplayer(); --- 64,73 ---- // Glauco code ! this.lastSelectedGenomeRepresentation = ! ((GenomeRepresentation)bestGenomes[0]); ! this.dtpFirstDate.Value = ! this.lastSelectedGenomeRepresentation.FirstOptimizationDate; ! this.dtpLastDate.Value = ! this.lastSelectedGenomeRepresentation.LastOptimizationDate; this.bestGenomes = bestGenomes; this.testdisplayer(); *************** *** 90,93 **** --- 99,103 ---- this.dtpFirstDate = new System.Windows.Forms.DateTimePicker(); this.dtpLastDate = new System.Windows.Forms.DateTimePicker(); + this.label1 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.dgBestGenomes)).BeginInit(); this.SuspendLayout(); *************** *** 98,104 **** this.dgBestGenomes.Dock = System.Windows.Forms.DockStyle.Bottom; this.dgBestGenomes.HeaderForeColor = System.Drawing.SystemColors.ControlText; ! this.dgBestGenomes.Location = new System.Drawing.Point(0, 93); this.dgBestGenomes.Name = "dgBestGenomes"; ! this.dgBestGenomes.Size = new System.Drawing.Size(496, 248); this.dgBestGenomes.TabIndex = 0; this.dgBestGenomes.MouseUp += new System.Windows.Forms.MouseEventHandler(this.dgBestGenomes_MouseUp); --- 108,114 ---- this.dgBestGenomes.Dock = System.Windows.Forms.DockStyle.Bottom; this.dgBestGenomes.HeaderForeColor = System.Drawing.SystemColors.ControlText; ! this.dgBestGenomes.Location = new System.Drawing.Point(0, 117); this.dgBestGenomes.Name = "dgBestGenomes"; ! this.dgBestGenomes.Size = new System.Drawing.Size(496, 224); this.dgBestGenomes.TabIndex = 0; this.dgBestGenomes.MouseUp += new System.Windows.Forms.MouseEventHandler(this.dgBestGenomes_MouseUp); *************** *** 117,120 **** --- 127,139 ---- this.dtpLastDate.TabIndex = 2; // + // label1 + // + this.label1.Location = new System.Drawing.Point(32, 64); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(400, 40); + this.label1.TabIndex = 3; + this.label1.Text = "Left click data grid rows to reset dates to the optimization period. Right click " + + "to preserve date displacements and backtest."; + // // TestDisplayer // *************** *** 122,125 **** --- 141,145 ---- this.ClientSize = new System.Drawing.Size(496, 341); this.Controls.AddRange(new System.Windows.Forms.Control[] { + this.label1, this.dtpLastDate, this.dtpFirstDate, *************** *** 133,145 **** #endregion ! private void dgBestGenomes_MouseUp_actually(object sender, System.Windows.Forms.MouseEventArgs e) { DataGrid dataGrid = (DataGrid)sender; Point point = new Point( e.X , e.Y ); DataGrid.HitTestInfo hitTestInfo = dataGrid.HitTest( point ); ArrayList bestGenomes = (ArrayList)dataGrid.DataSource; ! // DataRow dataRow = dataTable.Rows[ hitTestInfo.Row ]; ! GenomeRepresentation genomeRepresentation = (GenomeRepresentation)bestGenomes[ hitTestInfo.Row ]; string[] signedTickers = GenomeRepresentation.GetSignedTickers( genomeRepresentation.SignedTickers ); --- 153,198 ---- #endregion ! private bool aRowHasBeenClicked( ! object sender, System.Windows.Forms.MouseEventArgs e ) { DataGrid dataGrid = (DataGrid)sender; Point point = new Point( e.X , e.Y ); DataGrid.HitTestInfo hitTestInfo = dataGrid.HitTest( point ); + return hitTestInfo.Row>=0; + } + private GenomeRepresentation dgBestGenomes_MouseUp_getClickedGenomeRepresentation( + object sender, System.Windows.Forms.MouseEventArgs e ) + { + GenomeRepresentation genomeRepresentation = null; + DataGrid dataGrid = (DataGrid)sender; + Point point = new Point( e.X , e.Y ); + DataGrid.HitTestInfo hitTestInfo = dataGrid.HitTest( point ); ArrayList bestGenomes = (ArrayList)dataGrid.DataSource; ! // DataRow dataRow = dataTable.Rows[ hitTestInfo.Row ]; ! if ( hitTestInfo.Row >= 0 ) ! // a grid row has been clicked, not the header ! genomeRepresentation = (GenomeRepresentation)bestGenomes[ hitTestInfo.Row ]; + return genomeRepresentation; + } + private void dgBestGenomes_MouseUp_rightButton_updateDates( + GenomeRepresentation newSelectedGenomeRepresentation ) + { + TimeSpan currentFirstDateDisplacement = + ( this.dtpFirstDate.Value - + this.lastSelectedGenomeRepresentation.FirstOptimizationDate ); + TimeSpan currentLastDateDisplacement = + ( this.dtpLastDate.Value - + this.lastSelectedGenomeRepresentation.LastOptimizationDate ); + this.dtpFirstDate.Value = newSelectedGenomeRepresentation.FirstOptimizationDate + + currentFirstDateDisplacement; + this.dtpLastDate.Value = newSelectedGenomeRepresentation.LastOptimizationDate + + currentLastDateDisplacement; + } + private void dgBestGenomes_MouseUp_rightButton(object sender, System.Windows.Forms.MouseEventArgs e) + { + GenomeRepresentation genomeRepresentation = + this.dgBestGenomes_MouseUp_getClickedGenomeRepresentation( sender , e ); + dgBestGenomes_MouseUp_rightButton_updateDates( genomeRepresentation ); string[] signedTickers = GenomeRepresentation.GetSignedTickers( genomeRepresentation.SignedTickers ); *************** *** 148,156 **** this.dtpLastDate.Value , signedTickers ); linearCombinationTest.Run(); } private void dgBestGenomes_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { if ( e.Button == MouseButtons.Right ) ! this.dgBestGenomes_MouseUp_actually( sender , e ); } } --- 201,231 ---- this.dtpLastDate.Value , signedTickers ); linearCombinationTest.Run(); + this.lastSelectedGenomeRepresentation = genomeRepresentation; + } + private void dgBestGenomes_MouseUp_leftButton_updateDates( + GenomeRepresentation newSelectedGenomeRepresentation ) + { + this.dtpFirstDate.Value = + newSelectedGenomeRepresentation.FirstOptimizationDate; + this.dtpLastDate.Value = + newSelectedGenomeRepresentation.LastOptimizationDate; + } + private void dgBestGenomes_MouseUp_leftButton(object sender, System.Windows.Forms.MouseEventArgs e) + { + if ( aRowHasBeenClicked( sender , e ) ) + // a grid row has been clicked, not the header + { + GenomeRepresentation newSelectedGenomeRepresentation = + this.dgBestGenomes_MouseUp_getClickedGenomeRepresentation( sender , e ); + dgBestGenomes_MouseUp_leftButton_updateDates( newSelectedGenomeRepresentation ); + this.lastSelectedGenomeRepresentation = newSelectedGenomeRepresentation; + } } private void dgBestGenomes_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { if ( e.Button == MouseButtons.Right ) ! this.dgBestGenomes_MouseUp_rightButton( sender , e ); ! if ( e.Button == MouseButtons.Left ) ! this.dgBestGenomes_MouseUp_leftButton( sender , e ); } } |
|
From: Glauco S. <gla...@us...> - 2005-07-29 13:28:26
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataTables In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27700/b3_Data/DataTables Modified Files: Tickers_tickerGroups.cs Log Message: The Serializable attribute has been added Index: Tickers_tickerGroups.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataTables/Tickers_tickerGroups.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Tickers_tickerGroups.cs 10 Jun 2005 18:57:06 -0000 1.2 --- Tickers_tickerGroups.cs 29 Jul 2005 13:28:17 -0000 1.3 *************** *** 31,36 **** /// The DataTable to work with tickers inside a given group. /// </summary> ! ! public class Tickers_tickerGroups : DataTable { // these static fields provide field name in the database table --- 31,36 ---- /// The DataTable to work with tickers inside a given group. /// </summary> ! [Serializable] ! public class Tickers_tickerGroups : DataTable { // these static fields provide field name in the database table |
|
From: Glauco S. <gla...@us...> - 2005-07-29 13:27:55
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/Selectors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27638/b3_Data/Selectors Added Files: SelectorByGroup.cs Log Message: Class for selection on tickers by groupId --- NEW FILE: SelectorByGroup.cs --- /* QuantProject - Quantitative Finance Library SelectorByGroup.cs Copyright (C) 2003 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Collections; using System.Data; using System.Windows.Forms; using QuantProject.DataAccess.Tables; using QuantProject.Data.DataTables; namespace QuantProject.Data.Selectors { /// <summary> /// Class for selection on tickers by groupId /// </summary> public class SelectorByGroup : ITickerSelector { private string groupID; public SelectorByGroup( string groupID ) { this.groupID = groupID; } public DataTable GetTableOfSelectedTickers() { return QuantProject.DataAccess.Tables.Tickers_tickerGroups.GetTickers( this.groupID ); } public void SelectAllTickers() { ; } } } |
|
From: Glauco S. <gla...@us...> - 2005-07-29 13:26:11
|
Update of /cvsroot/quantproject/QuantProject/b3_Data In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27347/b3_Data Modified Files: b3_Data.csproj Log Message: Selectors\SelectorByGroup.cs has been added Index: b3_Data.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/b3_Data.csproj,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** b3_Data.csproj 30 May 2005 18:28:13 -0000 1.29 --- b3_Data.csproj 29 Jul 2005 13:26:03 -0000 1.30 *************** *** 288,291 **** --- 288,296 ---- /> <File + RelPath = "Selectors\SelectorByGroup.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Selectors\SelectorByLiquidity.cs" SubType = "Code" |
|
From: Marco M. <mi...@us...> - 2005-07-27 22:37:25
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29454/b7_Scripts Modified Files: Scripts.prjx Log Message: Updated #develop projects files. Index: Scripts.prjx =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/Scripts.prjx,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Scripts.prjx 25 Jul 2005 23:00:51 -0000 1.7 --- Scripts.prjx 27 Jul 2005 22:37:14 -0000 1.8 *************** *** 45,48 **** --- 45,50 ---- <File name=".\WalkForwardTesting\LinearCombination\RunBestLinearCombination.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> <File name=".\WalkForwardTesting\LinearCombination\TestDisplayer.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\TickerSelectionTesting\EndOfDayTimerHandlerCTCWeekly.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\TickerSelectionTesting\RunEfficientCTCWeeklyPortfolio.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> </Contents> <References> |
|
From: Marco M. <mi...@us...> - 2005-07-27 22:37:25
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29454/b1_ADT Modified Files: ADT.prjx Log Message: Updated #develop projects files. Index: ADT.prjx =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/ADT.prjx,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ADT.prjx 25 Jul 2005 23:00:50 -0000 1.5 --- ADT.prjx 27 Jul 2005 22:37:14 -0000 1.6 *************** *** 34,37 **** --- 34,38 ---- <File name=".\EstimatedObject.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> <File name=".\Optimizing\Genetic\NewGenerationEventArgs.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\Optimizing\Genetic\GenomeCounter.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> </Contents> <References /> |
|
From: Marco M. <mi...@us...> - 2005-07-27 22:36:56
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29372/b1_ADT Modified Files: b1_ADT.csproj Log Message: Added GenomeCounter object for counting how many different genomes are generated by a given GeneticOptimizer Index: b1_ADT.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/b1_ADT.csproj,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** b1_ADT.csproj 13 Jul 2005 16:30:30 -0000 1.18 --- b1_ADT.csproj 27 Jul 2005 22:36:48 -0000 1.19 *************** *** 198,201 **** --- 198,206 ---- /> <File + RelPath = "Optimizing\Genetic\GenomeCounter.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Optimizing\Genetic\GenomeManagement.cs" SubType = "Code" |
|
From: Marco M. <mi...@us...> - 2005-07-27 22:35:46
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29121/b1_ADT/Optimizing/Genetic Added Files: GenomeCounter.cs Log Message: Added GenomeCounter object for counting how many different genomes are generated by a given GeneticOptimizer. --- NEW FILE: GenomeCounter.cs --- /* QuantProject - Quantitative Finance Library GenomeCounter.cs Copyright (C) 2003 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; namespace QuantProject.ADT.Optimizing.Genetic { /// <summary> /// This object subscribes GeneticOptimizer's NewGeneration event /// in order to count how many genomes are totally tested /// Note: two different genomes are supposed to have different /// fitness values /// /// </summary> [Serializable] public class GenomeCounter { private Hashtable fitnessCollector; private GeneticOptimizer geneticOptimizer; public int TotalEvaluatedGenomes { get{return this.fitnessCollector.Count;} } public double BestFitness { get{return this.geneticOptimizer.BestGenome.Fitness;} } /// <summary> /// The instance of GenomeCounter has to be created /// before running the given GeneticOptimizer /// </summary> public GenomeCounter(GeneticOptimizer geneticOptimizer) { this.geneticOptimizer = geneticOptimizer; this.fitnessCollector = new Hashtable(); this.geneticOptimizer.NewGeneration += new NewGenerationEventHandler(this.newGenerationEventHandler); } private void newGenerationEventHandler(Object sender, NewGenerationEventArgs newGenerationEventArgs) { foreach(Genome genome in this.geneticOptimizer.CurrentGeneration) { if(!this.fitnessCollector.ContainsKey(genome.Fitness)) //the hashtable fitnessCollector doesn't contain the //current genome's fitness, yet this.fitnessCollector.Add(genome.Fitness, null); } } } } |
|
From: Marco M. <mi...@us...> - 2005-07-27 22:34:33
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28878/b1_ADT/Optimizing/Genetic Modified Files: GeneticOptimizer.cs Log Message: Added new constructor for the GeneticOptimizer; changed default values for mutationRate and the elitismRate (set to 0). Index: GeneticOptimizer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic/GeneticOptimizer.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** GeneticOptimizer.cs 25 Jul 2005 22:27:49 -0000 1.7 --- GeneticOptimizer.cs 27 Jul 2005 22:34:24 -0000 1.8 *************** *** 127,130 **** --- 127,134 ---- get{return this.worstGenome;} } + public ArrayList CurrentGeneration + { + get{return this.currentGeneration;} + } #endregion *************** *** 147,150 **** --- 151,163 ---- } + public GeneticOptimizer(IGenomeManager genomeManager, int populationSize, + int generationNumber, int seedForRandomGenerator) + { + this.genomeManager = genomeManager; + this.populationSize = populationSize; + this.generationNumber = generationNumber; + this.random = new Random(seedForRandomGenerator); + this.commonInitialization(); + } public GeneticOptimizer(double crossoverRate, double mutationRate, double elitismRate, *************** *** 178,184 **** private void commonInitialization() { ! this.mutationRate = 0.02; this.crossoverRate = 0.85; ! this.elitismRate = 0.01; this.minConvergenceRate = 0.80; this.keepOnRunningUntilConvergenceIsReached = false; --- 191,197 ---- private void commonInitialization() { ! this.mutationRate = 0.10; this.crossoverRate = 0.85; ! this.elitismRate = 0.0; this.minConvergenceRate = 0.80; this.keepOnRunningUntilConvergenceIsReached = false; |
|
From: Marco M. <mi...@us...> - 2005-07-27 22:32:23
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28334/b1_ADT Modified Files: ConstantsProvider.cs Log Message: Added constant for getting the seed for the random generator of the GeneticOptimizer and the GenomeManagement class Index: ConstantsProvider.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/ConstantsProvider.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ConstantsProvider.cs 19 Jun 2005 14:57:11 -0000 1.11 --- ConstantsProvider.cs 27 Jul 2005 22:32:05 -0000 1.12 *************** *** 32,35 **** --- 32,37 ---- public static int CachePages = 1000; public static int PagesToBeRemovedFromCache = 500; // for Garbage Collection + public static int SeedForRandomGenerator = 333; // for GeneticOptimizer and + // GenomeManagement } } |
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27684/b7_Scripts/TickerSelectionTesting Modified Files: EndOfDayTimerHandler.cs EndOfDayTimerHandlerCTC.cs EndOfDayTimerHandlerCTCTest.cs EndOfDayTimerHandlerCTO.cs EndOfDayTimerHandlerCTOTest.cs GenomeManagerForEfficientCTCPortfolio.cs GenomeManagerForEfficientPortfolio.cs RunEfficientCTCPortfolio.cs RunEfficientCTOPortfolio.cs RunEfficientPortfolio.cs RunLastChosenPortfolioOutOfSample.cs RunTestOptimizedCTCPortfolio.cs RunTestOptimizedCTOPortfolio.cs Log Message: - "Porfolio" fixed to "Portfolio"; - added GenomeCounter to the base EndOfDayTimerHandler; - modified setTickers methods in close to close and open to close Handlers in order to provide the use of GenomeCounter object; - showed in form.Text property GenomeCounter's info for the RunTestOptimizedCTCPortfolio and RunTestOptimizedCTOPortfolio Index: RunTestOptimizedCTOPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunTestOptimizedCTOPortfolio.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** RunTestOptimizedCTOPortfolio.cs 25 Jul 2005 22:35:43 -0000 1.5 --- RunTestOptimizedCTOPortfolio.cs 27 Jul 2005 22:30:56 -0000 1.6 *************** *** 50,57 **** /// </summary> [Serializable] ! public class RunTestOptimizedCTOPorfolio : RunEfficientCTOPorfolio { ! public RunTestOptimizedCTOPorfolio(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForLiquidity, int generationNumberForGeneticOptimizer, --- 50,57 ---- /// </summary> [Serializable] ! public class RunTestOptimizedCTOPortfolio : RunEfficientCTOPortfolio { ! public RunTestOptimizedCTOPortfolio(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForLiquidity, int generationNumberForGeneticOptimizer, *************** *** 98,101 **** --- 98,102 ---- this.benchmark ); report.Show(); + report.Text = this.getGenomeCounterInfo(); } Index: EndOfDayTimerHandler.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandler.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** EndOfDayTimerHandler.cs 24 Jun 2005 22:52:25 -0000 1.13 --- EndOfDayTimerHandler.cs 27 Jul 2005 22:30:55 -0000 1.14 *************** *** 66,69 **** --- 66,75 ---- protected PortfolioType portfolioType; + + protected GenomeCounter genomeCounter; + public GenomeCounter GenomeCounter + { + get{return this.genomeCounter;} + } public string[] LastChosenTickers Index: RunEfficientCTCPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunEfficientCTCPortfolio.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** RunEfficientCTCPortfolio.cs 25 Jul 2005 22:36:56 -0000 1.9 --- RunEfficientCTCPortfolio.cs 27 Jul 2005 22:30:55 -0000 1.10 *************** *** 57,61 **** /// </summary> [Serializable] ! public class RunEfficientCTCPorfolio : RunEfficientPorfolio { protected int numDayOfPortfolioLife; --- 57,61 ---- /// </summary> [Serializable] ! public class RunEfficientCTCPortfolio : RunEfficientPortfolio { protected int numDayOfPortfolioLife; *************** *** 63,67 **** protected double maxAcceptableCloseToCloseDrawdown; ! public RunEfficientCTCPorfolio(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForLiquidity, int generationNumberForGeneticOptimizer, --- 63,67 ---- protected double maxAcceptableCloseToCloseDrawdown; ! public RunEfficientCTCPortfolio(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForLiquidity, int generationNumberForGeneticOptimizer, Index: RunTestOptimizedCTCPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunTestOptimizedCTCPortfolio.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RunTestOptimizedCTCPortfolio.cs 25 Jul 2005 22:35:43 -0000 1.3 --- RunTestOptimizedCTCPortfolio.cs 27 Jul 2005 22:30:56 -0000 1.4 *************** *** 57,61 **** /// </summary> [Serializable] ! public class RunTestOptimizedCTCPortfolio : RunEfficientCTCPorfolio { --- 57,61 ---- /// </summary> [Serializable] ! public class RunTestOptimizedCTCPortfolio : RunEfficientCTCPortfolio { *************** *** 107,110 **** --- 107,111 ---- this.benchmark ); report.Show(); + report.Text = this.getGenomeCounterInfo(); } Index: GenomeManagerForEfficientCTCPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/GenomeManagerForEfficientCTCPortfolio.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** GenomeManagerForEfficientCTCPortfolio.cs 25 Jul 2005 22:49:54 -0000 1.8 --- GenomeManagerForEfficientCTCPortfolio.cs 27 Jul 2005 22:30:55 -0000 1.9 *************** *** 40,44 **** public class GenomeManagerForEfficientCTCPortfolio : GenomeManagerForEfficientPortfolio { - private int numDaysOfPortfolioLife; private int numDaysForReturnCalculation; --- 40,43 ---- *************** *** 47,51 **** DateTime lastQuoteDate, int numberOfTickersInPortfolio, - int numDaysOfPortfolioLife, int numDaysForReturnCalculation, double targetPerformance, --- 46,49 ---- *************** *** 61,65 **** { - this.numDaysOfPortfolioLife = numDaysOfPortfolioLife; this.numDaysForReturnCalculation = numDaysForReturnCalculation; this.retrieveData(); --- 59,62 ---- Index: EndOfDayTimerHandlerCTO.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerCTO.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** EndOfDayTimerHandlerCTO.cs 25 Jul 2005 22:52:02 -0000 1.14 --- EndOfDayTimerHandlerCTO.cs 27 Jul 2005 22:30:55 -0000 1.15 *************** *** 46,49 **** --- 46,50 ---- protected int numDaysBetweenEachOptimization; private int numDaysElapsedSinceLastOptimization; + public EndOfDayTimerHandlerCTO(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForLiquidity, Account account, *************** *** 132,137 **** } ! ! protected virtual void setTickers(DateTime currentDate) { --- 133,138 ---- } ! protected virtual void setTickers(DateTime currentDate, ! bool setGenomeCounter) { *************** *** 152,156 **** GeneticOptimizer GO = new GeneticOptimizer(genManEfficientCTOPortfolio, this.populationSizeForGeneticOptimizer, ! this.generationNumberForGeneticOptimizer); GO.Run(false); --- 153,160 ---- GeneticOptimizer GO = new GeneticOptimizer(genManEfficientCTOPortfolio, this.populationSizeForGeneticOptimizer, ! this.generationNumberForGeneticOptimizer, ! ConstantsProvider.SeedForRandomGenerator); ! if(setGenomeCounter) ! this.genomeCounter = new GenomeCounter(GO); GO.Run(false); *************** *** 184,188 **** this.numDaysBetweenEachOptimization) { ! this.setTickers(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime); //sets tickers to be chosen next Market Open event this.numDaysElapsedSinceLastOptimization = 0; --- 188,192 ---- this.numDaysBetweenEachOptimization) { ! this.setTickers(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime, false); //sets tickers to be chosen next Market Open event this.numDaysElapsedSinceLastOptimization = 0; Index: RunLastChosenPortfolioOutOfSample.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunLastChosenPortfolioOutOfSample.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RunLastChosenPortfolioOutOfSample.cs 25 Jun 2005 09:50:44 -0000 1.2 --- RunLastChosenPortfolioOutOfSample.cs 27 Jul 2005 22:30:56 -0000 1.3 *************** *** 52,56 **** /// </summary> [Serializable] ! public class RunLastChosenPortfolioOutOfSample : RunEfficientPorfolio { private string[] tickers; --- 52,56 ---- /// </summary> [Serializable] ! public class RunLastChosenPortfolioOutOfSample : RunEfficientPortfolio { private string[] tickers; Index: EndOfDayTimerHandlerCTOTest.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerCTOTest.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** EndOfDayTimerHandlerCTOTest.cs 26 Jun 2005 14:53:07 -0000 1.5 --- EndOfDayTimerHandlerCTOTest.cs 27 Jul 2005 22:30:55 -0000 1.6 *************** *** 45,48 **** --- 45,49 ---- { private static bool optimized; + public EndOfDayTimerHandlerCTOTest(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForLiquidity, Account account, *************** *** 61,69 **** } ! protected override void setTickers(DateTime currentDate) { ! if(!EndOfDayTimerHandlerCTOTest.optimized) { ! base.setTickers(currentDate.AddDays(this.numDaysForLiquidity)); EndOfDayTimerHandlerCTOTest.optimized = true; } --- 62,74 ---- } ! protected override void setTickers(DateTime currentDate, ! bool setGenomeCounter) { ! //setGenomeCounter never used; it is necessary for overriding ! ! if(!EndOfDayTimerHandlerCTOTest.optimized) { ! base.setTickers(currentDate.AddDays(this.numDaysForLiquidity), ! true); EndOfDayTimerHandlerCTOTest.optimized = true; } Index: RunEfficientPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunEfficientPortfolio.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** RunEfficientPortfolio.cs 25 Jun 2005 09:50:44 -0000 1.10 --- RunEfficientPortfolio.cs 27 Jul 2005 22:30:56 -0000 1.11 *************** *** 2,6 **** QuantProject - Quantitative Finance Library ! RunEfficientPorfolio.cs Copyright (C) 2003 Marco Milletti --- 2,6 ---- QuantProject - Quantitative Finance Library ! RunEfficientPortfolio.cs Copyright (C) 2003 Marco Milletti *************** *** 51,55 **** /// </summary> [Serializable] ! public class RunEfficientPorfolio { protected string tickerGroupID; --- 51,55 ---- /// </summary> [Serializable] ! public class RunEfficientPortfolio { protected string tickerGroupID; *************** *** 108,112 **** } ! public RunEfficientPorfolio(string benchmark, DateTime startDate, DateTime endDate, PortfolioType portfolioType, --- 108,112 ---- } ! public RunEfficientPortfolio(string benchmark, DateTime startDate, DateTime endDate, PortfolioType portfolioType, *************** *** 126,130 **** } ! public RunEfficientPorfolio(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForLiquidity, int generationNumberForGeneticOptimizer, --- 126,130 ---- } ! public RunEfficientPortfolio(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForLiquidity, int generationNumberForGeneticOptimizer, *************** *** 155,158 **** --- 155,170 ---- //this.numIntervalDays = 3; } + + protected string getGenomeCounterInfo() + { + string returnValue = ""; + if(this.endOfDayTimerHandler.GenomeCounter != null) + returnValue = "Total generated genomes: " + + this.endOfDayTimerHandler.GenomeCounter.TotalEvaluatedGenomes.ToString() + + "; Current fitness: " + + this.endOfDayTimerHandler.GenomeCounter.BestFitness.ToString(); + return returnValue; + } + #region Run Index: EndOfDayTimerHandlerCTCTest.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerCTCTest.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** EndOfDayTimerHandlerCTCTest.cs 26 Jun 2005 14:53:07 -0000 1.2 --- EndOfDayTimerHandlerCTCTest.cs 27 Jul 2005 22:30:55 -0000 1.3 *************** *** 71,79 **** } ! protected override void setTickers(DateTime currentDate) { if(!EndOfDayTimerHandlerCTCTest.optimized) { ! base.setTickers(currentDate.AddDays(this.numDaysForLiquidity)); EndOfDayTimerHandlerCTCTest.optimized = true; } --- 71,82 ---- } ! protected override void setTickers(DateTime currentDate, ! bool setGenomeCounter) { + //setGenomeCounter never used; it is necessary for overriding if(!EndOfDayTimerHandlerCTCTest.optimized) { ! base.setTickers(currentDate.AddDays(this.numDaysForLiquidity), ! true); EndOfDayTimerHandlerCTCTest.optimized = true; } Index: RunEfficientCTOPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunEfficientCTOPortfolio.cs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** RunEfficientCTOPortfolio.cs 24 Jun 2005 22:52:25 -0000 1.20 --- RunEfficientCTOPortfolio.cs 27 Jul 2005 22:30:56 -0000 1.21 *************** *** 54,61 **** /// </summary> [Serializable] ! public class RunEfficientCTOPorfolio : RunEfficientPorfolio { protected int numDaysBetweenEachOptimization; ! public RunEfficientCTOPorfolio(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForLiquidity, int generationNumberForGeneticOptimizer, --- 54,61 ---- /// </summary> [Serializable] ! public class RunEfficientCTOPortfolio : RunEfficientPortfolio { protected int numDaysBetweenEachOptimization; ! public RunEfficientCTOPortfolio(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForLiquidity, int generationNumberForGeneticOptimizer, Index: GenomeManagerForEfficientPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/GenomeManagerForEfficientPortfolio.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** GenomeManagerForEfficientPortfolio.cs 25 Jul 2005 22:47:57 -0000 1.13 --- GenomeManagerForEfficientPortfolio.cs 27 Jul 2005 22:30:55 -0000 1.14 *************** *** 120,123 **** --- 120,124 ---- this.portfolioType = portfolioType; this.setMinAndMaxValueForGenes(); + GenomeManagement.SetRandomGenerator(QuantProject.ADT.ConstantsProvider.SeedForRandomGenerator); } *************** *** 203,207 **** public Genome[] GetChilds(Genome parent1, Genome parent2) { ! return GenomeManagement.MixGenesWithoutDuplicates(parent1, parent2, this.constToDiscoverDuplicateGenes); --- 204,208 ---- public Genome[] GetChilds(Genome parent1, Genome parent2) { ! return GenomeManagement.MixGenesWithoutDuplicates(parent1, parent2, this.constToDiscoverDuplicateGenes); Index: EndOfDayTimerHandlerCTC.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerCTC.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** EndOfDayTimerHandlerCTC.cs 25 Jul 2005 22:59:57 -0000 1.10 --- EndOfDayTimerHandlerCTC.cs 27 Jul 2005 22:30:55 -0000 1.11 *************** *** 147,151 **** ! protected virtual void setTickers(DateTime currentDate) { DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); --- 147,152 ---- ! protected virtual void setTickers(DateTime currentDate, ! bool setGenomeCounter) { DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); *************** *** 164,174 **** currentDate.AddDays(-this.numDaysForLiquidity), currentDate, this.numberOfTickersToBeChosen, ! this.numDaysOfPortfolioLife, this.numDaysForReturnCalculation, this.targetReturn, this.portfolioType); GeneticOptimizer GO = new GeneticOptimizer(genManEfficientCTCPortfolio, this.populationSizeForGeneticOptimizer, ! this.generationNumberForGeneticOptimizer); ! //GO.KeepOnRunningUntilConvergenceIsReached = true; GO.Run(false); this.chosenTickers = (string[])GO.BestGenome.Meaning; --- 165,178 ---- currentDate.AddDays(-this.numDaysForLiquidity), currentDate, this.numberOfTickersToBeChosen, ! this.numDaysForReturnCalculation, this.targetReturn, this.portfolioType); GeneticOptimizer GO = new GeneticOptimizer(genManEfficientCTCPortfolio, this.populationSizeForGeneticOptimizer, ! this.generationNumberForGeneticOptimizer, ! ConstantsProvider.SeedForRandomGenerator); ! if(setGenomeCounter) ! this.genomeCounter = new GenomeCounter(GO); ! GO.Run(false); this.chosenTickers = (string[])GO.BestGenome.Meaning; *************** *** 191,195 **** { this.orders.Clear(); ! this.setTickers(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime); //it sets tickers to be chosen at next close } --- 195,199 ---- { this.orders.Clear(); ! this.setTickers(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime, false); //it sets tickers to be chosen at next close } |
|
From: Marco M. <mi...@us...> - 2005-07-27 22:23:24
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26140/b7_Scripts Modified Files: b7_Scripts.csproj Log Message: Added files for testing the close to close efficient portfolio buyed at monday and sold at friday; Index: b7_Scripts.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/b7_Scripts.csproj,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** b7_Scripts.csproj 25 Jul 2005 22:24:09 -0000 1.32 --- b7_Scripts.csproj 27 Jul 2005 22:23:14 -0000 1.33 *************** *** 184,187 **** --- 184,192 ---- /> <File + RelPath = "TickerSelectionTesting\EndOfDayTimerHandlerCTCWeekly.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "TickerSelectionTesting\EndOfDayTimerHandlerCTO.cs" SubType = "Code" *************** *** 224,227 **** --- 229,237 ---- /> <File + RelPath = "TickerSelectionTesting\RunEfficientCTCWeeklyPortfolio.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "TickerSelectionTesting\RunEfficientCTOPortfolio.cs" SubType = "Code" |
|
From: Marco M. <mi...@us...> - 2005-07-27 22:22:24
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25903/b7_Scripts/TickerSelectionTesting Added Files: EndOfDayTimerHandlerCTCWeekly.cs RunEfficientCTCWeeklyPortfolio.cs Log Message: Added files for testing the close to close efficient portfolio buyed at monday and sold at friday. --- NEW FILE: RunEfficientCTCWeeklyPortfolio.cs --- /* QuantProject - Quantitative Finance Library RunEfficientCTCWeeklyPorfolio.cs Copyright (C) 2003 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.Data; using QuantProject.ADT; using QuantProject.ADT.Optimizing.Genetic; using QuantProject.Business.DataProviders; using QuantProject.Business.Financial.Accounting; using QuantProject.Business.Financial.Accounting.Reporting; using QuantProject.Business.Financial.Instruments; using QuantProject.Business.Financial.Ordering; using QuantProject.Business.Scripting; using QuantProject.Business.Strategies; using QuantProject.Business.Testing; using QuantProject.Business.Timing; using QuantProject.Data.DataProviders; using QuantProject.Data.Selectors; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; using QuantProject.Presentation.Reporting.WindowsForm; using QuantProject.ADT.FileManaging; namespace QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios { /// <summary> /// Script to buy at close on Monday and sell at close /// on next Friday (or before, if drawdown crosses a given level) /// The efficient portfolio's generation rules are /// contained in EndOfDayTimerHandlerCTCWeekly class /// </summary> [Serializable] public class RunEfficientCTCWeeklyPortfolio : RunEfficientPortfolio { protected int numDaysForReturnCalculation; protected double maxAcceptableCloseToCloseDrawdown; public RunEfficientCTCWeeklyPortfolio(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForLiquidity, int generationNumberForGeneticOptimizer, int populationSizeForGeneticOptimizer, string benchmark, DateTime startDate, DateTime endDate, int numDaysForReturnCalculation, double targetReturn, PortfolioType portfolioType, double maxAcceptableCloseToCloseDrawdown, double maxRunningHours): base(tickerGroupID, numberOfEligibleTickers, numberOfTickersToBeChosen, numDaysForLiquidity, generationNumberForGeneticOptimizer, populationSizeForGeneticOptimizer, benchmark, startDate, endDate, targetReturn, portfolioType, maxRunningHours) { this.ScriptName = "CloseToCloseScriptsWeeklyEfficientPortfolio"; this.numDaysForReturnCalculation = numDaysForReturnCalculation; this.maxAcceptableCloseToCloseDrawdown = maxAcceptableCloseToCloseDrawdown; } #region auxiliary overriden methods for Run protected override void run_initializeEndOfDayTimerHandler() { this.endOfDayTimerHandler = new EndOfDayTimerHandlerCTCWeekly(this.tickerGroupID, this.numberOfEligibleTickers, this.numberOfTickersToBeChosen, this.numDaysForLiquidity, this.account, this.generationNumberForGeneticOptimizer, this.populationSizeForGeneticOptimizer, this.benchmark, this.numDaysForReturnCalculation, this.targetReturn, this.portfolioType, this.maxAcceptableCloseToCloseDrawdown); } protected override void run_initializeHistoricalQuoteProvider() { this.historicalQuoteProvider = new HistoricalAdjustedQuoteProvider(); } protected override void run_addEventHandlers() { this.endOfDayTimer.MarketClose += new MarketCloseEventHandler( this.endOfDayTimerHandler.MarketCloseEventHandler); this.endOfDayTimer.MarketClose += new MarketCloseEventHandler( this.checkDateForReport); this.endOfDayTimer.OneHourAfterMarketClose += new OneHourAfterMarketCloseEventHandler( this.endOfDayTimerHandler.OneHourAfterMarketCloseEventHandler); } #endregion } } --- NEW FILE: EndOfDayTimerHandlerCTCWeekly.cs --- /* QuantProject - Quantitative Finance Library EndOfDayTimerHandlerCTCWeekly.cs Copyright (C) 2003 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.Business.Financial.Accounting; using QuantProject.Business.Financial.Instruments; using QuantProject.Business.Financial.Ordering; using QuantProject.Business.Timing; using QuantProject.Data.DataProviders; using QuantProject.Data.Selectors; using QuantProject.ADT.Optimizing.Genetic; namespace QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios { /// <summary> /// Implements MarketOpenEventHandler and MarketCloseEventHandler /// These handlers contain the core strategy for the efficient close to close /// weekly portfolio (with a given days of life)! /// </summary> [Serializable] public class EndOfDayTimerHandlerCTCWeekly : EndOfDayTimerHandler { protected int numDaysForReturnCalculation; protected double maxAcceptableCloseToCloseDrawdown; protected bool stopLossConditionReached; protected double currentAccountValue; protected double previousAccountValue; public EndOfDayTimerHandlerCTCWeekly(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForLiquidity, Account account, int generationNumberForGeneticOptimizer, int populationSizeForGeneticOptimizer, string benchmark, int numDaysForReturnCalculation, double targetReturn, PortfolioType portfolioType, double maxAcceptableCloseToCloseDrawdown): base(tickerGroupID, numberOfEligibleTickers, numberOfTickersToBeChosen, numDaysForLiquidity, account, generationNumberForGeneticOptimizer, populationSizeForGeneticOptimizer, benchmark, targetReturn, portfolioType) { this.numDaysForReturnCalculation = numDaysForReturnCalculation; this.maxAcceptableCloseToCloseDrawdown = maxAcceptableCloseToCloseDrawdown; this.stopLossConditionReached = false; this.currentAccountValue = 0.0; this.previousAccountValue = 0.0; } #region MarketCloseEventHandler protected void updateStopLossCondition() { this.previousAccountValue = this.currentAccountValue; this.currentAccountValue = this.account.GetMarketValue(); if((this.currentAccountValue - this.previousAccountValue) /this.previousAccountValue < -this.maxAcceptableCloseToCloseDrawdown) { this.stopLossConditionReached = true; } else { this.stopLossConditionReached = false; } } public override void MarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { this.updateStopLossCondition(); if(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime.DayOfWeek == DayOfWeek.Monday) this.openPositions(); if(this.stopLossConditionReached || endOfDayTimingEventArgs.EndOfDayDateTime.DateTime.DayOfWeek == DayOfWeek.Friday) this.closePositions(); } #endregion #region OneHourAfterMarketCloseEventHandler protected DataTable getSetOfTickersToBeOptimized(DateTime currentDate) { SelectorByLiquidity mostLiquid = new SelectorByLiquidity(this.tickerGroupID,false, currentDate.AddDays(-this.numDaysForLiquidity), currentDate, this.numberOfEligibleTickers); this.eligibleTickers = mostLiquid.GetTableOfSelectedTickers(); SelectorByQuotationAtEachMarketDay quotedAtEachMarketDayFromMostLiquid = new SelectorByQuotationAtEachMarketDay(this.eligibleTickers, false, currentDate.AddDays(-this.numDaysForLiquidity),currentDate, this.numberOfEligibleTickers, this.benchmark); return quotedAtEachMarketDayFromMostLiquid.GetTableOfSelectedTickers(); } protected virtual void setTickers(DateTime currentDate) { DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); if(setOfTickersToBeOptimized.Rows.Count > this.chosenTickers.Length*2) //the optimization process is meaningful only if the initial set of tickers is //larger than the number of tickers to be chosen { //double targetReturnForEachPeriodOfPortfolioLife = // Math.Pow(1.60,(double)(1.0/(360.0/this.numDaysOfPortfolioLife))) - 1.0; //the target has to be such that annual system return is minimum 50% //(with no commissions and bid-ask spreads) IGenomeManager genManEfficientCTCPortfolio = new GenomeManagerForEfficientCTCPortfolio(setOfTickersToBeOptimized, currentDate.AddDays(-this.numDaysForLiquidity), currentDate, this.numberOfTickersToBeChosen, this.numDaysForReturnCalculation, this.targetReturn, this.portfolioType); GeneticOptimizer GO = new GeneticOptimizer(genManEfficientCTCPortfolio, this.populationSizeForGeneticOptimizer, this.generationNumberForGeneticOptimizer); //GO.KeepOnRunningUntilConvergenceIsReached = true; GO.Run(false); this.chosenTickers = (string[])GO.BestGenome.Meaning; } //else it will be buyed again the previous optimized portfolio //that's it the actual chosenTickers member } /// <summary> /// Handles a "One hour after market close" event. /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> public override void OneHourAfterMarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { if(this.account.Portfolio.Count == 0 && endOfDayTimingEventArgs.EndOfDayDateTime.DateTime.DayOfWeek == DayOfWeek.Friday) { this.orders.Clear(); this.setTickers(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime); //it sets tickers to be chosen at next Monday } } #endregion } } |
|
From: Marco M. <mi...@us...> - 2005-07-25 23:01:02
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26877/b1_ADT Modified Files: ADT.prjx Log Message: Updated #develop projects files. Index: ADT.prjx =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/ADT.prjx,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ADT.prjx 24 Jun 2005 22:54:50 -0000 1.4 --- ADT.prjx 25 Jul 2005 23:00:50 -0000 1.5 *************** *** 33,36 **** --- 33,37 ---- <File name=".\Statistics\AdvancedFunctions.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> <File name=".\EstimatedObject.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\Optimizing\Genetic\NewGenerationEventArgs.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> </Contents> <References /> |
|
From: Marco M. <mi...@us...> - 2005-07-25 23:01:00
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26877/b7_Scripts Modified Files: Scripts.prjx Log Message: Updated #develop projects files. Index: Scripts.prjx =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/Scripts.prjx,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Scripts.prjx 24 Jun 2005 22:54:51 -0000 1.6 --- Scripts.prjx 25 Jul 2005 23:00:51 -0000 1.7 *************** *** 37,40 **** --- 37,48 ---- <File name=".\TickerSelectionTesting\EndOfDayTimerHandlerLastChosenPortfolio.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> <File name=".\TickerSelectionTesting\RunLastChosenPortfolioOutOfSample.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\WalkForwardTesting\LinearCombination\GenomeRepresentation.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\TickerSelectionTesting\CandidateProperties.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\WalkForwardTesting\LinearCombination\VisualObjectArchiver.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\WalkForwardTesting\LinearCombination\LinearCombinationTest.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\WalkForwardTesting\LinearCombination\MainForm.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\WalkForwardTesting\LinearCombination\OptimizationOutput.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\WalkForwardTesting\LinearCombination\RunBestLinearCombination.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\WalkForwardTesting\LinearCombination\TestDisplayer.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> </Contents> <References> |
|
From: Marco M. <mi...@us...> - 2005-07-25 23:00:06
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26639/b7_Scripts/TickerSelectionTesting Modified Files: EndOfDayTimerHandlerCTC.cs Log Message: Now the EndOfDayTimerHandler for the Close To Close efficient portfolio contains a handler for the OneHourAfterMarketCloseEvent. Now, if at a given Close some positions are closed, new positions are opened at the next Close. Index: EndOfDayTimerHandlerCTC.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerCTC.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** EndOfDayTimerHandlerCTC.cs 24 Jun 2005 22:52:25 -0000 1.9 --- EndOfDayTimerHandlerCTC.cs 25 Jul 2005 22:59:57 -0000 1.10 *************** *** 51,55 **** protected double currentAccountValue; protected double previousAccountValue; ! public EndOfDayTimerHandlerCTC(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForLiquidity, --- 51,55 ---- protected double currentAccountValue; protected double previousAccountValue; ! public EndOfDayTimerHandlerCTC(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForLiquidity, *************** *** 71,75 **** this.numDaysOfPortfolioLife = numDaysOfPortfolioLife; this.numDaysForReturnCalculation = numDaysForReturnCalculation; ! this.daysCounter = -1; this.maxAcceptableCloseToCloseDrawdown = maxAcceptableCloseToCloseDrawdown; this.stopLossConditionReached = false; --- 71,75 ---- this.numDaysOfPortfolioLife = numDaysOfPortfolioLife; this.numDaysForReturnCalculation = numDaysForReturnCalculation; ! this.daysCounter = 0; this.maxAcceptableCloseToCloseDrawdown = maxAcceptableCloseToCloseDrawdown; this.stopLossConditionReached = false; *************** *** 77,82 **** this.previousAccountValue = 0.0; } ! ! #region MarketOpenEventHandler protected DataTable getSetOfTickersToBeOptimized(DateTime currentDate) { --- 77,135 ---- this.previousAccountValue = 0.0; } ! ! ! #region MarketCloseEventHandler ! ! ! ! protected void updateStopLossCondition() ! { ! this.previousAccountValue = this.currentAccountValue; ! this.currentAccountValue = this.account.GetMarketValue(); ! if((this.currentAccountValue - this.previousAccountValue) ! /this.previousAccountValue < -this.maxAcceptableCloseToCloseDrawdown) ! { ! this.stopLossConditionReached = true; ! } ! else ! { ! this.stopLossConditionReached = false; ! } ! } ! ! public override void MarketCloseEventHandler( ! Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) ! { ! bool positionsJustClosed = false; ! this.updateStopLossCondition(); ! if(this.account.Portfolio.Count > 0) ! //portfolio is not empty ! { ! this.daysCounter++; ! if(this.daysCounter == this.numDaysOfPortfolioLife || ! this.stopLossConditionReached) ! //num days of portfolio life or ! //max acceptable close to close drawdown reached ! { ! this.closePositions(); ! this.daysCounter = 0; ! positionsJustClosed = true; ! } ! } ! ! if(this.account.Portfolio.Count == 0 && ! !positionsJustClosed) ! //portfolio is empty but it has not been closed ! //at the current close ! { ! this.openPositions(); ! this.daysCounter = 0; ! } ! } ! ! #endregion ! ! #region OneHourAfterMarketCloseEventHandler ! protected DataTable getSetOfTickersToBeOptimized(DateTime currentDate) { *************** *** 125,191 **** } /// <summary> ! /// Handles a "Market Open" event. /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> ! public override void MarketOpenEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! this.updateStopLossCondition(); ! if(this.daysCounter == -1 || this.daysCounter == this.numDaysOfPortfolioLife - 1 || ! this.stopLossConditionReached ) ! //at the beginning, after num days of porfolio life has elasped, ! //or when the stop loss condition is reached { this.setTickers(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime); //it sets tickers to be chosen at next close - this.orders.Clear(); } } #endregion - - #region MarketCloseEventHandler - - - - protected void updateStopLossCondition() - { - this.previousAccountValue = this.currentAccountValue; - this.currentAccountValue = this.account.GetMarketValue(); - if((this.currentAccountValue - this.previousAccountValue) - /this.previousAccountValue < -this.maxAcceptableCloseToCloseDrawdown) - { - this.stopLossConditionReached = true; - } - else - { - this.stopLossConditionReached = false; - } - } - - public override void MarketCloseEventHandler( - Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) - { - if(this.daysCounter == -1 || - this.daysCounter == this.numDaysOfPortfolioLife || - this.stopLossConditionReached) - //it is the first day or num days of portfolio life or - //max acceptable close to close draw down - //has been reached - { - this.closePositions(); - this.openPositions(); - this.daysCounter = 0; - } - else - { - this.daysCounter++; - } - } - - #endregion - - } } --- 178,199 ---- } + /// <summary> ! /// Handles a "One hour after market close" event. /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> ! public override void OneHourAfterMarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! ! if(this.account.Portfolio.Count == 0 ) { + this.orders.Clear(); this.setTickers(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime); //it sets tickers to be chosen at next close } } #endregion } } |
|
From: Marco M. <mi...@us...> - 2005-07-25 22:52:10
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25583/b7_Scripts/WalkForwardTesting/LinearCombination Modified Files: MainForm.cs Log Message: Index: MainForm.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination/MainForm.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MainForm.cs 23 Jul 2005 18:06:31 -0000 1.2 --- MainForm.cs 25 Jul 2005 22:52:02 -0000 1.3 *************** *** 221,225 **** // this.getSetOfTickersToBeOptimized_quickly(); DataTable setOfTickersToBeOptimized = ! this.getSetOfTickersToBeOptimized_quickly(); // DataTable setOfTickersToBeOptimized = // this.getSetOfTickersToBeOptimized(); --- 221,225 ---- // this.getSetOfTickersToBeOptimized_quickly(); DataTable setOfTickersToBeOptimized = ! this.getSetOfTickersToBeOptimized(); // DataTable setOfTickersToBeOptimized = // this.getSetOfTickersToBeOptimized(); |
|
From: Marco M. <mi...@us...> - 2005-07-25 22:52:10
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25583/b7_Scripts/TickerSelectionTesting Modified Files: EndOfDayTimerHandlerCTO.cs Log Message: Index: EndOfDayTimerHandlerCTO.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerCTO.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** EndOfDayTimerHandlerCTO.cs 24 Jun 2005 22:52:25 -0000 1.13 --- EndOfDayTimerHandlerCTO.cs 25 Jul 2005 22:52:02 -0000 1.14 *************** *** 72,76 **** Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! this.openPositions(); } --- 72,78 ---- Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! //temporarily the if condition ! //if(this.numDaysElapsedSinceLastOptimization == 0) ! this.openPositions(); } *************** *** 79,83 **** Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! this.closePositions(); } --- 81,90 ---- Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! ! //temporarily ! //if(this.numDaysElapsedSinceLastOptimization == ! // this.numDaysBetweenEachOptimization) ! this.closePositions(); ! } *************** *** 116,126 **** // currentDate, this.numberOfEligibleTickers/4); //return winners.GetTableOfSelectedTickers(); ! SelectorByOpenCloseCorrelationToBenchmark lessCorrelated = ! new SelectorByOpenCloseCorrelationToBenchmark(quotedAtEachMarketDayFromEligible.GetTableOfSelectedTickers(), ! this.benchmark, true, ! currentDate.AddDays(-this.numDaysForLiquidity), ! currentDate, this.numberOfEligibleTickers/2); ! //return quotedAtEachMarketDayFromEligible.GetTableOfSelectedTickers(); ! return lessCorrelated.GetTableOfSelectedTickers(); } --- 123,133 ---- // currentDate, this.numberOfEligibleTickers/4); //return winners.GetTableOfSelectedTickers(); ! //SelectorByOpenCloseCorrelationToBenchmark lessCorrelated = ! // new SelectorByOpenCloseCorrelationToBenchmark(quotedAtEachMarketDayFromEligible.GetTableOfSelectedTickers(), ! // this.benchmark, true, ! // currentDate.AddDays(-this.numDaysForLiquidity), ! // currentDate, this.numberOfEligibleTickers/2); ! return quotedAtEachMarketDayFromEligible.GetTableOfSelectedTickers(); ! //return lessCorrelated.GetTableOfSelectedTickers(); } *************** *** 173,177 **** { this.orders.Clear(); - this.numDaysElapsedSinceLastOptimization++; //this.oneHourAfterMarketCloseEventHandler_updatePrices(); if(this.numDaysElapsedSinceLastOptimization == --- 180,183 ---- *************** *** 182,185 **** --- 188,195 ---- this.numDaysElapsedSinceLastOptimization = 0; } + else + { + this.numDaysElapsedSinceLastOptimization++; + } } |
|
From: Marco M. <mi...@us...> - 2005-07-25 22:50:03
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25036/b7_Scripts/TickerSelectionTesting Modified Files: GenomeManagerForEfficientCTCPortfolio.cs GenomeManagerForEfficientCTOPortfolio.cs Log Message: Decode method is now inherited directly by the base class. Index: GenomeManagerForEfficientCTOPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/GenomeManagerForEfficientCTOPortfolio.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** GenomeManagerForEfficientCTOPortfolio.cs 13 Jul 2005 16:37:04 -0000 1.12 --- GenomeManagerForEfficientCTOPortfolio.cs 25 Jul 2005 22:49:54 -0000 1.13 *************** *** 55,98 **** { ! this.retrieveData(); } - - public override object Decode(Genome genome) - { - - string[] arrayOfTickers = new string[genome.Genes().Length]; - int indexOfTicker; - for(int index = 0; index < genome.Genes().Length; index++) - { - indexOfTicker = (int)genome.Genes().GetValue(index); - arrayOfTickers[index] = (string)this.setOfTickers.Rows[indexOfTicker][0]; - } - return arrayOfTickers; - - /*old implementation, to be used for output to console - string sequenceOfTickers = ""; - object returnValue; - foreach(int index in genome.Genes()) - { - sequenceOfTickers += (string)this.setOfTickers.Rows[index][0] + ";" ; - } - returnValue = sequenceOfTickers; - returnValue += "(rate: " + this.RateOfReturn + " std: " + - System.Math.Sqrt(this.Variance) + ")"; - return returnValue; - */ - } - protected override float[] getArrayOfRatesOfReturn(string ticker) { float[] returnValue = null; ! if(!ticker.StartsWith("-")) ! { ! string tickerCode = GenomeManagerForEfficientPortfolio.GetCleanTickerCode(ticker); ! Quotes tickerQuotes = new Quotes(tickerCode, this.firstQuoteDate, this.lastQuoteDate); ! returnValue = ExtendedDataTable.GetRatesOfReturnsFromColumns(tickerQuotes, "quClose", "quOpen"); ! this.numberOfExaminedReturns = returnValue.Length; ! } return returnValue; } --- 55,68 ---- { ! this.retrieveData(); } protected override float[] getArrayOfRatesOfReturn(string ticker) { float[] returnValue = null; ! Quotes tickerQuotes = new Quotes(ticker, this.firstQuoteDate, this.lastQuoteDate); ! returnValue = ExtendedDataTable.GetRatesOfReturnsFromColumns(tickerQuotes, "quClose", "quOpen"); ! this.numberOfExaminedReturns = returnValue.Length; ! return returnValue; } Index: GenomeManagerForEfficientCTCPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/GenomeManagerForEfficientCTCPortfolio.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** GenomeManagerForEfficientCTCPortfolio.cs 13 Jul 2005 16:37:04 -0000 1.7 --- GenomeManagerForEfficientCTCPortfolio.cs 25 Jul 2005 22:49:54 -0000 1.8 *************** *** 66,105 **** } - - public override object Decode(Genome genome) - { - - string[] arrayOfTickers = new string[genome.Genes().Length]; - int indexOfTicker; - for(int index = 0; index < genome.Genes().Length; index++) - { - indexOfTicker = (int)genome.Genes().GetValue(index); - arrayOfTickers[index] = (string)this.setOfTickers.Rows[indexOfTicker][0]; - } - return arrayOfTickers; - - } - protected override float[] getArrayOfRatesOfReturn(string ticker) { float[] returnValue = null; ! if(!ticker.StartsWith("-")) ! { ! string tickerCode = GenomeManagerForEfficientPortfolio.GetCleanTickerCode(ticker); ! Quotes tickerQuotes = new Quotes(tickerCode, this.firstQuoteDate, this.lastQuoteDate); ! float[] allAdjValues = ExtendedDataTable.GetArrayOfFloatFromColumn(tickerQuotes, "quAdjustedClose"); ! returnValue = new float[allAdjValues.Length/this.numDaysForReturnCalculation + 1]; ! int i = 0; //index for ratesOfReturns array - for(int idx = 0; idx + this.numDaysForReturnCalculation < allAdjValues.Length; idx += this.numDaysForReturnCalculation ) - { - returnValue[i] = (allAdjValues[idx+this.numDaysForReturnCalculation]/ - allAdjValues[idx] - 1); - i++; - } - this.numberOfExaminedReturns = returnValue.Length; - } return returnValue; - } /* --- 66,85 ---- } protected override float[] getArrayOfRatesOfReturn(string ticker) { float[] returnValue = null; ! Quotes tickerQuotes = new Quotes(ticker, this.firstQuoteDate, this.lastQuoteDate); ! float[] allAdjValues = ExtendedDataTable.GetArrayOfFloatFromColumn(tickerQuotes, "quAdjustedClose"); ! returnValue = new float[allAdjValues.Length/this.numDaysForReturnCalculation + 1]; ! int i = 0; //index for ratesOfReturns array ! for(int idx = 0; idx + this.numDaysForReturnCalculation < allAdjValues.Length; idx += this.numDaysForReturnCalculation ) ! { ! returnValue[i] = (allAdjValues[idx+this.numDaysForReturnCalculation]/ ! allAdjValues[idx] - 1); ! i++; ! } ! this.numberOfExaminedReturns = returnValue.Length; return returnValue; } /* |
|
From: Marco M. <mi...@us...> - 2005-07-25 22:48:05
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24585/b7_Scripts/TickerSelectionTesting Modified Files: GenomeManagerForEfficientPortfolio.cs Log Message: Added array containing CandidateProperties (information on tickers to be optimized). Code has been simplified in many points. More relevant changes: - Decode method has been updated (and it is now used by inherited classes); - methods for getting portfolio rates of return have been changed (now they are based on the new CandidateProperties class) Index: GenomeManagerForEfficientPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/GenomeManagerForEfficientPortfolio.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** GenomeManagerForEfficientPortfolio.cs 13 Jul 2005 16:37:04 -0000 1.12 --- GenomeManagerForEfficientPortfolio.cs 25 Jul 2005 22:47:57 -0000 1.13 *************** *** 43,48 **** protected int maxValueForGenes; ! protected DataTable setOfTickers; protected int originalNumOfTickers; protected DateTime firstQuoteDate; protected DateTime lastQuoteDate; --- 43,52 ---- protected int maxValueForGenes; ! protected DataTable setOfTickers;//used only for keeping ! //the same signature for ! //protected retrieveData() method ! protected CandidateProperties[] setOfCandidates; protected int originalNumOfTickers; + protected int constToDiscoverDuplicateGenes; protected DateTime firstQuoteDate; protected DateTime lastQuoteDate; *************** *** 55,67 **** protected int numberOfExaminedReturns; ! static public string GetCleanTickerCode(string tickerModifiedCode) { ! if(tickerModifiedCode.StartsWith("-")) ! //if the first char is "-" ! //each element of the array of rates of return is ! //multiplied by -1 ! return tickerModifiedCode.Substring(1,tickerModifiedCode.Length -1); else ! return tickerModifiedCode; } --- 59,68 ---- protected int numberOfExaminedReturns; ! static public string GetCleanTickerCode(string tickerCodeForLongOrShortTrade) { ! if(tickerCodeForLongOrShortTrade.StartsWith("-")) ! return tickerCodeForLongOrShortTrade.Substring(1,tickerCodeForLongOrShortTrade.Length -1); else ! return tickerCodeForLongOrShortTrade; } *************** *** 99,102 **** --- 100,106 ---- } + //setOfInitialTickers has to contain the + //ticker's symbol in the first column ! + public GenomeManagerForEfficientPortfolio(DataTable setOfInitialTickers, DateTime firstQuoteDate, *************** *** 107,114 **** { ! this.setOfTickers = setOfInitialTickers; ! this.originalNumOfTickers = setOfInitialTickers.Rows.Count; ! if(!this.setOfTickers.Columns.Contains("ArrayOfRatesOfReturn")) ! this.setOfTickers.Columns.Add("ArrayOfRatesOfReturn", System.Type.GetType("System.Array")); this.firstQuoteDate = firstQuoteDate; this.lastQuoteDate = lastQuoteDate; --- 111,117 ---- { ! this.setOfTickers = setOfInitialTickers; ! this.originalNumOfTickers = setOfInitialTickers.Rows.Count; ! this.constToDiscoverDuplicateGenes = this.originalNumOfTickers + 1; this.firstQuoteDate = firstQuoteDate; this.lastQuoteDate = lastQuoteDate; *************** *** 117,171 **** this.portfolioType = portfolioType; this.setMinAndMaxValueForGenes(); - this.set_SetOfInitialTickers(); - - } - - - private void set_SetOfInitialTickers() - { - - if(this.portfolioType == PortfolioType.ShortAndLong) - { - for(int i = 0;i<this.originalNumOfTickers;i++) - { - string ticker = (string)this.setOfTickers.Rows[i][0]; - DataRow newRow = this.setOfTickers.NewRow(); - newRow[0] = "-" + ticker; - this.setOfTickers.Rows.Add(newRow); - //so, if row[i][0]="TICKER" - //row[i+originalNumOfTickers][0]="-TICKER" - } - } } private void setMinAndMaxValueForGenes() { - //each genes is the index for the setOfTickers table this.minValueForGenes = 0; ! ! if(this.portfolioType == PortfolioType.OnlyLong || ! this.portfolioType == PortfolioType.OnlyShort) ! this.maxValueForGenes = this.setOfTickers.Rows.Count - 1; ! else//ShortAndLong ! this.maxValueForGenes = this.setOfTickers.Rows.Count*2 - 1; } ! ! ! protected float getCoefficient(string ticker) { ! float returnValue; ! if(ticker.StartsWith("-")) ! //if the first char is "-" ! //each element of the array of rates of return is ! //multiplied by -1 ! returnValue = -1; ! else ! returnValue = 1; ! ! return returnValue; ! } ! protected virtual double getFitnessValue_calculate() { --- 120,154 ---- this.portfolioType = portfolioType; this.setMinAndMaxValueForGenes(); } private void setMinAndMaxValueForGenes() { this.minValueForGenes = 0; ! this.maxValueForGenes = this.originalNumOfTickers - 1; ! ! if(this.portfolioType == PortfolioType.ShortAndLong) ! this.minValueForGenes = - this.originalNumOfTickers; ! //if gene g is negative, it refers to the ticker Abs(g+1) to be shorted } ! //this protected method has to be called by inherited genome ! //managers (open to close or close to close) ! //only after all initializations provided ! //by their respective constructors ! protected void retrieveData() { ! this.setOfCandidates = new CandidateProperties[setOfTickers.Rows.Count]; ! for(int i = 0; i<setOfTickers.Rows.Count; i++) ! { ! string ticker = (string)setOfTickers.Rows[i][0]; ! this.setOfCandidates[i] = new CandidateProperties(ticker, ! this.getArrayOfRatesOfReturn(ticker)); ! } } ! ! //implementation of IGenomeManager ! ! #region GetFitnessValue ! protected virtual double getFitnessValue_calculate() { *************** *** 216,224 **** } public Genome[] GetChilds(Genome parent1, Genome parent2) { return GenomeManagement.MixGenesWithoutDuplicates(parent1, parent2, ! this.originalNumOfTickers); } --- 199,209 ---- } + #endregion + public Genome[] GetChilds(Genome parent1, Genome parent2) { return GenomeManagement.MixGenesWithoutDuplicates(parent1, parent2, ! this.constToDiscoverDuplicateGenes); } *************** *** 228,237 **** // the others already stored in the given genome int returnValue = GenomeManagement.RandomGenerator.Next(genome.MinValueForGenes, ! genome.MaxValueForGenes + 1); while(genome.HasGene(returnValue) || ! genome.HasGene(returnValue + this.originalNumOfTickers) || ! genome.HasGene(returnValue - this.originalNumOfTickers) ) ! //the portfolio can't have a long position and a short position ! // for the same ticker { returnValue = GenomeManagement.RandomGenerator.Next(genome.MinValueForGenes, --- 213,221 ---- // the others already stored in the given genome int returnValue = GenomeManagement.RandomGenerator.Next(genome.MinValueForGenes, ! genome.MaxValueForGenes + 1); while(genome.HasGene(returnValue) || ! genome.HasGene(returnValue + this.constToDiscoverDuplicateGenes) || ! genome.HasGene(returnValue - this.constToDiscoverDuplicateGenes) ) ! //the portfolio can't have a long position and a short one for the same ticker { returnValue = GenomeManagement.RandomGenerator.Next(genome.MinValueForGenes, *************** *** 241,245 **** return returnValue; } - public void Mutate(Genome genome, double mutationRate) --- 225,228 ---- *************** *** 251,256 **** int genePositionToBeMutated = GenomeManagement.RandomGenerator.Next(genome.Size); while(genome.HasGene(newValueForGene) || ! genome.HasGene(newValueForGene + this.originalNumOfTickers) || ! genome.HasGene(newValueForGene - this.originalNumOfTickers) ) //the efficient portfolio, in this implementation, // can't have a long position and a short position --- 234,239 ---- int genePositionToBeMutated = GenomeManagement.RandomGenerator.Next(genome.Size); while(genome.HasGene(newValueForGene) || ! genome.HasGene(newValueForGene + this.constToDiscoverDuplicateGenes) || ! genome.HasGene(newValueForGene - this.constToDiscoverDuplicateGenes) ) //the efficient portfolio, in this implementation, // can't have a long position and a short position *************** *** 258,284 **** { newValueForGene = GenomeManagement.RandomGenerator.Next(genome.MinValueForGenes, ! genome.MaxValueForGenes +1); } GenomeManagement.MutateOneGene(genome, mutationRate, ! genePositionToBeMutated, newValueForGene); } public virtual object Decode(Genome genome) { ! string sequenceOfTickers = ""; ! object returnValue; ! foreach(int index in genome.Genes()) { ! sequenceOfTickers += (string)this.setOfTickers.Rows[index][0] + ";" ; } ! returnValue = sequenceOfTickers; ! returnValue += "(rate: " + this.RateOfReturn + " std: " + ! System.Math.Sqrt(this.Variance) + ")"; ! return returnValue; } // end of implementation of IGenomeManager #region old implementation for variance computation ! protected double getPortfolioVariance(int[] tickerIdx) { --- 241,282 ---- { newValueForGene = GenomeManagement.RandomGenerator.Next(genome.MinValueForGenes, ! genome.MaxValueForGenes + 1); } GenomeManagement.MutateOneGene(genome, mutationRate, ! genePositionToBeMutated, newValueForGene); } + #region Decode + + private string decode_getTickerCodeForLongOrShortTrade(int geneValue) + { + string initialCharForTickerCode = ""; + int position = geneValue; + if(geneValue<0) + { + position = Math.Abs(geneValue + 1); + initialCharForTickerCode = "-"; + } + return initialCharForTickerCode + this.setOfCandidates[position].Ticker; + } + public virtual object Decode(Genome genome) { ! string[] arrayOfTickers = new string[genome.Genes().Length]; ! int indexOfTicker; ! for(int index = 0; index < genome.Genes().Length; index++) { ! indexOfTicker = (int)genome.Genes().GetValue(index); ! arrayOfTickers[index] = this.decode_getTickerCodeForLongOrShortTrade(indexOfTicker); } ! return arrayOfTickers; ! } + #endregion + // end of implementation of IGenomeManager #region old implementation for variance computation ! /* protected double getPortfolioVariance(int[] tickerIdx) { *************** *** 322,346 **** return returnValue; } ! #endregion ! ! ! protected void retrieveData() ! { ! foreach(DataRow row in this.setOfTickers.Rows) ! { ! // ! float[] arrayOfRatesOfReturn = this.getArrayOfRatesOfReturn((string)row[0]); ! if(arrayOfRatesOfReturn == null) ! row["ArrayOfRatesOfReturn"] = DBNull.Value; ! else ! row["ArrayOfRatesOfReturn"] = arrayOfRatesOfReturn; ! } ! } ! //this protected method must be overriden by inherited classes //specifing the type of rates of return that have to //be analyzed - protected virtual float[] getArrayOfRatesOfReturn(string ticker) { --- 320,330 ---- return returnValue; } ! */ #endregion ! ! //this protected method must be overriden by inherited classes //specifing the type of rates of return that have to //be analyzed protected virtual float[] getArrayOfRatesOfReturn(string ticker) { *************** *** 348,378 **** return returnValue; } ! ! ! protected double[] getPortfolioRatesOfReturn(int[] tickerIdx) { double[] returnValue = new double[this.numberOfExaminedReturns]; - float[] tickerRatesOfReturn; for(int i = 0; i<returnValue.Length; i++) { ! foreach(int idx in tickerIdx) ! { ! if(this.setOfTickers.Rows[idx]["ArrayOfRatesOfReturn"] is System.DBNull) ! //the idx points to a ticker for which short returns are ! //to be examined ! tickerRatesOfReturn = ! (float[])this.setOfTickers.Rows[idx - this.originalNumOfTickers]["ArrayOfRatesOfReturn"]; ! else ! tickerRatesOfReturn = (float[])this.setOfTickers.Rows[idx]["ArrayOfRatesOfReturn"]; ! ! returnValue[i] += ! this.getCoefficient((string)this.setOfTickers.Rows[idx][0])* ! tickerRatesOfReturn[i]/this.genomeSize; ! //the investment is assumed to be equally divided for each ticker ! } } return returnValue; - } } --- 332,373 ---- return returnValue; } ! ! #region getPortfolioRatesOfReturn ! ! private int getPortfolioRatesOfReturn_getRateOfTickerToBeAddedToTheArray_getPositionInArray(int geneValueForTickerIdx) ! { ! int position = geneValueForTickerIdx; ! if(geneValueForTickerIdx<0) ! position = Math.Abs(geneValueForTickerIdx + 1); ! return position; ! } ! ! private float getPortfolioRatesOfReturn_getRateOfTickerToBeAddedToTheArray(int tickerIdx, ! int arrayElementPosition) ! { ! bool longReturns = false; ! if(tickerIdx > 0) ! //the tickerIdx points to a ticker for which long returns are to be examined ! longReturns = true; ! int position = this.getPortfolioRatesOfReturn_getRateOfTickerToBeAddedToTheArray_getPositionInArray(tickerIdx); ! this.setOfCandidates[position].LongRatesOfReturn = longReturns; ! float[] arrayOfRatesOfReturn = this.setOfCandidates[position].ArrayOfRatesOfReturn; ! return (arrayOfRatesOfReturn[arrayElementPosition]/this.GenomeSize); ! //the investment is assumed to be equally divided for each ticker ! } ! ! protected double[] getPortfolioRatesOfReturn(int[] tickersIdx) { double[] returnValue = new double[this.numberOfExaminedReturns]; for(int i = 0; i<returnValue.Length; i++) { ! foreach(int tickerIdx in tickersIdx) ! returnValue[i] += ! this.getPortfolioRatesOfReturn_getRateOfTickerToBeAddedToTheArray(tickerIdx,i); } return returnValue; } + + #endregion } |
|
From: Marco M. <mi...@us...> - 2005-07-25 22:37:05
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22458/b7_Scripts/TickerSelectionTesting Modified Files: RunEfficientCTCPortfolio.cs Log Message: Added handler for the OneHourMarketClose event Index: RunEfficientCTCPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunEfficientCTCPortfolio.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** RunEfficientCTCPortfolio.cs 24 Jun 2005 22:52:25 -0000 1.8 --- RunEfficientCTCPortfolio.cs 25 Jul 2005 22:36:56 -0000 1.9 *************** *** 106,113 **** protected override void run_addEventHandlers() { ! this.endOfDayTimer.MarketOpen += ! new MarketOpenEventHandler( ! this.endOfDayTimerHandler.MarketOpenEventHandler); ! this.endOfDayTimer.MarketClose += new MarketCloseEventHandler( --- 106,110 ---- protected override void run_addEventHandlers() { ! this.endOfDayTimer.MarketClose += new MarketCloseEventHandler( *************** *** 117,120 **** --- 114,121 ---- new MarketCloseEventHandler( this.checkDateForReport); + + this.endOfDayTimer.OneHourAfterMarketClose += + new OneHourAfterMarketCloseEventHandler( + this.endOfDayTimerHandler.OneHourAfterMarketCloseEventHandler); } |
|
From: Marco M. <mi...@us...> - 2005-07-25 22:35:51
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22203/b7_Scripts/TickerSelectionTesting Modified Files: RunTestOptimizedCTCPortfolio.cs RunTestOptimizedCTOPortfolio.cs Log Message: Minor changes Index: RunTestOptimizedCTOPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunTestOptimizedCTOPortfolio.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** RunTestOptimizedCTOPortfolio.cs 26 Jun 2005 14:53:07 -0000 1.4 --- RunTestOptimizedCTOPortfolio.cs 25 Jul 2005 22:35:43 -0000 1.5 *************** *** 57,61 **** int generationNumberForGeneticOptimizer, int populationSizeForGeneticOptimizer, string benchmark, ! DateTime startDate, DateTime endDate, double targetReturn, PortfolioType portfolioType, double maxRunningHours, int numDaysBetweenEachOptimization): --- 57,61 ---- int generationNumberForGeneticOptimizer, int populationSizeForGeneticOptimizer, string benchmark, ! DateTime endDate, double targetReturn, PortfolioType portfolioType, double maxRunningHours, int numDaysBetweenEachOptimization): *************** *** 64,68 **** generationNumberForGeneticOptimizer, populationSizeForGeneticOptimizer, benchmark, ! startDate, endDate, targetReturn, portfolioType, maxRunningHours, numDaysBetweenEachOptimization) --- 64,68 ---- generationNumberForGeneticOptimizer, populationSizeForGeneticOptimizer, benchmark, ! endDate.AddDays(-numDaysForLiquidity), endDate, targetReturn, portfolioType, maxRunningHours, numDaysBetweenEachOptimization) *************** *** 93,100 **** Report report = new Report( this.account , this.historicalQuoteProvider ); ! report.Create( "Test optimization of OpenClose efficient portfolio", 1 , new EndOfDayDateTime( this.endDateTime.DateTime , EndOfDaySpecificTime.MarketClose ) , ! "^NDX" ); report.Show(); } --- 93,100 ---- Report report = new Report( this.account , this.historicalQuoteProvider ); ! report.Create( "TestOptimizationOpenToCloseEfficientPortfolio", 1 , new EndOfDayDateTime( this.endDateTime.DateTime , EndOfDaySpecificTime.MarketClose ) , ! this.benchmark ); report.Show(); } Index: RunTestOptimizedCTCPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunTestOptimizedCTCPortfolio.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RunTestOptimizedCTCPortfolio.cs 24 Jun 2005 22:52:25 -0000 1.2 --- RunTestOptimizedCTCPortfolio.cs 25 Jul 2005 22:35:43 -0000 1.3 *************** *** 64,68 **** int generationNumberForGeneticOptimizer, int populationSizeForGeneticOptimizer, string benchmark, ! DateTime startDate, DateTime endDate, int numDaysOfPortfolioLife, int numDaysForReturnCalculation, double targetReturn, --- 64,68 ---- int generationNumberForGeneticOptimizer, int populationSizeForGeneticOptimizer, string benchmark, ! DateTime endDate, int numDaysOfPortfolioLife, int numDaysForReturnCalculation, double targetReturn, *************** *** 73,78 **** generationNumberForGeneticOptimizer, populationSizeForGeneticOptimizer, benchmark, ! startDate, endDate, ! numDaysOfPortfolioLife, numDaysForReturnCalculation, targetReturn, portfolioType, maxAcceptableCloseToCloseDrawdown, --- 73,78 ---- generationNumberForGeneticOptimizer, populationSizeForGeneticOptimizer, benchmark, ! endDate.AddDays(-numDaysForLiquidity), endDate, ! numDaysOfPortfolioLife - 1, numDaysForReturnCalculation, targetReturn, portfolioType, maxAcceptableCloseToCloseDrawdown, *************** *** 102,109 **** ((EndOfDayTimerHandlerCTCTest)this.endOfDayTimerHandler).Reset(); Report report = new Report( this.account , this.historicalQuoteProvider ); ! report.Create( "Test optimization of Close to close efficient portfolio", 1 , new EndOfDayDateTime( this.endDateTime.DateTime , EndOfDaySpecificTime.MarketClose ) , ! "^SPX" ); report.Show(); } --- 102,109 ---- ((EndOfDayTimerHandlerCTCTest)this.endOfDayTimerHandler).Reset(); Report report = new Report( this.account , this.historicalQuoteProvider ); ! report.Create( "TestOptimizationCTCPortfolio", 1 , new EndOfDayDateTime( this.endDateTime.DateTime , EndOfDaySpecificTime.MarketClose ) , ! this.benchmark ); report.Show(); } |