quantproject-developers Mailing List for QuantProject (Page 103)
Brought to you by:
glauco_1
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(7) |
Nov
(103) |
Dec
(67) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(52) |
Feb
(9) |
Mar
(69) |
Apr
(53) |
May
(80) |
Jun
(23) |
Jul
(24) |
Aug
(112) |
Sep
(9) |
Oct
|
Nov
(58) |
Dec
(93) |
| 2005 |
Jan
(90) |
Feb
(93) |
Mar
(61) |
Apr
(56) |
May
(37) |
Jun
(61) |
Jul
(55) |
Aug
(68) |
Sep
(25) |
Oct
(46) |
Nov
(41) |
Dec
(37) |
| 2006 |
Jan
(33) |
Feb
(7) |
Mar
(19) |
Apr
(27) |
May
(73) |
Jun
(49) |
Jul
(83) |
Aug
(66) |
Sep
(45) |
Oct
(16) |
Nov
(15) |
Dec
(7) |
| 2007 |
Jan
(14) |
Feb
(33) |
Mar
|
Apr
(21) |
May
|
Jun
(34) |
Jul
(18) |
Aug
(100) |
Sep
(39) |
Oct
(55) |
Nov
(12) |
Dec
(2) |
| 2008 |
Jan
(120) |
Feb
(133) |
Mar
(129) |
Apr
(104) |
May
(42) |
Jun
(2) |
Jul
(52) |
Aug
(99) |
Sep
(134) |
Oct
|
Nov
(137) |
Dec
(48) |
| 2009 |
Jan
(48) |
Feb
(55) |
Mar
(61) |
Apr
(3) |
May
(2) |
Jun
(1) |
Jul
|
Aug
(51) |
Sep
|
Oct
(7) |
Nov
|
Dec
|
| 2010 |
Jan
(7) |
Feb
(1) |
Mar
(145) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(8) |
Dec
|
| 2011 |
Jan
(78) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(88) |
Sep
(6) |
Oct
(1) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
(1) |
Mar
|
Apr
(6) |
May
(5) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2013 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
| 2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Marco M. <mi...@us...> - 2005-08-03 19:00:06
|
Update of /cvsroot/quantproject/QuantProject/b3_Data In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13545/b3_Data Modified Files: Data.prjx Log Message: Updated #develop projects files. Index: Data.prjx =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/Data.prjx,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Data.prjx 24 Jun 2005 22:54:50 -0000 1.7 --- Data.prjx 3 Aug 2005 18:59:57 -0000 1.8 *************** *** 38,41 **** --- 38,42 ---- <File name=".\DataProviders\Caching\CachePage.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> <File name=".\DataProviders\Caching\MissingQuoteException.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\Selectors\SelectorByGroup.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> </Contents> <References> |
|
From: Marco M. <mi...@us...> - 2005-08-03 19:00:06
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13545/b7_Scripts Modified Files: Scripts.prjx Log Message: Updated #develop projects files. Index: Scripts.prjx =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/Scripts.prjx,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Scripts.prjx 27 Jul 2005 22:37:14 -0000 1.8 --- Scripts.prjx 3 Aug 2005 18:59:58 -0000 1.9 *************** *** 47,50 **** --- 47,51 ---- <File name=".\TickerSelectionTesting\EndOfDayTimerHandlerCTCWeekly.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> <File name=".\TickerSelectionTesting\RunEfficientCTCWeeklyPortfolio.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\TickerSelectionTesting\GenomeManipulator.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> </Contents> <References> |
|
From: Marco M. <mi...@us...> - 2005-08-03 18:59:28
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13377/b7_Scripts/TickerSelectionTesting Modified Files: GenomeManipulator.cs Log Message: MixGenesWithoutDuplicates has been definitively fixed (I hope ...). Now, a complete crossover (with an alternate fixed pattern) takes place when all parents' genes are different. A partial crossover (or no crossover at all, if parents are equal) takes place if some genes are duplicated. Index: GenomeManipulator.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/GenomeManipulator.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** GenomeManipulator.cs 31 Jul 2005 19:53:44 -0000 1.1 --- GenomeManipulator.cs 3 Aug 2005 18:59:19 -0000 1.2 *************** *** 53,58 **** childs[0] = parent1.Clone(); childs[1] = parent2.Clone(); ! //the two childs now points to their parents maskForChilds = new int[childs.Length, genomeSize]; } --- 53,64 ---- childs[0] = parent1.Clone(); childs[1] = parent2.Clone(); ! //the two childs now points to their parents, ! //and so do maskForChilds maskForChilds = new int[childs.Length, genomeSize]; + for(int i = 0; i<genomeSize; i++) + { + maskForChilds[0,i]=1; + maskForChilds[1,i]=2; + } } *************** *** 146,181 **** } ! private static bool setMaskForChildsForMixingWithoutDuplicates(Genome parent1, Genome parent2) { - bool returnValue = false; int[] genePlacesOfParent1NotPresentInParent2 = genePositionsOfParent1NotPresentInParent2(parent1, parent2); int[] genePlacesOfParent2NotPresentInParent1 = genePositionsOfParent1NotPresentInParent2(parent2, parent1); ! for(int i = 0; i<genePlacesOfParent1NotPresentInParent2.Length; i++) { ! for(int genePos = 0 ; genePos < GenomeManipulator.genomeSize ; genePos++) ! { ! if(genePos == genePlacesOfParent1NotPresentInParent2[i]) ! { ! maskForChilds[0, genePos] = 1; ! returnValue = true; ! } ! else ! maskForChilds[0, genePos] = 2; ! ! if(genePos == genePlacesOfParent2NotPresentInParent1[i]) ! { ! maskForChilds[1, genePos] = 2; ! returnValue = true; ! } ! else ! maskForChilds[1, genePos] = 1; } } - return returnValue; } ! private static void setChildsUsingMaskForChilds(Genome parent1, Genome parent2) { --- 152,182 ---- } ! private static void setMaskForChildsForMixingWithoutDuplicates(Genome parent1, Genome parent2) { int[] genePlacesOfParent1NotPresentInParent2 = genePositionsOfParent1NotPresentInParent2(parent1, parent2); int[] genePlacesOfParent2NotPresentInParent1 = genePositionsOfParent1NotPresentInParent2(parent2, parent1); ! for(int i = 0;i<parent1.Size;i++) { ! if(i%2 == 0) ! //genes are ex-changed only at even positions ! { ! if(genePlacesOfParent2NotPresentInParent1[i]!= - 1) ! { ! maskForChilds[0, i] = 2;//the change between genes ! maskForChilds[1, i] = 1;//creates a child different from parents ! } ! else if(genePlacesOfParent1NotPresentInParent2[i]!= - 1) //see 1st if ! { ! maskForChilds[0, i] = 1; ! maskForChilds[1, i] = 2; ! } } } } ! ! private static void setChildsUsingMaskForChilds(Genome parent1, Genome parent2) { *************** *** 238,243 **** throw new Exception("Genomes must have the same size!"); ! if(setMaskForChildsForMixingWithoutDuplicates(parent1, parent2)) ! setChildsUsingMaskForChilds(parent1, parent2); //throwExcIfAChildHasDuplicateGenes(); //just for debugging purposes return childs; --- 239,244 ---- throw new Exception("Genomes must have the same size!"); ! setMaskForChildsForMixingWithoutDuplicates(parent1, parent2); ! setChildsUsingMaskForChilds(parent1, parent2); //throwExcIfAChildHasDuplicateGenes(); //just for debugging purposes return childs; |
|
From: Marco M. <mi...@us...> - 2005-08-03 18:55:24
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12281/b7_Scripts/TickerSelectionTesting Modified Files: RunEfficientPortfolio.cs RunTestOptimizedCTCPortfolio.cs RunTestOptimizedCTOPortfolio.cs Log Message: Restored previous code: OptimizationOutput has been deleted from Account. SaveGenomes MenuItem has been deleted from Report. RunEfficientPortfolio now archives Genomes as previously. Index: RunTestOptimizedCTOPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunTestOptimizedCTOPortfolio.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** RunTestOptimizedCTOPortfolio.cs 1 Aug 2005 22:31:48 -0000 1.7 --- RunTestOptimizedCTOPortfolio.cs 3 Aug 2005 18:55:11 -0000 1.8 *************** *** 110,116 **** { this.endOfDayTimer.Stop(); - this.account.OptimizationOutput = (object) new OptimizationOutput(this.startDateTime.DateTime, - this.endDateTime.DateTime, - this.endOfDayTimerHandler.BestGenomes); } --- 110,113 ---- Index: RunEfficientPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunEfficientPortfolio.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** RunEfficientPortfolio.cs 1 Aug 2005 22:31:48 -0000 1.12 --- RunEfficientPortfolio.cs 3 Aug 2005 18:55:11 -0000 1.13 *************** *** 244,254 **** // this.checkDateForReport_createDirIfNotPresent(dirNameWhereToSaveBestGenomes); ! this.account.OptimizationOutput = (object) new OptimizationOutput(this.startDateTime.DateTime, ! this.endDateTime.DateTime, ! this.endOfDayTimerHandler.BestGenomes); ! ObjectArchiver.Archive((OptimizationOutput)this.account.OptimizationOutput, dirNameWhereToSaveBestGenomes + fileName + ".bgn"); - //this.account.BestGenomes = this.endOfDayTimerHandler.BestGenomes; this.endOfDayTimer.Stop(); --- 244,252 ---- // this.checkDateForReport_createDirIfNotPresent(dirNameWhereToSaveBestGenomes); ! ObjectArchiver.Archive(new OptimizationOutput(this.startDateTime.DateTime, ! this.endDateTime.DateTime, ! this.endOfDayTimerHandler.BestGenomes), dirNameWhereToSaveBestGenomes + fileName + ".bgn"); this.endOfDayTimer.Stop(); Index: RunTestOptimizedCTCPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunTestOptimizedCTCPortfolio.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** RunTestOptimizedCTCPortfolio.cs 1 Aug 2005 22:31:48 -0000 1.5 --- RunTestOptimizedCTCPortfolio.cs 3 Aug 2005 18:55:11 -0000 1.6 *************** *** 119,125 **** { this.endOfDayTimer.Stop(); - this.account.OptimizationOutput = (object) new OptimizationOutput(this.startDateTime.DateTime, - this.endDateTime.DateTime, - this.endOfDayTimerHandler.BestGenomes); } --- 119,122 ---- |
|
From: Marco M. <mi...@us...> - 2005-08-03 18:55:22
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12281/b4_Business/a1_Financial/a2_Accounting Modified Files: Account.cs Log Message: Restored previous code: OptimizationOutput has been deleted from Account. SaveGenomes MenuItem has been deleted from Report. RunEfficientPortfolio now archives Genomes as previously. Index: Account.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/Account.cs,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Account.cs 31 Jul 2005 20:10:28 -0000 1.19 --- Account.cs 3 Aug 2005 18:55:10 -0000 1.20 *************** *** 60,64 **** private ArrayList activeOrders; private AccountReport accountReport; - private object optimizationOutput = null; --- 60,63 ---- *************** *** 94,107 **** set { accountStrategy = value; } } ! /// <summary> ! /// the object contain a representation of the ! /// optimization working of the script ! /// </summary> ! public object OptimizationOutput ! { ! get { return this.optimizationOutput; } ! set { this.optimizationOutput = value; } ! } ! public TransactionHistory Transactions = new TransactionHistory(); --- 93,97 ---- set { accountStrategy = value; } } ! public TransactionHistory Transactions = new TransactionHistory(); |
|
From: Marco M. <mi...@us...> - 2005-08-03 18:55:22
|
Update of /cvsroot/quantproject/QuantProject/b5_Presentation/Reporting/WindowsForm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12281/b5_Presentation/Reporting/WindowsForm Modified Files: Report.cs Log Message: Restored previous code: OptimizationOutput has been deleted from Account. SaveGenomes MenuItem has been deleted from Report. RunEfficientPortfolio now archives Genomes as previously. Index: Report.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b5_Presentation/Reporting/WindowsForm/Report.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Report.cs 1 Aug 2005 22:27:31 -0000 1.15 --- Report.cs 3 Aug 2005 18:55:10 -0000 1.16 *************** *** 47,51 **** private System.Windows.Forms.MenuItem saveReport; private System.Windows.Forms.MenuItem saveTransactions; - private System.Windows.Forms.MenuItem saveGenomes; private SaveFileDialog saveFileDialog; --- 47,50 ---- *************** *** 92,98 **** this.saveTransactions.Text = "Save Transactions"; - this.saveGenomes = new MenuItem(); - this.saveGenomes.Text = "Save Genomes"; - this.file = new MenuItem(); this.file.Text = "File"; --- 91,94 ---- *************** *** 103,113 **** {this.saveAccount, this.saveReport, ! this.saveTransactions, ! this.saveGenomes}); this.Menu = this.mainMenu; this.saveAccount.Click += new System.EventHandler(this.saveAccount_Click); this.saveReport.Click += new System.EventHandler(this.saveReport_Click); this.saveTransactions.Click += new System.EventHandler(this.saveTransactions_Click); - this.saveGenomes.Click += new System.EventHandler(this.saveGenomes_Click); } --- 99,107 ---- {this.saveAccount, this.saveReport, ! this.saveTransactions}); this.Menu = this.mainMenu; this.saveAccount.Click += new System.EventHandler(this.saveAccount_Click); this.saveReport.Click += new System.EventHandler(this.saveReport_Click); this.saveTransactions.Click += new System.EventHandler(this.saveTransactions_Click); } *************** *** 177,181 **** } ! #region save account or report or transactions or genomes private void saveAccount_Click(object sender, System.EventArgs e) --- 171,175 ---- } ! #region save account or report or transactions private void saveAccount_Click(object sender, System.EventArgs e) *************** *** 195,203 **** } - private void saveGenomes_Click(object sender, System.EventArgs e) - { - this.saveObject((MenuItem)sender); - } - private void saveObject_setSaveFileDialog(MenuItem sender) { --- 189,192 ---- *************** *** 225,235 **** this.saveFileDialog.DefaultExt = "qPt"; } ! else if(sender.Text.EndsWith("Genomes")) ! //else the text property of the menu item sender contains at the end ! // the word "Genomes"; so it will be saved an OptimizationOutput ! //containing a GenomeRepresentation ! { ! this.saveFileDialog.DefaultExt = "bgn"; ! } this.saveFileDialog.AddExtension = true; this.saveFileDialog.CreatePrompt = true; --- 214,218 ---- this.saveFileDialog.DefaultExt = "qPt"; } ! this.saveFileDialog.AddExtension = true; this.saveFileDialog.CreatePrompt = true; *************** *** 259,265 **** QuantProject.ADT.FileManaging.ObjectArchiver.Archive(this.account.Transactions, this.saveFileDialog.FileName); - else if(((SaveFileDialog)sender).Title.EndsWith("Genomes")) - QuantProject.ADT.FileManaging.ObjectArchiver.Archive(this.account.OptimizationOutput, - this.saveFileDialog.FileName); } --- 242,245 ---- |
|
From: Glauco S. <gla...@us...> - 2005-08-02 23:13:09
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14944/b7_Scripts/WalkForwardTesting/LinearCombination Modified Files: LinearCombinationTest.cs Log Message: - Added radio buttons to switch between daily and weekly strategy - Bug fixed: HistoricalAdjustedQuoteProvider is used for weekly strategies, now Index: LinearCombinationTest.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination/LinearCombinationTest.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LinearCombinationTest.cs 23 Jul 2005 17:57:01 -0000 1.1 --- LinearCombinationTest.cs 2 Aug 2005 23:12:59 -0000 1.2 *************** *** 28,31 **** --- 28,32 ---- using QuantProject.Business.Financial.Instruments; using QuantProject.Business.Financial.Ordering; + using QuantProject.Business.Strategies; using QuantProject.Business.Timing; using QuantProject.Presentation.Reporting.WindowsForm; *************** *** 43,107 **** private DateTime lastDate; private string[] signedTickers; ! private HistoricalRawQuoteProvider historicalQuoteProvider; private HistoricalEndOfDayTimer historicalEndOfDayTimer; private Account account; public LinearCombinationTest( DateTime firstDate , DateTime lastDate , ! string[] signedTickers ) { this.firstDate = firstDate; this.lastDate = lastDate; this.signedTickers = signedTickers; ! } ! private long marketOpenEventHandler_addOrder_getQuantity( ! string ticker ) ! { ! double accountValue = this.account.GetMarketValue(); ! double currentTickerAsk = ! this.account.DataStreamer.GetCurrentAsk( ticker ); ! double maxPositionValueForThisTicker = ! accountValue/this.signedTickers.Length; ! long quantity = Convert.ToInt64( Math.Floor( ! maxPositionValueForThisTicker / currentTickerAsk ) ); ! return quantity; ! } ! private void marketOpenEventHandler_addOrder( string signedTicker ) ! { ! OrderType orderType = GenomeRepresentation.GetOrderType( signedTicker ); ! string ticker = GenomeRepresentation.GetTicker( signedTicker ); ! long quantity = marketOpenEventHandler_addOrder_getQuantity( ticker ); ! Order order = new Order( orderType , new Instrument( ticker ) , ! quantity ); ! this.account.AddOrder( order ); ! } ! private void marketOpenEventHandler_addOrders() ! { ! foreach ( string signedTicker in this.signedTickers ) ! marketOpenEventHandler_addOrder( signedTicker ); ! } ! private void marketOpenEventHandler( ! Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) ! { ! if ( ( this.account.CashAmount == 0 ) && ! ( this.account.Transactions.Count == 0 ) ) ! // cash has not been added yet ! this.account.AddCash( 30000 ); ! marketOpenEventHandler_addOrders(); } - private void fiveMinutesBeforeMarketCloseEventHandler_closePositions() - { - ArrayList tickers = new ArrayList(); - foreach ( Position position in this.account.Portfolio.Positions ) - tickers.Add( position.Instrument.Key ); - foreach ( string ticker in tickers ) - this.account.ClosePosition( ticker ); - } - private void fiveMinutesBeforeMarketCloseEventHandler( Object sender , - EndOfDayTimingEventArgs endOfDayTimingEventArgs) - { - fiveMinutesBeforeMarketCloseEventHandler_closePositions(); - } private void oneHourAfterMarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) --- 44,63 ---- private DateTime lastDate; private string[] signedTickers; + private bool openToCloseDaily; ! private IHistoricalQuoteProvider historicalQuoteProvider; private HistoricalEndOfDayTimer historicalEndOfDayTimer; private Account account; + private IEndOfDayStrategy endOfDayStrategy; public LinearCombinationTest( DateTime firstDate , DateTime lastDate , ! string[] signedTickers , bool openToCloseDaily ) { this.firstDate = firstDate; this.lastDate = lastDate; this.signedTickers = signedTickers; ! this.openToCloseDaily = openToCloseDaily; } private void oneHourAfterMarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) *************** *** 112,115 **** --- 68,87 ---- } + private void run_setHistoricalQuoteProvider() + { + if ( this.openToCloseDaily ) + this.historicalQuoteProvider = new HistoricalRawQuoteProvider(); + else + this.historicalQuoteProvider = new HistoricalAdjustedQuoteProvider(); + } + private void run_setStrategy() + { + if ( this.openToCloseDaily ) + this.endOfDayStrategy = new OpenToCloseDailyStrategy( + this.account , this.signedTickers ); + else + this.endOfDayStrategy = new OpenToCloseWeeklyStrategy( + this.account , this.signedTickers ); + } public void Run() { *************** *** 118,123 **** new EndOfDayDateTime( this.firstDate , EndOfDaySpecificTime.MarketOpen ) , "DYN" ); ! this.historicalQuoteProvider = ! new HistoricalRawQuoteProvider(); this.account = new Account( "LinearCombination" , historicalEndOfDayTimer , new HistoricalEndOfDayDataStreamer( historicalEndOfDayTimer , --- 90,94 ---- new EndOfDayDateTime( this.firstDate , EndOfDaySpecificTime.MarketOpen ) , "DYN" ); ! run_setHistoricalQuoteProvider(); this.account = new Account( "LinearCombination" , historicalEndOfDayTimer , new HistoricalEndOfDayDataStreamer( historicalEndOfDayTimer , *************** *** 125,136 **** new HistoricalEndOfDayOrderExecutor( historicalEndOfDayTimer , this.historicalQuoteProvider ) ); // OneRank oneRank = new OneRank( account , // this.endDateTime ); this.historicalEndOfDayTimer.MarketOpen += new MarketOpenEventHandler( ! this.marketOpenEventHandler ); this.historicalEndOfDayTimer.FiveMinutesBeforeMarketClose += new FiveMinutesBeforeMarketCloseEventHandler( ! this.fiveMinutesBeforeMarketCloseEventHandler ); this.historicalEndOfDayTimer.OneHourAfterMarketClose += new OneHourAfterMarketCloseEventHandler( --- 96,108 ---- new HistoricalEndOfDayOrderExecutor( historicalEndOfDayTimer , this.historicalQuoteProvider ) ); + run_setStrategy(); // OneRank oneRank = new OneRank( account , // this.endDateTime ); this.historicalEndOfDayTimer.MarketOpen += new MarketOpenEventHandler( ! this.endOfDayStrategy.MarketOpenEventHandler ); this.historicalEndOfDayTimer.FiveMinutesBeforeMarketClose += new FiveMinutesBeforeMarketCloseEventHandler( ! this.endOfDayStrategy.FiveMinutesBeforeMarketCloseEventHandler ); this.historicalEndOfDayTimer.OneHourAfterMarketClose += new OneHourAfterMarketCloseEventHandler( |
|
From: Glauco S. <gla...@us...> - 2005-08-02 23:10:43
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14601/b7_Scripts/WalkForwardTesting/LinearCombination Modified Files: TestDisplayer.cs Log Message: Added radio buttons to switch between daily and weekly strategy Index: TestDisplayer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination/TestDisplayer.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TestDisplayer.cs 29 Jul 2005 13:32:34 -0000 1.3 --- TestDisplayer.cs 2 Aug 2005 23:10:35 -0000 1.4 *************** *** 46,49 **** --- 46,51 ---- private ArrayList bestGenomes; private System.Windows.Forms.Label label1; + private System.Windows.Forms.RadioButton radioButtonOpenToCloseDaily; + private System.Windows.Forms.RadioButton radioButtonOpenToCloseWeekly; private GenomeRepresentation lastSelectedGenomeRepresentation; *************** *** 100,103 **** --- 102,107 ---- this.dtpLastDate = new System.Windows.Forms.DateTimePicker(); this.label1 = new System.Windows.Forms.Label(); + this.radioButtonOpenToCloseDaily = new System.Windows.Forms.RadioButton(); + this.radioButtonOpenToCloseWeekly = new System.Windows.Forms.RadioButton(); ((System.ComponentModel.ISupportInitialize)(this.dgBestGenomes)).BeginInit(); this.SuspendLayout(); *************** *** 108,114 **** this.dgBestGenomes.Dock = System.Windows.Forms.DockStyle.Bottom; this.dgBestGenomes.HeaderForeColor = System.Drawing.SystemColors.ControlText; ! this.dgBestGenomes.Location = new System.Drawing.Point(0, 117); this.dgBestGenomes.Name = "dgBestGenomes"; ! this.dgBestGenomes.Size = new System.Drawing.Size(496, 224); this.dgBestGenomes.TabIndex = 0; this.dgBestGenomes.MouseUp += new System.Windows.Forms.MouseEventHandler(this.dgBestGenomes_MouseUp); --- 112,118 ---- this.dgBestGenomes.Dock = System.Windows.Forms.DockStyle.Bottom; this.dgBestGenomes.HeaderForeColor = System.Drawing.SystemColors.ControlText; ! this.dgBestGenomes.Location = new System.Drawing.Point(0, 125); this.dgBestGenomes.Name = "dgBestGenomes"; ! this.dgBestGenomes.Size = new System.Drawing.Size(520, 248); this.dgBestGenomes.TabIndex = 0; this.dgBestGenomes.MouseUp += new System.Windows.Forms.MouseEventHandler(this.dgBestGenomes_MouseUp); *************** *** 136,144 **** "to preserve date displacements and backtest."; // // TestDisplayer // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); ! this.ClientSize = new System.Drawing.Size(496, 341); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.label1, this.dtpLastDate, --- 140,168 ---- "to preserve date displacements and backtest."; // + // radioButtonOpenToCloseDaily + // + this.radioButtonOpenToCloseDaily.Checked = true; + this.radioButtonOpenToCloseDaily.Location = new System.Drawing.Point(64, 96); + this.radioButtonOpenToCloseDaily.Name = "radioButtonOpenToCloseDaily"; + this.radioButtonOpenToCloseDaily.Size = new System.Drawing.Size(144, 24); + this.radioButtonOpenToCloseDaily.TabIndex = 4; + this.radioButtonOpenToCloseDaily.TabStop = true; + this.radioButtonOpenToCloseDaily.Text = "Open To Close Daily"; + // + // radioButtonOpenToCloseWeekly + // + this.radioButtonOpenToCloseWeekly.Location = new System.Drawing.Point(224, 96); + this.radioButtonOpenToCloseWeekly.Name = "radioButtonOpenToCloseWeekly"; + this.radioButtonOpenToCloseWeekly.Size = new System.Drawing.Size(144, 24); + this.radioButtonOpenToCloseWeekly.TabIndex = 5; + this.radioButtonOpenToCloseWeekly.Text = "Open To Close Weekly"; + // // TestDisplayer // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); ! this.ClientSize = new System.Drawing.Size(520, 373); this.Controls.AddRange(new System.Windows.Forms.Control[] { + this.radioButtonOpenToCloseWeekly, + this.radioButtonOpenToCloseDaily, this.label1, this.dtpLastDate, *************** *** 199,203 **** LinearCombinationTest linearCombinationTest = new LinearCombinationTest( this.dtpFirstDate.Value , ! this.dtpLastDate.Value , signedTickers ); linearCombinationTest.Run(); this.lastSelectedGenomeRepresentation = genomeRepresentation; --- 223,228 ---- LinearCombinationTest linearCombinationTest = new LinearCombinationTest( this.dtpFirstDate.Value , ! this.dtpLastDate.Value , signedTickers , ! this.radioButtonOpenToCloseDaily.Checked ); linearCombinationTest.Run(); this.lastSelectedGenomeRepresentation = genomeRepresentation; |
|
From: Glauco S. <gla...@us...> - 2005-08-02 23:08:40
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14144/b7_Scripts/WalkForwardTesting/LinearCombination Added Files: OpenToCloseDailyStrategy.cs Log Message: Open to close daily strategy --- NEW FILE: OpenToCloseDailyStrategy.cs --- /* QuantProject - Quantitative Finance Library OpenToCloseDailyStrategy.cs Copyright (C) 2003 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Collections; using QuantProject.Business.Financial.Accounting; using QuantProject.Business.Financial.Instruments; using QuantProject.Business.Financial.Ordering; using QuantProject.Business.Strategies; using QuantProject.Business.Timing; namespace QuantProject.Scripts.WalkForwardTesting.LinearCombination { /// <summary> /// Open to close daily strategy /// </summary> [Serializable] public class OpenToCloseDailyStrategy : IEndOfDayStrategy { private Account account; private string[] signedTickers; public OpenToCloseDailyStrategy( Account account , string[] signedTickers) { this.account = account; this.signedTickers = signedTickers; } private long marketOpenEventHandler_addOrder_getQuantity( string ticker ) { double accountValue = this.account.GetMarketValue(); double currentTickerAsk = this.account.DataStreamer.GetCurrentAsk( ticker ); double maxPositionValueForThisTicker = accountValue/this.signedTickers.Length; long quantity = Convert.ToInt64( Math.Floor( maxPositionValueForThisTicker / currentTickerAsk ) ); return quantity; } private void marketOpenEventHandler_addOrder( string signedTicker ) { OrderType orderType = GenomeRepresentation.GetOrderType( signedTicker ); string ticker = GenomeRepresentation.GetTicker( signedTicker ); long quantity = marketOpenEventHandler_addOrder_getQuantity( ticker ); Order order = new Order( orderType , new Instrument( ticker ) , quantity ); this.account.AddOrder( order ); } private void marketOpenEventHandler_addOrders() { foreach ( string signedTicker in this.signedTickers ) marketOpenEventHandler_addOrder( signedTicker ); } public void MarketOpenEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { if ( ( this.account.CashAmount == 0 ) && ( this.account.Transactions.Count == 0 ) ) // cash has not been added yet this.account.AddCash( 30000 ); marketOpenEventHandler_addOrders(); } private void fiveMinutesBeforeMarketCloseEventHandler_closePositions() { ArrayList tickers = new ArrayList(); foreach ( Position position in this.account.Portfolio.Positions ) tickers.Add( position.Instrument.Key ); foreach ( string ticker in tickers ) this.account.ClosePosition( ticker ); } public void FiveMinutesBeforeMarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs) { this.fiveMinutesBeforeMarketCloseEventHandler_closePositions(); } public void MarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs) { } public void OneHourAfterMarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs) { } } } |
|
From: Glauco S. <gla...@us...> - 2005-08-02 23:08:07
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14045/b7_Scripts/WalkForwardTesting/LinearCombination Added Files: OpenToCloseWeeklyStrategy.cs Log Message: Open to close weekly strategy --- NEW FILE: OpenToCloseWeeklyStrategy.cs --- /* QuantProject - Quantitative Finance Library OpenToCloseWeeklyStrategy.cs Copyright (C) 2003 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Collections; using QuantProject.Business.Financial.Accounting; using QuantProject.Business.Financial.Instruments; using QuantProject.Business.Financial.Ordering; using QuantProject.Business.Strategies; using QuantProject.Business.Timing; namespace QuantProject.Scripts.WalkForwardTesting.LinearCombination { /// <summary> /// Open to close weekly strategy /// </summary> [Serializable] public class OpenToCloseWeeklyStrategy : IEndOfDayStrategy { private Account account; private string[] signedTickers; public OpenToCloseWeeklyStrategy( Account account , string[] signedTickers) { this.account = account; this.signedTickers = signedTickers; } private long marketOpenEventHandler_addOrder_getQuantity( string ticker ) { double accountValue = this.account.GetMarketValue(); double currentTickerAsk = this.account.DataStreamer.GetCurrentAsk( ticker ); double maxPositionValueForThisTicker = accountValue/this.signedTickers.Length; long quantity = Convert.ToInt64( Math.Floor( maxPositionValueForThisTicker / currentTickerAsk ) ); return quantity; } private void marketOpenEventHandler_addOrder( string signedTicker ) { OrderType orderType = GenomeRepresentation.GetOrderType( signedTicker ); string ticker = GenomeRepresentation.GetTicker( signedTicker ); long quantity = marketOpenEventHandler_addOrder_getQuantity( ticker ); Order order = new Order( orderType , new Instrument( ticker ) , quantity ); this.account.AddOrder( order ); } private void marketOpenEventHandler_addOrders() { foreach ( string signedTicker in this.signedTickers ) marketOpenEventHandler_addOrder( signedTicker ); } public void MarketOpenEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { if ( ( this.account.CashAmount == 0 ) && ( this.account.Transactions.Count == 0 ) ) // cash has not been added yet this.account.AddCash( 30000 ); if ( endOfDayTimingEventArgs.EndOfDayDateTime.DateTime.DayOfWeek == DayOfWeek.Monday ) marketOpenEventHandler_addOrders(); } private void fiveMinutesBeforeMarketCloseEventHandler_closePositions() { ArrayList tickers = new ArrayList(); foreach ( Position position in this.account.Portfolio.Positions ) tickers.Add( position.Instrument.Key ); foreach ( string ticker in tickers ) this.account.ClosePosition( ticker ); } public void FiveMinutesBeforeMarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs) { if ( endOfDayTimingEventArgs.EndOfDayDateTime.DateTime.DayOfWeek == DayOfWeek.Friday ) this.fiveMinutesBeforeMarketCloseEventHandler_closePositions(); } public void MarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs) { } public void OneHourAfterMarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs) { } } } |
|
From: Glauco S. <gla...@us...> - 2005-08-02 23:07:00
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13796/b7_Scripts Modified Files: b7_Scripts.csproj Log Message: - WalkForwardTesting\LinearCombination\OpenToCloseDailyStrategy.cs has been added - WalkForwardTesting\LinearCombination\OpenToCloseWeeklyStrategy.cs has been added Index: b7_Scripts.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/b7_Scripts.csproj,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** b7_Scripts.csproj 31 Jul 2005 19:53:44 -0000 1.34 --- b7_Scripts.csproj 2 Aug 2005 23:06:22 -0000 1.35 *************** *** 284,287 **** --- 284,297 ---- /> <File + RelPath = "WalkForwardTesting\LinearCombination\OpenToCloseDailyStrategy.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "WalkForwardTesting\LinearCombination\OpenToCloseWeeklyStrategy.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "WalkForwardTesting\LinearCombination\OptimizationOutput.cs" SubType = "Code" *************** *** 299,302 **** --- 309,317 ---- /> <File + RelPath = "WalkForwardTesting\LinearCombination\TestDisplayer.resx" + DependentUpon = "TestDisplayer.cs" + BuildAction = "EmbeddedResource" + /> + <File RelPath = "WalkForwardTesting\LinearCombination\VisualObjectArchiver.cs" SubType = "Code" |
|
From: Glauco S. <gla...@us...> - 2005-08-02 23:04:52
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13519/b4_Business/a2_Strategies Added Files: IEndOfDayStrategy.cs Log Message: Interface to be implemented by end of day strategies --- NEW FILE: IEndOfDayStrategy.cs --- /* QuantProject - Quantitative Finance Library EndOfDayStrategy.cs Copyright (C) 2003 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.Business.Financial.Accounting.Transactions; using QuantProject.Business.Timing; namespace QuantProject.Business.Strategies { /// <summary> /// Interface to be implemented by end of day strategies /// </summary> public interface IEndOfDayStrategy { void MarketOpenEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ); void FiveMinutesBeforeMarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ); void MarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ); void OneHourAfterMarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ); } } |
|
From: Glauco S. <gla...@us...> - 2005-08-02 23:04:12
|
Update of /cvsroot/quantproject/QuantProject/b4_Business In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13403/b4_Business Modified Files: b4_Business.csproj Log Message: a2_Strategies\IEndOfDayStrategy.cs has been added Index: b4_Business.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/b4_Business.csproj,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** b4_Business.csproj 19 Jun 2005 15:29:10 -0000 1.25 --- b4_Business.csproj 2 Aug 2005 23:04:03 -0000 1.26 *************** *** 538,541 **** --- 538,546 ---- /> <File + RelPath = "a2_Strategies\IEndOfDayStrategy.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "a2_Strategies\Signal.cs" SubType = "Code" |
|
From: Marco M. <mi...@us...> - 2005-08-01 22:31:57
|
Update of /cvsroot/quantproject/QuantProject/b91_QuantProject In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16912/b91_QuantProject Modified Files: app.config Log Message: Now also genomes are saved at the end of the script, in a directory specified in the app.config file. Minor bugs have been fixed, in addition. Index: app.config =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b91_QuantProject/app.config,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** app.config 24 Jun 2005 22:54:51 -0000 1.3 --- app.config 1 Aug 2005 22:31:48 -0000 1.4 *************** *** 10,13 **** --- 10,14 ---- <add key="ReportsArchive" value="C:\\Documents and Settings\\Marco\\Documenti\\ProgettiOpenSource\\Quant\\SavedReports\\" /> <add key="TransactionsArchive" value="C:\\Documents and Settings\\Marco\\Documenti\\ProgettiOpenSource\\Quant\\SavedTransactions\\" /> + <add key="GenomesArchive" value="C:\\Documents and Settings\\Marco\\Documenti\\ProgettiOpenSource\\Quant\\SavedGenomes\\" /> </appSettings> |
|
From: Marco M. <mi...@us...> - 2005-08-01 22:31:57
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16912/b7_Scripts/TickerSelectionTesting Modified Files: EndOfDayTimerHandler.cs EndOfDayTimerHandlerCTC.cs EndOfDayTimerHandlerCTO.cs RunEfficientPortfolio.cs RunTestOptimizedCTCPortfolio.cs RunTestOptimizedCTOPortfolio.cs Log Message: Now also genomes are saved at the end of the script, in a directory specified in the app.config file. Minor bugs have been fixed, in addition. Index: RunTestOptimizedCTOPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunTestOptimizedCTOPortfolio.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** RunTestOptimizedCTOPortfolio.cs 27 Jul 2005 22:30:56 -0000 1.6 --- RunTestOptimizedCTOPortfolio.cs 1 Aug 2005 22:31:48 -0000 1.7 *************** *** 41,44 **** --- 41,45 ---- using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; using QuantProject.Presentation.Reporting.WindowsForm; + using QuantProject.Scripts.WalkForwardTesting.LinearCombination; *************** *** 109,112 **** --- 110,116 ---- { this.endOfDayTimer.Stop(); + this.account.OptimizationOutput = (object) new OptimizationOutput(this.startDateTime.DateTime, + this.endDateTime.DateTime, + this.endOfDayTimerHandler.BestGenomes); } Index: EndOfDayTimerHandler.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandler.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** EndOfDayTimerHandler.cs 27 Jul 2005 22:30:55 -0000 1.14 --- EndOfDayTimerHandler.cs 1 Aug 2005 22:31:48 -0000 1.15 *************** *** 32,35 **** --- 32,36 ---- using QuantProject.Data.Selectors; using QuantProject.ADT.Optimizing.Genetic; + using QuantProject.Scripts.WalkForwardTesting.LinearCombination; namespace QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios *************** *** 66,70 **** protected PortfolioType portfolioType; ! protected GenomeCounter genomeCounter; public GenomeCounter GenomeCounter --- 67,71 ---- protected PortfolioType portfolioType; ! protected GenomeCounter genomeCounter; public GenomeCounter GenomeCounter *************** *** 87,90 **** --- 88,100 ---- } + /// <summary> + /// bestGenomes[ i ] contains an array list with the best genomes + /// for generation i + /// </summary> + protected ArrayList bestGenomes; + public ArrayList BestGenomes + { + get { return this.bestGenomes; } + } public EndOfDayTimerHandler(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForLiquidity, Account account, *************** *** 107,110 **** --- 117,121 ---- this.targetReturn = targetReturn; this.portfolioType = portfolioType; + } *************** *** 192,195 **** --- 203,217 ---- } + protected void addGenomeToBestGenomes(Genome genome, + DateTime firstOptimizationDate, + DateTime secondOptimizationDate) + { + if(this.bestGenomes == null) + this.bestGenomes = new ArrayList(); + + this.bestGenomes.Add(new GenomeRepresentation(genome, + firstOptimizationDate, + secondOptimizationDate)); + } public virtual void MarketOpenEventHandler( Index: RunEfficientPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunEfficientPortfolio.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** RunEfficientPortfolio.cs 27 Jul 2005 22:30:56 -0000 1.11 --- RunEfficientPortfolio.cs 1 Aug 2005 22:31:48 -0000 1.12 *************** *** 43,46 **** --- 43,47 ---- using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; using QuantProject.Presentation.Reporting.WindowsForm; + using QuantProject.Scripts.WalkForwardTesting.LinearCombination; *************** *** 225,228 **** --- 226,231 ---- string dirNameWhereToSaveTransactions = System.Configuration.ConfigurationSettings.AppSettings["TransactionsArchive"] + "\\" + this.ScriptName + "\\"; + string dirNameWhereToSaveBestGenomes = System.Configuration.ConfigurationSettings.AppSettings["GenomesArchive"] + + "\\" + this.ScriptName + "\\"; //default report with numIntervalDays = 1 AccountReport accountReport = this.account.CreateReport(fileName,1, *************** *** 234,242 **** dirNameWhereToSaveReports + fileName + ".qPr"); this.checkDateForReport_createDirIfNotPresent(dirNameWhereToSaveTransactions); ObjectArchiver.Archive(this.account.Transactions, dirNameWhereToSaveTransactions + fileName + ".qPt"); ! this.endOfDayTimer.Stop(); --- 237,254 ---- dirNameWhereToSaveReports + fileName + ".qPr"); + // this.checkDateForReport_createDirIfNotPresent(dirNameWhereToSaveTransactions); ObjectArchiver.Archive(this.account.Transactions, dirNameWhereToSaveTransactions + fileName + ".qPt"); ! // ! this.checkDateForReport_createDirIfNotPresent(dirNameWhereToSaveBestGenomes); ! this.account.OptimizationOutput = (object) new OptimizationOutput(this.startDateTime.DateTime, ! this.endDateTime.DateTime, ! this.endOfDayTimerHandler.BestGenomes); ! ObjectArchiver.Archive((OptimizationOutput)this.account.OptimizationOutput, ! dirNameWhereToSaveBestGenomes + ! fileName + ".bgn"); ! //this.account.BestGenomes = this.endOfDayTimerHandler.BestGenomes; this.endOfDayTimer.Stop(); Index: EndOfDayTimerHandlerCTC.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerCTC.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** EndOfDayTimerHandlerCTC.cs 27 Jul 2005 22:30:55 -0000 1.11 --- EndOfDayTimerHandlerCTC.cs 1 Aug 2005 22:31:48 -0000 1.12 *************** *** 176,179 **** --- 176,181 ---- GO.Run(false); + this.addGenomeToBestGenomes(GO.BestGenome,currentDate.AddDays(-this.numDaysForLiquidity), + currentDate); this.chosenTickers = (string[])GO.BestGenome.Meaning; } Index: EndOfDayTimerHandlerCTO.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerCTO.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** EndOfDayTimerHandlerCTO.cs 27 Jul 2005 22:30:55 -0000 1.15 --- EndOfDayTimerHandlerCTO.cs 1 Aug 2005 22:31:48 -0000 1.16 *************** *** 159,163 **** GO.Run(false); ! this.chosenTickers = (string[])GO.BestGenome.Meaning; } --- 159,164 ---- GO.Run(false); ! this.addGenomeToBestGenomes(GO.BestGenome,currentDate.AddDays(-this.numDaysForLiquidity), ! currentDate); this.chosenTickers = (string[])GO.BestGenome.Meaning; } Index: RunTestOptimizedCTCPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunTestOptimizedCTCPortfolio.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** RunTestOptimizedCTCPortfolio.cs 27 Jul 2005 22:30:56 -0000 1.4 --- RunTestOptimizedCTCPortfolio.cs 1 Aug 2005 22:31:48 -0000 1.5 *************** *** 40,43 **** --- 40,44 ---- using QuantProject.Presentation.Reporting.WindowsForm; using QuantProject.ADT.FileManaging; + using QuantProject.Scripts.WalkForwardTesting.LinearCombination; *************** *** 118,121 **** --- 119,125 ---- { this.endOfDayTimer.Stop(); + this.account.OptimizationOutput = (object) new OptimizationOutput(this.startDateTime.DateTime, + this.endDateTime.DateTime, + this.endOfDayTimerHandler.BestGenomes); } |
|
From: Marco M. <mi...@us...> - 2005-08-01 22:27:40
|
Update of /cvsroot/quantproject/QuantProject/b5_Presentation/Reporting/WindowsForm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16034/b5_Presentation/Reporting/WindowsForm Modified Files: Report.cs Log Message: Added new menu item for saving genomes Index: Report.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b5_Presentation/Reporting/WindowsForm/Report.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Report.cs 10 Jun 2005 18:45:44 -0000 1.14 --- Report.cs 1 Aug 2005 22:27:31 -0000 1.15 *************** *** 28,31 **** --- 28,32 ---- using QuantProject.Business.Timing; + namespace QuantProject.Presentation.Reporting.WindowsForm { *************** *** 46,49 **** --- 47,51 ---- private System.Windows.Forms.MenuItem saveReport; private System.Windows.Forms.MenuItem saveTransactions; + private System.Windows.Forms.MenuItem saveGenomes; private SaveFileDialog saveFileDialog; *************** *** 90,93 **** --- 92,98 ---- this.saveTransactions.Text = "Save Transactions"; + this.saveGenomes = new MenuItem(); + this.saveGenomes.Text = "Save Genomes"; + this.file = new MenuItem(); this.file.Text = "File"; *************** *** 97,105 **** this.file.MenuItems.AddRange(new MenuItem[] {this.saveAccount, ! this.saveReport, this.saveTransactions}); this.Menu = this.mainMenu; this.saveAccount.Click += new System.EventHandler(this.saveAccount_Click); this.saveReport.Click += new System.EventHandler(this.saveReport_Click); ! this.saveTransactions.Click += new System.EventHandler(this.saveTransactions_Click); } --- 102,113 ---- this.file.MenuItems.AddRange(new MenuItem[] {this.saveAccount, ! this.saveReport, ! this.saveTransactions, ! this.saveGenomes}); this.Menu = this.mainMenu; this.saveAccount.Click += new System.EventHandler(this.saveAccount_Click); this.saveReport.Click += new System.EventHandler(this.saveReport_Click); ! this.saveTransactions.Click += new System.EventHandler(this.saveTransactions_Click); ! this.saveGenomes.Click += new System.EventHandler(this.saveGenomes_Click); } *************** *** 169,173 **** } ! #region save account or report or transactions private void saveAccount_Click(object sender, System.EventArgs e) --- 177,181 ---- } ! #region save account or report or transactions or genomes private void saveAccount_Click(object sender, System.EventArgs e) *************** *** 187,190 **** --- 195,203 ---- } + private void saveGenomes_Click(object sender, System.EventArgs e) + { + this.saveObject((MenuItem)sender); + } + private void saveObject_setSaveFileDialog(MenuItem sender) { *************** *** 212,216 **** this.saveFileDialog.DefaultExt = "qPt"; } ! this.saveFileDialog.AddExtension = true; this.saveFileDialog.CreatePrompt = true; --- 225,235 ---- this.saveFileDialog.DefaultExt = "qPt"; } ! else if(sender.Text.EndsWith("Genomes")) ! //else the text property of the menu item sender contains at the end ! // the word "Genomes"; so it will be saved an OptimizationOutput ! //containing a GenomeRepresentation ! { ! this.saveFileDialog.DefaultExt = "bgn"; ! } this.saveFileDialog.AddExtension = true; this.saveFileDialog.CreatePrompt = true; *************** *** 240,243 **** --- 259,265 ---- QuantProject.ADT.FileManaging.ObjectArchiver.Archive(this.account.Transactions, this.saveFileDialog.FileName); + else if(((SaveFileDialog)sender).Title.EndsWith("Genomes")) + QuantProject.ADT.FileManaging.ObjectArchiver.Archive(this.account.OptimizationOutput, + this.saveFileDialog.FileName); } |
|
From: Marco M. <mi...@us...> - 2005-08-01 22:26:41
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15811/b1_ADT/Optimizing/Genetic Modified Files: Genome.cs Log Message: Modified HasSomeDuplicateGenes method. Index: Genome.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic/Genome.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Genome.cs 13 Jul 2005 16:37:04 -0000 1.5 --- Genome.cs 1 Aug 2005 22:26:32 -0000 1.6 *************** *** 169,173 **** /// values in genes /// </summary> ! public bool HasSomeDuplicateGenes(int constToDiscoverDuplicateGenes) { bool returnValue = false; --- 169,173 ---- /// values in genes /// </summary> ! public bool HasSomeDuplicateGenes() { bool returnValue = false; *************** *** 176,183 **** for(int j = i + 1; j < this.size ; j++) { ! if(this.genes[i] == this.genes[j] || ! this.genes[i] + constToDiscoverDuplicateGenes == this.genes[j] || ! this.genes[i] == this.genes[j] + constToDiscoverDuplicateGenes) ! returnValue = true; } --- 176,180 ---- for(int j = i + 1; j < this.size ; j++) { ! if(this.genes[i] == this.genes[j]) returnValue = true; } *************** *** 185,188 **** --- 182,186 ---- return returnValue; } + } } |
|
From: Marco M. <mi...@us...> - 2005-07-31 20:10:47
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19178/b4_Business/a1_Financial/a2_Accounting Modified Files: Account.cs Log Message: Modified HasSomeDuplicateGenes method. Index: Account.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/Account.cs,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Account.cs 19 Jun 2005 15:00:09 -0000 1.18 --- Account.cs 31 Jul 2005 20:10:28 -0000 1.19 *************** *** 60,64 **** --- 60,66 ---- private ArrayList activeOrders; private AccountReport accountReport; + private object optimizationOutput = null; + public Portfolio Portfolio = new Portfolio(); //public AccountReport accountReport; *************** *** 92,97 **** set { accountStrategy = value; } } ! ! public TransactionHistory Transactions = new TransactionHistory(); public Account( string accountName ) : base ( accountName ) --- 94,108 ---- set { accountStrategy = value; } } ! /// <summary> ! /// the object contain a representation of the ! /// optimization working of the script ! /// </summary> ! public object OptimizationOutput ! { ! get { return this.optimizationOutput; } ! set { this.optimizationOutput = value; } ! } ! ! public TransactionHistory Transactions = new TransactionHistory(); public Account( string accountName ) : base ( accountName ) |
|
From: Marco M. <mi...@us...> - 2005-07-31 20:07:38
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18625/b1_ADT/Optimizing/Genetic Modified Files: GenomeCounter.cs Log Message: Changed name to the private method added to the NewGeneration event Index: GenomeCounter.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic/GenomeCounter.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** GenomeCounter.cs 27 Jul 2005 22:35:37 -0000 1.1 --- GenomeCounter.cs 31 Jul 2005 20:07:28 -0000 1.2 *************** *** 57,64 **** this.fitnessCollector = new Hashtable(); this.geneticOptimizer.NewGeneration += ! new NewGenerationEventHandler(this.newGenerationEventHandler); } ! private void newGenerationEventHandler(Object sender, NewGenerationEventArgs newGenerationEventArgs) { --- 57,64 ---- this.fitnessCollector = new Hashtable(); this.geneticOptimizer.NewGeneration += ! new NewGenerationEventHandler(this.addNewGenome); } ! private void addNewGenome(Object sender, NewGenerationEventArgs newGenerationEventArgs) { |
|
From: Marco M. <mi...@us...> - 2005-07-31 20:04:19
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataProviders In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17976/b3_Data/DataProviders Modified Files: HistoricalDataProvider.cs Log Message: Fixed bug Index: HistoricalDataProvider.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataProviders/HistoricalDataProvider.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** HistoricalDataProvider.cs 26 May 2005 23:42:25 -0000 1.8 --- HistoricalDataProvider.cs 31 Jul 2005 20:04:09 -0000 1.9 *************** *** 214,218 **** // } // ! private static double getQuote( string instrumentKey , DateTime dateTime , QuoteField quoteField ) { double returnValue; --- 214,218 ---- // } // ! /*private static double getQuote( string instrumentKey , DateTime dateTime , QuoteField quoteField ) { double returnValue; *************** *** 228,232 **** ).IndexOfKeyOrPrevious( dateTime ) ) ); return returnValue; ! } /// <summary> /// Returns the adjusted market value for the given ticker, at the given ExtendedDateTime --- 228,232 ---- ).IndexOfKeyOrPrevious( dateTime ) ) ); return returnValue; ! }*/ /// <summary> /// Returns the adjusted market value for the given ticker, at the given ExtendedDateTime *************** *** 263,271 **** double returnValue; if ( extendedDateTime.BarComponent == BarComponent.Close ) ! returnValue = getQuote( instrumentKey , extendedDateTime.DateTime , QuoteField.Close ); else // extendedDateTime.BarComponent is equal to BarComponent.Open ! returnValue = getQuote( instrumentKey , extendedDateTime.DateTime , QuoteField.Open ); return returnValue; --- 263,271 ---- double returnValue; if ( extendedDateTime.BarComponent == BarComponent.Close ) ! returnValue = privateCache.GetQuote( instrumentKey , extendedDateTime.DateTime , QuoteField.Close ); else // extendedDateTime.BarComponent is equal to BarComponent.Open ! returnValue = privateCache.GetQuote( instrumentKey , extendedDateTime.DateTime , QuoteField.Open ); return returnValue; |
|
From: Marco M. <mi...@us...> - 2005-07-31 20:03:40
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17771/b7_Scripts/TickerSelectionTesting Modified Files: GenomeManagerForEfficientPortfolio.cs Log Message: Fixed bugs in GenomeManagerForEfficientPortfolio; - added new property CurrentGeneticOptimizer to the IGenomeManager interface; - added new public method CalculateRandomFitness() for a new computation of fitness (now the code this new computation of fitness has been remarked: if you want more details, please write to me) Index: GenomeManagerForEfficientPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/GenomeManagerForEfficientPortfolio.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** GenomeManagerForEfficientPortfolio.cs 27 Jul 2005 22:30:55 -0000 1.14 --- GenomeManagerForEfficientPortfolio.cs 31 Jul 2005 20:03:31 -0000 1.15 *************** *** 48,52 **** protected CandidateProperties[] setOfCandidates; protected int originalNumOfTickers; - protected int constToDiscoverDuplicateGenes; protected DateTime firstQuoteDate; protected DateTime lastQuoteDate; --- 48,51 ---- *************** *** 58,61 **** --- 57,61 ---- protected double[] portfolioRatesOfReturn; protected int numberOfExaminedReturns; + protected GeneticOptimizer currentGeneticOptimizer; static public string GetCleanTickerCode(string tickerCodeForLongOrShortTrade) *************** *** 100,103 **** --- 100,109 ---- } + public GeneticOptimizer CurrentGeneticOptimizer + { + get{return this.currentGeneticOptimizer;} + set{this.currentGeneticOptimizer = value;} + } + //setOfInitialTickers has to contain the //ticker's symbol in the first column ! *************** *** 113,117 **** this.setOfTickers = setOfInitialTickers; this.originalNumOfTickers = setOfInitialTickers.Rows.Count; - this.constToDiscoverDuplicateGenes = this.originalNumOfTickers + 1; this.firstQuoteDate = firstQuoteDate; this.lastQuoteDate = lastQuoteDate; --- 119,122 ---- *************** *** 130,134 **** if(this.portfolioType == PortfolioType.ShortAndLong) this.minValueForGenes = - this.originalNumOfTickers; ! //if gene g is negative, it refers to the ticker Abs(g+1) to be shorted } --- 135,139 ---- if(this.portfolioType == PortfolioType.ShortAndLong) this.minValueForGenes = - this.originalNumOfTickers; ! //if gene g is negative, it refers to the ticker |g|-1 to be shorted } *************** *** 168,172 **** //returnValue = normal.GetProbability(-this.targetPerformance*1.25,-this.targetPerformance*0.75); returnValue = normal.GetProbability(-this.targetPerformance); ! return returnValue; --- 173,188 ---- //returnValue = normal.GetProbability(-this.targetPerformance*1.25,-this.targetPerformance*0.75); returnValue = normal.GetProbability(-this.targetPerformance); ! /*the following code has to be tested ! if(this.currentGeneticOptimizer.AverageRandomFitness != 0.0 && ! this.currentGeneticOptimizer.StandardDeviationOfRandomFitness != 0.0) ! //the two properties remain equal to 0.0 for the GeneticOptimizer ! //instance created in the Run method: the two properties are updated ! //effectively only for the GO instance calling the Run method ! returnValue = (returnValue - this.CurrentGeneticOptimizer.AverageRandomFitness)/ ! this.CurrentGeneticOptimizer.StandardDeviationOfRandomFitness; ! if(returnValue < 0.0) ! returnValue = 0.0; ! //fitness should be now pure positive number ! */ return returnValue; *************** *** 205,210 **** { return ! GenomeManagement.MixGenesWithoutDuplicates(parent1, parent2, ! this.constToDiscoverDuplicateGenes); } --- 221,225 ---- { return ! GenomeManipulator.MixGenesWithoutDuplicates(parent1, parent2); } *************** *** 216,221 **** genome.MaxValueForGenes + 1); while(genome.HasGene(returnValue) || ! genome.HasGene(returnValue + this.constToDiscoverDuplicateGenes) || ! genome.HasGene(returnValue - this.constToDiscoverDuplicateGenes) ) //the portfolio can't have a long position and a short one for the same ticker { --- 231,236 ---- genome.MaxValueForGenes + 1); while(genome.HasGene(returnValue) || ! genome.HasGene(Math.Abs(returnValue) - 1 ) || ! genome.HasGene(- Math.Abs(returnValue) - 1) ) //the portfolio can't have a long position and a short one for the same ticker { *************** *** 232,240 **** // the new value has to be different from all the other genes of the genome int newValueForGene = GenomeManagement.RandomGenerator.Next(genome.MinValueForGenes, ! genome.MaxValueForGenes +1); int genePositionToBeMutated = GenomeManagement.RandomGenerator.Next(genome.Size); while(genome.HasGene(newValueForGene) || ! genome.HasGene(newValueForGene + this.constToDiscoverDuplicateGenes) || ! genome.HasGene(newValueForGene - this.constToDiscoverDuplicateGenes) ) //the efficient portfolio, in this implementation, // can't have a long position and a short position --- 247,255 ---- // the new value has to be different from all the other genes of the genome int newValueForGene = GenomeManagement.RandomGenerator.Next(genome.MinValueForGenes, ! genome.MaxValueForGenes +1); int genePositionToBeMutated = GenomeManagement.RandomGenerator.Next(genome.Size); while(genome.HasGene(newValueForGene) || ! genome.HasGene(Math.Abs(newValueForGene) - 1 ) || ! genome.HasGene(- Math.Abs(newValueForGene) - 1) ) //the efficient portfolio, in this implementation, // can't have a long position and a short position *************** *** 256,260 **** if(geneValue<0) { ! position = Math.Abs(geneValue + 1); initialCharForTickerCode = "-"; } --- 271,275 ---- if(geneValue<0) { ! position = Math.Abs(geneValue) - 1; initialCharForTickerCode = "-"; } |
|
From: Marco M. <mi...@us...> - 2005-07-31 20:03:40
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17771/b1_ADT/Optimizing/Genetic Modified Files: GeneticOptimizer.cs GenomeManagerTest.cs IGenomeManager.cs Log Message: Fixed bugs in GenomeManagerForEfficientPortfolio; - added new property CurrentGeneticOptimizer to the IGenomeManager interface; - added new public method CalculateRandomFitness() for a new computation of fitness (now the code this new computation of fitness has been remarked: if you want more details, please write to me) Index: GenomeManagerTest.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic/GenomeManagerTest.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** GenomeManagerTest.cs 13 Jul 2005 16:37:04 -0000 1.3 --- GenomeManagerTest.cs 31 Jul 2005 20:03:31 -0000 1.4 *************** *** 37,40 **** --- 37,41 ---- private int minValueForGenes; private int maxValueForGenes; + private GeneticOptimizer currentGeneticOptimizer; public int GenomeSize *************** *** 53,56 **** --- 54,62 ---- } + public GeneticOptimizer CurrentGeneticOptimizer + { + get{return this.currentGeneticOptimizer;} + set{this.currentGeneticOptimizer = value;} + } public GenomeManagerTest(int genomeSize, int minValueForGenes, int maxValueForGenes) Index: GeneticOptimizer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic/GeneticOptimizer.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** GeneticOptimizer.cs 27 Jul 2005 22:34:24 -0000 1.8 --- GeneticOptimizer.cs 31 Jul 2005 20:03:31 -0000 1.9 *************** *** 65,68 **** --- 65,71 ---- private int generationCounter; + private double averageRandomFitness; + private double standardDeviationOfRandomFitness; + #endregion *************** *** 131,134 **** --- 134,154 ---- get{return this.currentGeneration;} } + + /// <summary> + /// Average fitness of a group of genomes (this.numberOfGenomesForAverageRandomFitness) + /// chosen at random + /// </summary> + public double AverageRandomFitness + { + get{return this.averageRandomFitness;} + } + /// <summary> + /// Standard deviation of fitness of a group of genomes (this.numberOfGenomesForAverageRandomFitness) + /// chosen at random + /// </summary> + public double StandardDeviationOfRandomFitness + { + get{return this.standardDeviationOfRandomFitness;} + } #endregion *************** *** 207,212 **** --- 227,265 ---- eliteNumber); this.generationCounter = 1; + this.genomeManager.CurrentGeneticOptimizer = this; + } + + /// <summary> + /// It updates AverageRandomFitness and StandardDeviationOfRandomFitness + /// properties with the average and std dev fitness + /// of a given group of genomes chosen at random + /// </summary> + public void CalculateRandomFitness() + { + this.createFirstGeneration(false); + this.averageRandomFitness = this.totalFitness/this.currentGeneration.Count; + this.standardDeviationOfRandomFitness = this.calculateRandomFitness_getStdDevOfRandomFitness(); + } + /// <summary> + /// It updates StandardDeviationOfRandomFitness property with the std dev of + /// fitness of a given group of genomes chosen at random + /// </summary> + private double calculateRandomFitness_getStdDevOfRandomFitness() + { + double[] fitnesses = new double[this.currentGeneration.Count]; + for(int i = 0; i<this.currentGeneration.Count; i++) + fitnesses[i] = ((Genome)this.currentGeneration[i]).Fitness; + return QuantProject.ADT.Statistics.BasicFunctions.StdDev(fitnesses); } + private void run_calculateRandomFitness() + { + GeneticOptimizer GOForAverageRandomFitness = + new GeneticOptimizer(this.genomeManager, ConstantsProvider.NumGenomesForRandomFitnessComputation, + 0,ConstantsProvider.SeedForRandomGenerator); + GOForAverageRandomFitness.CalculateRandomFitness(); + this.averageRandomFitness = GOForAverageRandomFitness.AverageRandomFitness; + this.standardDeviationOfRandomFitness = GOForAverageRandomFitness.StandardDeviationOfRandomFitness; + } /// <summary> /// Method to start the GeneticOptmizer *************** *** 214,217 **** --- 267,271 ---- public void Run(bool showOutputToConsole) { + //this.run_calculateRandomFitness(); to be tested yet this.createFirstGeneration(showOutputToConsole); if(this.keepOnRunningUntilConvergenceIsReached) Index: IGenomeManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic/IGenomeManager.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IGenomeManager.cs 1 Dec 2004 22:36:11 -0000 1.1 --- IGenomeManager.cs 31 Jul 2005 20:03:31 -0000 1.2 *************** *** 43,46 **** --- 43,47 ---- int MinValueForGenes{get;} int MaxValueForGenes{get;} + GeneticOptimizer CurrentGeneticOptimizer{get;set;} int GetNewGeneValue(Genome genome); // Used in generation of genes |
|
From: Marco M. <mi...@us...> - 2005-07-31 20:03:39
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17771/b1_ADT Modified Files: ConstantsProvider.cs Log Message: Fixed bugs in GenomeManagerForEfficientPortfolio; - added new property CurrentGeneticOptimizer to the IGenomeManager interface; - added new public method CalculateRandomFitness() for a new computation of fitness (now the code this new computation of fitness has been remarked: if you want more details, please write to me) Index: ConstantsProvider.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/ConstantsProvider.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ConstantsProvider.cs 27 Jul 2005 22:32:05 -0000 1.12 --- ConstantsProvider.cs 31 Jul 2005 20:03:31 -0000 1.13 *************** *** 34,37 **** --- 34,42 ---- public static int SeedForRandomGenerator = 333; // for GeneticOptimizer and // GenomeManagement + public static int NumGenomesForRandomFitnessComputation = 100; + // for GeneticOptimizer (used by CalculateRandomFitness() in order + //to update averageRandomFitness and standardDeviationOfRandomFitness properties + + } } |
|
From: Marco M. <mi...@us...> - 2005-07-31 19:53:53
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15756/b7_Scripts/TickerSelectionTesting Added Files: GenomeManipulator.cs Log Message: Moved specific methods for the GenomeManagerForTheEfficientPortfolio from GenomeManagement to the new GenomeManipulator class, created in the namespace QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; - modified MixGenesWithoutDuplicates, that now tries to mix all genes of the two parents in offspring (without duplication) --- NEW FILE: GenomeManipulator.cs --- /* QuantProject - Quantitative Finance Library GenomeManipulator.cs Copyright (C) 2003 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Collections; using QuantProject.ADT; using QuantProject.ADT.Optimizing.Genetic; namespace QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios { /// <summary> /// Class providing static methods for manipulating Genomes /// (used by th IGenomeManagerForEfficientPortfolio) /// </summary> [Serializable] public sealed class GenomeManipulator { public static Random RandomGenerator; private static int genomeSize; private static Genome[] childs; private static int[,] maskForChilds; static GenomeManipulator() { RandomGenerator = new Random(ConstantsProvider.SeedForRandomGenerator); childs = new Genome[2]; } private static void initializeStaticMembers(Genome parent1, Genome parent2) { genomeSize = parent1.Size; childs[0] = parent1.Clone(); childs[1] = parent2.Clone(); //the two childs now points to their parents maskForChilds = new int[childs.Length, genomeSize]; } private static void assignFitnessAndMeaningToChilds() { foreach(Genome child in childs) { child.AssignMeaning(); child.CalculateFitness(); } } /*old private static int firstGenePositionOfParent1NotPresentInParent2(Genome parent1, Genome parent2) { int returnValue = -1; for(int genePos = 0 ; genePos < GenomeManipulator.genomeSize && returnValue == -1; genePos++) { int geneValue = parent1.GetGeneValue(genePos); if(geneValue >= 0) { if(!parent2.HasGene(geneValue) && !parent2.HasGene(-Math.Abs(geneValue) - 1)) returnValue = genePos; } else { if(!parent2.HasGene(geneValue) && !parent2.HasGene(Math.Abs(geneValue) - 1)) returnValue = genePos; } } return returnValue; } */ /* old private static bool setMaskForChildsForMixingWithoutDuplicates(Genome parent1, Genome parent2) { bool returnValue = false; int firstGenePosOfParent1NotPresentInParent2 = firstGenePositionOfParent1NotPresentInParent2(parent1, parent2); int firstGenePosOfParent2NotPresentInParent1 = firstGenePositionOfParent1NotPresentInParent2(parent2, parent1); if(firstGenePosOfParent1NotPresentInParent2 > -1 && firstGenePosOfParent2NotPresentInParent1 > -1 ) //there is at least a gene in parent1 not present in parent2 and viceversa { for(int genePos = 0 ; genePos < GenomeManipulator.genomeSize ; genePos++) { if(genePos == firstGenePosOfParent1NotPresentInParent2) maskForChilds[0, genePos] = 1; else maskForChilds[0, genePos] = 2; if(genePos == firstGenePosOfParent2NotPresentInParent1) maskForChilds[1, genePos] = 2; else maskForChilds[1, genePos] = 1; } returnValue = true; } return returnValue; } */ private static int[] genePositionsOfParent1NotPresentInParent2(Genome parent1, Genome parent2) { int[] returnValue = new int[parent1.Size]; for(int i = 0; i < returnValue.Length; i++) { returnValue[i] = - 1; int geneValue = parent1.GetGeneValue(i); if(geneValue >= 0) { if(!parent2.HasGene(geneValue) && !parent2.HasGene(-Math.Abs(geneValue) - 1)) returnValue[i] = i; } else { if(!parent2.HasGene(geneValue) && !parent2.HasGene(Math.Abs(geneValue) - 1)) returnValue[i] = i; } } return returnValue; } private static bool setMaskForChildsForMixingWithoutDuplicates(Genome parent1, Genome parent2) { bool returnValue = false; int[] genePlacesOfParent1NotPresentInParent2 = genePositionsOfParent1NotPresentInParent2(parent1, parent2); int[] genePlacesOfParent2NotPresentInParent1 = genePositionsOfParent1NotPresentInParent2(parent2, parent1); for(int i = 0; i<genePlacesOfParent1NotPresentInParent2.Length; i++) { for(int genePos = 0 ; genePos < GenomeManipulator.genomeSize ; genePos++) { if(genePos == genePlacesOfParent1NotPresentInParent2[i]) { maskForChilds[0, genePos] = 1; returnValue = true; } else maskForChilds[0, genePos] = 2; if(genePos == genePlacesOfParent2NotPresentInParent1[i]) { maskForChilds[1, genePos] = 2; returnValue = true; } else maskForChilds[1, genePos] = 1; } } return returnValue; } private static void setChildsUsingMaskForChilds(Genome parent1, Genome parent2) { for(int childIndex = 0; childIndex < 2; childIndex++) { for(int genePos = 0 ; genePos < GenomeManipulator.genomeSize ; genePos++) { if(maskForChilds[childIndex,genePos]==1) childs[childIndex].SetGeneValue(parent1.GetGeneValue(genePos), genePos); else//maskForChilds[childIndex,genePos]==2 childs[childIndex].SetGeneValue(parent2.GetGeneValue(genePos), genePos); } } } private static bool hasSomeDuplicateGenes(Genome genome) { bool returnValue = false; for(int i = 0; i < genome.Size ; i++) { for(int j = i + 1; j < genome.Size ; j++) { if(genome.Genes()[i] == genome.Genes()[j] || ((genome.Genes()[i]<0 && genome.Genes()[j]>0) && Math.Abs(genome.Genes()[i]) - 1 == genome.Genes()[j]) || ((genome.Genes()[i]>0 && genome.Genes()[j]<0) && -Math.Abs(genome.Genes()[i]) - 1 == genome.Genes()[j])) returnValue = true; } } return returnValue; } //just for debugging purposes private static void throwExcIfAChildHasDuplicateGenes() { foreach(Genome gen in childs) { if(GenomeManipulator.hasSomeDuplicateGenes(gen)) throw new Exception("A child with duplicate genes has been generated!"); } } /// <summary> /// This method returns an array of genomes based on /// a mix of the genes of parents, such that the 2 childs, /// if possible, are different from parents and, at /// the same time, childs' genes are not duplicated /// </summary> /// <param name="parent1">First genome parent from which genes are to be mixed in offspring</param> /// <param name="parents">Second genome parent from which genes are to be mixed in offspring</param> /// <param name="constToDiscoverGenesDuplicates">Gene y is a duplicate of gene x iff y = |x| - 1 /// or y = -|x| -1</param> public static Genome[] MixGenesWithoutDuplicates(Genome parent1, Genome parent2) { initializeStaticMembers(parent1, parent2); if(parent1.Size > (parent1.MaxValueForGenes - parent1.MinValueForGenes + 1)) //it is impossible not to duplicate genes if size is too // large for the range of variation of each gene throw new Exception("Impossible to avoid duplicates with the given size!"); if(parent1.Size != parent2.Size) throw new Exception("Genomes must have the same size!"); if(setMaskForChildsForMixingWithoutDuplicates(parent1, parent2)) setChildsUsingMaskForChilds(parent1, parent2); //throwExcIfAChildHasDuplicateGenes(); //just for debugging purposes return childs; } } } |
|
From: Marco M. <mi...@us...> - 2005-07-31 19:53:53
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15756/b1_ADT/Optimizing/Genetic Modified Files: GenomeManagement.cs Log Message: Moved specific methods for the GenomeManagerForTheEfficientPortfolio from GenomeManagement to the new GenomeManipulator class, created in the namespace QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; - modified MixGenesWithoutDuplicates, that now tries to mix all genes of the two parents in offspring (without duplication) Index: GenomeManagement.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic/GenomeManagement.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** GenomeManagement.cs 25 Jul 2005 22:30:32 -0000 1.5 --- GenomeManagement.cs 31 Jul 2005 19:53:44 -0000 1.6 *************** *** 65,68 **** --- 65,83 ---- } + private static void setChildsUsingMaskForChilds(Genome parent1, + Genome parent2) + { + for(int childIndex = 0; childIndex < 2; childIndex++) + { + for(int genePos = 0 ; genePos < GenomeManagement.genomeSize ; genePos++) + { + if(maskForChilds[childIndex,genePos]==1) + childs[childIndex].SetGeneValue(parent1.GetGeneValue(genePos), genePos); + else//maskForChilds[childIndex,genePos]==2 + childs[childIndex].SetGeneValue(parent2.GetGeneValue(genePos), genePos); + } + } + + } /// <summary> /// It sets randomGenerator used by all other public methods *************** *** 103,264 **** } ! private static void setMaskForChildsForUniformCrossover() ! { ! for(int childIndex = 0; childIndex < 2; childIndex++) ! { ! for(int i = 0 ; i < GenomeManagement.genomeSize ; i++) ! { ! maskForChilds[childIndex,i] = GenomeManagement.RandomGenerator.Next(1,3); ! } ! } ! } ! ! private static void setMaskForChildsForAlternateFixedCrossover() ! { ! for(int childIndex = 0; childIndex < 2; childIndex++) ! { ! for(int genePos = 0; genePos < genomeSize; genePos++) ! { ! if(genePos%2 == 0) ! //gene position is even ! maskForChilds[childIndex, genePos] = 1; ! else ! // gene position is odd ! maskForChilds[childIndex, genePos] = 2; ! } ! } ! } ! ! private static int firstGenePositionOfParent1NotPresentInParent2(Genome parent1, ! Genome parent2, ! int constToDiscoverGenesDuplicates) { - int returnValue = -1; - for(int genePos = 0 ; - genePos < GenomeManagement.genomeSize && returnValue == -1; - genePos++) - { - int geneValue = parent1.GetGeneValue(genePos); - if(!parent2.HasGene(geneValue) && - !parent2.HasGene(geneValue + constToDiscoverGenesDuplicates) && - !parent2.HasGene(geneValue - constToDiscoverGenesDuplicates)) - returnValue = genePos; - } - return returnValue; - } - - private static bool setMaskForChildsForMixingWithoutDuplicates(Genome parent1, Genome parent2, - int constToDiscoverGenesDuplicates) - { - bool returnValue = false; - int firstGenePosOfParent1NotPresentInParent2 = - firstGenePositionOfParent1NotPresentInParent2(parent1, parent2, constToDiscoverGenesDuplicates); - int firstGenePosOfParent2NotPresentInParent1 = - firstGenePositionOfParent1NotPresentInParent2(parent2, parent1, constToDiscoverGenesDuplicates); - if(firstGenePosOfParent1NotPresentInParent2 > -1 && - firstGenePosOfParent2NotPresentInParent1 > -1 ) - //there is at least a gene in parent1 not present in parent2 and viceversa - { - for(int genePos = 0 ; genePos < GenomeManagement.genomeSize ; genePos++) - { - if(genePos == firstGenePosOfParent1NotPresentInParent2) - maskForChilds[0, genePos] = 1; - else - maskForChilds[0, genePos] = 2; - - if(genePos == firstGenePosOfParent2NotPresentInParent1) - maskForChilds[1, genePos] = 2; - else - maskForChilds[1, genePos] = 1; - } - returnValue = true; - } - return returnValue; - } - - private static void setChildsUsingMaskForChilds(Genome parent1, - Genome parent2) - { for(int childIndex = 0; childIndex < 2; childIndex++) { ! for(int genePos = 0 ; genePos < GenomeManagement.genomeSize ; genePos++) ! { ! if(maskForChilds[childIndex,genePos]==1) ! childs[childIndex].SetGeneValue(parent1.GetGeneValue(genePos), genePos); ! else//maskForChilds[childIndex,genePos]==2 ! childs[childIndex].SetGeneValue(parent2.GetGeneValue(genePos), genePos); } } ! ! } ! /// <summary> ! /// This method returns an array of genomes based on ! /// a random recombination of the genes of parents ! /// </summary> public static Genome[] UniformCrossover(Genome parent1, Genome parent2) { initializeStaticMembers(parent1, parent2); if(parent1.Size != parent2.Size) ! throw new Exception("Genomes must have the same size!"); ! setMaskForChildsForUniformCrossover(); ! setChildsUsingMaskForChilds(parent1, parent2); return childs; } /// <summary> ! /// This method returns an array of genomes based on ! /// an alternate fixed recombination of the genes of parents ! /// </summary> public static Genome[] AlternateFixedCrossover(Genome parent1, Genome parent2) { initializeStaticMembers(parent1, parent2); if(parent1.Size != parent2.Size) ! throw new Exception("Genomes must have the same size!"); setMaskForChildsForAlternateFixedCrossover(); ! setChildsUsingMaskForChilds(parent1, parent2); return childs; } ! private static void launchExIfAChildHasDuplicateGenes(int constToDiscoverGenesDuplicates) ! { ! foreach(Genome gen in childs) ! { ! if(gen.HasSomeDuplicateGenes(constToDiscoverGenesDuplicates)) ! throw new Exception("A child with duplicate genes has been generated!"); ! } ! ! } ! /// <summary> ! /// This method returns an array of genomes based on ! /// a mix of the genes of parents, such that the 2 childs, ! /// if possible, are different from parents and, at ! /// the same time, childs' genes are not duplicated ! /// </summary> ! /// <param name="parent1">First genome parent from which genes are to be mixed in offspring</param> ! /// <param name="parents">Second genome parent from which genes are to be mixed in offspring</param> ! /// <param name="constToDiscoverGenesDuplicates">Gene y is a duplicate of gene x iff y = x or y = x + constToDiscoverGenesDuplicates</param> ! public static Genome[] MixGenesWithoutDuplicates(Genome parent1, Genome parent2, ! int constToDiscoverGenesDuplicates) ! { ! initializeStaticMembers(parent1, parent2); ! if(parent1.Size > (parent1.MaxValueForGenes - parent1.MinValueForGenes + 1)) ! //it is impossible not to duplicate genes if size is too ! // large for the range of variation of each gene ! throw new Exception("Impossible to avoid duplicates with the given size!"); ! if(parent1.Size != parent2.Size) ! throw new Exception("Genomes must have the same size!"); ! ! if(setMaskForChildsForMixingWithoutDuplicates(parent1, parent2, ! constToDiscoverGenesDuplicates)) ! setChildsUsingMaskForChilds(parent1, parent2); ! launchExIfAChildHasDuplicateGenes(constToDiscoverGenesDuplicates); ! return childs; ! } ! ! ! static public void MutateAllGenes(Genome genome, double mutationRate) { for (int pos = 0 ; pos < genome.Size; pos++) --- 118,177 ---- } ! private static void setMaskForChildsForUniformCrossover() { for(int childIndex = 0; childIndex < 2; childIndex++) { ! for(int i = 0 ; i < GenomeManagement.genomeSize ; i++) ! { ! maskForChilds[childIndex,i] = GenomeManagement.RandomGenerator.Next(1,3); } } ! } /// <summary> ! /// This method returns an array of genomes based on ! /// a random recombination of the genes of parents ! /// </summary> public static Genome[] UniformCrossover(Genome parent1, Genome parent2) { initializeStaticMembers(parent1, parent2); if(parent1.Size != parent2.Size) ! throw new Exception("Genomes must have the same size!"); ! setMaskForChildsForUniformCrossover(); ! setChildsUsingMaskForChilds(parent1, parent2); return childs; } + private static void setMaskForChildsForAlternateFixedCrossover() + { + for(int childIndex = 0; childIndex < 2; childIndex++) + { + for(int genePos = 0; genePos < genomeSize; genePos++) + { + if(genePos%2 == 0) + //gene position is even + maskForChilds[childIndex, genePos] = 1; + else + // gene position is odd + maskForChilds[childIndex, genePos] = 2; + } + } + } /// <summary> ! /// This method returns an array of genomes based on ! /// an alternate fixed recombination of the genes of parents ! /// </summary> public static Genome[] AlternateFixedCrossover(Genome parent1, Genome parent2) { initializeStaticMembers(parent1, parent2); if(parent1.Size != parent2.Size) ! throw new Exception("Genomes must have the same size!"); setMaskForChildsForAlternateFixedCrossover(); ! setChildsUsingMaskForChilds(parent1, parent2); return childs; } ! static public void MutateAllGenes(Genome genome, double mutationRate) { for (int pos = 0 ; pos < genome.Size; pos++) |