quantproject-developers Mailing List for QuantProject (Page 69)
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...> - 2007-08-29 10:34:25
|
Update of /cvsroot/quantproject/QuantProject/b91_QuantProject In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv8646/b91_QuantProject Modified Files: b91_QuantProject.csproj Log Message: Automatic changes by VS net Index: b91_QuantProject.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b91_QuantProject/b91_QuantProject.csproj,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** b91_QuantProject.csproj 13 Jul 2007 10:03:23 -0000 1.11 --- b91_QuantProject.csproj 29 Aug 2007 10:34:15 -0000 1.12 *************** *** 2,6 **** <CSHARP ProjectType = "Local" ! ProductVersion = "7.0.9466" SchemaVersion = "1.0" ProjectGuid = "{75FE4A9C-867E-48FE-8B49-964B318B4583}" --- 2,6 ---- <CSHARP ProjectType = "Local" ! ProductVersion = "7.0.9955" SchemaVersion = "1.0" ProjectGuid = "{75FE4A9C-867E-48FE-8B49-964B318B4583}" |
|
From: Marco M. <mi...@us...> - 2007-08-29 10:33:03
|
Update of /cvsroot/quantproject/QuantProject/b3_Data In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv7154/b3_Data Modified Files: b3_Data.csproj Log Message: Automatic changes by VS net Index: b3_Data.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/b3_Data.csproj,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** b3_Data.csproj 27 Aug 2007 22:21:27 -0000 1.50 --- b3_Data.csproj 29 Aug 2007 10:32:54 -0000 1.51 *************** *** 2,6 **** <CSHARP ProjectType = "Local" ! ProductVersion = "7.0.9466" SchemaVersion = "1.0" ProjectGuid = "{6AC0A2C1-B926-4921-A685-F5AA80E81C94}" --- 2,6 ---- <CSHARP ProjectType = "Local" ! ProductVersion = "7.0.9955" SchemaVersion = "1.0" ProjectGuid = "{6AC0A2C1-B926-4921-A685-F5AA80E81C94}" *************** *** 144,148 **** <File RelPath = "ExtendedDataTable.cs" ! SubType = "Component" BuildAction = "Compile" /> --- 144,148 ---- <File RelPath = "ExtendedDataTable.cs" ! SubType = "Code" BuildAction = "Compile" /> |
|
From: Marco M. <mi...@us...> - 2007-08-29 10:32:15
|
Update of /cvsroot/quantproject/QuantProject/b5_Presentation In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv6441/b5_Presentation Modified Files: b5_Presentation.csproj Log Message: Automatic changes by VS net Index: b5_Presentation.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b5_Presentation/b5_Presentation.csproj,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** b5_Presentation.csproj 4 Aug 2007 19:58:11 -0000 1.38 --- b5_Presentation.csproj 29 Aug 2007 10:32:02 -0000 1.39 *************** *** 2,6 **** <CSHARP ProjectType = "Local" ! ProductVersion = "7.0.9466" SchemaVersion = "1.0" ProjectGuid = "{D3DC9EA6-3B06-4255-B19A-5FC5B66A1402}" --- 2,6 ---- <CSHARP ProjectType = "Local" ! ProductVersion = "7.0.9955" SchemaVersion = "1.0" ProjectGuid = "{D3DC9EA6-3B06-4255-B19A-5FC5B66A1402}" *************** *** 131,142 **** /> <Reference - Name = "Microsoft.Office.Core" - Guid = "{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}" - VersionMajor = "2" - VersionMinor = "3" - Lcid = "0" - WrapperTool = "primary" - /> - <Reference Name = "NPlot" AssemblyName = "NPlot" --- 131,134 ---- *************** *** 198,201 **** --- 190,198 ---- /> <File + RelPath = "Reporting\WindowsForm\Report.resx" + DependentUpon = "Report.cs" + BuildAction = "EmbeddedResource" + /> + <File RelPath = "Reporting\WindowsForm\ReportGrid.cs" SubType = "Component" |
|
From: Marco M. <mi...@us...> - 2007-08-29 10:14:54
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv25249/b7_Scripts Modified Files: b7_Scripts.csproj Log Message: Some new strategies have been added: - DoubleOverReaction WeekEndBounce; - BestAndWorstFollower; - OTC_CTOTrendFollower Index: b7_Scripts.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/b7_Scripts.csproj,v retrieving revision 1.75 retrieving revision 1.76 diff -C2 -d -r1.75 -r1.76 *** b7_Scripts.csproj 15 Aug 2007 19:23:31 -0000 1.75 --- b7_Scripts.csproj 29 Aug 2007 10:14:43 -0000 1.76 *************** *** 2,6 **** <CSHARP ProjectType = "Local" ! ProductVersion = "7.0.9466" SchemaVersion = "1.0" ProjectGuid = "{451DB77D-D4C7-44D1-8047-2920D864A4CD}" --- 2,6 ---- <CSHARP ProjectType = "Local" ! ProductVersion = "7.0.9955" SchemaVersion = "1.0" ProjectGuid = "{451DB77D-D4C7-44D1-8047-2920D864A4CD}" *************** *** 123,126 **** --- 123,146 ---- /> <File + RelPath = "ArbitrageTesting\OverReactionHypothesis\DoubleOverReaction_OTC\EndOfDayTimerHandlerDOR_OTC.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "ArbitrageTesting\OverReactionHypothesis\DoubleOverReaction_OTC\RunDOR_OTC.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "ArbitrageTesting\OverReactionHypothesis\DoubleOverReaction_WeekEndBounce\EndOfDayTimerHandlerDOR_WeekEndBounce.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "ArbitrageTesting\OverReactionHypothesis\DoubleOverReaction_WeekEndBounce\RunDOR_WeekEndBounce.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "ArbitrageTesting\OverReactionHypothesis\SimpleOHTest\EndOfDayTimerHandlerSimpleOHTest.cs" SubType = "Code" *************** *** 379,382 **** --- 399,412 ---- /> <File + RelPath = "TechnicalAnalysisTesting\TrendFollowing\BestAndWorst\EndOfDayTimerHandlerBWFollower.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "TechnicalAnalysisTesting\TrendFollowing\BestAndWorst\RunBestAndWorstFollower.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "TechnicalAnalysisTesting\TrendFollowing\ImmediateTrendFollower\EndOfDayTimerHandlerITF.cs" SubType = "Code" *************** *** 394,397 **** --- 424,437 ---- /> <File + RelPath = "TechnicalAnalysisTesting\TrendFollowing\OTC_CTOTrendFollower\EndOfDayTimerHandlerOTC_CTOTrendFollower.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "TechnicalAnalysisTesting\TrendFollowing\OTC_CTOTrendFollower\RunEfficientOTC_CTOTrendFollower.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "TickerSelectionTesting\CandidateProperties.cs" SubType = "Code" *************** *** 424,427 **** --- 464,472 ---- /> <File + RelPath = "TickerSelectionTesting\EndOfDayTimerHandlerCTO_WorstAtDay.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "TickerSelectionTesting\EndOfDayTimerHandlerLastChosenPortfolio.cs" SubType = "Code" *************** *** 434,437 **** --- 479,487 ---- /> <File + RelPath = "TickerSelectionTesting\EndOfDayTimerHandlerOTC_WorstAtNight.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "TickerSelectionTesting\EndOfDayTimerHandlerOTCCTO.cs" SubType = "Code" *************** *** 509,512 **** --- 559,567 ---- /> <File + RelPath = "TickerSelectionTesting\RunEfficientCTO_WorstAtDayPortfolio.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "TickerSelectionTesting\RunEfficientCTOPortfolio.cs" SubType = "Code" *************** *** 514,517 **** --- 569,577 ---- /> <File + RelPath = "TickerSelectionTesting\RunEfficientOTC_WorstAtNightPortfolio.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "TickerSelectionTesting\RunEfficientOTCCTOPortfolio.cs" SubType = "Code" *************** *** 714,717 **** --- 774,782 ---- /> <File + RelPath = "WalkForwardTesting\LinearCombination\TestDisplayer.resx" + DependentUpon = "TestDisplayer.cs" + BuildAction = "EmbeddedResource" + /> + <File RelPath = "WalkForwardTesting\LinearCombination\WalkForwardTest\RunWalkForwardLinearCombination.cs" SubType = "Code" |
|
From: Marco M. <mi...@us...> - 2007-08-29 10:10:37
|
Update of /cvsroot/quantproject/QuantProject/b4_Business In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv23308/b4_Business Modified Files: b4_Business.csproj Log Message: AverageNumberOfTransactionsPerDay and AccountManager have been added Index: b4_Business.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/b4_Business.csproj,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** b4_Business.csproj 15 Aug 2007 19:23:52 -0000 1.45 --- b4_Business.csproj 29 Aug 2007 10:10:30 -0000 1.46 *************** *** 2,6 **** <CSHARP ProjectType = "Local" ! ProductVersion = "7.0.9466" SchemaVersion = "1.0" ProjectGuid = "{6EE31501-376E-491B-869E-F06D5B7C9C30}" --- 2,6 ---- <CSHARP ProjectType = "Local" ! ProductVersion = "7.0.9955" SchemaVersion = "1.0" ProjectGuid = "{6EE31501-376E-491B-869E-F06D5B7C9C30}" *************** *** 363,366 **** --- 363,371 ---- /> <File + RelPath = "a1_Financial\a2_Accounting\h5_Reporting\SummaryRows\AverageNumberOfTransactionsPerDay.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "a1_Financial\a2_Accounting\h5_Reporting\SummaryRows\AverageShortTradePercentageReturn.cs" SubType = "Code" *************** *** 588,591 **** --- 593,601 ---- /> <File + RelPath = "a2_Strategies\AccountManager.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "a2_Strategies\AccountStrategy.cs" SubType = "Code" |
|
From: Marco M. <mi...@us...> - 2007-08-29 10:08:49
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv22412/b1_ADT Modified Files: ConstantsProvider.cs Log Message: Changed constant value (just to flag this file as "committed" ...) Index: ConstantsProvider.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/ConstantsProvider.cs,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** ConstantsProvider.cs 9 Apr 2007 18:16:26 -0000 1.19 --- ConstantsProvider.cs 29 Aug 2007 10:08:39 -0000 1.20 *************** *** 40,44 **** public static DateTime DefaultDateForTickersAddedToGroups = new DateTime(1980,1,1); //conventional date for new tickers added to groups ! public static double AmountOfVariableWeightToBeAssignedToTickers = 0.5; //total weight to be assigned to portfolio's tickers through genetic optimizer, //this constant is used at the moment only by GenomeManagerForWeightedEfficientPortfolio --- 40,44 ---- public static DateTime DefaultDateForTickersAddedToGroups = new DateTime(1980,1,1); //conventional date for new tickers added to groups ! public static double AmountOfVariableWeightToBeAssignedToTickers = 0.40; //total weight to be assigned to portfolio's tickers through genetic optimizer, //this constant is used at the moment only by GenomeManagerForWeightedEfficientPortfolio |
|
From: Marco M. <mi...@us...> - 2007-08-29 10:05:37
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv21099/b7_Scripts/WalkForwardTesting/LinearCombination Modified Files: TestDisplayer.cs Log Message: Fixed bug in TestDisplayer form Index: TestDisplayer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination/TestDisplayer.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** TestDisplayer.cs 27 Feb 2007 23:02:40 -0000 1.12 --- TestDisplayer.cs 29 Aug 2007 10:05:29 -0000 1.13 *************** *** 197,455 **** /// </summary> private void InitializeComponent() { ! this.dgBestGenomes = new System.Windows.Forms.DataGrid(); ! this.radioButtonCloseToOpenDaily = new System.Windows.Forms.RadioButton(); ! this.radioButtonOpenToCloseWeekly = new System.Windows.Forms.RadioButton(); ! this.textBoxDaysFPOscillatorAndRevOneRank = new System.Windows.Forms.TextBox(); ! this.dtpFirstDate = new System.Windows.Forms.DateTimePicker(); ! this.label1 = new System.Windows.Forms.Label(); ! this.dtpLastDate = new System.Windows.Forms.DateTimePicker(); ! this.radioButtonExtremeCounterTrend = new System.Windows.Forms.RadioButton(); ! this.radioButtonOpenToCloseDaily = new System.Windows.Forms.RadioButton(); ! this.radioButtonFixedPeriodOscillator = new System.Windows.Forms.RadioButton(); ! this.labelDays = new System.Windows.Forms.Label(); ! 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(); ! 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(); ! // ! // dgBestGenomes ! // ! this.dgBestGenomes.DataMember = ""; ! 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); ! // ! // radioButtonCloseToOpenDaily ! // ! this.radioButtonCloseToOpenDaily.Location = new System.Drawing.Point(64, 104); ! this.radioButtonCloseToOpenDaily.Name = "radioButtonCloseToOpenDaily"; ! this.radioButtonCloseToOpenDaily.Size = new System.Drawing.Size(144, 24); ! this.radioButtonCloseToOpenDaily.TabIndex = 6; ! this.radioButtonCloseToOpenDaily.Text = "Close To Open Daily"; ! this.radioButtonCloseToOpenDaily.CheckedChanged += new System.EventHandler(this.radioButtonCloseToOpenDaily_CheckedChanged); ! // ! // radioButtonOpenToCloseWeekly ! // ! this.radioButtonOpenToCloseWeekly.Location = new System.Drawing.Point(64, 128); ! this.radioButtonOpenToCloseWeekly.Name = "radioButtonOpenToCloseWeekly"; ! this.radioButtonOpenToCloseWeekly.Size = new System.Drawing.Size(144, 24); ! this.radioButtonOpenToCloseWeekly.TabIndex = 5; ! this.radioButtonOpenToCloseWeekly.Text = "Open To Close Weekly"; ! this.radioButtonOpenToCloseWeekly.CheckedChanged += new System.EventHandler(this.radioButtonOpenToCloseWeekly_CheckedChanged); ! // ! // textBoxDaysFPOscillatorAndRevOneRank ! // ! this.textBoxDaysFPOscillatorAndRevOneRank.Location = new System.Drawing.Point(480, 120); ! this.textBoxDaysFPOscillatorAndRevOneRank.Name = "textBoxDaysFPOscillatorAndRevOneRank"; ! this.textBoxDaysFPOscillatorAndRevOneRank.Size = new System.Drawing.Size(56, 20); ! this.textBoxDaysFPOscillatorAndRevOneRank.TabIndex = 8; ! this.textBoxDaysFPOscillatorAndRevOneRank.Text = "1"; ! // ! // dtpFirstDate ! // ! this.dtpFirstDate.Location = new System.Drawing.Point(48, 8); ! this.dtpFirstDate.Name = "dtpFirstDate"; ! this.dtpFirstDate.TabIndex = 1; ! // ! // label1 ! // ! this.label1.Location = new System.Drawing.Point(32, 48); ! 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."; ! // ! // dtpLastDate ! // ! this.dtpLastDate.Location = new System.Drawing.Point(264, 8); ! this.dtpLastDate.Name = "dtpLastDate"; ! this.dtpLastDate.Size = new System.Drawing.Size(208, 20); ! this.dtpLastDate.TabIndex = 2; ! // ! // 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"; ! this.radioButtonExtremeCounterTrend.CheckedChanged += new System.EventHandler(this.radioButtonExtremeCounterTrend_CheckedChanged); ! // ! // radioButtonOpenToCloseDaily ! // ! this.radioButtonOpenToCloseDaily.Location = new System.Drawing.Point(64, 80); ! this.radioButtonOpenToCloseDaily.Name = "radioButtonOpenToCloseDaily"; ! this.radioButtonOpenToCloseDaily.Size = new System.Drawing.Size(144, 24); ! this.radioButtonOpenToCloseDaily.TabIndex = 4; ! this.radioButtonOpenToCloseDaily.Text = "Open To Close Daily"; ! this.radioButtonOpenToCloseDaily.CheckedChanged += new System.EventHandler(this.radioButtonOpenToCloseDaily_CheckedChanged); ! // ! // 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"; ! this.radioButtonFixedPeriodOscillator.CheckedChanged += new System.EventHandler(this.radioButtonFixedPeriodOscillator_CheckedChanged); ! // ! // labelDays ! // ! this.labelDays.Location = new System.Drawing.Point(424, 120); ! this.labelDays.Name = "labelDays"; ! this.labelDays.Size = new System.Drawing.Size(32, 16); ! this.labelDays.TabIndex = 9; ! this.labelDays.Text = "days"; ! // ! // radioButtonOTCCTODaily ! // ! this.radioButtonOTCCTODaily.Location = new System.Drawing.Point(64, 152); ! this.radioButtonOTCCTODaily.Name = "radioButtonOTCCTODaily"; ! this.radioButtonOTCCTODaily.Size = new System.Drawing.Size(144, 24); ! this.radioButtonOTCCTODaily.TabIndex = 11; ! this.radioButtonOTCCTODaily.Text = "OTC - CTO Daily"; ! // ! // radioButtonImmediateTrendFollower ! // ! this.radioButtonImmediateTrendFollower.Location = new System.Drawing.Point(232, 104); ! this.radioButtonImmediateTrendFollower.Name = "radioButtonImmediateTrendFollower"; ! this.radioButtonImmediateTrendFollower.Size = new System.Drawing.Size(192, 24); ! this.radioButtonImmediateTrendFollower.TabIndex = 12; ! this.radioButtonImmediateTrendFollower.Text = "Immediate Trend Follower"; ! this.radioButtonImmediateTrendFollower.CheckedChanged += new System.EventHandler(this.radioButtonImmediateTrendFollower_CheckedChanged); ! // ! // comboBoxPortfolioType ! // ! this.comboBoxPortfolioType.Location = new System.Drawing.Point(472, 64); ! 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(472, 48); ! this.labelPortfolioType.Name = "labelPortfolioType"; ! this.labelPortfolioType.Size = new System.Drawing.Size(100, 16); ! this.labelPortfolioType.TabIndex = 14; ! this.labelPortfolioType.Text = "Type of portfolio"; ! // ! // radioButtonPVO ! // ! this.radioButtonPVO.Location = new System.Drawing.Point(232, 128); ! this.radioButtonPVO.Name = "radioButtonPVO"; ! this.radioButtonPVO.Size = new System.Drawing.Size(192, 24); ! this.radioButtonPVO.TabIndex = 15; ! this.radioButtonPVO.Text = "Portfolio Value Oscillator"; ! 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, ! this.comboBoxPortfolioType, ! this.radioButtonImmediateTrendFollower, ! this.radioButtonOTCCTODaily, ! this.radioButtonExtremeCounterTrend, ! this.labelDays, ! this.textBoxDaysFPOscillatorAndRevOneRank, ! this.radioButtonFixedPeriodOscillator, ! this.radioButtonCloseToOpenDaily, ! this.radioButtonOpenToCloseWeekly, ! this.radioButtonOpenToCloseDaily, ! this.label1, ! this.dtpLastDate, ! this.dtpFirstDate, ! this.dgBestGenomes}); ! this.Name = "TestDisplayer"; ! this.Text = "TestDisplayer"; ! ((System.ComponentModel.ISupportInitialize)(this.dgBestGenomes)).EndInit(); ! this.ResumeLayout(false); ! } #endregion --- 197,456 ---- /// </summary> private void InitializeComponent() { ! this.dgBestGenomes = new System.Windows.Forms.DataGrid(); ! this.radioButtonCloseToOpenDaily = new System.Windows.Forms.RadioButton(); ! this.radioButtonOpenToCloseWeekly = new System.Windows.Forms.RadioButton(); ! this.textBoxDaysFPOscillatorAndRevOneRank = new System.Windows.Forms.TextBox(); ! this.dtpFirstDate = new System.Windows.Forms.DateTimePicker(); ! this.label1 = new System.Windows.Forms.Label(); ! this.dtpLastDate = new System.Windows.Forms.DateTimePicker(); ! this.radioButtonExtremeCounterTrend = new System.Windows.Forms.RadioButton(); ! this.radioButtonOpenToCloseDaily = new System.Windows.Forms.RadioButton(); ! this.radioButtonFixedPeriodOscillator = new System.Windows.Forms.RadioButton(); ! this.labelDays = new System.Windows.Forms.Label(); ! 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(); ! 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(); ! // ! // dgBestGenomes ! // ! this.dgBestGenomes.DataMember = ""; ! 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); ! // ! // radioButtonCloseToOpenDaily ! // ! this.radioButtonCloseToOpenDaily.Location = new System.Drawing.Point(64, 104); ! this.radioButtonCloseToOpenDaily.Name = "radioButtonCloseToOpenDaily"; ! this.radioButtonCloseToOpenDaily.Size = new System.Drawing.Size(144, 24); ! this.radioButtonCloseToOpenDaily.TabIndex = 6; ! this.radioButtonCloseToOpenDaily.Text = "Close To Open Daily"; ! this.radioButtonCloseToOpenDaily.CheckedChanged += new System.EventHandler(this.radioButtonCloseToOpenDaily_CheckedChanged); ! // ! // radioButtonOpenToCloseWeekly ! // ! this.radioButtonOpenToCloseWeekly.Location = new System.Drawing.Point(64, 128); ! this.radioButtonOpenToCloseWeekly.Name = "radioButtonOpenToCloseWeekly"; ! this.radioButtonOpenToCloseWeekly.Size = new System.Drawing.Size(144, 24); ! this.radioButtonOpenToCloseWeekly.TabIndex = 5; ! this.radioButtonOpenToCloseWeekly.Text = "Open To Close Weekly"; ! this.radioButtonOpenToCloseWeekly.CheckedChanged += new System.EventHandler(this.radioButtonOpenToCloseWeekly_CheckedChanged); ! // ! // textBoxDaysFPOscillatorAndRevOneRank ! // ! this.textBoxDaysFPOscillatorAndRevOneRank.Location = new System.Drawing.Point(480, 120); ! this.textBoxDaysFPOscillatorAndRevOneRank.Name = "textBoxDaysFPOscillatorAndRevOneRank"; ! this.textBoxDaysFPOscillatorAndRevOneRank.Size = new System.Drawing.Size(56, 20); ! this.textBoxDaysFPOscillatorAndRevOneRank.TabIndex = 8; ! this.textBoxDaysFPOscillatorAndRevOneRank.Text = "1"; ! // ! // dtpFirstDate ! // ! this.dtpFirstDate.Location = new System.Drawing.Point(48, 8); ! this.dtpFirstDate.Name = "dtpFirstDate"; ! this.dtpFirstDate.TabIndex = 1; ! // ! // label1 ! // ! this.label1.Location = new System.Drawing.Point(32, 48); ! 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."; ! // ! // dtpLastDate ! // ! this.dtpLastDate.Location = new System.Drawing.Point(264, 8); ! this.dtpLastDate.Name = "dtpLastDate"; ! this.dtpLastDate.Size = new System.Drawing.Size(208, 20); ! this.dtpLastDate.TabIndex = 2; ! // ! // 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"; ! this.radioButtonExtremeCounterTrend.CheckedChanged += new System.EventHandler(this.radioButtonExtremeCounterTrend_CheckedChanged); ! // ! // radioButtonOpenToCloseDaily ! // ! this.radioButtonOpenToCloseDaily.Location = new System.Drawing.Point(64, 80); ! this.radioButtonOpenToCloseDaily.Name = "radioButtonOpenToCloseDaily"; ! this.radioButtonOpenToCloseDaily.Size = new System.Drawing.Size(144, 24); ! this.radioButtonOpenToCloseDaily.TabIndex = 4; ! this.radioButtonOpenToCloseDaily.Text = "Open To Close Daily"; ! this.radioButtonOpenToCloseDaily.CheckedChanged += new System.EventHandler(this.radioButtonOpenToCloseDaily_CheckedChanged); ! // ! // 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"; ! this.radioButtonFixedPeriodOscillator.CheckedChanged += new System.EventHandler(this.radioButtonFixedPeriodOscillator_CheckedChanged); ! // ! // labelDays ! // ! this.labelDays.Location = new System.Drawing.Point(424, 120); ! this.labelDays.Name = "labelDays"; ! this.labelDays.Size = new System.Drawing.Size(32, 16); ! this.labelDays.TabIndex = 9; ! this.labelDays.Text = "days"; ! // ! // radioButtonOTCCTODaily ! // ! this.radioButtonOTCCTODaily.Location = new System.Drawing.Point(64, 152); ! this.radioButtonOTCCTODaily.Name = "radioButtonOTCCTODaily"; ! this.radioButtonOTCCTODaily.Size = new System.Drawing.Size(144, 24); ! this.radioButtonOTCCTODaily.TabIndex = 11; ! this.radioButtonOTCCTODaily.Text = "OTC - CTO Daily"; ! this.radioButtonOTCCTODaily.CheckedChanged += new System.EventHandler(this.radioButtonOTCCTODaily_CheckedChanged); ! // ! // radioButtonImmediateTrendFollower ! // ! this.radioButtonImmediateTrendFollower.Location = new System.Drawing.Point(232, 104); ! this.radioButtonImmediateTrendFollower.Name = "radioButtonImmediateTrendFollower"; ! this.radioButtonImmediateTrendFollower.Size = new System.Drawing.Size(192, 24); ! this.radioButtonImmediateTrendFollower.TabIndex = 12; ! this.radioButtonImmediateTrendFollower.Text = "Immediate Trend Follower"; ! this.radioButtonImmediateTrendFollower.CheckedChanged += new System.EventHandler(this.radioButtonImmediateTrendFollower_CheckedChanged); ! // ! // comboBoxPortfolioType ! // ! this.comboBoxPortfolioType.Location = new System.Drawing.Point(472, 64); ! 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(472, 48); ! this.labelPortfolioType.Name = "labelPortfolioType"; ! this.labelPortfolioType.Size = new System.Drawing.Size(100, 16); ! this.labelPortfolioType.TabIndex = 14; ! this.labelPortfolioType.Text = "Type of portfolio"; ! // ! // radioButtonPVO ! // ! this.radioButtonPVO.Location = new System.Drawing.Point(232, 128); ! this.radioButtonPVO.Name = "radioButtonPVO"; ! this.radioButtonPVO.Size = new System.Drawing.Size(192, 24); ! this.radioButtonPVO.TabIndex = 15; ! this.radioButtonPVO.Text = "Portfolio Value Oscillator"; ! 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, ! this.comboBoxPortfolioType, ! this.radioButtonImmediateTrendFollower, ! this.radioButtonOTCCTODaily, ! this.radioButtonExtremeCounterTrend, ! this.labelDays, ! this.textBoxDaysFPOscillatorAndRevOneRank, ! this.radioButtonFixedPeriodOscillator, ! this.radioButtonCloseToOpenDaily, ! this.radioButtonOpenToCloseWeekly, ! this.radioButtonOpenToCloseDaily, ! this.label1, ! this.dtpLastDate, ! this.dtpFirstDate, ! this.dgBestGenomes}); ! this.Name = "TestDisplayer"; ! this.Text = "TestDisplayer"; ! ((System.ComponentModel.ISupportInitialize)(this.dgBestGenomes)).EndInit(); ! this.ResumeLayout(false); ! } #endregion *************** *** 642,645 **** --- 643,651 ---- this.update_selectedStrategyType(); } + + private void radioButtonOTCCTODaily_CheckedChanged(object sender, System.EventArgs e) + { + this.update_selectedStrategyType(); + } } |
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv20431/b7_Scripts/TickerSelectionTesting Modified Files: RunEfficientOTC_WorstAtNightPortfolio.cs RunEfficientOTCPortfolio.cs RunEfficientOTCPortfolioMultiday.cs RunEfficientPortfolio.cs Log Message: Minor changes Index: RunEfficientOTCPortfolioMultiday.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunEfficientOTCPortfolioMultiday.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RunEfficientOTCPortfolioMultiday.cs 21 Oct 2005 18:07:45 -0000 1.1 --- RunEfficientOTCPortfolioMultiday.cs 29 Aug 2007 10:04:28 -0000 1.2 *************** *** 71,75 **** portfolioType, maxRunningHours) { ! this.ScriptName = "MultidayOpenCloseScripts"; this.numDaysBetweenEachOptimization = numDaysPortfolioLife; } --- 71,75 ---- portfolioType, maxRunningHours) { ! this.ScriptName = "MultidayOpenCloseScripts_SharpeNoCoeff"; this.numDaysBetweenEachOptimization = numDaysPortfolioLife; } Index: RunEfficientOTC_WorstAtNightPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunEfficientOTC_WorstAtNightPortfolio.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RunEfficientOTC_WorstAtNightPortfolio.cs 30 Jun 2007 18:50:38 -0000 1.1 --- RunEfficientOTC_WorstAtNightPortfolio.cs 29 Aug 2007 10:04:26 -0000 1.2 *************** *** 69,75 **** portfolioType, maxRunningHours) { ! //this.ScriptName = "OpenCloseScriptsSharpeRatioWithCoeff"; //this.ScriptName = "OpenCloseScriptsSharpeRatio"; ! this.ScriptName = "OTC_WorstAtNight_SharpeRatioNoCoeff"; //this.ScriptName = "OpenCloseScripts"; this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; --- 69,75 ---- portfolioType, maxRunningHours) { ! this.ScriptName = "OTC_WorstAtNight_SharpeRatioWithCoeff_OnlyMutation"; //this.ScriptName = "OpenCloseScriptsSharpeRatio"; ! // this.ScriptName = "OTC_WorstAtNight_SharpeRatioNoCoeff"; //this.ScriptName = "OpenCloseScripts"; this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; Index: RunEfficientPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunEfficientPortfolio.cs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** RunEfficientPortfolio.cs 3 Aug 2006 21:19:25 -0000 1.20 --- RunEfficientPortfolio.cs 29 Aug 2007 10:04:30 -0000 1.21 *************** *** 89,96 **** //is still running, it will be stopped. ! public string[] LastOrderedTickers ! { ! get { return this.endOfDayTimerHandler.LastOrderedTickers; } ! } public PortfolioType TypeOfPortfolio { --- 89,93 ---- //is still running, it will be stopped. ! public PortfolioType TypeOfPortfolio { *************** *** 214,220 **** } ! public virtual void SaveScriptResults() { ! string fileName = "From_" + this.tickerGroupID + "_" + + this.numberOfEligibleTickers + "_OptDays" + this.numDaysForOptimizationPeriod + "_Port" + --- 211,219 ---- } ! public virtual string SaveScriptResults_CreateFileName() { ! return DateTime.Now.Hour.ToString().PadLeft(2,'0') + "_" + ! DateTime.Now.Minute.ToString().PadLeft(2,'0') + "_" + ! "From_" + this.tickerGroupID + "_" + + this.numberOfEligibleTickers + "_OptDays" + this.numDaysForOptimizationPeriod + "_Port" + *************** *** 223,226 **** --- 222,231 ---- "PopSize" + this.populationSizeForGeneticOptimizer + Convert.ToString(this.portfolioType); + } + + + public virtual void SaveScriptResults() + { + string fileName = this.SaveScriptResults_CreateFileName(); string dirNameWhereToSaveReports = System.Configuration.ConfigurationSettings.AppSettings["ReportsArchive"] + "\\" + this.ScriptName + "\\"; Index: RunEfficientOTCPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunEfficientOTCPortfolio.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RunEfficientOTCPortfolio.cs 14 May 2006 18:21:47 -0000 1.2 --- RunEfficientOTCPortfolio.cs 29 Aug 2007 10:04:27 -0000 1.3 *************** *** 53,57 **** public class RunEfficientOTCPortfolio : RunEfficientPortfolio { ! protected int numDaysBetweenEachOptimization; public RunEfficientOTCPortfolio(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, --- 53,58 ---- public class RunEfficientOTCPortfolio : RunEfficientPortfolio { ! protected int numDaysBetweenEachOptimization; ! public RunEfficientOTCPortfolio(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, *************** *** 69,77 **** { //this.ScriptName = "OpenCloseScriptsSharpeRatioWithCoeff"; //this.ScriptName = "OpenCloseScriptsSharpeRatio"; ! this.ScriptName = "OpenCloseScriptsSharpeRatioNoCoeff"; //this.ScriptName = "OpenCloseScripts"; this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; ! } --- 70,80 ---- { //this.ScriptName = "OpenCloseScriptsSharpeRatioWithCoeff"; + //this.ScriptName = "OTC_SharpeRatioWithCoeff_OnlyMutation"; //this.ScriptName = "OpenCloseScriptsSharpeRatio"; ! this.ScriptName = "OTC_SharpeRatioNoCoeff"; ! //this.ScriptName = "OTC_ExpectancyScoreNoCoeff"; //this.ScriptName = "OpenCloseScripts"; this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; ! } *************** *** 110,115 **** protected override void run_initializeHistoricalQuoteProvider() { ! //this.historicalQuoteProvider = new HistoricalRawQuoteProvider(); ! this.historicalQuoteProvider = new HistoricalAdjustedQuoteProvider(); } --- 113,118 ---- protected override void run_initializeHistoricalQuoteProvider() { ! this.historicalQuoteProvider = new HistoricalRawQuoteProvider(); ! // this.historicalQuoteProvider = new HistoricalAdjustedQuoteProvider(); } *************** *** 133,138 **** } - - //necessary far calling RunEfficientPortfolio.Run() //in classes that inherit from this class --- 136,139 ---- |
|
From: Marco M. <mi...@us...> - 2007-08-29 10:04:38
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/SimpleSelection In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv20431/b7_Scripts/TickerSelectionTesting/SimpleSelection Modified Files: BestTickersScreener.cs RunSimpleSelection.cs Log Message: Minor changes Index: RunSimpleSelection.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/SimpleSelection/RunSimpleSelection.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RunSimpleSelection.cs 21 Oct 2005 17:54:11 -0000 1.1 --- RunSimpleSelection.cs 29 Aug 2007 10:04:30 -0000 1.2 *************** *** 82,90 **** //if MaxNumberOfHoursForScript has elapsed and the script //is still running, it will be stopped. ! ! public string[] LastOrderedTickers ! { ! get { return this.endOfDayTimerHandler.LastOrderedTickers; } ! } public PortfolioType TypeOfPortfolio { --- 82,86 ---- //if MaxNumberOfHoursForScript has elapsed and the script //is still running, it will be stopped. ! public PortfolioType TypeOfPortfolio { *************** *** 147,152 **** //this.numIntervalDays = 3; } ! ! #region Run --- 143,147 ---- //this.numIntervalDays = 3; } ! #region Run Index: BestTickersScreener.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/SimpleSelection/BestTickersScreener.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** BestTickersScreener.cs 23 Oct 2005 18:11:28 -0000 1.3 --- BestTickersScreener.cs 29 Aug 2007 10:04:30 -0000 1.4 *************** *** 24,30 **** --- 24,32 ---- using System.Data; using System.Collections; + using QuantProject.ADT.Statistics; using QuantProject.Data; using QuantProject.Data.DataTables; + using QuantProject.Business.Strategies; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; *************** *** 159,173 **** /// the remaining half for long. Tickers for short trading are signed! /// </summary> ! public string[] GetBestTickers(int numberOfTickers) { ! string[] returnValue = new string[numberOfTickers]; if(this.portfolioType == PortfolioType.OnlyLong) ! this.getBestTickers_setReturnValueForOnlyLong(returnValue); else if(this.portfolioType == PortfolioType.OnlyShort) ! this.getBestTickers_setReturnValueForOnlyShort(returnValue); else if(this.portfolioType == PortfolioType.ShortAndLong) ! this.getBestTickers_setReturnValueForShortAndLong(returnValue); ! return returnValue; } --- 161,175 ---- /// the remaining half for long. Tickers for short trading are signed! /// </summary> ! public SignedTickers GetBestTickers(int numberOfTickers) { ! string[] arrayOfSignedTickers = new string[numberOfTickers]; if(this.portfolioType == PortfolioType.OnlyLong) ! this.getBestTickers_setReturnValueForOnlyLong(arrayOfSignedTickers); else if(this.portfolioType == PortfolioType.OnlyShort) ! this.getBestTickers_setReturnValueForOnlyShort(arrayOfSignedTickers); else if(this.portfolioType == PortfolioType.ShortAndLong) ! this.getBestTickers_setReturnValueForShortAndLong(arrayOfSignedTickers); ! return new SignedTickers(arrayOfSignedTickers); } |
|
From: Marco M. <mi...@us...> - 2007-08-29 10:01:49
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Statistics In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv18898/b1_ADT/Statistics Modified Files: AdvancedFunctions.cs Log Message: Added GetProbabilityOfWinning method (it is intended to be used for evaluation of a fitness function) Index: AdvancedFunctions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Statistics/AdvancedFunctions.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AdvancedFunctions.cs 14 Aug 2007 14:48:19 -0000 1.4 --- AdvancedFunctions.cs 29 Aug 2007 10:01:38 -0000 1.5 *************** *** 116,119 **** --- 116,130 ---- //negative semivariance is a special case of Lower partial moment } + + public static double GetProbabilityOfWinning( ICollection returns ) + { + double numberOfReturns = returns.Count; + double winningPeriods = 0; + foreach ( double singleReturn in returns ) + if ( singleReturn > 0 ) + winningPeriods++; + + return winningPeriods / numberOfReturns; + } public static double GetSharpeRatio( ICollection returns ) |
|
From: Marco M. <mi...@us...> - 2007-08-29 09:59:47
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv17853/b7_Scripts/TickerSelectionTesting Modified Files: PortfolioType.cs Log Message: Added new portfolio enumeration item "OnlyMixed" (for portfolios that should have both long and short position) Index: PortfolioType.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/PortfolioType.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PortfolioType.cs 7 Aug 2006 21:12:24 -0000 1.3 --- PortfolioType.cs 29 Aug 2007 09:59:41 -0000 1.4 *************** *** 34,38 **** OnlyLong, OnlyShort, ! ShortAndLong } } --- 34,39 ---- OnlyLong, OnlyShort, ! ShortAndLong, ! OnlyMixed } } |
|
From: Marco M. <mi...@us...> - 2007-08-29 09:58:07
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16992/b7_Scripts/TickerSelectionTesting Modified Files: GenomeManipulator.cs Log Message: Added WillGenomeHaveTickersOfSameSign method (the name wil be changed soon, it is not much clear) Index: GenomeManipulator.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/GenomeManipulator.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** GenomeManipulator.cs 3 Jan 2007 23:20:12 -0000 1.9 --- GenomeManipulator.cs 29 Aug 2007 09:57:53 -0000 1.10 *************** *** 290,293 **** --- 290,356 ---- return returnValue; } + // // + // /// <summary> + // /// Returns true if a given gene value, + // /// for which the meaning is a ticker code, has the same sign + // /// of all the other genes that point to tickers + // /// contained in a given genome. + // /// </summary> + // /// <param name="newGeneValuePointingToTicker">Gene's value for which sign has to be checked</param> + // /// <param name="newGeneValuePosition">Position for the new gene value inside the genome to be checked</param> + // /// <param name="positionsForTickersInsideGenomeToBeChecked">Positions for genes pointing to tickers, inside genome, to be checked</param> + // /// <param name="genomeToBeModified">The genome inside which check has to be done, before + // /// a mutation or a new gene assignment + // /// through the parameter newGeneValuePointingToTicker</param> + // public static bool WillGenomeHaveTickersOfSameSign(int newGeneValuePointingToTicker, + // int newGeneValuePosition, + // int[] positionsForTickersInsideGenomeToBeChecked, + // Genome genomeToBeModified) + // { + // bool returnValue = true; + // foreach(int position in positionsForTickersInsideGenome) + // { + // if( (position != newGeneValuePosition) && + // ( (newGeneValuePointingToTicker < 0 && genomeToBeModified.GetGeneValue(position) >= 0 ) || + // (newGeneValuePointingToTicker >= 0 && genomeToBeModified.GetGeneValue(position) < 0 ) ) ) + // // if the current position is different from the newGeneValuePosition + // // and + // // newGeneValuePointingToTicker points to a short (long) position and + // // a the gene in the current position points to a long (short) one + // returnValue = false; + // } + // return returnValue; + // } + // + // /// <summary> + // /// Returns true if a given gene value, + // /// for which the meaning is a ticker code, has the same sign + // /// of all the other genes that point to tickers + // /// contained in a given genome. + // /// </summary> + // /// <param name="newGeneValuePointingToTicker">Gene's value for which sign has to be checked</param> + // /// <param name="newGeneValuePosition">Position for the new gene value inside the genome to be checked</param> + // /// <param name="genomeToBeModified">The genome to be checked, before + // /// a mutation or a new gene assignment + // /// through the parameter newGeneValuePointingToTicker</param> + // public static bool WillGenomeHaveTickersOfSameSign(int newGeneValuePointingToTicker, + // int newGeneValuePosition, + // Genome genomeToBeModified) + // { + // bool returnValue = true; + // for( int position = 0; position < genomeToBeModified.Size; position++ ) + // { + // if( (position != newGeneValuePosition) && + // ( (newGeneValuePointingToTicker < 0 && genomeToBeModified.GetGeneValue(position) >= 0 ) || + // (newGeneValuePointingToTicker >= 0 && genomeToBeModified.GetGeneValue(position) < 0 ) ) ) + // // if the current position is different from the newGeneValuePosition + // // and + // // newGeneValuePointingToTicker points to a short (long) position and + // // a the gene in the current position points to a long (short) one + // returnValue = false; + // } + // return returnValue; + // } + } } |
|
From: Marco M. <mi...@us...> - 2007-08-29 09:56:08
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16135/b7_Scripts/TickerSelectionTesting Modified Files: GenomeManagerForEfficientOTCCTOPortfolio.cs GenomeManagerForEfficientPortfolio.cs Log Message: Minor changes Index: GenomeManagerForEfficientPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/GenomeManagerForEfficientPortfolio.cs,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** GenomeManagerForEfficientPortfolio.cs 3 Jan 2007 23:20:14 -0000 1.27 --- GenomeManagerForEfficientPortfolio.cs 29 Aug 2007 09:56:00 -0000 1.28 *************** *** 24,27 **** --- 24,28 ---- using System.Data; using System.Collections; + using QuantProject.ADT.Statistics; using QuantProject.ADT.Optimizing.Genetic; *************** *** 29,33 **** --- 30,36 ---- using QuantProject.Data; using QuantProject.Data.DataTables; + using QuantProject.Business.Strategies; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; + using QuantProject.Scripts.WalkForwardTesting.WalkForwardLag; namespace QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios *************** *** 60,71 **** protected GeneticOptimizer currentGeneticOptimizer; - static public string GetCleanTickerCode(string tickerCodeForLongOrShortTrade) - { - if(tickerCodeForLongOrShortTrade.StartsWith("-")) - return tickerCodeForLongOrShortTrade.Substring(1,tickerCodeForLongOrShortTrade.Length -1); - else - return tickerCodeForLongOrShortTrade; - } - //IGenomeManager implementation for properties public virtual int GenomeSize --- 63,66 ---- *************** *** 154,158 **** this.maxValueForGenes = - 1; break; ! case QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios.PortfolioType.ShortAndLong : //Both Long and Short orders are admitted this.minValueForGenes = - this.originalNumOfTickers; --- 149,153 ---- this.maxValueForGenes = - 1; break; ! default : //Both Long and Short orders are admitted this.minValueForGenes = - this.originalNumOfTickers; *************** *** 234,238 **** this.variance = portfolioVariance; this.rateOfReturn = averagePortfolioRateOfReturn; ! returnValue = this.getFitnessValue_calculate(); } --- 229,246 ---- this.variance = portfolioVariance; this.rateOfReturn = averagePortfolioRateOfReturn; ! SignedTickers signedTickers = ! new SignedTickers( ((GenomeMeaning)genome.Meaning).Tickers ); ! WeightedPositions weightedPositions = ! new WeightedPositions( ((GenomeMeaning)genome.Meaning).TickersPortfolioWeights, ! signedTickers ); ! if( this.portfolioType == PortfolioType.OnlyMixed && ! ( weightedPositions.NumberOfLongPositions == 0 || ! weightedPositions.NumberOfShortPositions == 0 ) ) ! // if both long and short positions have to be taken and ! // there aren't both long and short positions in portfolio ! returnValue = -1.0; ! else//short and long, only long or only short portfolio OR ! //Only Mixed portfolio with both long and short position ! returnValue = this.getFitnessValue_calculate(); } *************** *** 280,290 **** // in this implementation new gene values must be different from // the others already stored in the given genome - // the generation of new genes doesn't depend on gene's position - // within the genome int returnValue = GenomeManagement.RandomGenerator.Next(genome.GetMinValueForGenes(genePosition), genome.GetMaxValueForGenes(genePosition) + 1); ! while(GenomeManipulator.IsTickerContainedInGenome(returnValue, ! genome) ) ! //the portfolio can't have a long position and a short one for the same ticker { returnValue = GenomeManagement.RandomGenerator.Next(genome.GetMinValueForGenes(genePosition), --- 288,295 ---- // in this implementation new gene values must be different from // the others already stored in the given genome int returnValue = GenomeManagement.RandomGenerator.Next(genome.GetMinValueForGenes(genePosition), genome.GetMaxValueForGenes(genePosition) + 1); ! while( GenomeManipulator.IsTickerContainedInGenome(returnValue,genome) ) ! //the portfolio can't have a long position and a short one for the same ticker { returnValue = GenomeManagement.RandomGenerator.Next(genome.GetMinValueForGenes(genePosition), *************** *** 303,317 **** genome.GetMaxValueForGenes(genePositionToBeMutated) + 1); ! while(GenomeManipulator.IsTickerContainedInGenome(newValueForGene, ! genome) ) ! //the efficient portfolio, in this implementation, ! // can't have a long position and a short position ! // for the same ticker { newValueForGene = GenomeManagement.RandomGenerator.Next(genome.GetMinValueForGenes(genePositionToBeMutated), genome.GetMaxValueForGenes(genePositionToBeMutated) + 1); } ! GenomeManagement.MutateOneGene(genome, ! genePositionToBeMutated, newValueForGene); } --- 308,318 ---- genome.GetMaxValueForGenes(genePositionToBeMutated) + 1); ! while( GenomeManipulator.IsTickerContainedInGenome(newValueForGene,genome) ) ! //the portfolio can't have a long position and a short one for the same ticker { newValueForGene = GenomeManagement.RandomGenerator.Next(genome.GetMinValueForGenes(genePositionToBeMutated), genome.GetMaxValueForGenes(genePositionToBeMutated) + 1); } ! GenomeManagement.MutateOneGene(genome, genePositionToBeMutated, newValueForGene); } Index: GenomeManagerForEfficientOTCCTOPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/GenomeManagerForEfficientOTCCTOPortfolio.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** GenomeManagerForEfficientOTCCTOPortfolio.cs 9 Apr 2007 18:02:18 -0000 1.4 --- GenomeManagerForEfficientOTCCTOPortfolio.cs 29 Aug 2007 09:56:00 -0000 1.5 *************** *** 38,42 **** /// </summary> [Serializable] ! public class GenomeManagerForEfficientOTCCTOPortfolio : GenomeManagerForEfficientPortfolio { --- 38,42 ---- /// </summary> [Serializable] ! public class GenomeManagerForEfficientOTCCTOPortfolio : GenomeManagerForWeightedEfficientPortfolio { |
|
From: Marco M. <mi...@us...> - 2007-08-29 09:54:57
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv15708/b7_Scripts/TickerSelectionTesting Modified Files: GenomeManagerForWeightedEfficientPortfolio.cs Log Message: Fixed bug in mutation method Index: GenomeManagerForWeightedEfficientPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/GenomeManagerForWeightedEfficientPortfolio.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** GenomeManagerForWeightedEfficientPortfolio.cs 3 Jan 2007 23:20:13 -0000 1.6 --- GenomeManagerForWeightedEfficientPortfolio.cs 29 Aug 2007 09:54:51 -0000 1.7 *************** *** 171,183 **** { int returnValue; ! double partOfGeneToSubtractOrAdd = 0.25; ! int geneValue = Math.Abs(genome.GetGeneValue(genePositionToBeMutated)); int subtractOrAdd = GenomeManagement.RandomGenerator.Next(2); if(subtractOrAdd == 1)//subtract a part of the gene value from the gene value itself ! returnValue = geneValue - Convert.ToInt32(partOfGeneToSubtractOrAdd*geneValue); ! else ! returnValue = Math.Min(genome.GetMaxValueForGenes(genePositionToBeMutated), ! geneValue + Convert.ToInt32(partOfGeneToSubtractOrAdd*geneValue)); return returnValue; } --- 171,196 ---- { int returnValue; ! double partOfGeneToSubtractOrAdd = 0.03; ! int geneValue = genome.GetGeneValue(genePositionToBeMutated); int subtractOrAdd = GenomeManagement.RandomGenerator.Next(2); if(subtractOrAdd == 1)//subtract a part of the gene value from the gene value itself ! { ! if( geneValue < 0 ) ! returnValue = Math.Max( geneValue - Convert.ToInt32(partOfGeneToSubtractOrAdd*Math.Abs(geneValue)), ! genome.GetMinValueForGenes(genePositionToBeMutated) ); ! else // geneValue >= 0 ! returnValue = geneValue - Convert.ToInt32(partOfGeneToSubtractOrAdd*Math.Abs(geneValue)); ! } ! else//add a part of the gene value to the gene value itself ! { ! if( geneValue < 0 ) ! returnValue = geneValue + Convert.ToInt32(partOfGeneToSubtractOrAdd*Math.Abs(geneValue)); ! else // geneValue >= 0 ! returnValue = Math.Min(genome.GetMaxValueForGenes(genePositionToBeMutated), ! geneValue + Convert.ToInt32(partOfGeneToSubtractOrAdd*geneValue)); ! } ! return returnValue; + } *************** *** 211,215 **** // a new newalueForGene has to be generated newValueForGene = GenomeManagement.RandomGenerator.Next(genome.GetMinValueForGenes(genePositionToBeMutated), ! genome.GetMaxValueForGenes(genePositionToBeMutated) + 1); genome.SetGeneValue(newValueForGene, genePositionToBeMutated); --- 224,228 ---- // a new newalueForGene has to be generated newValueForGene = GenomeManagement.RandomGenerator.Next(genome.GetMinValueForGenes(genePositionToBeMutated), ! genome.GetMaxValueForGenes(genePositionToBeMutated) + 1); genome.SetGeneValue(newValueForGene, genePositionToBeMutated); |
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/WeightedPVO/WeightedBalancedPVO In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv13724/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/WeightedPVO/WeightedBalancedPVO Modified Files: EndOfDayTimerHandlerWeightedBalancedPVO.cs Log Message: Code has been re-organized in a more logical and Object Oriented way: - WeightedPositions class has been used. - Some static methods have been deleted from SignedTicker class. They have been moved to WeightedPositions. - Basic orders'management has been moved to the primitive base class EndOfDayTimerHandler and to AccountManager class Index: EndOfDayTimerHandlerWeightedBalancedPVO.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/WeightedPVO/WeightedBalancedPVO/EndOfDayTimerHandlerWeightedBalancedPVO.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** EndOfDayTimerHandlerWeightedBalancedPVO.cs 9 Apr 2007 18:07:09 -0000 1.2 --- EndOfDayTimerHandlerWeightedBalancedPVO.cs 29 Aug 2007 09:50:21 -0000 1.3 *************** *** 127,131 **** { 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 --- 127,131 ---- { DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); ! if(setOfTickersToBeOptimized.Rows.Count > this.numberOfTickersToBeChosen*2) //the optimization process is meaningful only if the initial set of tickers is //larger than the number of tickers to be chosen *************** *** 154,159 **** GO.Run(false); ! this.chosenTickers = ((GenomeMeaningPVO)GO.BestGenome.Meaning).Tickers; ! this.chosenTickersPortfolioWeights = ((GenomeMeaningPVO)GO.BestGenome.Meaning).TickersPortfolioWeights; this.currentOversoldThreshold = ((GenomeMeaningPVO)GO.BestGenome.Meaning).OversoldThreshold; this.currentOverboughtThreshold = ((GenomeMeaningPVO)GO.BestGenome.Meaning).OverboughtThreshold; --- 154,159 ---- GO.Run(false); ! this.chosenWeightedPositions = new WeightedPositions( ((GenomeMeaningPVO)GO.BestGenome.Meaning).TickersPortfolioWeights, ! new SignedTickers( ((GenomeMeaningPVO)GO.BestGenome.Meaning).Tickers) ); this.currentOversoldThreshold = ((GenomeMeaningPVO)GO.BestGenome.Meaning).OversoldThreshold; this.currentOverboughtThreshold = ((GenomeMeaningPVO)GO.BestGenome.Meaning).OverboughtThreshold; |
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/BiasedPVO/BiasedOTC_PVONoThresholds In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv13724/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/BiasedPVO/BiasedOTC_PVONoThresholds Modified Files: EndOfDayTimerHandlerBiasedOTC_PVONoThresholds.cs Log Message: Code has been re-organized in a more logical and Object Oriented way: - WeightedPositions class has been used. - Some static methods have been deleted from SignedTicker class. They have been moved to WeightedPositions. - Basic orders'management has been moved to the primitive base class EndOfDayTimerHandler and to AccountManager class Index: EndOfDayTimerHandlerBiasedOTC_PVONoThresholds.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/BiasedPVO/BiasedOTC_PVONoThresholds/EndOfDayTimerHandlerBiasedOTC_PVONoThresholds.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** EndOfDayTimerHandlerBiasedOTC_PVONoThresholds.cs 27 Feb 2007 22:52:41 -0000 1.1 --- EndOfDayTimerHandlerBiasedOTC_PVONoThresholds.cs 29 Aug 2007 09:50:20 -0000 1.2 *************** *** 51,59 **** protected int numOfDifferentGenomesToEvaluateOutOfSample; protected int currentGenomeIndex = 0; ! protected double currentTickersGainOrLoss = 0.0; protected Hashtable genomesCollector; ! new protected string[,] chosenTickers; ! new protected double[,] chosenTickersPortfolioWeights; public EndOfDayTimerHandlerBiasedOTC_PVONoThresholds(string tickerGroupID, int numberOfEligibleTickers, --- 51,58 ---- protected int numOfDifferentGenomesToEvaluateOutOfSample; protected int currentGenomeIndex = 0; ! protected double currentWeightedPositionsGainOrLoss = 0.0; protected Hashtable genomesCollector; ! protected WeightedPositions[] weightedPositionsToEvaluateOutOfSample; public EndOfDayTimerHandlerBiasedOTC_PVONoThresholds(string tickerGroupID, int numberOfEligibleTickers, *************** *** 84,94 **** { this.numOfDifferentGenomesToEvaluateOutOfSample = numOfDifferentGenomesToEvaluateOutOfSample; ! this.chosenTickers = new string[numOfDifferentGenomesToEvaluateOutOfSample, numberOfTickersToBeChosen]; ! this.chosenTickersPortfolioWeights = new double[numOfDifferentGenomesToEvaluateOutOfSample, numberOfTickersToBeChosen]; this.genomesCollector = new Hashtable(); } ! protected virtual double getCurrentChosenTickersGainOrLoss(IndexBasedEndOfDayTimer timer, ! int indexForChosenTickers) { double returnValue = 999.0; --- 83,92 ---- { this.numOfDifferentGenomesToEvaluateOutOfSample = numOfDifferentGenomesToEvaluateOutOfSample; ! this.weightedPositionsToEvaluateOutOfSample = new WeightedPositions[numOfDifferentGenomesToEvaluateOutOfSample]; this.genomesCollector = new Hashtable(); } ! protected virtual double getCurrentWeightedPositionsGainOrLoss(IndexBasedEndOfDayTimer timer, ! int indexForChosenWeightedPositions) { double returnValue = 999.0; *************** *** 99,114 **** DateTime lastMarketDay = (DateTime)timer.IndexQuotes.Rows[timer.CurrentDateArrayPosition - 1]["quDate"]; - - string[] tickers = new string[this.numberOfTickersToBeChosen]; - double[] tickerWeights = new double[this.numberOfTickersToBeChosen]; - for(int i = 0; i < this.numberOfTickersToBeChosen; i++) - { - tickers[i] = this.chosenTickers[indexForChosenTickers,i]; - tickerWeights[i] = this.chosenTickersPortfolioWeights[indexForChosenTickers,i]; - } returnValue = ! SignedTicker.GetLastNightPortfolioReturn( ! tickers, tickerWeights, ! lastMarketDay, today); } catch(MissingQuotesException ex) --- 97,103 ---- DateTime lastMarketDay = (DateTime)timer.IndexQuotes.Rows[timer.CurrentDateArrayPosition - 1]["quDate"]; returnValue = ! this.weightedPositionsToEvaluateOutOfSample[indexForChosenWeightedPositions].GetLastNightReturn( ! lastMarketDay, today); } catch(MissingQuotesException ex) *************** *** 121,137 **** //sets currentGenomeIndex with the genome's index that crosses an overbought/oversold threshold with the //highest degree and sets currentTickersGainOrLoss accordingly ! private void marketOpenEventHandler_openPositions_chooseBestGenome(IndexBasedEndOfDayTimer timer) { //default genome index is the first //genome (with the highest plain fitness), if no other genome //presents a gain or a loss greater than the first genome ! double currentTickersGainOrLoss = 0.0; double currentMaxAbsoluteMove = 0.0; double currentAbsoluteMove = 0.0; for(int i = 0; i < this.numOfDifferentGenomesToEvaluateOutOfSample; i++) { ! currentTickersGainOrLoss = this.getCurrentChosenTickersGainOrLoss(timer, i); currentAbsoluteMove = ! Math.Abs( currentTickersGainOrLoss ); if(currentAbsoluteMove != 999.0 && currentAbsoluteMove > currentMaxAbsoluteMove) --- 110,126 ---- //sets currentGenomeIndex with the genome's index that crosses an overbought/oversold threshold with the //highest degree and sets currentTickersGainOrLoss accordingly ! protected virtual void openPositions_chooseBestGenome(IndexBasedEndOfDayTimer timer) { //default genome index is the first //genome (with the highest plain fitness), if no other genome //presents a gain or a loss greater than the first genome ! double currentWeightedPositionsGainOrLoss = 0.0; double currentMaxAbsoluteMove = 0.0; double currentAbsoluteMove = 0.0; for(int i = 0; i < this.numOfDifferentGenomesToEvaluateOutOfSample; i++) { ! currentWeightedPositionsGainOrLoss = this.getCurrentWeightedPositionsGainOrLoss(timer, i); currentAbsoluteMove = ! Math.Abs( currentWeightedPositionsGainOrLoss ); if(currentAbsoluteMove != 999.0 && currentAbsoluteMove > currentMaxAbsoluteMove) *************** *** 141,168 **** currentMaxAbsoluteMove = currentAbsoluteMove; this.currentGenomeIndex = i; ! this.currentTickersGainOrLoss = currentTickersGainOrLoss; } } } ! ! ! protected void marketOpenEventHandler_openPositions(IndexBasedEndOfDayTimer timer) { ! this.currentTickersGainOrLoss = 999.0; ! this.marketOpenEventHandler_openPositions_chooseBestGenome(timer); ! if(this.currentTickersGainOrLoss != 999.0) ! //currentChosenTickersValue has been properly computed { ! string[] tickers = new string[this.numberOfTickersToBeChosen]; ! for(int i = 0; i < this.numberOfTickersToBeChosen; i++) ! tickers[i] = this.chosenTickers[this.currentGenomeIndex,i]; ! if(this.currentTickersGainOrLoss > 0.0) { ! SignedTicker.ChangeSignOfEachTicker(tickers); ! base.openPositions(tickers); } else //(currentChosenTickersGainOrLoss < 0.0) { ! base.openPositions(tickers); } } --- 130,164 ---- currentMaxAbsoluteMove = currentAbsoluteMove; this.currentGenomeIndex = i; ! this.currentWeightedPositionsGainOrLoss = currentWeightedPositionsGainOrLoss; } } } ! //no thresholds ! protected virtual void openPositions(IndexBasedEndOfDayTimer timer) { ! this.currentWeightedPositionsGainOrLoss = 999.0; ! this.openPositions_chooseBestGenome(timer); ! if(this.currentWeightedPositionsGainOrLoss != 999.0) ! //currentWeightedPositionsGainOrLoss has been properly computed { ! if(this.currentWeightedPositionsGainOrLoss > 0.0) { ! this.weightedPositionsToEvaluateOutOfSample[this.currentGenomeIndex].Reverse(); ! try ! { ! AccountManager.OpenPositions(this.weightedPositionsToEvaluateOutOfSample[this.currentGenomeIndex], ! this.account); ! } ! catch(Exception ex) ! {ex=ex;} ! finally ! { ! this.weightedPositionsToEvaluateOutOfSample[this.currentGenomeIndex].Reverse(); ! } } else //(currentChosenTickersGainOrLoss < 0.0) { ! AccountManager.OpenPositions(this.weightedPositionsToEvaluateOutOfSample[this.currentGenomeIndex], ! this.account); } } *************** *** 174,178 **** if(this.account.Portfolio.Count == 0 && this.genomesCollector.Count > 0) ! this.marketOpenEventHandler_openPositions((IndexBasedEndOfDayTimer)sender); } --- 170,174 ---- if(this.account.Portfolio.Count == 0 && this.genomesCollector.Count > 0) ! this.openPositions((IndexBasedEndOfDayTimer)sender); } *************** *** 180,190 **** Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! base.closePositions(); ! this.orders.Clear(); } #region OneHourAfterMarketCloseEventHandler ! private void setTickers_updateTickersListAndAddGenomesForLog(GeneticOptimizer GO, int eligibleTickersForGO) { --- 176,185 ---- Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! AccountManager.ClosePositions(this.account); } #region OneHourAfterMarketCloseEventHandler ! protected void setTickers_updateTickersListAndAddGenomesForLog(GeneticOptimizer GO, int eligibleTickersForGO) { *************** *** 202,215 **** // fitness has been added to the hashtable yet { ! for(int i = 0; i<this.numberOfTickersToBeChosen; i++) ! { ! this.chosenTickers[addedGenomes,i] = ! ((GenomeMeaningPVO)currentGenome.Meaning).Tickers[i]; ! this.chosenTickersPortfolioWeights[addedGenomes,i] = ! ((GenomeMeaningPVO)currentGenome.Meaning).TickersPortfolioWeights[i]; ! } ! this.genomesCollector.Add(currentGenome.Fitness, null); - this.addPVOGenomeToBestGenomes(currentGenome,((GenomeManagerForEfficientPortfolio)this.iGenomeManager).FirstQuoteDate, ((GenomeManagerForEfficientPortfolio)this.iGenomeManager).LastQuoteDate, eligibleTickersForGO, --- 197,204 ---- // fitness has been added to the hashtable yet { ! this.weightedPositionsToEvaluateOutOfSample[addedGenomes] = new WeightedPositions( ! ((GenomeMeaningPVO)currentGenome.Meaning).TickersPortfolioWeights, ! new SignedTickers( ((GenomeMeaningPVO)currentGenome.Meaning).Tickers ) ); this.genomesCollector.Add(currentGenome.Fitness, null); this.addPVOGenomeToBestGenomes(currentGenome,((GenomeManagerForEfficientPortfolio)this.iGenomeManager).FirstQuoteDate, ((GenomeManagerForEfficientPortfolio)this.iGenomeManager).LastQuoteDate, eligibleTickersForGO, |
|
From: Marco M. <mi...@us...> - 2007-08-29 09:50:36
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/WeightedPVO In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv13724/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/WeightedPVO Modified Files: EndOfDayTimerHandlerWeightedPVO.cs Log Message: Code has been re-organized in a more logical and Object Oriented way: - WeightedPositions class has been used. - Some static methods have been deleted from SignedTicker class. They have been moved to WeightedPositions. - Basic orders'management has been moved to the primitive base class EndOfDayTimerHandler and to AccountManager class Index: EndOfDayTimerHandlerWeightedPVO.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/WeightedPVO/EndOfDayTimerHandlerWeightedPVO.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** EndOfDayTimerHandlerWeightedPVO.cs 27 Feb 2007 22:52:40 -0000 1.1 --- EndOfDayTimerHandlerWeightedPVO.cs 29 Aug 2007 09:50:21 -0000 1.2 *************** *** 124,128 **** { 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 --- 124,128 ---- { DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); ! if(setOfTickersToBeOptimized.Rows.Count > this.numberOfTickersToBeChosen*2) //the optimization process is meaningful only if the initial set of tickers is //larger than the number of tickers to be chosen *************** *** 151,156 **** GO.Run(false); ! this.chosenTickers = ((GenomeMeaningPVO)GO.BestGenome.Meaning).Tickers; ! this.chosenTickersPortfolioWeights = ((GenomeMeaningPVO)GO.BestGenome.Meaning).TickersPortfolioWeights; this.currentOversoldThreshold = ((GenomeMeaningPVO)GO.BestGenome.Meaning).OversoldThreshold; this.currentOverboughtThreshold = ((GenomeMeaningPVO)GO.BestGenome.Meaning).OverboughtThreshold; --- 151,156 ---- GO.Run(false); ! this.chosenWeightedPositions = new WeightedPositions( ((GenomeMeaningPVO)GO.BestGenome.Meaning).TickersPortfolioWeights, ! new SignedTickers( ((GenomeMeaningPVO)GO.BestGenome.Meaning).Tickers) ); this.currentOversoldThreshold = ((GenomeMeaningPVO)GO.BestGenome.Meaning).OversoldThreshold; this.currentOverboughtThreshold = ((GenomeMeaningPVO)GO.BestGenome.Meaning).OverboughtThreshold; |
|
From: Marco M. <mi...@us...> - 2007-08-29 09:50:31
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv13724/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator Modified Files: EndOfDayTimerHandlerPVO.cs Log Message: Code has been re-organized in a more logical and Object Oriented way: - WeightedPositions class has been used. - Some static methods have been deleted from SignedTicker class. They have been moved to WeightedPositions. - Basic orders'management has been moved to the primitive base class EndOfDayTimerHandler and to AccountManager class Index: EndOfDayTimerHandlerPVO.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/EndOfDayTimerHandlerPVO.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** EndOfDayTimerHandlerPVO.cs 9 Apr 2007 18:08:04 -0000 1.5 --- EndOfDayTimerHandlerPVO.cs 29 Aug 2007 09:50:20 -0000 1.6 *************** *** 57,65 **** protected double currentOverboughtThreshold; protected double maxAcceptableCloseToCloseDrawdown; - protected bool stopLossConditionReached; - protected double currentAccountValue; - protected double previousAccountValue; - protected int numDaysBetweenEachOptimization; - protected int numDaysElapsedSinceLastOptimization; protected DateTime lastCloseDate; protected IGenomeManager iGenomeManager; --- 57,60 ---- *************** *** 118,133 **** 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; - } } ! protected virtual double getCurrentChosenTickersValue(IndexBasedEndOfDayTimer timer) { double returnValue = 999.0; --- 113,124 ---- 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; } ! protected virtual double getCurrentChosenWeightedPositionsValue(IndexBasedEndOfDayTimer timer) { double returnValue = 999.0; *************** *** 141,147 **** (DateTime)timer.IndexQuotes.Rows[timer.CurrentDateArrayPosition]["quDate"]; returnValue = ! SignedTicker.GetCloseToClosePortfolioReturn( ! this.chosenTickers, this.chosenTickersPortfolioWeights, ! initialDate,finalDate) + 1.0; } catch(MissingQuotesException ex) --- 132,137 ---- (DateTime)timer.IndexQuotes.Rows[timer.CurrentDateArrayPosition]["quDate"]; returnValue = ! this.chosenWeightedPositions.GetCloseToCloseReturn( initialDate, ! finalDate) + 1.0; } catch(MissingQuotesException ex) *************** *** 154,160 **** private void marketCloseEventHandler_reverseIfNeeded(IndexBasedEndOfDayTimer timer) { ! double currentChosenTickersValue = ! this.getCurrentChosenTickersValue(timer); ! if(currentChosenTickersValue != 999.0) //currentChosenTickersValue has been properly computed { --- 144,150 ---- private void marketCloseEventHandler_reverseIfNeeded(IndexBasedEndOfDayTimer timer) { ! double currentChosenWeightedPositionsTickersValue = ! this.getCurrentChosenWeightedPositionsValue(timer); ! if(currentChosenWeightedPositionsTickersValue != 999.0) //currentChosenTickersValue has been properly computed { *************** *** 162,166 **** //it is possible to reverse positions { ! if(currentChosenTickersValue >= 1.0 + currentOverboughtThreshold && this.portfolioHasBeenOversold) //open positions derive from an overSold period but now --- 152,156 ---- //it is possible to reverse positions { ! if(currentChosenWeightedPositionsTickersValue >= 1.0 + currentOverboughtThreshold && this.portfolioHasBeenOversold) //open positions derive from an overSold period but now *************** *** 171,175 **** this.portfolioHasBeenOverbought = true; } ! if(currentChosenTickersValue <= 1.0 - currentOversoldThreshold && this.portfolioHasBeenOverbought) //open positions derive from an overSold period but now --- 161,165 ---- this.portfolioHasBeenOverbought = true; } ! if(currentChosenWeightedPositionsTickersValue <= 1.0 - currentOversoldThreshold && this.portfolioHasBeenOverbought) //open positions derive from an overSold period but now *************** *** 184,203 **** } ! private void marketCloseEventHandler_openPositions(IndexBasedEndOfDayTimer timer) { ! double currentChosenTickersValue = ! this.getCurrentChosenTickersValue(timer); ! if(currentChosenTickersValue != 999.0) //currentChosenTickersValue has been properly computed { ! if(currentChosenTickersValue >= 1.0 + currentOverboughtThreshold && this.portfolioType == PortfolioType.ShortAndLong) { ! SignedTicker.ChangeSignOfEachTicker(this.chosenTickers); ! ! //short the portfolio try { ! base.openPositions(this.chosenTickers); this.portfolioHasBeenOverbought = true; this.portfolioHasBeenOversold = false; --- 174,194 ---- } ! protected void marketCloseEventHandler_openPositions(IndexBasedEndOfDayTimer timer) { ! if(this.account.CashAmount == 0.0 && this.account.Transactions.Count == 0) ! this.account.AddCash(15000); ! double currentChosenWeightedPositionsValue = ! this.getCurrentChosenWeightedPositionsValue(timer); ! if(currentChosenWeightedPositionsValue != 999.0) //currentChosenTickersValue has been properly computed { ! if(currentChosenWeightedPositionsValue >= 1.0 + currentOverboughtThreshold && this.portfolioType == PortfolioType.ShortAndLong) { ! this.chosenWeightedPositions.Reverse(); try { ! AccountManager.OpenPositions( this.chosenWeightedPositions, ! this.account ); this.portfolioHasBeenOverbought = true; this.portfolioHasBeenOversold = false; *************** *** 209,218 **** finally { ! SignedTicker.ChangeSignOfEachTicker(this.chosenTickers); } } ! else if (currentChosenTickersValue <= 1.0 - currentOversoldThreshold) { ! base.openPositions(this.chosenTickers); this.portfolioHasBeenOverbought = false; this.portfolioHasBeenOversold = true; --- 200,210 ---- finally { ! this.chosenWeightedPositions.Reverse(); } } ! else if (currentChosenWeightedPositionsValue <= 1.0 - currentOversoldThreshold) { ! AccountManager.OpenPositions( this.chosenWeightedPositions, ! this.account ); this.portfolioHasBeenOverbought = false; this.portfolioHasBeenOversold = true; *************** *** 226,232 **** this.numDaysElapsedSinceLastOptimization + 1 == this.numDaysBetweenEachOptimization ) { ! base.closePositions(); //a new optimization is needed, now ! this.chosenTickers[0] = null; //when positions are closed, these parameters //have to be reset to false --- 218,224 ---- this.numDaysElapsedSinceLastOptimization + 1 == this.numDaysBetweenEachOptimization ) { ! AccountManager.ClosePositions(this.account); //a new optimization is needed, now ! this.chosenWeightedPositions = null; //when positions are closed, these parameters //have to be reset to false *************** *** 241,245 **** //this.marketCloseEventHandler_updateStopLossCondition(); this.marketCloseEventHandler_closePositionsIfNeeded(); ! if(this.chosenTickers[0] != null) //tickers to buy have been chosen by the optimizer { --- 233,237 ---- //this.marketCloseEventHandler_updateStopLossCondition(); this.marketCloseEventHandler_closePositionsIfNeeded(); ! if(this.chosenWeightedPositions != null) //tickers to buy have been chosen by the optimizer { *************** *** 248,252 **** //positions are opened only if thresholds are reached else//there are some opened positions ! this.marketCloseEventHandler_reverseIfNeeded((IndexBasedEndOfDayTimer)sender);; } --- 240,244 ---- //positions are opened only if thresholds are reached else//there are some opened positions ! this.marketCloseEventHandler_reverseIfNeeded((IndexBasedEndOfDayTimer)sender); } *************** *** 320,324 **** { 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 --- 312,316 ---- { DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); ! if(setOfTickersToBeOptimized.Rows.Count > this.numberOfTickersToBeChosen*2) //the optimization process is meaningful only if the initial set of tickers is //larger than the number of tickers to be chosen *************** *** 347,352 **** GO.Run(false); ! this.chosenTickers = ((GenomeMeaningPVO)GO.BestGenome.Meaning).Tickers; ! this.chosenTickersPortfolioWeights = ((GenomeMeaningPVO)GO.BestGenome.Meaning).TickersPortfolioWeights; this.currentOversoldThreshold = ((GenomeMeaningPVO)GO.BestGenome.Meaning).OversoldThreshold; this.currentOverboughtThreshold = ((GenomeMeaningPVO)GO.BestGenome.Meaning).OverboughtThreshold; --- 339,344 ---- GO.Run(false); ! this.chosenWeightedPositions = new WeightedPositions( ((GenomeMeaningPVO)GO.BestGenome.Meaning).TickersPortfolioWeights, ! new SignedTickers( ((GenomeMeaningPVO)GO.BestGenome.Meaning).Tickers) ); this.currentOversoldThreshold = ((GenomeMeaningPVO)GO.BestGenome.Meaning).OversoldThreshold; this.currentOverboughtThreshold = ((GenomeMeaningPVO)GO.BestGenome.Meaning).OverboughtThreshold; *************** *** 371,375 **** this.seedForRandomGenerator++; this.numDaysElapsedSinceLastOptimization++; - this.orders.Clear(); if((this.numDaysElapsedSinceLastOptimization == this.numDaysBetweenEachOptimization)) --- 363,366 ---- |
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/BiasedPVO/BiasedPVONoThresholds In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv12786/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/BiasedPVO/BiasedPVONoThresholds Modified Files: EndOfDayTimerHandlerBiasedPVONoThresholds.cs Log Message: Changed inherited class: now this class derives from EndOfDayTimerHandlerBiasedOTC_PVONoThresholds (in place of EndOfDayTimerHandlerPVO) Code has been re-organized in a more logical and Object Oriented way: - WeightedPositions class has been used. - Some static methods have been deleted from SignedTicker class. They have been moved to WeightedPositions. - Basic orders'management has been moved to the primitive base class EndOfDayTimerHandler and to AccountManager class Index: EndOfDayTimerHandlerBiasedPVONoThresholds.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/BiasedPVO/BiasedPVONoThresholds/EndOfDayTimerHandlerBiasedPVONoThresholds.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** EndOfDayTimerHandlerBiasedPVONoThresholds.cs 27 Feb 2007 22:52:40 -0000 1.1 --- EndOfDayTimerHandlerBiasedPVONoThresholds.cs 29 Aug 2007 09:48:18 -0000 1.2 *************** *** 38,41 **** --- 38,43 ---- using QuantProject.Scripts.WalkForwardTesting.LinearCombination; using QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator; + using QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator.BiasedPVO.BiasedOTC_PVONoThresholds; + namespace QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator.BiasedPVO.BiasedPVONoThresholds *************** *** 47,62 **** /// </summary> [Serializable] ! public class EndOfDayTimerHandlerBiasedPVONoThresholds : EndOfDayTimerHandlerPVO { - protected int numOfDifferentGenomesToEvaluateOutOfSample; protected double minimumAcceptableGain; ! protected int currentGenomeIndex = 0; ! protected double currentTickersGainOrLoss = 0.0; ! protected Hashtable genomesCollector; ! protected bool takeProfitConditionReached; ! ! new protected string[,] chosenTickers; ! new protected double[,] chosenTickersPortfolioWeights; ! public EndOfDayTimerHandlerBiasedPVONoThresholds(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, --- 49,56 ---- /// </summary> [Serializable] ! public class EndOfDayTimerHandlerBiasedPVONoThresholds : EndOfDayTimerHandlerBiasedOTC_PVONoThresholds { protected double minimumAcceptableGain; ! public EndOfDayTimerHandlerBiasedPVONoThresholds(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, *************** *** 74,177 **** generationNumberForGeneticOptimizer, populationSizeForGeneticOptimizer, ! benchmark, ! 2, ! 0, ! 0, ! 0, ! 0, ! 1, ! true, ! false, ! numDaysBetweenEachOptimization, ! portfolioType, maxAcceptableCloseToCloseDrawdown) { - this.numOfDifferentGenomesToEvaluateOutOfSample = numOfDifferentGenomesToEvaluateOutOfSample; this.minimumAcceptableGain = minimumAcceptableGain; ! this.chosenTickers = new string[numOfDifferentGenomesToEvaluateOutOfSample, numberOfTickersToBeChosen]; ! this.chosenTickersPortfolioWeights = new double[numOfDifferentGenomesToEvaluateOutOfSample, numberOfTickersToBeChosen]; ! this.genomesCollector = new Hashtable(); } #region MarketCloseEventHandler ! protected virtual double getCurrentChosenTickersGainOrLoss(IndexBasedEndOfDayTimer timer, ! int indexForChosenTickers) ! { ! double returnValue = 999.0; ! try ! { ! DateTime date = ! (DateTime)timer.IndexQuotes.Rows[timer.CurrentDateArrayPosition]["quDate"]; ! string[] tickers = new string[this.numberOfTickersToBeChosen]; ! double[] tickerWeights = new double[this.numberOfTickersToBeChosen]; ! for(int i = 0; i < this.numberOfTickersToBeChosen; i++) ! { ! tickers[i] = this.chosenTickers[indexForChosenTickers,i]; ! tickerWeights[i] = this.chosenTickersPortfolioWeights[indexForChosenTickers,i]; ! } ! returnValue = ! SignedTicker.GetCloseToClosePortfolioReturn( ! tickers, tickerWeights, ! date,date); ! } ! catch(MissingQuotesException ex) ! { ! ex = ex; ! } ! return returnValue; ! } ! ! //sets currentGenomeIndex with the genome's index that crosses an overbought/oversold threshold with the ! //highest degree and sets currentTickersGainOrLoss accordingly ! private void marketCloseEventHandler_openPositions_chooseBestGenome(IndexBasedEndOfDayTimer timer) ! { ! //default genome index is the first ! //genome (with the highest plain fitness), if no other genome ! //presents a gain or a loss greater than the first genome ! double currentTickersGainOrLoss = 0.0; ! double currentMaxAbsoluteMove = 0.0; ! double currentAbsoluteMove = 0.0; ! for(int i = 0; i < this.numOfDifferentGenomesToEvaluateOutOfSample; i++) ! { ! currentTickersGainOrLoss = this.getCurrentChosenTickersGainOrLoss(timer, i); ! currentAbsoluteMove = ! Math.Abs( currentTickersGainOrLoss ); ! if(currentAbsoluteMove != 999.0 && ! currentAbsoluteMove > currentMaxAbsoluteMove) ! //currentAbsoluteMove has been properly computed and it is ! //greater than the current greatest move up to date ! { ! currentMaxAbsoluteMove = currentAbsoluteMove; ! this.currentGenomeIndex = i; ! this.currentTickersGainOrLoss = currentTickersGainOrLoss; ! } ! } ! } ! ! ! private void marketCloseEventHandler_openPositions(IndexBasedEndOfDayTimer timer) ! { ! this.currentTickersGainOrLoss = 999.0; ! this.marketCloseEventHandler_openPositions_chooseBestGenome(timer); ! if(this.currentTickersGainOrLoss != 999.0) ! //currentChosenTickersValue has been properly computed ! { ! string[] tickers = new string[this.numberOfTickersToBeChosen]; ! for(int i = 0; i < this.numberOfTickersToBeChosen; i++) ! tickers[i] = this.chosenTickers[this.currentGenomeIndex,i]; ! if(this.currentTickersGainOrLoss > 0.0) ! { ! SignedTicker.ChangeSignOfEachTicker(tickers); ! base.openPositions(tickers); ! } ! else //(currentChosenTickersGainOrLoss < 0.0) ! { ! base.openPositions(tickers); ! } ! this.currentAccountValue = this.account.GetMarketValue(); ! } ! } ! ! private void marketCloseEventHandler_closeIfItIsTimeToClose_updateStopLossAndTakeProfitConditions() { this.previousAccountValue = this.currentAccountValue; --- 68,103 ---- generationNumberForGeneticOptimizer, populationSizeForGeneticOptimizer, ! benchmark,numOfDifferentGenomesToEvaluateOutOfSample, ! numDaysBetweenEachOptimization,portfolioType) ! { this.minimumAcceptableGain = minimumAcceptableGain; ! this.maxAcceptableCloseToCloseDrawdown = maxAcceptableCloseToCloseDrawdown; } #region MarketCloseEventHandler ! protected override double getCurrentWeightedPositionsGainOrLoss(IndexBasedEndOfDayTimer timer, ! int indexForChosenWeightedPositions) ! { ! double returnValue = 999.0; ! try ! { ! DateTime today = ! (DateTime)timer.IndexQuotes.Rows[timer.CurrentDateArrayPosition]["quDate"]; ! DateTime lastMarketDay = ! (DateTime)timer.IndexQuotes.Rows[timer.CurrentDateArrayPosition - 1]["quDate"]; ! returnValue = ! this.weightedPositionsToEvaluateOutOfSample[indexForChosenWeightedPositions].GetCloseToCloseReturn( ! lastMarketDay, today); ! } ! catch(MissingQuotesException ex) ! { ! ex = ex; ! } ! return returnValue; ! } ! ! protected virtual void marketCloseEventHandler_closeIfItIsTimeToClose_updateStopLossAndTakeProfitConditions() { this.previousAccountValue = this.currentAccountValue; *************** *** 198,202 **** } ! private void marketCloseEventHandler_closeIfItIsTimeToClose() { this.marketCloseEventHandler_closeIfItIsTimeToClose_updateStopLossAndTakeProfitConditions(); --- 124,128 ---- } ! protected virtual void marketCloseEventHandler_closeIfItIsTimeToClose() { this.marketCloseEventHandler_closeIfItIsTimeToClose_updateStopLossAndTakeProfitConditions(); *************** *** 209,214 **** //another optimization { ! base.closePositions(); ! this.orders.Clear(); } } --- 135,139 ---- //another optimization { ! AccountManager.ClosePositions(this.account); } } *************** *** 221,225 **** this.marketCloseEventHandler_closeIfItIsTimeToClose(); else if ( this.account.Portfolio.Count == 0 && ! this.chosenTickers[0,0] != null ) //portfolio is empty and optimization has been already launched this.marketCloseEventHandler_openPositions((IndexBasedEndOfDayTimer)sender); --- 146,150 ---- this.marketCloseEventHandler_closeIfItIsTimeToClose(); else if ( this.account.Portfolio.Count == 0 && ! this.weightedPositionsToEvaluateOutOfSample != null ) //portfolio is empty and optimization has been already launched this.marketCloseEventHandler_openPositions((IndexBasedEndOfDayTimer)sender); *************** *** 231,270 **** #region OneHourAfterMarketCloseEventHandler ! private void setTickers_updateTickersListAndAddGenomesForLog(GeneticOptimizer GO, ! int eligibleTickersForGO) ! { ! int addedGenomes = 0; ! int counter = 0; ! Genome currentGenome = null; ! this.genomesCollector.Clear(); ! while(addedGenomes < this.numOfDifferentGenomesToEvaluateOutOfSample && ! counter < GO.PopulationSize) ! { ! currentGenome = (Genome)GO.CurrentGeneration[GO.PopulationSize - 1 - counter]; ! if(counter == 0 || ! !this.genomesCollector.ContainsKey(currentGenome.Fitness) ) ! //it is the first genome to be added or no genome with the current ! // fitness has been added to the hashtable yet ! { ! for(int i = 0; i<this.numberOfTickersToBeChosen; i++) ! { ! this.chosenTickers[addedGenomes,i] = ! ((GenomeMeaningPVO)currentGenome.Meaning).Tickers[i]; ! this.chosenTickersPortfolioWeights[addedGenomes,i] = ! ((GenomeMeaningPVO)currentGenome.Meaning).TickersPortfolioWeights[i]; ! } ! ! this.genomesCollector.Add(currentGenome.Fitness, null); ! ! this.addPVOGenomeToBestGenomes(currentGenome,((GenomeManagerForEfficientPortfolio)this.iGenomeManager).FirstQuoteDate, ! ((GenomeManagerForEfficientPortfolio)this.iGenomeManager).LastQuoteDate, eligibleTickersForGO, ! 2, this.portfolioType, GO.GenerationCounter, ! 0.0, 0.0); ! addedGenomes ++ ; ! } ! counter ++ ; ! } ! } ! protected override void setTickers(DateTime currentDate, bool setGenomeCounter) --- 156,160 ---- #region OneHourAfterMarketCloseEventHandler ! protected override void setTickers(DateTime currentDate, bool setGenomeCounter) |
|
From: Marco M. <mi...@us...> - 2007-08-29 09:48:02
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/BiasedPVO In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv12371/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/BiasedPVO Modified Files: EndOfDayTimerHandlerBiasedPVO.cs Log Message: Changed inherited class: now this class derives from EndOfDayTimerHandlerBiasedPVONoThresholds (in place of EndOfDayTimerHandlerPVO) Code has been re-organized in a more logical and Object Oriented way: - WeightedPositions class has been used. - Some static methods have been deleted from SignedTicker class. They have been moved to WeightedPositions. - Basic orders'management has been moved to the primitive base class EndOfDayTimerHandler and to AccountManager class Index: EndOfDayTimerHandlerBiasedPVO.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/BiasedPVO/EndOfDayTimerHandlerBiasedPVO.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** EndOfDayTimerHandlerBiasedPVO.cs 9 Apr 2007 18:14:09 -0000 1.2 --- EndOfDayTimerHandlerBiasedPVO.cs 29 Aug 2007 09:47:54 -0000 1.3 *************** *** 39,42 **** --- 39,43 ---- using QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator; using QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator.WeightedPVO.WeightedBalancedPVO; + using QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator.BiasedPVO.BiasedPVONoThresholds; namespace QuantProject.Scripts.TechnicalAnalysisTesting.Oscillators.FixedLevelOscillators.PortfolioValueOscillator.BiasedPVO *************** *** 48,66 **** /// </summary> [Serializable] ! public class EndOfDayTimerHandlerBiasedPVO : EndOfDayTimerHandlerPVO { - protected int numOfDifferentGenomesToEvaluateOutOfSample; - protected double minimumAcceptableGain; - protected int currentGenomeIndex = 0; - protected double currentTickersGainOrLoss = 0.0; - protected Hashtable genomesCollector; - protected bool takeProfitConditionReached; - protected string[,] bestGenomesChosenTickers; - protected double[,] bestGenomesChosenTickersPortfolioWeights; - - new protected double[] currentOversoldThreshold; new protected double[] currentOverboughtThreshold; ! ! public EndOfDayTimerHandlerBiasedPVO(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, --- 49,57 ---- /// </summary> [Serializable] ! public class EndOfDayTimerHandlerBiasedPVO : EndOfDayTimerHandlerBiasedPVONoThresholds { new protected double[] currentOverboughtThreshold; ! new protected double[] currentOversoldThreshold; ! public EndOfDayTimerHandlerBiasedPVO(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, *************** *** 81,109 **** PortfolioType portfolioType, double maxAcceptableCloseToCloseDrawdown, double minimumAcceptableGain): ! base(tickerGroupID, numberOfEligibleTickers, ! numberOfTickersToBeChosen, numDaysForOptimizationPeriod, ! account, ! generationNumberForGeneticOptimizer, ! populationSizeForGeneticOptimizer, ! benchmark, ! numDaysForOscillatingPeriod, ! minLevelForOversoldThreshold, ! maxLevelForOversoldThreshold, ! minLevelForOverboughtThreshold, ! maxLevelForOverboughtThreshold, ! divisorForThresholdComputation, ! symmetricalThresholds, ! overboughtMoreThanOversoldForFixedPortfolio, ! numDaysBetweenEachOptimization, ! portfolioType, maxAcceptableCloseToCloseDrawdown) { ! ! this.numOfDifferentGenomesToEvaluateOutOfSample = numOfDifferentGenomesToEvaluateOutOfSample; ! this.minimumAcceptableGain = minimumAcceptableGain; ! this.bestGenomesChosenTickers = new string[numOfDifferentGenomesToEvaluateOutOfSample, numberOfTickersToBeChosen]; ! this.bestGenomesChosenTickersPortfolioWeights = new double[numOfDifferentGenomesToEvaluateOutOfSample, numberOfTickersToBeChosen]; ! this.currentOversoldThreshold = new double[numOfDifferentGenomesToEvaluateOutOfSample]; ! this.currentOverboughtThreshold = new double[numOfDifferentGenomesToEvaluateOutOfSample]; ! this.genomesCollector = new Hashtable(); } --- 72,94 ---- PortfolioType portfolioType, double maxAcceptableCloseToCloseDrawdown, double minimumAcceptableGain): ! base(tickerGroupID, numberOfEligibleTickers, ! numberOfTickersToBeChosen, numDaysForOptimizationPeriod, ! account, generationNumberForGeneticOptimizer, ! populationSizeForGeneticOptimizer, benchmark, ! numOfDifferentGenomesToEvaluateOutOfSample, ! numDaysBetweenEachOptimization, ! portfolioType, maxAcceptableCloseToCloseDrawdown, ! minimumAcceptableGain) { ! this.currentOverboughtThreshold = new double[numOfDifferentGenomesToEvaluateOutOfSample]; ! this.currentOversoldThreshold = new double[numOfDifferentGenomesToEvaluateOutOfSample]; ! this.numDaysForOscillatingPeriod = numDaysForOscillatingPeriod; ! this.minLevelForOversoldThreshold = minLevelForOversoldThreshold; ! this.maxLevelForOversoldThreshold = maxLevelForOversoldThreshold; ! this.minLevelForOverboughtThreshold = minLevelForOverboughtThreshold; ! this.maxLevelForOverboughtThreshold = maxLevelForOverboughtThreshold; ! this.divisorForThresholdComputation = divisorForThresholdComputation; ! this.symmetricalThresholds =symmetricalThresholds; ! this.overboughtMoreThanOversoldForFixedPortfolio = overboughtMoreThanOversoldForFixedPortfolio; } *************** *** 111,207 **** #region MarketCloseEventHandler ! protected virtual double getCurrentChosenTickersGainOrLoss(IndexBasedEndOfDayTimer timer, ! int indexForChosenTickers) ! { ! double returnValue = 999.0; ! try ! { ! DateTime initialDate = ! (DateTime)timer.IndexQuotes.Rows[timer.CurrentDateArrayPosition - this.numDaysForOscillatingPeriod + 2]["quDate"]; ! //so to replicate exactly in sample scheme, where only numOscillatingDay - 1 returns ! //are computed ! DateTime finalDate = ! (DateTime)timer.IndexQuotes.Rows[timer.CurrentDateArrayPosition]["quDate"]; ! string[] tickers = new string[this.numberOfTickersToBeChosen]; ! double[] tickerWeights = new double[this.numberOfTickersToBeChosen]; ! for(int i = 0; i < this.numberOfTickersToBeChosen; i++) ! { ! tickers[i] = this.bestGenomesChosenTickers[indexForChosenTickers,i]; ! tickerWeights[i] = this.bestGenomesChosenTickersPortfolioWeights[indexForChosenTickers,i]; ! } ! returnValue = ! SignedTicker.GetCloseToClosePortfolioReturn( ! tickers, tickerWeights, ! initialDate,finalDate) + 1.0; ! } ! catch(MissingQuotesException ex) ! { ! ex = ex; ! } ! return returnValue; ! } ! ! private void marketCloseEventHandler_reverseOrClose(IndexBasedEndOfDayTimer timer) ! { ! double currentChosenTickersGainOrLoss = ! this.getCurrentChosenTickersGainOrLoss(timer, this.currentGenomeIndex); ! this.marketCloseEventHandler_updateStopLossAndTakeProfitConditions(); ! if(currentChosenTickersGainOrLoss != 999.0) ! //currentChosenTickersValue has been properly computed ! { ! if(currentChosenTickersGainOrLoss >= 1.0 + currentOverboughtThreshold[this.currentGenomeIndex] && ! this.portfolioHasBeenOversold) ! //open positions derive from an overSold period but now ! //the overbought threshold has been reached ! { ! this.reversePositions(); ! this.portfolioHasBeenOversold = false; ! this.portfolioHasBeenOverbought = true; ! } ! else if(currentChosenTickersGainOrLoss <= 1.0 - currentOversoldThreshold[this.currentGenomeIndex] && ! this.portfolioHasBeenOverbought) ! //open positions derive from an overBought period but now ! //the overSold threshold has been reached ! { ! this.reversePositions(); ! this.portfolioHasBeenOversold = true; ! this.portfolioHasBeenOverbought = false; ! } ! else if(this.stopLossConditionReached || ! this.takeProfitConditionReached || ! this.numDaysElapsedSinceLastOptimization + 1 == this.numDaysBetweenEachOptimization ) ! //reversal conditions have not been reached but ! //stop loss or take profit conditions yes ! //or after the close it is necessary to run ! //another optimization ! { ! base.closePositions(); ! this.orders.Clear(); ! this.portfolioHasBeenOverbought = false; ! this.portfolioHasBeenOversold = false; ! } ! } ! } ! ! private void marketCloseEventHandler_closeIfItIsTimeToClose() ! { ! this.marketCloseEventHandler_updateStopLossAndTakeProfitConditions(); ! if(this.stopLossConditionReached || ! this.takeProfitConditionReached || ! this.numDaysElapsedSinceLastOptimization + 1 == this.numDaysBetweenEachOptimization ) ! //stop loss or take profit conditions yes ! //or after the next close it is necessary to run ! //another optimization ! { ! base.closePositions(); ! this.orders.Clear(); ! this.portfolioHasBeenOverbought = false; ! this.portfolioHasBeenOversold = false; ! } ! } ! //sets currentGenomeIndex with the genome's index that crosses an overbought/oversold threshold with the //highest degree and sets currentTickersGainOrLoss accordingly ! private void marketCloseEventHandler_openPositions_chooseBestGenome(IndexBasedEndOfDayTimer timer) { //default index is the first --- 96,103 ---- #region MarketCloseEventHandler ! //sets currentGenomeIndex with the genome's index that crosses an overbought/oversold threshold with the //highest degree and sets currentTickersGainOrLoss accordingly ! protected override void openPositions_chooseBestGenome(IndexBasedEndOfDayTimer timer) { //default index is the first *************** *** 212,232 **** for(int i = 0; i < this.numOfDifferentGenomesToEvaluateOutOfSample; i++) { ! double currentChosenTickersGainOrLoss = ! this.getCurrentChosenTickersGainOrLoss(timer, i); ! if(currentChosenTickersGainOrLoss != 999.0) //currentChosenTickersValue has been properly computed { //computing degree of crossing threshold ! if(currentChosenTickersGainOrLoss >= 1.0 + this.currentOverboughtThreshold[i]) { currentDegreeOfCrossingThreshold = ! (currentChosenTickersGainOrLoss - 1.0 - this.currentOverboughtThreshold[i])/ (1 + this.currentOverboughtThreshold[i]); } ! else if (currentChosenTickersGainOrLoss <= 1.0 - this.currentOversoldThreshold[i]) { currentDegreeOfCrossingThreshold = ! (1.0 - this.currentOversoldThreshold[i] - currentChosenTickersGainOrLoss)/ (1.0 - this.currentOversoldThreshold[i]); } --- 108,128 ---- for(int i = 0; i < this.numOfDifferentGenomesToEvaluateOutOfSample; i++) { ! double currentChosenWeightedPositionsGainOrLoss = ! this.getCurrentWeightedPositionsGainOrLoss(timer, i); ! if(currentChosenWeightedPositionsGainOrLoss != 999.0) //currentChosenTickersValue has been properly computed { //computing degree of crossing threshold ! if(currentChosenWeightedPositionsGainOrLoss >= 1.0 + this.currentOverboughtThreshold[i]) { currentDegreeOfCrossingThreshold = ! (currentChosenWeightedPositionsGainOrLoss - 1.0 - this.currentOverboughtThreshold[i])/ (1 + this.currentOverboughtThreshold[i]); } ! else if (currentChosenWeightedPositionsGainOrLoss <= 1.0 - this.currentOversoldThreshold[i]) { currentDegreeOfCrossingThreshold = ! (1.0 - this.currentOversoldThreshold[i] - currentChosenWeightedPositionsGainOrLoss)/ (1.0 - this.currentOversoldThreshold[i]); } *************** *** 235,270 **** currentMaxDegreeOfCrossingThreshold = currentDegreeOfCrossingThreshold; this.currentGenomeIndex = i; ! this.currentTickersGainOrLoss = currentChosenTickersGainOrLoss; } } } ! } ! ! private void marketCloseEventHandler_openPositions(IndexBasedEndOfDayTimer timer) { ! this.currentTickersGainOrLoss = 999.0; // ! this.marketCloseEventHandler_openPositions_chooseBestGenome(timer); ! if(this.currentTickersGainOrLoss != 999.0) ! //currentChosenTickersValue has been properly computed { ! string[] tickers = new string[this.numberOfTickersToBeChosen]; ! double[] tickersWeights = new double[this.numberOfTickersToBeChosen]; ! for(int i = 0; i < this.numberOfTickersToBeChosen; i++) ! { ! tickers[i] = this.bestGenomesChosenTickers[this.currentGenomeIndex,i]; ! tickersWeights[i] = this.bestGenomesChosenTickersPortfolioWeights[this.currentGenomeIndex,i]; ! } ! if(this.currentTickersGainOrLoss >= 1.0 + currentOverboughtThreshold[this.currentGenomeIndex] && this.portfolioType == PortfolioType.ShortAndLong) { ! SignedTicker.ChangeSignOfEachTicker(tickers); ! base.openPositions(tickers, tickersWeights); ! this.portfolioHasBeenOverbought = true; ! this.portfolioHasBeenOversold = false; } ! else if (this.currentTickersGainOrLoss <= 1.0 - currentOversoldThreshold[this.currentGenomeIndex]) { ! base.openPositions(tickers, tickersWeights); this.portfolioHasBeenOverbought = false; this.portfolioHasBeenOversold = true; --- 131,168 ---- currentMaxDegreeOfCrossingThreshold = currentDegreeOfCrossingThreshold; this.currentGenomeIndex = i; ! this.currentWeightedPositionsGainOrLoss = currentChosenWeightedPositionsGainOrLoss; } } } ! } ! protected override void openPositions(IndexBasedEndOfDayTimer timer) { ! this.currentWeightedPositionsGainOrLoss = 999.0; // ! this.openPositions_chooseBestGenome(timer); ! if(this.currentWeightedPositionsGainOrLoss != 999.0) ! //currentWeightedPositionsGainOrLoss has been properly computed { ! if(this.currentWeightedPositionsGainOrLoss >= 1.0 + currentOverboughtThreshold[this.currentGenomeIndex] && this.portfolioType == PortfolioType.ShortAndLong) { ! this.weightedPositionsToEvaluateOutOfSample[this.currentGenomeIndex].Reverse(); ! try{ ! AccountManager.OpenPositions(this.weightedPositionsToEvaluateOutOfSample[this.currentGenomeIndex], ! this.account); ! this.portfolioHasBeenOverbought = true; ! this.portfolioHasBeenOversold = false; ! } ! catch(Exception ex){ ! ex=ex; ! } ! finally{ ! this.weightedPositionsToEvaluateOutOfSample[this.currentGenomeIndex].Reverse(); ! } } ! else if (this.currentWeightedPositionsGainOrLoss <= 1.0 - currentOversoldThreshold[this.currentGenomeIndex]) { ! AccountManager.OpenPositions(this.weightedPositionsToEvaluateOutOfSample[this.currentGenomeIndex], ! this.account); this.portfolioHasBeenOverbought = false; this.portfolioHasBeenOversold = true; *************** *** 273,312 **** } } ! ! private void marketCloseEventHandler_updateStopLossAndTakeProfitConditions() ! { ! this.previousAccountValue = this.currentAccountValue; ! this.currentAccountValue = this.account.GetMarketValue(); ! double portfolioGainOrLoss = (this.currentAccountValue - this.previousAccountValue) ! /this.previousAccountValue; ! ! if( portfolioGainOrLoss < -this.maxAcceptableCloseToCloseDrawdown ) ! { ! this.stopLossConditionReached = true; ! this.takeProfitConditionReached = false; ! } ! else if (portfolioGainOrLoss >= this.minimumAcceptableGain) ! ! { ! this.stopLossConditionReached = false; ! this.takeProfitConditionReached = true; ! } ! else ! { ! this.stopLossConditionReached = false; ! this.takeProfitConditionReached = false; ! } ! } ! public override void MarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { if(this.account.Portfolio.Count > 0) - //this.marketCloseEventHandler_reverseOrClose((IndexBasedEndOfDayTimer)sender); this.marketCloseEventHandler_closeIfItIsTimeToClose(); else if ( this.account.Portfolio.Count == 0 && ! this.bestGenomesChosenTickers[0,0] != null ) //portfolio is empty and optimization has been already launched ! this.marketCloseEventHandler_openPositions((IndexBasedEndOfDayTimer)sender); } --- 171,184 ---- } } ! public override void MarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { if(this.account.Portfolio.Count > 0) this.marketCloseEventHandler_closeIfItIsTimeToClose(); else if ( this.account.Portfolio.Count == 0 && ! this.weightedPositionsToEvaluateOutOfSample != null ) //portfolio is empty and optimization has been already launched ! this.openPositions((IndexBasedEndOfDayTimer)sender); } *************** *** 334,349 **** // fitness has been added to the hashtable yet { ! for(int i = 0; i<this.numberOfTickersToBeChosen; i++) ! { ! this.bestGenomesChosenTickers[addedGenomes,i] = ! ((GenomeMeaningPVO)currentGenome.Meaning).Tickers[i]; ! this.bestGenomesChosenTickersPortfolioWeights[addedGenomes,i] = ! ((GenomeMeaningPVO)currentGenome.Meaning).TickersPortfolioWeights[i]; ! } this.currentOversoldThreshold[addedGenomes] = ((GenomeMeaningPVO)currentGenome.Meaning).OversoldThreshold; this.currentOverboughtThreshold[addedGenomes] = ((GenomeMeaningPVO)currentGenome.Meaning).OverboughtThreshold; - this.genomesCollector.Add( ( (GenomeMeaning)currentGenome.Meaning ).HashCodeForTickerComposition, null); --- 206,216 ---- // fitness has been added to the hashtable yet { ! this.weightedPositionsToEvaluateOutOfSample[addedGenomes] = new WeightedPositions( ! ((GenomeMeaningPVO)currentGenome.Meaning).TickersPortfolioWeights, ! new SignedTickers( ((GenomeMeaningPVO)currentGenome.Meaning).Tickers ) ); this.currentOversoldThreshold[addedGenomes] = ((GenomeMeaningPVO)currentGenome.Meaning).OversoldThreshold; this.currentOverboughtThreshold[addedGenomes] = ((GenomeMeaningPVO)currentGenome.Meaning).OverboughtThreshold; this.genomesCollector.Add( ( (GenomeMeaning)currentGenome.Meaning ).HashCodeForTickerComposition, null); |
|
From: Marco M. <mi...@us...> - 2007-08-29 09:47:16
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv12296/b7_Scripts/TickerSelectionTesting Modified Files: EndOfDayTimerHandler.cs Log Message: Code has been re-organized in a more logical and Object Oriented way: - WeightedPositions class has been used. - Some static methods have been deleted from SignedTicker class. They have been moved to WeightedPositions. - Basic orders'management has been moved to the primitive base class EndOfDayTimerHandler and to AccountManager class Index: EndOfDayTimerHandler.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandler.cs,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** EndOfDayTimerHandler.cs 9 Apr 2007 18:15:40 -0000 1.24 --- EndOfDayTimerHandler.cs 29 Aug 2007 09:47:09 -0000 1.25 *************** *** 24,35 **** 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.Data.DataTables; using QuantProject.ADT.Optimizing.Genetic; using QuantProject.ADT.Optimizing.BruteForce; --- 24,30 ---- using System.Collections; using QuantProject.Business.Financial.Accounting; ! using QuantProject.Business.Strategies; ! using QuantProject.Business.Timing; using QuantProject.ADT.Optimizing.Genetic; using QuantProject.ADT.Optimizing.BruteForce; *************** *** 38,42 **** namespace QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios { - /// <summary> /// Base class for EndOfDayTimerHandlers for efficient portfolios --- 33,36 ---- *************** *** 46,64 **** { protected DataTable eligibleTickers; ! protected string[] chosenTickers; ! protected string[] reversedTickersForOpenedPositions; ! protected double[] chosenTickersPortfolioWeights; ! protected string[] lastOrderedTickers; ! protected string tickerGroupID; protected int numberOfEligibleTickers; protected int numberOfTickersToBeChosen; protected int numDaysForOptimizationPeriod; protected int generationNumberForGeneticOptimizer; protected int populationSizeForGeneticOptimizer; - protected Account account = null; - protected ArrayList orders; - protected string benchmark; //these two values have to be updated during --- 40,53 ---- { protected DataTable eligibleTickers; ! protected WeightedPositions chosenWeightedPositions = null; protected string tickerGroupID; protected int numberOfEligibleTickers; protected int numberOfTickersToBeChosen; protected int numDaysForOptimizationPeriod; + protected int numDaysBetweenEachOptimization = 0; + protected int numDaysElapsedSinceLastOptimization = 0; protected int generationNumberForGeneticOptimizer; protected int populationSizeForGeneticOptimizer; protected Account account = null; protected string benchmark; //these two values have to be updated during *************** *** 67,85 **** protected double minPriceForMinimumCommission = 30; protected double maxPriceForMinimumCommission = 500; - protected double targetReturn; - protected PortfolioType portfolioType; ! protected GenomeCounter genomeCounter; public GenomeCounter GenomeCounter { get{return this.genomeCounter;} } ! ! public string[] LastOrderedTickers ! { ! get { return this.lastOrderedTickers; } ! } public int NumberOfEligibleTickers { --- 56,73 ---- protected double minPriceForMinimumCommission = 30; protected double maxPriceForMinimumCommission = 500; protected double targetReturn; protected PortfolioType portfolioType; ! protected bool stopLossConditionReached = false; ! protected bool takeProfitConditionReached = false; ! protected double currentAccountValue = 0.0; ! protected double previousAccountValue = 0.0; ! ! protected GenomeCounter genomeCounter; public GenomeCounter GenomeCounter { get{return this.genomeCounter;} } ! public int NumberOfEligibleTickers { *************** *** 101,105 **** get { return this.bestGenomes; } } - private void endOfDayTimerHandler_initializeBasic(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, --- 89,92 ---- *************** *** 116,128 **** this.populationSizeForGeneticOptimizer = populationSizeForGeneticOptimizer; this.benchmark = benchmark; - this.orders = new ArrayList(); - this.chosenTickers = new string[numberOfTickersToBeChosen]; - this.lastOrderedTickers = new string[numberOfTickersToBeChosen]; this.targetReturn = targetReturn; this.portfolioType = portfolioType; - this.setDefaultChosenTickersPortfolioWeights(); - } - public EndOfDayTimerHandler(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, Account account, --- 103,109 ---- *************** *** 155,363 **** portfolioType); } ! ! ! ! public EndOfDayTimerHandler(string[] chosenTickers, PortfolioType portfolioType, Account account, string benchmark) { - this.account = account; this.benchmark = benchmark; ! this.orders = new ArrayList(); ! this.chosenTickers = chosenTickers; ! this.numberOfTickersToBeChosen = chosenTickers.Length; ! this.lastOrderedTickers = new string[chosenTickers.Length]; this.portfolioType = portfolioType; - this.setDefaultChosenTickersPortfolioWeights(); } ! ! private void setDefaultChosenTickersPortfolioWeights() ! { ! this.chosenTickersPortfolioWeights = new double[this.chosenTickers.Length]; ! for(int i = 0;i<this.chosenTickers.Length;i++) ! this.chosenTickersPortfolioWeights[i]=1.0/this.chosenTickers.Length; ! } ! ! protected virtual void addOrderForTicker(string[] tickers, ! int tickerPosition ) ! { ! string tickerCode = ! GenomeManagerForEfficientPortfolio.GetCleanTickerCode(tickers[tickerPosition]); ! double cashForSinglePosition = ! this.account.CashAmount * this.chosenTickersPortfolioWeights[tickerPosition]; ! long quantity = ! Convert.ToInt64( Math.Floor( cashForSinglePosition / this.account.DataStreamer.GetCurrentBid( tickerCode ) ) ); ! Order order; ! if(this.portfolioType == PortfolioType.OnlyShort || ! (this.portfolioType == PortfolioType.ShortAndLong && ! tickers[tickerPosition] != tickerCode)) ! order = new Order( OrderType.MarketSellShort, new Instrument( tickerCode ) , quantity ); ! else ! order = new Order( OrderType.MarketBuy, new Instrument( tickerCode ) , quantity ); ! this.orders.Add(order); ! } ! ! protected virtual void closePosition( ! string ticker ) ! { ! this.account.ClosePosition( ticker ); ! } ! ! protected virtual void closePositions() ! { ! if(this.lastOrderedTickers != null) ! { ! foreach( string ticker in this.lastOrderedTickers) ! { ! for(int i = 0; i<this.account.Portfolio.Keys.Count; i++) ! { ! if(this.account.Portfolio[ticker]!=null) ! closePosition( ticker ); ! } ! } ! } ! } ! ! protected virtual void addChosenTickersToOrderList(string[] tickers) ! { ! for( int i = 0; i<tickers.Length; i++) ! { ! if(tickers[i] != null) ! { ! this.addOrderForTicker( tickers, i ); ! this.lastOrderedTickers[i] = ! GenomeManagerForEfficientPortfolio.GetCleanTickerCode(tickers[i]); ! } ! } ! } ! ! protected bool openPositions_allTickersToOpenQuotedAtCurrentDate(string[] tickers) ! { ! bool returnValue = true; ! DateTime currentDate = this.Account.EndOfDayTimer.GetCurrentTime().DateTime; ! foreach(string ticker in tickers) ! { ! if(ticker != null) ! { ! Quotes tickerQuotes = new Quotes(GenomeManagerForEfficientPortfolio.GetCleanTickerCode(ticker), ! currentDate, currentDate); ! if(tickerQuotes.Rows.Count == 0) ! //no quote available for the current ticker ! returnValue = false; ! } ! } ! return returnValue; ! } ! ! protected virtual void openPositions(string[] tickers, double[] tickersWeights) ! { ! this.chosenTickersPortfolioWeights = tickersWeights; ! this.openPositions(tickers); ! } ! ! protected virtual void openPositions(string[] tickers) { //add cash first ! if(this.orders.Count == 0 && this.account.Transactions.Count == 0) ! this.account.AddCash(30000); ! if(this.openPositions_allTickersToOpenQuotedAtCurrentDate(tickers)) ! //all tickers have quotes at the current date, so orders can be filled ! { ! this.addChosenTickersToOrderList(tickers); ! //execute orders actually ! foreach(object item in this.orders) ! this.account.AddOrder((Order)item); ! } ! } ! ! protected void addGenomeToBestGenomes(Genome genome, ! DateTime firstOptimizationDate, ! DateTime secondOptimizationDate, ! int eligibleTickers) ! { ! if(this.bestGenomes == null) ! this.bestGenomes = new ArrayList(); ! ! this.bestGenomes.Add(new GenomeRepresentation(genome, ! firstOptimizationDate, ! secondOptimizationDate, ! genome.Generation, ! eligibleTickers) ); ! } ! ! protected void addGenomeToBestGenomes(BruteForceOptimizableParameters BFOptimizableParameters, ! string[] signedTickers, ! DateTime firstOptimizationDate, ! DateTime secondOptimizationDate, ! int eligibleTickers) ! { ! if(this.bestGenomes == null) ! this.bestGenomes = new ArrayList(); ! ! this.bestGenomes.Add(new GenomeRepresentation(BFOptimizableParameters, ! signedTickers, ! firstOptimizationDate, ! secondOptimizationDate, ! eligibleTickers) ); ! } ! ! protected void addGenomeToBestGenomes(Genome genome, ! DateTime firstOptimizationDate, ! DateTime secondOptimizationDate, ! int eligibleTickers, int halfPeriodDays) ! { ! if(this.bestGenomes == null) ! this.bestGenomes = new ArrayList(); ! ! this.bestGenomes.Add(new GenomeRepresentation(genome, ! firstOptimizationDate, ! secondOptimizationDate, ! genome.Generation, ! eligibleTickers, ! halfPeriodDays)); ! } ! ! protected void addGenomeToBestGenomes(Genome genome, ! DateTime firstOptimizationDate, ! DateTime secondOptimizationDate, ! int eligibleTickers, int halfPeriodDays, ! PortfolioType portfolioType) ! { ! if(this.bestGenomes == null) ! this.bestGenomes = new ArrayList(); ! ! this.bestGenomes.Add(new GenomeRepresentation(genome, ! firstOptimizationDate, ! secondOptimizationDate, ! genome.Generation, ! eligibleTickers, ! halfPeriodDays, portfolioType)); ! } ! ! protected void addGenomeToBestGenomes(Genome genome, ! DateTime firstOptimizationDate, ! DateTime secondOptimizationDate, ! int eligibleTickers, int halfPeriodDays, ! PortfolioType portfolioType, ! int createdGenerations) ! { ! if(this.bestGenomes == null) ! this.bestGenomes = new ArrayList(); ! ! this.bestGenomes.Add(new GenomeRepresentation(genome, ! firstOptimizationDate, ! secondOptimizationDate, ! genome.Generation, ! eligibleTickers, ! halfPeriodDays, portfolioType, createdGenerations)); } ! public virtual void MarketOpenEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) --- 136,250 ---- portfolioType); } ! public EndOfDayTimerHandler(WeightedPositions chosenWeightedPositions, PortfolioType portfolioType, Account account, string benchmark) { this.account = account; this.benchmark = benchmark; ! this.chosenWeightedPositions = chosenWeightedPositions; ! this.numberOfTickersToBeChosen = this.chosenWeightedPositions.Count; this.portfolioType = portfolioType; } ! ! #region addGenomeToBestGenomes ! ! protected void addGenomeToBestGenomes(Genome genome, ! DateTime firstOptimizationDate, ! DateTime secondOptimizationDate, ! int eligibleTickers) ! { ! if(this.bestGenomes == null) ! this.bestGenomes = new ArrayList(); ! this.bestGenomes.Add(new GenomeRepresentation(genome, ! firstOptimizationDate, ! secondOptimizationDate, ! genome.Generation, ! eligibleTickers) ); ! } ! protected void addGenomeToBestGenomes(BruteForceOptimizableParameters BFOptimizableParameters, ! SignedTickers signedTickers, ! DateTime firstOptimizationDate, ! DateTime secondOptimizationDate, ! int eligibleTickers) ! { ! if(this.bestGenomes == null) ! this.bestGenomes = new ArrayList(); ! this.bestGenomes.Add(new GenomeRepresentation(BFOptimizableParameters, ! signedTickers.ArrayForSignedTickers, ! firstOptimizationDate, ! secondOptimizationDate, ! eligibleTickers) ); ! } ! protected void addGenomeToBestGenomes(Genome genome, ! DateTime firstOptimizationDate, ! DateTime secondOptimizationDate, ! int eligibleTickers, int halfPeriodDays) ! { ! if(this.bestGenomes == null) ! this.bestGenomes = new ArrayList(); + this.bestGenomes.Add(new GenomeRepresentation(genome, + firstOptimizationDate, + secondOptimizationDate, + genome.Generation, + eligibleTickers, + halfPeriodDays)); + } + protected void addGenomeToBestGenomes(Genome genome, + DateTime firstOptimizationDate, + DateTime secondOptimizationDate, + int eligibleTickers, int halfPeriodDays, + PortfolioType portfolioType) + { + if(this.bestGenomes == null) + this.bestGenomes = new ArrayList(); ! this.bestGenomes.Add(new GenomeRepresentation(genome, ! firstOptimizationDate, ! secondOptimizationDate, ! genome.Generation, ! eligibleTickers, ! halfPeriodDays, portfolioType)); ! } ! protected void addGenomeToBestGenomes(Genome genome, ! DateTime firstOptimizationDate, ! DateTime secondOptimizationDate, ! int eligibleTickers, int halfPeriodDays, ! PortfolioType portfolioType, ! int createdGenerations) ! { ! if(this.bestGenomes == null) ! this.bestGenomes = new ArrayList(); ! this.bestGenomes.Add(new GenomeRepresentation(genome, ! firstOptimizationDate, ! secondOptimizationDate, ! genome.Generation, ! eligibleTickers, ! halfPeriodDays, portfolioType, createdGenerations)); ! } ! #endregion ! ! protected virtual void openPositions() { //add cash first ! if(this.account.Transactions.Count == 0) ! this.account.AddCash(15000); ! AccountManager.OpenPositions(this.chosenWeightedPositions, this.account); } ! ! protected void reversePositions() ! { ! if ( this.portfolioType == PortfolioType.OnlyLong || ! this.portfolioType == PortfolioType.OnlyShort ) ! throw new Exception ("It's not possible to reverse positions " + ! "when portfolio has to contain only " + ! "long or short positions!"); ! AccountManager.ReversePositions(this.account); ! } ! public virtual void MarketOpenEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) *************** *** 375,441 **** ; } ! ! #region reversePositions ! private void reversePositions_addReversedTickersToOrderList_addOrderForTicker(int tickerPosition ) ! { ! string tickerCode = ! GenomeManagerForEfficientPortfolio.GetCleanTickerCode(this.reversedTickersForOpenedPositions[tickerPosition]); ! double cashForSinglePosition = ! this.account.CashAmount * this.chosenTickersPortfolioWeights[tickerPosition]; ! long quantity = ! Convert.ToInt64( Math.Floor( cashForSinglePosition / this.account.DataStreamer.GetCurrentBid( tickerCode ) ) ); ! Order order; ! if(this.portfolioType == PortfolioType.OnlyShort || ! (this.portfolioType == PortfolioType.ShortAndLong && ! this.reversedTickersForOpenedPositions[tickerPosition] != tickerCode)) ! order = new Order( OrderType.MarketSellShort, new Instrument( tickerCode ) , quantity ); ! else ! order = new Order( OrderType.MarketBuy, new Instrument( tickerCode ) , quantity ); ! ! this.orders.Add(order); ! } ! ! private void reversePositions_addReversedTickersToOrderList() ! { ! for( int i = 0; i<this.reversedTickersForOpenedPositions.Length; i++) ! { ! if(this.reversedTickersForOpenedPositions[i] != null) ! { ! this.reversePositions_addReversedTickersToOrderList_addOrderForTicker( i ); ! this.lastOrderedTickers[i] = ! GenomeManagerForEfficientPortfolio.GetCleanTickerCode(this.reversedTickersForOpenedPositions[i]); ! } ! } ! } ! ! ! private void reversePositions_setReversedTickers() ! { ! string sign = ""; ! string instrumentKey = ""; ! Position[] positions = new Position[this.chosenTickers.Length]; ! this.account.Portfolio.Positions.CopyTo(positions, 0); ! for(int i = 0; i<this.account.Portfolio.Count; i++) ! { ! instrumentKey = positions[i].Instrument.Key; ! if(positions[i].IsShort) ! sign = ""; ! else ! sign = "-"; ! this.reversedTickersForOpenedPositions[i] = sign + instrumentKey; ! } ! } ! ! protected void reversePositions() ! { ! this.reversedTickersForOpenedPositions = ! new string[this.chosenTickers.Length]; ! this.reversePositions_setReversedTickers(); ! this.closePositions(); ! this.orders.Clear(); ! this.openPositions(this.reversedTickersForOpenedPositions); ! } ! #endregion ! ! } // end of class } --- 262,265 ---- ; } ! } } |
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv10276/b7_Scripts/TickerSelectionTesting Modified Files: EndOfDayTimerHandlerCTC.cs EndOfDayTimerHandlerCTCWeekly.cs EndOfDayTimerHandlerCTO.cs EndOfDayTimerHandlerCTO_WorstAtDay.cs EndOfDayTimerHandlerLastChosenPortfolio.cs EndOfDayTimerHandlerOTC.cs EndOfDayTimerHandlerOTC_WorstAtNight.cs EndOfDayTimerHandlerOTCCTO.cs EndOfDayTimerHandlerOTCMultiAccount.cs EndOfDayTimerHandlerOTCMultiday.cs Log Message: Code has been re-organized in a more logical and Object Oriented way: - WeightedPositions class has been used. - Some static methods have been deleted from SignedTicker class. They have been moved to WeightedPositions. - Basic orders'management has been moved to the primitive base class EndOfDayTimerHandler and to AccountManager class Index: EndOfDayTimerHandlerLastChosenPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerLastChosenPortfolio.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** EndOfDayTimerHandlerLastChosenPortfolio.cs 17 Sep 2006 21:48:39 -0000 1.3 --- EndOfDayTimerHandlerLastChosenPortfolio.cs 29 Aug 2007 09:43:32 -0000 1.4 *************** *** 29,32 **** --- 29,33 ---- using QuantProject.Business.Financial.Ordering; using QuantProject.Business.Timing; + using QuantProject.Business.Strategies; using QuantProject.Data.DataProviders; using QuantProject.Data.Selectors; *************** *** 54,59 **** EndOfDayDateTime firstDate, EndOfDayDateTime lastDate): ! base(chosenTickers, portfolioType, account, ! benchmark) { this.firstDate = firstDate; --- 55,60 ---- EndOfDayDateTime firstDate, EndOfDayDateTime lastDate): ! base(new WeightedPositions( new SignedTickers(chosenTickers) ), ! portfolioType, account, benchmark) { this.firstDate = firstDate; *************** *** 71,75 **** if(endOfDayTimingEventArgs.EndOfDayDateTime.CompareTo(this.firstDate) == 0) { ! this.openPositions(this.chosenTickers); } } --- 72,76 ---- if(endOfDayTimingEventArgs.EndOfDayDateTime.CompareTo(this.firstDate) == 0) { ! this.openPositions(); } } *************** *** 82,86 **** // this.closePositions(); if(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime.CompareTo(this.lastDate.DateTime.AddDays(-1)) == 0) ! this.closePositions(); } --- 83,87 ---- // this.closePositions(); if(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime.CompareTo(this.lastDate.DateTime.AddDays(-1)) == 0) ! AccountManager.ClosePositions(this.account); } Index: EndOfDayTimerHandlerOTCCTO.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerOTCCTO.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** EndOfDayTimerHandlerOTCCTO.cs 17 Sep 2006 21:48:39 -0000 1.6 --- EndOfDayTimerHandlerOTCCTO.cs 29 Aug 2007 09:43:33 -0000 1.7 *************** *** 29,32 **** --- 29,33 ---- using QuantProject.Business.Financial.Ordering; using QuantProject.Business.Timing; + using QuantProject.Business.Strategies; using QuantProject.Data.DataProviders; using QuantProject.Data.Selectors; *************** *** 44,49 **** public class EndOfDayTimerHandlerOTCCTO : EndOfDayTimerHandler { - protected int numDaysBetweenEachOptimization; - private int numDaysElapsedSinceLastOptimization; protected int seedForRandomGenerator; --- 45,48 ---- *************** *** 77,98 **** //temporarily the if condition //if(this.numDaysElapsedSinceLastOptimization == 0) ! this.closePositions(); ! this.openPositions(this.chosenTickers); ! } ! private void reverseSignOfChosenTickers() ! { ! for(int i = 0; i<this.chosenTickers.Length; i++) ! { ! if(this.chosenTickers[i] != null) ! { ! if(this.chosenTickers[i].StartsWith("-")) ! this.chosenTickers[i] = ! GenomeManagerForEfficientPortfolio.GetCleanTickerCode(this.chosenTickers[i]); ! else ! this.chosenTickers[i] = "-" + this.chosenTickers[i]; ! } ! } } ! public override void MarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) --- 76,83 ---- //temporarily the if condition //if(this.numDaysElapsedSinceLastOptimization == 0) ! AccountManager.ClosePositions(this.account); ! this.openPositions(); } ! public override void MarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) *************** *** 102,110 **** //if(this.numDaysElapsedSinceLastOptimization == // this.numDaysBetweenEachOptimization) ! this.closePositions(); ! this.orders.Clear(); ! this.reverseSignOfChosenTickers(); ! this.openPositions(this.chosenTickers); ! this.reverseSignOfChosenTickers(); } --- 87,99 ---- //if(this.numDaysElapsedSinceLastOptimization == // this.numDaysBetweenEachOptimization) ! AccountManager.ClosePositions(this.account); ! try{ ! this.chosenWeightedPositions.Reverse(); ! this.openPositions(); ! } ! catch(Exception ex){ ! ex = ex; ! } ! this.chosenWeightedPositions.Reverse(); } *************** *** 145,149 **** DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); ! if(setOfTickersToBeOptimized.Rows.Count > this.chosenTickers.Length*2) //the optimization process is possible only if the initial set of tickers is //as large as the number of tickers to be chosen --- 134,138 ---- DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); ! if(setOfTickersToBeOptimized.Rows.Count > this.numberOfTickersToBeChosen*2) //the optimization process is possible only if the initial set of tickers is //as large as the number of tickers to be chosen *************** *** 168,173 **** this.addGenomeToBestGenomes(GO.BestGenome,currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, setOfTickersToBeOptimized.Rows.Count); ! this.chosenTickers = ((GenomeMeaning)GO.BestGenome.Meaning).Tickers; ! this.chosenTickersPortfolioWeights = ((GenomeMeaning)GO.BestGenome.Meaning).TickersPortfolioWeights; } //else it will be buyed again the previous optimized portfolio --- 157,162 ---- this.addGenomeToBestGenomes(GO.BestGenome,currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, setOfTickersToBeOptimized.Rows.Count); ! this.chosenWeightedPositions = new WeightedPositions( ((GenomeMeaning)GO.BestGenome.Meaning).TickersPortfolioWeights, ! new SignedTickers( ((GenomeMeaning)GO.BestGenome.Meaning).Tickers) ); } //else it will be buyed again the previous optimized portfolio *************** *** 193,197 **** { this.seedForRandomGenerator++; - this.orders.Clear(); //this.oneHourAfterMarketCloseEventHandler_updatePrices(); if(this.numDaysElapsedSinceLastOptimization == --- 182,185 ---- Index: EndOfDayTimerHandlerCTO_WorstAtDay.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerCTO_WorstAtDay.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** EndOfDayTimerHandlerCTO_WorstAtDay.cs 30 Jun 2007 18:52:44 -0000 1.1 --- EndOfDayTimerHandlerCTO_WorstAtDay.cs 29 Aug 2007 09:43:32 -0000 1.2 *************** *** 33,36 **** --- 33,37 ---- using QuantProject.Data.Selectors; using QuantProject.ADT.Optimizing.Genetic; + using QuantProject.Scripts.WalkForwardTesting.WalkForwardLag; namespace QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios *************** *** 47,52 **** public class EndOfDayTimerHandlerCTO_WorstAtDay : EndOfDayTimerHandler { - protected int numDaysBetweenEachOptimization; - private int numDaysElapsedSinceLastOptimization; protected int seedForRandomGenerator; protected GeneticOptimizer currentGO; --- 48,51 ---- *************** *** 82,86 **** Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! this.closePositions(); } --- 81,85 ---- Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! AccountManager.ClosePositions(this.account); } *************** *** 107,115 **** try{ //retrieves loss at day for the CurrentCombination ! lossOfCurrentCombination = ! - SignedTicker.GetOpenToClosePortfolioReturn( ! ((GenomeMeaning)((Genome)this.currentGO.CurrentGeneration[populationSize - i - 1]).Meaning).Tickers, ! ((GenomeMeaning)((Genome)this.currentGO.CurrentGeneration[populationSize - i - 1]).Meaning).TickersPortfolioWeights, ! today);//- because fitness in GenomeOTCCTO is just the reversal of what needed numOfGenomesScanned++; if(lossOfCurrentCombination < lossOfCurrentWorstCombination) --- 106,117 ---- try{ //retrieves loss at day for the CurrentCombination ! SignedTickers signedTickers = ! new SignedTickers( ((GenomeMeaning)((Genome)this.currentGO.CurrentGeneration[populationSize - i - 1]).Meaning).Tickers); ! WeightedPositions weightedPositions = ! new WeightedPositions( ((GenomeMeaning)((Genome)this.currentGO.CurrentGeneration[populationSize - i - 1]).Meaning).TickersPortfolioWeights, ! signedTickers); ! lossOfCurrentCombination = ! - weightedPositions.GetOpenToCloseReturn( today ); ! //- because fitness in GenomeOTCCTO is just the reversal of what needed numOfGenomesScanned++; if(lossOfCurrentCombination < lossOfCurrentWorstCombination) *************** *** 125,134 **** } } ! this.chosenTickers = ! ((GenomeMeaning)((Genome)this.currentGO.CurrentGeneration[indexOfWorstCombination]).Meaning).Tickers; ! SignedTicker.ChangeSignOfEachTicker(this.chosenTickers);//it is used a fitness that is ! //the reversal of qwhat needed ! this.chosenTickersPortfolioWeights = ! ((GenomeMeaning)((Genome)this.currentGO.CurrentGeneration[indexOfWorstCombination]).Meaning).TickersPortfolioWeights; } --- 127,133 ---- } } ! this.chosenWeightedPositions = new WeightedPositions( ((GenomeMeaning)((Genome)this.currentGO.CurrentGeneration[indexOfWorstCombination]).Meaning).TickersPortfolioWeights, ! new SignedTickers( ((GenomeMeaning)((Genome)this.currentGO.CurrentGeneration[indexOfWorstCombination]).Meaning).Tickers)); ! } *************** *** 137,149 **** Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! if(this.orders.Count == 0 && this.account.Transactions.Count == 0) ! this.account.AddCash(30000); ! ! if(this.currentGO != null) //so a list of genomes is available this.marketCloseEventHandler_chooseTheWorstOTCGenome(); ! this.openPositions(this.chosenTickers); ! } --- 136,144 ---- Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! if(this.currentGO != null) //so a list of genomes is available this.marketCloseEventHandler_chooseTheWorstOTCGenome(); ! this.openPositions(); } *************** *** 179,183 **** DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); ! if(setOfTickersToBeOptimized.Rows.Count > this.chosenTickers.Length*2) //the optimization process is possible only if the initial set of tickers is //as large as the number of tickers to be chosen --- 174,178 ---- DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); ! if(setOfTickersToBeOptimized.Rows.Count > this.numberOfTickersToBeChosen * 2) //the optimization process is possible only if the initial set of tickers is //as large as the number of tickers to be chosen *************** *** 203,209 **** this.addGenomeToBestGenomes(GO.BestGenome,currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, setOfTickersToBeOptimized.Rows.Count); ! this.chosenTickers = ((GenomeMeaning)GO.BestGenome.Meaning).Tickers; ! this.chosenTickersPortfolioWeights = ((GenomeMeaning)GO.BestGenome.Meaning).TickersPortfolioWeights; ! this.currentGO = GO; } //else it will be buyed again the previous optimized portfolio --- 198,204 ---- this.addGenomeToBestGenomes(GO.BestGenome,currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, setOfTickersToBeOptimized.Rows.Count); ! this.chosenWeightedPositions = new WeightedPositions( ((GenomeMeaning)GO.BestGenome.Meaning).TickersPortfolioWeights, ! new SignedTickers( ((GenomeMeaning)GO.BestGenome.Meaning).Tickers) ); ! this.currentGO = GO; } //else it will be buyed again the previous optimized portfolio *************** *** 229,233 **** { this.seedForRandomGenerator++; - this.orders.Clear(); //this.oneHourAfterMarketCloseEventHandler_updatePrices(); if(this.numDaysElapsedSinceLastOptimization == --- 224,227 ---- *************** *** 244,250 **** } - #endregion - } } --- 238,242 ---- Index: EndOfDayTimerHandlerOTCMultiday.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerOTCMultiday.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** EndOfDayTimerHandlerOTCMultiday.cs 17 Sep 2006 21:48:39 -0000 1.7 --- EndOfDayTimerHandlerOTCMultiday.cs 29 Aug 2007 09:43:33 -0000 1.8 *************** *** 29,32 **** --- 29,33 ---- using QuantProject.Business.Financial.Ordering; using QuantProject.Business.Timing; + using QuantProject.Business.Strategies; using QuantProject.Data.DataProviders; using QuantProject.Data.Selectors; *************** *** 44,49 **** public class EndOfDayTimerHandlerOTCMultiday : EndOfDayTimerHandler { - protected int numDaysBetweenEachOptimization; - private int numDaysElapsedSinceLastOptimization; protected int seedForRandomGenerator; --- 45,48 ---- *************** *** 65,70 **** this.seedForRandomGenerator = ConstantsProvider.SeedForRandomGenerator; } ! ! /// <summary> /// Handles a "Market Open" event. --- 64,68 ---- this.seedForRandomGenerator = ConstantsProvider.SeedForRandomGenerator; } ! /// <summary> /// Handles a "Market Open" event. *************** *** 77,157 **** if(this.numDaysElapsedSinceLastOptimization == 0) ! this.openPositions(this.chosenTickers); } ! ! public override void MarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! ! ! if(this.numDaysElapsedSinceLastOptimization == this.numDaysBetweenEachOptimization - 1) ! this.closePositions(); ! } ! ! ! ! #region OneHourAfterMarketCloseEventHandler protected DataTable getSetOfTickersToBeOptimized(DateTime currentDate) { ! /* ! SelectorByAverageRawOpenPrice selectorByOpenPrice = ! new SelectorByAverageRawOpenPrice(this.tickerGroupID, false, ! currentDate.AddDays(-this.numDaysForLiquidity), currentDate, ! this.numberOfEligibleTickers, this.minPriceForMinimumCommission, ! this.maxPriceForMinimumCommission, 0, 2); ! DataTable tickersByPrice = selectorByOpenPrice.GetTableOfSelectedTickers(); ! */ ! ! SelectorByGroup temporizedGroup = new SelectorByGroup(this.tickerGroupID, currentDate); ! SelectorByOpenCloseCorrelationToBenchmark lessCorrelatedFromTemporizedGroup = ! new SelectorByOpenCloseCorrelationToBenchmark(temporizedGroup.GetTableOfSelectedTickers(), ! this.benchmark,true, ! currentDate.AddDays(-this.numDaysForOptimizationPeriod ), ! currentDate, ! this.numberOfEligibleTickers); ! this.eligibleTickers = lessCorrelatedFromTemporizedGroup.GetTableOfSelectedTickers(); ! SelectorByQuotationAtEachMarketDay quotedAtEachMarketDayFromEligible = ! new SelectorByQuotationAtEachMarketDay( this.eligibleTickers, ! false, currentDate.AddDays(-this.numDaysForOptimizationPeriod), ! currentDate, this.numberOfEligibleTickers, this.benchmark); ! //SelectorByWinningOpenToClose winners = ! // new SelectorByWinningOpenToClose(quotedAtEachMarketDayFromMostLiquid.GetTableOfSelectedTickers(), ! // false, currentDate.AddDays(-2), ! // 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(); } ! ! // private string[] setTickers_getBestTickersLosingAtLastDay(IGenomeManager genomeManager) ! // { ! // string[] returnValue = ! // ((GenomeMeaning)genomeManager.CurrentGeneticOptimizer.BestGenome.Meaning).Tickers; ! // int numOfGenomes = genomeManager.CurrentGeneticOptimizer.CurrentGeneration.Count; ! // int i; ! // for(i = 0;i<numOfGenomes; i++) ! // { ! // if(((GenomeMeaning)((Genome)genomeManager.CurrentGeneticOptimizer.CurrentGeneration[numOfGenomes - i - 1]).Meaning).ReturnAtLastDayInSample < 0) ! // //the current portfolio has a negative return at the last day in sample ! // { ! // returnValue = ! // ((GenomeMeaning)((Genome)genomeManager.CurrentGeneticOptimizer.CurrentGeneration[numOfGenomes - i - 1]).Meaning).Tickers; ! // i = numOfGenomes; ! // } ! // } ! // ! // return returnValue; ! // } ! protected virtual void setTickers(DateTime currentDate, bool setGenomeCounter) --- 75,115 ---- if(this.numDaysElapsedSinceLastOptimization == 0) ! this.openPositions(); } ! public override void MarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! if(this.numDaysElapsedSinceLastOptimization == this.numDaysBetweenEachOptimization - 1) ! AccountManager.ClosePositions(this.account); } ! ! #region OneHourAfterMarketCloseEventHandler protected DataTable getSetOfTickersToBeOptimized(DateTime currentDate) { ! SelectorByGroup temporizedGroup = new SelectorByGroup(this.tickerGroupID, currentDate); ! DataTable tickersFromGroup = temporizedGroup.GetTableOfSelectedTickers(); ! SelectorByLiquidity mostLiquid = ! new SelectorByLiquidity(tickersFromGroup, ! false,currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, ! this.numberOfEligibleTickers); ! SelectorByQuotationAtEachMarketDay quotedAtEachMarketDayFromMostLiquid = ! new SelectorByQuotationAtEachMarketDay(mostLiquid.GetTableOfSelectedTickers(), ! false, currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, ! this.numberOfEligibleTickers, this.benchmark); ! ! SelectorByAverageRawOpenPrice byPrice = ! new SelectorByAverageRawOpenPrice(quotedAtEachMarketDayFromMostLiquid.GetTableOfSelectedTickers(), ! false,currentDate.AddDays(-30), ! currentDate, ! this.numberOfEligibleTickers, ! 28); ! ! return byPrice.GetTableOfSelectedTickers(); } ! protected virtual void setTickers(DateTime currentDate, bool setGenomeCounter) *************** *** 159,163 **** DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); ! if(setOfTickersToBeOptimized.Rows.Count > this.chosenTickers.Length*2) //the optimization process is possible only if the initial set of tickers is //as large as the number of tickers to be chosen --- 117,121 ---- DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); ! if(setOfTickersToBeOptimized.Rows.Count > this.numberOfTickersToBeChosen*2) //the optimization process is possible only if the initial set of tickers is //as large as the number of tickers to be chosen *************** *** 165,169 **** { IGenomeManager genManEfficientOTCPortfolio = ! new GenomeManagerForEfficientOTCPortfolio(setOfTickersToBeOptimized, currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, --- 123,127 ---- { IGenomeManager genManEfficientOTCPortfolio = ! new GenomeManagerForEfficientOTCCTOPortfolio(setOfTickersToBeOptimized, currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, *************** *** 182,189 **** this.addGenomeToBestGenomes(GO.BestGenome,currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, setOfTickersToBeOptimized.Rows.Count); ! this.chosenTickers = ((GenomeMeaning)GO.BestGenome.Meaning).Tickers; ! this.chosenTickersPortfolioWeights = ((GenomeMeaning)GO.BestGenome.Meaning).TickersPortfolioWeights; ! //this.chosenTickers = ! // this.setTickers_getBestTickersLosingAtLastDay(genManEfficientCTOPortfolio); } //else it will be buyed again the previous optimized portfolio --- 140,145 ---- this.addGenomeToBestGenomes(GO.BestGenome,currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, setOfTickersToBeOptimized.Rows.Count); ! this.chosenWeightedPositions = new WeightedPositions( ((GenomeMeaning)GO.BestGenome.Meaning).TickersPortfolioWeights, ! new SignedTickers( ((GenomeMeaning)GO.BestGenome.Meaning).Tickers) ); } //else it will be buyed again the previous optimized portfolio *************** *** 209,213 **** { this.seedForRandomGenerator++; - this.orders.Clear(); //this.oneHourAfterMarketCloseEventHandler_updatePrices(); if(this.numDaysElapsedSinceLastOptimization == --- 165,168 ---- Index: EndOfDayTimerHandlerOTC.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerOTC.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** EndOfDayTimerHandlerOTC.cs 17 Sep 2006 21:48:39 -0000 1.5 --- EndOfDayTimerHandlerOTC.cs 29 Aug 2007 09:43:32 -0000 1.6 *************** *** 28,31 **** --- 28,32 ---- using QuantProject.Business.Financial.Instruments; using QuantProject.Business.Financial.Ordering; + using QuantProject.Business.Strategies; using QuantProject.Business.Timing; using QuantProject.Data.DataProviders; *************** *** 44,51 **** public class EndOfDayTimerHandlerOTC : EndOfDayTimerHandler { - protected int numDaysBetweenEachOptimization; - private int numDaysElapsedSinceLastOptimization; protected int seedForRandomGenerator; ! public EndOfDayTimerHandlerOTC(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, Account account, --- 45,50 ---- public class EndOfDayTimerHandlerOTC : EndOfDayTimerHandler { protected int seedForRandomGenerator; ! public EndOfDayTimerHandlerOTC(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, Account account, *************** *** 64,111 **** this.numDaysElapsedSinceLastOptimization = 0; this.seedForRandomGenerator = ConstantsProvider.SeedForRandomGenerator; ! } ! ! private double marketOpenEventHandler_currCombinationHasLost_getValue(ExtendedDateTime extendedDateTime) ! { ! double returnValue = 0.0; ! string signedTicker; ! string unsignedTicker; ! double tickerMarketValue; ! for(int i = 0; i<this.chosenTickers.Length; i++) ! { ! signedTicker = this.chosenTickers[i]; ! unsignedTicker = ! GenomeManagerForEfficientPortfolio.GetCleanTickerCode(signedTicker); ! tickerMarketValue = ! HistoricalDataProvider.GetAdjustedMarketValue(unsignedTicker,extendedDateTime); ! if(signedTicker == unsignedTicker) ! //long position for the ticker ! returnValue += this.chosenTickersPortfolioWeights[i]*tickerMarketValue; ! else//short position for the ticker ! returnValue -= this.chosenTickersPortfolioWeights[i]*tickerMarketValue; ! } ! return returnValue; ! ! } ! ! private bool marketOpenEventHandler_currCombinationHasLost() ! { ! bool returnValue = false; ! IndexBasedEndOfDayTimer currentTimer = (IndexBasedEndOfDayTimer)this.account.EndOfDayTimer; ! ExtendedDateTime now = ! new ExtendedDateTime(currentTimer.GetCurrentTime().DateTime, ! BarComponent.Open); ! ExtendedDateTime previousClose = ! new ExtendedDateTime(currentTimer.GetPreviousDateTime(), ! BarComponent.Close); ! double currentCombinationValue_Now = ! this.marketOpenEventHandler_currCombinationHasLost_getValue(now); ! double currentCombinationValue_AtPreviousMarketClose = ! this.marketOpenEventHandler_currCombinationHasLost_getValue(previousClose); ! if(currentCombinationValue_Now < currentCombinationValue_AtPreviousMarketClose) ! returnValue = true; ! return returnValue; ! } ! /// <summary> /// Handles a "Market Open" event. --- 63,68 ---- this.numDaysElapsedSinceLastOptimization = 0; this.seedForRandomGenerator = ConstantsProvider.SeedForRandomGenerator; ! } ! /// <summary> /// Handles a "Market Open" event. *************** *** 116,131 **** Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! if(this.orders.Count == 0 && this.account.Transactions.Count == 0) ! this.account.AddCash(30000); ! bool allTickerHasBeenChosen = true; ! for( int i = 0; i<this.chosenTickers.Length; i++) ! { ! if(this.chosenTickers[i] == null) ! allTickerHasBeenChosen = false; ! } ! if(allTickerHasBeenChosen && ! this.marketOpenEventHandler_currCombinationHasLost()) ! this.openPositions(this.chosenTickers); ! } --- 73,78 ---- Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! this.openPositions(); ! } *************** *** 133,137 **** Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! this.closePositions(); } --- 80,84 ---- Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! AccountManager.ClosePositions(this.account); } *************** *** 153,158 **** false, currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, this.numberOfEligibleTickers, this.benchmark); ! ! return quotedAtEachMarketDayFromMostLiquid.GetTableOfSelectedTickers(); } --- 100,119 ---- false, currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, this.numberOfEligibleTickers, this.benchmark); ! ! SelectorByAverageRawOpenPrice byPrice = ! new SelectorByAverageRawOpenPrice(quotedAtEachMarketDayFromMostLiquid.GetTableOfSelectedTickers(), ! false,currentDate.AddDays(-30), ! currentDate, ! this.numberOfEligibleTickers, ! 35); ! DataTable tickersByPrice = byPrice.GetTableOfSelectedTickers(); ! ! SelectorByOpenCloseCorrelationToBenchmark tickersLessCorrelatedToBenchmark = ! new SelectorByOpenCloseCorrelationToBenchmark(tickersByPrice, ! "^GSPC",true, ! currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, ! tickersByPrice.Rows.Count/2); ! ! return tickersLessCorrelatedToBenchmark.GetTableOfSelectedTickers(); } *************** *** 163,167 **** DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); ! if(setOfTickersToBeOptimized.Rows.Count > this.chosenTickers.Length*2) //the optimization process is possible only if the initial set of tickers is //as large as the number of tickers to be chosen --- 124,128 ---- DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); ! if(setOfTickersToBeOptimized.Rows.Count > this.numberOfTickersToBeChosen*2) //the optimization process is possible only if the initial set of tickers is //as large as the number of tickers to be chosen *************** *** 188,197 **** if(setGenomeCounter) this.genomeCounter = new GenomeCounter(GO); ! GO.Run(false); this.addGenomeToBestGenomes(GO.BestGenome,currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, setOfTickersToBeOptimized.Rows.Count); ! this.chosenTickers = ((GenomeMeaning)GO.BestGenome.Meaning).Tickers; ! this.chosenTickersPortfolioWeights = ((GenomeMeaning)GO.BestGenome.Meaning).TickersPortfolioWeights; } //else it will be buyed again the previous optimized portfolio --- 149,159 ---- if(setGenomeCounter) this.genomeCounter = new GenomeCounter(GO); ! GO.CrossoverRate = 0.0; ! GO.MutationRate = 0.70; GO.Run(false); this.addGenomeToBestGenomes(GO.BestGenome,currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, setOfTickersToBeOptimized.Rows.Count); ! this.chosenWeightedPositions = new WeightedPositions( ((GenomeMeaning)GO.BestGenome.Meaning).TickersPortfolioWeights, ! new SignedTickers( ((GenomeMeaning)GO.BestGenome.Meaning).Tickers) ); } //else it will be buyed again the previous optimized portfolio *************** *** 217,221 **** { this.seedForRandomGenerator++; - this.orders.Clear(); //this.oneHourAfterMarketCloseEventHandler_updatePrices(); if(this.numDaysElapsedSinceLastOptimization == --- 179,182 ---- Index: EndOfDayTimerHandlerOTCMultiAccount.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerOTCMultiAccount.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** EndOfDayTimerHandlerOTCMultiAccount.cs 17 Sep 2006 21:48:39 -0000 1.2 --- EndOfDayTimerHandlerOTCMultiAccount.cs 29 Aug 2007 09:43:33 -0000 1.3 *************** *** 29,32 **** --- 29,33 ---- using QuantProject.Business.Financial.Ordering; using QuantProject.Business.Timing; + using QuantProject.Business.Strategies; using QuantProject.Data.DataProviders; using QuantProject.Data.Selectors; *************** *** 44,55 **** public class EndOfDayTimerHandlerOTCMultiAccount : EndOfDayTimerHandler { - protected int numDaysBetweenEachOptimization; - private int numDaysElapsedSinceLastOptimization; protected int seedForRandomGenerator; ! private string[,] chosenTickersForAccounts; private int distanceForEachGenomeToTest; private Account[] accounts; - private ArrayList[] ordersForAccounts; - private string[,] lastOrderedTickersForAccounts; public EndOfDayTimerHandlerOTCMultiAccount(string tickerGroupID, int numberOfEligibleTickers, --- 45,52 ---- public class EndOfDayTimerHandlerOTCMultiAccount : EndOfDayTimerHandler { protected int seedForRandomGenerator; ! private WeightedPositions[] chosenWeightedPositionsForAccounts; private int distanceForEachGenomeToTest; private Account[] accounts; public EndOfDayTimerHandlerOTCMultiAccount(string tickerGroupID, int numberOfEligibleTickers, *************** *** 71,162 **** this.numDaysElapsedSinceLastOptimization = 0; this.seedForRandomGenerator = ConstantsProvider.SeedForRandomGenerator; ! this.chosenTickersForAccounts = new string[numberOfAccounts,numberOfTickersToBeChosen]; ! this.lastOrderedTickersForAccounts = new string[numberOfAccounts,numberOfTickersToBeChosen]; ! this.ordersForAccounts = new ArrayList[numberOfAccounts]; ! for(int i = 0; i<numberOfAccounts;i++) ! ordersForAccounts[i] = new ArrayList(); this.distanceForEachGenomeToTest = distanceForEachGenomeToTest; this.accounts = accounts; } ! ! private void addOrderForTickerForEachAccount(int accountNumber, string ticker ) ! { ! string tickerCode = ! GenomeManagerForEfficientPortfolio.GetCleanTickerCode(ticker); ! double cashForSinglePosition = this.accounts[accountNumber].CashAmount / this.numberOfTickersToBeChosen; ! long quantity = ! Convert.ToInt64( Math.Floor( cashForSinglePosition / this.accounts[accountNumber].DataStreamer.GetCurrentBid( tickerCode ) ) ); ! Order order; ! if(this.portfolioType == PortfolioType.OnlyShort || ! (this.portfolioType == PortfolioType.ShortAndLong && ! ticker != tickerCode)) ! order = new Order( OrderType.MarketSellShort, new Instrument( tickerCode ) , quantity ); ! else ! order = new Order( OrderType.MarketBuy, new Instrument( tickerCode ) , quantity ); ! ! this.ordersForAccounts[accountNumber].Add(order); ! } ! ! protected override void addChosenTickersToOrderList(string[] tickers) ! { ! for(int i = 0; i<this.accounts.Length; i++) ! { ! for(int j = 0; j<this.numberOfTickersToBeChosen; j++) ! { ! string ticker = this.chosenTickersForAccounts[i,j]; ! if( ticker != null) ! { ! this.addOrderForTickerForEachAccount(i, ticker ); ! this.lastOrderedTickersForAccounts[i,j] = ! GenomeManagerForEfficientPortfolio.GetCleanTickerCode(ticker); ! } ! } ! } ! } ! ! ! protected override void openPositions(string[] tickers) { //add cash first ! for(int i = 0; i<this.accounts.Length; i++) ! { ! if(this.ordersForAccounts[i].Count == 0 && this.accounts[i].Transactions.Count == 0) ! this.accounts[i].AddCash(17000); ! } ! ! this.addChosenTickersToOrderList(tickers); //execute orders actually for(int i = 0; i<this.accounts.Length; i++) ! { ! foreach(object item in this.ordersForAccounts[i]) ! this.accounts[i].AddOrder((Order)item); ! } ! } ! private void closePositions_closePositionForAccount(int accountNumber, ! string ticker) ! { ! this.accounts[accountNumber].ClosePosition(ticker); ! } ! protected override void closePositions() ! { ! string ticker; ! for(int i = 0; i<this.accounts.Length; i++) ! { ! for(int j = 0; j<this.numberOfTickersToBeChosen; j++) ! { ! ticker = this.lastOrderedTickersForAccounts[i,j]; ! if( ticker != null) ! { ! if(this.accounts[i].Portfolio[ticker]!=null) ! closePositions_closePositionForAccount(i, ticker ); ! } ! } ! } ! } ! ! ! /// <summary> /// Handles a "Market Open" event. /// </summary> --- 68,89 ---- this.numDaysElapsedSinceLastOptimization = 0; this.seedForRandomGenerator = ConstantsProvider.SeedForRandomGenerator; ! this.chosenWeightedPositionsForAccounts = new WeightedPositions[numberOfAccounts]; this.distanceForEachGenomeToTest = distanceForEachGenomeToTest; this.accounts = accounts; } ! ! private void openPositions(WeightedPositions[] chosenWeightedPositionsForAccounts) { //add cash first ! for ( int i = 0; i<this.accounts.Length; i++ ) ! if ( this.accounts[i].Transactions.Count == 0 ) ! this.accounts[i].AddCash(15000); //execute orders actually for(int i = 0; i<this.accounts.Length; i++) ! AccountManager.OpenPositions(this.chosenWeightedPositionsForAccounts[i], ! this.accounts[i]); } ! /// <summary> /// Handles a "Market Open" event. /// </summary> *************** *** 168,172 **** //temporarily the if condition //if(this.numDaysElapsedSinceLastOptimization == 0) ! this.openPositions(this.chosenTickers); } --- 95,99 ---- //temporarily the if condition //if(this.numDaysElapsedSinceLastOptimization == 0) ! this.openPositions(this.chosenWeightedPositionsForAccounts); } *************** *** 179,187 **** //if(this.numDaysElapsedSinceLastOptimization == // this.numDaysBetweenEachOptimization) ! this.closePositions(); ! } - - #region OneHourAfterMarketCloseEventHandler --- 106,112 ---- //if(this.numDaysElapsedSinceLastOptimization == // this.numDaysBetweenEachOptimization) ! for(int i = 0; i<this.accounts.Length; i++) ! AccountManager.ClosePositions( this.accounts[i] ); } #region OneHourAfterMarketCloseEventHandler *************** *** 230,234 **** DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); ! if(setOfTickersToBeOptimized.Rows.Count > this.chosenTickers.Length*2) //the optimization process is possible only if the initial set of tickers is //as large as the number of tickers to be chosen --- 155,159 ---- DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); ! if(setOfTickersToBeOptimized.Rows.Count > this.numberOfTickersToBeChosen*2) //the optimization process is possible only if the initial set of tickers is //as large as the number of tickers to be chosen *************** *** 253,266 **** //this.addGenomeToBestGenomes(GO.BestGenome,currentDate.AddDays(-this.numDaysForOptimizationPeriod), // currentDate); ! for(int i = 0; i<this.accounts.Length; i++) { ! for(int j = 0; j<this.numberOfTickersToBeChosen; j++) ! this.chosenTickersForAccounts[i,j] = ! ((string[])((Genome)GO.CurrentGeneration[GO.CurrentGeneration.Count - 1 -i*this.distanceForEachGenomeToTest]).Meaning)[j]; ! } ! } //else it will be buyed again the previous optimized portfolio - //that's it the actual chosenTickers member } --- 178,189 ---- //this.addGenomeToBestGenomes(GO.BestGenome,currentDate.AddDays(-this.numDaysForOptimizationPeriod), // currentDate); ! SignedTickers signedTickers; ! for(int i = 0; i<this.accounts.Length; i++) { ! signedTickers = new SignedTickers( (string[])((Genome)GO.CurrentGeneration[GO.CurrentGeneration.Count - 1 -i*this.distanceForEachGenomeToTest]).Meaning ); ! this.chosenWeightedPositionsForAccounts[i] = new WeightedPositions( signedTickers ); ! } } //else it will be buyed again the previous optimized portfolio } *************** *** 283,288 **** { this.seedForRandomGenerator++; - foreach(ArrayList arrayList in this.ordersForAccounts) - arrayList.Clear(); //this.oneHourAfterMarketCloseEventHandler_updatePrices(); if(this.numDaysElapsedSinceLastOptimization == --- 206,209 ---- Index: EndOfDayTimerHandlerCTO.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerCTO.cs,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** EndOfDayTimerHandlerCTO.cs 17 Sep 2006 21:48:39 -0000 1.25 --- EndOfDayTimerHandlerCTO.cs 29 Aug 2007 09:43:32 -0000 1.26 *************** *** 29,32 **** --- 29,33 ---- using QuantProject.Business.Financial.Ordering; using QuantProject.Business.Timing; + using QuantProject.Business.Strategies; using QuantProject.Data.DataProviders; using QuantProject.Data.Selectors; *************** *** 44,49 **** public class EndOfDayTimerHandlerCTO : EndOfDayTimerHandler { - protected int numDaysBetweenEachOptimization; - private int numDaysElapsedSinceLastOptimization; protected int seedForRandomGenerator; --- 45,48 ---- *************** *** 75,79 **** Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! this.closePositions(); } --- 74,78 ---- Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! AccountManager.ClosePositions(this.account); } *************** *** 82,93 **** Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! if(this.orders.Count == 0 && this.account.Transactions.Count == 0) ! this.account.AddCash(30000); ! ! // if(this.numDaysElapsedSinceLastOptimization < ! // this.numDaysBetweenEachOptimization - 1) ! // { ! this.openPositions(this.chosenTickers); ! // } } --- 81,85 ---- Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! this.openPositions(); } *************** *** 119,123 **** DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); ! if(setOfTickersToBeOptimized.Rows.Count > this.chosenTickers.Length*2) //the optimization process is possible only if the initial set of tickers is //as large as the number of tickers to be chosen --- 111,115 ---- DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); ! if(setOfTickersToBeOptimized.Rows.Count > this.numberOfTickersToBeChosen*2) //the optimization process is possible only if the initial set of tickers is //as large as the number of tickers to be chosen *************** *** 142,148 **** this.addGenomeToBestGenomes(GO.BestGenome,currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, setOfTickersToBeOptimized.Rows.Count); ! this.chosenTickers = ((GenomeMeaning)GO.BestGenome.Meaning).Tickers; ! this.chosenTickersPortfolioWeights = ((GenomeMeaning)GO.BestGenome.Meaning).TickersPortfolioWeights; ! } //else it will be buyed again the previous optimized portfolio //that's it the actual chosenTickers member --- 134,140 ---- this.addGenomeToBestGenomes(GO.BestGenome,currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, setOfTickersToBeOptimized.Rows.Count); ! this.chosenWeightedPositions = new WeightedPositions( ((GenomeMeaning)GO.BestGenome.Meaning).TickersPortfolioWeights, ! new SignedTickers( ((GenomeMeaning)GO.BestGenome.Meaning).Tickers) ); ! } //else it will be buyed again the previous optimized portfolio //that's it the actual chosenTickers member *************** *** 167,171 **** { this.seedForRandomGenerator++; - this.orders.Clear(); //this.oneHourAfterMarketCloseEventHandler_updatePrices(); if(this.numDaysElapsedSinceLastOptimization == --- 159,162 ---- Index: EndOfDayTimerHandlerCTCWeekly.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerCTCWeekly.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** EndOfDayTimerHandlerCTCWeekly.cs 17 Sep 2006 21:48:39 -0000 1.6 --- EndOfDayTimerHandlerCTCWeekly.cs 29 Aug 2007 09:43:32 -0000 1.7 *************** *** 29,32 **** --- 29,33 ---- using QuantProject.Business.Financial.Ordering; using QuantProject.Business.Timing; + using QuantProject.Business.Strategies; using QuantProject.Data.DataProviders; using QuantProject.Data.Selectors; *************** *** 46,53 **** protected int numDaysForReturnCalculation; protected double maxAcceptableCloseToCloseDrawdown; ! protected bool stopLossConditionReached; ! protected double currentAccountValue; ! protected double previousAccountValue; ! public EndOfDayTimerHandlerCTCWeekly(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, --- 47,51 ---- protected int numDaysForReturnCalculation; protected double maxAcceptableCloseToCloseDrawdown; ! public EndOfDayTimerHandlerCTCWeekly(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, *************** *** 68,76 **** this.numDaysForReturnCalculation = numDaysForReturnCalculation; this.maxAcceptableCloseToCloseDrawdown = maxAcceptableCloseToCloseDrawdown; - this.stopLossConditionReached = false; - this.currentAccountValue = 0.0; - this.previousAccountValue = 0.0; } - #region MarketCloseEventHandler --- 66,70 ---- *************** *** 100,109 **** if(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime.DayOfWeek == DayOfWeek.Monday) ! this.openPositions(this.chosenTickers); if(this.stopLossConditionReached || endOfDayTimingEventArgs.EndOfDayDateTime.DateTime.DayOfWeek == DayOfWeek.Friday) ! this.closePositions(); } --- 94,103 ---- if(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime.DayOfWeek == DayOfWeek.Monday) ! this.openPositions(); if(this.stopLossConditionReached || endOfDayTimingEventArgs.EndOfDayDateTime.DateTime.DayOfWeek == DayOfWeek.Friday) ! AccountManager.ClosePositions(this.account); } *************** *** 130,134 **** { 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 --- 124,128 ---- { DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); ! if(setOfTickersToBeOptimized.Rows.Count > this.numberOfTickersToBeChosen*2) //the optimization process is meaningful only if the initial set of tickers is //larger than the number of tickers to be chosen *************** *** 152,157 **** //GO.KeepOnRunningUntilConvergenceIsReached = true; GO.Run(false); ! this.chosenTickers = ((GenomeMeaning)GO.BestGenome.Meaning).Tickers; ! this.chosenTickersPortfolioWeights = ((GenomeMeaning)GO.BestGenome.Meaning).TickersPortfolioWeights; } //else it will be buyed again the previous optimized portfolio --- 146,151 ---- //GO.KeepOnRunningUntilConvergenceIsReached = true; GO.Run(false); ! this.chosenWeightedPositions = new WeightedPositions( ((GenomeMeaning)GO.BestGenome.Meaning).TickersPortfolioWeights, ! new SignedTickers( ((GenomeMeaning)GO.BestGenome.Meaning).Tickers) ); } //else it will be buyed again the previous optimized portfolio *************** *** 172,176 **** DayOfWeek.Friday) { - this.orders.Clear(); this.setTickers(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime); //it sets tickers to be chosen at next Monday --- 166,169 ---- Index: EndOfDayTimerHandlerCTC.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerCTC.cs,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** EndOfDayTimerHandlerCTC.cs 17 Sep 2006 21:48:39 -0000 1.22 --- EndOfDayTimerHandlerCTC.cs 29 Aug 2007 09:43:31 -0000 1.23 *************** *** 29,32 **** --- 29,33 ---- using QuantProject.Business.Financial.Ordering; using QuantProject.Business.Timing; + using QuantProject.Business.Strategies; using QuantProject.Data.DataProviders; using QuantProject.Data.Selectors; *************** *** 50,59 **** protected int daysCounterWithNoPositions; protected double maxAcceptableCloseToCloseDrawdown; ! protected bool stopLossConditionReached; ! protected double currentAccountValue; ! protected double previousAccountValue; ! protected int numDaysBetweenEachOptimization; ! private int numDaysElapsedSinceLastOptimization; ! public EndOfDayTimerHandlerCTC(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, --- 51,55 ---- protected int daysCounterWithNoPositions; protected double maxAcceptableCloseToCloseDrawdown; ! public EndOfDayTimerHandlerCTC(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, *************** *** 121,125 **** //max acceptable close to close drawdown reached { ! this.closePositions(); this.daysCounterWithPositions = 0; //positionsJustClosed = true; --- 117,121 ---- //max acceptable close to close drawdown reached { ! AccountManager.ClosePositions(this.account); this.daysCounterWithPositions = 0; //positionsJustClosed = true; *************** *** 132,136 **** this.Account.Transactions.Count <= 1) { ! this.openPositions(this.chosenTickers); this.daysCounterWithNoPositions = 0; } --- 128,132 ---- this.Account.Transactions.Count <= 1) { ! AccountManager.OpenPositions(this.chosenWeightedPositions,this.account); this.daysCounterWithNoPositions = 0; } *************** *** 188,192 **** { 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 --- 184,188 ---- { DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); ! if(setOfTickersToBeOptimized.Rows.Count > this.numberOfTickersToBeChosen*2) //the optimization process is meaningful only if the initial set of tickers is //larger than the number of tickers to be chosen *************** *** 216,222 **** ((GenomeManagerForEfficientCTCPortfolio)genManEfficientCTCPortfolio).LastQuoteDate, setOfTickersToBeOptimized.Rows.Count); ! this.chosenTickers = ((GenomeMeaning)GO.BestGenome.Meaning).Tickers; ! this.chosenTickersPortfolioWeights = ((GenomeMeaning)GO.BestGenome.Meaning).TickersPortfolioWeights; ! } //else it will be buyed again the previous optimized portfolio //that's it the actual chosenTickers member --- 212,218 ---- ((GenomeManagerForEfficientCTCPortfolio)genManEfficientCTCPortfolio).LastQuoteDate, setOfTickersToBeOptimized.Rows.Count); ! this.chosenWeightedPositions = new WeightedPositions( ((GenomeMeaning)GO.BestGenome.Meaning).TickersPortfolioWeights, ! new SignedTickers( ((GenomeMeaning)GO.BestGenome.Meaning).Tickers) ); ! } //else it will be buyed again the previous optimized portfolio //that's it the actual chosenTickers member *************** *** 243,247 **** //this.oneHourAfterMarketCloseEventHandler_updatePrices(); this.numDaysElapsedSinceLastOptimization++; - this.orders.Clear(); if(this.numDaysElapsedSinceLastOptimization == this.numDaysBetweenEachOptimization) --- 239,242 ---- Index: EndOfDayTimerHandlerOTC_WorstAtNight.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerOTC_WorstAtNight.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** EndOfDayTimerHandlerOTC_WorstAtNight.cs 30 Jun 2007 18:50:38 -0000 1.1 --- EndOfDayTimerHandlerOTC_WorstAtNight.cs 29 Aug 2007 09:43:32 -0000 1.2 *************** *** 45,50 **** public class EndOfDayTimerHandlerOTC_WorstAtNight : EndOfDayTimerHandler { - protected int numDaysBetweenEachOptimization; - private int numDaysElapsedSinceLastOptimization; protected int seedForRandomGenerator; protected GeneticOptimizer currentGO; --- 45,48 ---- *************** *** 82,86 **** DateTime lastMarketDay = currentTimer.GetPreviousDateTime(); int numOfGenomesScanned = 0; ! for(int i = 0; numOfGenomesScanned < this.numOfGenomesForCTOScanning; i++) { if( i == 0 || --- 80,87 ---- DateTime lastMarketDay = currentTimer.GetPreviousDateTime(); int numOfGenomesScanned = 0; ! for(int i = 0; ! numOfGenomesScanned < this.numOfGenomesForCTOScanning && ! i < populationSize - 1; ! i++) { if( i == 0 || *************** *** 94,103 **** try{ //tries to retrieve loss at night for the CurrentCombination ! lossOfCurrentCombination = ! SignedTicker.GetLastNightPortfolioReturn( ! ((GenomeMeaning)((Genome)this.currentGO.CurrentGeneration[populationSize - i - 1]).Meaning).Tickers, ! ((GenomeMeaning)((Genome)this.currentGO.CurrentGeneration[populationSize - i - 1]).Meaning).TickersPortfolioWeights, ! lastMarketDay, ! today); numOfGenomesScanned++; if(lossOfCurrentCombination < lossOfCurrentWorstCombination) --- 95,105 ---- try{ //tries to retrieve loss at night for the CurrentCombination ! SignedTickers signedTickers = ! new SignedTickers( ((GenomeMeaning)((Genome)this.currentGO.CurrentGeneration[populationSize - i - 1]).Meaning).Tickers); ! WeightedPositions weightedPositions = ! new WeightedPositions( ((GenomeMeaning)((Genome)this.currentGO.CurrentGeneration[populationSize - i - 1]).Meaning).TickersPortfolioWeights, ! signedTickers); ! lossOfCurrentCombination = ! weightedPositions.GetLastNightReturn(lastMarketDay,today); numOfGenomesScanned++; if(lossOfCurrentCombination < lossOfCurrentWorstCombination) *************** *** 113,121 **** } } ! ! this.chosenTickers = ! ((GenomeMeaning)((Genome)this.currentGO.CurrentGeneration[indexOfWorstCombination]).Meaning).Tickers; ! this.chosenTickersPortfolioWeights = ! ((GenomeMeaning)((Genome)this.currentGO.CurrentGeneration[indexOfWorstCombination]).Meaning).TickersPortfolioWeights; } --- 115,120 ---- } } ! this.chosenWeightedPositions = new WeightedPositions( ((GenomeMeaning)((Genome)this.currentGO.CurrentGeneration[indexOfWorstCombination]).Meaning).TickersPortfolioWeights, ! new SignedTickers( ((GenomeMeaning)((Genome)this.currentGO.CurrentGeneration[indexOfWorstCombination]).Meaning).Tickers)); } *************** *** 128,138 **** Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! if(this.orders.Count == 0 && this.account.Transactions.Count == 0) ! this.account.AddCash(30000); ! if(this.currentGO != null) //so a list of genomes is available this.marketOpenEventHandler_chooseTheWorstCTOGenome(); ! this.openPositions(this.chosenTickers); } --- 127,135 ---- Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! if(this.currentGO != null) //so a list of genomes is available this.marketOpenEventHandler_chooseTheWorstCTOGenome(); ! this.openPositions(); } *************** *** 140,144 **** Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! this.closePositions(); } --- 137,141 ---- Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! AccountManager.ClosePositions(this.account); } *************** *** 147,177 **** protected DataTable getSetOfTickersToBeOptimized(DateTime currentDate) { ! Sel... [truncated message content] |
|
From: Marco M. <mi...@us...> - 2007-08-29 09:44:17
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/TestingOTCTypes In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv10276/b7_Scripts/TickerSelectionTesting/TestingOTCTypes Modified Files: EndOfDayTimerHandlerOTCTypes.cs Log Message: Code has been re-organized in a more logical and Object Oriented way: - WeightedPositions class has been used. - Some static methods have been deleted from SignedTicker class. They have been moved to WeightedPositions. - Basic orders'management has been moved to the primitive base class EndOfDayTimerHandler and to AccountManager class Index: EndOfDayTimerHandlerOTCTypes.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/TestingOTCTypes/EndOfDayTimerHandlerOTCTypes.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** EndOfDayTimerHandlerOTCTypes.cs 9 Apr 2007 18:08:59 -0000 1.7 --- EndOfDayTimerHandlerOTCTypes.cs 29 Aug 2007 09:43:34 -0000 1.8 *************** *** 36,41 **** namespace QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios { ! ! /// <summary> /// Implements MarketOpenEventHandler, /// MarketCloseEventHandler and OneHourAfterMarketCloseEventHandler --- 36,40 ---- namespace QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios { ! /// <summary> /// Implements MarketOpenEventHandler, /// MarketCloseEventHandler and OneHourAfterMarketCloseEventHandler *************** *** 46,57 **** public class EndOfDayTimerHandlerOTCTypes : EndOfDayTimerHandler { - private int numDaysBetweenEachOptimization; - private int numDaysElapsedSinceLastOptimization; private int seedForRandomGenerator; private Account[] accounts; - private string[,] lastOrderedTickersForTheAccount; int numOfClosesWithOpenPositionsFor2DaysStrategy; ! ! public EndOfDayTimerHandlerOTCTypes(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, --- 45,52 ---- public class EndOfDayTimerHandlerOTCTypes : EndOfDayTimerHandler { private int seedForRandomGenerator; private Account[] accounts; int numOfClosesWithOpenPositionsFor2DaysStrategy; ! public EndOfDayTimerHandlerOTCTypes(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, *************** *** 72,77 **** this.seedForRandomGenerator = ConstantsProvider.SeedForRandomGenerator; this.accounts = accounts; - this.lastOrderedTickersForTheAccount = new string[this.accounts.Length, - this.numberOfTickersToBeChosen]; } --- 67,70 ---- *************** *** 79,159 **** { if(this.accounts[accountNumber].Portfolio.Count == 0) ! { ! this.orders.Clear(); ! this.addChosenTickersToOrderListForTheGivenAccount(accountNumber); ! for(int i = 0; i<this.orders.Count;i++) ! { ! this.accounts[accountNumber].AddOrder((Order)this.orders[i]); ! this.lastOrderedTickersForTheAccount[accountNumber, i] = ! SignedTicker.GetTicker(((Order)this.orders[i]).Instrument.Key); ! } ! } } - protected void addOrderForTickerForTheGivenAccount(int tickerPosition, - int accountNumber ) - { - string tickerCode = - GenomeManagerForEfficientPortfolio.GetCleanTickerCode(this.chosenTickers[tickerPosition]); - double cashForSinglePosition = - this.accounts[accountNumber].CashAmount * this.chosenTickersPortfolioWeights[tickerPosition]; - long quantity = - Convert.ToInt64( Math.Floor( cashForSinglePosition / this.accounts[accountNumber].DataStreamer.GetCurrentBid( tickerCode ) ) ); - Order order; - if(this.portfolioType == PortfolioType.OnlyShort || - (this.portfolioType == PortfolioType.ShortAndLong && - this.chosenTickers[tickerPosition] != tickerCode)) - order = new Order( OrderType.MarketSellShort, new Instrument( tickerCode ) , quantity ); - else - order = new Order( OrderType.MarketBuy, new Instrument( tickerCode ) , quantity ); - - this.orders.Add(order); - } - - protected void addChosenTickersToOrderListForTheGivenAccount(int accountNumber) - { - for( int i = 0; i<this.chosenTickers.Length; i++) - { - if(this.chosenTickers[i] != null) - this.addOrderForTickerForTheGivenAccount( i, accountNumber ); - } - } - - private void closePositionsForTheAccount(int accountNumber) { ! string ticker; ! if(this.accounts[accountNumber].Portfolio.Count >0) ! { ! for(int j = 0; j<this.numberOfTickersToBeChosen; j++) ! { ! ticker = this.lastOrderedTickersForTheAccount[accountNumber, j]; ! if( ticker != null) ! { ! if(this.accounts[accountNumber].Portfolio[ticker]!=null) ! this.accounts[accountNumber].ClosePosition(ticker); ! } ! } ! } ! } ! ! private void marketCloseEventHandler_reversePositionsForTheAccount(int accountNumber) ! { ! this.closePositionsForTheAccount(accountNumber); ! SignedTicker.ChangeSignOfEachTicker(this.chosenTickers); ! try ! { ! this.openPositionsForTheAccountWhenPortfolioIsEmpty(accountNumber); ! } ! catch(Exception ex) ! { ! ex = ex; ! } ! finally ! { ! SignedTicker.ChangeSignOfEachTicker(this.chosenTickers); ! } } ! /// <summary> /// Handles a "Market Open" event. --- 72,83 ---- { if(this.accounts[accountNumber].Portfolio.Count == 0) ! AccountManager.OpenPositions(this.chosenWeightedPositions, this.accounts[accountNumber]); } private void closePositionsForTheAccount(int accountNumber) { ! AccountManager.ClosePositions(this.accounts[accountNumber]); } ! /// <summary> /// Handles a "Market Open" event. *************** *** 167,172 **** { //add cash first for each account ! if(this.orders.Count == 0 && this.accounts[i].Transactions.Count == 0) ! this.accounts[i].AddCash(30000); if(i<=1)//daily classical and multiday --- 91,96 ---- { //add cash first for each account ! if(this.accounts[i].Transactions.Count == 0) ! this.accounts[i].AddCash(15000); if(i<=1)//daily classical and multiday *************** *** 205,214 **** if(i>=2)//for the OTC-CTO and CTO ! this.marketCloseEventHandler_reversePositionsForTheAccount(i); } } - - #region OneHourAfterMarketCloseEventHandler --- 129,136 ---- if(i>=2)//for the OTC-CTO and CTO ! AccountManager.ReversePositions(this.accounts[i]); } } #region OneHourAfterMarketCloseEventHandler *************** *** 222,227 **** currentDate, tickersFromGroup.Rows.Count, ! 20,500, 0.0001,100); ! SelectorByLiquidity mostLiquidSelector = --- 144,148 ---- currentDate, tickersFromGroup.Rows.Count, ! 25); SelectorByLiquidity mostLiquidSelector = *************** *** 241,247 **** bool setGenomeCounter) { - DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); ! if(setOfTickersToBeOptimized.Rows.Count > this.chosenTickers.Length*2) //the optimization process is possible only if the initial set of tickers is //as large as the number of tickers to be chosen --- 162,167 ---- bool setGenomeCounter) { DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); ! if(setOfTickersToBeOptimized.Rows.Count > this.numberOfTickersToBeChosen*2) //the optimization process is possible only if the initial set of tickers is //as large as the number of tickers to be chosen *************** *** 268,274 **** currentDate,setOfTickersToBeOptimized.Rows.Count,-1, this.portfolioType, GO.GenerationCounter); ! this.chosenTickers = ((GenomeMeaning)GO.BestGenome.Meaning).Tickers; ! this.chosenTickersPortfolioWeights = ((GenomeMeaning)GO.BestGenome.Meaning).TickersPortfolioWeights; ! } //else it will be buyed again the previous optimized portfolio --- 188,193 ---- currentDate,setOfTickersToBeOptimized.Rows.Count,-1, this.portfolioType, GO.GenerationCounter); ! this.chosenWeightedPositions = new WeightedPositions( ((GenomeMeaning)GO.BestGenome.Meaning).TickersPortfolioWeights, ! new SignedTickers( ((GenomeMeaning)GO.BestGenome.Meaning).Tickers) ); } //else it will be buyed again the previous optimized portfolio *************** *** 285,290 **** { this.seedForRandomGenerator++; ! this.orders.Clear(); ! if(this.numDaysElapsedSinceLastOptimization == this.numDaysBetweenEachOptimization - 1) { --- 204,208 ---- { this.seedForRandomGenerator++; ! if(this.numDaysElapsedSinceLastOptimization == this.numDaysBetweenEachOptimization - 1) { *************** *** 299,305 **** } - #endregion - } } --- 217,221 ---- |
|
From: Marco M. <mi...@us...> - 2007-08-29 09:44:17
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/SimpleSelection In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv10276/b7_Scripts/TickerSelectionTesting/SimpleSelection Modified Files: EndOfDayTimerHandlerSimpleSelection.cs EndOfDayTimerHandlerSimpleSelectionOpenToClose.cs Log Message: Code has been re-organized in a more logical and Object Oriented way: - WeightedPositions class has been used. - Some static methods have been deleted from SignedTicker class. They have been moved to WeightedPositions. - Basic orders'management has been moved to the primitive base class EndOfDayTimerHandler and to AccountManager class Index: EndOfDayTimerHandlerSimpleSelection.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/SimpleSelection/EndOfDayTimerHandlerSimpleSelection.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** EndOfDayTimerHandlerSimpleSelection.cs 21 Oct 2005 17:54:11 -0000 1.1 --- EndOfDayTimerHandlerSimpleSelection.cs 29 Aug 2007 09:43:34 -0000 1.2 *************** *** 41,205 **** /// </summary> [Serializable] ! public class EndOfDayTimerHandlerSimpleSelection { ! protected DataTable eligibleTickers; ! protected string[] chosenTickers; ! protected string[] lastOrderedTickers; ! ! protected string tickerGroupID; ! protected int numberOfEligibleTickers; ! protected int numberOfTickersToBeChosen; ! protected int numDaysForOptimizationPeriod; ! ! protected Account account; ! protected ArrayList orders; ! ! protected string benchmark; ! //these two values have to be updated during ! //backtest, for minimizing commission amount, ! //according to broker's commission scheme ! protected double minPriceForMinimumCommission = 0; ! protected double maxPriceForMinimumCommission = 500; ! ! protected double targetReturn; ! ! protected PortfolioType portfolioType; ! ! public string[] LastOrderedTickers ! { ! get { return this.lastOrderedTickers; } ! } ! public int NumberOfEligibleTickers ! { ! get { return this.numberOfEligibleTickers; } ! } ! ! public Account Account ! { ! get { return this.account; } ! } ! ! ! public EndOfDayTimerHandlerSimpleSelection(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, Account account, string benchmark, double targetReturn, ! PortfolioType portfolioType) ! { ! this.tickerGroupID = tickerGroupID; ! this.numberOfEligibleTickers = numberOfEligibleTickers; ! this.numberOfTickersToBeChosen = numberOfTickersToBeChosen; ! this.numDaysForOptimizationPeriod = numDaysForOptimizationPeriod; ! this.account = account; ! this.benchmark = benchmark; ! this.orders = new ArrayList(); ! this.chosenTickers = new string[numberOfTickersToBeChosen]; ! this.lastOrderedTickers = new string[numberOfTickersToBeChosen]; ! this.targetReturn = targetReturn; ! this.portfolioType = portfolioType; ! ! } ! ! ! protected virtual void addOrderForTicker(string ticker ) ! { ! string tickerCode = ! GenomeManagerForEfficientPortfolio.GetCleanTickerCode(ticker); ! double cashForSinglePosition = this.account.CashAmount / this.numberOfTickersToBeChosen; ! long quantity = ! Convert.ToInt64( Math.Floor( cashForSinglePosition / this.account.DataStreamer.GetCurrentBid( tickerCode ) ) ); ! Order order; ! if(this.portfolioType == PortfolioType.OnlyShort || ! (this.portfolioType == PortfolioType.ShortAndLong && ! ticker != tickerCode)) ! order = new Order( OrderType.MarketSellShort, new Instrument( tickerCode ) , quantity ); ! else ! order = new Order( OrderType.MarketBuy, new Instrument( tickerCode ) , quantity ); ! ! this.orders.Add(order); ! } ! ! protected virtual void closePosition( ! string ticker ) ! { ! this.account.ClosePosition( ticker ); ! } ! ! protected virtual void closePositions() ! { ! ! if(this.lastOrderedTickers != null) ! { ! foreach( string ticker in this.lastOrderedTickers) ! { ! for(int i = 0; i<this.account.Portfolio.Keys.Count; i++) ! { ! if(this.account.Portfolio[ticker]!=null) ! closePosition( ticker ); ! } ! } ! } ! ! ! } ! ! protected virtual void addChosenTickersToOrderList() ! { ! int idx = 0; ! foreach ( string ticker in this.chosenTickers ) ! { ! if(ticker != null) ! { ! this.addOrderForTicker( ticker ); ! this.lastOrderedTickers[idx] = ! GenomeManagerForEfficientPortfolio.GetCleanTickerCode(ticker); ! } ! idx++; ! } ! } ! ! protected bool openPositions_allChosenTickersQuotedAtCurrentDate() ! { ! bool returnValue = true; ! DateTime currentDate = this.Account.EndOfDayTimer.GetCurrentTime().DateTime; ! foreach(string ticker in this.chosenTickers) ! { ! if(ticker != null) ! { ! Quotes tickerQuotes = new Quotes(GenomeManagerForEfficientPortfolio.GetCleanTickerCode(ticker), ! currentDate, currentDate); ! if(tickerQuotes.Rows.Count == 0) ! //no quote available for the current ticker ! returnValue = false; ! } ! } ! return returnValue; ! } ! ! protected virtual void openPositions() { ! //add cash first ! if(this.orders.Count == 0 && this.account.Transactions.Count == 0) ! this.account.AddCash(17000); ! if(this.openPositions_allChosenTickersQuotedAtCurrentDate()) ! //all tickers have quotes at the current date, so orders can be filled ! { ! this.addChosenTickersToOrderList(); ! //execute orders actually ! foreach(object item in this.orders) ! this.account.AddOrder((Order)item); ! } } ! ! public virtual void MarketOpenEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ; } ! public virtual void MarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ; } ! public virtual void OneHourAfterMarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { --- 41,70 ---- /// </summary> [Serializable] ! public class EndOfDayTimerHandlerSimpleSelection : EndOfDayTimerHandler { ! public EndOfDayTimerHandlerSimpleSelection(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, Account account, string benchmark, double targetReturn, ! PortfolioType portfolioType): ! base(tickerGroupID, numberOfEligibleTickers, ! numberOfTickersToBeChosen, numDaysForOptimizationPeriod, account, ! 0,0, ! benchmark, targetReturn, ! portfolioType) { ! } ! ! public override void MarketOpenEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ; } ! public override void MarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ; } ! public override void OneHourAfterMarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { Index: EndOfDayTimerHandlerSimpleSelectionOpenToClose.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/SimpleSelection/EndOfDayTimerHandlerSimpleSelectionOpenToClose.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** EndOfDayTimerHandlerSimpleSelectionOpenToClose.cs 21 Oct 2005 17:54:11 -0000 1.1 --- EndOfDayTimerHandlerSimpleSelectionOpenToClose.cs 29 Aug 2007 09:43:34 -0000 1.2 *************** *** 29,32 **** --- 29,33 ---- using QuantProject.Business.Financial.Ordering; using QuantProject.Business.Timing; + using QuantProject.Business.Strategies; using QuantProject.Data.DataProviders; using QuantProject.Data.Selectors; *************** *** 43,49 **** public class EndOfDayTimerHandlerSimpleSelectionOpenToClose : EndOfDayTimerHandlerSimpleSelection { ! protected int numDaysBetweenEachOptimization; ! private int numDaysElapsedSinceLastOptimization; ! public EndOfDayTimerHandlerSimpleSelectionOpenToClose(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, Account account, --- 44,48 ---- public class EndOfDayTimerHandlerSimpleSelectionOpenToClose : EndOfDayTimerHandlerSimpleSelection { ! public EndOfDayTimerHandlerSimpleSelectionOpenToClose(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, Account account, *************** *** 68,72 **** Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! this.closePositions(); } --- 67,71 ---- Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! AccountManager.ClosePositions(this.account); } *************** *** 115,119 **** DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); ! if(setOfTickersToBeOptimized.Rows.Count >= this.chosenTickers.Length) //the optimization process is possible only if the initial set of tickers is //as large as the number of tickers to be chosen --- 114,118 ---- DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); ! if(setOfTickersToBeOptimized.Rows.Count >= this.numberOfTickersToBeChosen) //the optimization process is possible only if the initial set of tickers is //as large as the number of tickers to be chosen *************** *** 125,129 **** currentDate, this.targetReturn, this.portfolioType); ! this.chosenTickers = OTCScreener.GetBestTickers(this.numberOfTickersToBeChosen); } //else it will be buyed again the previous optimized portfolio --- 124,128 ---- currentDate, this.targetReturn, this.portfolioType); ! this.chosenWeightedPositions = new WeightedPositions(OTCScreener.GetBestTickers(this.numberOfTickersToBeChosen)); } //else it will be buyed again the previous optimized portfolio *************** *** 148,153 **** Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { - this.orders.Clear(); - //this.oneHourAfterMarketCloseEventHandler_updatePrices(); if(this.numDaysElapsedSinceLastOptimization == this.numDaysBetweenEachOptimization - 1) --- 147,150 ---- |
|
From: Marco M. <mi...@us...> - 2007-08-29 09:44:15
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/TestingOTCTypes/BruteForceOptimization In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv10276/b7_Scripts/TickerSelectionTesting/TestingOTCTypes/BruteForceOptimization Modified Files: EndOfDayTimerHandlerOTCTypesBruteForce.cs Log Message: Code has been re-organized in a more logical and Object Oriented way: - WeightedPositions class has been used. - Some static methods have been deleted from SignedTicker class. They have been moved to WeightedPositions. - Basic orders'management has been moved to the primitive base class EndOfDayTimerHandler and to AccountManager class Index: EndOfDayTimerHandlerOTCTypesBruteForce.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/TestingOTCTypes/BruteForceOptimization/EndOfDayTimerHandlerOTCTypesBruteForce.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** EndOfDayTimerHandlerOTCTypesBruteForce.cs 3 Jan 2007 23:01:52 -0000 1.2 --- EndOfDayTimerHandlerOTCTypesBruteForce.cs 29 Aug 2007 09:43:34 -0000 1.3 *************** *** 48,56 **** public class EndOfDayTimerHandlerOTCTypesBruteForce : EndOfDayTimerHandler { - private int numDaysBetweenEachOptimization; - private int numDaysElapsedSinceLastOptimization; private int seedForRandomGenerator; private Account[] accounts; - private string[,] lastOrderedTickersForTheAccount; int numOfClosesWithOpenPositionsFor2DaysStrategy; --- 48,53 ---- *************** *** 71,76 **** this.seedForRandomGenerator = ConstantsProvider.SeedForRandomGenerator; this.accounts = accounts; - this.lastOrderedTickersForTheAccount = new string[this.accounts.Length, - this.numberOfTickersToBeChosen]; } --- 68,71 ---- *************** *** 78,156 **** { if(this.accounts[accountNumber].Portfolio.Count == 0) ! { ! this.orders.Clear(); ! this.addChosenTickersToOrderListForTheGivenAccount(accountNumber); ! for(int i = 0; i<this.orders.Count;i++) ! { ! this.accounts[accountNumber].AddOrder((Order)this.orders[i]); ! this.lastOrderedTickersForTheAccount[accountNumber, i] = ! SignedTicker.GetTicker(((Order)this.orders[i]).Instrument.Key); ! } ! } ! } ! ! protected void addOrderForTickerForTheGivenAccount(int tickerPosition, ! int accountNumber ) ! { ! string tickerCode = ! GenomeManagerForEfficientPortfolio.GetCleanTickerCode(this.chosenTickers[tickerPosition]); ! double cashForSinglePosition = ! this.accounts[accountNumber].CashAmount * this.chosenTickersPortfolioWeights[tickerPosition]; ! long quantity = ! Convert.ToInt64( Math.Floor( cashForSinglePosition / this.accounts[accountNumber].DataStreamer.GetCurrentBid( tickerCode ) ) ); ! Order order; ! if(this.portfolioType == PortfolioType.OnlyShort || ! (this.portfolioType == PortfolioType.ShortAndLong && ! this.chosenTickers[tickerPosition] != tickerCode)) ! order = new Order( OrderType.MarketSellShort, new Instrument( tickerCode ) , quantity ); ! else ! order = new Order( OrderType.MarketBuy, new Instrument( tickerCode ) , quantity ); ! ! this.orders.Add(order); ! } ! ! protected void addChosenTickersToOrderListForTheGivenAccount(int accountNumber) ! { ! for( int i = 0; i<this.chosenTickers.Length; i++) ! { ! if(this.chosenTickers[i] != null) ! this.addOrderForTickerForTheGivenAccount( i, accountNumber ); ! } } - private void closePositionsForTheAccount(int accountNumber) { ! string ticker; ! if(this.accounts[accountNumber].Portfolio.Count >0) ! { ! for(int j = 0; j<this.numberOfTickersToBeChosen; j++) ! { ! ticker = this.lastOrderedTickersForTheAccount[accountNumber, j]; ! if( ticker != null) ! { ! if(this.accounts[accountNumber].Portfolio[ticker]!=null) ! this.accounts[accountNumber].ClosePosition(ticker); ! } ! } ! } } private void marketCloseEventHandler_reversePositionsForTheAccount(int accountNumber) { ! this.closePositionsForTheAccount(accountNumber); ! SignedTicker.ChangeSignOfEachTicker(this.chosenTickers); ! try ! { ! this.openPositionsForTheAccountWhenPortfolioIsEmpty(accountNumber); ! } ! catch(Exception ex) ! { ! ex = ex; ! } ! finally ! { ! SignedTicker.ChangeSignOfEachTicker(this.chosenTickers); ! } } --- 73,87 ---- { if(this.accounts[accountNumber].Portfolio.Count == 0) ! AccountManager.OpenPositions(this.chosenWeightedPositions, this.accounts[accountNumber]); } private void closePositionsForTheAccount(int accountNumber) { ! AccountManager.ClosePositions(this.accounts[accountNumber]); } private void marketCloseEventHandler_reversePositionsForTheAccount(int accountNumber) { ! AccountManager.ReversePositions(this.accounts[accountNumber]); } *************** *** 166,171 **** { //add cash first for each account ! if(this.orders.Count == 0 && this.accounts[i].Transactions.Count == 0) ! this.accounts[i].AddCash(30000); if(i<=1)//daily classical and multiday --- 97,102 ---- { //add cash first for each account ! if( this.accounts[i].Transactions.Count == 0) ! this.accounts[i].AddCash(15000); if(i<=1)//daily classical and multiday *************** *** 207,213 **** } } ! ! ! #region OneHourAfterMarketCloseEventHandler --- 138,142 ---- } } ! #region OneHourAfterMarketCloseEventHandler *************** *** 250,254 **** DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); ! if(setOfTickersToBeOptimized.Rows.Count > this.chosenTickers.Length*2) //the optimization process is possible only if the initial set of tickers is //as large as the number of tickers to be chosen --- 179,183 ---- DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); ! if(setOfTickersToBeOptimized.Rows.Count > this.numberOfTickersToBeChosen*2) //the optimization process is possible only if the initial set of tickers is //as large as the number of tickers to be chosen *************** *** 260,274 **** setOfTickersToBeOptimized, currentDate.AddDays(-this.numDaysForOptimizationPeriod), ! currentDate,this.chosenTickers.Length); BruteForceOptimizer BFO = new BruteForceOptimizer(otcBruteForceParamManager); BFO.Run(); - this.chosenTickers = - ((GenomeMeaning)otcBruteForceParamManager.Decode(BFO.BestParameters)).Tickers; //this.setTickers_getChosenTickers(BFO.BestParameters); ! this.addGenomeToBestGenomes(BFO.BestParameters,this.chosenTickers, currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate,setOfTickersToBeOptimized.Rows.Count); ! this.chosenTickersPortfolioWeights = this.setTickers_getWeights(this.chosenTickers); } --- 189,202 ---- setOfTickersToBeOptimized, currentDate.AddDays(-this.numDaysForOptimizationPeriod), ! currentDate,this.numberOfTickersToBeChosen); BruteForceOptimizer BFO = new BruteForceOptimizer(otcBruteForceParamManager); BFO.Run(); //this.setTickers_getChosenTickers(BFO.BestParameters); ! this.addGenomeToBestGenomes(BFO.BestParameters,this.chosenWeightedPositions.SignedTickers, currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate,setOfTickersToBeOptimized.Rows.Count); ! this.chosenWeightedPositions = ! new WeightedPositions(new SignedTickers(((GenomeMeaning)otcBruteForceParamManager.Decode(BFO.BestParameters)).Tickers)); } *************** *** 286,290 **** { this.seedForRandomGenerator++; - this.orders.Clear(); if(this.numDaysElapsedSinceLastOptimization == this.numDaysBetweenEachOptimization - 1) --- 214,217 ---- *************** *** 298,304 **** this.numDaysElapsedSinceLastOptimization++; } - } - #endregion --- 225,229 ---- |