quantproject-developers Mailing List for QuantProject (Page 42)
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-09 22:15:24
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/OTManagement In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv23298/OTManagement Log Message: Directory /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/OTManagement added to the repository |
|
From: Glauco S. <gla...@us...> - 2008-07-09 22:15:11
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/ExchangeSelectors In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv23153/ExchangeSelectors Log Message: Directory /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/ExchangeSelectors added to the repository |
|
From: Glauco S. <gla...@us...> - 2008-07-09 22:14:34
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/DatabaseManagement In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv22799 Added Files: DataBaseWriter.cs Log Message: Writes downloaded bars into the database --- NEW FILE: DataBaseWriter.cs --- /* QuantProject - Quantitative Finance Library DataBaseWriter.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.Threading; using QuantProject.DataAccess; namespace QuantProject.Applications.Downloader.OpenTickDownloader { public delegate void DatabaseUpdatedEventHandler( object sender , DatabaseUpdatedEventArgs e ); /// <summary> /// Writes downloaded bars into the database /// </summary> public class DataBaseWriter { public event DatabaseUpdatedEventHandler DatabaseUpdated; private BarQueue barQueue; private int maxNumberOfBarsToBeWrittenWithASingleSqlCommand; private Thread writeToDataBaseThread; private bool areAllBarsWrittenToDatabase; public DataBaseWriter( BarQueue barQueue , int maxNumberOfBarsToBeWrittenWithASingleSqlCommand ) { this.barQueue = barQueue; this.maxNumberOfBarsToBeWrittenWithASingleSqlCommand = maxNumberOfBarsToBeWrittenWithASingleSqlCommand; this.areAllBarsWrittenToDatabase = false; } #region writeToDataBase #region writeToDataBaseIfEnoughBars private bool isThereEnoughBarsInTheQueue() { bool isThereEnoughBars; lock( this.barQueue ) { isThereEnoughBars = ( this.barQueue.Queue.Count >= this.maxNumberOfBarsToBeWrittenWithASingleSqlCommand ); } return isThereEnoughBars; } #region writeToDataBaseActually private Bar dequeue() { Bar bar; lock( this.barQueue ) { bar = this.barQueue.Queue.Dequeue(); } return bar; } #region getSqlCommand #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 ) { string formattedValue = value.ToString().Replace( ',' , '.' ); return formattedValue; } private string getSqlCommand_getValues( Bar bar ) { DateTime utcDateTimeForOpen = TimeZoneManager.ConvertToEST( bar.DateTimeForOpenInUTCTime ); string values = "'" + bar.Ticker + "' , " + "'" + bar.Exchange + "' , " + this.getDateConstant( utcDateTimeForOpen ) + " , " + bar.Interval + " , " + formatDoubleForSql( bar.Open ) + " , " + formatDoubleForSql( bar.High ) + " , " + formatDoubleForSql( bar.Low ) + " , " + formatDoubleForSql( bar.Close ) + " , " + bar.Volume; return values; } #endregion getSqlCommand_getValues private string getSqlCommand( Bar bar ) { string sqlCommand = "INSERT INTO bars " + "( baTicker, baExchange, baDateTimeForOpen, baInterval, baOpen, baHigh, baLow, baClose, baVolume ) " + "SELECT " + this.getSqlCommand_getValues( bar ) + ";"; // "SELECT 'MSFT' , 'Q' , #12/13/2004 15:16:17# , 60 , 30.2 , 30.5 , 29.9 , 30.3 , 100000 ;"; return sqlCommand; } #endregion getSqlCommand private void writeToDataBaseActually( Bar bar ) { string sqlCommand = this.getSqlCommand( bar ); SqlExecutor.ExecuteNonQuery( sqlCommand ); } private void riseDatabaseUpdatedEvent( Bar bar ) { if ( this.DatabaseUpdated != null ) { DatabaseUpdatedEventArgs eventArgs = new DatabaseUpdatedEventArgs( bar.Ticker , TimeZoneManager.ConvertToEST( bar.DateTimeForOpenInUTCTime ) ); this.DatabaseUpdated( this , eventArgs ); } } private void writeToDataBaseActually() { Bar bar = this.dequeue(); this.writeToDataBaseActually( bar ); this.riseDatabaseUpdatedEvent( bar ); } #endregion writeToDataBaseActually private void writeToDataBaseIfEnoughBars() { if ( this.isThereEnoughBarsInTheQueue() ) this.writeToDataBaseActually(); } #endregion writeToDataBaseIfEnoughBars private void writeToDataBase() { while ( !this.areAllBarsWrittenToDatabase ) { this.writeToDataBaseIfEnoughBars(); Thread.Sleep( 50 ); } } #endregion writeToDataBase public void StartWritingBuffersToDatabase() { this.writeToDataBaseThread = new Thread( new ThreadStart( this.writeToDataBase ) ); this.writeToDataBaseThread.Start(); } } } |
|
From: Glauco S. <gla...@us...> - 2008-07-09 22:12:42
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/BarsSelectors In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv22307 Added Files: IBarsSelector.cs Log Message: Interface to be implemented by bars selectors. A bar selector selects some OpenHighLowClose bars (that then will be downloaded) --- NEW FILE: IBarsSelector.cs --- /* QuantProject - Quantitative Finance Library IBarsSelector.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> /// Interface to be implemented by bars selectors. A bar /// selector selects some OpenHighLowClose bars (that then /// will be downloaded) /// </summary> public interface IBarsSelector { /// <summary> /// returns the next BarIdentifier (for the historical OHLC bar /// to be requested) /// </summary> /// <returns></returns> BarIdentifier GetNextBarIdentifier(); /// <summary> /// true iif all bars have already been selected and /// signaled outside /// </summary> bool AreAllBarsAlredyGiven { get; } } } |
|
From: Glauco S. <gla...@us...> - 2008-07-09 22:12:08
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/BarsSelectors In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv22262 Added Files: DailyBarsSelector.cs Log Message: Selects all daily bars, without looking at what it's in the database, already --- NEW FILE: DailyBarsSelector.cs --- /* QuantProject - Quantitative Finance Library DailyBarsSelector.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> /// Selects all daily bars, without looking at what it's in the database, already /// </summary> 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> /// points to the ticker for the current bar to be selected /// </summary> private int currentTickerIndex; private DateTime currentDate; /// <summary> /// (0 based) current bar in the currentDate /// </summary> private int currentDailyBar; public bool AreAllBarsAlredyGiven { get { bool areAllBarsAlredyGiven = ( this.currentTickerIndex == ( this.tickers.Length - 1 ) ) && ( ( this.currentDate.CompareTo( this.lastDate ) == 0 ) && ( this.currentDailyBar == this.numberOfBarsToBeDownloadedForEachDay - 1 ) ); return areAllBarsAlredyGiven; } } /// <summary> /// Selects all daily bars, without looking at what it's /// in the database, already /// </summary> /// <param name="tickers">the tickers whose bars are to be downloaded</param> /// <param name="firstDate">first date for the days to be considered</param> /// <param name="lastDate">last date for the days to be considered</param> /// <param name="barInterval">lenght, in seconds, for a bar (60 for /// a one minute bar)</param> /// <param name="firstBarOpenTimeInNewYorkTimeZone">time for the open /// of the first bar that has to be downloaded, for every day; /// use New York time zone for this parameter</param> /// <param name="numberOfBarsToBeDownloadedForEachDay">number of bars /// to be downloaded every day</param> public DailyBarsSelector( string[] tickers , DateTime firstDate , DateTime lastDate , int barInterval , DateTime firstBarOpenTimeInNewYorkTimeZone , int numberOfBarsToBeDownloadedForEachDay ) { this.checkParameters( firstDate , lastDate , numberOfBarsToBeDownloadedForEachDay ); this.tickers = tickers; this.firstDate = firstDate; this.lastDate = lastDate; this.barInterval = barInterval; this.firstBarOpenTimeInNewYorkTimeZone = firstBarOpenTimeInNewYorkTimeZone; this.numberOfBarsToBeDownloadedForEachDay = numberOfBarsToBeDownloadedForEachDay; this.currentTickerIndex = 0; this.currentDate = this.firstDate.AddDays( - 1 ); this.currentDailyBar = numberOfBarsToBeDownloadedForEachDay - 1; this.moveToTheNextSelectedBar(); } #region checkParameters private void checkParameters_checkNoTime( DateTime dateTime ) { if ( ( dateTime.Hour != 0 ) || ( dateTime.Minute != 0 ) || ( dateTime.Second != 0 ) ) throw new Exception( "A date is expected!" ); } private void checkParameters( DateTime firstDate , DateTime lastDate , int numberOfBarsToBeDownloadedForEachDay ) { this.checkParameters_checkNoTime( firstDate ); this.checkParameters_checkNoTime( lastDate ); if ( firstDate.CompareTo( lastDate ) > 0 ) throw new Exception( "firstDate cannot follow lastDate!" ); if ( numberOfBarsToBeDownloadedForEachDay <= 0 ) throw new Exception( "numberOfBarsToBeDownloadedForEachDay must be greater than zero!" ); } #endregion checkParameters // private void handleCaseTheLastBarIdentifierWasTheLastOneForTheDay() // { // if ( this.currentDailyBar > // this.numberOfBarsToBeDownloadedForEachDay ) // // the last bar identifier was the last one for the day // { // this.currentDailyBar = 0; // this.currentDate.AddDays( 1 ); // } // } #region moveToTheNextBar #region doNextStep #region doNextStep_actually private void doNextStep_actually_moveToTheNextDay() { if ( this.currentDate == this.lastDate ) { // all bars for the current ticker have been signaled this.currentTickerIndex++; this.currentDate = this.firstDate; } else // for the current ticker there may be // some other bars to be signaled out this.currentDate = this.currentDate.AddDays( 1 ); this.currentDailyBar = 0; } private void doNextStep_actually() { if ( this.currentDailyBar == ( this.numberOfBarsToBeDownloadedForEachDay - 1 ) ) // the current bar identifier is the last one for the // current (ticker,date) this.doNextStep_actually_moveToTheNextDay(); else // the current bar identifier is not the last one // for the current (ticker,date) this.currentDailyBar ++; } #endregion doNextStep_actually private void doNextStep() { this.doNextStep_actually(); // this.handle_areAllBarsAlredyGiven(); } #endregion doNextStep private bool isTheCurrentBarBeyondTheLastDate() { bool isBeyondTheLastDate = ( this.currentDate.CompareTo( this.lastDate ) > 0 ); return isBeyondTheLastDate; } #region isTheCurrentBarSelectable private bool isAPossibleMarketDay( DateTime currentDate ) { bool isAPossibleMarkDay = ( currentDate.DayOfWeek != DayOfWeek.Saturday ) && ( currentDate.DayOfWeek != DayOfWeek.Sunday ) && !( ( currentDate.Month == 1 ) && ( currentDate.Day == 1 ) ) && !( ( currentDate.Month == 12 ) && ( currentDate.Day == 25 ) ); return isAPossibleMarkDay; } protected virtual bool isTheCurrentBarSelectable() { bool isSelectable = this.isAPossibleMarketDay( this.currentDate ); return isSelectable; } #endregion isTheCurrentBarSelectable private void moveToTheNextSelectedBar() { this.doNextStep(); while ( !this.isTheCurrentBarBeyondTheLastDate() && !this.isTheCurrentBarSelectable() ) this.doNextStep(); // DateTime currentDate = this.firstDate; // while ( currentDate <= this.lastDate ) // { // if ( this.isAPossibleMarketDay( currentDate ) ) // this.fillQueue_requestBars( currentDate ); // currentDate = currentDate.AddDays( 1 ); // } } #endregion moveToTheNextBar #region GetNextBarIdentifier private string getCurrentTicker() { string currentTicker = this.tickers[ this.currentTickerIndex ]; return currentTicker; } private BarIdentifier getNextBarIdentifier_actually() { DateTime dateTimeForBarOpenInNewYorkTimeZone = new DateTime( currentDate.Year , currentDate.Month , currentDate.Day , this.firstBarOpenTimeInNewYorkTimeZone.Hour , this.firstBarOpenTimeInNewYorkTimeZone.Minute , this.firstBarOpenTimeInNewYorkTimeZone.Second ).AddSeconds( this.currentDailyBar * this.barInterval ); BarIdentifier barIdentifier = new BarIdentifier( this.getCurrentTicker() , dateTimeForBarOpenInNewYorkTimeZone , this.barInterval ); return barIdentifier; } public BarIdentifier GetNextBarIdentifier() { if ( this.AreAllBarsAlredyGiven ) throw new Exception( "There are no more bars to be selected!" ); BarIdentifier barIdentifier = this.getNextBarIdentifier_actually(); this.moveToTheNextSelectedBar(); return barIdentifier; } #endregion GetNextBarIdentifier } } |
|
From: Glauco S. <gla...@us...> - 2008-07-09 22:11:49
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/BarsSelectors In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv22220 Added Files: BarIdentifier.cs Log Message: Identifies an OpenHighLowClose bar to be requested (the exchange is not considered) --- NEW FILE: BarIdentifier.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; namespace QuantProject.Applications.Downloader.OpenTickDownloader { /// <summary> /// Identifies an OpenHighLowClose bar to be requested /// (the exchange is not considered) /// </summary> public class BarIdentifier { private string ticker; private DateTime dateTimeForOpenInNewYorkTimeZone; private long interval; public string Ticker { get { return this.ticker; } } public DateTime DateTimeForOpenInNewYorkTimeZone { get { return this.dateTimeForOpenInNewYorkTimeZone; } } public long Interval { get { return this.interval; } } /// <summary> /// Identifies an OpenHighLowClose bar bar to be requested /// (the exchange is not considered) /// </summary> /// <param name="ticker">the ticker the bar is referred to</param> /// <param name="dateTimeForOpenInNewYorkTimeZone">date time when the bar begins</param> /// <param name="interval">number or seconds between the /// bar's open and the bar's close (in other words, the bar's /// length, in seconds)</param> public BarIdentifier( string ticker , DateTime dateTimeForOpenInNewYorkTimeZone , long interval ) { this.ticker = ticker; this.dateTimeForOpenInNewYorkTimeZone = dateTimeForOpenInNewYorkTimeZone; this.interval = interval; } } } |
|
From: Glauco S. <gla...@us...> - 2008-07-09 22:11:06
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/BarsSelectors In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv21789/BarsSelectors Log Message: Directory /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/BarsSelectors added to the repository |
|
From: Glauco S. <gla...@us...> - 2008-07-09 22:10:26
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv21720 Added Files: BarsDownloader.cs Log Message: Downloads bars and stores them in the database (in the bars table) --- NEW FILE: BarsDownloader.cs --- /* QuantProject - Quantitative Finance Library BarsDownloader.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 System.Threading; using OTFeed_NET; using QuantProject.ADT.Messaging; namespace QuantProject.Applications.Downloader.OpenTickDownloader { /// <summary> /// Downloads bars and stores them in the /// database (in the bars table) /// </summary> public class BarsDownloader : IMessageSender { public event NewOHLCRequestEventHandler NewOHLCRequest; public event NewMessageEventHandler NewMessage; public event DatabaseUpdatedEventHandler DatabaseUpdated; private IBarsSelector barsSelector; private IExchangeSelector exchangeSelector; private string openTickUser; private string openTickPassword; private OTManager oTManager; // private string ticker; // private DateTime firstDate; // private DateTime lastDate; // private int barInterval; // private DateTime firstBarOpenTime; // private int numberOfBarsToBeDownloadedForEachDay; private BarQueue barQueue; private BarQueueFiller barQueueFiller; private DataBaseWriter dataBaseWriter; // private MainExchangeFinder mainExchangeFinder; // public event ExchangeNotFoundEventHandler ExchangeNotFound; /// <summary> /// Downloads and writes to database the requested bars /// </summary> /// <param name="oTClient">OTClient to be used for downloading</param> /// <param name="ticker">the ticker whose bars have to be downloaded</param> /// <param name="firstDate">first date for the days to be considered</param> /// <param name="lastDate">last date for the days to be considered</param> /// <param name="barInterval">lenght, in seconds, for a bar (60 for /// a one minute bar)</param> /// <param name="firstBarOpenTime">time for the open of the first bar /// that has to be downloaded, for every day; use New York time zone /// for this parameter</param> /// <param name="numberOfBarsToBeDownloadedForEachDay">number of bars /// to be downloaded every day</param> public BarsDownloader( IBarsSelector barsSelector , IExchangeSelector exchangeSelector , string openTickUser , string openTickPassword // , // string ticker , // DateTime firstDate , // DateTime lastDate , // int barInterval , // DateTime firstBarOpenTime , // int numberOfBarsToBeDownloadedForEachDay ) { this.barsSelector = barsSelector; this.exchangeSelector = exchangeSelector; this.openTickUser = openTickUser; this.openTickPassword = openTickPassword; this.oTManager = new OTManager(); // this.ticker = ticker; // this.firstDate = firstDate; // this.lastDate = lastDate; // this.barInterval = barInterval; // this.firstBarOpenTime = firstBarOpenTime; // this.numberOfBarsToBeDownloadedForEachDay = // numberOfBarsToBeDownloadedForEachDay; } #region DownloadBars // private void runMainExchangeFinder() // { // // consider using this.oTClient.requestListSymbols( string exchange ); //// this.mainExchangeFinder = //// new MainExchangeFinder( this.oTClient , this.ticker ); // this.mainExchangeFinder.NewOHLCRequest += // new NewOHLCRequestEventHandler( this.newOHLCRequestEventHandler ); // mainExchangeFinder.FindMainExchange(); // while ( !mainExchangeFinder.IsSearchComplete ) // // the main exchange has not been found, yet // Thread.Sleep( 200 ); // } private void initializeBarQueue() { this.barQueue = new BarQueue( DownloaderConstants.MAX_NUMBER_OF_BARS_TO_BE_WRITTEN_WITH_A_SINGLE_SQL_COMMAND ); } #region initializeBarQueueFiller private void newOHLCRequestEventHandler( int requestID , DateTime dateTimeForRequestInUTC , long barInterval ) { if ( this.NewOHLCRequest != null ) this.NewOHLCRequest( requestID , dateTimeForRequestInUTC , barInterval ); } private void newMessageEventHandler( object sender , NewMessageEventArgs eventArgs ) { this.NewMessage( this , eventArgs ); } private void initializeBarQueueFiller() { this.barQueueFiller = new BarQueueFiller( this.barsSelector , this.exchangeSelector , this.oTManager , // this.ticker , // this.mainExchangeFinder.MainExchange , // this.firstDate , // this.lastDate , // this.barInterval , // this.firstBarOpenTime , // this.numberOfBarsToBeDownloadedForEachDay , this.barQueue ); this.barQueueFiller.NewOHLCRequest += new NewOHLCRequestEventHandler( this.newOHLCRequestEventHandler ); this.barQueueFiller.NewMessage += new NewMessageEventHandler( this.newMessageEventHandler ); } #endregion initializeBarQueueFiller #region initializeDatabaseWriter private void databaseUpdatedEventHandler( object sender , DatabaseUpdatedEventArgs eventArgs ) { if ( this.DatabaseUpdated != null ) this.DatabaseUpdated( this , eventArgs ); } private void initializeDatabaseWriter() { this.dataBaseWriter = new DataBaseWriter( this.barQueue , DownloaderConstants.MAX_NUMBER_OF_BARS_TO_BE_WRITTEN_WITH_A_SINGLE_SQL_COMMAND ); this.dataBaseWriter.DatabaseUpdated += new DatabaseUpdatedEventHandler( this.databaseUpdatedEventHandler ); } #endregion initializeDatabaseWriter private void initializeDownloadingObjects() { this.initializeBarQueue(); this.initializeBarQueueFiller(); this.initializeDatabaseWriter(); } private void startThreadToFillBarQueue() { this.barQueueFiller.StartFillingQueue(); } private void startThreadToWriteBarsFromBuffersToTheDatabase() { this.dataBaseWriter.StartWritingBuffersToDatabase(); } private void onLoginEventHandler() { // this.runMainExchangeFinder(); // if ( this.mainExchangeFinder.IsMainExchangeFound ) // // the main exchange has been found and // { this.initializeDownloadingObjects(); this.startThreadToFillBarQueue(); this.startThreadToWriteBarsFromBuffersToTheDatabase(); // } // else // this.ExchangeNotFound( this , this.ticker ); // this.downloadBarsThread = new Thread( // new ThreadStart( this.downloadBars ) ); // this.downloadBarsThread.Start(); // this.testForDaylightSavingTime(); } public void DownloadBars() { OTManager.OnLogin += new OnLoginEventHandler( this.onLoginEventHandler ); OTManager.SubmitLogin( this.openTickUser , this.openTickPassword ); } #endregion DownloadBars } } |
|
From: Glauco S. <gla...@us...> - 2008-07-09 22:08:13
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv20973 Added Files: BarQueueFiller.cs Log Message: Downloads all the bars for a given ticker and writes them into a queue --- NEW FILE: BarQueueFiller.cs --- /* QuantProject - Quantitative Finance Library BarQueueFiller.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.Threading; using OTFeed_NET; using QuantProject.ADT.Messaging; namespace QuantProject.Applications.Downloader.OpenTickDownloader { public delegate void NewOHLCRequestEventHandler( int requestId , DateTime dateTimeForRequest , long barInterval ); /// <summary> /// Downloads all the bars for a given ticker and /// writes them into a queue /// </summary> public class BarQueueFiller : IMessageSender { public event NewOHLCRequestEventHandler NewOHLCRequest; public event NewMessageEventHandler NewMessage; private IBarsSelector barsSelector; private OTManager oTManager; // private string ticker; // private string exchange; // private DateTime firstDate; // private DateTime lastDate; // private long barInterval; // private DateTime firstBarOpenTime; // private int numberOfBarsToBeDownloadedForEachDay; private BarQueue barQueue; private IExchangeSelector exchangeSelector; private Thread fillQueueThread; // private bool working; // private DateTime currentDate; /// <summary> /// Downloads all the bars for a given ticker and /// writes them into a queue /// </summary> /// <param name="oTClient">OTClient to be used for downloading</param> /// <param name="ticker">the ticker whose bars have to be downloaded</param> /// <param name="exchange">exchange from which bars are to requested</param> /// <param name="firstDate">first date for the days to be considered</param> /// <param name="lastDate">last date for the days to be considered</param> /// <param name="barInterval">lenght, in seconds, for a bar (60 for /// a one minute bar)</param> /// <param name="firstBarOpenTime">time for the open of the first bar /// that has to be downloaded, for every day; use New York time zone /// for this parameter</param> /// <param name="numberOfBarsToBeDownloadedForEachDay">number of bars /// to be downloaded every day</param> /// <param name="barQueue">queue to be filled with the /// downloaded bars</param> public BarQueueFiller( IBarsSelector barsSelector , IExchangeSelector exchangeSelector , OTManager oTManager , // string ticker , // string exchange , // DateTime firstDate , // DateTime lastDate , // long barInterval , // DateTime firstBarOpenTime , // int numberOfBarsToBeDownloadedForEachDay , BarQueue barQueue ) { this.barsSelector = barsSelector; this.exchangeSelector = exchangeSelector; this.exchangeSelector.NewMessage += new NewMessageEventHandler( this.newMessageEventHandler ); this.oTManager = oTManager; this.oTManager.NewMessage += new NewMessageEventHandler( this.newMessageEventHandler ); // this.ticker = ticker; // this.exchange = exchange; // this.firstDate = firstDate; // this.lastDate = lastDate; // this.barInterval = barInterval; // this.firstBarOpenTime = firstBarOpenTime; // this.numberOfBarsToBeDownloadedForEachDay = // numberOfBarsToBeDownloadedForEachDay; this.barQueue = barQueue; } private void newMessageEventHandler( object sender , NewMessageEventArgs eventArgs ) { if ( this.NewMessage != null ) this.NewMessage( this , eventArgs ); } #region fillQueue #region onHistoricalOHLC #region getBar private long getBar_getInterval( OTOHLC ohlc ) { int interval = 60; // TO DO use an internal list to handle this data return interval; } private Bar getBar( OTOHLC ohlc ) { BarRequest barRequest = this.oTManager.GetBarRequest( ohlc.RequestId ); string ticker = barRequest.Symbol; string exchange = barRequest.Exchange; long interval = this.getBar_getInterval( ohlc ); Bar bar = new Bar( ticker , exchange , ohlc.Timestamp , interval , ohlc.OpenPrice , ohlc.HighPrice , ohlc.LowPrice , ohlc.ClosePrice , ohlc.Volume ); return bar; } #endregion getBar private void onHistoricalOHLCEventHandler( OTOHLC ohlc , BarRequest barRequest ) { Bar bar = this.getBar( ohlc ); this.barQueue.Enqueue( bar ); } #endregion onHistoricalOHLC private void fillQueue_setEventHandlers() { this.oTManager.OnHistoricalOHLC += new OnHistoricalOHLCEventHandler( this.onHistoricalOHLCEventHandler ); } #region fillQueue_requestBarsForEachMarketDay // private bool isAPossibleMarketDay( DateTime currentDate ) // { // bool isAPossibleMarkDay = // ( currentDate.DayOfWeek != DayOfWeek.Saturday ) && // ( currentDate.DayOfWeek != DayOfWeek.Sunday ) && // !( ( currentDate.Month == 1 ) && ( currentDate.Day == 1 ) ) && // !( ( currentDate.Month == 12 ) && ( currentDate.Day == 25 ) ); // // return isAPossibleMarkDay; // } #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 , dateTimeForBarOpenInUTC , dateTimeForBarOpenInUTC , OTHistoricalType.OhlcMinutely , numberOfMinutesInEachBar ); if ( this.NewOHLCRequest != null ) this.NewOHLCRequest( requestId , dateTimeForBarOpenInUTC , barIdentifier.Interval ); } // private void fillQueue_requestBars( DateTime currentDate ) // { // for ( int currentDailyBarIndex = 0 ; // currentDailyBarIndex < this.numberOfBarsToBeDownloadedForEachDay ; // currentDailyBarIndex++ ) // this.fillQueue_requestBar( // currentDate , currentDailyBarIndex ); // } #endregion fillQueue_requestBars private void fillQueue_requestBarsForEachMarketDay() { while ( !this.barsSelector.AreAllBarsAlredyGiven ) this.fillQueue_requestBar( this.barsSelector.GetNextBarIdentifier() ); // DateTime currentDate = this.firstDate; // while ( currentDate <= this.lastDate ) // { // if ( this.isAPossibleMarketDay( currentDate ) ) // this.fillQueue_requestBars( currentDate ); // currentDate = currentDate.AddDays( 1 ); // } } #endregion fillQueue_requestBarsForEachMarketDay private void fillQueue() { this.fillQueue_setEventHandlers(); this.fillQueue_requestBarsForEachMarketDay(); string forBreakpoint = "temp"; } #endregion fillQueue public void StartFillingQueue() { // this.working = true; this.fillQueueThread = new Thread( new ThreadStart( this.fillQueue ) ); this.fillQueueThread.Start(); } } } |
|
From: Glauco S. <gla...@us...> - 2008-07-09 22:07:36
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv20878 Added Files: BarQueue.cs Log Message: Keeps a queue of bars, rises events when needed --- NEW FILE: BarQueue.cs --- /* QuantProject - Quantitative Finance Library BarQueue.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 System.Threading; namespace QuantProject.Applications.Downloader.OpenTickDownloader { public delegate void NewChunkOfBarsToBeWrittenWithASingleSqlCommandEventHandler(); /// <summary> /// Keeps a queue of bars, rises events when needed. /// </summary> public class BarQueue { public event NewChunkOfBarsToBeWrittenWithASingleSqlCommandEventHandler NewChunkOfBarsToBeWrittenWithASingleSqlCommand; // private Queue<Bar> barQueue; private int numberOfBarsToBeWrittenWithASingleSqlCommand; private int numberOfBarsEnqueuedSinceLast_NewChunkOfBarsEvent; private Queue<Bar> queue; public Queue<Bar> Queue { get { return this.queue; } } public BarQueue( int numberOfBarsToBeWrittenWithASingleSqlCommand ) : base() { this.numberOfBarsToBeWrittenWithASingleSqlCommand = numberOfBarsToBeWrittenWithASingleSqlCommand; this.numberOfBarsEnqueuedSinceLast_NewChunkOfBarsEvent = 0; this.queue = new Queue<Bar>(); } #region Enqueue private void riseNewChunkOfBarsToBeWrittenWithASingleSqlCommand() { if ( this.NewChunkOfBarsToBeWrittenWithASingleSqlCommand != null ) this.NewChunkOfBarsToBeWrittenWithASingleSqlCommand(); this.numberOfBarsEnqueuedSinceLast_NewChunkOfBarsEvent = 0; } private void enqueue_handleChunkOfBarsToBeWrittenToDatabase() { this.numberOfBarsEnqueuedSinceLast_NewChunkOfBarsEvent++; if ( this.numberOfBarsEnqueuedSinceLast_NewChunkOfBarsEvent == this.numberOfBarsToBeWrittenWithASingleSqlCommand ) this.riseNewChunkOfBarsToBeWrittenWithASingleSqlCommand(); } public void Enqueue( Bar bar ) { this.Queue.Enqueue( bar ); this.enqueue_handleChunkOfBarsToBeWrittenToDatabase(); } #endregion Enqueue } } |
|
From: Glauco S. <gla...@us...> - 2008-07-09 22:06:59
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv20324 Added Files: Bar.cs Log Message: A single Bar --- NEW FILE: Bar.cs --- /* QuantProject - Quantitative Finance Library Bar.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 single Bar /// </summary> public struct Bar { private string ticker; private string exchange; private DateTime dateTimeForOpenInUTCTime; private long interval; private double open; private double high; private double low; private double close; private long volume; public string Ticker { get { return this.ticker; } } public string Exchange { get { return this.exchange; } } public DateTime DateTimeForOpenInUTCTime { get { return this.dateTimeForOpenInUTCTime; } } public long Interval { get { return this.interval; } } public double Open { get { return this.open; } } public double High { get { return this.high; } } public double Low { get { return this.low; } } public double Close { get { return this.close; } } public long Volume { get { return this.volume; } } public Bar( string ticker , string exchange , DateTime dateTimeForOpenInUTCTime , long interval , double open , double high , double low , double close , long volume ) { this.ticker = ticker; this.exchange = exchange; this.dateTimeForOpenInUTCTime = dateTimeForOpenInUTCTime; this.interval = interval; this.open = open; this.high = high; this.low = low; this.close = close; this.volume = volume; } } } |
|
From: Glauco S. <gla...@us...> - 2008-07-09 22:05:57
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv20028 Removed Files: DatabaseUpdatedEventArgs.cs Log Message: OpenTickDownloader\DatabaseUpdatedEventArgs.cs has been moved to OpenTickDownloader\DatabaseManagement\DatabaseUpdatedEventArgs.cs --- DatabaseUpdatedEventArgs.cs DELETED --- |
|
From: Glauco S. <gla...@us...> - 2008-07-09 22:04:49
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/DatabaseManagement In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv19321 Added Files: DatabaseUpdatedEventArgs.cs Log Message: OpenTickDownloader\DatabaseUpdatedEventArgs.cs has been moved to OpenTickDownloader\DatabaseManagement\DatabaseUpdatedEventArgs.cs --- NEW FILE: DatabaseUpdatedEventArgs.cs --- /* QuantProject - Quantitative Finance Library DatabaseUpdatedEventArgs.cs Copyright (C) 2008 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; namespace QuantProject.Applications.Downloader.OpenTickDownloader { /// <summary> /// Description of DatabaseUpdatedEventArgs. /// </summary> public class DatabaseUpdatedEventArgs : EventArgs { private string ticker; private DateTime dateTimeOfLastBarUpdated; public string Ticker { get { return this.ticker; } } public DateTime DateTimeOfLastBarUpdated { get { return this.dateTimeOfLastBarUpdated; } } public DatabaseUpdatedEventArgs( string ticker , DateTime dateTimeOfLastBarUpdated ) { this.ticker = ticker; this.dateTimeOfLastBarUpdated = dateTimeOfLastBarUpdated; } } } |
|
From: Glauco S. <gla...@us...> - 2008-07-09 22:04:14
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/DatabaseManagement In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv19160/DatabaseManagement Log Message: Directory /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/DatabaseManagement added to the repository |
|
From: Glauco S. <gla...@us...> - 2008-07-09 22:03:10
|
Update of /cvsroot/quantproject/QuantDownloader In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv18740 Modified Files: QuantDownloader_SD.sln Log Message: The solution's format has been updated to a more recent version Index: QuantDownloader_SD.sln =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/QuantDownloader_SD.sln,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** QuantDownloader_SD.sln 2 Jul 2006 20:08:31 -0000 1.1 --- QuantDownloader_SD.sln 9 Jul 2008 22:03:06 -0000 1.2 *************** *** 1,4 **** ! Microsoft Visual Studio Solution File, Format Version 9.00 ! # SharpDevelop 2.0.0.1462 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuantDownloader", "Downloader\QuantDownloader_SD.csproj", "{55423900-E60B-4638-AD2A-A2A9C3F2E3B6}" EndProject --- 1,6 ---- !  ! Microsoft Visual Studio Solution File, Format Version 9.00 ! # Visual Studio 2005 ! # SharpDevelop 2.2.1.2648 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuantDownloader", "Downloader\QuantDownloader_SD.csproj", "{55423900-E60B-4638-AD2A-A2A9C3F2E3B6}" EndProject |
|
From: Glauco S. <gla...@us...> - 2008-07-09 22:01:40
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/UserForms In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv18353/Downloader/OpenTickDownloader/UserForms Modified Files: OTWebDownloader.cs Log Message: Now, more control values are passed to OTTickerDownloader Index: OTWebDownloader.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/UserForms/OTWebDownloader.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OTWebDownloader.cs 1 Jul 2008 17:41:33 -0000 1.1 --- OTWebDownloader.cs 9 Jul 2008 22:01:36 -0000 1.2 *************** *** 580,603 **** private void buttonDownloadQuotesOfSelectedTickers_Click(object sender, System.EventArgs e) { ! try{ ! OTTickerDownloader tickerDownloader = ! new OTTickerDownloader(this.TickersToDownload, this.StartingNewYorkDateTime, ! this.dateTimeOverwriteQuotesBefore.Value, ! this.checkBoxCheckingForMissingQuotes.Checked, ! this.checkBoxOverWrite.Checked, ! this.radioButtonDownloadOnlyAfterMax.Checked, ! this.txtOpenTickUser.Text, ! this.txtOpenTickPassword.Text); ! tickerDownloader.DownloadingStarted += ! new DownloadingStartedEventHandler(this.refreshForm_atDownloadedStarted); ! tickerDownloader.DatabaseUpdated += ! new DatabaseUpdatedEventHandler(this.refreshGrid); ! tickerDownloader.DownloadingCompleted += ! new DownloadingCompletedEventHandler(this.refreshForm_atDownloadedCompleted); ! this.buttonDownloadQuotesOfSelectedTickers.Enabled = false; ! this.downloadThread = new Thread( tickerDownloader.DownloadTickers ); ! this.downloadThread.Start(); ! } ! catch(Exception ex) { MessageBox.Show(ex.Message); --- 580,610 ---- private void buttonDownloadQuotesOfSelectedTickers_Click(object sender, System.EventArgs e) { ! try{ ! OTTickerDownloader tickerDownloader = ! new OTTickerDownloader( ! this.TickersToDownload, ! this.StartingNewYorkDateTime, ! Convert.ToInt32( this.fromHour.Value ) , ! Convert.ToInt32( this.fromMin.Value ) , ! Convert.ToInt32( this.fromSec.Value ) , ! Convert.ToInt32( this.timeFrameInSeconds.Value ) , ! Convert.ToInt32( this.numberOfBars.Value ) , ! this.dateTimeOverwriteQuotesBefore.Value, ! this.checkBoxCheckingForMissingQuotes.Checked, ! this.checkBoxOverWrite.Checked, ! this.radioButtonDownloadOnlyAfterMax.Checked, ! this.txtOpenTickUser.Text, ! this.txtOpenTickPassword.Text); ! tickerDownloader.DownloadingStarted += ! new DownloadingStartedEventHandler(this.refreshForm_atDownloadedStarted); ! tickerDownloader.DatabaseUpdated += ! new DatabaseUpdatedEventHandler(this.refreshGrid); ! tickerDownloader.DownloadingCompleted += ! new DownloadingCompletedEventHandler(this.refreshForm_atDownloadedCompleted); ! this.buttonDownloadQuotesOfSelectedTickers.Enabled = false; ! this.downloadThread = new Thread( tickerDownloader.DownloadTickers ); ! this.downloadThread.Start(); ! } ! catch(Exception ex) { MessageBox.Show(ex.Message); |
|
From: Glauco S. <gla...@us...> - 2008-07-09 22:00:56
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv17790/Downloader/OpenTickDownloader Modified Files: OTTickerDownloader.cs Log Message: Now real downloading objects are used Index: OTTickerDownloader.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/OTTickerDownloader.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OTTickerDownloader.cs 1 Jul 2008 17:40:22 -0000 1.1 --- OTTickerDownloader.cs 9 Jul 2008 22:00:49 -0000 1.2 *************** *** 3,7 **** OTTickerDownloader.cs ! Copyright (C) 2008 Glauco Siliprandi --- 3,7 ---- OTTickerDownloader.cs ! Copyright (C) 2008 Glauco Siliprandi *************** *** 19,23 **** 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; --- 19,23 ---- 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; *************** *** 25,28 **** --- 25,29 ---- using QuantProject.ADT; + using QuantProject.Presentation; namespace QuantProject.Applications.Downloader.OpenTickDownloader *************** *** 31,37 **** object sender , DownloadingStartedEventArgs e ); - public delegate void DatabaseUpdatedEventHandler( - object sender , DatabaseUpdatedEventArgs e ); - public delegate void DownloadingCompletedEventHandler( object sender , DownloadingCompletedEventArgs e ); --- 32,35 ---- *************** *** 40,153 **** /// Summary description for OTTickerDownloader. /// </summary> ! public class OTTickerDownloader ! { ! private string[] tickersToDownload; ! private DateTime startingNewYorkDateTime; ! private DateTime dateTimeForOverWritingQuotes;//before this ! //date quotes should be overwritten automatically ! private bool checkForMissingQuotes;//it downloads and writes ! //to db all the missing quotes ! private bool overwriteAllQuotesInDatabase;//for overWriting quotes ! //also after dateTimeForOverWritingQuotes ! private bool downloadOnlySuccessiveQuotesToTheLastQuoteInDatabase; ! //the starting date for download is just the next day to the ! //last one stored in database. If no quote is stored, ! //the starting date for download is startingNewYorkDateTime ! private string openTickUser; ! private string openTickPassword; ! ! private void otTickerDownloader_checkParameters( string[] tickersToDownload, ! DateTime startingNewYorkDateTime, ! DateTime dateTimeForOverWritingQuotes, ! bool checkForMissingQuotes, ! bool overwriteAllQuotesInDatabase, ! bool downloadOnlySuccessiveQuotesToTheLastQuoteInDatabase, ! string openTickUser, ! string openTickPassword ) ! { ! if(tickersToDownload == null) ! throw new Exception("No ticker has been indicated for download!"); ! if( !downloadOnlySuccessiveQuotesToTheLastQuoteInDatabase && ! dateTimeForOverWritingQuotes.CompareTo(startingNewYorkDateTime) < 0 ) ! //the user has not requested only quotes successive to the last ! //stored in the DB and date time for overwriting quotes precedes ! //the date time for the first quote to download ! throw new Exception("Date Time for OverWriting Quotes can't precede " + ! "starting Date for download!"); ! if( checkForMissingQuotes && downloadOnlySuccessiveQuotesToTheLastQuoteInDatabase ) ! //the two options have to be different in value or both false ! throw new Exception("Downloading only quotes successive to the last quote in the DB " + ! "implies that missing quotes will not be checked" ); ! if( ( openTickUser == null || openTickUser == "" ) || ! ( openTickPassword == null || openTickPassword == "" ) ) ! throw new Exception("Type in user and password for logging to OpenTick" ); ! } ! ! public OTTickerDownloader( string[] tickersToDownload, ! DateTime startingNewYorkDateTime, ! DateTime dateTimeForOverWritingQuotes, ! bool checkForMissingQuotes, ! bool overwriteAllQuotesInDatabase, ! bool downloadOnlySuccessiveQuotesToTheLastQuoteInDatabase, ! string openTickUser, ! string openTickPassword) ! { ! this.otTickerDownloader_checkParameters(tickersToDownload, ! startingNewYorkDateTime, ! dateTimeForOverWritingQuotes, ! checkForMissingQuotes, ! overwriteAllQuotesInDatabase, ! downloadOnlySuccessiveQuotesToTheLastQuoteInDatabase, ! openTickUser, ! openTickPassword); ! this.tickersToDownload = tickersToDownload; ! this.startingNewYorkDateTime = startingNewYorkDateTime; ! this.dateTimeForOverWritingQuotes = dateTimeForOverWritingQuotes; ! this.checkForMissingQuotes = checkForMissingQuotes; ! this.overwriteAllQuotesInDatabase = overwriteAllQuotesInDatabase; ! this.downloadOnlySuccessiveQuotesToTheLastQuoteInDatabase = downloadOnlySuccessiveQuotesToTheLastQuoteInDatabase; ! this.openTickUser = openTickUser; ! this.openTickPassword = openTickPassword; ! } ! public event DownloadingStartedEventHandler DownloadingStarted; ! public event DatabaseUpdatedEventHandler DatabaseUpdated; ! public event DownloadingCompletedEventHandler DownloadingCompleted; ! ! private void downloadTickers_dummyDatabaseUpdatedEventRiser() ! { ! DateTime dateTimeOfLastBarUpdated = DateTime.Now; ! foreach(string ticker in this.tickersToDownload) ! { ! Thread.Sleep(500); ! DatabaseUpdatedEventArgs databaseUpdatedEventArgs = ! new DatabaseUpdatedEventArgs(ticker, dateTimeOfLastBarUpdated); ! if(this.DatabaseUpdated != null) ! this.DatabaseUpdated(this, databaseUpdatedEventArgs); ! } ! } ! ! private void downloadTickers_dummyDownloadingStartedEventRiser() ! { ! DownloadingStartedEventArgs eventArgs = ! new DownloadingStartedEventArgs(DateTime.Now); ! if(this.DownloadingStarted != null) ! this.DownloadingStarted( this, eventArgs ); ! } ! ! private void downloadTickers_dummyDownloadingCompletedEventRiser() ! { ! DownloadingCompletedEventArgs eventArgs = ! new DownloadingCompletedEventArgs(DateTime.Now); ! if(this.DownloadingCompleted != null) ! this.DownloadingCompleted( this, eventArgs ); ! } ! ! public void DownloadTickers() ! { ! this.downloadTickers_dummyDownloadingStartedEventRiser(); ! this.downloadTickers_dummyDatabaseUpdatedEventRiser(); ! this.downloadTickers_dummyDownloadingCompletedEventRiser(); ! } ! } } --- 38,291 ---- /// Summary description for OTTickerDownloader. /// </summary> ! public class OTTickerDownloader ! { ! private string[] tickersToDownload; ! private DateTime firstDate; ! /// <summary> ! /// time (date doesn't matter for this member) for the first ! /// bar to be downloaded, each day ! /// </summary> ! private DateTime firstBarOpenTimeInNewYorkTimeZone; ! /// <summary> ! /// number of seconds in each bar ! /// </summary> ! private int barInterval; ! /// <summary> ! /// number of bars to be downloaded for each day ! /// </summary> ! private int numberOfDailyBars; ! private DateTime dateTimeForOverWritingQuotes;//before this ! //date quotes should be overwritten automatically ! private bool checkForMissingQuotes;//it downloads and writes ! //to db all the missing quotes ! private bool overwriteAllQuotesInDatabase;//for overWriting quotes ! //also after dateTimeForOverWritingQuotes ! private bool downloadOnlySuccessiveQuotesToTheLastQuoteInDatabase; ! //the starting date for download is just the next day to the ! //last one stored in database. If no quote is stored, ! //the starting date for download is startingNewYorkDateTime ! private string openTickUser; ! private string openTickPassword; ! private IExchangeSelector exchangeSelector; ! private IBarsSelector barsSelector; ! private BarsDownloader barsDownloader; ! private MessageManager messageManager; ! ! private Thread downloadBarsThread; ! ! private void otTickerDownloader_checkParameters( string[] tickersToDownload, ! DateTime startingNewYorkDateTime, ! DateTime dateTimeForOverWritingQuotes, ! bool checkForMissingQuotes, ! bool overwriteAllQuotesInDatabase, ! bool downloadOnlySuccessiveQuotesToTheLastQuoteInDatabase, ! string openTickUser, ! string openTickPassword ) ! { ! if(tickersToDownload == null) ! throw new Exception("No ticker has been indicated for download!"); ! if( !downloadOnlySuccessiveQuotesToTheLastQuoteInDatabase && ! dateTimeForOverWritingQuotes.CompareTo(startingNewYorkDateTime) < 0 ) ! //the user has not requested only quotes successive to the last ! //stored in the DB and date time for overwriting quotes precedes ! //the date time for the first quote to download ! throw new Exception("Date Time for OverWriting Quotes can't precede " + ! "starting Date for download!"); ! if( checkForMissingQuotes && downloadOnlySuccessiveQuotesToTheLastQuoteInDatabase ) ! //the two options have to be different in value or both false ! throw new Exception("Downloading only quotes successive to the last quote in the DB " + ! "implies that missing quotes will not be checked" ); ! if( ( openTickUser == null || openTickUser == "" ) || ! ( openTickPassword == null || openTickPassword == "" ) ) ! throw new Exception("Type in user and password for logging to OpenTick" ); ! } ! ! public OTTickerDownloader( ! string[] tickersToDownload, ! DateTime firstDate, ! int fromHour , ! int fromMinute , ! int fromSecond , ! int barInterval , ! int numberOfDailyBars , ! DateTime dateTimeForOverWritingQuotes, ! bool checkForMissingQuotes, ! bool overwriteAllQuotesInDatabase, ! bool downloadOnlySuccessiveQuotesToTheLastQuoteInDatabase, ! string openTickUser, ! string openTickPassword) ! { ! this.otTickerDownloader_checkParameters(tickersToDownload, ! firstDate, ! dateTimeForOverWritingQuotes, ! checkForMissingQuotes, ! overwriteAllQuotesInDatabase, ! downloadOnlySuccessiveQuotesToTheLastQuoteInDatabase, ! openTickUser, ! openTickPassword); ! this.tickersToDownload = tickersToDownload; ! this.firstDate = firstDate; ! this.firstBarOpenTimeInNewYorkTimeZone = ! new DateTime( ! 1 , 1 , 1 , fromHour , fromMinute , fromSecond ); ! this.barInterval = barInterval; ! this.numberOfDailyBars = numberOfDailyBars; ! this.dateTimeForOverWritingQuotes = dateTimeForOverWritingQuotes; ! this.checkForMissingQuotes = checkForMissingQuotes; ! this.overwriteAllQuotesInDatabase = overwriteAllQuotesInDatabase; ! this.downloadOnlySuccessiveQuotesToTheLastQuoteInDatabase = ! downloadOnlySuccessiveQuotesToTheLastQuoteInDatabase; ! this.openTickUser = openTickUser; ! this.openTickPassword = openTickPassword; ! } ! ! public event DownloadingStartedEventHandler DownloadingStarted; ! public event DatabaseUpdatedEventHandler DatabaseUpdated; ! public event DownloadingCompletedEventHandler DownloadingCompleted; ! ! #region DownloadTickers ! private void downloadTickers_dummyDatabaseUpdatedEventRiser() ! { ! DateTime dateTimeOfLastBarUpdated = DateTime.Now; ! foreach(string ticker in this.tickersToDownload) ! { ! Thread.Sleep(500); ! DatabaseUpdatedEventArgs databaseUpdatedEventArgs = ! new DatabaseUpdatedEventArgs(ticker, dateTimeOfLastBarUpdated); ! if(this.DatabaseUpdated != null) ! this.DatabaseUpdated(this, databaseUpdatedEventArgs); ! } ! } ! ! private void downloadTickers_dummyDownloadingStartedEventRiser() ! { ! DownloadingStartedEventArgs eventArgs = ! new DownloadingStartedEventArgs(DateTime.Now); ! if(this.DownloadingStarted != null) ! this.DownloadingStarted( this, eventArgs ); ! } ! ! private void downloadTickers_dummyDownloadingCompletedEventRiser() ! { ! DownloadingCompletedEventArgs eventArgs = ! new DownloadingCompletedEventArgs(DateTime.Now); ! if(this.DownloadingCompleted != null) ! this.DownloadingCompleted( this, eventArgs ); ! } ! ! #region downloadTickersActually ! private DateTime setBarsSelector_getDate( DateTime dateTime ) ! { ! DateTime date = new DateTime( ! dateTime.Year , dateTime.Month , dateTime.Day ); ! return date; ! } ! 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() ! { ! this.exchangeSelector = ! new MostLiquidExchangeSelector(); ! } ! #region setBarsDownloaderAndRunIt ! ! #region setBarsDownloader ! ! #region setBarsDownloader_setEventHandlers ! private void databaseUpdatedEventHandler( ! object sender , DatabaseUpdatedEventArgs eventArgs ) ! { ! if ( this.DatabaseUpdated != null ) ! this.DatabaseUpdated( this , eventArgs ); ! } ! private void setBarsDownloader_setEventHandlers() ! { ! this.barsDownloader.DatabaseUpdated += ! new DatabaseUpdatedEventHandler( ! this.databaseUpdatedEventHandler ); ! } ! #endregion setBarsDownloader_setEventHandlers ! ! private void setBarsDownloader() ! { ! // DailyBarsSelector barsSelector = ! // new DailyBarsSelector( ! // new string[]{ "GE" , "MSFT" } , ! // new DateTime( 2002 , 3 , 1 ) , ! // new DateTime( 2002 , 4 , 30 ) , ! // 60 , ! // new DateTime( 1 , 1 , 1 , 9 , 29 , 0 ) , ! // 3 ); ! this.barsDownloader = ! new BarsDownloader( ! this.barsSelector , ! this.exchangeSelector , ! this.openTickUser , ! this.openTickPassword ); ! this.setBarsDownloader_setEventHandlers(); ! // this.barsDownloader.NewOHLCRequest += ! // new NewOHLCRequestEventHandler ( ! // this.newOHLCRequestEventHandler ); ! } ! #endregion setBarsDownloader ! ! #region setMessageManager ! private string getLogFileName() ! { ! string logFileName = ! @"C:\QuantProject\OpenTickDownloader\textFilesForLoggingNotification\textFileForLoggingNotification"; ! logFileName = logFileName + "_" + ! ExtendedDateTime.GetCompleteShortDescriptionForFileName( ! DateTime.Now ) + ".txt"; ! return logFileName; ! } ! private void setMessageManager() ! { ! this.messageManager = ! new MessageManager( this.getLogFileName() ); ! this.messageManager.Monitor( ! this.barsDownloader ); ! } ! #endregion setMessageManager ! ! private void downloadBarsInANewThread() ! { ! this.downloadBarsThread = new Thread( ! new ThreadStart( this.barsDownloader.DownloadBars ) ); ! this.downloadBarsThread.Start(); ! } ! private void setBarsDownloaderAndRunIt() ! { ! this.setBarsDownloader(); ! this.setMessageManager(); ! this.downloadBarsInANewThread(); ! } ! #endregion setBarsDownloaderAndRunIt ! private void downloadTickersActually() ! { ! this.setBarsSelector(); ! this.setExchangeSelector(); ! this.setBarsDownloaderAndRunIt(); ! } ! #endregion downloadTickersActually ! ! public void DownloadTickers() ! { ! this.downloadTickersActually(); ! // this.downloadTickers_dummyDownloadingStartedEventRiser(); ! // this.downloadTickers_dummyDatabaseUpdatedEventRiser(); ! // this.downloadTickers_dummyDownloadingCompletedEventRiser(); ! } ! #endregion DownloadTickers ! } } |
|
From: Glauco S. <gla...@us...> - 2008-07-09 21:58:10
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16446/Downloader Modified Files: app.config Log Message: Now the 2.0 framework is targeted Index: app.config =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/app.config,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** app.config 7 Jul 2004 20:07:21 -0000 1.1 --- app.config 9 Jul 2008 21:58:02 -0000 1.2 *************** *** 2,6 **** <configuration> <startup> ! <supportedRuntime version="v1.1.4322" /> </startup> ! </configuration> \ No newline at end of file --- 2,6 ---- <configuration> <startup> ! <supportedRuntime version="v2.0.50727" /> </startup> ! </configuration> |
|
From: Marco M. <mi...@us...> - 2008-07-01 22:22:36
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv17170/Downloader Removed Files: QuantDownloader.prjx QuantDownloader_SD.prjx Log Message: Deleted old SD project's files --- QuantDownloader.prjx DELETED --- --- QuantDownloader_SD.prjx DELETED --- |
|
From: Marco M. <mi...@us...> - 2008-07-01 22:22:36
|
Update of /cvsroot/quantproject/QuantDownloader In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv17170 Removed Files: QuantDownloader.cmbx QuantDownloader_SD.cmbx Log Message: Deleted old SD project's files --- QuantDownloader.cmbx DELETED --- --- QuantDownloader_SD.cmbx DELETED --- |
|
From: Marco M. <mi...@us...> - 2008-07-01 17:46:36
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/TickerSelectors In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv12722/TickerSelectors Modified Files: TickerViewerMenu.cs Log Message: Added the item "Download from OT" to the context menu for ITickerSelectorForm Index: TickerViewerMenu.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/TickerSelectors/TickerViewerMenu.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TickerViewerMenu.cs 1 Dec 2004 22:54:01 -0000 1.7 --- TickerViewerMenu.cs 1 Jul 2008 17:46:33 -0000 1.8 *************** *** 24,30 **** --- 24,32 ---- using System.Data; using System.Windows.Forms; + using QuantProject.DataAccess.Tables; using QuantProject.Data.DataTables; using QuantProject.Data.Selectors; + using QuantProject.Applications.Downloader.OpenTickDownloader.UserForms; *************** *** 41,45 **** protected Form parentForm; private MenuItem menuItemSelectAll = new MenuItem("&Select all items"); ! private MenuItem menuItemDownload = new MenuItem("&Download selection"); private MenuItem menuItemValidate = new MenuItem("&Validate selection"); private MenuItem menuItemCopy = new MenuItem("&Copy selection"); --- 43,48 ---- protected Form parentForm; private MenuItem menuItemSelectAll = new MenuItem("&Select all items"); ! private MenuItem menuItemDownloadFromYahoo = new MenuItem("&Download selection - Yahoo"); ! private MenuItem menuItemDownloadFromOpenTick = new MenuItem("&Download selection - OpenTick"); private MenuItem menuItemValidate = new MenuItem("&Validate selection"); private MenuItem menuItemCopy = new MenuItem("&Copy selection"); *************** *** 54,58 **** //this.parentForm.ContextMenu = this; this.menuItemSelectAll.Click += new System.EventHandler(this.selectAllTickers); ! this.menuItemDownload.Click += new System.EventHandler(this.downloadSelectedTickers); this.menuItemValidate.Click += new System.EventHandler(this.validateSelectedTickers); this.menuItemCopy.Click += new System.EventHandler(this.copySelectedTickers); --- 57,62 ---- //this.parentForm.ContextMenu = this; this.menuItemSelectAll.Click += new System.EventHandler(this.selectAllTickers); ! this.menuItemDownloadFromYahoo.Click += new System.EventHandler(this.downloadSelectedTickersFromYahoo); ! this.menuItemDownloadFromOpenTick.Click += new System.EventHandler(this.downloadSelectedTickersFromOpenTick); this.menuItemValidate.Click += new System.EventHandler(this.validateSelectedTickers); this.menuItemCopy.Click += new System.EventHandler(this.copySelectedTickers); *************** *** 62,66 **** this.MenuItems.Add(this.menuItemSelectAll); ! this.MenuItems.Add(this.menuItemDownload); this.MenuItems.Add(this.menuItemValidate); this.MenuItems.Add(this.menuItemCopy); --- 66,71 ---- this.MenuItems.Add(this.menuItemSelectAll); ! this.MenuItems.Add(this.menuItemDownloadFromYahoo); ! this.MenuItems.Add(this.menuItemDownloadFromOpenTick); this.MenuItems.Add(this.menuItemValidate); this.MenuItems.Add(this.menuItemCopy); *************** *** 82,86 **** } ! private void downloadSelectedTickers(object sender, System.EventArgs e) { ITickerSelector iTickerSelector = (ITickerSelector)this.parentForm; --- 87,91 ---- } ! private void downloadSelectedTickersFromYahoo(object sender, System.EventArgs e) { ITickerSelector iTickerSelector = (ITickerSelector)this.parentForm; *************** *** 95,98 **** --- 100,116 ---- webDownloader.Show(); } + private void downloadSelectedTickersFromOpenTick(object sender, System.EventArgs e) + { + ITickerSelector iTickerSelector = (ITickerSelector)this.parentForm; + DataTable tableOfSelectedTickers = iTickerSelector.GetTableOfSelectedTickers(); + + if(tableOfSelectedTickers.Rows.Count == 0) + { + this.displayMessageNoTickersSelected(); + return; + } + OTWebDownloader webDownloader = new OTWebDownloader(tableOfSelectedTickers); + webDownloader.Show(); + } private void validateSelectedTickers(object sender, System.EventArgs e) { |
|
From: Marco M. <mi...@us...> - 2008-07-01 17:45:19
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv12279 Modified Files: Main.cs Log Message: The QuantDownloader application now can't be closed if there is a downloading thread in progress Index: Main.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/Main.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Main.cs 1 Dec 2004 22:54:01 -0000 1.9 --- Main.cs 1 Jul 2008 17:45:13 -0000 1.10 *************** *** 6,9 **** --- 6,10 ---- using System.Windows.Forms; using QuantProject.Applications.Downloader.TickerSelectors; + using QuantProject.Applications.Downloader.OpenTickDownloader.UserForms; using QuantProject.Data.Selectors; *************** *** 42,46 **** // InitializeComponent(); ! // // TODO: Add any constructor code after InitializeComponent call --- 43,47 ---- // InitializeComponent(); ! this.Closing += new CancelEventHandler( this.Principale_Closing ); // // TODO: Add any constructor code after InitializeComponent call *************** *** 244,247 **** --- 245,272 ---- } + private bool isSomeDownloadingInProgress() + { + bool returnValue = false; + foreach(Form downloader in Application.OpenForms) + if(downloader is OTWebDownloader) + if( ((OTWebDownloader)downloader).DownloadInProgress ) + returnValue = true; + + return returnValue; + } + + private void Principale_Closing(Object sender, CancelEventArgs e) + { + if ( this.isSomeDownloadingInProgress() ) + { + e.Cancel = true; + MessageBox.Show("You can't close the application if some downloading is still in progress!"); + } + else + { + e.Cancel = false; + } + } + private void menuItem14_Click(object sender, System.EventArgs e) { |
|
From: Marco M. <mi...@us...> - 2008-07-01 17:43:09
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv11094 Modified Files: Downloader.csproj Downloader.csproj.user QuantDownloader_SD.csproj Log Message: Added OTWebDownloader (form that will use the OTTickerDownloader) Index: Downloader.csproj.user =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/Downloader.csproj.user,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Downloader.csproj.user 7 Jul 2004 20:10:29 -0000 1.5 --- Downloader.csproj.user 1 Jul 2008 17:43:03 -0000 1.6 *************** *** 2,6 **** <CSHARP> <Build> ! <Settings ReferencePath = "C:\Documents and Settings\Glauco\Desktop\QuantProject\QuantDownloader\Downloader\bin\Debug\;C:\Documents and Settings\Glauco\My Documents\nostri\GLAUCO\bin\;c:\windows\assembly\gac\crystaldecisions.windows.forms\9.1.3300.0__692fbea5521e1304\;C:\Documents and Settings\Glauco\Desktop\QuantProject\lib\" > <Config Name = "Debug" --- 2,6 ---- <CSHARP> <Build> ! <Settings ReferencePath = "C:\Documents and Settings\Glauco\Desktop\QuantProject\QuantDownloader\Downloader\bin\Debug\;C:\Documents and Settings\Glauco\My Documents\nostri\GLAUCO\bin\;c:\windows\assembly\gac\crystaldecisions.windows.forms\9.1.3300.0__692fbea5521e1304\;C:\Documents and Settings\Glauco\Desktop\QuantProject\lib\;C:\Quant\QuantDownloader\Downloader\bin\Debug\;C:\Quant\" > <Config Name = "Debug" Index: QuantDownloader_SD.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/QuantDownloader_SD.csproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** QuantDownloader_SD.csproj 7 Jun 2008 16:54:58 -0000 1.2 --- QuantDownloader_SD.csproj 1 Jul 2008 17:43:04 -0000 1.3 *************** *** 31,34 **** --- 31,38 ---- </PropertyGroup> <ItemGroup> + <Reference Include="OTFeed_NET"> + <HintPath>..\..\OTFeed_NET\OTFeed_NET.dll</HintPath> + <SpecificVersion>False</SpecificVersion> + </Reference> <Reference Include="System" /> <Reference Include="System.Data" /> *************** *** 46,49 **** --- 50,58 ---- <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" /> <Compile Include="TestDownloadedData.cs" /> *************** *** 78,81 **** --- 87,99 ---- <None Include="app.config" /> <None Include="App.ico" /> + <EmbeddedResource Include="OpenTickDownloader\UserForms\OTWebDownloader.resx"> + <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> *************** *** 100,103 **** --- 118,123 ---- <Name>b5_Presentation</Name> </ProjectReference> + <Folder Include="OpenTickDownloader" /> + <Folder Include="OpenTickDownloader\UserForms" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> Index: Downloader.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/Downloader.csproj,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** Downloader.csproj 8 Sep 2006 13:59:22 -0000 1.31 --- Downloader.csproj 1 Jul 2008 17:43:03 -0000 1.32 *************** *** 131,135 **** Name = "NPlot" AssemblyName = "NPlot" ! HintPath = "bin\Debug\NPlot.dll" /> </References> --- 131,135 ---- Name = "NPlot" AssemblyName = "NPlot" ! HintPath = "..\..\lib\NPlot.dll" /> </References> |
|
From: Marco M. <mi...@us...> - 2008-07-01 17:41:37
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/UserForms In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv10572/UserForms Added Files: OTWebDownloader.cs Log Message: Added the form that will use the OTTickerDownloader --- NEW FILE: OTWebDownloader.cs --- /* QuantDownloader - Quantitative Finance Library OTWebDownloader.cs Copyright (C) 2008 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.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Data.OleDb; using System.Net; using System.IO; using System.Threading; using QuantProject.DataAccess; using QuantProject.DataAccess.Tables; using QuantProject.Applications.Downloader.TickerSelectors; using QuantProject.Data.DataTables; using QuantProject.Data.Selectors; namespace QuantProject.Applications.Downloader.OpenTickDownloader.UserForms { /// <summary> /// Form to be used for downloading quotes from OpenTick provider /// </summary> public class OTWebDownloader : System.Windows.Forms.Form, ITickerSelector { public System.Windows.Forms.DataGrid dataGrid1; public DataSet1 DsTickerCurrentlyDownloaded = new DataSet1(); private System.Windows.Forms.Button buttonDownloadQuotesOfSelectedTickers; private DataTable tableOfSelectedTickers; private System.Windows.Forms.Label labelStartingDateTime; private System.Windows.Forms.DateTimePicker dateTimePickerStartingDate; private System.Windows.Forms.RadioButton radioButtonAllAvailableUntilNow; private System.Windows.Forms.GroupBox groupBoxWebDownloaderOptions; private System.Windows.Forms.RadioButton radioButtonDownloadOnlyAfterMax; private Thread downloadThread; private System.Windows.Forms.ToolTip toolTip1; private System.ComponentModel.IContainer components; private bool downloadingInProgress; private string textForStartingDownloadingTimeLabel; private string textForEndingDownloadingTimeLabel; public OTWebDownloader(DataTable tableOfSelectedTickers) { // // Required for Windows Form Designer support // InitializeComponent(); this.commonInitialization(); // //this.Text = "Download quotes from OpenTick for the selected tickers"; this.tableOfSelectedTickers = tableOfSelectedTickers; // } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } /// <summary> /// common initialization of the controls of the form /// </summary> private void commonInitialization() { this.dateTimePickerStartingDate.Value = QuantProject.ADT.ConstantsProvider.InitialDateTimeForDownload; this.radioButtonAllAvailableUntilNow.Checked = true; this.radioButtonDownloadOnlyAfterMax.Checked = false; this.dataGrid1.ContextMenu = new TickerViewerMenu(this); this.Closing += new CancelEventHandler(this.OTWebDownloader_Closing); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.dataGrid1 = new System.Windows.Forms.DataGrid(); this.buttonDownloadQuotesOfSelectedTickers = new System.Windows.Forms.Button(); this.dateTimePickerStartingDate = new System.Windows.Forms.DateTimePicker(); this.labelStartingDateTime = new System.Windows.Forms.Label(); this.radioButtonAllAvailableUntilNow = new System.Windows.Forms.RadioButton(); this.groupBoxWebDownloaderOptions = new System.Windows.Forms.GroupBox(); this.radioButtonDownloadOnlyAfterMax = new System.Windows.Forms.RadioButton(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.label1 = new System.Windows.Forms.Label(); this.dateTimeOverwriteQuotesBefore = new System.Windows.Forms.DateTimePicker(); this.timeFrameInSeconds = new System.Windows.Forms.NumericUpDown(); this.label2 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.fromHour = new System.Windows.Forms.NumericUpDown(); this.label4 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); this.fromMin = new System.Windows.Forms.NumericUpDown(); this.label6 = new System.Windows.Forms.Label(); this.numberOfBars = new System.Windows.Forms.NumericUpDown(); this.fromSec = new System.Windows.Forms.NumericUpDown(); this.label7 = new System.Windows.Forms.Label(); this.txtOpenTickUser = new System.Windows.Forms.TextBox(); this.label8 = new System.Windows.Forms.Label(); this.label9 = new System.Windows.Forms.Label(); this.txtOpenTickPassword = new System.Windows.Forms.TextBox(); this.checkBoxCheckingForMissingQuotes = new System.Windows.Forms.CheckBox(); this.checkBoxOverWrite = new System.Windows.Forms.CheckBox(); this.label10 = new System.Windows.Forms.Label(); this.endingDownloadingTimeLabel = new System.Windows.Forms.Label(); this.startingDownloadingTimeLabel = new System.Windows.Forms.Label(); this.timer1 = new System.Windows.Forms.Timer(this.components); this.signallingLabel = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit(); this.groupBoxWebDownloaderOptions.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.timeFrameInSeconds)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.fromHour)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.fromMin)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numberOfBars)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.fromSec)).BeginInit(); this.SuspendLayout(); // // dataGrid1 // this.dataGrid1.DataMember = ""; 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; // // buttonDownloadQuotesOfSelectedTickers // this.buttonDownloadQuotesOfSelectedTickers.Location = new System.Drawing.Point(6, 408); this.buttonDownloadQuotesOfSelectedTickers.Name = "buttonDownloadQuotesOfSelectedTickers"; this.buttonDownloadQuotesOfSelectedTickers.Size = new System.Drawing.Size(72, 32); this.buttonDownloadQuotesOfSelectedTickers.TabIndex = 2; this.buttonDownloadQuotesOfSelectedTickers.Text = "Download"; this.buttonDownloadQuotesOfSelectedTickers.Click += new System.EventHandler(this.buttonDownloadQuotesOfSelectedTickers_Click); // // dateTimePickerStartingDate // 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); // // labelStartingDateTime // this.labelStartingDateTime.Location = new System.Drawing.Point(8, 49); this.labelStartingDateTime.Name = "labelStartingDateTime"; this.labelStartingDateTime.Size = new System.Drawing.Size(80, 23); this.labelStartingDateTime.TabIndex = 8; this.labelStartingDateTime.Text = "Starting date"; // // radioButtonAllAvailableUntilNow // this.radioButtonAllAvailableUntilNow.Checked = true; this.radioButtonAllAvailableUntilNow.Location = new System.Drawing.Point(6, 19); this.radioButtonAllAvailableUntilNow.Name = "radioButtonAllAvailableUntilNow"; this.radioButtonAllAvailableUntilNow.Size = new System.Drawing.Size(272, 24); this.radioButtonAllAvailableUntilNow.TabIndex = 10; this.radioButtonAllAvailableUntilNow.TabStop = true; this.radioButtonAllAvailableUntilNow.Text = "All available quotes until now, since starting date"; // // groupBoxWebDownloaderOptions // this.groupBoxWebDownloaderOptions.Controls.Add(this.radioButtonDownloadOnlyAfterMax); this.groupBoxWebDownloaderOptions.Controls.Add(this.radioButtonAllAvailableUntilNow); this.groupBoxWebDownloaderOptions.Controls.Add(this.dateTimePickerStartingDate); this.groupBoxWebDownloaderOptions.Controls.Add(this.labelStartingDateTime); 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; this.groupBoxWebDownloaderOptions.Text = "Web Downloader options (source: OpenTick)"; // // radioButtonDownloadOnlyAfterMax // this.radioButtonDownloadOnlyAfterMax.Location = new System.Drawing.Point(8, 75); this.radioButtonDownloadOnlyAfterMax.Name = "radioButtonDownloadOnlyAfterMax"; this.radioButtonDownloadOnlyAfterMax.Size = new System.Drawing.Size(307, 55); this.radioButtonDownloadOnlyAfterMax.TabIndex = 3; this.radioButtonDownloadOnlyAfterMax.Text = "Download only quotes after last available quote in the DB (in case no quotes are " + "available in the local DB, quotes are downloaded from starting date)"; // // label1 // this.label1.Location = new System.Drawing.Point(10, 243); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(80, 41); this.label1.TabIndex = 16; this.label1.Text = "OverWrite quotes before"; // // dateTimeOverwriteQuotesBefore // 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); // // timeFrameInSeconds // this.timeFrameInSeconds.Increment = new decimal(new int[] { 60, 0, 0, 0}); this.timeFrameInSeconds.Location = new System.Drawing.Point(114, 56); this.timeFrameInSeconds.Maximum = new decimal(new int[] { 3600, 0, 0, 0}); this.timeFrameInSeconds.Minimum = new decimal(new int[] { 60, 0, 0, 0}); this.timeFrameInSeconds.Name = "timeFrameInSeconds"; this.timeFrameInSeconds.Size = new System.Drawing.Size(49, 20); this.timeFrameInSeconds.TabIndex = 17; this.timeFrameInSeconds.Value = new decimal(new int[] { 60, 0, 0, 0}); // // label2 // this.label2.Location = new System.Drawing.Point(6, 58); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(102, 20); this.label2.TabIndex = 18; this.label2.Text = "Time Frame (sec.)"; // // label3 // this.label3.Location = new System.Drawing.Point(6, 26); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(46, 23); this.label3.TabIndex = 19; this.label3.Text = "From:"; // // fromHour // this.fromHour.Location = new System.Drawing.Point(72, 25); this.fromHour.Maximum = new decimal(new int[] { 16, 0, 0, 0}); this.fromHour.Minimum = new decimal(new int[] { 9, 0, 0, 0}); this.fromHour.Name = "fromHour"; this.fromHour.Size = new System.Drawing.Size(42, 20); this.fromHour.TabIndex = 20; this.fromHour.Value = new decimal(new int[] { 9, 0, 0, 0}); // // label4 // this.label4.Location = new System.Drawing.Point(44, 27); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(22, 13); this.label4.TabIndex = 21; this.label4.Text = "H."; // // label5 // this.label5.Location = new System.Drawing.Point(120, 27); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(30, 13); this.label5.TabIndex = 23; this.label5.Text = "Min."; // // fromMin // this.fromMin.Location = new System.Drawing.Point(156, 25); this.fromMin.Maximum = new decimal(new int[] { 59, 0, 0, 0}); this.fromMin.Minimum = new decimal(new int[] { 1, 0, 0, 0}); this.fromMin.Name = "fromMin"; this.fromMin.Size = new System.Drawing.Size(45, 20); this.fromMin.TabIndex = 22; this.fromMin.Value = new decimal(new int[] { 30, 0, 0, 0}); // // label6 // this.label6.Location = new System.Drawing.Point(169, 58); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(68, 20); this.label6.TabIndex = 25; this.label6.Text = "n° of bars"; // // numberOfBars // this.numberOfBars.Location = new System.Drawing.Point(243, 56); this.numberOfBars.Maximum = new decimal(new int[] { 10000, 0, 0, 0}); this.numberOfBars.Minimum = new decimal(new int[] { 1, 0, 0, 0}); this.numberOfBars.Name = "numberOfBars"; this.numberOfBars.Size = new System.Drawing.Size(38, 20); this.numberOfBars.TabIndex = 24; this.numberOfBars.Value = new decimal(new int[] { 1, 0, 0, 0}); // // fromSec // this.fromSec.Location = new System.Drawing.Point(257, 24); this.fromSec.Maximum = new decimal(new int[] { 59, 0, 0, 0}); this.fromSec.Name = "fromSec"; this.fromSec.Size = new System.Drawing.Size(45, 20); this.fromSec.TabIndex = 26; // // label7 // this.label7.Location = new System.Drawing.Point(219, 26); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(30, 13); this.label7.TabIndex = 27; this.label7.Text = "Sec."; // // txtOpenTickUser // this.txtOpenTickUser.Location = new System.Drawing.Point(63, 361); this.txtOpenTickUser.Name = "txtOpenTickUser"; this.txtOpenTickUser.Size = new System.Drawing.Size(78, 20); this.txtOpenTickUser.TabIndex = 28; // // label8 // this.label8.Location = new System.Drawing.Point(6, 361); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(37, 23); this.label8.TabIndex = 29; this.label8.Text = "user"; // // label9 // this.label9.Location = new System.Drawing.Point(169, 361); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(58, 23); this.label9.TabIndex = 31; this.label9.Text = "password"; // // txtOpenTickPassword // this.txtOpenTickPassword.Location = new System.Drawing.Point(247, 361); this.txtOpenTickPassword.Name = "txtOpenTickPassword"; this.txtOpenTickPassword.Size = new System.Drawing.Size(78, 20); this.txtOpenTickPassword.TabIndex = 30; this.txtOpenTickPassword.UseSystemPasswordChar = true; // // checkBoxCheckingForMissingQuotes // this.checkBoxCheckingForMissingQuotes.Location = new System.Drawing.Point(12, 331); this.checkBoxCheckingForMissingQuotes.Name = "checkBoxCheckingForMissingQuotes"; this.checkBoxCheckingForMissingQuotes.Size = new System.Drawing.Size(315, 24); this.checkBoxCheckingForMissingQuotes.TabIndex = 32; this.checkBoxCheckingForMissingQuotes.Text = "Check for missing quotes"; this.checkBoxCheckingForMissingQuotes.UseVisualStyleBackColor = true; // // checkBoxOverWrite // this.checkBoxOverWrite.Location = new System.Drawing.Point(12, 287); this.checkBoxOverWrite.Name = "checkBoxOverWrite"; this.checkBoxOverWrite.Size = new System.Drawing.Size(246, 38); this.checkBoxOverWrite.TabIndex = 33; this.checkBoxOverWrite.Text = "OverWrite all quotes, also after the given date"; this.checkBoxOverWrite.UseVisualStyleBackColor = true; // // label10 // this.label10.Location = new System.Drawing.Point(93, -1); this.label10.Name = "label10"; this.label10.Size = new System.Drawing.Size(131, 23); this.label10.TabIndex = 34; this.label10.Text = "New York Local Time"; // // endingDownloadingTimeLabel // this.endingDownloadingTimeLabel.Location = new System.Drawing.Point(84, 436); this.endingDownloadingTimeLabel.Name = "endingDownloadingTimeLabel"; this.endingDownloadingTimeLabel.Size = new System.Drawing.Size(262, 23); this.endingDownloadingTimeLabel.TabIndex = 36; this.endingDownloadingTimeLabel.Text = "."; // // startingDownloadingTimeLabel // this.startingDownloadingTimeLabel.Location = new System.Drawing.Point(84, 392); this.startingDownloadingTimeLabel.Name = "startingDownloadingTimeLabel"; this.startingDownloadingTimeLabel.Size = new System.Drawing.Size(262, 23); this.startingDownloadingTimeLabel.TabIndex = 37; this.startingDownloadingTimeLabel.Text = "."; // // timer1 // this.timer1.Enabled = true; this.timer1.Interval = 1000; this.timer1.Tick += new System.EventHandler(this.Timer1Tick); // // signallingLabel // this.signallingLabel.Location = new System.Drawing.Point(84, 415); this.signallingLabel.Name = "signallingLabel"; this.signallingLabel.Size = new System.Drawing.Size(129, 11); this.signallingLabel.TabIndex = 38; // // OTWebDownloader // 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); this.Controls.Add(this.endingDownloadingTimeLabel); this.Controls.Add(this.label10); this.Controls.Add(this.checkBoxOverWrite); this.Controls.Add(this.checkBoxCheckingForMissingQuotes); this.Controls.Add(this.label9); this.Controls.Add(this.txtOpenTickPassword); this.Controls.Add(this.label8); this.Controls.Add(this.txtOpenTickUser); this.Controls.Add(this.label7); this.Controls.Add(this.fromSec); this.Controls.Add(this.label6); this.Controls.Add(this.numberOfBars); this.Controls.Add(this.label5); this.Controls.Add(this.fromMin); this.Controls.Add(this.label4); this.Controls.Add(this.fromHour); this.Controls.Add(this.label3); this.Controls.Add(this.label2); this.Controls.Add(this.timeFrameInSeconds); this.Controls.Add(this.label1); this.Controls.Add(this.dateTimeOverwriteQuotesBefore); this.Controls.Add(this.groupBoxWebDownloaderOptions); this.Controls.Add(this.buttonDownloadQuotesOfSelectedTickers); this.Controls.Add(this.dataGrid1); this.Name = "OTWebDownloader"; this.Text = "OT Web downloader"; this.Load += new System.EventHandler(this.otWebDownloaderLoad); ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit(); this.groupBoxWebDownloaderOptions.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.timeFrameInSeconds)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.fromHour)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.fromMin)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numberOfBars)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.fromSec)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); } private System.Windows.Forms.Label signallingLabel; private System.Windows.Forms.Timer timer1; private System.Windows.Forms.Label endingDownloadingTimeLabel; private System.Windows.Forms.Label startingDownloadingTimeLabel; private System.Windows.Forms.Label label10; private System.Windows.Forms.CheckBox checkBoxOverWrite; private System.Windows.Forms.CheckBox checkBoxCheckingForMissingQuotes; private System.Windows.Forms.TextBox txtOpenTickPassword; private System.Windows.Forms.Label label9; private System.Windows.Forms.Label label8; private System.Windows.Forms.TextBox txtOpenTickUser; private System.Windows.Forms.NumericUpDown timeFrameInSeconds; private System.Windows.Forms.Label label7; private System.Windows.Forms.NumericUpDown fromSec; private System.Windows.Forms.NumericUpDown numberOfBars; private System.Windows.Forms.DateTimePicker dateTimeOverwriteQuotesBefore; private System.Windows.Forms.Label label6; private System.Windows.Forms.NumericUpDown fromMin; private System.Windows.Forms.Label label5; private System.Windows.Forms.Label label4; private System.Windows.Forms.NumericUpDown fromHour; private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label1; #endregion #region ITickerSelector's implementation public DataTable GetTableOfSelectedTickers() { return TickerSelector.GetTableOfManuallySelectedTickers(this.dataGrid1); } public void SelectAllTickers() { DataTable dataTableOfDataGrid1 = (DataTable)this.dataGrid1.DataSource; int indexOfRow = 0; while(indexOfRow != dataTableOfDataGrid1.Rows.Count) { this.dataGrid1.Select(indexOfRow); indexOfRow++; } } #endregion #region form options public bool IsOnlyAfterLastQuoteSelected { get { return this.radioButtonDownloadOnlyAfterMax.Checked; } } public bool IsOverWriteSelected { get { return this.checkBoxOverWrite.Checked; } } #endregion #region download thread private void buttonDownloadQuotesOfSelectedTickers_Click(object sender, System.EventArgs e) { try{ OTTickerDownloader tickerDownloader = new OTTickerDownloader(this.TickersToDownload, this.StartingNewYorkDateTime, this.dateTimeOverwriteQuotesBefore.Value, this.checkBoxCheckingForMissingQuotes.Checked, this.checkBoxOverWrite.Checked, this.radioButtonDownloadOnlyAfterMax.Checked, this.txtOpenTickUser.Text, this.txtOpenTickPassword.Text); tickerDownloader.DownloadingStarted += new DownloadingStartedEventHandler(this.refreshForm_atDownloadedStarted); tickerDownloader.DatabaseUpdated += new DatabaseUpdatedEventHandler(this.refreshGrid); tickerDownloader.DownloadingCompleted += new DownloadingCompletedEventHandler(this.refreshForm_atDownloadedCompleted); this.buttonDownloadQuotesOfSelectedTickers.Enabled = false; this.downloadThread = new Thread( tickerDownloader.DownloadTickers ); this.downloadThread.Start(); } catch(Exception ex) { MessageBox.Show(ex.Message); } } #endregion private void refreshGrid(object sender, DatabaseUpdatedEventArgs eventArgs) { DataTable tickersCurrentylDownloaded = this.DsTickerCurrentlyDownloaded.Tables["Tickers"]; for(int i = 0; i < tickersCurrentylDownloaded.Rows.Count; i++) { if( (string)tickersCurrentylDownloaded.Rows[i][0] == eventArgs.Ticker ) { tickersCurrentylDownloaded.Rows[i][1] = "Yes"; tickersCurrentylDownloaded.Rows[i][2] = eventArgs.DateTimeOfLastBarUpdated; } } } private void refreshForm_atDownloadedStarted(object sender, DownloadingStartedEventArgs eventArgs) { this.textForStartingDownloadingTimeLabel = "Downloading started at: " + eventArgs.StartingDateTime.ToString(); this.downloadingInProgress = true; } private void refreshForm_atDownloadedCompleted(object sender, DownloadingCompletedEventArgs eventArgs) { this.textForEndingDownloadingTimeLabel = "Downloading completed at: " + eventArgs.EndingDateTime.ToString(); this.downloadingInProgress = false; } #region properties public DateTime StartingNewYorkDateTime { get { return new DateTime(this.dateTimePickerStartingDate.Value.Year, this.dateTimePickerStartingDate.Value.Month, this.dateTimePickerStartingDate.Value.Day, Convert.ToInt32(this.fromHour.Value), Convert.ToInt32(this.fromMin.Value), Convert.ToInt32(this.fromSec.Value)); } } public int TimeFrameInSeconds { get { return Convert.ToInt32(this.timeFrameInSeconds.Value); } } public int NumberOfBars { get { return Convert.ToInt32(this.numberOfBars.Value); } } public string[] TickersToDownload { get { string[] tickersToDownload = new string[this.tableOfSelectedTickers.Rows.Count]; for(int i = 0; i < tickersToDownload.Length; i++) tickersToDownload[i] = (string)this.tableOfSelectedTickers.Rows[i][0]; return tickersToDownload; } } public bool DownloadInProgress { get { return this.downloadingInProgress; } } #endregion private void otWebDownloaderLoad_setStyleForDataGrid() { DataGridTableStyle dataGrid1TableStyle = new DataGridTableStyle(); dataGrid1TableStyle.MappingName = this.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ].TableName; dataGrid1TableStyle.ColumnHeadersVisible = true; dataGrid1TableStyle.ReadOnly = true; dataGrid1TableStyle.SelectionBackColor = Color.DimGray ; DataGridTextBoxColumn columnStyle_Tickers = new DataGridTextBoxColumn(); columnStyle_Tickers.MappingName = "tickers"; columnStyle_Tickers.HeaderText = "Tickers"; columnStyle_Tickers.TextBox.Enabled = false; columnStyle_Tickers.NullText = ""; columnStyle_Tickers.Width = 60; DataGridTextBoxColumn columnStyle_dbUpdated = new DataGridTextBoxColumn(); columnStyle_dbUpdated.MappingName = "dbUpdated"; columnStyle_dbUpdated.HeaderText = "DB Updated"; columnStyle_dbUpdated.TextBox.Enabled = false; columnStyle_dbUpdated.NullText = ""; columnStyle_dbUpdated.Width = 70; DataGridTextBoxColumn columnStyle_dateTimeOfLastBar = new DataGridTextBoxColumn(); columnStyle_dateTimeOfLastBar.MappingName = "dateTimeOfLastBar"; columnStyle_dateTimeOfLastBar.HeaderText = "Date Time of Last Bar"; columnStyle_dateTimeOfLastBar.TextBox.Enabled = false; columnStyle_dateTimeOfLastBar.NullText = ""; columnStyle_dateTimeOfLastBar.Width = 120; dataGrid1TableStyle.GridColumnStyles.Add(columnStyle_Tickers); dataGrid1TableStyle.GridColumnStyles.Add(columnStyle_dbUpdated); dataGrid1TableStyle.GridColumnStyles.Add(columnStyle_dateTimeOfLastBar); this.dataGrid1.TableStyles.Add(dataGrid1TableStyle); } private void otWebDownloaderLoad_fillDataGridWithTickersToBeDownloaded() { //prepares the table for the dataGrid if (!this.DsTickerCurrentlyDownloaded.Tables.Contains( "Tickers" )) { this.DsTickerCurrentlyDownloaded.Tables.Add( "Tickers" ); this.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ].Columns.Add( new DataColumn( "tickers" , this.tableOfSelectedTickers.Columns[0].DataType ) ); this.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ].Columns.Add( "dbUpdated" , System.Type.GetType( "System.String" ) ); this.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ].Columns.Add( "dateTimeOfLastBar" , System.Type.GetType( "System.DateTime" ) ); } //populates the dataGrid with the selectedTickers to be downloaded for (int i = 0; i<this.tableOfSelectedTickers.Rows.Count; i++) { DataRow newRow = this.DsTickerCurrentlyDownloaded.Tables["Tickers"].NewRow(); newRow[0] = this.tableOfSelectedTickers.Rows[i][0]; newRow[1] = "No";//databaseUpdated newRow[2] = DBNull.Value;//dateTime of the last updated bar this.DsTickerCurrentlyDownloaded.Tables["Tickers"].Rows.Add(newRow); } //link of dataGrid to the table this.dataGrid1.DataSource = this.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ]; this.otWebDownloaderLoad_setStyleForDataGrid(); } private void otWebDownloaderLoad(object sender, EventArgs e) { this.otWebDownloaderLoad_fillDataGridWithTickersToBeDownloaded(); } private void Timer1Tick_refreshSignallingLabel() { if(this.downloadingInProgress) { if(this.signallingLabel.Text.Length<40) this.signallingLabel.Text += "--"; else this.signallingLabel.Text = ""; } else { this.signallingLabel.Text = ""; } } void Timer1Tick(object sender, EventArgs e) { this.Timer1Tick_refreshSignallingLabel(); this.startingDownloadingTimeLabel.Text = textForStartingDownloadingTimeLabel; this.endingDownloadingTimeLabel.Text = textForEndingDownloadingTimeLabel; } private void OTWebDownloader_Closing(Object sender, CancelEventArgs e) { if (this.downloadingInProgress) { e.Cancel = true; MessageBox.Show("You can't close the form if downloading is still in progress!"); } else { e.Cancel = false; } } } } |
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv10120 Added Files: DatabaseUpdatedEventArgs.cs DownloadedCompletedEventArgs.cs DownloadingStartedEventArgs.cs OTTickerDownloader.cs Log Message: Added skeleton file (and the related eventArgs classes) for the OT Ticker Downloader --- NEW FILE: DownloadingStartedEventArgs.cs --- /* QuantProject - Quantitative Finance Library DownloadingStartedEventArgs.cs Copyright (C) 2008 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; namespace QuantProject.Applications.Downloader.OpenTickDownloader { /// <summary> /// Description of DownloadingStartedEventArgs. /// </summary> public class DownloadingStartedEventArgs : EventArgs { private DateTime startingDateTime; public DateTime StartingDateTime { get { return this.startingDateTime; } } public DownloadingStartedEventArgs(DateTime startingDateTime ) { this.startingDateTime = startingDateTime; } } } --- NEW FILE: DownloadedCompletedEventArgs.cs --- /* QuantProject - Quantitative Finance Library DownloadingCompletedEventArgs.cs Copyright (C) 2008 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; namespace QuantProject.Applications.Downloader.OpenTickDownloader { /// <summary> /// Description of DownloadingCompletedEventArgs. /// </summary> public class DownloadingCompletedEventArgs : EventArgs { private DateTime endingDateTime; public DateTime EndingDateTime { get { return this.endingDateTime; } } public DownloadingCompletedEventArgs(DateTime endingDateTime ) { this.endingDateTime = endingDateTime; } } } --- NEW FILE: OTTickerDownloader.cs --- /* QuantProject - Quantitative Finance Library OTTickerDownloader.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.Data; using System.Threading; using QuantProject.ADT; namespace QuantProject.Applications.Downloader.OpenTickDownloader { public delegate void DownloadingStartedEventHandler( object sender , DownloadingStartedEventArgs e ); public delegate void DatabaseUpdatedEventHandler( object sender , DatabaseUpdatedEventArgs e ); public delegate void DownloadingCompletedEventHandler( object sender , DownloadingCompletedEventArgs e ); /// <summary> /// Summary description for OTTickerDownloader. /// </summary> public class OTTickerDownloader { private string[] tickersToDownload; private DateTime startingNewYorkDateTime; private DateTime dateTimeForOverWritingQuotes;//before this //date quotes should be overwritten automatically private bool checkForMissingQuotes;//it downloads and writes //to db all the missing quotes private bool overwriteAllQuotesInDatabase;//for overWriting quotes //also after dateTimeForOverWritingQuotes private bool downloadOnlySuccessiveQuotesToTheLastQuoteInDatabase; //the starting date for download is just the next day to the //last one stored in database. If no quote is stored, //the starting date for download is startingNewYorkDateTime private string openTickUser; private string openTickPassword; private void otTickerDownloader_checkParameters( string[] tickersToDownload, DateTime startingNewYorkDateTime, DateTime dateTimeForOverWritingQuotes, bool checkForMissingQuotes, bool overwriteAllQuotesInDatabase, bool downloadOnlySuccessiveQuotesToTheLastQuoteInDatabase, string openTickUser, string openTickPassword ) { if(tickersToDownload == null) throw new Exception("No ticker has been indicated for download!"); if( !downloadOnlySuccessiveQuotesToTheLastQuoteInDatabase && dateTimeForOverWritingQuotes.CompareTo(startingNewYorkDateTime) < 0 ) //the user has not requested only quotes successive to the last //stored in the DB and date time for overwriting quotes precedes //the date time for the first quote to download throw new Exception("Date Time for OverWriting Quotes can't precede " + "starting Date for download!"); if( checkForMissingQuotes && downloadOnlySuccessiveQuotesToTheLastQuoteInDatabase ) //the two options have to be different in value or both false throw new Exception("Downloading only quotes successive to the last quote in the DB " + "implies that missing quotes will not be checked" ); if( ( openTickUser == null || openTickUser == "" ) || ( openTickPassword == null || openTickPassword == "" ) ) throw new Exception("Type in user and password for logging to OpenTick" ); } public OTTickerDownloader( string[] tickersToDownload, DateTime startingNewYorkDateTime, DateTime dateTimeForOverWritingQuotes, bool checkForMissingQuotes, bool overwriteAllQuotesInDatabase, bool downloadOnlySuccessiveQuotesToTheLastQuoteInDatabase, string openTickUser, string openTickPassword) { this.otTickerDownloader_checkParameters(tickersToDownload, startingNewYorkDateTime, dateTimeForOverWritingQuotes, checkForMissingQuotes, overwriteAllQuotesInDatabase, downloadOnlySuccessiveQuotesToTheLastQuoteInDatabase, openTickUser, openTickPassword); this.tickersToDownload = tickersToDownload; this.startingNewYorkDateTime = startingNewYorkDateTime; this.dateTimeForOverWritingQuotes = dateTimeForOverWritingQuotes; this.checkForMissingQuotes = checkForMissingQuotes; this.overwriteAllQuotesInDatabase = overwriteAllQuotesInDatabase; this.downloadOnlySuccessiveQuotesToTheLastQuoteInDatabase = downloadOnlySuccessiveQuotesToTheLastQuoteInDatabase; this.openTickUser = openTickUser; this.openTickPassword = openTickPassword; } public event DownloadingStartedEventHandler DownloadingStarted; public event DatabaseUpdatedEventHandler DatabaseUpdated; public event DownloadingCompletedEventHandler DownloadingCompleted; private void downloadTickers_dummyDatabaseUpdatedEventRiser() { DateTime dateTimeOfLastBarUpdated = DateTime.Now; foreach(string ticker in this.tickersToDownload) { Thread.Sleep(500); DatabaseUpdatedEventArgs databaseUpdatedEventArgs = new DatabaseUpdatedEventArgs(ticker, dateTimeOfLastBarUpdated); if(this.DatabaseUpdated != null) this.DatabaseUpdated(this, databaseUpdatedEventArgs); } } private void downloadTickers_dummyDownloadingStartedEventRiser() { DownloadingStartedEventArgs eventArgs = new DownloadingStartedEventArgs(DateTime.Now); if(this.DownloadingStarted != null) this.DownloadingStarted( this, eventArgs ); } private void downloadTickers_dummyDownloadingCompletedEventRiser() { DownloadingCompletedEventArgs eventArgs = new DownloadingCompletedEventArgs(DateTime.Now); if(this.DownloadingCompleted != null) this.DownloadingCompleted( this, eventArgs ); } public void DownloadTickers() { this.downloadTickers_dummyDownloadingStartedEventRiser(); this.downloadTickers_dummyDatabaseUpdatedEventRiser(); this.downloadTickers_dummyDownloadingCompletedEventRiser(); } } } --- NEW FILE: DatabaseUpdatedEventArgs.cs --- /* QuantProject - Quantitative Finance Library DatabaseUpdatedEventArgs.cs Copyright (C) 2008 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; namespace QuantProject.Applications.Downloader.OpenTickDownloader { /// <summary> /// Description of DatabaseUpdatedEventArgs. /// </summary> public class DatabaseUpdatedEventArgs : EventArgs { private string ticker; private DateTime dateTimeOfLastBarUpdated; public string Ticker { get { return this.ticker; } } public DateTime DateTimeOfLastBarUpdated { get { return this.dateTimeOfLastBarUpdated; } } public DatabaseUpdatedEventArgs( string ticker , DateTime dateTimeOfLastBarUpdated ) { this.ticker = ticker; this.dateTimeOfLastBarUpdated = dateTimeOfLastBarUpdated; } } } |