[Quantproject-developers] QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination GenomeRepre
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2006-08-07 21:19:43
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv30161/b7_Scripts/WalkForwardTesting/LinearCombination Modified Files: GenomeRepresentation.cs LinearCombinationTest.cs TestDisplayer.cs Log Message: TestDisplayer, the form for examining genomes saved to disk, has been improved. Index: LinearCombinationTest.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination/LinearCombinationTest.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** LinearCombinationTest.cs 3 Aug 2006 21:15:57 -0000 1.8 --- LinearCombinationTest.cs 7 Aug 2006 21:19:40 -0000 1.9 *************** *** 31,34 **** --- 31,35 ---- using QuantProject.Business.Timing; using QuantProject.Presentation.Reporting.WindowsForm; + using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; *************** *** 52,58 **** private Account account; private IEndOfDayStrategy endOfDayStrategy; public LinearCombinationTest( DateTime firstDate , DateTime lastDate , ! GenomeRepresentation genomeRepresentation , StrategyType strategyType) { this.firstDate = firstDate; --- 53,61 ---- private Account account; private IEndOfDayStrategy endOfDayStrategy; + private PortfolioType portfolioType; public LinearCombinationTest( DateTime firstDate , DateTime lastDate , ! GenomeRepresentation genomeRepresentation , StrategyType strategyType, ! PortfolioType portfolioType) { this.firstDate = firstDate; *************** *** 61,68 **** // this.openToCloseDaily = openToCloseDaily; this.strategyType = strategyType; ! } public LinearCombinationTest( DateTime firstDate , DateTime lastDate , GenomeRepresentation genomeRepresentation , StrategyType strategyType, int numDaysForOscillatorStrategy) { --- 64,73 ---- // this.openToCloseDaily = openToCloseDaily; this.strategyType = strategyType; ! this.portfolioType = portfolioType; ! } public LinearCombinationTest( DateTime firstDate , DateTime lastDate , GenomeRepresentation genomeRepresentation , StrategyType strategyType, + PortfolioType portfolioType, int numDaysForOscillatorStrategy) { *************** *** 72,75 **** --- 77,81 ---- // this.openToCloseDaily = openToCloseDaily; this.strategyType = strategyType; + this.portfolioType = portfolioType; this.numDaysForOscillatorStrategy = numDaysForOscillatorStrategy; } *************** *** 125,129 **** case StrategyType.ExtremeCounterTrend: this.endOfDayStrategy = new ExtremeCounterTrendStrategy( ! this.account , signedTickers , weightsForSignedTickers, this.numDaysForOscillatorStrategy ); break; --- 131,136 ---- case StrategyType.ExtremeCounterTrend: this.endOfDayStrategy = new ExtremeCounterTrendStrategy( ! this.account , signedTickers , weightsForSignedTickers, this.numDaysForOscillatorStrategy, ! this.portfolioType); break; Index: GenomeRepresentation.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination/GenomeRepresentation.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** GenomeRepresentation.cs 3 Aug 2006 21:26:10 -0000 1.6 --- GenomeRepresentation.cs 7 Aug 2006 21:19:40 -0000 1.7 *************** *** 45,48 **** --- 45,50 ---- private DateTime lastOptimizationDate; private int eligibleTickers = -1; + private int halfPeriodDays = -1; + private PortfolioType portfolioType = PortfolioType.ShortAndLong; public string SignedTickers *************** *** 89,92 **** --- 91,109 ---- } + public int HalfPeriodDays + { + get + { + return this.halfPeriodDays; + } + } + + public PortfolioType PortfolioType + { + get + { + return this.portfolioType; + } + } // public static string[] GetSignedTickers( string signedTickers ) // { *************** *** 215,219 **** this.signedTickers = newRepresentationForSignedTickers.Substring(0, newRepresentationForSignedTickers.Length -1); } - } --- 232,235 ---- *************** *** 244,255 **** {ex = ex;} } - this.genomeRepresentation_synchronizeOldWithNew(); - } private void genomeRepresentation( Genome genome , DateTime firstOptimizationDate , DateTime lastOptimizationDate , ! int generationCounter, int eligibleTickers ) { this.fitness = genome.Fitness; --- 260,269 ---- {ex = ex;} } this.genomeRepresentation_synchronizeOldWithNew(); } private void genomeRepresentation( Genome genome , DateTime firstOptimizationDate , DateTime lastOptimizationDate , ! int generationCounter, int eligibleTickers, int halfPeriodDays, PortfolioType portfolioType ) { this.fitness = genome.Fitness; *************** *** 261,277 **** this.generationCounter = generationCounter; this.eligibleTickers = eligibleTickers; } ! public GenomeRepresentation( Genome genome , DateTime firstOptimizationDate , DateTime lastOptimizationDate ) { this.genomeRepresentation( genome , ! firstOptimizationDate , lastOptimizationDate , -1, -1 ); } ! public GenomeRepresentation( Genome genome , DateTime firstOptimizationDate , DateTime lastOptimizationDate , int generationCounter ) { this.genomeRepresentation( genome , firstOptimizationDate , ! lastOptimizationDate , generationCounter, -1 ); } --- 275,295 ---- this.generationCounter = generationCounter; this.eligibleTickers = eligibleTickers; + this.halfPeriodDays = halfPeriodDays; + this.portfolioType = portfolioType; } ! ! public GenomeRepresentation( Genome genome , DateTime firstOptimizationDate , DateTime lastOptimizationDate ) { this.genomeRepresentation( genome , ! firstOptimizationDate , lastOptimizationDate , -1, -1, -1, PortfolioType.ShortAndLong ); } ! ! public GenomeRepresentation( Genome genome , DateTime firstOptimizationDate , DateTime lastOptimizationDate , int generationCounter ) { this.genomeRepresentation( genome , firstOptimizationDate , ! lastOptimizationDate , generationCounter, -1, -1, PortfolioType.ShortAndLong); } *************** *** 281,287 **** { this.genomeRepresentation( genome , firstOptimizationDate , ! lastOptimizationDate , generationCounter, eligibleTickers ); } ! #region GetObjectData /// <summary> --- 299,322 ---- { this.genomeRepresentation( genome , firstOptimizationDate , ! lastOptimizationDate , generationCounter, eligibleTickers, -1, PortfolioType.ShortAndLong); } ! ! public GenomeRepresentation( Genome genome , ! DateTime firstOptimizationDate , DateTime lastOptimizationDate , ! int generationCounter, int eligibleTickers, int halfPeriodDays ) ! { ! this.genomeRepresentation( genome , firstOptimizationDate , ! lastOptimizationDate , generationCounter, eligibleTickers, halfPeriodDays, ! PortfolioType.ShortAndLong); ! } ! ! public GenomeRepresentation( Genome genome , ! DateTime firstOptimizationDate , DateTime lastOptimizationDate , ! int generationCounter, int eligibleTickers, int halfPeriodDays, PortfolioType portfolioType ) ! { ! this.genomeRepresentation( genome , firstOptimizationDate , ! lastOptimizationDate , generationCounter, eligibleTickers, halfPeriodDays, portfolioType); ! } ! #region GetObjectData /// <summary> Index: TestDisplayer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination/TestDisplayer.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** TestDisplayer.cs 3 Aug 2006 21:15:57 -0000 1.9 --- TestDisplayer.cs 7 Aug 2006 21:19:40 -0000 1.10 *************** *** 27,30 **** --- 27,31 ---- using System.ComponentModel; using System.Windows.Forms; + using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; namespace QuantProject.Scripts.WalkForwardTesting.LinearCombination *************** *** 57,62 **** private System.Windows.Forms.RadioButton radioButtonImmediateTrendFollower; private StrategyType selectedStrategyType = StrategyType.OpenToCloseDaily; ! ! private void testdisplayer() { this.dgBestGenomes.DataSource = this.bestGenomes; --- 58,65 ---- private System.Windows.Forms.RadioButton radioButtonImmediateTrendFollower; private StrategyType selectedStrategyType = StrategyType.OpenToCloseDaily; ! private System.Windows.Forms.Label labelPortfolioType; ! private System.Windows.Forms.ComboBox comboBoxPortfolioType; ! ! private void testDisplayer() { this.dgBestGenomes.DataSource = this.bestGenomes; *************** *** 123,127 **** this.lastSelectedGenomeRepresentation.LastOptimizationDate; this.bestGenomes = bestGenomes; ! this.testdisplayer(); } --- 126,137 ---- this.lastSelectedGenomeRepresentation.LastOptimizationDate; this.bestGenomes = bestGenomes; ! this.comboBoxPortfolioType.Items.Add(PortfolioType.ShortAndLong); ! this.comboBoxPortfolioType.Items.Add(PortfolioType.OnlyLong); ! this.comboBoxPortfolioType.Items.Add(PortfolioType.OnlyShort); ! this.comboBoxPortfolioType.SelectedItem = PortfolioType.ShortAndLong; ! this.comboBoxPortfolioType.Text = this.comboBoxPortfolioType.SelectedItem.ToString(); ! this.comboBoxPortfolioType.Visible = false; ! this.labelPortfolioType.Visible = false; ! this.testDisplayer(); } *************** *** 160,163 **** --- 170,175 ---- this.radioButtonOTCCTODaily = new System.Windows.Forms.RadioButton(); this.radioButtonImmediateTrendFollower = new System.Windows.Forms.RadioButton(); + this.comboBoxPortfolioType = new System.Windows.Forms.ComboBox(); + this.labelPortfolioType = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.dgBestGenomes)).BeginInit(); this.SuspendLayout(); *************** *** 170,174 **** this.dgBestGenomes.Location = new System.Drawing.Point(0, 205); this.dgBestGenomes.Name = "dgBestGenomes"; ! this.dgBestGenomes.Size = new System.Drawing.Size(584, 168); this.dgBestGenomes.TabIndex = 0; this.dgBestGenomes.MouseUp += new System.Windows.Forms.MouseEventHandler(this.dgBestGenomes_MouseUp); --- 182,186 ---- this.dgBestGenomes.Location = new System.Drawing.Point(0, 205); this.dgBestGenomes.Name = "dgBestGenomes"; ! this.dgBestGenomes.Size = new System.Drawing.Size(704, 168); this.dgBestGenomes.TabIndex = 0; this.dgBestGenomes.MouseUp += new System.Windows.Forms.MouseEventHandler(this.dgBestGenomes_MouseUp); *************** *** 274,282 **** this.radioButtonImmediateTrendFollower.CheckedChanged += new System.EventHandler(this.radioButtonImmediateTrendFollower_CheckedChanged); // // TestDisplayer // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); ! this.ClientSize = new System.Drawing.Size(584, 373); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.radioButtonImmediateTrendFollower, this.radioButtonOTCCTODaily, --- 286,312 ---- this.radioButtonImmediateTrendFollower.CheckedChanged += new System.EventHandler(this.radioButtonImmediateTrendFollower_CheckedChanged); // + // comboBoxPortfolioType + // + this.comboBoxPortfolioType.Location = new System.Drawing.Point(480, 104); + this.comboBoxPortfolioType.Name = "comboBoxPortfolioType"; + this.comboBoxPortfolioType.Size = new System.Drawing.Size(184, 21); + this.comboBoxPortfolioType.TabIndex = 13; + this.comboBoxPortfolioType.Text = "comboBoxPortfolioType"; + // + // labelPortfolioType + // + this.labelPortfolioType.Location = new System.Drawing.Point(480, 88); + this.labelPortfolioType.Name = "labelPortfolioType"; + this.labelPortfolioType.Size = new System.Drawing.Size(100, 16); + this.labelPortfolioType.TabIndex = 14; + this.labelPortfolioType.Text = "Type of portfolio"; + // // TestDisplayer // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); ! this.ClientSize = new System.Drawing.Size(704, 373); this.Controls.AddRange(new System.Windows.Forms.Control[] { + this.labelPortfolioType, + this.comboBoxPortfolioType, this.radioButtonImmediateTrendFollower, this.radioButtonOTCCTODaily, *************** *** 346,361 **** new LinearCombinationTest( this.dtpFirstDate.Value , this.dtpLastDate.Value , genomeRepresentation , ! this.selectedStrategyType, Convert.ToInt32(this.textBoxDaysFPOscillatorAndRevOneRank.Text)); 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) { --- 376,404 ---- new LinearCombinationTest( this.dtpFirstDate.Value , this.dtpLastDate.Value , genomeRepresentation , ! this.selectedStrategyType, ! (PortfolioType)this.comboBoxPortfolioType.SelectedItem, Convert.ToInt32(this.textBoxDaysFPOscillatorAndRevOneRank.Text)); linearCombinationTest.Run(); this.lastSelectedGenomeRepresentation = genomeRepresentation; } ! ! ! private void dgBestGenomes_MouseUp_leftButton_updateForm( ! GenomeRepresentation newSelectedGenomeRepresentation ) ! { ! this.dtpFirstDate.Value = ! newSelectedGenomeRepresentation.FirstOptimizationDate; ! this.dtpLastDate.Value = ! newSelectedGenomeRepresentation.LastOptimizationDate; ! ! if(newSelectedGenomeRepresentation.HalfPeriodDays > 0) ! //genomeRepresentation derives from a strategy ! //based on HalfPeriodDays ! this.textBoxDaysFPOscillatorAndRevOneRank.Text = ! newSelectedGenomeRepresentation.HalfPeriodDays.ToString(); ! ! this.comboBoxPortfolioType.SelectedItem = ! newSelectedGenomeRepresentation.PortfolioType; ! } ! private void dgBestGenomes_MouseUp_leftButton(object sender, System.Windows.Forms.MouseEventArgs e) { *************** *** 365,370 **** GenomeRepresentation newSelectedGenomeRepresentation = this.dgBestGenomes_MouseUp_getClickedGenomeRepresentation( sender , e ); ! dgBestGenomes_MouseUp_leftButton_updateDates( newSelectedGenomeRepresentation ); ! this.lastSelectedGenomeRepresentation = newSelectedGenomeRepresentation; } } --- 408,413 ---- GenomeRepresentation newSelectedGenomeRepresentation = this.dgBestGenomes_MouseUp_getClickedGenomeRepresentation( sender , e ); ! this.lastSelectedGenomeRepresentation = newSelectedGenomeRepresentation; ! dgBestGenomes_MouseUp_leftButton_updateForm( newSelectedGenomeRepresentation ); } } *************** *** 418,421 **** --- 461,466 ---- { this.update_selectedStrategyType(); + this.comboBoxPortfolioType.Visible = this.radioButtonExtremeCounterTrend.Checked; + this.labelPortfolioType.Visible = this.radioButtonExtremeCounterTrend.Checked;; } |