[Quantproject-developers] QuantProject/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases/InSampleC
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2008-08-16 19:32:22
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases/InSampleChoosers In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv28831/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases/InSampleChoosers Modified Files: FixedLengthTwoPhasesFitnessEvaluator.cs Log Message: Now the expected meaning is a TestingPositions (it was a WeightedPositions in the previous revision) Index: FixedLengthTwoPhasesFitnessEvaluator.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases/InSampleChoosers/FixedLengthTwoPhasesFitnessEvaluator.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FixedLengthTwoPhasesFitnessEvaluator.cs 10 Feb 2008 14:18:53 -0000 1.2 --- FixedLengthTwoPhasesFitnessEvaluator.cs 16 Aug 2008 19:32:17 -0000 1.3 *************** *** 26,29 **** --- 26,30 ---- using QuantProject.Business.Strategies.EquityEvaluation; using QuantProject.Business.Strategies.Optimizing.FitnessEvaluation; + using QuantProject.Business.Strategies.OutOfSample; using QuantProject.Business.Strategies.ReturnsManagement; *************** *** 35,38 **** --- 36,41 ---- public class FixedLengthTwoPhasesFitnessEvaluator : IFitnessEvaluator { + private const double fitnessForInvalidCandidate = -1000d; + private IEquityEvaluator equityEvaluator; *************** *** 51,55 **** --- 54,65 ---- this.equityEvaluator = equityEvaluator; } + #region GetFitnessValue + private void getFitnessValue_checkParameters( object meaning ) + { + if ( !( meaning is TestingPositions ) ) + throw new Exception( + "The meaning should always be a TestingPositions!" ); + } /// <summary> /// This private method is written in compact mode, in order *************** *** 90,110 **** return fitnessValue; } ! public double GetFitnessValue( object meaning , ReturnsManager returnsManager ) { double fitnessValue; ! if ( meaning is WeightedPositions ) ! { // for the current optimization's candidate, // all positions's tickers are distinct - WeightedPositions weightedPositions = - (WeightedPositions)meaning; fitnessValue = this.getFitnessValue( weightedPositions , returnsManager ); ! } ! else ! { ! // the current optimization's candidate contains ! // two genes that decode to the same tickers ! fitnessValue = -0.4; ! } return fitnessValue; } --- 100,124 ---- return fitnessValue; } ! private double getFitnessValue( TestingPositions testingPositions , ! ReturnsManager returnsManager ) { double fitnessValue; ! WeightedPositions weightedPositions = testingPositions.WeightedPositions; ! if ( weightedPositions == null ) ! // the current optimization's candidate contains ! // two genes that decode to the same tickers ! fitnessValue = fitnessForInvalidCandidate; ! else // for the current optimization's candidate, // all positions's tickers are distinct fitnessValue = this.getFitnessValue( weightedPositions , returnsManager ); ! return fitnessValue; ! } ! ! public double GetFitnessValue( object meaning , ReturnsManager returnsManager ) ! { ! this.getFitnessValue_checkParameters( meaning ); ! double fitnessValue = ! this.getFitnessValue( (TestingPositions)meaning , returnsManager ); return fitnessValue; } |