quantproject-developers Mailing List for QuantProject (Page 41)
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: Glauco S. <gla...@us...> - 2008-07-20 20:40:38
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Collections In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv8751/b1_ADT/Collections Modified Files: Set.cs Log Message: The public method Clear() has been added Index: Set.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Collections/Set.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Set.cs 13 Jul 2007 09:59:36 -0000 1.1 --- Set.cs 20 Jul 2008 20:40:22 -0000 1.2 *************** *** 56,59 **** --- 56,67 ---- return this.elements.ContainsKey( element ); } + + /// <summary> + /// removes all elements in the set + /// </summary> + public void Clear() + { + this.elements.Clear(); + } } } |
|
From: Glauco S. <gla...@us...> - 2008-07-20 20:39:30
|
Update of /cvsroot/quantproject/QuantProject/b91_QuantProject In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv8253/b91_QuantProject Modified Files: app.config Log Message: The target runtime has been changed (2.0 now) Index: app.config =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b91_QuantProject/app.config,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** app.config 28 Aug 2005 10:08:07 -0000 1.5 --- app.config 20 Jul 2008 20:39:26 -0000 1.6 *************** *** 3,7 **** <configuration> <startup> ! <supportedRuntime version="v1.1.4322" /> </startup> --- 3,7 ---- <configuration> <startup> ! <supportedRuntime version="v2.0.50727" /> </startup> |
|
From: Glauco S. <gla...@us...> - 2008-07-20 20:38:42
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/UserForms In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv7818/Downloader/OpenTickDownloader/UserForms Modified Files: OTWebDownloader.cs Log Message: The form and some controls have been enlarged Index: OTWebDownloader.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/UserForms/OTWebDownloader.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** OTWebDownloader.cs 9 Jul 2008 22:01:36 -0000 1.2 --- OTWebDownloader.cs 20 Jul 2008 20:38:39 -0000 1.3 *************** *** 153,160 **** this.dataGrid1.Dock = System.Windows.Forms.DockStyle.Right; this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText; ! this.dataGrid1.Location = new System.Drawing.Point(352, 0); this.dataGrid1.Name = "dataGrid1"; this.dataGrid1.ReadOnly = true; ! this.dataGrid1.Size = new System.Drawing.Size(301, 459); this.dataGrid1.TabIndex = 1; // --- 153,160 ---- this.dataGrid1.Dock = System.Windows.Forms.DockStyle.Right; this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText; ! this.dataGrid1.Location = new System.Drawing.Point(382, 0); this.dataGrid1.Name = "dataGrid1"; this.dataGrid1.ReadOnly = true; ! this.dataGrid1.Size = new System.Drawing.Size(352, 459); this.dataGrid1.TabIndex = 1; // *************** *** 172,176 **** this.dateTimePickerStartingDate.Location = new System.Drawing.Point(86, 49); this.dateTimePickerStartingDate.Name = "dateTimePickerStartingDate"; ! this.dateTimePickerStartingDate.Size = new System.Drawing.Size(162, 20); this.dateTimePickerStartingDate.TabIndex = 6; this.dateTimePickerStartingDate.Value = new System.DateTime(2001, 1, 1, 0, 0, 0, 0); --- 172,176 ---- this.dateTimePickerStartingDate.Location = new System.Drawing.Point(86, 49); this.dateTimePickerStartingDate.Name = "dateTimePickerStartingDate"; ! this.dateTimePickerStartingDate.Size = new System.Drawing.Size(231, 20); this.dateTimePickerStartingDate.TabIndex = 6; this.dateTimePickerStartingDate.Value = new System.DateTime(2001, 1, 1, 0, 0, 0, 0); *************** *** 202,206 **** this.groupBoxWebDownloaderOptions.Location = new System.Drawing.Point(10, 97); this.groupBoxWebDownloaderOptions.Name = "groupBoxWebDownloaderOptions"; ! this.groupBoxWebDownloaderOptions.Size = new System.Drawing.Size(320, 134); this.groupBoxWebDownloaderOptions.TabIndex = 13; this.groupBoxWebDownloaderOptions.TabStop = false; --- 202,206 ---- this.groupBoxWebDownloaderOptions.Location = new System.Drawing.Point(10, 97); this.groupBoxWebDownloaderOptions.Name = "groupBoxWebDownloaderOptions"; ! this.groupBoxWebDownloaderOptions.Size = new System.Drawing.Size(336, 134); this.groupBoxWebDownloaderOptions.TabIndex = 13; this.groupBoxWebDownloaderOptions.TabStop = false; *************** *** 228,232 **** this.dateTimeOverwriteQuotesBefore.Location = new System.Drawing.Point(96, 247); this.dateTimeOverwriteQuotesBefore.Name = "dateTimeOverwriteQuotesBefore"; ! this.dateTimeOverwriteQuotesBefore.Size = new System.Drawing.Size(162, 20); this.dateTimeOverwriteQuotesBefore.TabIndex = 15; this.dateTimeOverwriteQuotesBefore.Value = new System.DateTime(2000, 1, 1, 0, 0, 0, 0); --- 228,232 ---- this.dateTimeOverwriteQuotesBefore.Location = new System.Drawing.Point(96, 247); this.dateTimeOverwriteQuotesBefore.Name = "dateTimeOverwriteQuotesBefore"; ! this.dateTimeOverwriteQuotesBefore.Size = new System.Drawing.Size(229, 20); this.dateTimeOverwriteQuotesBefore.TabIndex = 15; this.dateTimeOverwriteQuotesBefore.Value = new System.DateTime(2000, 1, 1, 0, 0, 0, 0); *************** *** 474,478 **** // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); ! this.ClientSize = new System.Drawing.Size(653, 459); this.Controls.Add(this.signallingLabel); this.Controls.Add(this.startingDownloadingTimeLabel); --- 474,478 ---- // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); ! this.ClientSize = new System.Drawing.Size(734, 459); this.Controls.Add(this.signallingLabel); this.Controls.Add(this.startingDownloadingTimeLabel); |
|
From: Glauco S. <gla...@us...> - 2008-07-20 20:37:56
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv7378/Downloader/OpenTickDownloader Modified Files: OTTickerDownloader.cs Log Message: The checkForMissingQuotes flag is now properly handled Index: OTTickerDownloader.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/OTTickerDownloader.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** OTTickerDownloader.cs 9 Jul 2008 22:00:49 -0000 1.2 --- OTTickerDownloader.cs 20 Jul 2008 20:37:51 -0000 1.3 *************** *** 184,195 **** private void setBarsSelector() { ! this.barsSelector = ! new DailyBarsSelector( ! this.tickersToDownload , ! this.setBarsSelector_getDate( this.firstDate ) , ! this.setBarsSelector_getDate( DateTime.Now ) , ! this.barInterval , ! this.firstBarOpenTimeInNewYorkTimeZone , ! this.numberOfDailyBars ); } private void setExchangeSelector() --- 184,212 ---- private void setBarsSelector() { ! DateTime firstDateForBarsSelector = ! this.setBarsSelector_getDate( this.firstDate ); ! DateTime lastDateForBarsSelector = ! this.setBarsSelector_getDate( DateTime.Now ); ! if ( this.checkForMissingQuotes ) ! // only missing quotes are to be downloaded ! this.barsSelector = ! new MissingDailyBarsSelector( ! this.tickersToDownload , ! this.setBarsSelector_getDate( this.firstDate ) , ! this.setBarsSelector_getDate( DateTime.Now ) , ! this.barInterval , ! this.firstBarOpenTimeInNewYorkTimeZone , ! this.numberOfDailyBars ); ! else ! // all quotes are to be downloaded, even if they ! // are in the database already ! this.barsSelector = ! new DailyBarsSelector( ! this.tickersToDownload , ! this.setBarsSelector_getDate( this.firstDate ) , ! this.setBarsSelector_getDate( DateTime.Now ) , ! this.barInterval , ! this.firstBarOpenTimeInNewYorkTimeZone , ! this.numberOfDailyBars ); } private void setExchangeSelector() |
|
From: Glauco S. <gla...@us...> - 2008-07-20 20:36:47
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/OTManagement In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv6919/Downloader/OpenTickDownloader/OTManagement Modified Files: OTManager.cs Log Message: Some code has been added, to avoid having too many pending requests (but it is commented out, and then non used, in this revision) Index: OTManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/OTManagement/OTManager.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OTManager.cs 9 Jul 2008 22:21:09 -0000 1.1 --- OTManager.cs 20 Jul 2008 20:36:44 -0000 1.2 *************** *** 23,26 **** --- 23,27 ---- using System; using System.Collections; + using System.Threading; using OTFeed_NET; *************** *** 59,63 **** /// is removed /// </summary> ! private Hashtable barRequests; /// <summary> /// full path for the file where messages will be logged; if --- 60,64 ---- /// is removed /// </summary> ! private Hashtable pendingBarRequests; /// <summary> /// full path for the file where messages will be logged; if *************** *** 113,120 **** { bool wasSubmittedByThisOTManagerInstance; ! lock( this.barRequests ) { wasSubmittedByThisOTManagerInstance = ! this.barRequests.ContainsKey( requestId ); } return wasSubmittedByThisOTManagerInstance; --- 114,121 ---- { bool wasSubmittedByThisOTManagerInstance; ! lock( this.pendingBarRequests ) { wasSubmittedByThisOTManagerInstance = ! this.pendingBarRequests.ContainsKey( requestId ); } return wasSubmittedByThisOTManagerInstance; *************** *** 296,300 **** private void commonInitialization() { ! this.barRequests = new Hashtable(); this.setOTClientEventHandlers(); } --- 297,301 ---- private void commonInitialization() { ! this.pendingBarRequests = new Hashtable(); this.setOTClientEventHandlers(); } *************** *** 341,347 **** { BarRequest barRequest; ! lock ( this.barRequests ) { ! barRequest = (BarRequest)this.barRequests[ requestId ]; } if ( barRequest == null ) --- 342,348 ---- { BarRequest barRequest; ! lock ( this.pendingBarRequests ) { ! barRequest = (BarRequest)this.pendingBarRequests[ requestId ]; } if ( barRequest == null ) *************** *** 355,361 **** BarRequest barRequest = this.GetBarRequest( requestId ); ! lock ( this.barRequests ) { ! this.barRequests.Remove( requestId ); } return barRequest; --- 356,362 ---- BarRequest barRequest = this.GetBarRequest( requestId ); ! lock ( this.pendingBarRequests ) { ! this.pendingBarRequests.Remove( requestId ); } return barRequest; *************** *** 363,366 **** --- 364,380 ---- #region RequestHistData + private bool areThereTooManyPendentBarRequests() + { + bool areThereTooMany; + lock( this.pendingBarRequests ) + { + areThereTooMany = + ( this.pendingBarRequests.Count >= + DownloaderConstants.MAX_NUMBER_OF_PENDING_REQUESTS_FOR_A_SINGLE_OTMANAGER ); + } + return areThereTooMany; + } + + #region requestHistDataWithoutTooManyPendentBarRequests private int requestHistDataActually( string exchange , *************** *** 392,401 **** symbol , startingDateInUTC ); ! lock ( this.barRequests ) { ! this.barRequests.Add( requestId , barRequest ); } } ! public int RequestHistData( string exchange , string symbol , --- 406,415 ---- symbol , startingDateInUTC ); ! lock ( this.pendingBarRequests ) { ! this.pendingBarRequests.Add( requestId , barRequest ); } } ! public int requestHistDataWithoutTooManyPendentBarRequests( string exchange , string symbol , *************** *** 422,425 **** --- 436,461 ---- return requestId; } + #endregion requestHistDataWithoutTooManyPendentBarRequests + + public int RequestHistData( + string exchange , + string symbol , + DateTime startingDateInUTC , + DateTime endingDateInUTC , + OTHistoricalType oTHistoricalType , + short intervalValue ) + { + // while ( this.areThereTooManyPendentBarRequests() ) + // Thread.Sleep( 10 ); + int requestId = + this.requestHistDataWithoutTooManyPendentBarRequests( + exchange , + symbol , + startingDateInUTC , + endingDateInUTC , + oTHistoricalType , + intervalValue ); + return requestId; + } #endregion RequestHistData |
|
From: Glauco S. <gla...@us...> - 2008-07-20 20:35:32
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/ExchangeSelectors/MostLiquid In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv6467/Downloader/OpenTickDownloader/ExchangeSelectors/MostLiquid Modified Files: MostLiquidExchangeSelectorForSingleTicker.cs Log Message: A comment has been improved Index: MostLiquidExchangeSelectorForSingleTicker.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/ExchangeSelectors/MostLiquid/MostLiquidExchangeSelectorForSingleTicker.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MostLiquidExchangeSelectorForSingleTicker.cs 9 Jul 2008 22:19:36 -0000 1.1 --- MostLiquidExchangeSelectorForSingleTicker.cs 20 Jul 2008 20:35:29 -0000 1.2 *************** *** 85,88 **** --- 85,93 ---- } + /// <summary> + /// Returns the identifier for the most liquid exchange, for the given + /// ticker. If the given ticker is not found to be traded on any of the + /// possible exchanges, then an empty string is returned + /// </summary> public string MostLiquidExchange { |
|
From: Glauco S. <gla...@us...> - 2008-07-20 20:34:55
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/ExchangeSelectors In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv6030/Downloader/OpenTickDownloader/ExchangeSelectors Modified Files: IExchangeSelector.cs Log Message: The interface has been patched, to handle the event that no exchange has been found, for a given ticker Index: IExchangeSelector.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/ExchangeSelectors/IExchangeSelector.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IExchangeSelector.cs 9 Jul 2008 22:18:30 -0000 1.1 --- IExchangeSelector.cs 20 Jul 2008 20:34:51 -0000 1.2 *************** *** 33,37 **** { /// <summary> ! /// returns an identifier for an exchange where the ticker is traded /// </summary> /// <param name="ticker"></param> --- 33,39 ---- { /// <summary> ! /// returns an identifier for an exchange where the ticker is traded; ! /// if the ticker is not found traded on any exchange, then ! /// an empty string is returned /// </summary> /// <param name="ticker"></param> |
|
From: Glauco S. <gla...@us...> - 2008-07-20 20:33:42
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv5578/Downloader/OpenTickDownloader Modified Files: DownloaderConstants.cs Log Message: A new constan has been added, to allow an OTManager to have a max number of pending requests (to avoid too many requests to be submitted) Index: DownloaderConstants.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/DownloaderConstants.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DownloaderConstants.cs 9 Jul 2008 22:17:14 -0000 1.1 --- DownloaderConstants.cs 20 Jul 2008 20:33:39 -0000 1.2 *************** *** 34,37 **** --- 34,45 ---- public const int MAX_NUMBER_OF_BARS_TO_BE_WRITTEN_WITH_A_SINGLE_SQL_COMMAND = 1; + + /// <summary> + /// Max number of bars that a single OTManager object will have + /// pending (if new requests arrive, they will be delayed until + /// the previous ones have been satisfied) + /// </summary> + public const + int MAX_NUMBER_OF_PENDING_REQUESTS_FOR_A_SINGLE_OTMANAGER = 100; // public DownloaderConstants() |
|
From: Glauco S. <gla...@us...> - 2008-07-20 20:32:28
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/DatabaseManagement In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv5121/Downloader/OpenTickDownloader/DatabaseManagement Modified Files: DataBaseWriter.cs Log Message: GetDateConstant() is now a public, static method Index: DataBaseWriter.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/DatabaseManagement/DataBaseWriter.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DataBaseWriter.cs 9 Jul 2008 22:14:30 -0000 1.1 --- DataBaseWriter.cs 20 Jul 2008 20:32:24 -0000 1.2 *************** *** 84,100 **** #region getSqlCommand_getValues - private string getDateConstant( DateTime dateTime ) - { - string dateConstant = - "#" + - dateTime.Month + "/" + - dateTime.Day + "/" + - dateTime.Year + " " + - dateTime.Hour + ":" + - dateTime.Minute + ":" + - dateTime.Second + - "#"; - return dateConstant; - } private string formatDoubleForSql( double value ) { --- 84,87 ---- *************** *** 110,114 **** "'" + bar.Ticker + "' , " + "'" + bar.Exchange + "' , " + ! this.getDateConstant( utcDateTimeForOpen ) + " , " + bar.Interval + " , " + formatDoubleForSql( bar.Open ) + " , " + --- 97,101 ---- "'" + bar.Ticker + "' , " + "'" + bar.Exchange + "' , " + ! DataBaseWriter.GetDateConstant( utcDateTimeForOpen ) + " , " + bar.Interval + " , " + formatDoubleForSql( bar.Open ) + " , " + *************** *** 180,183 **** --- 167,189 ---- this.writeToDataBaseThread.Start(); } + + /// <summary> + /// Builds a date to be used in a Sql query + /// </summary> + /// <param name="dateTime"></param> + /// <returns></returns> + public static string GetDateConstant( DateTime dateTime ) + { + string dateConstant = + "#" + + dateTime.Month + "/" + + dateTime.Day + "/" + + dateTime.Year + " " + + dateTime.Hour + ":" + + dateTime.Minute + ":" + + dateTime.Second + + "#"; + return dateConstant; + } } } |
|
From: Glauco S. <gla...@us...> - 2008-07-20 20:31:57
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/BarsSelectors In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv4714/Downloader/OpenTickDownloader/BarsSelectors Modified Files: DailyBarsSelector.cs Log Message: Some changes have been applied, to make this class become a base class that can be extended Index: DailyBarsSelector.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/BarsSelectors/DailyBarsSelector.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DailyBarsSelector.cs 9 Jul 2008 22:12:05 -0000 1.1 --- DailyBarsSelector.cs 20 Jul 2008 20:31:54 -0000 1.2 *************** *** 31,43 **** public class DailyBarsSelector : IBarsSelector { ! string[] tickers; ! DateTime firstDate; ! DateTime lastDate; /// <summary> /// lenght, in seconds, for a bar (60 for a one minute bar) /// </summary> ! int barInterval; ! DateTime firstBarOpenTimeInNewYorkTimeZone; ! int numberOfBarsToBeDownloadedForEachDay; /// <summary> --- 31,43 ---- public class DailyBarsSelector : IBarsSelector { ! private string[] tickers; ! protected DateTime firstDate; ! protected DateTime lastDate; /// <summary> /// lenght, in seconds, for a bar (60 for a one minute bar) /// </summary> ! protected int barInterval; ! protected DateTime firstBarOpenTimeInNewYorkTimeZone; ! protected int numberOfBarsToBeDownloadedForEachDay; /// <summary> *************** *** 45,49 **** /// </summary> private int currentTickerIndex; ! private DateTime currentDate; /// <summary> /// (0 based) current bar in the currentDate --- 45,49 ---- /// </summary> private int currentTickerIndex; ! protected DateTime currentDate; /// <summary> /// (0 based) current bar in the currentDate *************** *** 186,190 **** #region isTheCurrentBarSelectable ! private bool isAPossibleMarketDay( DateTime currentDate ) { bool isAPossibleMarkDay = --- 186,190 ---- #region isTheCurrentBarSelectable ! protected bool isAPossibleMarketDay( DateTime currentDate ) { bool isAPossibleMarkDay = *************** *** 221,232 **** #region GetNextBarIdentifier ! private string getCurrentTicker() { string currentTicker = this.tickers[ this.currentTickerIndex ]; return currentTicker; } ! private BarIdentifier getNextBarIdentifier_actually() { ! DateTime dateTimeForBarOpenInNewYorkTimeZone = new DateTime( currentDate.Year , --- 221,234 ---- #region GetNextBarIdentifier ! protected string getCurrentTicker() { string currentTicker = this.tickers[ this.currentTickerIndex ]; return currentTicker; } ! ! #region getNextBarIdentifier_actually ! protected DateTime getDateTimeForCurrentCandidateBarOpenInNewYorkTimeZone() { ! DateTime dateTimeForCurrentCandidateBarOpenInNewYorkTimeZone = new DateTime( currentDate.Year , *************** *** 237,247 **** this.firstBarOpenTimeInNewYorkTimeZone.Second ).AddSeconds( this.currentDailyBar * this.barInterval ); BarIdentifier barIdentifier = new BarIdentifier( this.getCurrentTicker() , ! dateTimeForBarOpenInNewYorkTimeZone , this.barInterval ); return barIdentifier; } public BarIdentifier GetNextBarIdentifier() { --- 239,257 ---- this.firstBarOpenTimeInNewYorkTimeZone.Second ).AddSeconds( this.currentDailyBar * this.barInterval ); + return dateTimeForCurrentCandidateBarOpenInNewYorkTimeZone; + } + private BarIdentifier getNextBarIdentifier_actually() + { + DateTime dateTimeForCurrentCandidateBarOpenInNewYorkTimeZone = + this.getDateTimeForCurrentCandidateBarOpenInNewYorkTimeZone(); BarIdentifier barIdentifier = new BarIdentifier( this.getCurrentTicker() , ! dateTimeForCurrentCandidateBarOpenInNewYorkTimeZone , this.barInterval ); return barIdentifier; } + #endregion getNextBarIdentifier_actually + public BarIdentifier GetNextBarIdentifier() { |
|
From: Glauco S. <gla...@us...> - 2008-07-20 20:30:12
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv3814/Downloader/OpenTickDownloader Modified Files: BarsDownloader.cs Log Message: Fixed code for non present event handlers Index: BarsDownloader.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/BarsDownloader.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BarsDownloader.cs 9 Jul 2008 22:10:22 -0000 1.1 --- BarsDownloader.cs 20 Jul 2008 20:30:06 -0000 1.2 *************** *** 137,141 **** object sender , NewMessageEventArgs eventArgs ) { ! this.NewMessage( this , eventArgs ); } private void initializeBarQueueFiller() --- 137,142 ---- object sender , NewMessageEventArgs eventArgs ) { ! if ( this.NewMessage != null ) ! this.NewMessage( this , eventArgs ); } private void initializeBarQueueFiller() |
|
From: Glauco S. <gla...@us...> - 2008-07-20 20:29:27
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv3631/Downloader/OpenTickDownloader Modified Files: BarQueueFiller.cs Log Message: Performance improved when no market is found, for a given ticker Index: BarQueueFiller.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/BarQueueFiller.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BarQueueFiller.cs 9 Jul 2008 22:08:09 -0000 1.1 --- BarQueueFiller.cs 20 Jul 2008 20:29:19 -0000 1.2 *************** *** 178,209 **** // } ! #region fillQueue_requestBars ! private void fillQueue_requestBar( ! BarIdentifier barIdentifier ) { - string exchange = - this.exchangeSelector.SelectExchange( barIdentifier.Ticker ); - - - // DateTime currentDate; - // int currentDailyBarIndex; - // OTDataEntity oTDataEntity = - // new OTDataEntity( exchange , barIdentifier.Ticker ); short numberOfMinutesInEachBar = Convert.ToInt16( Math.Round( Convert.ToDouble( barIdentifier.Interval / 60 ) ) ); - // DateTime dateTimeForBarOpenInNewYorkTimeZone = - // new DateTime( - // currentDate.Year , - // currentDate.Month , - // currentDate.Day , - // this.firstBarOpenTime.Hour , - // this.firstBarOpenTime.Minute , - // this.firstBarOpenTime.Second ).AddMinutes( - // currentDailyBarIndex * numberOfMinutesInEachBar ); DateTime dateTimeForBarOpenInUTC = TimeZoneManager.ConvertToUTC( barIdentifier.DateTimeForOpenInNewYorkTimeZone ); - int requestId = this.oTManager.RequestHistData( exchange , barIdentifier.Ticker , --- 178,191 ---- // } ! #region fillQueue_requestBar ! private void fillQueue_requestBar_actually( ! BarIdentifier barIdentifier , string exchange ) { short numberOfMinutesInEachBar = Convert.ToInt16( Math.Round( Convert.ToDouble( barIdentifier.Interval / 60 ) ) ); DateTime dateTimeForBarOpenInUTC = TimeZoneManager.ConvertToUTC( barIdentifier.DateTimeForOpenInNewYorkTimeZone ); int requestId = this.oTManager.RequestHistData( exchange , barIdentifier.Ticker , *************** *** 214,218 **** this.NewOHLCRequest( requestId , dateTimeForBarOpenInUTC , ! barIdentifier.Interval ); } // private void fillQueue_requestBars( DateTime currentDate ) --- 196,209 ---- this.NewOHLCRequest( requestId , dateTimeForBarOpenInUTC , ! barIdentifier.Interval ); ! } ! private void fillQueue_requestBar( ! BarIdentifier barIdentifier ) ! { ! string exchange = ! this.exchangeSelector.SelectExchange( barIdentifier.Ticker ); ! if ( exchange != "" ) ! // the exchange has been actually selected ! this.fillQueue_requestBar_actually( barIdentifier , exchange ); } // private void fillQueue_requestBars( DateTime currentDate ) *************** *** 224,228 **** // currentDate , currentDailyBarIndex ); // } ! #endregion fillQueue_requestBars private void fillQueue_requestBarsForEachMarketDay() --- 215,219 ---- // currentDate , currentDailyBarIndex ); // } ! #endregion fillQueue_requestBar private void fillQueue_requestBarsForEachMarketDay() |
|
From: Glauco S. <gla...@us...> - 2008-07-20 20:27:56
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv2758/Downloader Modified Files: QuantDownloader_SD.csproj Log Message: OpenTickDownloader\BarsSelectors\MissingDailyBarsSelector.cs has been added Index: QuantDownloader_SD.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/QuantDownloader_SD.csproj,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** QuantDownloader_SD.csproj 9 Jul 2008 22:28:42 -0000 1.4 --- QuantDownloader_SD.csproj 20 Jul 2008 20:27:52 -0000 1.5 *************** *** 58,61 **** --- 58,62 ---- <Compile Include="OpenTickDownloader\BarsSelectors\DailyBarsSelector.cs" /> <Compile Include="OpenTickDownloader\BarsSelectors\IBarsSelector.cs" /> + <Compile Include="OpenTickDownloader\BarsSelectors\MissingDailyBarsSelector.cs" /> <Compile Include="OpenTickDownloader\DatabaseManagement\DatabaseUpdatedEventArgs.cs" /> <Compile Include="OpenTickDownloader\DatabaseManagement\DataBaseWriter.cs" /> |
|
From: Glauco S. <gla...@us...> - 2008-07-20 20:27:17
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/BarsSelectors In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv2624/Downloader/OpenTickDownloader/BarsSelectors Added Files: MissingDailyBarsSelector.cs Log Message: Selects daily bars, but only those who are not already in the database --- NEW FILE: MissingDailyBarsSelector.cs --- /* QuantProject - Quantitative Finance Library MissingDailyBarsSelector.cs Copyright (C) 2008 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Collections; using System.Data; using QuantProject.ADT.Collections; using QuantProject.Data; using QuantProject.DataAccess; namespace QuantProject.Applications.Downloader.OpenTickDownloader { /// <summary> /// Selects daily bars, but only those who are not already in the database /// </summary> public class MissingDailyBarsSelector : DailyBarsSelector { /// <summary> /// contains the dateTimeForOpen for those bars that are /// in the database, for the curren ticker and the given /// barInterval /// </summary> private Set barsAlreadyInTheDatabaseForTheCurrentTicker; /// <summary> /// the last ticker for whom the bars have been read from /// the database /// </summary> private string currentTicker; public MissingDailyBarsSelector( string[] tickers , DateTime firstDate , DateTime lastDate , int barInterval , DateTime firstBarOpenTimeInNewYorkTimeZone , int numberOfBarsToBeDownloadedForEachDay ) : base( tickers , firstDate , lastDate , barInterval , firstBarOpenTimeInNewYorkTimeZone , numberOfBarsToBeDownloadedForEachDay ) { } #region isTheCurrentBarSelectable #region isCurrentBarInTheDatabase #region updateBarsAlreadyInTheDatabase #region updateBarsAlreadyInTheDatabase_actually #region getBarsInTheDatabase private string getSqlTimeConstant( DateTime time ) { string sqlTimeConstant = time.Hour.ToString().PadLeft( 2 , '0' ) + ":" + time.Minute.ToString().PadLeft( 2 , '0' ) + ":" + time.Second.ToString().PadLeft( 2 , '0' ); return sqlTimeConstant; } private string getSqlTimeConstantForFirstDailyBar() { string sqlTimeConstantForFirstDailyBar = this.getSqlTimeConstant( this.firstBarOpenTimeInNewYorkTimeZone ); return sqlTimeConstantForFirstDailyBar; } #region getSqlTimeConstantForLastDailyBar private DateTime getLastBarOpenTimeInNewYorkTimeZone() { int secondsToBeAdded = this.barInterval * ( this.numberOfBarsToBeDownloadedForEachDay - 1 ); DateTime lastBarOpenTimeInNewYorkTimeZone = this.firstBarOpenTimeInNewYorkTimeZone.AddSeconds( secondsToBeAdded ); return lastBarOpenTimeInNewYorkTimeZone; } private string getSqlTimeConstantForLastDailyBar() { DateTime lastBarOpenTimeInNewYorkTimeZone = this.getLastBarOpenTimeInNewYorkTimeZone(); string sqlTimeConstantForLastDailyBar = this.getSqlTimeConstant( lastBarOpenTimeInNewYorkTimeZone ); return sqlTimeConstantForLastDailyBar; } #endregion getSqlTimeConstantForLastDailyBar private DataTable getBarsInTheDatabase( string ticker ) { string sql = "select baDateTimeForOpen from bars " + "where (baTicker='" + ticker + "') and " + "(baInterval=" + this.barInterval + ") and" + "(baDateTimeForOpen>=" + DataBaseWriter.GetDateConstant( this.firstDate ) + ") and" + "(baDateTimeForOpen<" + DataBaseWriter.GetDateConstant( this.lastDate.AddDays( 1 ) ) + ") and" + "(Format([baDateTimeForOpen],'hh:mm:ss')>='" + this.getSqlTimeConstantForFirstDailyBar() + "') and" + "(Format([baDateTimeForOpen],'hh:mm:ss')<='" + this.getSqlTimeConstantForLastDailyBar() + "');"; DataTable barsInTheDatabase = SqlExecutor.GetDataTable( sql ); return barsInTheDatabase; } #endregion getBarsInTheDatabase #region updateBarsAlreadyInTheDatabase private void clearBarsAlreadyInTheDatabaseForTheCurrentTicker() { if ( this.barsAlreadyInTheDatabaseForTheCurrentTicker == null ) // this is the first time bars are added and // barsAlreadyInTheDatabaseForTheCurrentTicker has not // even been created, yet this.barsAlreadyInTheDatabaseForTheCurrentTicker = new Set(); } private void updateBarsAlreadyInTheDatabase( DataTable dtBarsInTheDatabase ) { this.clearBarsAlreadyInTheDatabaseForTheCurrentTicker(); this.barsAlreadyInTheDatabaseForTheCurrentTicker.Clear(); foreach( DataRow dataRow in dtBarsInTheDatabase.Rows ) this.barsAlreadyInTheDatabaseForTheCurrentTicker.Add( dataRow[ 0 ] ); } #endregion updateBarsAlreadyInTheDatabase private void updateBarsAlreadyInTheDatabase_actually() { DataTable dtBarsInTheDatabase = this.getBarsInTheDatabase( this.getCurrentTicker() ); this.updateBarsAlreadyInTheDatabase( dtBarsInTheDatabase ); this.currentTicker = this.getCurrentTicker(); } #endregion updateBarsAlreadyInTheDatabase_actually private void updateBarsAlreadyInTheDatabase() { if ( this.currentTicker != this.getCurrentTicker() ) // the current ticker has changed and so // this.barsAlreadyInTheDatabase is not up to date this.updateBarsAlreadyInTheDatabase_actually(); } #endregion updateBarsAlreadyInTheDatabase private bool isCurrentBarAlreadyInTheDatabase_withSetUpdated() { DateTime dateTimeForCurrentCandidateBarOpenInNewYorkTimeZone = this.getDateTimeForCurrentCandidateBarOpenInNewYorkTimeZone(); bool isAlreadyInTheDatabase = this.barsAlreadyInTheDatabaseForTheCurrentTicker.Contains( dateTimeForCurrentCandidateBarOpenInNewYorkTimeZone ); return isAlreadyInTheDatabase; } private bool isCurrentBarAlreadyInTheDatabase() { this.updateBarsAlreadyInTheDatabase(); bool isAlreadyInTheDatabase = this.isCurrentBarAlreadyInTheDatabase_withSetUpdated(); return isAlreadyInTheDatabase; } #endregion isCurrentBarInTheDatabase protected override bool isTheCurrentBarSelectable() { bool isSelectable = ( ( this.isAPossibleMarketDay( this.currentDate ) ) && ( ! this.isCurrentBarAlreadyInTheDatabase() ) ); return isSelectable; } #endregion isTheCurrentBarSelectable } } |
|
From: Glauco S. <gla...@us...> - 2008-07-09 22:28:47
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv30275 Modified Files: QuantDownloader_SD.csproj Log Message: - a reference to System.Configuration has been added - OpenTickDownloader\DatabaseUpdatedEventArgs.cs has been moved to OpenTickDownloader\DatabaseManagement\DatabaseUpdatedEventArgs.cs - OpenTickDownloader\Bar.cs has been added - OpenTickDownloader\BarQueue.cs has been added - OpenTickDownloader\BarQueueFiller.cs has been added - OpenTickDownloader\BarsDownloader.cs has been added - OpenTickDownloader\BarsSelectors\BarIdentifier.cs has been added - OpenTickDownloader\BarsSelectors\DailyBarsSelector.cs has been added - OpenTickDownloader\BarsSelectors\IBarsSelector.cs has been added - OpenTickDownloader\DatabaseManagement\DatabaseUpdatedEventArgs.cs has been added - OpenTickDownloader\DatabaseManagement\DataBaseWriter.cs has been added - OpenTickDownloader\DownloaderConstants.cs has been added - OpenTickDownloader\ExchangeSelectors\IExchangeSelector.cs has been added - OpenTickDownloader\ExchangeSelectors\MostLiquid\MostLiquidExchangeSelector.cs has been added - OpenTickDownloader\ExchangeSelectors\MostLiquid\MostLiquidExchangeSelectorForSingleTicker.cs has been added - OpenTickDownloader\OTManagement\BarRequest.cs has been added - OpenTickDownloader\OTManagement\OTManager.cs has been added - OpenTickDownloader\TimeZoneManaging\DSTPeriod.cs has been added - OpenTickDownloader\TimeZoneManaging\TimeZoneManager.cs has been added - folder OpenTickDownloader\BarsSelectors\ has been added - folder OpenTickDownloader\DatabaseManagement\ has been added - folder OpenTickDownloader\ExchangeSelectors\ has been added - folder OpenTickDownloader\ExchangeSelectors\MostLiquid\ has been added - folder OpenTickDownloader\OTManagement\ has been added - folder OpenTickDownloader\TimeZoneManaging\ has been added Index: QuantDownloader_SD.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/QuantDownloader_SD.csproj,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** QuantDownloader_SD.csproj 1 Jul 2008 17:43:04 -0000 1.3 --- QuantDownloader_SD.csproj 9 Jul 2008 22:28:42 -0000 1.4 *************** *** 36,39 **** --- 36,40 ---- </Reference> <Reference Include="System" /> + <Reference Include="System.Configuration" /> <Reference Include="System.Data" /> <Reference Include="System.Drawing" /> *************** *** 50,57 **** <Compile Include="DataSet1.cs" /> <Compile Include="Main.cs" /> ! <Compile Include="OpenTickDownloader\DatabaseUpdatedEventArgs.cs" /> <Compile Include="OpenTickDownloader\DownloadedCompletedEventArgs.cs" /> <Compile Include="OpenTickDownloader\DownloadingStartedEventArgs.cs" /> <Compile Include="OpenTickDownloader\OTTickerDownloader.cs" /> <Compile Include="OpenTickDownloader\UserForms\OTWebDownloader.cs" /> <Compile Include="QuotesDataGrid.cs" /> --- 51,74 ---- <Compile Include="DataSet1.cs" /> <Compile Include="Main.cs" /> ! <Compile Include="OpenTickDownloader\Bar.cs" /> ! <Compile Include="OpenTickDownloader\BarQueue.cs" /> ! <Compile Include="OpenTickDownloader\BarQueueFiller.cs" /> ! <Compile Include="OpenTickDownloader\BarsDownloader.cs" /> ! <Compile Include="OpenTickDownloader\BarsSelectors\BarIdentifier.cs" /> ! <Compile Include="OpenTickDownloader\BarsSelectors\DailyBarsSelector.cs" /> ! <Compile Include="OpenTickDownloader\BarsSelectors\IBarsSelector.cs" /> ! <Compile Include="OpenTickDownloader\DatabaseManagement\DatabaseUpdatedEventArgs.cs" /> ! <Compile Include="OpenTickDownloader\DatabaseManagement\DataBaseWriter.cs" /> <Compile Include="OpenTickDownloader\DownloadedCompletedEventArgs.cs" /> + <Compile Include="OpenTickDownloader\DownloaderConstants.cs" /> <Compile Include="OpenTickDownloader\DownloadingStartedEventArgs.cs" /> + <Compile Include="OpenTickDownloader\ExchangeSelectors\IExchangeSelector.cs" /> + <Compile Include="OpenTickDownloader\ExchangeSelectors\MostLiquid\MostLiquidExchangeSelector.cs" /> + <Compile Include="OpenTickDownloader\ExchangeSelectors\MostLiquid\MostLiquidExchangeSelectorForSingleTicker.cs" /> + <Compile Include="OpenTickDownloader\OTManagement\BarRequest.cs" /> + <Compile Include="OpenTickDownloader\OTManagement\OTManager.cs" /> <Compile Include="OpenTickDownloader\OTTickerDownloader.cs" /> + <Compile Include="OpenTickDownloader\TimeZoneManaging\DSTPeriod.cs" /> + <Compile Include="OpenTickDownloader\TimeZoneManaging\TimeZoneManager.cs" /> <Compile Include="OpenTickDownloader\UserForms\OTWebDownloader.cs" /> <Compile Include="QuotesDataGrid.cs" /> *************** *** 90,99 **** <DependentUpon>OTWebDownloader.cs</DependentUpon> </EmbeddedResource> - <EmbeddedResource Include="TickerSelectors\TickerSelectorForm.resx"> - <DependentUpon>TickerSelectorForm.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="WebDownloader.resx"> - <DependentUpon>WebDownloader.cs</DependentUpon> - </EmbeddedResource> </ItemGroup> <ItemGroup> --- 107,110 ---- *************** *** 119,122 **** --- 130,139 ---- </ProjectReference> <Folder Include="OpenTickDownloader" /> + <Folder Include="OpenTickDownloader\BarsSelectors" /> + <Folder Include="OpenTickDownloader\DatabaseManagement" /> + <Folder Include="OpenTickDownloader\ExchangeSelectors" /> + <Folder Include="OpenTickDownloader\ExchangeSelectors\MostLiquid" /> + <Folder Include="OpenTickDownloader\OTManagement" /> + <Folder Include="OpenTickDownloader\TimeZoneManaging" /> <Folder Include="OpenTickDownloader\UserForms" /> </ItemGroup> |
|
From: Glauco S. <gla...@us...> - 2008-07-09 22:22:27
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/TimeZoneManaging In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv26765 Added Files: TimeZoneManager.cs Log Message: Handles DateTime conversion from EST/EDT to UTC --- NEW FILE: TimeZoneManager.cs --- /* QuantProject - Quantitative Finance Library TimeZoneManager.cs Copyright (C) 2008 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Collections; namespace QuantProject.Applications.Downloader.OpenTickDownloader { /// <summary> /// Handles DateTime conversion from EST/EDT to UTC /// </summary> public class TimeZoneManager { static Hashtable dSTPeriods; public TimeZoneManager() { } #region IsDaylightSavingTime #region initialize_dstPeriods #region initialize_dstPeriods_add private static void initialize_dstPeriods_add( int year , int monthForBegin , int dayForBegin , int monthForEnd , int dayForEnd ) { DateTime dateTimeForBegin = new DateTime( year , monthForBegin , dayForBegin , 1 , 59 , 59 ); DateTime dateTimeForEnd = new DateTime( year , monthForEnd , dayForEnd , 1 , 59 , 59 ); DSTPeriod dSTPeriod = new DSTPeriod( dateTimeForBegin , dateTimeForEnd ); dSTPeriods.Add( year , dSTPeriod ); } #endregion initialize_dstPeriods_add private static void initialize_dstPeriods() { // dates have been taken by this page http://www.timeanddate.com/worldclock/timezone.html?n=179 dSTPeriods = new Hashtable(); initialize_dstPeriods_add( 2000 , 4 , 2 , 10 , 29 ); initialize_dstPeriods_add( 2001 , 4 , 1 , 10 , 28 ); initialize_dstPeriods_add( 2002 , 4 , 7 , 10 , 27 ); initialize_dstPeriods_add( 2003 , 4 , 6 , 10 , 26 ); initialize_dstPeriods_add( 2004 , 4 , 4 , 10 , 31 ); initialize_dstPeriods_add( 2005 , 4 , 3 , 10 , 30 ); initialize_dstPeriods_add( 2006 , 4 , 2 , 10 , 29 ); initialize_dstPeriods_add( 2007 , 3 , 11 , 11 , 4 ); initialize_dstPeriods_add( 2008 , 3 , 9 , 11 , 2 ); initialize_dstPeriods_add( 2009 , 3 , 8 , 11 , 1 ); } #endregion initialize_dstPeriods /// <summary> /// True iif the given DateTime is a daylightSavingTime /// </summary> /// <param name="dateTimeInNewYorkTimeZone"></param> /// <returns></returns> public static bool IsDaylightSavingTime( DateTime dateTimeInNewYorkTimeZone ) { if ( dSTPeriods == null ) initialize_dstPeriods(); DSTPeriod dSTPeriod = (DSTPeriod)dSTPeriods[ dateTimeInNewYorkTimeZone.Year ]; bool isDaylightSavingTime = ( dSTPeriod.Begin.CompareTo( dateTimeInNewYorkTimeZone ) < 0 ) && ( dSTPeriod.End.CompareTo( dateTimeInNewYorkTimeZone ) > 0 ); return isDaylightSavingTime; } #endregion IsDaylightSavingTime /// <summary> /// Converts a DateTime in the New York time zone /// (that can either be EST or EDT) to UTC /// </summary> /// <param name="dateTimeInNewYorkTimeZone"></param> /// <returns></returns> public static DateTime ConvertToUTC( DateTime dateTimeInNewYorkTimeZone ) { DateTime dateTimeInUTC; if ( TimeZoneManager.IsDaylightSavingTime( dateTimeInNewYorkTimeZone ) ) dateTimeInUTC = dateTimeInNewYorkTimeZone.AddHours( 4 ); else dateTimeInUTC = dateTimeInNewYorkTimeZone.AddHours( 5 ); return dateTimeInUTC; } public static DateTime ConvertToEST( DateTime dateTimeInUTC ) { DateTime dateTimeInEST = dateTimeInUTC.AddHours( -5 ); if ( TimeZoneManager.IsDaylightSavingTime( dateTimeInEST ) ) dateTimeInEST = dateTimeInUTC.AddHours( -4 ); return dateTimeInEST; } } } |
|
From: Glauco S. <gla...@us...> - 2008-07-09 22:21:57
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/TimeZoneManaging In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv26220 Added Files: DSTPeriod.cs Log Message: A period when the Daylight Saving Time is applied --- NEW FILE: DSTPeriod.cs --- /* QuantProject - Quantitative Finance Library DSTPeriod.cs Copyright (C) 2008 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; namespace QuantProject.Applications.Downloader.OpenTickDownloader { /// <summary> /// A period when the Daylight Saving Time is applied /// </summary> public class DSTPeriod { private DateTime begin; private DateTime end; public DateTime Begin { get { return begin; } } public DateTime End { get { return end; } } /// <summary> /// A period when the Daylight Saving Time is applied /// </summary> /// <param name="begin">begin of the period</param> /// <param name="end">end of the period</param> public DSTPeriod( DateTime begin , DateTime end ) { this.checkParameters( begin , end ); this.begin = begin; this.end = end; } #region checkParameters private void checkForSunday( DateTime dateTime ) { if ( dateTime.DayOfWeek != DayOfWeek.Sunday ) throw new Exception( "Begin and end of a DSTPeriod must be a Sunday!" ); } private void checkParameters( DateTime begin , DateTime end ) { this.checkForSunday( begin ); this.checkForSunday( end ); } #endregion checkParameters } } |
|
From: Glauco S. <gla...@us...> - 2008-07-09 22:21:13
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/OTManagement In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv26019 Added Files: OTManager.cs Log Message: Encapsulates the OTClient and extends its features --- NEW FILE: OTManager.cs --- /* QuantProject - Quantitative Finance Library OTManager.cs Copyright (C) 2008 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Collections; using OTFeed_NET; using QuantProject.ADT.Messaging; //using QuantProject.Presentation; namespace QuantProject.Applications.Downloader.OpenTickDownloader { public delegate void OnErrorEventHandler( OTError otError ); public delegate void OnLoginEventHandler(); public delegate void OnNoDataEventHandler( int requestId , BarRequest barRequest ); public delegate void OnEndOfDataEventHandler( int requestId , BarRequest barRequest ); public delegate void OnHistoricalOHLCEventHandler( OTOHLC ohlc , BarRequest barRequest ); /// <summary> /// Encapsulates the OTClient and extends its features /// </summary> public class OTManager : IMessageSender { public event OnErrorEventHandler OnError; public static OnLoginEventHandler OnLogin; public event OnNoDataEventHandler OnNoData; public event OnEndOfDataEventHandler OnEndOfData; public event OnHistoricalOHLCEventHandler OnHistoricalOHLC; public event NewMessageEventHandler NewMessage; /// <summary> /// requests for wich an answering event has not been received yet; /// when such an event returns, it is forwarded and then the request /// is removed /// </summary> private Hashtable barRequests; /// <summary> /// full path for the file where messages will be logged; if /// this member is "" then no logging is required /// </summary> // private string logFileName; private static OTClient oTClient; /// <summary> /// used to lock OTManager.oTClient: we use a dummy BarRequest /// but any reference type would have done the job /// </summary> // private static BarRequest oTClientCreatorLocker = // new BarRequest( "A" , "A" , new DateTime( 1 , 1 , 2008 ) ); static OTManager() { OTManager.oTClient = new OTClient(); OTManager.oTClient.onLogin += new OTLoginEvent( OTManager.onLoginEventHandler ); OTManager.oTClient.onStatusChanged += new OTStatusChangedEvent( OTManager.onStatusChangedEventHandler ); } private static void onLoginEventHandler() { if ( OTManager.OnLogin != null ) OTManager.OnLogin(); } private static void onStatusChangedEventHandler( int status ) { string currentStatusHasChangedTo = OTStatus.GetName( typeof( OTStatus ) , status ); string message = "Current status has changed to: " + currentStatusHasChangedTo; // this.riseNewMessageEvent( message ); } /// <summary> /// Encapsulates the OTClient and extends its features. Using /// this constructor, no log is done /// </summary> public OTManager() { // this.logFileName = ""; this.commonInitialization(); } #region commonInitialization #region setOTCLientEventHandlers private bool wasThisRequestSubmittedByThisOTManagerInstance( int requestId ) { bool wasSubmittedByThisOTManagerInstance; lock( this.barRequests ) { wasSubmittedByThisOTManagerInstance = this.barRequests.ContainsKey( requestId ); } return wasSubmittedByThisOTManagerInstance; } #region onOTClientError #region onOTClientError_actually private void onOTClientError_riseOnNoDataIfTheCase( OTError error ) { if ( error.Code == Convert.ToInt32( OTErrorCodes.NoData ) ) // current error event signals no data available for // the given ticker, for the given exchange { BarRequest barRequest = this.RemoveBarRequest( error.RequestId ); if ( this.OnNoData != null ) this.OnNoData( error.RequestId , barRequest ); } } private void onOTClientError_logMessage( OTError error ) { string message = "onOTClientError " + "---" + "Code: " + error.Code + "---" + "Description: " + error.Description + "---" + "RequestId: " + error.RequestId + "---" + "Type: " + error.Type; OTDataEntity oTDataEntity = OTManager.oTClient.getEntityById( error.RequestId ); if ( oTDataEntity != null ) // RequestId was refered to a OTDataEntity message = message + "---" + "Ticker: " + oTDataEntity.Symbol + "---" + "Exchange: " + oTDataEntity.Exchange; this.riseNewMessageEvent( message ); } private void onOTClientError_actually( OTError error ) { this.onOTClientError_riseOnNoDataIfTheCase( error ); this.onOTClientError_logMessage( error ); if ( this.OnError != null ) this.OnError( error ); } #endregion onOTClientError_actually private void onOTClientError( OTError error ) { if ( this.wasThisRequestSubmittedByThisOTManagerInstance( error.RequestId ) ) // the error refers to a request submitted by this OTManager instance this.onOTClientError_actually( error ); } #endregion onOTClientError #region onMessageEventHandler #region onMessageEventHandler_actually #region onMessageEventHandler_logMessage private string getCompleteMessage( string message , OTDataEntity oTDataEntity , int requestId ) { BarRequest barRequest = this.GetBarRequest( requestId ); // DateTime dateTimeForRequest = (DateTime) // this.requestsThatAreNotCompletedYet[ requestId ]; // this.requestsThatAreNotCompletedYet.Remove( requestId ); string completeMessage = message + "---" + "Ticker: " + oTDataEntity.Symbol + "---" + "Exchange: " + oTDataEntity.Exchange + "---" + "DateTime: " + barRequest.DateTimeForOpenInUTC; return completeMessage; } private void onMessageEventHandler_logMessage( OTMessage oTMessage ) { string message = "onMessageEventHandler " + "---" + "Code: " + oTMessage.Code + "---" + "Description: " + oTMessage.Description + "---" + "RequestId: " + oTMessage.RequestId; OTDataEntity oTDataEntity = OTManager.oTClient.getEntityById( oTMessage.RequestId ); if ( oTDataEntity != null ) // RequestId was refered to a OTDataEntity message = this.getCompleteMessage( message , oTDataEntity , oTMessage.RequestId ); this.riseNewMessageEvent( message ); // System.Windows.Forms.MessageBox.Show( message ); } #endregion onMessageEventHandler_logMessage private void onMessageEventHandler_riseOnEndOfDataIfTheCase( OTMessage oTMessage ) { if ( oTMessage.Code == Convert.ToInt32( OTMessageCodes.EndOfData ) ) // a request has all been satisfied { BarRequest barRequest = this.RemoveBarRequest( oTMessage.RequestId ); if ( this.OnEndOfData != null ) this.OnEndOfData( oTMessage.RequestId , barRequest ); } } private void onMessageEventHandler_actually( OTMessage oTMessage ) { this.onMessageEventHandler_logMessage( oTMessage ); this.onMessageEventHandler_riseOnEndOfDataIfTheCase( oTMessage ); } #endregion onMessageEventHandler_actually private void onMessageEventHandler( OTMessage oTMessage ) { if ( this.wasThisRequestSubmittedByThisOTManagerInstance( oTMessage.RequestId ) ) this.onMessageEventHandler_actually( oTMessage ); } #endregion onMessageEventHandler #region onHistoricalOHLC #region onHistoricalOHLC_actually private void onHistoricalOHLC_logMessage( OTOHLC ohlc ) { OTDataEntity oTDataEntity = OTManager.oTClient.getEntityById( ohlc.RequestId ); string message = String.Format( "OHLC({7}):time={0} o={1,-6} h={2,-6} " + "l={3,-6} c={4,-6} v={5,-8} now is {6} " + "- ticker:{8} - exchange:{9}" , ohlc.Timestamp, ohlc.OpenPrice, ohlc.HighPrice, ohlc.LowPrice, ohlc.ClosePrice, ohlc.Volume, DateTime.Now, ohlc.RequestId , oTDataEntity.Symbol , oTDataEntity.Exchange ); this.riseNewMessageEvent( message ); } private void onHistoricalOHLC_actually( OTOHLC ohlc ) { this.onHistoricalOHLC_logMessage( ohlc ); if ( this.OnHistoricalOHLC != null ) { BarRequest barRequest = this.GetBarRequest( ohlc.RequestId ); this.OnHistoricalOHLC( ohlc , barRequest ); } } #endregion onHistoricalOHLC_actually private void onHistoricalOHLC( OTOHLC ohlc ) { if ( this.wasThisRequestSubmittedByThisOTManagerInstance( ohlc.RequestId ) ) this.onHistoricalOHLC_actually( ohlc ); } #endregion onHistoricalOHLC private void setOTClientEventHandlers() { OTManager.oTClient.onError += new OTErrorEvent( this.onOTClientError ); OTManager.oTClient.onMessage += new OTMessageEvent( this.onMessageEventHandler ); // if ( oTClientWasJustCreated ) // // oTClient was null. We want only one OTManager instance // // to monitor (and possibly log) oTClient status changes // { // OTManager.oTClient.onLogin += new OTLoginEvent( // OTManager.onLoginEventHandler ); // OTManager.oTClient.onStatusChanged += new OTStatusChangedEvent( // OTManager.onStatusChangedEventHandler ); // } OTManager.oTClient.onHistoricalOHLC += new OTOHLCEvent( this.onHistoricalOHLC ); } #endregion setOTCLientEventHandlers private void commonInitialization() { this.barRequests = new Hashtable(); this.setOTClientEventHandlers(); } #endregion commonInitialization public static void SubmitLogin( string openTickUser , string openTickPassword ) { OTManager.oTClient.addHost( "feed1.opentick.com" , 10010 ); // string username = // System.Configuration.ConfigurationManager.AppSettings[ // "usrnm" ]; // string password = // System.Configuration.ConfigurationManager.AppSettings[ // "pswd" ]; OTManager.oTClient.login( openTickUser , openTickPassword ); } // /// <summary> // /// This method can be // /// </summary> // public void SubmitLogin() // { // bool oTCLientWasNullWhenThisMethodBegan; // // TO DO add a lock to the following two statements //// lock( ??? what could I use here??? ) //// { //// oTCLientWasNullWhenThisMethodBegan = //// ( OTManager.oTClient == null ); //// if ( oTCLientWasNullWhenThisMethodBegan ) //// OTManager.oTClient = new OTClient(); //// } // this.setOTClientEventHandlers( oTCLientWasNullWhenThisMethodBegan ); // if ( oTCLientWasNullWhenThisMethodBegan ) // this.submitLogin(); // } public BarRequest GetBarRequest( int requestId ) { BarRequest barRequest; lock ( this.barRequests ) { barRequest = (BarRequest)this.barRequests[ requestId ]; } if ( barRequest == null ) throw new Exception( "There is no request for the given requestId" ); return barRequest; } public BarRequest RemoveBarRequest( int requestId ) { BarRequest barRequest = this.GetBarRequest( requestId ); lock ( this.barRequests ) { this.barRequests.Remove( requestId ); } return barRequest; } #region RequestHistData private int requestHistDataActually( string exchange , string symbol , DateTime startingDateInUTC , DateTime endingDateInUTC , OTHistoricalType oTHistoricalType , short intervalValue ) { OTDataEntity oTDataEntity = new OTDataEntity( exchange , symbol ); int requestId = OTManager.oTClient.requestHistData( oTDataEntity , startingDateInUTC , endingDateInUTC , oTHistoricalType , intervalValue ); return requestId; } private void update_barRequests( int requestId , string exchange , string symbol , DateTime startingDateInUTC , DateTime endingDateInUTC , OTHistoricalType oTHistoricalType , short intervalValue) { BarRequest barRequest = new BarRequest( exchange , symbol , startingDateInUTC ); lock ( this.barRequests ) { this.barRequests.Add( requestId , barRequest ); } } public int RequestHistData( string exchange , string symbol , DateTime startingDateInUTC , DateTime endingDateInUTC , OTHistoricalType oTHistoricalType , short intervalValue ) { int requestId = this.requestHistDataActually( exchange , symbol , startingDateInUTC , endingDateInUTC , oTHistoricalType , intervalValue ); this.update_barRequests( requestId , exchange , symbol , startingDateInUTC , endingDateInUTC , oTHistoricalType , intervalValue); return requestId; } #endregion RequestHistData private void riseNewMessageEvent( string message ) { NewMessageEventArgs eArgs = new NewMessageEventArgs( message ); if ( this.NewMessage != null ) this.NewMessage( this , eArgs ); // MessageManager.DisplayMessage( // message + "\n" , this.logFileName ); } } } |
|
From: Glauco S. <gla...@us...> - 2008-07-09 22:20:45
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/OTManagement In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv25397 Added Files: BarRequest.cs Log Message: A bar to be requested to the OTClient --- NEW FILE: BarRequest.cs --- /* QuantProject - Quantitative Finance Library BarRequest.cs Copyright (C) 2008 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; namespace QuantProject.Applications.Downloader.OpenTickDownloader { /// <summary> /// A bar to be requested to the OTClient /// </summary> public class BarRequest { private string exchange; private string symbol; private DateTime dateTimeForOpenInUTC; public string Exchange { get { return exchange; } } public string Symbol { get { return symbol; } } public DateTime DateTimeForOpenInUTC { get { return dateTimeForOpenInUTC; } } public BarRequest( string exchange , string symbol , DateTime dateTimeForOpenInUTC ) { this.exchange = exchange; this.symbol = symbol; this.dateTimeForOpenInUTC = dateTimeForOpenInUTC; } } } |
|
From: Glauco S. <gla...@us...> - 2008-07-09 22:19:39
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/ExchangeSelectors/MostLiquid In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv24813/MostLiquid Added Files: MostLiquidExchangeSelectorForSingleTicker.cs Log Message: Finds the most liquid exchange for a ticker --- NEW FILE: MostLiquidExchangeSelectorForSingleTicker.cs --- /* QuantProject - Quantitative Finance Library MostLiquidExchangeSelectorForSingleTicker.cs Copyright (C) 2008 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Collections.Generic; using OTFeed_NET; using QuantProject.ADT.Messaging; namespace QuantProject.Applications.Downloader.OpenTickDownloader { public delegate void MostLiquidExchangeFoundEventHandler( object sender , string ticker , string mostLiquidExchange ); public delegate void MostLiquidExchangeNotFoundEventHandler( object sender , string ticker ); /// <summary> /// Finds the most liquid exchange for a ticker /// </summary> public class MostLiquidExchangeSelectorForSingleTicker : IMessageSender { /// <summary> /// the main exchange for the ticker has been found /// </summary> public event MostLiquidExchangeFoundEventHandler MostLiquidExchangeFound; /// <summary> /// the ticker is not exchanged in any of the considered exchanges /// </summary> public event MostLiquidExchangeNotFoundEventHandler MostLiquidExchangeNotFound; public event NewOHLCRequestEventHandler NewOHLCRequest; public event NewMessageEventHandler NewMessage; private OTManager oTManager; private string ticker; private DateTime startingDate; private DateTime endingDate; private Dictionary<string , long> volumeForExchange; private List<int> requestIdsFromThisObject; private bool isSearchComplete; private bool isMostLiquidExchangeFound; private string mostLiquidExchange; public bool IsSearchComplete { get { return this.isSearchComplete; } } public bool IsMostLiquidExchangeFound { get { if ( !this.IsSearchComplete ) throw new Exception( "The search is not complete, yet!" ); return this.isMostLiquidExchangeFound; } } public string MostLiquidExchange { get { if ( !this.IsSearchComplete ) throw new Exception( "The search is not complete, yet!" ); return this.mostLiquidExchange; } } /// <summary> /// Finds the most liquid exchange for a ticker. Events are logged /// to the given text file /// </summary> /// <param name="ticker">ticker for whom the most liquid exchange is /// to be found</param> /// <param name="logFileName">full path for the file where events will /// be logged in</param> // public MostLiquidExchangeSelectorForSingleTicker( // string ticker , string logFileName ) // { // this.oTManager = new OTManager(); // this.commonInitialization( ticker ); // } public MostLiquidExchangeSelectorForSingleTicker( string ticker ) { this.oTManager = new OTManager(); this.oTManager.NewMessage += new NewMessageEventHandler( this.newMessageEventHandler ); this.commonInitialization( ticker ); } private void commonInitialization( string ticker ) { this.ticker = ticker; this.isSearchComplete = false; } private void newMessageEventHandler( object sender , NewMessageEventArgs eventArgs ) { if ( this.NewMessage != null ) this.NewMessage( this , eventArgs ); } #region SelectMostLiquidExchange private void setRequestParameters() { this.startingDate = new DateTime( 2007 , 1 , 1 ); this.endingDate = new DateTime( 2007 , 1 , 10 ); } #region setEventsHandlers #region compareVolumesSetResultsAndRiseEvents #region setMostLiquidExchange private void setMostLiquidExchange( out long volumeForMostLiquidExchange ) { volumeForMostLiquidExchange = long.MinValue; this.mostLiquidExchange = ""; foreach ( KeyValuePair< string , long > exchangeWithVolume in this.volumeForExchange ) if ( exchangeWithVolume.Value > volumeForMostLiquidExchange ) { volumeForMostLiquidExchange = exchangeWithVolume.Value; this.mostLiquidExchange = exchangeWithVolume.Key; } } #endregion setMostLiquidExchange private void setResultsForExchangeNotFound() { this.isMostLiquidExchangeFound = false; if ( this.MostLiquidExchangeNotFound != null ) this.MostLiquidExchangeNotFound( this , this.ticker ); } private void setResultsForMainExchangeFound() { this.isMostLiquidExchangeFound = true; // MainExchangeFoundEventArgs eventArgs = // new MainExchangeFoundEventArgs( // this.ticker , this.mostLiquidExchange ); if ( this.MostLiquidExchangeFound != null ) this.MostLiquidExchangeFound( this , this.ticker , this.mostLiquidExchange ); } private void compareVolumesSetResultsAndRiseEvents() { long volumeForMostLiquidExchange; this.setMostLiquidExchange( out volumeForMostLiquidExchange ); if ( volumeForMostLiquidExchange <= 0 ) // the ticker is not exchanged in any of the considered exchanges this.setResultsForExchangeNotFound(); else // the main exchange for the ticker has been found this.setResultsForMainExchangeFound(); } #endregion compareVolumesSetResultsAndRiseEvents private void addVolumeForExchange( string exchange , long volume ) { this.volumeForExchange.Add( exchange , volume ); if ( this.volumeForExchange.Count == 3 ) // all three bars have been analyzed { this.compareVolumesSetResultsAndRiseEvents(); this.isSearchComplete = true; this.oTManager.OnHistoricalOHLC -= this.onHistoricalOHLCeventHandler; this.oTManager.OnNoData -= this.onNoDataEventHandler; } } #region onHistoricalOHLCeventHandler_addVolumeForExchange private void onHistoricalOHLCeventHandler_addVolumeForExchangeActually( string exchange , long volume ) { // OTDataEntity oTDataEntity = this.oTClient.getEntityById( // ohlc.RequestId ); this.addVolumeForExchange( exchange , volume ); } private void onHistoricalOHLCeventHandler_addVolumeForExchange( int requestId , string exchange , long volume ) { if ( this.requestIdsFromThisObject.Contains( requestId ) ) { this.onHistoricalOHLCeventHandler_addVolumeForExchangeActually( exchange , volume ); } } #endregion onHistoricalOHLCeventHandler_addVolumeForExchange private void onHistoricalOHLCeventHandler( OTOHLC ohlc , BarRequest barRequest ) { this.onHistoricalOHLCeventHandler_addVolumeForExchange( ohlc.RequestId , barRequest.Exchange , ohlc.Volume ); } private void onNoDataEventHandler( int requestId , BarRequest barRequest ) { if ( this.requestIdsFromThisObject.Contains( requestId ) ) // the request had been submitted by this object // OTDataEntity oTDataEntity = // this.oTClient.getEntityById( error.RequestId ); this.addVolumeForExchange( barRequest.Exchange , 0 ); } private void onEndOfDataEventHandler( int requestId , BarRequest barRequest ) { if ( this.requestIdsFromThisObject.Contains( requestId ) ) { // the request had been submitted by this object // OTDataEntity oTDataEntity = // this.oTClient.getEntityById( oTMessage.RequestId ); if ( !this.volumeForExchange.ContainsKey( barRequest.Exchange ) ) // no data is available for this exchange this.addVolumeForExchange( barRequest.Exchange , 0 ); } } private void setEventsHandlers() { this.oTManager.OnHistoricalOHLC += new OnHistoricalOHLCEventHandler( this.onHistoricalOHLCeventHandler ); this.oTManager.OnNoData += new OnNoDataEventHandler( this.onNoDataEventHandler ); this.oTManager.OnEndOfData += new OnEndOfDataEventHandler( this.onEndOfDataEventHandler ); } #endregion setEventsHandlers #region request #region riseNewOHLCRequestEvent private long getBarInterval() { TimeSpan timeSpan = this.endingDate.Subtract( this.startingDate ); long barInterval = timeSpan.Seconds; return barInterval; } private void riseNewOHLCRequestEvent( int requestId ) { long barInterval = this.getBarInterval(); if ( this.NewOHLCRequest != null ) this.NewOHLCRequest( requestId , this.startingDate , barInterval ); } #endregion riseNewOHLCRequestEvent private void request( string exchangeCode ) { // OTDataEntity oTDataEntity = new OTDataEntity( // exchangeCode , this.ticker ); int requestId = this.oTManager.RequestHistData( exchangeCode , this.ticker , this.startingDate , this.endingDate , OTHistoricalType.OhlcDaily , 10 ); this.requestIdsFromThisObject.Add( requestId ); this.riseNewOHLCRequestEvent( requestId ); } #endregion request public void SelectMostLiquidExchange() { this.volumeForExchange = new Dictionary<string , long>(); this.requestIdsFromThisObject = new List<int>(); this.setRequestParameters(); this.setEventsHandlers(); this.request( "A" ); this.request( "N" ); this.request( "Q" ); } #endregion SelectMostLiquidExchange } } |
|
From: Glauco S. <gla...@us...> - 2008-07-09 22:19:24
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/ExchangeSelectors/MostLiquid In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv24780/MostLiquid Added Files: MostLiquidExchangeSelector.cs Log Message: Finds the most liquid exchange for given tickers --- NEW FILE: MostLiquidExchangeSelector.cs --- /* QuantProject - Quantitative Finance Library MostLiquidExchangeSelector.cs Copyright (C) 2008 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Collections; using System.Collections.Generic; using System.Threading; using OTFeed_NET; using QuantProject.ADT.Messaging; namespace QuantProject.Applications.Downloader.OpenTickDownloader { /// <summary> /// Finds the most liquid exchange for given tickers /// </summary> public class MostLiquidExchangeSelector : IExchangeSelector { public event NewMessageEventHandler NewMessage; // /// <summary> // /// the main exchange for the ticker has been found // /// </summary> // public event MainExchangeFoundEventHandler MainExchangeFound; // // /// <summary> // /// the ticker is not exchanged in any of the considered exchanges // /// </summary> // public event ExchangeNotFoundEventHandler ExchangeNotFound; // // public event NewOHLCRequestEventHandler NewOHLCRequest; // private OTManager oTManager; /// <summary> /// if non empty, contains the full path to the file where /// OTManager's events will be logged /// </summary> // private string logFileName; /// <summary> /// keys are the tickers; mostLiquidExchange[ ticker ] is the /// most liquid exchange for ticker /// </summary> private Hashtable mostLiquidExchange; // private DateTime startingDate; // private DateTime endingDate; // public MostLiquidExchangeSelector( string logFileName ) // { //// this.oTManager = oTManager; // this.logFileName = logFileName; // this.commonInitialization(); // } public MostLiquidExchangeSelector() { // this.oTManager = oTManager; // this.logFileName = ""; this.mostLiquidExchange = new Hashtable(); } // private void commonInitialization() // { // this.mostLiquidExchange = new Hashtable(); // } #region SelectExchange #region setExchange #region setExchange_setMostLiquidExchangeSelectorForSingleTicker private void newMessageEventHandler( object sender , NewMessageEventArgs eventArgs ) { if ( this.NewMessage != null ) this.NewMessage( this , eventArgs ); } private MostLiquidExchangeSelectorForSingleTicker setExchange_setMostLiquidExchangeSelectorForSingleTicker( string ticker ) { MostLiquidExchangeSelectorForSingleTicker mostLiquidExchangeSelectorForSingleTicker = new MostLiquidExchangeSelectorForSingleTicker( ticker ); mostLiquidExchangeSelectorForSingleTicker.NewMessage += new NewMessageEventHandler( this.newMessageEventHandler ); // if ( this.logFileName == "" ) // // no logging is required // mostLiquidExchangeSelectorForSingleTicker = // new MostLiquidExchangeSelectorForSingleTicker( ticker ); // else // // logging is required // mostLiquidExchangeSelectorForSingleTicker = // new MostLiquidExchangeSelectorForSingleTicker( // ticker , this.logFileName ); return mostLiquidExchangeSelectorForSingleTicker; } #endregion setExchange_setMostLiquidExchangeSelectorForSingleTicker private void setExchange( string ticker ) { MostLiquidExchangeSelectorForSingleTicker mostLiquidExchangeSelectorForSingleTicker = this.setExchange_setMostLiquidExchangeSelectorForSingleTicker( ticker ); // MostLiquidExchangeSelectorForSingleTicker // mostLiquidExchangeSelectorForSingleTicker = // new MostLiquidExchangeSelectorForSingleTicker( // ticker , this.logFileName ); mostLiquidExchangeSelectorForSingleTicker.SelectMostLiquidExchange(); while ( !mostLiquidExchangeSelectorForSingleTicker.IsSearchComplete ) // the most liquid exchange has not been found, yet Thread.Sleep( 200 ); this.mostLiquidExchange.Add( ticker , mostLiquidExchangeSelectorForSingleTicker.MostLiquidExchange ); } #endregion setExchange public string SelectExchange( string ticker ) { string exchange; if ( !this.mostLiquidExchange.ContainsKey( ticker ) ) // the most liquid exchang for ticker has not been computed, yet this.setExchange( ticker ); exchange = (string)this.mostLiquidExchange[ ticker ]; return exchange; } #endregion SelectExchange } } |
|
From: Glauco S. <gla...@us...> - 2008-07-09 22:18:33
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/ExchangeSelectors In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv24291 Added Files: IExchangeSelector.cs Log Message: Selects an exchange for a given ticker --- NEW FILE: IExchangeSelector.cs --- /* QuantProject - Quantitative Finance Library BarIdentifier.cs Copyright (C) 2008 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.ADT.Messaging; namespace QuantProject.Applications.Downloader.OpenTickDownloader { /// <summary> /// Selects an exchange for a given ticker /// </summary> public interface IExchangeSelector : IMessageSender { /// <summary> /// returns an identifier for an exchange where the ticker is traded /// </summary> /// <param name="ticker"></param> /// <returns></returns> string SelectExchange( string ticker ); } } |
|
From: Glauco S. <gla...@us...> - 2008-07-09 22:17:49
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/ExchangeSelectors/MostLiquid In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv24142/MostLiquid Log Message: Directory /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/ExchangeSelectors/MostLiquid added to the repository |
|
From: Glauco S. <gla...@us...> - 2008-07-09 22:17:19
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv23999 Added Files: DownloaderConstants.cs Log Message: Constants to be used by the download process --- NEW FILE: DownloaderConstants.cs --- /* QuantProject - Quantitative Finance Library DownloaderConstants.cs Copyright (C) 2008 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; namespace QuantProject.Applications.Downloader.OpenTickDownloader { /// <summary> /// Constants to be used by the download process /// </summary> public class DownloaderConstants { /// <summary>Number of bars that will be written by the database writer, /// with a single Sql command</summary> public const int MAX_NUMBER_OF_BARS_TO_BE_WRITTEN_WITH_A_SINGLE_SQL_COMMAND = 1; // public DownloaderConstants() // { // } } } |
|
From: Glauco S. <gla...@us...> - 2008-07-09 22:15:35
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/TimeZoneManaging In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv23316/TimeZoneManaging Log Message: Directory /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/TimeZoneManaging added to the repository |