quantproject-developers Mailing List for QuantProject (Page 118)
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-02-04 00:01:59
|
Update of /cvsroot/quantproject/QuantProject/b91_QuantProject In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4270/b91_QuantProject Modified Files: b91_QuantProject.csproj Added Files: AccountViewer.cs Log Message: Added AccountViewer to the project (work is still in progress) Index: b91_QuantProject.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b91_QuantProject/b91_QuantProject.csproj,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** b91_QuantProject.csproj 20 Jan 2005 01:11:33 -0000 1.6 --- b91_QuantProject.csproj 4 Feb 2005 00:01:47 -0000 1.7 *************** *** 98,101 **** --- 98,111 ---- <Include> <File + RelPath = "AccountViewer.cs" + SubType = "Form" + BuildAction = "Compile" + /> + <File + RelPath = "AccountViewer.resx" + DependentUpon = "AccountViewer.cs" + BuildAction = "EmbeddedResource" + /> + <File RelPath = "app.config" BuildAction = "None" --- NEW FILE: AccountViewer.cs --- using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; namespace QuantProject.Principale { /// <summary> /// AccountViewer. /// </summary> public class AccountViewer : System.Windows.Forms.Form { private System.Windows.Forms.Button buttonAddAccounts; private System.Windows.Forms.DataGrid dataGridAccounts; private System.ComponentModel.Container components = null; public AccountViewer() { // InitializeComponent(); // // TODO: // } /// <summary> /// Clean up /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code //do not modify with code editor private void InitializeComponent() { this.buttonAddAccounts = new System.Windows.Forms.Button(); this.dataGridAccounts = new System.Windows.Forms.DataGrid(); ((System.ComponentModel.ISupportInitialize)(this.dataGridAccounts)).BeginInit(); this.SuspendLayout(); // // buttonAddAccounts // this.buttonAddAccounts.Location = new System.Drawing.Point(320, 112); this.buttonAddAccounts.Name = "buttonAddAccounts"; this.buttonAddAccounts.Size = new System.Drawing.Size(120, 32); this.buttonAddAccounts.TabIndex = 1; this.buttonAddAccounts.Text = "Add Accounts ..."; this.buttonAddAccounts.Click += new System.EventHandler(this.buttonAddAccounts_Click); // // dataGridAccounts // this.dataGridAccounts.DataMember = ""; this.dataGridAccounts.HeaderForeColor = System.Drawing.SystemColors.ControlText; this.dataGridAccounts.Location = new System.Drawing.Point(8, 0); this.dataGridAccounts.Name = "dataGridAccounts"; this.dataGridAccounts.Size = new System.Drawing.Size(296, 264); this.dataGridAccounts.TabIndex = 2; // // AccountViewer // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(456, 266); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.dataGridAccounts, this.buttonAddAccounts}); this.Name = "AccountViewer"; this.Text = "AccountViewer"; ((System.ComponentModel.ISupportInitialize)(this.dataGridAccounts)).EndInit(); this.ResumeLayout(false); } #endregion private void buttonAddAccounts_Click(object sender, System.EventArgs e) { //add code her for loading accounts } } } |
|
From: Marco M. <mi...@us...> - 2005-02-03 23:59:28
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/CallingReportsForRunnedScripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3600/CallingReportsForRunnedScripts Log Message: Directory /cvsroot/quantproject/QuantProject/b7_Scripts/CallingReportsForRunnedScripts added to the repository |
|
From: Glauco S. <gla...@us...> - 2005-02-03 00:35:15
|
Update of /cvsroot/quantproject/QuantProject In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18057 Modified Files: QuantProject.suo Log Message: An IndexBasedEndOfDayTimer is used, now. Index: QuantProject.suo =================================================================== RCS file: /cvsroot/quantproject/QuantProject/QuantProject.suo,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 Binary files /tmp/cvs0PyfsA and /tmp/cvsEEJpTN differ |
|
From: Glauco S. <gla...@us...> - 2005-02-03 00:30:49
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardOneRank In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17169/b7_Scripts/WalkForwardTesting/WalkForwardOneRank Modified Files: RunWalkForwardOneRank.cs EndOfDayTimerHandler.cs EligibleTickers.cs Log Message: An IndexBasedEndOfDayTimer is used, now. Index: EligibleTickers.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardOneRank/EligibleTickers.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** EligibleTickers.cs 29 Nov 2004 14:33:18 -0000 1.1 --- EligibleTickers.cs 3 Feb 2005 00:30:22 -0000 1.2 *************** *** 34,42 **** { private int numberEligibleTickersToBeChosen; private int numDaysToComputeLiquidity = 10; ! public EligibleTickers( int numberEligibleTickersToBeChosen ) { this.numberEligibleTickersToBeChosen = numberEligibleTickersToBeChosen; } --- 34,45 ---- { private int numberEligibleTickersToBeChosen; + private int numberDaysForPerformanceCalculation; private int numDaysToComputeLiquidity = 10; ! public EligibleTickers( int numberEligibleTickersToBeChosen , ! int numberDaysForPerformanceCalculation ) { this.numberEligibleTickersToBeChosen = numberEligibleTickersToBeChosen; + this.numberDaysForPerformanceCalculation = numberDaysForPerformanceCalculation; } *************** *** 44,53 **** private void setTickers_build( DateTime dateTime ) { ! TickerSelector tickerSelector = new TickerSelector( SelectionType.Liquidity , false , "Test" , dateTime.AddDays( - this.numDaysToComputeLiquidity ) , dateTime , this.numberEligibleTickersToBeChosen ); DataTable selectedTickers = ! tickerSelector.GetTableOfSelectedTickers(); foreach ( DataRow dataRow in selectedTickers.Rows ) this.Add( dataRow[ "tiTicker" ].ToString() , --- 47,64 ---- private void setTickers_build( DateTime dateTime ) { ! TickerSelector mostLiquid = new TickerSelector( SelectionType.Liquidity , false , "Test" , dateTime.AddDays( - this.numDaysToComputeLiquidity ) , dateTime , this.numberEligibleTickersToBeChosen ); + DataTable mostLiquidTickers = + mostLiquid.GetTableOfSelectedTickers(); + TickerSelector quotedInEachMarketDayFromMostLiquid = + new TickerSelector( mostLiquidTickers, + SelectionType.QuotedInEachMarketDay, false, "", + dateTime.AddDays( - this.numberDaysForPerformanceCalculation ) , + dateTime, this.numberEligibleTickersToBeChosen); + quotedInEachMarketDayFromMostLiquid.MarketIndex = "^SPX"; DataTable selectedTickers = ! quotedInEachMarketDayFromMostLiquid.GetTableOfSelectedTickers(); foreach ( DataRow dataRow in selectedTickers.Rows ) this.Add( dataRow[ "tiTicker" ].ToString() , Index: EndOfDayTimerHandler.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardOneRank/EndOfDayTimerHandler.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** EndOfDayTimerHandler.cs 29 Dec 2004 17:10:00 -0000 1.4 --- EndOfDayTimerHandler.cs 3 Feb 2005 00:30:22 -0000 1.5 *************** *** 91,95 **** this.account = account; ! this.eligibleTickers = new EligibleTickers( numberEligibleTickers ); this.bestPerformingTickers = new BestPerformingTickers( numberBestPeformingTickers , this.inSampleWindowDays ); --- 91,96 ---- this.account = account; ! this.eligibleTickers = new EligibleTickers( numberEligibleTickers , ! inSampleWindowDays ); this.bestPerformingTickers = new BestPerformingTickers( numberBestPeformingTickers , this.inSampleWindowDays ); Index: RunWalkForwardOneRank.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardOneRank/RunWalkForwardOneRank.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** RunWalkForwardOneRank.cs 9 Jan 2005 23:45:20 -0000 1.6 --- RunWalkForwardOneRank.cs 3 Feb 2005 00:30:21 -0000 1.7 *************** *** 67,71 **** new DateTime( 1998 , 1 , 1 ) , EndOfDaySpecificTime.MarketOpen ); this.endDateTime = new EndOfDayDateTime( ! new DateTime( 1998 , 1 , 30 ) , EndOfDaySpecificTime.OneHourAfterMarketClose ); this.numIntervalDays = 1; } --- 67,71 ---- new DateTime( 1998 , 1 , 1 ) , EndOfDaySpecificTime.MarketOpen ); this.endDateTime = new EndOfDayDateTime( ! new DateTime( 1998 , 8 , 31 ) , EndOfDaySpecificTime.OneHourAfterMarketClose ); this.numIntervalDays = 1; } *************** *** 74,78 **** { this.endOfDayTimer = ! new HistoricalEndOfDayTimer( this.startDateTime ); } private void run_initializeAccount() --- 74,78 ---- { this.endOfDayTimer = ! new IndexBasedEndOfDayTimer( this.startDateTime, "^SPX" ); } private void run_initializeAccount() *************** *** 86,90 **** private void run_initializeEndOfDayTimerHandler() { ! this.endOfDayTimerHandler = new EndOfDayTimerHandler( 50 , 20 , 5 , 360 , 30 , this.account ); } --- 86,90 ---- private void run_initializeEndOfDayTimerHandler() { ! this.endOfDayTimerHandler = new EndOfDayTimerHandler( 200 , 20 , 5 , 360 , 30 , this.account ); } *************** *** 126,131 **** Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { - this.oneHourAfterMarketCloseEventHandler_handleProgessBarForm( - ( IEndOfDayTimer )sender ); if ( ( ( IEndOfDayTimer )sender ).GetCurrentTime().DateTime > this.endDateTime.DateTime ) --- 126,129 ---- *************** *** 137,140 **** --- 135,142 ---- report.Show( "WFT One Rank" , this.numIntervalDays , this.endDateTime , "MSFT" ); } + else + // the simulation has not reached the ending date, yet + this.oneHourAfterMarketCloseEventHandler_handleProgessBarForm( + ( IEndOfDayTimer )sender ); } #endregion |
|
From: Glauco S. <gla...@us...> - 2005-02-03 00:30:49
|
Update of /cvsroot/quantproject/QuantProject/b91_QuantProject In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17169/b91_QuantProject Modified Files: Main.cs Log Message: An IndexBasedEndOfDayTimer is used, now. Index: Main.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b91_QuantProject/Main.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Main.cs 29 Nov 2004 16:12:37 -0000 1.6 --- Main.cs 3 Feb 2005 00:30:39 -0000 1.7 *************** *** 27,30 **** --- 27,31 ---- using System.Windows.Forms; using QuantProject.Scripts; + using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; using QuantProject.Scripts.WalkForwardTesting.WalkForwardOneRank; *************** *** 231,234 **** --- 232,236 ---- //new RunMSFTwalkForward().Run(); //new RunMultiTestOneRank().Run(); + //new RunEfficientCTOPorfolio().Run(); new RunWalkForwardOneRank().Run(); } |
|
From: Marco M. <mi...@us...> - 2005-01-30 19:58:20
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataTables In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4467/b3_Data/DataTables Modified Files: Quotes.cs Log Message: Added "[Serializable]" attribute in order to make the Account class serializable. Index: Quotes.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataTables/Quotes.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Quotes.cs 8 Jan 2005 11:51:57 -0000 1.10 --- Quotes.cs 30 Jan 2005 19:57:37 -0000 1.11 *************** *** 13,16 **** --- 13,17 ---- /// DataTable for quotes table data /// </summary> + [Serializable] public class Quotes : DataTable { |
|
From: Marco M. <mi...@us...> - 2005-01-30 19:57:50
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a4_Scripting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4467/b4_Business/a4_Scripting Modified Files: Script.cs Log Message: Added "[Serializable]" attribute in order to make the Account class serializable. Index: Script.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a4_Scripting/Script.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Script.cs 13 Oct 2003 21:59:28 -0000 1.1.1.1 --- Script.cs 30 Jan 2005 19:57:39 -0000 1.2 *************** *** 29,33 **** /// Summary description for Script. /// </summary> ! public class Script { public Script() --- 29,34 ---- /// Summary description for Script. /// </summary> ! [Serializable] ! public class Script { public Script() |
|
From: Marco M. <mi...@us...> - 2005-01-30 19:57:49
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4467/b4_Business/a05_Timing Modified Files: EndOfDayDateTime.cs HistoricalEndOfDayTimer.cs IndexBasedEndOfDayTimer.cs Log Message: Added "[Serializable]" attribute in order to make the Account class serializable. Index: EndOfDayDateTime.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing/EndOfDayDateTime.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** EndOfDayDateTime.cs 8 Jan 2005 11:46:49 -0000 1.3 --- EndOfDayDateTime.cs 30 Jan 2005 19:57:37 -0000 1.4 *************** *** 29,33 **** /// Date time to be used with end of day strategies /// </summary> ! public class EndOfDayDateTime : IComparable { private DateTime dateTime; --- 29,34 ---- /// Date time to be used with end of day strategies /// </summary> ! [Serializable] ! public class EndOfDayDateTime : IComparable { private DateTime dateTime; Index: HistoricalEndOfDayTimer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing/HistoricalEndOfDayTimer.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** HistoricalEndOfDayTimer.cs 15 Jan 2005 10:54:14 -0000 1.5 --- HistoricalEndOfDayTimer.cs 30 Jan 2005 19:57:38 -0000 1.6 *************** *** 30,33 **** --- 30,34 ---- /// IDataStreamer implementation using historical data /// </summary> + [Serializable] public class HistoricalEndOfDayTimer : IEndOfDayTimer { Index: IndexBasedEndOfDayTimer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing/IndexBasedEndOfDayTimer.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IndexBasedEndOfDayTimer.cs 15 Jan 2005 10:54:20 -0000 1.2 --- IndexBasedEndOfDayTimer.cs 30 Jan 2005 19:57:38 -0000 1.3 *************** *** 32,35 **** --- 32,36 ---- /// for time walking simulation /// </summary> + [Serializable] public class IndexBasedEndOfDayTimer : HistoricalEndOfDayTimer { |
|
From: Marco M. <mi...@us...> - 2005-01-30 19:57:49
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a3_Ordering In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4467/b4_Business/a1_Financial/a3_Ordering Modified Files: HistoricalEndOfDayOrderExecutor.cs Order.cs Log Message: Added "[Serializable]" attribute in order to make the Account class serializable. Index: Order.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a3_Ordering/Order.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Order.cs 29 Nov 2004 16:15:37 -0000 1.2 --- Order.cs 30 Jan 2005 19:57:38 -0000 1.3 *************** *** 33,37 **** /// Summary description for Order. /// </summary> ! public class Order { private OrderType orderType; --- 33,38 ---- /// Summary description for Order. /// </summary> ! [Serializable] ! public class Order { private OrderType orderType; Index: HistoricalEndOfDayOrderExecutor.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a3_Ordering/HistoricalEndOfDayOrderExecutor.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** HistoricalEndOfDayOrderExecutor.cs 9 Jan 2005 23:15:21 -0000 1.3 --- HistoricalEndOfDayOrderExecutor.cs 30 Jan 2005 19:57:38 -0000 1.4 *************** *** 36,39 **** --- 36,40 ---- /// Simulates historical order executions/rejections for end of day simulation /// </summary> + [Serializable] public class HistoricalEndOfDayOrderExecutor : IOrderExecutor { |
|
From: Marco M. <mi...@us...> - 2005-01-30 19:57:49
|
Update of /cvsroot/quantproject/QuantProject/b5_Presentation/Reporting/WindowsForm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4467/b5_Presentation/Reporting/WindowsForm Modified Files: Report.cs Log Message: Added "[Serializable]" attribute in order to make the Account class serializable. Index: Report.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b5_Presentation/Reporting/WindowsForm/Report.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Report.cs 9 Jan 2005 23:44:15 -0000 1.4 --- Report.cs 30 Jan 2005 19:57:39 -0000 1.5 *************** *** 33,36 **** --- 33,38 ---- /// Windows Form account report /// </summary> + + [Serializable] public class Report : Form { |
|
From: Marco M. <mi...@us...> - 2005-01-30 19:57:49
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4467/b4_Business/a07_DataProviders Modified Files: HistoricalAdjustedQuoteProvider.cs HistoricalEndOfDayDataStreamer.cs Log Message: Added "[Serializable]" attribute in order to make the Account class serializable. Index: HistoricalEndOfDayDataStreamer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders/HistoricalEndOfDayDataStreamer.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** HistoricalEndOfDayDataStreamer.cs 9 Jan 2005 23:15:19 -0000 1.3 --- HistoricalEndOfDayDataStreamer.cs 30 Jan 2005 19:57:38 -0000 1.4 *************** *** 32,35 **** --- 32,36 ---- /// IDataStreamer implementation using end of day historical data /// </summary> + [Serializable] public class HistoricalEndOfDayDataStreamer : IDataStreamer { Index: HistoricalAdjustedQuoteProvider.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders/HistoricalAdjustedQuoteProvider.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HistoricalAdjustedQuoteProvider.cs 9 Jan 2005 23:31:53 -0000 1.1 --- HistoricalAdjustedQuoteProvider.cs 30 Jan 2005 19:57:38 -0000 1.2 *************** *** 31,34 **** --- 31,35 ---- /// Returns historical adjusted quotes /// </summary> + [Serializable] public class HistoricalAdjustedQuoteProvider : IHistoricalQuoteProvider { |
|
From: Marco M. <mi...@us...> - 2005-01-30 19:57:49
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4467/b4_Business/a1_Financial/a2_Accounting/h5_Reporting Modified Files: AccountReport.cs ReportTable.cs Log Message: Added "[Serializable]" attribute in order to make the Account class serializable. Index: AccountReport.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/AccountReport.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** AccountReport.cs 9 Jan 2005 19:40:48 -0000 1.9 --- AccountReport.cs 30 Jan 2005 19:57:38 -0000 1.10 *************** *** 39,42 **** --- 39,43 ---- /// Summary description for AccountReport. /// </summary> + [Serializable] public class AccountReport { Index: ReportTable.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/ReportTable.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ReportTable.cs 28 Nov 2003 16:06:20 -0000 1.3 --- ReportTable.cs 30 Jan 2005 19:57:38 -0000 1.4 *************** *** 29,32 **** --- 29,34 ---- /// Summary description for ExcelSheet. /// </summary> + + [Serializable] public class ReportTable { |
|
From: Marco M. <mi...@us...> - 2005-01-30 19:55:45
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4123/b1_ADT Modified Files: b1_ADT.csproj Log Message: Added ObjectArchiver for serializing objects into files. Index: b1_ADT.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/b1_ADT.csproj,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** b1_ADT.csproj 14 Dec 2004 21:18:04 -0000 1.12 --- b1_ADT.csproj 30 Jan 2005 19:55:36 -0000 1.13 *************** *** 138,141 **** --- 138,146 ---- /> <File + RelPath = "FileManaging\ObjectArchiver.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Histories\History.cs" SubType = "Code" |
|
From: Marco M. <mi...@us...> - 2005-01-30 19:55:45
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/FileManaging In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4123/b1_ADT/FileManaging Added Files: ObjectArchiver.cs Log Message: Added ObjectArchiver for serializing objects into files. --- NEW FILE: ObjectArchiver.cs --- /* QuantProject - Quantitative Finance Library ObjectArchiver.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.IO; using System.Runtime.Serialization.Formatters.Binary; namespace QuantProject.ADT.FileManaging { /// <summary> /// Implements static methods /// to save and load objects through serialization / deserialization /// </summary> public class ObjectArchiver { private static Stream stream; private static BinaryFormatter formatter; private static Object archive; private static string fileName; private static string directoryPath; public static void Archive(Object objectToArchive, string fileName, string directoryPath) { try { ObjectArchiver.archive = objectToArchive; ObjectArchiver.setDiskPosition(fileName, directoryPath); ObjectArchiver.setVariables(); ObjectArchiver.formatter.Serialize(ObjectArchiver.stream, objectToArchive); } catch(Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); } finally { ObjectArchiver.stream.Close(); } } private static void setDiskPosition(string fileName, string directoryPath) { ObjectArchiver.fileName = fileName; ObjectArchiver.directoryPath = directoryPath; } private static void setVariables() { ObjectArchiver.stream = new FileStream( ObjectArchiver.directoryPath + ObjectArchiver.fileName, FileMode.Create, FileAccess.Write, FileShare.None); ObjectArchiver.formatter = new BinaryFormatter(); } public static object Extract(string fileName, string directoryPath) { try { ObjectArchiver.setDiskPosition(fileName, directoryPath); ObjectArchiver.setVariables(); return ObjectArchiver.formatter.Deserialize(ObjectArchiver.stream); } catch(Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); return new Object(); //just to avoid compiling error //throw new Exception("Extracting object failed!"); } finally { ObjectArchiver.stream.Close(); } } } } |
|
From: Marco M. <mi...@us...> - 2005-01-30 19:53:29
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3550/b7_Scripts Modified Files: b7_Scripts.csproj Log Message: New structure for the classes that make up script for the efficient portfolio. Now, the genomeManagers (for close to open and close to close portfolio) for the genetic optimizer derive from a common base class GenomeManagerForTheEfficientPortfolio. Handlers and Runs have been renamed. Index: b7_Scripts.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/b7_Scripts.csproj,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** b7_Scripts.csproj 20 Jan 2005 01:11:33 -0000 1.18 --- b7_Scripts.csproj 30 Jan 2005 19:53:13 -0000 1.19 *************** *** 144,148 **** /> <File ! RelPath = "TickerSelectionTesting\EndOfDayTimerHandler.cs" SubType = "Code" BuildAction = "Compile" --- 144,158 ---- /> <File ! RelPath = "TickerSelectionTesting\EndOfDayTimerHandlerCTC.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "TickerSelectionTesting\EndOfDayTimerHandlerCTO.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "TickerSelectionTesting\GenomeManagerForEfficientCTCPortfolio.cs" SubType = "Code" BuildAction = "Compile" *************** *** 159,168 **** /> <File ! RelPath = "TickerSelectionTesting\RunEfficientCTOPortfolio.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "TickerSelectionTesting\RunEfficientPortfolio.cs" SubType = "Code" BuildAction = "Compile" --- 169,178 ---- /> <File ! RelPath = "TickerSelectionTesting\RunEfficientCTCPortfolio.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "TickerSelectionTesting\RunEfficientCTOPortfolio.cs" SubType = "Code" BuildAction = "Compile" |
|
From: Marco M. <mi...@us...> - 2005-01-30 19:53:29
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3550/b7_Scripts/TickerSelectionTesting Modified Files: GenomeManagerForEfficientCTOPortfolio.cs GenomeManagerForEfficientPortfolio.cs RunEfficientCTOPortfolio.cs Added Files: EndOfDayTimerHandlerCTC.cs EndOfDayTimerHandlerCTO.cs GenomeManagerForEfficientCTCPortfolio.cs RunEfficientCTCPortfolio.cs Removed Files: EndOfDayTimerHandler.cs RunEfficientPortfolio.cs Log Message: New structure for the classes that make up script for the efficient portfolio. Now, the genomeManagers (for close to open and close to close portfolio) for the genetic optimizer derive from a common base class GenomeManagerForTheEfficientPortfolio. Handlers and Runs have been renamed. --- NEW FILE: EndOfDayTimerHandlerCTO.cs --- /* QuantProject - Quantitative Finance Library EndOfDayTimerHandlerCTO.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.Data; 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.ADT.Optimizing.Genetic; namespace QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios { /// <summary> /// Implements MarketOpenEventHandler, /// TwoMinutesBeforeMarketCloseEventHandler and OneHourAfterMarketCloseEventHandler /// These handlers contain the core strategy for the efficient close to open portfolio! /// </summary> public class EndOfDayTimerHandlerCTO { private DataTable eligibleTickers; private string[] chosenTickers; //private string[] lastChosenTickers; private string tickerGroupID; private int numberOfEligibleTickers; private int numberOfTickersToBeChosen; private int generationNumberForGeneticOptimizer; private Account account; private ArrayList orders; public int NumberOfEligibleTickers { get { return this.numberOfEligibleTickers; } } public Account Account { get { return this.account; } } public EndOfDayTimerHandlerCTO(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, Account account, int generationNumberForGeneticOptimizer) { this.tickerGroupID = tickerGroupID; this.numberOfEligibleTickers = numberOfEligibleTickers; this.numberOfTickersToBeChosen = numberOfTickersToBeChosen; this.account = account; this.generationNumberForGeneticOptimizer = generationNumberForGeneticOptimizer; this.orders = new ArrayList(); this.chosenTickers = new string[numberOfTickersToBeChosen]; //this.lastChosenTickers = new string[numberOfTickersToBeChosen]; } #region MarketOpenEventHandler private void marketOpenEventHandler_orderChosenTickers_addToOrderList_forTicker( string ticker ) { double cashForSinglePosition = this.account.CashAmount / this.numberOfTickersToBeChosen; long quantity = Convert.ToInt64( Math.Floor( cashForSinglePosition / this.account.DataStreamer.GetCurrentBid( ticker ) ) ); Order order = new Order( OrderType.MarketBuy, new Instrument( ticker ) , quantity ); this.orders.Add(order); } private void marketOpenEventHandler_orderChosenTickers_addToOrderList() { foreach ( string ticker in this.chosenTickers ) { if(ticker != null) marketOpenEventHandler_orderChosenTickers_addToOrderList_forTicker( ticker ); } } private void marketOpenEventHandler_orderChosenTickers() { this.marketOpenEventHandler_orderChosenTickers_addToOrderList(); } /// <summary> /// Handles a "Market Open" event. /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> public void MarketOpenEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { if(this.orders.Count == 0 && this.account.Transactions.Count == 0) this.account.AddCash(15000); this.marketOpenEventHandler_orderChosenTickers(); foreach(object item in this.orders) { this.account.AddOrder((Order)item); } } #endregion #region MarketCloseEventHandler private void marketCloseEventHandler_closePosition( string ticker ) { this.account.ClosePosition( ticker ); } private void marketCloseEventHandler_closePositions() { if(this.chosenTickers != null) { foreach( string ticker in this.chosenTickers) { for(int i = 0; i<this.account.Portfolio.Keys.Count; i++) { if(this.account.Portfolio[ticker]!=null) marketCloseEventHandler_closePosition( ticker ); } } } } public void MarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { this.marketCloseEventHandler_closePositions(); } #endregion #region OneHourAfterMarketCloseEventHandler private DataTable getSetOfTickersToBeOptimized(DateTime currentDate) { TickerSelector mostLiquid = new TickerSelector(SelectionType.Liquidity, false, this.tickerGroupID , currentDate.AddDays(-45), currentDate, this.numberOfEligibleTickers); this.eligibleTickers = mostLiquid.GetTableOfSelectedTickers(); TickerSelector quotedInEachMarketDayFromMostLiquid = new TickerSelector( this.eligibleTickers, SelectionType.QuotedInEachMarketDay, false, "", currentDate.AddDays(-45),currentDate, this.numberOfEligibleTickers); quotedInEachMarketDayFromMostLiquid.MarketIndex = "^MIBTEL"; return quotedInEachMarketDayFromMostLiquid.GetTableOfSelectedTickers(); } private void setTickers(DateTime currentDate) { //this.lastChosenTickers = this.chosenTickers; 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 { IGenomeManager genManEfficientCTOPortfolio = new GenomeManagerForEfficientCTOPortfolio(setOfTickersToBeOptimized, currentDate.AddDays(-30), currentDate, this.numberOfTickersToBeChosen, 1, 0.005); GeneticOptimizer GO = new GeneticOptimizer(genManEfficientCTOPortfolio); //GO.KeepOnRunningUntilConvergenceIsReached = true; GO.GenerationNumber = this.generationNumberForGeneticOptimizer; GO.Run(false); this.chosenTickers = (string[])GO.BestGenome.Meaning; //this.lastChosenTickers = this.chosenTickers; } //else it will be buyed again the previous optimized portfolio //that's it the actual chosenTickers member } /// <summary> /// Handles a "One hour after market close" event. /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> public void OneHourAfterMarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { this.setTickers(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime); //sets tickers to be chosen next Market Open event this.orders.Clear(); } #endregion } } --- EndOfDayTimerHandler.cs DELETED --- --- NEW FILE: RunEfficientCTCPortfolio.cs --- /* QuantProject - Quantitative Finance Library RunEfficientCTCPorfolio.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 System.Data; using QuantProject.ADT; using QuantProject.ADT.Optimizing.Genetic; using QuantProject.Business.DataProviders; using QuantProject.Business.Financial.Accounting; using QuantProject.Business.Financial.Accounting.Reporting; using QuantProject.Business.Financial.Instruments; using QuantProject.Business.Financial.Ordering; using QuantProject.Business.Scripting; using QuantProject.Business.Strategies; using QuantProject.Business.Testing; using QuantProject.Business.Timing; using QuantProject.Data.DataProviders; using QuantProject.Data.Selectors; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; using QuantProject.Presentation.Reporting.WindowsForm; using QuantProject.ADT.FileManaging; namespace QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios { /// <summary> /// Script to buy at close and sell at close /// after a specified number of market days /// the efficient portfolio /// The efficient portfolio's generation rules /// (contained in the EndOfDayTimerHandler) are: /// - choose the most liquid tickers; /// - choose only tickers quoted at each market day /// during a given previous interval of days; /// - choose the most efficient portfolio among these tickers /// </summary> [Serializable] public class RunEfficientCTCPorfolio : Script { private ReportTable reportTable; private EndOfDayDateTime startDateTime; private EndOfDayDateTime endDateTime; private int numIntervalDays;// number of days for the equity line graph private IHistoricalQuoteProvider historicalQuoteProvider = new HistoricalAdjustedQuoteProvider(); //private ProgressBarForm progressBarForm; private EndOfDayTimerHandlerCTC endOfDayTimerHandler; private Account account; private IEndOfDayTimer endOfDayTimer; public RunEfficientCTCPorfolio() { //this.progressBarForm = new ProgressBarForm(); this.reportTable = new ReportTable( "Summary_Reports" ); this.startDateTime = new EndOfDayDateTime( new DateTime( 2003 , 1 , 1 ) , EndOfDaySpecificTime.MarketOpen ); this.endDateTime = new EndOfDayDateTime( new DateTime( 2003 , 1 , 31 ) , EndOfDaySpecificTime.MarketClose ); this.numIntervalDays = 3; //for report } #region Run private void run_initializeEndOfDayTimer() { this.endOfDayTimer = new IndexBasedEndOfDayTimer( this.startDateTime, "^MIBTEL" ); } private void run_initializeAccount() { this.account = new Account( "EfficientCloseToClosePortfolio" , this.endOfDayTimer , new HistoricalEndOfDayDataStreamer( this.endOfDayTimer , this.historicalQuoteProvider ) , new HistoricalEndOfDayOrderExecutor( this.endOfDayTimer , this.historicalQuoteProvider ) ); } private void run_initializeEndOfDayTimerHandler() { this.endOfDayTimerHandler = new EndOfDayTimerHandlerCTC("STOCKMI",70,5,3,this.account,10); } /* private void inSampleNewProgressEventHandler( Object sender , NewProgressEventArgs eventArgs ) { this.progressBarForm.ProgressBarInSample.Value = eventArgs.CurrentProgress; this.progressBarForm.ProgressBarInSample.Refresh(); } private void run_initializeProgressHandlers() { this.endOfDayTimerHandler.InSampleNewProgress += new InSampleNewProgressEventHandler( this.inSampleNewProgressEventHandler ); } */ #region oneHourAfterMarketCloseEventHandler /* private void oneHourAfterMarketCloseEventHandler_handleProgessBarForm( IEndOfDayTimer endOfDayTimer ) { long elapsedDays = Convert.ToInt64( ((TimeSpan)( endOfDayTimer.GetCurrentTime().DateTime - this.startDateTime.DateTime )).TotalDays ); long totalDays = Convert.ToInt64( ((TimeSpan)( this.endDateTime.DateTime - this.startDateTime.DateTime )).TotalDays ); if ( Math.Floor( elapsedDays / totalDays * 100 ) > Math.Floor( ( elapsedDays - 1 ) / totalDays * 100 ) ) // a new out of sample time percentage point has been elapsed this.progressBarForm.ProgressBarOutOfSample.Value = Convert.ToInt16( Math.Floor( elapsedDays / totalDays * 100 ) ); } public void oneHourAfterMarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { this.oneHourAfterMarketCloseEventHandler_handleProgessBarForm( ( IEndOfDayTimer )sender ); if ( ( ( IEndOfDayTimer )sender ).GetCurrentTime().DateTime > this.endDateTime.DateTime ) { // the simulation has reached the ending date this.account.EndOfDayTimer.Stop(); this.progressBarForm.Close(); } } */ #endregion private void checkDateForReport(Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs) { Report report; if(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime>=this.endDateTime.DateTime ) { this.endOfDayTimer.Stop(); report = new Report( this.account , this.historicalQuoteProvider ); report.Show("CTC_Portfolio" , this.numIntervalDays , this.endDateTime , "^MIBTEL" ); //ObjectArchiver.Archive(this.account, "CtcPortfolioAccount.qP","C:\\"); } } public override void Run() { //old script //this.run_FindBestPortfolioForNextTrade(); run_initializeEndOfDayTimer(); run_initializeAccount(); run_initializeEndOfDayTimerHandler(); //run_initializeProgressHandlers(); this.endOfDayTimer.MarketOpen += new MarketOpenEventHandler( this.endOfDayTimerHandler.MarketOpenEventHandler); this.endOfDayTimer.MarketClose += new MarketCloseEventHandler( this.endOfDayTimerHandler.MarketCloseEventHandler); this.endOfDayTimer.MarketClose += new MarketCloseEventHandler( this.checkDateForReport); //this.endOfDayTimer.OneHourAfterMarketClose += //new OneHourAfterMarketCloseEventHandler( //this.endOfDayTimerHandler.OneHourAfterMarketCloseEventHandler ); //this.endOfDayTimer.OneHourAfterMarketClose += //new OneHourAfterMarketCloseEventHandler( //this.oneHourAfterMarketCloseEventHandler ); //this.progressBarForm.Show(); this.endOfDayTimer.Start(); } #endregion } } --- RunEfficientPortfolio.cs DELETED --- --- NEW FILE: EndOfDayTimerHandlerCTC.cs --- /* QuantProject - Quantitative Finance Library EndOfDayTimerHandlerCTC.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.Data; 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.ADT.Optimizing.Genetic; namespace QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios { /// <summary> /// Implements MarketOpenEventHandler and MarketCloseEventHandler /// These handlers contain the core strategy for the efficient close to close /// portfolio (with a given days of life)! /// </summary> [Serializable] public class EndOfDayTimerHandlerCTC { private DataTable eligibleTickers; private string[] chosenTickers; private string[] lastChosenTickers; private string tickerGroupID; private int numberOfEligibleTickers; private int numberOfTickersToBeChosen; private int numDaysOfPortfolioLife; private int daysCounter; private int generationNumberForGeneticOptimizer; private Account account; private ArrayList orders; public int NumberOfEligibleTickers { get { return this.numberOfEligibleTickers; } } public Account Account { get { return this.account; } } public EndOfDayTimerHandlerCTC(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysOfPortfolioLife, Account account, int generationNumberForGeneticOptimizer) { this.tickerGroupID = tickerGroupID; this.numberOfEligibleTickers = numberOfEligibleTickers; this.numberOfTickersToBeChosen = numberOfTickersToBeChosen; this.numDaysOfPortfolioLife = numDaysOfPortfolioLife; this.daysCounter = 0; this.account = account; this.generationNumberForGeneticOptimizer = generationNumberForGeneticOptimizer; this.orders = new ArrayList(); this.chosenTickers = new string[numberOfTickersToBeChosen]; this.lastChosenTickers = new string[numberOfTickersToBeChosen]; } #region MarketOpenEventHandler private DataTable getSetOfTickersToBeOptimized(DateTime currentDate) { TickerSelector mostLiquid = new TickerSelector(SelectionType.Liquidity, false, this.tickerGroupID , currentDate.AddDays(-90), currentDate, this.numberOfEligibleTickers); this.eligibleTickers = mostLiquid.GetTableOfSelectedTickers(); TickerSelector quotedInEachMarketDayFromMostLiquid = new TickerSelector( this.eligibleTickers, SelectionType.QuotedInEachMarketDay, false, "", currentDate.AddDays(-90),currentDate, this.numberOfEligibleTickers); quotedInEachMarketDayFromMostLiquid.MarketIndex = "^MIBTEL"; return quotedInEachMarketDayFromMostLiquid.GetTableOfSelectedTickers(); } private void setTickers(DateTime currentDate) { 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 { IGenomeManager genManEfficientCTCPortfolio = new GenomeManagerForEfficientCTCPortfolio(setOfTickersToBeOptimized, currentDate.AddDays(-90), currentDate, this.numberOfTickersToBeChosen, this.numDaysOfPortfolioLife, 0.01); GeneticOptimizer GO = new GeneticOptimizer(genManEfficientCTCPortfolio); //GO.KeepOnRunningUntilConvergenceIsReached = true; GO.GenerationNumber = this.generationNumberForGeneticOptimizer; GO.Run(false); this.chosenTickers = (string[])GO.BestGenome.Meaning; } //else it will be buyed again the previous optimized portfolio //that's it the actual chosenTickers member } /// <summary> /// Handles a "Market Open" event. /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> public void MarketOpenEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { if(this.daysCounter == 0 || this.daysCounter == this.numDaysOfPortfolioLife - 1) //at next close it will be time to open a new portfolio { this.setTickers(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime); //sets tickers to be chosen at next close this.orders.Clear(); } } #endregion #region MarketCloseEventHandler private void marketCloseEventHandler_orderChosenTickers_addToOrderList_forTicker(string ticker) { double cashForSinglePosition = this.account.CashAmount / this.numberOfTickersToBeChosen; long quantity = Convert.ToInt64( Math.Floor( cashForSinglePosition / this.account.DataStreamer.GetCurrentBid( ticker ) ) ); Order order = new Order( OrderType.MarketBuy, new Instrument( ticker ) , quantity ); this.orders.Add(order); } private void marketCloseEventHandler_orderChosenTickers_addToOrderList() { int idx = 0; foreach ( string ticker in this.chosenTickers ) { this.lastChosenTickers[idx] = ticker; if(ticker != null) marketCloseEventHandler_orderChosenTickers_addToOrderList_forTicker( ticker ); idx++; } } private void marketCloseEventHandler_orderChosenTickers() { this.marketCloseEventHandler_orderChosenTickers_addToOrderList(); } private void marketCloseEventHandler_openPositions() { if(this.orders.Count == 0 && this.account.Transactions.Count == 0) this.account.AddCash(15000); this.marketCloseEventHandler_orderChosenTickers(); foreach(object item in this.orders) { this.account.AddOrder((Order)item); } } private void marketCloseEventHandler_closePosition( string ticker ) { this.account.ClosePosition( ticker ); } private void marketCloseEventHandler_closePositions() { if(this.lastChosenTickers != null) { foreach( string ticker in this.lastChosenTickers) { for(int i = 0; i<this.account.Portfolio.Keys.Count; i++) { if(this.account.Portfolio[ticker]!=null) marketCloseEventHandler_closePosition( ticker ); } } } } public void MarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { this.daysCounter++; if(this.daysCounter == this.numDaysOfPortfolioLife) //it's time to change portfolio { this.marketCloseEventHandler_closePositions(); this.marketCloseEventHandler_openPositions(); this.daysCounter = 0; } } #endregion } } --- NEW FILE: GenomeManagerForEfficientCTCPortfolio.cs --- /* QuantProject - Quantitative Finance Library GenomeManagerForEfficientCTCPortfolio.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.Data; using System.Collections; using QuantProject.ADT.Statistics; using QuantProject.ADT.Optimizing.Genetic; using QuantProject.Data; using QuantProject.Data.DataTables; namespace QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios { /// <summary> /// Class to find efficient /// portfolios based on tickers' CloseToClose rates (adjusted values), /// using the GeneticOptimizer /// </summary> public class GenomeManagerForEfficientCTCPortfolio : GenomeManagerForEfficientPortfolio { public GenomeManagerForEfficientCTCPortfolio(DataTable setOfInitialTickers, DateTime firstQuoteDate, DateTime lastQuoteDate, int numberOfTickersInPortfolio, int numDaysOfPortfolioLife, double targetPerformance) : base(setOfInitialTickers, firstQuoteDate, lastQuoteDate, numberOfTickersInPortfolio, numDaysOfPortfolioLife, targetPerformance) { } public override object Decode(Genome genome) { string[] arrayOfTickers = new string[genome.Genes().Length]; int indexOfTicker; for(int index = 0; index < genome.Genes().Length; index++) { indexOfTicker = (int)genome.Genes().GetValue(index); arrayOfTickers[index] = (string)this.setOfTickers.Rows[indexOfTicker][0]; } return arrayOfTickers; } protected override float[] getArrayOfRatesOfReturn(string ticker) { Quotes tickerQuotes = new Quotes(ticker, this.firstQuoteDate, this.lastQuoteDate); float[] allAdjValues = ExtendedDataTable.GetArrayOfFloatFromColumn(tickerQuotes, "quAdjustedClose"); float[] ratesOfReturns = new float[allAdjValues.Length/this.numDaysOfPortfolioLife + 1]; int i = 0; //index for ratesOfReturns array for(int idx = 0; idx + this.numDaysOfPortfolioLife < allAdjValues.Length; idx += this.numDaysOfPortfolioLife ) { ratesOfReturns[i] = allAdjValues[idx+this.numDaysOfPortfolioLife]/ allAdjValues[idx] - 1; i++; } return ratesOfReturns; } } } Index: RunEfficientCTOPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunEfficientCTOPortfolio.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** RunEfficientCTOPortfolio.cs 15 Jan 2005 10:56:03 -0000 1.9 --- RunEfficientCTOPortfolio.cs 30 Jan 2005 19:53:11 -0000 1.10 *************** *** 70,74 **** //private ProgressBarForm progressBarForm; ! private EndOfDayTimerHandler endOfDayTimerHandler; private Account account; --- 70,74 ---- //private ProgressBarForm progressBarForm; ! private EndOfDayTimerHandlerCTO endOfDayTimerHandler; private Account account; *************** *** 81,88 **** this.reportTable = new ReportTable( "Summary_Reports" ); this.startDateTime = new EndOfDayDateTime( ! new DateTime( 2000 , 1 , 1 ) , EndOfDaySpecificTime.FiveMinutesBeforeMarketClose ); this.endDateTime = new EndOfDayDateTime( ! new DateTime( 2000 , 12 , 31 ) , EndOfDaySpecificTime.OneHourAfterMarketClose ); ! this.numIntervalDays = 7; } #region Run --- 81,88 ---- this.reportTable = new ReportTable( "Summary_Reports" ); this.startDateTime = new EndOfDayDateTime( ! new DateTime( 2002 , 1 , 1 ) , EndOfDaySpecificTime.FiveMinutesBeforeMarketClose ); this.endDateTime = new EndOfDayDateTime( ! new DateTime( 2002 , 1 , 20 ) , EndOfDaySpecificTime.OneHourAfterMarketClose ); ! this.numIntervalDays = 2; } #region Run *************** *** 97,101 **** IGenomeManager genManEfficientCTOPortfolio = new GenomeManagerForEfficientCTOPortfolio(tickers,firstDate, ! lastDate, 6, 0.005, 0.05); GeneticOptimizer GO = new GeneticOptimizer(genManEfficientCTOPortfolio); //GO.KeepOnRunningUntilConvergenceIsReached = true; --- 97,101 ---- IGenomeManager genManEfficientCTOPortfolio = new GenomeManagerForEfficientCTOPortfolio(tickers,firstDate, ! lastDate, 6,1, 0.005); GeneticOptimizer GO = new GeneticOptimizer(genManEfficientCTOPortfolio); //GO.KeepOnRunningUntilConvergenceIsReached = true; *************** *** 124,128 **** private void run_initializeEndOfDayTimerHandler() { ! this.endOfDayTimerHandler = new EndOfDayTimerHandler("STOCKMI",70,6,this.account,7); } /* --- 124,128 ---- private void run_initializeEndOfDayTimerHandler() { ! this.endOfDayTimerHandler = new EndOfDayTimerHandlerCTO("STOCKMI",70,5,this.account,10); } /* Index: GenomeManagerForEfficientPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/GenomeManagerForEfficientPortfolio.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** GenomeManagerForEfficientPortfolio.cs 1 Dec 2004 22:40:03 -0000 1.1 --- GenomeManagerForEfficientPortfolio.cs 30 Jan 2005 19:53:11 -0000 1.2 *************** *** 32,57 **** namespace QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios { ! /// <summary> ! /// This class implements IGenomeManager, in order to find efficient ! /// portfolios based on the comparison of adjustedClose values for each ! /// portfolio's ticker ! /// at the beginning and at the end of a specified interval of days, using the ! /// GeneticOptimizer ! /// </summary> public class GenomeManagerForEfficientPortfolio : IGenomeManager { ! private int genomeSize; ! private int minValueForGenes; ! private int maxValueForGenes; ! ! private int intervalLength; ! ! private DataTable setOfTickers; ! private DateTime firstQuoteDate; ! private DateTime lastQuoteDate; ! private double targetPerformance; ! private double targetStdDev; ! private double variance; ! private double rateOfReturn; //IGenomeManager implementation for properties --- 32,52 ---- namespace QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios { ! /// <summary> ! /// This is the base class implementing IGenomeManager, in order to find ! /// efficient portfolios using the GeneticOptimizer ! /// </summary> public class GenomeManagerForEfficientPortfolio : IGenomeManager { ! protected int genomeSize; ! protected int minValueForGenes; ! protected int maxValueForGenes; ! ! protected DataTable setOfTickers; ! protected DateTime firstQuoteDate; ! protected DateTime lastQuoteDate; ! protected int numDaysOfPortfolioLife; ! protected double targetPerformance; ! protected double variance; ! protected double rateOfReturn; //IGenomeManager implementation for properties *************** *** 82,105 **** } ! public GenomeManagerForEfficientPortfolio(int intervalLengthInDays, ! DataTable setOfInitialTickers, ! DateTime firstQuoteDate, ! DateTime lastQuoteDate, ! int numberOfTickersInPortfolio, ! double targetPerformance, ! double targetStdDev) { this.setOfTickers = setOfInitialTickers; ! this.intervalLength = intervalLengthInDays; ! //arrayOfRatesOfReturn contains the rates of return computed for the given interval in days if(!this.setOfTickers.Columns.Contains("ArrayOfRatesOfReturn")) ! this.setOfTickers.Columns.Add("ArrayOfRatesOfReturn", System.Type.GetType("System.Array")); this.firstQuoteDate = firstQuoteDate; this.lastQuoteDate = lastQuoteDate; ! this.targetPerformance = targetPerformance; ! this.targetStdDev = targetStdDev; this.genomeSize = numberOfTickersInPortfolio; ! //each genes is the index for the setOfTickers table this.minValueForGenes = 0; this.maxValueForGenes = this.setOfTickers.Rows.Count - 1; --- 77,98 ---- } ! public GenomeManagerForEfficientPortfolio( DataTable setOfInitialTickers, ! DateTime firstQuoteDate, ! DateTime lastQuoteDate, ! int numberOfTickersInPortfolio, ! int numDaysOfPortfolioLife, ! double targetPerformance) { this.setOfTickers = setOfInitialTickers; ! if(!this.setOfTickers.Columns.Contains("ArrayOfRatesOfReturn")) ! this.setOfTickers.Columns.Add("ArrayOfRatesOfReturn", System.Type.GetType("System.Array")); this.firstQuoteDate = firstQuoteDate; this.lastQuoteDate = lastQuoteDate; ! this.targetPerformance = targetPerformance; this.genomeSize = numberOfTickersInPortfolio; ! this.numDaysOfPortfolioLife = numDaysOfPortfolioLife; ! //each genes is the index for the setOfTickers table this.minValueForGenes = 0; this.maxValueForGenes = this.setOfTickers.Rows.Count - 1; *************** *** 108,125 **** } ! public double GetFitnessValue(Genome genome) { ! //parameters used to balance the rate of return against variance ! double a=2.5, b=2.0; ! double portofolioVariance = this.getPortfolioVariance(genome.Genes()); double portfolioRateOfReturn = this.getPortfolioRateOfReturn(genome.Genes()); ! this.variance = portofolioVariance; this.rateOfReturn = portfolioRateOfReturn; ! //double returnValue = System.Math.Pow(((this.targetStdDev*this.targetStdDev)/portofolioVariance),a)* ! //System.Math.Pow((portfolioRateOfReturn/this.targetPerformance),b); ! ! double returnValue = System.Math.Pow(((this.targetStdDev*this.targetStdDev)/portofolioVariance),a)* ! System.Math.Pow(System.Math.Max(0.0,(portfolioRateOfReturn/this.targetPerformance)),b); return returnValue; } --- 101,115 ---- } ! public virtual double GetFitnessValue(Genome genome) { ! double returnValue; ! double portfolioVariance = this.getPortfolioVariance(genome.Genes()); double portfolioRateOfReturn = this.getPortfolioRateOfReturn(genome.Genes()); ! this.variance = portfolioVariance; this.rateOfReturn = portfolioRateOfReturn; ! NormalDistribution normal = new NormalDistribution(portfolioRateOfReturn, Math.Sqrt(portfolioVariance)); ! //returnValue = normal.GetProbability(this.targetPerformance*0.5,this.targetPerformance*1.5); ! returnValue = 1 - normal.GetProbability(this.targetPerformance); return returnValue; } *************** *** 151,166 **** // 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)) { newValueForGene = GenomeManagement.RandomGenerator.Next(genome.MinValueForGenes, ! genome.MaxValueForGenes +1); } GenomeManagement.MutateOneGene(genome, mutationRate, ! genePositionToBeMutated, newValueForGene); } ! public object Decode(Genome genome) { string sequenceOfTickers = ""; --- 141,156 ---- // 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)) { newValueForGene = GenomeManagement.RandomGenerator.Next(genome.MinValueForGenes, ! genome.MaxValueForGenes +1); } GenomeManagement.MutateOneGene(genome, mutationRate, ! genePositionToBeMutated, newValueForGene); } ! public virtual object Decode(Genome genome) { string sequenceOfTickers = ""; *************** *** 172,181 **** returnValue = sequenceOfTickers; returnValue += "(rate: " + this.RateOfReturn + " std: " + ! System.Math.Sqrt(this.Variance) + ")"; return returnValue; } // end of implementation of IGenomeManager ! private double getPortfolioVariance(int[] tickerIdx) { double sumOfVariances = this.getSumOfVariances(tickerIdx); --- 162,171 ---- returnValue = sequenceOfTickers; returnValue += "(rate: " + this.RateOfReturn + " std: " + ! System.Math.Sqrt(this.Variance) + ")"; return returnValue; } // end of implementation of IGenomeManager ! protected double getPortfolioVariance(int[] tickerIdx) { double sumOfVariances = this.getSumOfVariances(tickerIdx); *************** *** 185,189 **** } ! private double getSumOfVariances(int[] tickerIdx) { double returnValue = 0; --- 175,179 ---- } ! protected double getSumOfVariances(int[] tickerIdx) { double returnValue = 0; *************** *** 197,201 **** } ! private double getSumOfCovariances(int[] tickerIdx) { double returnValue = 0; --- 187,191 ---- } ! protected double getSumOfCovariances(int[] tickerIdx) { double returnValue = 0; *************** *** 219,223 **** } ! private void retrieveData() { foreach(DataRow row in this.setOfTickers.Rows) --- 209,213 ---- } ! protected void retrieveData() { foreach(DataRow row in this.setOfTickers.Rows) *************** *** 228,238 **** } } ! private float[] getArrayOfRatesOfReturn(string ticker) { Quotes tickerQuotes = new Quotes(ticker, this.firstQuoteDate, this.lastQuoteDate); float[] allAdjValues = ExtendedDataTable.GetArrayOfFloatFromColumn(tickerQuotes, "quAdjustedClose"); ! float[] ratesOfReturns = new float[allAdjValues.Length/this.intervalLength + 1]; int i = 0; //index for ratesOfReturns array for(int idx = 0; idx + this.intervalLength < allAdjValues.Length; idx += this.intervalLength ) { --- 218,234 ---- } } + //this protected method can be overriden by inherited classes + //which can specify the type of rates of return ! //in this basic implementation rates of returns ! //are based on daily close to close ! protected virtual float[] getArrayOfRatesOfReturn(string ticker) { Quotes tickerQuotes = new Quotes(ticker, this.firstQuoteDate, this.lastQuoteDate); float[] allAdjValues = ExtendedDataTable.GetArrayOfFloatFromColumn(tickerQuotes, "quAdjustedClose"); ! //float[] ratesOfReturns = new float[allAdjValues.Length/this.intervalLength + 1]; ! float[] ratesOfReturns = new float[allAdjValues.Length]; int i = 0; //index for ratesOfReturns array + /* for(int idx = 0; idx + this.intervalLength < allAdjValues.Length; idx += this.intervalLength ) { *************** *** 241,244 **** --- 237,248 ---- i++; } + */ + for(int idx = 0; idx < allAdjValues.Length; idx++) + { + ratesOfReturns[i] = allAdjValues[idx+1]/ + allAdjValues[idx] - 1; + i++; + } + return ratesOfReturns; } *************** *** 247,257 **** ! private double getPortfolioRateOfReturn(int[] tickerIdx) { double returnValue = 0; ! foreach(int idx in tickerIdx) ! { ! returnValue += BasicFunctions.SimpleAverage((float[])this.setOfTickers.Rows[idx]["ArrayOfRatesOfReturn"]); ! } //the investement is assumed to be equally divided return (returnValue/this.GenomeSize); --- 251,261 ---- ! protected double getPortfolioRateOfReturn(int[] tickerIdx) { double returnValue = 0; ! foreach(int idx in tickerIdx) ! { ! returnValue += BasicFunctions.SimpleAverage((float[])this.setOfTickers.Rows[idx]["ArrayOfRatesOfReturn"]); ! } //the investement is assumed to be equally divided return (returnValue/this.GenomeSize); Index: GenomeManagerForEfficientCTOPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/GenomeManagerForEfficientCTOPortfolio.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** GenomeManagerForEfficientCTOPortfolio.cs 14 Dec 2004 21:25:45 -0000 1.2 --- GenomeManagerForEfficientCTOPortfolio.cs 30 Jan 2005 19:53:10 -0000 1.3 *************** *** 37,157 **** /// GeneticOptimizer /// </summary> ! public class GenomeManagerForEfficientCTOPortfolio : IGenomeManager { - private int genomeSize; - private int minValueForGenes; - private int maxValueForGenes; - - private DataTable setOfTickers; - private DateTime firstQuoteDate; - private DateTime lastQuoteDate; - private double targetPerformance; - private double targetStdDev; - private double variance; - private double rateOfReturn; - - //IGenomeManager implementation for properties - public int GenomeSize - { - get{return this.genomeSize;} - } - - public int MinValueForGenes - { - get{return this.minValueForGenes;} - } - public int MaxValueForGenes - { - get{return this.maxValueForGenes;} - } - //end of implementation for properties - - public double Variance - { - get{return this.variance;} - } - - public double RateOfReturn - { - get{return this.rateOfReturn;} - } - public GenomeManagerForEfficientCTOPortfolio(DataTable setOfInitialTickers, ! DateTime firstQuoteDate, ! DateTime lastQuoteDate, ! int numberOfTickersInPortfolio, ! double targetPerformance, ! double targetStdDev) { - this.setOfTickers = setOfInitialTickers; - if(!this.setOfTickers.Columns.Contains("ArrayOfCloseToOpenRates")) - this.setOfTickers.Columns.Add("ArrayOfCloseToOpenRates", System.Type.GetType("System.Array")); - this.firstQuoteDate = firstQuoteDate; - this.lastQuoteDate = lastQuoteDate; - this.targetPerformance = targetPerformance; - this.targetStdDev = targetStdDev; - this.genomeSize = numberOfTickersInPortfolio; - //each genes is the index for the setOfTickers table - this.minValueForGenes = 0; - this.maxValueForGenes = this.setOfTickers.Rows.Count - 1; - this.retrieveData(); - } - - public double GetFitnessValue(Genome genome) - { - //parameters used to balance the rate of return against variance - //double a=2.5, b=2.0; - double portofolioVariance = this.getPortfolioVariance(genome.Genes()); - double portfolioRateOfReturn = this.getPortfolioRateOfReturn(genome.Genes()); - this.variance = portofolioVariance; - this.rateOfReturn = portfolioRateOfReturn; - NormalDistribution normal = new NormalDistribution(portfolioRateOfReturn, Math.Sqrt(portofolioVariance)); - double returnValue = normal.GetProbability(this.targetPerformance*0.5,this.targetPerformance*1.5); - //double returnValue = System.Math.Pow(((this.targetStdDev*this.targetStdDev)/portofolioVariance),a)* - //System.Math.Pow(System.Math.Max(0.0,(portfolioRateOfReturn/this.targetPerformance)),b); - return returnValue; - } - - public Genome[] GetChilds(Genome parent1, Genome parent2) - { - return GenomeManagement.MixGenesWithoutDuplicates(parent1, parent2); - } - - public int GetNewGeneValue(Genome genome) - { - // in this implementation new gene values must be different from - // the others already stored in the given genome - int returnValue = GenomeManagement.RandomGenerator.Next(genome.MinValueForGenes, - genome.MaxValueForGenes + 1); - while(genome.HasGene(returnValue)) - { - returnValue = GenomeManagement.RandomGenerator.Next(genome.MinValueForGenes, - genome.MaxValueForGenes + 1); - } - - return returnValue; } - - public void Mutate(Genome genome, double mutationRate) - { - // in this implementation only one gene is mutated - // 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)) - { - newValueForGene = GenomeManagement.RandomGenerator.Next(genome.MinValueForGenes, - genome.MaxValueForGenes +1); - } - GenomeManagement.MutateOneGene(genome, mutationRate, - genePositionToBeMutated, newValueForGene); - } ! public object Decode(Genome genome) { --- 37,62 ---- /// GeneticOptimizer /// </summary> ! public class GenomeManagerForEfficientCTOPortfolio : GenomeManagerForEfficientPortfolio { public GenomeManagerForEfficientCTOPortfolio(DataTable setOfInitialTickers, ! DateTime firstQuoteDate, ! DateTime lastQuoteDate, ! int numberOfTickersInPortfolio, ! int numDaysOfPortfolioLife, ! double targetPerformance) ! :base(setOfInitialTickers, ! firstQuoteDate, ! lastQuoteDate, ! numberOfTickersInPortfolio, ! numDaysOfPortfolioLife, ! targetPerformance) { } ! public override object Decode(Genome genome) { *************** *** 177,236 **** return returnValue; */ - - } - // end of implementation of IGenomeManager - - private double getPortfolioVariance(int[] tickerIdx) - { - double sumOfVariances = this.getSumOfVariances(tickerIdx); - double sumOfCovariances = this.getSumOfCovariances(tickerIdx); - double returnValue = sumOfVariances + sumOfCovariances; - return returnValue; - } - - private double getSumOfVariances(int[] tickerIdx) - { - double returnValue = 0; - double tickerCoeff = 1.0/this.genomeSize; - foreach(int idx in tickerIdx) - { - returnValue += BasicFunctions.Variance((float[])this.setOfTickers.Rows[idx]["ArrayOfCloseToOpenRates"]); - } - returnValue = returnValue * tickerCoeff * tickerCoeff; - return returnValue; } ! ! private double getSumOfCovariances(int[] tickerIdx) ! { ! double returnValue = 0; ! float[] ticker_i; ! float[] ticker_j; ! double tickerCoeff = 1/this.genomeSize; ! for(int i = 0; i<this.genomeSize ; i++) ! { ! ticker_i = (float[])this.setOfTickers.Rows[i]["ArrayOfCloseToOpenRates"]; ! for(int j = 0 ; j<this.genomeSize ; j++) ! { ! if(j != i) ! { ! ticker_j = (float[])this.setOfTickers.Rows[j]["ArrayOfCloseToOpenRates"]; ! returnValue += BasicFunctions.CoVariance(ticker_i, ticker_j); ! } ! } ! } ! returnValue = returnValue * tickerCoeff * tickerCoeff; ! return returnValue; ! } ! ! private void retrieveData() ! { ! foreach(DataRow row in this.setOfTickers.Rows) ! { ! float[] arrayOfCTORates = this.getArrayOfCTORates((string)row[0]); ! row["ArrayOfCloseToOpenRates"] = arrayOfCTORates; ! } ! } ! ! private float[] getArrayOfCTORates(string ticker) { Quotes tickerQuotes = new Quotes(ticker, this.firstQuoteDate, this.lastQuoteDate); --- 82,88 ---- return returnValue; */ } ! ! protected override float[] getArrayOfRatesOfReturn(string ticker) { Quotes tickerQuotes = new Quotes(ticker, this.firstQuoteDate, this.lastQuoteDate); *************** *** 238,253 **** } - - - private double getPortfolioRateOfReturn(int[] tickerIdx) - { - double returnValue = 0; - foreach(int idx in tickerIdx) - { - returnValue += (BasicFunctions.SimpleAverage((float[])this.setOfTickers.Rows[idx]["ArrayOfCloseToOpenRates"]) - 1); - } - //the investement is assumed to be equally divided - return (returnValue/this.GenomeSize); - } } --- 90,93 ---- |
|
From: Marco M. <mi...@us...> - 2005-01-30 19:45:13
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/FileManaging In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1671/FileManaging Log Message: Directory /cvsroot/quantproject/QuantProject/b1_ADT/FileManaging added to the repository |
|
From: Marco M. <mi...@us...> - 2005-01-22 19:35:13
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19124/Downloader Modified Files: TickerDownloader.cs WebDownloader.cs Log Message: WebDownloader form and ticker downloader class updated: it is now possible to choose if computation of close to close ratios (for new quotes only) has to be done during downloading of new quotes Index: WebDownloader.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/WebDownloader.cs,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** WebDownloader.cs 5 Sep 2004 13:57:00 -0000 1.17 --- WebDownloader.cs 22 Jan 2005 19:35:04 -0000 1.18 *************** *** 50,58 **** private System.Windows.Forms.Button buttonAbort; private Thread downloadThread = null; ! ! /// <summary> ! /// Required designer variable. ! /// </summary> ! private System.ComponentModel.Container components = null; public WebDownloader() --- 50,56 ---- private System.Windows.Forms.Button buttonAbort; private Thread downloadThread = null; ! internal System.Windows.Forms.CheckBox checkBoxComputeCloseToCloseValues; ! private System.Windows.Forms.ToolTip toolTip1; ! private System.ComponentModel.IContainer components; public WebDownloader() *************** *** 115,118 **** --- 113,119 ---- this.radioButtonDownloadOnlyAfterMax.Checked = true; this.dataGrid1.ContextMenu = new TickerViewerMenu(this); + this.toolTip1.SetToolTip(this.checkBoxComputeCloseToCloseValues, + "It is possible to compute close to close " + + "ratios out of connection"); //this.downloadThread = new Thread( new ThreadStart( this.downloadQuotes_createTickerDataSet)); } *************** *** 126,129 **** --- 127,131 ---- private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); this.button1 = new System.Windows.Forms.Button(); this.dataGrid1 = new System.Windows.Forms.DataGrid(); *************** *** 149,152 **** --- 151,156 ---- this.radioButtonOverWriteYes = new System.Windows.Forms.RadioButton(); this.buttonAbort = new System.Windows.Forms.Button(); + this.checkBoxComputeCloseToCloseValues = new System.Windows.Forms.CheckBox(); + this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit(); this.groupBoxWebDownloaderOptions.SuspendLayout(); *************** *** 156,160 **** // button1 // ! this.button1.Location = new System.Drawing.Point(88, 352); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(112, 32); --- 160,164 ---- // button1 // ! this.button1.Location = new System.Drawing.Point(16, 392); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(112, 32); *************** *** 251,255 **** // buttonDownloadQuotesOfSelectedTickers // ! this.buttonDownloadQuotesOfSelectedTickers.Location = new System.Drawing.Point(88, 392); this.buttonDownloadQuotesOfSelectedTickers.Name = "buttonDownloadQuotesOfSelectedTickers"; this.buttonDownloadQuotesOfSelectedTickers.Size = new System.Drawing.Size(112, 32); --- 255,259 ---- // buttonDownloadQuotesOfSelectedTickers // ! this.buttonDownloadQuotesOfSelectedTickers.Location = new System.Drawing.Point(136, 392); this.buttonDownloadQuotesOfSelectedTickers.Name = "buttonDownloadQuotesOfSelectedTickers"; this.buttonDownloadQuotesOfSelectedTickers.Size = new System.Drawing.Size(112, 32); *************** *** 260,264 **** // labelNumberOfTickersToDownload // ! this.labelNumberOfTickersToDownload.Location = new System.Drawing.Point(152, 440); this.labelNumberOfTickersToDownload.Name = "labelNumberOfTickersToDownload"; this.labelNumberOfTickersToDownload.Size = new System.Drawing.Size(48, 24); --- 264,268 ---- // labelNumberOfTickersToDownload // ! this.labelNumberOfTickersToDownload.Location = new System.Drawing.Point(160, 448); this.labelNumberOfTickersToDownload.Name = "labelNumberOfTickersToDownload"; this.labelNumberOfTickersToDownload.Size = new System.Drawing.Size(48, 24); *************** *** 268,272 **** // labelTickersLeft // ! this.labelTickersLeft.Location = new System.Drawing.Point(8, 440); this.labelTickersLeft.Name = "labelTickersLeft"; this.labelTickersLeft.Size = new System.Drawing.Size(136, 24); --- 272,276 ---- // labelTickersLeft // ! this.labelTickersLeft.Location = new System.Drawing.Point(16, 448); this.labelTickersLeft.Name = "labelTickersLeft"; this.labelTickersLeft.Size = new System.Drawing.Size(136, 24); *************** *** 276,280 **** // dateTimePickerStartingDate // ! this.dateTimePickerStartingDate.Location = new System.Drawing.Point(96, 104); this.dateTimePickerStartingDate.Name = "dateTimePickerStartingDate"; this.dateTimePickerStartingDate.Size = new System.Drawing.Size(184, 20); --- 280,284 ---- // dateTimePickerStartingDate // ! this.dateTimePickerStartingDate.Location = new System.Drawing.Point(96, 96); this.dateTimePickerStartingDate.Name = "dateTimePickerStartingDate"; this.dateTimePickerStartingDate.Size = new System.Drawing.Size(184, 20); *************** *** 283,287 **** // labelStartingDateTime // ! this.labelStartingDateTime.Location = new System.Drawing.Point(8, 104); this.labelStartingDateTime.Name = "labelStartingDateTime"; this.labelStartingDateTime.Size = new System.Drawing.Size(80, 23); --- 287,291 ---- // labelStartingDateTime // ! this.labelStartingDateTime.Location = new System.Drawing.Point(8, 96); this.labelStartingDateTime.Name = "labelStartingDateTime"; this.labelStartingDateTime.Size = new System.Drawing.Size(80, 23); *************** *** 311,315 **** this.radioButtonAllAvailableUntilNowSinceStartingDate, this.radioButtonAllAvailableUntilNow}); ! this.groupBoxWebDownloaderOptions.Location = new System.Drawing.Point(8, 8); this.groupBoxWebDownloaderOptions.Name = "groupBoxWebDownloaderOptions"; this.groupBoxWebDownloaderOptions.Size = new System.Drawing.Size(288, 88); --- 315,319 ---- this.radioButtonAllAvailableUntilNowSinceStartingDate, this.radioButtonAllAvailableUntilNow}); ! this.groupBoxWebDownloaderOptions.Location = new System.Drawing.Point(8, 0); this.groupBoxWebDownloaderOptions.Name = "groupBoxWebDownloaderOptions"; this.groupBoxWebDownloaderOptions.Size = new System.Drawing.Size(288, 88); *************** *** 381,386 **** // this.buttonAbort.Enabled = false; ! this.buttonAbort.Location = new System.Drawing.Point(216, 376); this.buttonAbort.Name = "buttonAbort"; this.buttonAbort.TabIndex = 15; this.buttonAbort.Text = "Abort"; --- 385,391 ---- // this.buttonAbort.Enabled = false; ! this.buttonAbort.Location = new System.Drawing.Point(256, 408); this.buttonAbort.Name = "buttonAbort"; + this.buttonAbort.Size = new System.Drawing.Size(32, 23); this.buttonAbort.TabIndex = 15; this.buttonAbort.Text = "Abort"; *************** *** 388,396 **** this.buttonAbort.Click += new System.EventHandler(this.buttonAbort_Click); // // WebDownloader // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); ! this.ClientSize = new System.Drawing.Size(840, 470); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.buttonAbort, this.groupBoxUpdateDatabaseOptions, --- 393,410 ---- this.buttonAbort.Click += new System.EventHandler(this.buttonAbort_Click); // + // checkBoxComputeCloseToCloseValues + // + this.checkBoxComputeCloseToCloseValues.Location = new System.Drawing.Point(16, 352); + this.checkBoxComputeCloseToCloseValues.Name = "checkBoxComputeCloseToCloseValues"; + this.checkBoxComputeCloseToCloseValues.Size = new System.Drawing.Size(272, 24); + this.checkBoxComputeCloseToCloseValues.TabIndex = 16; + this.checkBoxComputeCloseToCloseValues.Text = "Compute close to close ratios (slower)"; + // // WebDownloader // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); ! this.ClientSize = new System.Drawing.Size(840, 486); this.Controls.AddRange(new System.Windows.Forms.Control[] { + this.checkBoxComputeCloseToCloseValues, this.buttonAbort, this.groupBoxUpdateDatabaseOptions, *************** *** 730,734 **** this.downloadThread.Abort(); } ! public bool IsBeforeAndAfterSelected { --- 744,756 ---- this.downloadThread.Abort(); } ! ! public bool IsComputeCloseToCloseRatioSelected ! { ! get ! { ! return this.checkBoxComputeCloseToCloseValues.Checked; ! } ! } ! public bool IsBeforeAndAfterSelected { Index: TickerDownloader.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/TickerDownloader.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** TickerDownloader.cs 20 Jan 2005 19:16:14 -0000 1.14 --- TickerDownloader.cs 22 Jan 2005 19:35:04 -0000 1.15 *************** *** 391,396 **** { if(this.p_myForm.IsOverWriteYesSelected) ! Quotes.Delete(this.p_quTicker); ! QuantProject.DataAccess.Tables.Quotes.ComputeCloseToCloseValues(this.downloadedValuesFromSource); this.adapter.OleDbDataAdapter.ContinueUpdateOnError = true; int rowsUpdated = this.adapter.OleDbDataAdapter.Update(this.downloadedValuesFromSource); --- 391,397 ---- { if(this.p_myForm.IsOverWriteYesSelected) ! Quotes.Delete(this.p_quTicker); ! if(this.p_myForm.IsComputeCloseToCloseRatioSelected) ! QuantProject.DataAccess.Tables.Quotes.ComputeCloseToCloseValues(this.downloadedValuesFromSource); this.adapter.OleDbDataAdapter.ContinueUpdateOnError = true; int rowsUpdated = this.adapter.OleDbDataAdapter.Update(this.downloadedValuesFromSource); |
|
From: Marco M. <mi...@us...> - 2005-01-20 19:19:19
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/TickerSelectors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv916/Downloader/TickerSelectors Modified Files: TickerViewer.cs Log Message: Some little bugs has been fixed. New functionalities: - added column containing number of quotes for each ticker; - added button for viewing all tickers for which downloading process has failed. Index: TickerViewer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/TickerSelectors/TickerViewer.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TickerViewer.cs 1 Dec 2004 22:54:01 -0000 1.4 --- TickerViewer.cs 20 Jan 2005 19:19:08 -0000 1.5 *************** *** 62,65 **** --- 62,67 ---- private System.Windows.Forms.ComboBox comboBoxSecondOperator; private DataTable tableTickers; + private System.Windows.Forms.Button buttonViewFaultyTickers; + private System.Windows.Forms.Label label4; private bool skipRowChangedEvent;// event must be launched only by // user's changes *************** *** 70,74 **** this.tableTickers = new DataTable("tickers"); this.dataGrid1.DataSource = this.tableTickers; - this.setStyle_dataGrid1(); this.AcceptButton = this.buttonFindTickers; } --- 72,75 ---- *************** *** 116,119 **** --- 117,122 ---- this.radioButtonAnyTicker = new System.Windows.Forms.RadioButton(); this.splitter1 = new System.Windows.Forms.Splitter(); + this.buttonViewFaultyTickers = new System.Windows.Forms.Button(); + this.label4 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit(); this.panel2.SuspendLayout(); *************** *** 161,165 **** // buttonFindTickers // ! this.buttonFindTickers.Location = new System.Drawing.Point(152, 232); this.buttonFindTickers.Name = "buttonFindTickers"; this.buttonFindTickers.Size = new System.Drawing.Size(104, 24); --- 164,168 ---- // buttonFindTickers // ! this.buttonFindTickers.Location = new System.Drawing.Point(152, 224); this.buttonFindTickers.Name = "buttonFindTickers"; this.buttonFindTickers.Size = new System.Drawing.Size(104, 24); *************** *** 188,191 **** --- 191,196 ---- // this.panel2.Controls.AddRange(new System.Windows.Forms.Control[] { + this.label4, + this.buttonViewFaultyTickers, this.groupBoxDateQuoteFilter, this.textBoxStringToFind, *************** *** 316,319 **** --- 321,342 ---- this.splitter1.TabStop = false; // + // buttonViewFaultyTickers + // + this.buttonViewFaultyTickers.Location = new System.Drawing.Point(144, 296); + this.buttonViewFaultyTickers.Name = "buttonViewFaultyTickers"; + this.buttonViewFaultyTickers.Size = new System.Drawing.Size(120, 24); + this.buttonViewFaultyTickers.TabIndex = 15; + this.buttonViewFaultyTickers.Text = "&View faulty Tickers"; + this.buttonViewFaultyTickers.Click += new System.EventHandler(this.buttonViewFaultyTickers_Click); + // + // label4 + // + this.label4.Location = new System.Drawing.Point(24, 264); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(352, 16); + this.label4.TabIndex = 16; + this.label4.Text = "________________________________________"; + this.label4.TextAlign = System.Drawing.ContentAlignment.TopCenter; + // // TickerViewer // *************** *** 335,341 **** ! #region Style for dataGrid1 ! private void setStyle_dataGrid1() { DataGridTableStyle dataGrid1TableStyle = new DataGridTableStyle(); --- 358,364 ---- ! #region Style for dataGrid ! private void setStyle_dataGridWithQuoteInfo() { DataGridTableStyle dataGrid1TableStyle = new DataGridTableStyle(); *************** *** 356,360 **** columnStyle_tiCompanyName.TextBox.Enabled = false; columnStyle_tiCompanyName.NullText = ""; ! columnStyle_tiCompanyName.Width = 150; DataGridTextBoxColumn columnStyle_FirstQuote = new DataGridTextBoxColumn(); columnStyle_FirstQuote.MappingName = "FirstQuote"; --- 379,383 ---- columnStyle_tiCompanyName.TextBox.Enabled = false; columnStyle_tiCompanyName.NullText = ""; ! columnStyle_tiCompanyName.Width = 120; DataGridTextBoxColumn columnStyle_FirstQuote = new DataGridTextBoxColumn(); columnStyle_FirstQuote.MappingName = "FirstQuote"; *************** *** 362,366 **** columnStyle_FirstQuote.TextBox.Enabled = false; columnStyle_FirstQuote.NullText = ""; ! columnStyle_FirstQuote.Width = 80; DataGridTextBoxColumn columnStyle_LastQuote = new DataGridTextBoxColumn(); columnStyle_LastQuote.MappingName = "LastQuote"; --- 385,389 ---- columnStyle_FirstQuote.TextBox.Enabled = false; columnStyle_FirstQuote.NullText = ""; ! columnStyle_FirstQuote.Width = 60; DataGridTextBoxColumn columnStyle_LastQuote = new DataGridTextBoxColumn(); columnStyle_LastQuote.MappingName = "LastQuote"; *************** *** 368,381 **** columnStyle_LastQuote.TextBox.Enabled = false; columnStyle_LastQuote.NullText = ""; ! columnStyle_LastQuote.Width = 80; ! dataGrid1TableStyle.GridColumnStyles.Add(columnStyle_tiTicker); dataGrid1TableStyle.GridColumnStyles.Add(columnStyle_tiCompanyName); dataGrid1TableStyle.GridColumnStyles.Add(columnStyle_FirstQuote); dataGrid1TableStyle.GridColumnStyles.Add(columnStyle_LastQuote); this.dataGrid1.TableStyles.Add(dataGrid1TableStyle); } #endregion --- 391,470 ---- columnStyle_LastQuote.TextBox.Enabled = false; columnStyle_LastQuote.NullText = ""; ! columnStyle_LastQuote.Width = 60; ! ! DataGridTextBoxColumn columnStyle_NumberOfQuotes = new DataGridTextBoxColumn(); ! columnStyle_NumberOfQuotes.MappingName = "NumberOfQuotes"; ! columnStyle_NumberOfQuotes.HeaderText = "# Quotes"; ! columnStyle_NumberOfQuotes.TextBox.Enabled = false; ! columnStyle_NumberOfQuotes.NullText = ""; ! columnStyle_NumberOfQuotes.Width = 60; ! dataGrid1TableStyle.GridColumnStyles.Add(columnStyle_tiTicker); dataGrid1TableStyle.GridColumnStyles.Add(columnStyle_tiCompanyName); dataGrid1TableStyle.GridColumnStyles.Add(columnStyle_FirstQuote); dataGrid1TableStyle.GridColumnStyles.Add(columnStyle_LastQuote); + dataGrid1TableStyle.GridColumnStyles.Add(columnStyle_NumberOfQuotes); + this.dataGrid1.TableStyles.Add(dataGrid1TableStyle); + } + + private void setStyle_dataGridWithoutQuoteInfo() + { + DataGridTableStyle dataGrid1TableStyle = new DataGridTableStyle(); + dataGrid1TableStyle.MappingName = this.tableTickers.TableName; + dataGrid1TableStyle.ColumnHeadersVisible = true; + dataGrid1TableStyle.ReadOnly = true; + dataGrid1TableStyle.SelectionBackColor = Color.DimGray ; + + DataGridTextBoxColumn columnStyle_tiTicker = new DataGridTextBoxColumn(); + columnStyle_tiTicker.MappingName = "tiTicker"; + columnStyle_tiTicker.HeaderText = "Ticker"; + columnStyle_tiTicker.TextBox.Enabled = false; + columnStyle_tiTicker.NullText = ""; + columnStyle_tiTicker.Width = 60; + DataGridTextBoxColumn columnStyle_tiCompanyName = new DataGridTextBoxColumn(); + columnStyle_tiCompanyName.MappingName = "tiCompanyName"; + columnStyle_tiCompanyName.HeaderText = "Company Name"; + columnStyle_tiCompanyName.TextBox.Enabled = false; + columnStyle_tiCompanyName.NullText = ""; + columnStyle_tiCompanyName.Width = 120; + + dataGrid1TableStyle.GridColumnStyles.Add(columnStyle_tiTicker); + dataGrid1TableStyle.GridColumnStyles.Add(columnStyle_tiCompanyName); + + this.dataGrid1.TableStyles.Add(dataGrid1TableStyle); + + } + + private void setStyle_faultyTickersDataGrid() + { + DataGridTableStyle dataGrid1TableStyle = new DataGridTableStyle(); + dataGrid1TableStyle.MappingName = this.tableTickers.TableName; + dataGrid1TableStyle.ColumnHeadersVisible = true; + dataGrid1TableStyle.ReadOnly = true; + dataGrid1TableStyle.SelectionBackColor = Color.DimGray ; + + DataGridTextBoxColumn columnStyle_ftTicker = new DataGridTextBoxColumn(); + columnStyle_ftTicker.MappingName = "ftTicker"; + columnStyle_ftTicker.HeaderText = "Ticker not downloaded"; + columnStyle_ftTicker.TextBox.Enabled = false; + columnStyle_ftTicker.NullText = ""; + columnStyle_ftTicker.Width = 100; + DataGridTextBoxColumn columnStyle_ftDate = new DataGridTextBoxColumn(); + columnStyle_ftDate.MappingName = "ftDate"; + columnStyle_ftDate.HeaderText = "Last attempt"; + columnStyle_ftDate.TextBox.Enabled = false; + columnStyle_ftDate.NullText = ""; + columnStyle_ftDate.Width = 80; + + dataGrid1TableStyle.GridColumnStyles.Add(columnStyle_ftTicker); + dataGrid1TableStyle.GridColumnStyles.Add(columnStyle_ftDate); + + this.dataGrid1.TableStyles.Add(dataGrid1TableStyle); + + } #endregion *************** *** 402,405 **** --- 491,495 ---- this.tableTickers.RowDeleted += new DataRowChangeEventHandler(this.row_Deleted); this.dataGrid1.DataSource = this.tableTickers; + this.setStyle_dataGridWithoutQuoteInfo(); this.dataGrid1.ReadOnly = false; } *************** *** 414,417 **** --- 504,508 ---- this.dateTimePickerLastDate.Value); this.dataGrid1.DataSource = this.tableTickers; + this.setStyle_dataGridWithQuoteInfo(); this.dataGrid1.ReadOnly = true; } *************** *** 544,547 **** --- 635,661 ---- } + private void buttonViewFaultyTickers_Click(object sender, System.EventArgs e) + { + try + { + Cursor.Current = Cursors.WaitCursor; + + this.tableTickers = new FaultyTickers().Table; + + this.dataGrid1.DataSource = this.tableTickers; + this.setStyle_faultyTickersDataGrid(); + this.dataGrid1.ReadOnly = false; + } + catch(Exception ex) + { + MessageBox.Show(ex.ToString()); + } + finally + { + Cursor.Current = Cursors.Default; + } + + } + } |
|
From: Marco M. <mi...@us...> - 2005-01-20 19:19:17
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv916/Downloader Modified Files: Downloader.csproj Log Message: Some little bugs has been fixed. New functionalities: - added column containing number of quotes for each ticker; - added button for viewing all tickers for which downloading process has failed. Index: Downloader.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/Downloader.csproj,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** Downloader.csproj 5 Dec 2004 02:38:38 -0000 1.27 --- Downloader.csproj 20 Jan 2005 19:19:03 -0000 1.28 *************** *** 195,198 **** --- 195,203 ---- /> <File + RelPath = "WebDownloader.resx" + DependentUpon = "WebDownloader.cs" + BuildAction = "EmbeddedResource" + /> + <File RelPath = "QuotesEditor\QuotesChart.cs" SubType = "UserControl" *************** *** 310,313 **** --- 315,323 ---- /> <File + RelPath = "TickerSelectors\TickerSelectorForm.resx" + DependentUpon = "TickerSelectorForm.cs" + BuildAction = "EmbeddedResource" + /> + <File RelPath = "TickerSelectors\TickerViewer.cs" SubType = "Form" |
|
From: Marco M. <mi...@us...> - 2005-01-20 19:16:24
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv322/Downloader Modified Files: TickerDownloader.cs Log Message: Added code for inserting in faultyTickers table those tickers for which downloading has not been successful Index: TickerDownloader.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/TickerDownloader.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TickerDownloader.cs 5 Sep 2004 13:57:00 -0000 1.13 --- TickerDownloader.cs 20 Jan 2005 19:16:14 -0000 1.14 *************** *** 560,564 **** string notUsed = exception.ToString(); numTrials++; ! //if(numTrials==6) //throw new Exception("It has not been possible to set streams from Yahoo: \n\n" + // "Check the connection to the internet or the following url: \n\n" + --- 560,566 ---- string notUsed = exception.ToString(); numTrials++; ! if(numTrials==5) ! FaultyTickers.AddOrUpdate(this.p_quTicker, DateTime.Now.Date); ! // to add faulty tickers to database table //throw new Exception("It has not been possible to set streams from Yahoo: \n\n" + // "Check the connection to the internet or the following url: \n\n" + |
|
From: Marco M. <mi...@us...> - 2005-01-20 19:13:42
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32157/b2_DataAccess/Tables Modified Files: Tickers.cs Log Message: Updated method for getting tickers for the TickerViewer form Index: Tickers.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables/Tickers.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Tickers.cs 1 Dec 2004 22:47:00 -0000 1.3 --- Tickers.cs 20 Jan 2005 19:13:33 -0000 1.4 *************** *** 107,111 **** if(firstQuoteDate.CompareTo(lastQuoteDate)>0) throw new Exception("Last Date can't be previous of First date!"); ! sqlSelectString = "SELECT tiTicker, tiCompanyName, Min(quotes.quDate) AS FirstQuote, Max(quotes.quDate) AS LastQuote " + "FROM quotes INNER JOIN tickers ON quotes.quTicker = tickers.tiTicker " + "WHERE tiTicker LIKE '" + --- 107,112 ---- if(firstQuoteDate.CompareTo(lastQuoteDate)>0) throw new Exception("Last Date can't be previous of First date!"); ! sqlSelectString = "SELECT tiTicker, tiCompanyName, " + ! "Min(quotes.quDate) AS FirstQuote, Max(quotes.quDate) AS LastQuote, Count(quotes.quDate) AS NumberOfQuotes " + "FROM quotes INNER JOIN tickers ON quotes.quTicker = tickers.tiTicker " + "WHERE tiTicker LIKE '" + |
|
From: Marco M. <mi...@us...> - 2005-01-20 19:12:40
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31817/b2_DataAccess Modified Files: b2_DataAccess.csproj Log Message: Added FaultyTickers class to access faultyTickers table Index: b2_DataAccess.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/b2_DataAccess.csproj,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** b2_DataAccess.csproj 20 Jan 2005 01:11:32 -0000 1.14 --- b2_DataAccess.csproj 20 Jan 2005 19:12:28 -0000 1.15 *************** *** 138,141 **** --- 138,146 ---- /> <File + RelPath = "Tables\FaultyTickers.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Tables\Quotes.cs" SubType = "Code" |
|
From: Marco M. <mi...@us...> - 2005-01-20 19:12:38
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31817/b2_DataAccess/Tables Added Files: FaultyTickers.cs Log Message: Added FaultyTickers class to access faultyTickers table --- NEW FILE: FaultyTickers.cs --- /* QuantDownloader - Quantitative Finance Library FaultyTickers.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.Data; using QuantProject.DataAccess; namespace QuantProject.DataAccess.Tables { /// <summary> /// Class to access the Faulty Tickers table (containing tickers not /// downloaded because of some error) /// </summary> public class FaultyTickers { // these static fields provide field name in the database table // They are intended to be used through intellisense when necessary public static string Ticker = "ftTicker"; public static string Date = "ftDate"; private DataTable faultyTickers; private int count; public FaultyTickers() { this.faultyTickers = SqlExecutor.GetDataTable("SELECT * FROM faultyTickers"); this.count = this.faultyTickers.Rows.Count; } /// <summary> /// Number of tickers in FaultyTickers table /// </summary> public int Count { get { return this.count; } } /// <summary> /// Returns the actual faultyTickers table /// </summary> public DataTable Table { get { return this.faultyTickers;; } } private static bool isAlreadyStored(string ticker) { bool returnValue = false; DataTable table = SqlExecutor.GetDataTable("SELECT * FROM faultyTickers " + "WHERE ftTicker='"+ ticker + "'"); if(table.Rows.Count>0) returnValue = true; return returnValue; } private static void updateDate(string ticker, DateTime newDateForTicker) { string sql = "UPDATE faultyTickers SET faultyTickers.ftDate =" + SQLBuilder.GetDateConstant(newDateForTicker)+ " WHERE faultyTickers.ftTicker='" + ticker + "'"; SqlExecutor.ExecuteNonQuery (sql); } /// <summary> /// Adds a new record to FaultyTickers table or, /// in case the ticker to be added is already stored, /// updates trial date for the given ticker /// </summary> public static void AddOrUpdate(string faultyTickerToBeAdded, DateTime errorDateInDownloading) { try { if(FaultyTickers.isAlreadyStored(faultyTickerToBeAdded)) FaultyTickers.updateDate(faultyTickerToBeAdded, errorDateInDownloading); else SqlExecutor.ExecuteNonQuery("INSERT INTO faultyTickers(ftTicker, ftDate) " + "VALUES('" + faultyTickerToBeAdded + "', " + SQLBuilder.GetDateConstant(errorDateInDownloading) + ")"); } catch(Exception ex) { string notUsed = ex.ToString(); } } } } |
|
From: Glauco S. <gla...@us...> - 2005-01-20 01:26:41
|
Update of /cvsroot/quantproject/QuantProject In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5300 Modified Files: QuantProject.sln QuantProject.suo Log Message: - the MultiplyBy method has been added to the History class - the benchmark buy and hold equity line has been added to the report - minor bug fixing - minor code cleaning Index: QuantProject.sln =================================================================== RCS file: /cvsroot/quantproject/QuantProject/QuantProject.sln,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** QuantProject.sln 15 Oct 2003 15:07:08 -0000 1.3 --- QuantProject.sln 20 Jan 2005 01:26:28 -0000 1.4 *************** *** 10,17 **** Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "b4_Business", "b4_Business\b4_Business.csproj", "{6EE31501-376E-491B-869E-F06D5B7C9C30}" EndProject - Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "b5_Presentation", "b5_Presentation\b5_Presentation.csproj", "{D3DC9EA6-3B06-4255-B19A-5FC5B66A1402}" - EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "b7_Scripts", "b7_Scripts\b7_Scripts.csproj", "{451DB77D-D4C7-44D1-8047-2920D864A4CD}" EndProject Global GlobalSection(SolutionConfiguration) = preSolution --- 10,17 ---- Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "b4_Business", "b4_Business\b4_Business.csproj", "{6EE31501-376E-491B-869E-F06D5B7C9C30}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "b7_Scripts", "b7_Scripts\b7_Scripts.csproj", "{451DB77D-D4C7-44D1-8047-2920D864A4CD}" EndProject + Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "b5_Presentation", "b5_Presentation\b5_Presentation.csproj", "{D3DC9EA6-3B06-4255-B19A-5FC5B66A1402}" + EndProject Global GlobalSection(SolutionConfiguration) = preSolution *************** *** 20,23 **** --- 20,51 ---- EndGlobalSection GlobalSection(ProjectDependencies) = postSolution + {75FE4A9C-867E-48FE-8B49-964B318B4583}.0 = {6EE31501-376E-491B-869E-F06D5B7C9C30} + {75FE4A9C-867E-48FE-8B49-964B318B4583}.1 = {451DB77D-D4C7-44D1-8047-2920D864A4CD} + {75FE4A9C-867E-48FE-8B49-964B318B4583}.2 = {451DB77D-D4C7-44D1-8047-2920D864A4CD} + {75FE4A9C-867E-48FE-8B49-964B318B4583}.3 = {6EE31501-376E-491B-869E-F06D5B7C9C30} + {8CF7C0D8-A8CB-43DC-B406-77DE62729487}.0 = {B8A01161-3698-4591-B1EF-90F5FC7D8DBA} + {8CF7C0D8-A8CB-43DC-B406-77DE62729487}.1 = {B8A01161-3698-4591-B1EF-90F5FC7D8DBA} + {6AC0A2C1-B926-4921-A685-F5AA80E81C94}.0 = {8CF7C0D8-A8CB-43DC-B406-77DE62729487} + {6AC0A2C1-B926-4921-A685-F5AA80E81C94}.1 = {B8A01161-3698-4591-B1EF-90F5FC7D8DBA} + {6AC0A2C1-B926-4921-A685-F5AA80E81C94}.2 = {B8A01161-3698-4591-B1EF-90F5FC7D8DBA} + {6AC0A2C1-B926-4921-A685-F5AA80E81C94}.3 = {8CF7C0D8-A8CB-43DC-B406-77DE62729487} + {6EE31501-376E-491B-869E-F06D5B7C9C30}.0 = {6AC0A2C1-B926-4921-A685-F5AA80E81C94} + {6EE31501-376E-491B-869E-F06D5B7C9C30}.1 = {8CF7C0D8-A8CB-43DC-B406-77DE62729487} + {6EE31501-376E-491B-869E-F06D5B7C9C30}.2 = {B8A01161-3698-4591-B1EF-90F5FC7D8DBA} + {6EE31501-376E-491B-869E-F06D5B7C9C30}.3 = {B8A01161-3698-4591-B1EF-90F5FC7D8DBA} + {6EE31501-376E-491B-869E-F06D5B7C9C30}.4 = {8CF7C0D8-A8CB-43DC-B406-77DE62729487} + {6EE31501-376E-491B-869E-F06D5B7C9C30}.5 = {6AC0A2C1-B926-4921-A685-F5AA80E81C94} + {451DB77D-D4C7-44D1-8047-2920D864A4CD}.0 = {6EE31501-376E-491B-869E-F06D5B7C9C30} + {451DB77D-D4C7-44D1-8047-2920D864A4CD}.1 = {6AC0A2C1-B926-4921-A685-F5AA80E81C94} + {451DB77D-D4C7-44D1-8047-2920D864A4CD}.2 = {D3DC9EA6-3B06-4255-B19A-5FC5B66A1402} + {451DB77D-D4C7-44D1-8047-2920D864A4CD}.3 = {D3DC9EA6-3B06-4255-B19A-5FC5B66A1402} + {451DB77D-D4C7-44D1-8047-2920D864A4CD}.4 = {6AC0A2C1-B926-4921-A685-F5AA80E81C94} + {451DB77D-D4C7-44D1-8047-2920D864A4CD}.5 = {6EE31501-376E-491B-869E-F06D5B7C9C30} + {D3DC9EA6-3B06-4255-B19A-5FC5B66A1402}.0 = {6EE31501-376E-491B-869E-F06D5B7C9C30} + {D3DC9EA6-3B06-4255-B19A-5FC5B66A1402}.1 = {6AC0A2C1-B926-4921-A685-F5AA80E81C94} + {D3DC9EA6-3B06-4255-B19A-5FC5B66A1402}.2 = {B8A01161-3698-4591-B1EF-90F5FC7D8DBA} + {D3DC9EA6-3B06-4255-B19A-5FC5B66A1402}.3 = {6AC0A2C1-B926-4921-A685-F5AA80E81C94} + {D3DC9EA6-3B06-4255-B19A-5FC5B66A1402}.4 = {6EE31501-376E-491B-869E-F06D5B7C9C30} + {D3DC9EA6-3B06-4255-B19A-5FC5B66A1402}.5 = {B8A01161-3698-4591-B1EF-90F5FC7D8DBA} EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution *************** *** 42,53 **** {6EE31501-376E-491B-869E-F06D5B7C9C30}.Release.ActiveCfg = Release|.NET {6EE31501-376E-491B-869E-F06D5B7C9C30}.Release.Build.0 = Release|.NET - {D3DC9EA6-3B06-4255-B19A-5FC5B66A1402}.Debug.ActiveCfg = Debug|.NET - {D3DC9EA6-3B06-4255-B19A-5FC5B66A1402}.Debug.Build.0 = Debug|.NET - {D3DC9EA6-3B06-4255-B19A-5FC5B66A1402}.Release.ActiveCfg = Release|.NET - {D3DC9EA6-3B06-4255-B19A-5FC5B66A1402}.Release.Build.0 = Release|.NET {451DB77D-D4C7-44D1-8047-2920D864A4CD}.Debug.ActiveCfg = Debug|.NET {451DB77D-D4C7-44D1-8047-2920D864A4CD}.Debug.Build.0 = Debug|.NET {451DB77D-D4C7-44D1-8047-2920D864A4CD}.Release.ActiveCfg = Release|.NET {451DB77D-D4C7-44D1-8047-2920D864A4CD}.Release.Build.0 = Release|.NET EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution --- 70,81 ---- {6EE31501-376E-491B-869E-F06D5B7C9C30}.Release.ActiveCfg = Release|.NET {6EE31501-376E-491B-869E-F06D5B7C9C30}.Release.Build.0 = Release|.NET {451DB77D-D4C7-44D1-8047-2920D864A4CD}.Debug.ActiveCfg = Debug|.NET {451DB77D-D4C7-44D1-8047-2920D864A4CD}.Debug.Build.0 = Debug|.NET {451DB77D-D4C7-44D1-8047-2920D864A4CD}.Release.ActiveCfg = Release|.NET {451DB77D-D4C7-44D1-8047-2920D864A4CD}.Release.Build.0 = Release|.NET + {D3DC9EA6-3B06-4255-B19A-5FC5B66A1402}.Debug.ActiveCfg = Debug|.NET + {D3DC9EA6-3B06-4255-B19A-5FC5B66A1402}.Debug.Build.0 = Debug|.NET + {D3DC9EA6-3B06-4255-B19A-5FC5B66A1402}.Release.ActiveCfg = Release|.NET + {D3DC9EA6-3B06-4255-B19A-5FC5B66A1402}.Release.Build.0 = Release|.NET EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution Index: QuantProject.suo =================================================================== RCS file: /cvsroot/quantproject/QuantProject/QuantProject.suo,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 Binary files /tmp/cvsylAn1o and /tmp/cvskfwnvz differ |