[Quantproject-developers] QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination TestDisplay
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2007-02-27 23:02:46
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv11917/b7_Scripts/WalkForwardTesting/LinearCombination Modified Files: TestDisplayer.cs StrategyType.cs LinearCombinationTest.cs Log Message: Added variations of PVO strategy for in sample testing. The form for in sample testing now supports multi genomes testing (for strategies that accept array of genomes with the same optimization dates) Index: LinearCombinationTest.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination/LinearCombinationTest.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** LinearCombinationTest.cs 17 Sep 2006 21:24:53 -0000 1.10 --- LinearCombinationTest.cs 27 Feb 2007 23:02:41 -0000 1.11 *************** *** 46,53 **** private DateTime firstDate; private DateTime lastDate; ! private GenomeRepresentation genomeRepresentation; // private bool openToCloseDaily; private StrategyType strategyType; private int numDaysForOscillatorStrategy; private IHistoricalQuoteProvider historicalQuoteProvider; --- 46,55 ---- private DateTime firstDate; private DateTime lastDate; ! private GenomeRepresentation[] genomeRepresentations; // private bool openToCloseDaily; private StrategyType strategyType; private int numDaysForOscillatorStrategy; + private double stopLoss; + private double takeProfit; private IHistoricalQuoteProvider historicalQuoteProvider; *************** *** 58,67 **** public LinearCombinationTest( DateTime firstDate , DateTime lastDate , ! GenomeRepresentation genomeRepresentation , StrategyType strategyType, PortfolioType portfolioType) { this.firstDate = firstDate; this.lastDate = lastDate; ! this.genomeRepresentation = genomeRepresentation; // this.openToCloseDaily = openToCloseDaily; this.strategyType = strategyType; --- 60,69 ---- public LinearCombinationTest( DateTime firstDate , DateTime lastDate , ! GenomeRepresentation[] genomeRepresentations , StrategyType strategyType, PortfolioType portfolioType) { this.firstDate = firstDate; this.lastDate = lastDate; ! this.genomeRepresentations = genomeRepresentations; // this.openToCloseDaily = openToCloseDaily; this.strategyType = strategyType; *************** *** 70,74 **** public LinearCombinationTest( DateTime firstDate , DateTime lastDate , ! GenomeRepresentation genomeRepresentation , StrategyType strategyType, PortfolioType portfolioType, int numDaysForOscillatorStrategy) --- 72,76 ---- public LinearCombinationTest( DateTime firstDate , DateTime lastDate , ! GenomeRepresentation[] genomeRepresentations , StrategyType strategyType, PortfolioType portfolioType, int numDaysForOscillatorStrategy) *************** *** 76,80 **** this.firstDate = firstDate; this.lastDate = lastDate; ! this.genomeRepresentation = genomeRepresentation; // this.openToCloseDaily = openToCloseDaily; this.strategyType = strategyType; --- 78,82 ---- this.firstDate = firstDate; this.lastDate = lastDate; ! this.genomeRepresentations = genomeRepresentations; // this.openToCloseDaily = openToCloseDaily; this.strategyType = strategyType; *************** *** 82,86 **** this.numDaysForOscillatorStrategy = numDaysForOscillatorStrategy; } ! private void oneHourAfterMarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) --- 84,102 ---- this.numDaysForOscillatorStrategy = numDaysForOscillatorStrategy; } ! public LinearCombinationTest( DateTime firstDate , DateTime lastDate , ! GenomeRepresentation[] genomeRepresentations , StrategyType strategyType, ! PortfolioType portfolioType, ! int numDaysForOscillatorStrategy, double stopLoss, double takeProfit) ! { ! this.firstDate = firstDate; ! this.lastDate = lastDate; ! this.genomeRepresentations = genomeRepresentations; ! // this.openToCloseDaily = openToCloseDaily; ! this.strategyType = strategyType; ! this.portfolioType = portfolioType; ! this.numDaysForOscillatorStrategy = numDaysForOscillatorStrategy; ! this.stopLoss = stopLoss; ! this.takeProfit = takeProfit; ! } private void oneHourAfterMarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) *************** *** 98,106 **** this.historicalQuoteProvider = new HistoricalAdjustedQuoteProvider(); } private void run_setStrategy() { ! string[] signedTickers = genomeRepresentation.SignedTickers.Split(";".ToCharArray()); double[] weightsForSignedTickers = ! GenomeRepresentation.GetWeightsArray(this.genomeRepresentation.WeightsForSignedTickers); switch (this.strategyType) { --- 114,201 ---- this.historicalQuoteProvider = new HistoricalAdjustedQuoteProvider(); } + + private void run_setStrategy_setBiasedOTC_PVONoThresholdsStrategy() + { + int numberOfTickersToBeChosen = + GenomeRepresentation.GetSignedTickers(this.genomeRepresentations[0].SignedTickers).Length; + string[,] signedTickers = new string[this.genomeRepresentations.Length, numberOfTickersToBeChosen]; + double[,] tickersPortfolioWeights = new double[this.genomeRepresentations.Length, numberOfTickersToBeChosen]; + for(int i = 0; i < this.genomeRepresentations.Length; i++) + { + for(int j = 0; j < numberOfTickersToBeChosen; j++) + { + signedTickers[i,j] = + GenomeRepresentation.GetSignedTickers( + this.genomeRepresentations[i].SignedTickers)[j]; + tickersPortfolioWeights[i,j] = + GenomeRepresentation.GetWeightsArray( + this.genomeRepresentations[i].WeightsForSignedTickers)[j]; + } + } + this.endOfDayStrategy = new FixedLevelOscBiasedOTC_PVONoThresholdsStrategy( + this.account , signedTickers , tickersPortfolioWeights, + this.genomeRepresentations.Length); + } + + private void run_setStrategy_setBiasedPVONoThresholdsStrategy() + { + int numberOfTickersToBeChosen = + GenomeRepresentation.GetSignedTickers(this.genomeRepresentations[0].SignedTickers).Length; + string[,] signedTickers = new string[this.genomeRepresentations.Length, numberOfTickersToBeChosen]; + double[,] tickersPortfolioWeights = new double[this.genomeRepresentations.Length, numberOfTickersToBeChosen]; + for(int i = 0; i < this.genomeRepresentations.Length; i++) + { + for(int j = 0; j < numberOfTickersToBeChosen; j++) + { + signedTickers[i,j] = + GenomeRepresentation.GetSignedTickers( + this.genomeRepresentations[i].SignedTickers)[j]; + tickersPortfolioWeights[i,j] = + GenomeRepresentation.GetWeightsArray( + this.genomeRepresentations[i].WeightsForSignedTickers)[j]; + } + } + this.endOfDayStrategy = new FixedLevelOscillatorBiasedPVONoThresholdsStrategy( + this.account , signedTickers , tickersPortfolioWeights, + this.genomeRepresentations.Length, + this.stopLoss, + this.takeProfit); + } + + private void run_setStrategy_setBiasedPVOStrategy() + { + int numberOfTickersToBeChosen = + GenomeRepresentation.GetSignedTickers(this.genomeRepresentations[0].SignedTickers).Length; + string[,] signedTickers = new string[this.genomeRepresentations.Length, numberOfTickersToBeChosen]; + double[,] tickersPortfolioWeights = new double[this.genomeRepresentations.Length, numberOfTickersToBeChosen]; + double[] oversoldThresholds = new double[this.genomeRepresentations.Length]; + double[] overboughtThresholds = new double[this.genomeRepresentations.Length]; + for(int i = 0; i < this.genomeRepresentations.Length; i++) + { + for(int j = 0; j < numberOfTickersToBeChosen; j++) + { + signedTickers[i,j] = + GenomeRepresentation.GetSignedTickers( + this.genomeRepresentations[i].SignedTickers)[j]; + tickersPortfolioWeights[i,j] = + GenomeRepresentation.GetWeightsArray( + this.genomeRepresentations[i].WeightsForSignedTickers)[j]; + } + oversoldThresholds[i] = this.genomeRepresentations[i].OversoldThreshold; + overboughtThresholds[i] = this.genomeRepresentations[i].OverboughtThreshold; + } + this.endOfDayStrategy = new FixedLevelOscillatorBiasedPVOStrategy( + this.account , signedTickers , tickersPortfolioWeights, + oversoldThresholds, overboughtThresholds, + overboughtThresholds.Length, + this.numDaysForOscillatorStrategy,this.stopLoss, + this.takeProfit); + } + private void run_setStrategy() { ! string[] signedTickers = genomeRepresentations[0].SignedTickers.Split(";".ToCharArray()); double[] weightsForSignedTickers = ! GenomeRepresentation.GetWeightsArray(this.genomeRepresentations[0].WeightsForSignedTickers); switch (this.strategyType) { *************** *** 145,151 **** this.endOfDayStrategy = new FixedLevelOscillatorPVOStrategy( this.account , signedTickers , weightsForSignedTickers, ! this.genomeRepresentation.OversoldThreshold, this.genomeRepresentation.OverboughtThreshold, this.numDaysForOscillatorStrategy ); break; } } --- 240,258 ---- this.endOfDayStrategy = new FixedLevelOscillatorPVOStrategy( this.account , signedTickers , weightsForSignedTickers, ! this.genomeRepresentations[0].OversoldThreshold, this.genomeRepresentations[0].OverboughtThreshold, this.numDaysForOscillatorStrategy ); break; + + case StrategyType.PortfolioValueOscillatorBiased: + this.run_setStrategy_setBiasedPVOStrategy(); + break; + + case StrategyType.PortfolioValueOscillatorBiasedNoThresholds: + this.run_setStrategy_setBiasedPVONoThresholdsStrategy(); + break; + + case StrategyType.OTC_PVOBiasedNoThresholds: + this.run_setStrategy_setBiasedOTC_PVONoThresholdsStrategy(); + break; } } *************** *** 158,170 **** { string returnValue = "Fitness:" + ! this.genomeRepresentation.Fitness.ToString() + " | Tickers:" + ! this.genomeRepresentation.SignedTickers + " - " + "from " + this.getDateString( this.firstDate ) + " to " + this.getDateString( this.lastDate ) + " opt. in sample from " + this.getDateString( ! this.genomeRepresentation.FirstOptimizationDate ) + " to " + this.getDateString( ! this.genomeRepresentation.LastOptimizationDate ); return returnValue; } --- 265,277 ---- { string returnValue = "Fitness:" + ! this.genomeRepresentations[0].Fitness.ToString() + " | Tickers:" + ! this.genomeRepresentations[0].SignedTickers + " - " + "from " + this.getDateString( this.firstDate ) + " to " + this.getDateString( this.lastDate ) + " opt. in sample from " + this.getDateString( ! this.genomeRepresentations[0].FirstOptimizationDate ) + " to " + this.getDateString( ! this.genomeRepresentations[0].LastOptimizationDate ); return returnValue; } *************** *** 184,190 **** { double[] normalizedWeights = ! GenomeRepresentation.GetWeightsArray(this.genomeRepresentation.WeightsForSignedTickers); string[] tickers = ! GenomeRepresentation.GetSignedTickers(this.genomeRepresentation.SignedTickers); for(int i = 0; i<tickers.Length; i++) { --- 291,297 ---- { double[] normalizedWeights = ! GenomeRepresentation.GetWeightsArray(genomeRepresentation.WeightsForSignedTickers); string[] tickers = ! GenomeRepresentation.GetSignedTickers(genomeRepresentation.SignedTickers); for(int i = 0; i<tickers.Length; i++) { *************** *** 232,236 **** "^GSPC"); WeightedPositions weightedPositions = ! this.run_getWeightedPositions(this.genomeRepresentation); this.run_addEquityLineForWeightedPositions(weightedPositions, Color.Brown, report); --- 339,343 ---- "^GSPC"); WeightedPositions weightedPositions = ! this.run_getWeightedPositions(this.genomeRepresentations[0]); this.run_addEquityLineForWeightedPositions(weightedPositions, Color.Brown, report); Index: StrategyType.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination/StrategyType.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** StrategyType.cs 17 Sep 2006 21:24:53 -0000 1.5 --- StrategyType.cs 27 Feb 2007 23:02:41 -0000 1.6 *************** *** 37,41 **** ExtremeCounterTrend, ImmediateTrendFollower, ! PortfolioValueOscillator } } --- 37,44 ---- ExtremeCounterTrend, ImmediateTrendFollower, ! PortfolioValueOscillator, ! PortfolioValueOscillatorBiased, ! PortfolioValueOscillatorBiasedNoThresholds, ! OTC_PVOBiasedNoThresholds } } Index: TestDisplayer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination/TestDisplayer.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** TestDisplayer.cs 17 Sep 2006 21:24:53 -0000 1.11 --- TestDisplayer.cs 27 Feb 2007 23:02:40 -0000 1.12 *************** *** 52,57 **** // Glauco code private ArrayList bestGenomes; ! private GenomeRepresentation lastSelectedGenomeRepresentation; private System.Windows.Forms.RadioButton radioButtonOTCCTODaily; private System.Windows.Forms.RadioButton radioButtonExtremeCounterTrend; --- 52,59 ---- // Glauco code + // Millo code: lastSelectedGenomeRepresentation has been + // changed into an array private ArrayList bestGenomes; ! private GenomeRepresentation[] lastSelectedGenomeRepresentations; private System.Windows.Forms.RadioButton radioButtonOTCCTODaily; private System.Windows.Forms.RadioButton radioButtonExtremeCounterTrend; *************** *** 60,63 **** --- 62,72 ---- private System.Windows.Forms.Label labelPortfolioType; private System.Windows.Forms.RadioButton radioButtonPVO; + private System.Windows.Forms.RadioButton radioButtonPVOBiased; + private System.Windows.Forms.Label labelStopLoss; + private System.Windows.Forms.TextBox textBoxStopLoss; + private System.Windows.Forms.Label labelTakeProfit; + private System.Windows.Forms.TextBox textBoxTakeProfit; + private System.Windows.Forms.RadioButton radioButtonPVOBiasedNoThresholds; + private System.Windows.Forms.RadioButton radioButtonOTCPVOBiasedNoThresholds; private System.Windows.Forms.ComboBox comboBoxPortfolioType; *************** *** 123,126 **** --- 132,151 ---- this.dgBestGenomes.AllowSorting = true; } + + private void testDisplayer_InitializeLastSelectedGenomeRepresentations(ArrayList bestGenomes) + { + //genomes with the same optimization's dates are grouped together + GenomeRepresentation firstGenomeRepresentation = + ((GenomeRepresentation)bestGenomes[0]); + DateTime firstDate = firstGenomeRepresentation.FirstOptimizationDate; + int counterOfGenomesWithSameOptimizationDates = 0; + foreach(Object item in bestGenomes) + if(firstDate == ((GenomeRepresentation)item).FirstOptimizationDate) + counterOfGenomesWithSameOptimizationDates++; + this.lastSelectedGenomeRepresentations = new GenomeRepresentation[counterOfGenomesWithSameOptimizationDates]; + this.lastSelectedGenomeRepresentations[0]= + ((GenomeRepresentation)bestGenomes[0]); + } + public TestDisplayer( DateTime firstDate , DateTime lastDate , ArrayList bestGenomes ) *************** *** 134,144 **** InitializeComponent(); ! // Glauco code ! this.lastSelectedGenomeRepresentation = ! ((GenomeRepresentation)bestGenomes[0]); this.dtpFirstDate.Value = ! this.lastSelectedGenomeRepresentation.FirstOptimizationDate; this.dtpLastDate.Value = ! this.lastSelectedGenomeRepresentation.LastOptimizationDate; this.bestGenomes = bestGenomes; this.comboBoxPortfolioType.Items.Add(PortfolioType.ShortAndLong); --- 159,168 ---- InitializeComponent(); ! // Glauco code + Millo code ! this.testDisplayer_InitializeLastSelectedGenomeRepresentations(bestGenomes); this.dtpFirstDate.Value = ! this.lastSelectedGenomeRepresentations[0].FirstOptimizationDate; this.dtpLastDate.Value = ! this.lastSelectedGenomeRepresentations[0].LastOptimizationDate; this.bestGenomes = bestGenomes; this.comboBoxPortfolioType.Items.Add(PortfolioType.ShortAndLong); *************** *** 189,192 **** --- 213,223 ---- this.labelPortfolioType = new System.Windows.Forms.Label(); this.radioButtonPVO = new System.Windows.Forms.RadioButton(); + this.radioButtonPVOBiased = new System.Windows.Forms.RadioButton(); + this.labelStopLoss = new System.Windows.Forms.Label(); + this.textBoxStopLoss = new System.Windows.Forms.TextBox(); + this.labelTakeProfit = new System.Windows.Forms.Label(); + this.textBoxTakeProfit = new System.Windows.Forms.TextBox(); + this.radioButtonPVOBiasedNoThresholds = new System.Windows.Forms.RadioButton(); + this.radioButtonOTCPVOBiasedNoThresholds = new System.Windows.Forms.RadioButton(); ((System.ComponentModel.ISupportInitialize)(this.dgBestGenomes)).BeginInit(); this.SuspendLayout(); *************** *** 197,203 **** this.dgBestGenomes.Dock = System.Windows.Forms.DockStyle.Bottom; this.dgBestGenomes.HeaderForeColor = System.Drawing.SystemColors.ControlText; ! 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); --- 228,234 ---- this.dgBestGenomes.Dock = System.Windows.Forms.DockStyle.Bottom; this.dgBestGenomes.HeaderForeColor = System.Drawing.SystemColors.ControlText; ! this.dgBestGenomes.Location = new System.Drawing.Point(0, 238); this.dgBestGenomes.Name = "dgBestGenomes"; ! this.dgBestGenomes.Size = new System.Drawing.Size(704, 176); this.dgBestGenomes.TabIndex = 0; this.dgBestGenomes.MouseUp += new System.Windows.Forms.MouseEventHandler(this.dgBestGenomes_MouseUp); *************** *** 205,209 **** // radioButtonCloseToOpenDaily // ! this.radioButtonCloseToOpenDaily.Location = new System.Drawing.Point(64, 120); this.radioButtonCloseToOpenDaily.Name = "radioButtonCloseToOpenDaily"; this.radioButtonCloseToOpenDaily.Size = new System.Drawing.Size(144, 24); --- 236,240 ---- // radioButtonCloseToOpenDaily // ! this.radioButtonCloseToOpenDaily.Location = new System.Drawing.Point(64, 104); this.radioButtonCloseToOpenDaily.Name = "radioButtonCloseToOpenDaily"; this.radioButtonCloseToOpenDaily.Size = new System.Drawing.Size(144, 24); *************** *** 214,218 **** // radioButtonOpenToCloseWeekly // ! this.radioButtonOpenToCloseWeekly.Location = new System.Drawing.Point(64, 144); this.radioButtonOpenToCloseWeekly.Name = "radioButtonOpenToCloseWeekly"; this.radioButtonOpenToCloseWeekly.Size = new System.Drawing.Size(144, 24); --- 245,249 ---- // radioButtonOpenToCloseWeekly // ! this.radioButtonOpenToCloseWeekly.Location = new System.Drawing.Point(64, 128); this.radioButtonOpenToCloseWeekly.Name = "radioButtonOpenToCloseWeekly"; this.radioButtonOpenToCloseWeekly.Size = new System.Drawing.Size(144, 24); *************** *** 223,227 **** // textBoxDaysFPOscillatorAndRevOneRank // ! this.textBoxDaysFPOscillatorAndRevOneRank.Location = new System.Drawing.Point(472, 128); this.textBoxDaysFPOscillatorAndRevOneRank.Name = "textBoxDaysFPOscillatorAndRevOneRank"; this.textBoxDaysFPOscillatorAndRevOneRank.Size = new System.Drawing.Size(56, 20); --- 254,258 ---- // textBoxDaysFPOscillatorAndRevOneRank // ! this.textBoxDaysFPOscillatorAndRevOneRank.Location = new System.Drawing.Point(480, 120); this.textBoxDaysFPOscillatorAndRevOneRank.Name = "textBoxDaysFPOscillatorAndRevOneRank"; this.textBoxDaysFPOscillatorAndRevOneRank.Size = new System.Drawing.Size(56, 20); *************** *** 231,235 **** // dtpFirstDate // ! this.dtpFirstDate.Location = new System.Drawing.Point(16, 24); this.dtpFirstDate.Name = "dtpFirstDate"; this.dtpFirstDate.TabIndex = 1; --- 262,266 ---- // dtpFirstDate // ! this.dtpFirstDate.Location = new System.Drawing.Point(48, 8); this.dtpFirstDate.Name = "dtpFirstDate"; this.dtpFirstDate.TabIndex = 1; *************** *** 237,241 **** // label1 // ! this.label1.Location = new System.Drawing.Point(32, 64); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(400, 40); --- 268,272 ---- // label1 // ! this.label1.Location = new System.Drawing.Point(32, 48); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(400, 40); *************** *** 246,250 **** // dtpLastDate // ! this.dtpLastDate.Location = new System.Drawing.Point(264, 24); this.dtpLastDate.Name = "dtpLastDate"; this.dtpLastDate.Size = new System.Drawing.Size(208, 20); --- 277,281 ---- // dtpLastDate // ! this.dtpLastDate.Location = new System.Drawing.Point(264, 8); this.dtpLastDate.Name = "dtpLastDate"; this.dtpLastDate.Size = new System.Drawing.Size(208, 20); *************** *** 253,259 **** // radioButtonExtremeCounterTrend // ! this.radioButtonExtremeCounterTrend.Location = new System.Drawing.Point(232, 120); this.radioButtonExtremeCounterTrend.Name = "radioButtonExtremeCounterTrend"; ! this.radioButtonExtremeCounterTrend.Size = new System.Drawing.Size(192, 24); this.radioButtonExtremeCounterTrend.TabIndex = 10; this.radioButtonExtremeCounterTrend.Text = "Extreme counter trend"; --- 284,290 ---- // radioButtonExtremeCounterTrend // ! this.radioButtonExtremeCounterTrend.Location = new System.Drawing.Point(64, 176); this.radioButtonExtremeCounterTrend.Name = "radioButtonExtremeCounterTrend"; ! this.radioButtonExtremeCounterTrend.Size = new System.Drawing.Size(144, 24); this.radioButtonExtremeCounterTrend.TabIndex = 10; this.radioButtonExtremeCounterTrend.Text = "Extreme counter trend"; *************** *** 262,266 **** // radioButtonOpenToCloseDaily // ! this.radioButtonOpenToCloseDaily.Location = new System.Drawing.Point(64, 96); this.radioButtonOpenToCloseDaily.Name = "radioButtonOpenToCloseDaily"; this.radioButtonOpenToCloseDaily.Size = new System.Drawing.Size(144, 24); --- 293,297 ---- // radioButtonOpenToCloseDaily // ! this.radioButtonOpenToCloseDaily.Location = new System.Drawing.Point(64, 80); this.radioButtonOpenToCloseDaily.Name = "radioButtonOpenToCloseDaily"; this.radioButtonOpenToCloseDaily.Size = new System.Drawing.Size(144, 24); *************** *** 271,277 **** // radioButtonFixedPeriodOscillator // ! this.radioButtonFixedPeriodOscillator.Location = new System.Drawing.Point(232, 96); this.radioButtonFixedPeriodOscillator.Name = "radioButtonFixedPeriodOscillator"; ! this.radioButtonFixedPeriodOscillator.Size = new System.Drawing.Size(192, 24); this.radioButtonFixedPeriodOscillator.TabIndex = 7; this.radioButtonFixedPeriodOscillator.Text = "Fixed Period n-days oscillator"; --- 302,308 ---- // radioButtonFixedPeriodOscillator // ! this.radioButtonFixedPeriodOscillator.Location = new System.Drawing.Point(232, 80); this.radioButtonFixedPeriodOscillator.Name = "radioButtonFixedPeriodOscillator"; ! this.radioButtonFixedPeriodOscillator.Size = new System.Drawing.Size(184, 24); this.radioButtonFixedPeriodOscillator.TabIndex = 7; this.radioButtonFixedPeriodOscillator.Text = "Fixed Period n-days oscillator"; *************** *** 280,284 **** // labelDays // ! this.labelDays.Location = new System.Drawing.Point(432, 136); this.labelDays.Name = "labelDays"; this.labelDays.Size = new System.Drawing.Size(32, 16); --- 311,315 ---- // labelDays // ! this.labelDays.Location = new System.Drawing.Point(424, 120); this.labelDays.Name = "labelDays"; this.labelDays.Size = new System.Drawing.Size(32, 16); *************** *** 288,292 **** // radioButtonOTCCTODaily // ! this.radioButtonOTCCTODaily.Location = new System.Drawing.Point(64, 168); this.radioButtonOTCCTODaily.Name = "radioButtonOTCCTODaily"; this.radioButtonOTCCTODaily.Size = new System.Drawing.Size(144, 24); --- 319,323 ---- // radioButtonOTCCTODaily // ! this.radioButtonOTCCTODaily.Location = new System.Drawing.Point(64, 152); this.radioButtonOTCCTODaily.Name = "radioButtonOTCCTODaily"; this.radioButtonOTCCTODaily.Size = new System.Drawing.Size(144, 24); *************** *** 296,300 **** // radioButtonImmediateTrendFollower // ! this.radioButtonImmediateTrendFollower.Location = new System.Drawing.Point(232, 144); this.radioButtonImmediateTrendFollower.Name = "radioButtonImmediateTrendFollower"; this.radioButtonImmediateTrendFollower.Size = new System.Drawing.Size(192, 24); --- 327,331 ---- // radioButtonImmediateTrendFollower // ! this.radioButtonImmediateTrendFollower.Location = new System.Drawing.Point(232, 104); this.radioButtonImmediateTrendFollower.Name = "radioButtonImmediateTrendFollower"; this.radioButtonImmediateTrendFollower.Size = new System.Drawing.Size(192, 24); *************** *** 305,309 **** // comboBoxPortfolioType // ! this.comboBoxPortfolioType.Location = new System.Drawing.Point(472, 80); this.comboBoxPortfolioType.Name = "comboBoxPortfolioType"; this.comboBoxPortfolioType.Size = new System.Drawing.Size(184, 21); --- 336,340 ---- // comboBoxPortfolioType // ! this.comboBoxPortfolioType.Location = new System.Drawing.Point(472, 64); this.comboBoxPortfolioType.Name = "comboBoxPortfolioType"; this.comboBoxPortfolioType.Size = new System.Drawing.Size(184, 21); *************** *** 313,317 **** // labelPortfolioType // ! this.labelPortfolioType.Location = new System.Drawing.Point(472, 64); this.labelPortfolioType.Name = "labelPortfolioType"; this.labelPortfolioType.Size = new System.Drawing.Size(100, 16); --- 344,348 ---- // labelPortfolioType // ! this.labelPortfolioType.Location = new System.Drawing.Point(472, 48); this.labelPortfolioType.Name = "labelPortfolioType"; this.labelPortfolioType.Size = new System.Drawing.Size(100, 16); *************** *** 321,325 **** // radioButtonPVO // ! this.radioButtonPVO.Location = new System.Drawing.Point(232, 168); this.radioButtonPVO.Name = "radioButtonPVO"; this.radioButtonPVO.Size = new System.Drawing.Size(192, 24); --- 352,356 ---- // radioButtonPVO // ! this.radioButtonPVO.Location = new System.Drawing.Point(232, 128); this.radioButtonPVO.Name = "radioButtonPVO"; this.radioButtonPVO.Size = new System.Drawing.Size(192, 24); *************** *** 328,336 **** this.radioButtonPVO.CheckedChanged += new System.EventHandler(this.radioButtonPVO_CheckedChanged); // // 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.radioButtonPVO, this.labelPortfolioType, --- 359,433 ---- this.radioButtonPVO.CheckedChanged += new System.EventHandler(this.radioButtonPVO_CheckedChanged); // + // radioButtonPVOBiased + // + this.radioButtonPVOBiased.Location = new System.Drawing.Point(232, 152); + this.radioButtonPVOBiased.Name = "radioButtonPVOBiased"; + this.radioButtonPVOBiased.Size = new System.Drawing.Size(88, 24); + this.radioButtonPVOBiased.TabIndex = 16; + this.radioButtonPVOBiased.Text = "PVO Biased"; + this.radioButtonPVOBiased.CheckedChanged += new System.EventHandler(this.radioButtonPVOBiased_CheckedChanged); + // + // labelStopLoss + // + this.labelStopLoss.Location = new System.Drawing.Point(424, 160); + this.labelStopLoss.Name = "labelStopLoss"; + this.labelStopLoss.Size = new System.Drawing.Size(56, 16); + this.labelStopLoss.TabIndex = 18; + this.labelStopLoss.Text = "stop loss"; + // + // textBoxStopLoss + // + this.textBoxStopLoss.Location = new System.Drawing.Point(480, 160); + this.textBoxStopLoss.Name = "textBoxStopLoss"; + this.textBoxStopLoss.Size = new System.Drawing.Size(56, 20); + this.textBoxStopLoss.TabIndex = 17; + this.textBoxStopLoss.Text = "0.02"; + // + // labelTakeProfit + // + this.labelTakeProfit.Location = new System.Drawing.Point(544, 160); + this.labelTakeProfit.Name = "labelTakeProfit"; + this.labelTakeProfit.Size = new System.Drawing.Size(56, 16); + this.labelTakeProfit.TabIndex = 20; + this.labelTakeProfit.Text = "take profit"; + // + // textBoxTakeProfit + // + this.textBoxTakeProfit.Location = new System.Drawing.Point(608, 160); + this.textBoxTakeProfit.Name = "textBoxTakeProfit"; + this.textBoxTakeProfit.Size = new System.Drawing.Size(56, 20); + this.textBoxTakeProfit.TabIndex = 19; + this.textBoxTakeProfit.Text = "0.005"; + // + // radioButtonPVOBiasedNoThresholds + // + this.radioButtonPVOBiasedNoThresholds.Location = new System.Drawing.Point(232, 176); + this.radioButtonPVOBiasedNoThresholds.Name = "radioButtonPVOBiasedNoThresholds"; + this.radioButtonPVOBiasedNoThresholds.Size = new System.Drawing.Size(192, 24); + this.radioButtonPVOBiasedNoThresholds.TabIndex = 21; + this.radioButtonPVOBiasedNoThresholds.Text = "PVO Biased No Thresholds"; + this.radioButtonPVOBiasedNoThresholds.CheckedChanged += new System.EventHandler(this.radioButtonPVOBiasedNoThresholds_CheckedChanged); + // + // radioButtonOTCPVOBiasedNoThresholds + // + this.radioButtonOTCPVOBiasedNoThresholds.Location = new System.Drawing.Point(232, 200); + this.radioButtonOTCPVOBiasedNoThresholds.Name = "radioButtonOTCPVOBiasedNoThresholds"; + this.radioButtonOTCPVOBiasedNoThresholds.Size = new System.Drawing.Size(192, 24); + this.radioButtonOTCPVOBiasedNoThresholds.TabIndex = 22; + this.radioButtonOTCPVOBiasedNoThresholds.Text = "OTC_PVO Biased No Thresholds"; + this.radioButtonOTCPVOBiasedNoThresholds.CheckedChanged += new System.EventHandler(this.radioButtonOTCPVOBiasedNoThresholds_CheckedChanged); + // // TestDisplayer // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); ! this.ClientSize = new System.Drawing.Size(704, 414); this.Controls.AddRange(new System.Windows.Forms.Control[] { + this.radioButtonOTCPVOBiasedNoThresholds, + this.radioButtonPVOBiasedNoThresholds, + this.labelTakeProfit, + this.textBoxTakeProfit, + this.labelStopLoss, + this.textBoxStopLoss, + this.radioButtonPVOBiased, this.radioButtonPVO, this.labelPortfolioType, *************** *** 365,372 **** 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 ); --- 462,470 ---- return hitTestInfo.Row>=0; } ! private GenomeRepresentation[] dgBestGenomes_MouseUp_getClickedGenomeRepresentation( object sender, System.Windows.Forms.MouseEventArgs e ) { ! GenomeRepresentation[] genomeRepresentations = ! new GenomeRepresentation[this.lastSelectedGenomeRepresentations.Length]; DataGrid dataGrid = (DataGrid)sender; Point point = new Point( e.X , e.Y ); *************** *** 376,382 **** 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( --- 474,491 ---- if ( hitTestInfo.Row >= 0 ) // a grid row has been clicked, not the header ! // all best genomes with the same optimization's dates ! // are saved in an array ! { ! genomeRepresentations[0] = ! (GenomeRepresentation)bestGenomes[ hitTestInfo.Row ]; ! for(int i = 1; i < bestGenomes.Count - hitTestInfo.Row; i++) ! if( genomeRepresentations[0].FirstOptimizationDate == ! ((GenomeRepresentation)bestGenomes[hitTestInfo.Row+i]).FirstOptimizationDate ) ! // the next row has the same optimization's date of the ! // original selected best genome by the user ! genomeRepresentations[i] = ! (GenomeRepresentation)bestGenomes[ hitTestInfo.Row + i]; ! } ! return genomeRepresentations; } private void dgBestGenomes_MouseUp_rightButton_updateDates( *************** *** 385,392 **** TimeSpan currentFirstDateDisplacement = ( this.dtpFirstDate.Value - ! this.lastSelectedGenomeRepresentation.FirstOptimizationDate ); TimeSpan currentLastDateDisplacement = ( this.dtpLastDate.Value - ! this.lastSelectedGenomeRepresentation.LastOptimizationDate ); this.dtpFirstDate.Value = newSelectedGenomeRepresentation.FirstOptimizationDate + currentFirstDateDisplacement; --- 494,501 ---- TimeSpan currentFirstDateDisplacement = ( this.dtpFirstDate.Value - ! this.lastSelectedGenomeRepresentations[0].FirstOptimizationDate ); TimeSpan currentLastDateDisplacement = ( this.dtpLastDate.Value - ! this.lastSelectedGenomeRepresentations[0].LastOptimizationDate ); this.dtpFirstDate.Value = newSelectedGenomeRepresentation.FirstOptimizationDate + currentFirstDateDisplacement; *************** *** 396,410 **** 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.SignedTickers.Split(";".ToCharArray()); LinearCombinationTest linearCombinationTest = 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; } --- 505,520 ---- private void dgBestGenomes_MouseUp_rightButton(object sender, System.Windows.Forms.MouseEventArgs e) { ! GenomeRepresentation[] genomeRepresentations = this.dgBestGenomes_MouseUp_getClickedGenomeRepresentation( sender , e ); ! dgBestGenomes_MouseUp_rightButton_updateDates( genomeRepresentations[0] ); ! //string[] signedTickers = genomeRepresentation.SignedTickers.Split(";".ToCharArray()); LinearCombinationTest linearCombinationTest = new LinearCombinationTest( this.dtpFirstDate.Value , ! this.dtpLastDate.Value , genomeRepresentations , this.selectedStrategyType, ! (PortfolioType)this.comboBoxPortfolioType.SelectedItem, Convert.ToInt32(this.textBoxDaysFPOscillatorAndRevOneRank.Text), ! Convert.ToDouble(this.textBoxStopLoss.Text),Convert.ToDouble(this.textBoxTakeProfit.Text) ); linearCombinationTest.Run(); ! this.lastSelectedGenomeRepresentations = genomeRepresentations; } *************** *** 433,440 **** // a grid row has been clicked, not the header { ! GenomeRepresentation newSelectedGenomeRepresentation = this.dgBestGenomes_MouseUp_getClickedGenomeRepresentation( sender , e ); ! this.lastSelectedGenomeRepresentation = newSelectedGenomeRepresentation; ! dgBestGenomes_MouseUp_leftButton_updateForm( newSelectedGenomeRepresentation ); } } --- 543,550 ---- // a grid row has been clicked, not the header { ! GenomeRepresentation[] newSelectedGenomeRepresentations = this.dgBestGenomes_MouseUp_getClickedGenomeRepresentation( sender , e ); ! this.lastSelectedGenomeRepresentations = newSelectedGenomeRepresentations; ! dgBestGenomes_MouseUp_leftButton_updateForm( newSelectedGenomeRepresentations[0] ); } } *************** *** 465,468 **** --- 575,584 ---- else if(this.radioButtonPVO.Checked) this.selectedStrategyType = StrategyType.PortfolioValueOscillator; + else if(this.radioButtonPVOBiased.Checked) + this.selectedStrategyType = StrategyType.PortfolioValueOscillatorBiased; + else if(this.radioButtonPVOBiasedNoThresholds.Checked) + this.selectedStrategyType = StrategyType.PortfolioValueOscillatorBiasedNoThresholds; + else if(this.radioButtonOTCPVOBiasedNoThresholds.Checked) + this.selectedStrategyType = StrategyType.OTC_PVOBiasedNoThresholds; } *************** *** 503,506 **** --- 619,645 ---- this.update_selectedStrategyType(); } + + private void radioButtonPVOBiased_CheckedChanged(object sender, System.EventArgs e) + { + this.update_selectedStrategyType(); + this.labelStopLoss.Visible = this.radioButtonPVOBiased.Checked; + this.textBoxStopLoss.Visible = this.radioButtonPVOBiased.Checked; + this.labelTakeProfit.Visible = this.radioButtonPVOBiased.Checked; + this.textBoxTakeProfit.Visible = this.radioButtonPVOBiased.Checked; + } + + private void radioButtonPVOBiasedNoThresholds_CheckedChanged(object sender, System.EventArgs e) + { + this.update_selectedStrategyType(); + this.labelStopLoss.Visible = this.radioButtonPVOBiasedNoThresholds.Checked; + this.textBoxStopLoss.Visible = this.radioButtonPVOBiasedNoThresholds.Checked; + this.labelTakeProfit.Visible = this.radioButtonPVOBiasedNoThresholds.Checked; + this.textBoxTakeProfit.Visible = this.radioButtonPVOBiasedNoThresholds.Checked; + } + + private void radioButtonOTCPVOBiasedNoThresholds_CheckedChanged(object sender, System.EventArgs e) + { + this.update_selectedStrategyType(); + } } |