quantproject-developers Mailing List for QuantProject (Page 23)
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...> - 2009-01-18 18:27:20
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv25891/Downloader/OpenTickDownloader Modified Files: BarQueueFiller.cs Log Message: Now bars received from OpenTick are formally checked, before being accepted Index: BarQueueFiller.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/BarQueueFiller.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** BarQueueFiller.cs 11 Jan 2009 20:38:14 -0000 1.4 --- BarQueueFiller.cs 18 Jan 2009 18:27:09 -0000 1.5 *************** *** 3,7 **** BarQueueFiller.cs ! Copyright (C) 2008 Glauco Siliprandi --- 3,7 ---- BarQueueFiller.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; --- 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; *************** *** 32,36 **** public delegate void NewOHLCRequestEventHandler( int requestId , DateTime dateTimeForRequest , long barInterval ); ! /// <summary> /// Downloads all the bars for a given ticker and --- 32,36 ---- public delegate void NewOHLCRequestEventHandler( int requestId , DateTime dateTimeForRequest , long barInterval ); ! /// <summary> /// Downloads all the bars for a given ticker and *************** *** 48,51 **** --- 48,52 ---- private BarQueue barQueue; + private DateTime minDateTimeForAcceptablesBars; private IExchangeSelector exchangeSelector; *************** *** 75,79 **** IExchangeSelector exchangeSelector , OTManager oTManager , ! BarQueue barQueue ) { --- 76,80 ---- IExchangeSelector exchangeSelector , OTManager oTManager , ! BarQueue barQueue ) { *************** *** 87,91 **** new NewMessageEventHandler( this.newMessageEventHandler ); ! this.barQueue = barQueue; } private void newMessageEventHandler( --- 88,93 ---- new NewMessageEventHandler( this.newMessageEventHandler ); ! this.barQueue = barQueue; ! this.minDateTimeForAcceptablesBars = new DateTime( 1950 , 1 , 1 ); } private void newMessageEventHandler( *************** *** 98,103 **** #region fillQueue ! #region onHistoricalOHLC #region getBar private long getBar_getInterval( OTOHLC ohlc ) --- 100,137 ---- #region fillQueue ! #region onHistoricalOHLCEventHandler + #region isAcceptable + private bool isAcceptableDateTime( OTOHLC ohlc ) + { + bool isAcceptable = + ( + ( ohlc.Timestamp >= this.minDateTimeForAcceptablesBars ) && + ( ohlc.Timestamp <= DateTime.Now ) + ); + return isAcceptable; + } + private bool areAcceptableOHLCvalues( OTOHLC ohlc ) + { + bool areAcceptable = + ( + ( ohlc.LowPrice > 0 ) && + ( ohlc.OpenPrice <= ohlc.HighPrice ) && + ( ohlc.OpenPrice >= ohlc.LowPrice ) && + ( ohlc.ClosePrice <= ohlc.HighPrice ) && + ( ohlc.ClosePrice >= ohlc.LowPrice ) + ); + return areAcceptable; + } + private bool isAcceptable( OTOHLC ohlc ) + { + bool isOk = + ( this.isAcceptableDateTime( ohlc ) ) && + ( this.areAcceptableOHLCvalues( ohlc ) ); + return isOk; + } + #endregion isAcceptable + + #region enqueueBar #region getBar private long getBar_getInterval( OTOHLC ohlc ) *************** *** 126,138 **** } #endregion getBar ! private void onHistoricalOHLCEventHandler( OTOHLC ohlc , BarRequest barRequest ) ! { ! Bar bar = this.getBar( ohlc ); ! this.barQueue.Enqueue( bar ); ! } ! ! #endregion onHistoricalOHLC ! private void fillQueue_setEventHandlers() { --- 160,181 ---- } #endregion getBar ! ! private void enqueueBar( OTOHLC ohlc ) ! { ! Bar bar = this.getBar( ohlc ); ! this.barQueue.Enqueue( bar ); ! } ! #endregion enqueueBar ! ! private void onHistoricalOHLCEventHandler( OTOHLC ohlc , BarRequest barRequest ) ! { ! if ( this.isAcceptable( ohlc ) ) ! // the bar is acceptable ! this.enqueueBar( ohlc ); ! } ! ! #endregion onHistoricalOHLCEventHandler ! private void fillQueue_setEventHandlers() { *************** *** 143,147 **** #region fillQueue_requestBarsForEachMarketDay ! #region fillQueue_requestBar private void fillQueue_requestBar_actually( --- 186,190 ---- #region fillQueue_requestBarsForEachMarketDay ! #region fillQueue_requestBar private void fillQueue_requestBar_actually( *************** *** 162,166 **** this.NewOHLCRequest( requestId , dateTimeForBarOpenInUTC , ! barIdentifier.Interval ); } private void fillQueue_requestBar( --- 205,209 ---- this.NewOHLCRequest( requestId , dateTimeForBarOpenInUTC , ! barIdentifier.Interval ); } private void fillQueue_requestBar( *************** *** 182,186 **** } #endregion fillQueue_requestBarsForEachMarketDay ! private void fillQueue() { --- 225,229 ---- } #endregion fillQueue_requestBarsForEachMarketDay ! private void fillQueue() { |
|
From: Glauco S. <gla...@us...> - 2009-01-14 23:37:57
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv2285/b2_DataAccess Modified Files: DataBase.cs Log Message: The method IsExceptionForForbiddenDataDuplication() has been removed (written that way, it didn't work for any OS language) Index: DataBase.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/DataBase.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** DataBase.cs 11 Jan 2009 20:16:35 -0000 1.14 --- DataBase.cs 14 Jan 2009 23:37:51 -0000 1.15 *************** *** 311,337 **** #endregion GetBarOpenHistory ! /// <summary> ! /// true iif exception is risen by the attempt to duplicate a value in ! /// a table ! /// </summary> ! /// <param name="exception"></param> ! /// <returns></returns> ! public static bool IsExceptionForForbiddenDataDuplication( ! Exception exception ) ! { ! bool isExceptionForForbiddenDataDuplication = ! ( ! ( ! ( exception is OleDbException ) && ! exception.Message.Contains( "duplicate values" ) ! ) ! || ! ( ! ( exception is MySqlException ) && ! exception.Message.Contains( "Duplicate entry" ) ! ) ! ); ! return isExceptionForForbiddenDataDuplication; ! } } } --- 311,337 ---- #endregion GetBarOpenHistory ! // /// <summary> ! // /// true iif exception is risen by the attempt to duplicate a value in ! // /// a table ! // /// </summary> ! // /// <param name="exception"></param> ! // /// <returns></returns> ! // public static bool IsExceptionForForbiddenDataDuplication( ! // Exception exception ) ! // { ! // bool isExceptionForForbiddenDataDuplication = ! // ( ! // ( ! // ( exception is OleDbException ) && ! // exception.Message.Contains( "duplicate values" ) ! // ) ! // || ! // ( ! // ( exception is MySqlException ) && ! // exception.Message.Contains( "Duplicate entry" ) ! // ) ! // ); ! // return isExceptionForForbiddenDataDuplication; ! // } } } |
|
From: Glauco S. <gla...@us...> - 2009-01-14 23:36:35
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv2199/b2_DataAccess/Tables Modified Files: Bars.cs Log Message: - a new method has been added: public static DataTable GetTickerBars( string ticker , string exchange , DateTime firstBarDateTime , DateTime lastBarDateTime , long intervalFrameInSeconds ) - a new method has been added: public static bool ContainsBar( string ticker , string exchange , DateTime dateTimeForOpenInESTTime , long interval ) - a try catch has been removed from the method AddBar() (exceptions have to be managed by the caller) Index: Bars.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables/Bars.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Bars.cs 11 Jan 2009 20:15:17 -0000 1.6 --- Bars.cs 14 Jan 2009 23:36:27 -0000 1.7 *************** *** 250,253 **** --- 250,280 ---- return SqlExecutor.GetDataTable( sql ); } + + /// <summary> + /// returns the bars DataTable for the given ticker + /// </summary> + /// <param name="ticker">ticker whose quotes are to be returned</param> + /// <param name="exchange">the exchange where the ticker was traded</param> + /// <param name="firstBarDateTime">The first bar date time</param> + /// <param name="lastBarDateTime">The last bar date time</param> + /// <param name="intervalFrameInSeconds">interval frame in seconds for + /// the ticker's bars</param> + /// <returns></returns> + public static DataTable GetTickerBars( + string ticker , string exchange , + DateTime firstBarDateTime , DateTime lastBarDateTime , long intervalFrameInSeconds ) + { + string sql = "select * from bars " + + "where " + Bars.TickerFieldName + "='" + ticker + "' and " + + Bars.Exchange + "='" + exchange + "' and " + + Bars.IntervalFrameInSeconds + "=" + intervalFrameInSeconds + " " + + "and " + Bars.DateTimeForOpen + " between " + + SQLBuilder.GetDateTimeConstant(firstBarDateTime) + " " + + "and " + SQLBuilder.GetDateTimeConstant(lastBarDateTime) + " " + + "order by " + Bars.DateTimeForOpen; + return SqlExecutor.GetDataTable( sql ); + } + + /// <summary> /// Returns the bars for the given instrument , since startDateTime to endDateTime *************** *** 537,552 **** ticker , exchange , dateTimeForOpenInESTTime , interval , open , high , low , close , volume ); ! try ! { ! SqlExecutor.ExecuteNonQuery( sqlCommand ); ! } ! catch( Exception exception ) ! { ! if ( !DataBase.IsExceptionForForbiddenDataDuplication( exception ) ) ! // the exception is not due to a duplicated bar ! throw exception; ! } } #endregion AddBar } } --- 564,595 ---- ticker , exchange , dateTimeForOpenInESTTime , interval , open , high , low , close , volume ); ! // try ! // { ! SqlExecutor.ExecuteNonQuery( sqlCommand ); ! // } ! // catch( Exception exception ) ! // { ! // if ( !DataBase.IsExceptionForForbiddenDataDuplication( exception ) ) ! // // the exception is not due to a duplicated bar ! // throw exception; ! // } } #endregion AddBar + + /// <summary> + /// true iif the database contains a bar for the given key values + /// </summary> + /// <param name="ticker"></param> + /// <param name="exchange"></param> + /// <param name="dateTimeForOpenInESTTime"></param> + /// <param name="interval"></param> + public static bool ContainsBar( + string ticker , string exchange , DateTime dateTimeForOpenInESTTime , long interval ) + { + DataTable bars = Bars.GetTickerBars( + ticker , exchange , dateTimeForOpenInESTTime , dateTimeForOpenInESTTime , interval ); + bool containsBar = ( bars.Rows.Count > 0 ); + return containsBar; + } } } |
|
From: Glauco S. <gla...@us...> - 2009-01-14 23:32:50
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/DatabaseManagement In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv2030/Downloader/OpenTickDownloader/DatabaseManagement Modified Files: DataBaseWriter.cs Log Message: Bars with a duplicate key are skipped now Index: DataBaseWriter.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/DatabaseManagement/DataBaseWriter.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DataBaseWriter.cs 11 Jan 2009 20:38:14 -0000 1.4 --- DataBaseWriter.cs 14 Jan 2009 23:32:39 -0000 1.5 *************** *** 3,7 **** DataBaseWriter.cs ! Copyright (C) 2008 Glauco Siliprandi --- 3,7 ---- DataBaseWriter.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; --- 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; *************** *** 82,93 **** } private void writeToDataBaseActually( Bar bar ) { DateTime dateTimeForOpenInESTTime = TimeZoneManager.ConvertToEST( bar.DateTimeForOpenInUTCTime ); ! Bars.AddBar( ! bar.Ticker , bar.Exchange , dateTimeForOpenInESTTime , bar.Interval , ! bar.Open , bar.High , bar.Low , bar.Close , bar.Volume ); } private void riseDatabaseUpdatedEvent( Bar bar ) { --- 82,114 ---- } + #region writeToDataBaseActually + private void throwExceptionIfOtherThanBarAlreadyInTheDatabase( + string ticker , string exchange , DateTime dateTimeForOpenInESTTime , long interval , + Exception exception ) + { + if ( !Bars.ContainsBar( + ticker , exchange , dateTimeForOpenInESTTime , interval ) ) + // exception was not due to a duplicate key + throw exception; + } private void writeToDataBaseActually( Bar bar ) { DateTime dateTimeForOpenInESTTime = TimeZoneManager.ConvertToEST( bar.DateTimeForOpenInUTCTime ); ! try ! { ! Bars.AddBar( ! bar.Ticker , bar.Exchange , dateTimeForOpenInESTTime , bar.Interval , ! bar.Open , bar.High , bar.Low , bar.Close , bar.Volume ); ! } ! catch ( Exception exception ) ! { ! this.throwExceptionIfOtherThanBarAlreadyInTheDatabase( ! bar.Ticker , bar.Exchange , dateTimeForOpenInESTTime , bar.Interval , ! exception ); ! } } + #endregion writeToDataBaseActually + private void riseDatabaseUpdatedEvent( Bar bar ) { *************** *** 114,119 **** this.writeToDataBaseActually(); } ! #endregion writeToDataBaseIfEnoughBars ! private void writeToDataBase() { --- 135,140 ---- this.writeToDataBaseActually(); } ! #endregion writeToDataBaseIfEnoughBars ! private void writeToDataBase() { *************** *** 122,126 **** this.writeToDataBaseIfEnoughBars(); Thread.Sleep( 50 ); ! } } #endregion writeToDataBase --- 143,147 ---- this.writeToDataBaseIfEnoughBars(); Thread.Sleep( 50 ); ! } } #endregion writeToDataBase *************** *** 132,135 **** --- 153,180 ---- this.writeToDataBaseThread.Start(); } + + // uncomment the two following methods to test if writeToDataBaseActually + // properly handles duplicate keys attempt + // public static void TestAddBar() + // { + // DataBaseWriter dataBaseWriter = new DataBaseWriter( + // new BarQueue( 1 ) , 1 ); + // dataBaseWriter.TestAddBarForInstance(); + // } + // public void TestAddBarForInstance() + // { + // Bar bar = new Bar( + // "AAPL" , "Q" , new DateTime( 2009 , 1 , 2 , 15 , 52 , 0 ) , 60 , + // 1 , 4 , 3 , 2 , 10000 ); + // // the following statement should actually add a bar, if no bar with the same + // // key is in the database + // this.writeToDataBaseActually( bar ); + // bar = new Bar( + // "AAPL" , "Q" , new DateTime( 2009 , 1 , 2 , 15 , 52 , 0 ) , 60 , + // 1 , 4 , 3 , 2 , 20000 ); + // // the following statement will not add the bar, because a bar with the + // // same key has just been added above, but NO EXCEPTION will be risen + // this.writeToDataBaseActually( bar ); + // } } } |
|
From: Glauco S. <gla...@us...> - 2009-01-13 15:25:51
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv2319 Removed Files: app.config Log Message: The file has been removed from the repository --- app.config DELETED --- |
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv16997/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator Modified Files: PVOPositions.cs PVOStrategyIntraday.cs PVOStrategyIntradayMain.cs Log Message: Updated files for the PVO strategy intraday Index: PVOStrategyIntraday.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/PVOStrategyIntraday.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PVOStrategyIntraday.cs 1 Jan 2009 13:44:57 -0000 1.2 --- PVOStrategyIntraday.cs 12 Jan 2009 18:11:01 -0000 1.3 *************** *** 103,107 **** --- 103,109 ---- protected double inefficiencyLengthInMinutes; protected double maxOpeningLengthInMinutes; + protected double minutesFromLastInefficiencyTimeToWaitBeforeOpening; protected Time lastEntryTime; + protected Time lastInefficiencyTime; protected List<Time> openingTimesForAvailableBars; protected double currentAccountValue; *************** *** 169,172 **** --- 171,175 ---- HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample, double inefficiencyLengthInMinutes, + double minutesFromLastInefficiencyTimeToWaitBeforeOpening, double maxOpeningLengthInMinutes, List<Time> openingTimesForAvailableBars, *************** *** 186,189 **** --- 189,194 ---- this.historicalMarketValueProviderForOutOfSample = historicalMarketValueProviderForOutOfSample; this.inefficiencyLengthInMinutes = inefficiencyLengthInMinutes; + this.minutesFromLastInefficiencyTimeToWaitBeforeOpening = + minutesFromLastInefficiencyTimeToWaitBeforeOpening; this.maxOpeningLengthInMinutes = maxOpeningLengthInMinutes; this.openingTimesForAvailableBars = openingTimesForAvailableBars; *************** *** 194,197 **** --- 199,203 ---- this.pvoStrategyIntraday_checkTimeParameters(); this.lastEntryTime = new Time("00:00:00"); + this.lastInefficiencyTime = new Time("00:00:00"); // this.optimalPositionsHaveBeenUpdated = false; } *************** *** 210,213 **** --- 216,220 ---- HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample, double inefficiencyLengthInMinutes, + double minutesFromLastInefficiencyTimeToWaitBeforeOpening, double maxOpeningLengthInMinutes, List<Time> openingTimesForAvailableBars, *************** *** 222,225 **** --- 229,233 ---- historicalMarketValueProviderForOutOfSample, inefficiencyLengthInMinutes, + minutesFromLastInefficiencyTimeToWaitBeforeOpening, maxOpeningLengthInMinutes, openingTimesForAvailableBars, *************** *** 239,242 **** --- 247,251 ---- HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample, double inefficiencyLengthInMinutes, + double minutesFromLastInefficiencyTimeToWaitBeforeOpening, double maxOpeningLengthInMinutes, List<Time> openingTimesForAvailableBars, *************** *** 251,254 **** --- 260,264 ---- historicalMarketValueProviderForOutOfSample, inefficiencyLengthInMinutes, + minutesFromLastInefficiencyTimeToWaitBeforeOpening, maxOpeningLengthInMinutes, openingTimesForAvailableBars, *************** *** 269,272 **** --- 279,283 ---- HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample, double inefficiencyLengthInMinutes, + double minutesFromLastInefficiencyTimeToWaitBeforeOpening, double maxOpeningLengthInMinutes, List<Time> openingTimesForAvailableBars, *************** *** 281,284 **** --- 292,296 ---- historicalMarketValueProviderForOutOfSample, inefficiencyLengthInMinutes, + minutesFromLastInefficiencyTimeToWaitBeforeOpening, maxOpeningLengthInMinutes, openingTimesForAvailableBars, *************** *** 297,300 **** --- 309,313 ---- HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample, double inefficiencyLengthInMinutes, + double minutesFromLastInefficiencyTimeToWaitBeforeOpening, double maxOpeningLengthInMinutes, List<Time> openingTimesForAvailableBars, *************** *** 308,311 **** --- 321,325 ---- historicalMarketValueProviderForOutOfSample, inefficiencyLengthInMinutes, + minutesFromLastInefficiencyTimeToWaitBeforeOpening, maxOpeningLengthInMinutes, openingTimesForAvailableBars, *************** *** 452,455 **** --- 466,470 ---- AccountManager.ClosePositions( this.account ); this.lastEntryTime = new Time("00:00:00"); + this.lastInefficiencyTime = new Time("00:00:00"); } } *************** *** 522,526 **** } #endregion newDateTimeEventHandler_openPositions ! #region newDateTimeEventHandler_updateStatus private void newDateTimeEventHandler_setPositionsAndStatus(Time currentDailyTime) --- 537,576 ---- } #endregion newDateTimeEventHandler_openPositions ! ! #region newDateTimeEventHandler_inefficiencyIsMovingBack ! private bool newDateTimeEventHandler_inefficiencyIsMovingBack(Time currentDailyTime) ! { ! bool returnValue = false; ! DateTime beginOfOscillatingPeriod = ! Time.GetDateTimeFromMerge( this.now() , this.lastInefficiencyTime ); ! DateTime endOfOscillatingPeriod = ! Time.GetDateTimeFromMerge( this.now() , currentDailyTime ); ! PVOPositionsStatus currentStatusForCurrentPositions = ! PVOPositionsStatus.InTheMiddle; ! double coefficientForThresholdLevelComputationForMovingBackSignal = ! this.minutesFromLastInefficiencyTimeToWaitBeforeOpening/this.inefficiencyLengthInMinutes; ! if(this.positionsForOutOfSample != null) ! try{ ! currentStatusForCurrentPositions = ! this.positionsForOutOfSample.GetStatus( beginOfOscillatingPeriod, endOfOscillatingPeriod, ! this.benchmark.Ticker, this.historicalMarketValueProviderForOutOfSample, ! this.oversoldThreshold * coefficientForThresholdLevelComputationForMovingBackSignal, ! 0.50, ! this.overboughtThreshold * coefficientForThresholdLevelComputationForMovingBackSignal, ! 0.50); ! ! }catch(Exception ex){string str = ex.ToString();} ! returnValue = ( (currentStatusForCurrentPositions == PVOPositionsStatus.Overbought && ! this.positionsForOutOfSampleStatus == PVOPositionsStatus.Oversold) || ! (currentStatusForCurrentPositions == PVOPositionsStatus.Oversold && ! this.positionsForOutOfSampleStatus == PVOPositionsStatus.Overbought) ); ! if( returnValue == false ) ! this.positionsForOutOfSample = null; //it forces a new research for inefficiencies ! return returnValue; ! } ! ! ! #endregion newDateTimeEventHandler_inefficiencyIsMovingBack ! #region newDateTimeEventHandler_updateStatus private void newDateTimeEventHandler_setPositionsAndStatus(Time currentDailyTime) *************** *** 530,536 **** DateTime endOfOscillatingPeriod = Time.GetDateTimeFromMerge(this.now() , currentDailyTime); ! this.positionsForOutOfSample = null; this.positionsForOutOfSampleStatus = PVOPositionsStatus.InTheMiddle; for(int i = 0; i<this.chosenPVOPositions.Length; i++) { --- 580,587 ---- DateTime endOfOscillatingPeriod = Time.GetDateTimeFromMerge(this.now() , currentDailyTime); ! // this.positionsForOutOfSample = null; this.positionsForOutOfSampleStatus = PVOPositionsStatus.InTheMiddle; + this.lastInefficiencyTime = new Time("00:00:00"); for(int i = 0; i<this.chosenPVOPositions.Length; i++) { *************** *** 541,545 **** this.benchmark.Ticker, this.historicalMarketValueProviderForOutOfSample, this.oversoldThresholdMAX, this.overboughtThresholdMAX); ! }catch(Exception ex){string str = ex.ToString();} if(this.positionsForOutOfSampleStatus == PVOPositionsStatus.Oversold || --- 592,597 ---- this.benchmark.Ticker, this.historicalMarketValueProviderForOutOfSample, this.oversoldThresholdMAX, this.overboughtThresholdMAX); ! ! }catch(Exception ex){string str = ex.ToString();} if(this.positionsForOutOfSampleStatus == PVOPositionsStatus.Oversold || *************** *** 547,550 **** --- 599,603 ---- { this.positionsForOutOfSample = (PVOPositions)this.chosenPVOPositions[i]; + this.lastInefficiencyTime = currentDailyTime; i = this.chosenPVOPositions.Length;//exit from for } *************** *** 593,608 **** this.newDateTimeEventHandler_updateStopLossAndTakeProfitConditions(); this.newDateTimeEventHandler_closePositions(currentTime); if( currentTime < getLastEventTimeWithCachedBars() && currentTime >= getFirstEventTimeWithCachedBars().AddMinutes(inefficiencyLengthInMinutes) && ! this.chosenPVOPositions != null ) ! //it's possible to compute inefficiency and optimization ! //has been done ! { this.newDateTimeEventHandler_setPositionsAndStatus(currentTime); this.newDateTimeEventHandler_openPositions(currentTime); ! } if( currentTime == getLastEventTimeWithCachedBars() ) this.newDateTimeEventHandler_updateTestingPositions( dateTime ); } --- 646,674 ---- this.newDateTimeEventHandler_updateStopLossAndTakeProfitConditions(); this.newDateTimeEventHandler_closePositions(currentTime); + if( currentTime < getLastEventTimeWithCachedBars() && currentTime >= getFirstEventTimeWithCachedBars().AddMinutes(inefficiencyLengthInMinutes) && ! this.chosenPVOPositions != null && this.positionsForOutOfSample == null ) ! //it's possible to compute inefficiency and optimization has been done and no inefficiency ! //has been found this.newDateTimeEventHandler_setPositionsAndStatus(currentTime); + + if( currentTime == + this.lastInefficiencyTime.AddMinutes(this.minutesFromLastInefficiencyTimeToWaitBeforeOpening) && + this.newDateTimeEventHandler_inefficiencyIsMovingBack(currentTime) ) + //it's time for checking if inefficiency is moving back and the last inefficiency found is + //moving back this.newDateTimeEventHandler_openPositions(currentTime); ! if( currentTime == getLastEventTimeWithCachedBars() ) + //it's time for new optimization, if the case + { this.newDateTimeEventHandler_updateTestingPositions( dateTime ); + this.positionsForOutOfSample = null; + this.positionsForOutOfSampleStatus = PVOPositionsStatus.InTheMiddle; + this.lastInefficiencyTime = new Time(0,0,0); + } + } Index: PVOStrategyIntradayMain.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/PVOStrategyIntradayMain.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PVOStrategyIntradayMain.cs 1 Jan 2009 13:44:57 -0000 1.2 --- PVOStrategyIntradayMain.cs 12 Jan 2009 18:11:01 -0000 1.3 *************** *** 66,69 **** --- 66,70 ---- private double inefficiencyLengthInMinutes; private double maxOpeningLengthInMinutes; + private double minutesFromLastInefficiencyTimeToWaitBeforeOpening; private Timer timerForBackTester; private DateTime firstDateTime; *************** *** 74,78 **** { //this.benchmark = new Benchmark( "^GSPC" ); ! this.inefficiencyLengthInMinutes = 30; this.maxOpeningLengthInMinutes = 120; --- 75,80 ---- { //this.benchmark = new Benchmark( "^GSPC" ); ! this.inefficiencyLengthInMinutes = 120; ! this.minutesFromLastInefficiencyTimeToWaitBeforeOpening = 30; this.maxOpeningLengthInMinutes = 120; *************** *** 97,102 **** protected override IEligiblesSelector getEligiblesSelector() { ! ! int maxNumberOfEligiblesToBeChosen = 100; string tickersGroupId = "SP500"; --- 99,104 ---- protected override IEligiblesSelector getEligiblesSelector() { ! int maxNumberOfMostLiquidTickersToBeChosen = 100; ! int maxNumberOfEligiblesToBeChosen = 50; string tickersGroupId = "SP500"; *************** *** 104,112 **** bool temporizedGroup = true; int numDaysForAverageRawOpenPriceComputation = 10; ! double minPrice = 30; ! double maxPrice = 75; ! ! int maxNumberOfMostLiquidTickersToBeChosen = 150; ! int numDaysForVolatility = 10; // IEligiblesSelector eligiblesSelector = --- 106,113 ---- bool temporizedGroup = true; int numDaysForAverageRawOpenPriceComputation = 10; ! double minPrice = 25.0; ! double maxPrice = 500.0; ! ! int numDaysForVolatility = 15; // IEligiblesSelector eligiblesSelector = *************** *** 117,121 **** // minPrice , maxPrice, intervalFrameInSeconds , // this.benchmark.Ticker ); ! // IEligiblesSelector eligiblesSelector = new ByPriceMostLiquidLessVolatileOTCAlwaysQuoted( --- 118,122 ---- // minPrice , maxPrice, intervalFrameInSeconds , // this.benchmark.Ticker ); ! // LAST GOOD IEligiblesSelector eligiblesSelector = new ByPriceMostLiquidLessVolatileOTCAlwaysQuoted( *************** *** 160,164 **** double maxCorrelationAllowed = 0.96; int numberOfBestTestingPositionsToBeReturned = 50; ! numberOfBestTestingPositionsToBeReturned = 50; bool balancedWeightsOnVolatilityBase = true; float minimumAbsoluteReturnValue = 0.000001f; --- 161,165 ---- double maxCorrelationAllowed = 0.96; int numberOfBestTestingPositionsToBeReturned = 50; ! // numberOfBestTestingPositionsToBeReturned = 50; bool balancedWeightsOnVolatilityBase = true; float minimumAbsoluteReturnValue = 0.000001f; *************** *** 186,190 **** // inSampleChooser = // new PVOChooserFromSavedBackTestLog( ! // @"C:\Utente\MarcoVarie\Vari\qP\LogArchive\2008_05_04_18_54_45_PVO_OTC_from_2006_01_01_to_2008_04_28_annlRtrn_93.08_maxDD_5.18\2008_05_04_18_54_45_PVO_OTC_from_2006_01_01_to_2008_04_28_annlRtrn_93.08_maxDD_5.18.qpL", // numberOfBestTestingPositionsToBeReturned); return inSampleChooser; --- 187,191 ---- // inSampleChooser = // new PVOChooserFromSavedBackTestLog( ! // @"C:\Utente\MarcoVarie\Vari\qP\LogArchive\2009_01_07_18_51_09_PVOIntraday_from_2006_01_01_to_2007_12_31_annlRtrn_15.67_maxDD_2.91\2009_01_07_18_51_09_PVOIntraday_from_2006_01_01_to_2007_12_31_annlRtrn_15.67_maxDD_2.91.qpL", // numberOfBestTestingPositionsToBeReturned); return inSampleChooser; *************** *** 194,206 **** { //int inSampleDays = 90; ! int inSampleDays = 150; int numDaysBetweenEachOptimization = 5; int minNumOfEligiblesForValidOptimization = 20; ! double oversoldThreshold = 0.0065; ! double overboughtThreshold = 0.0065; ! double oversoldThresholdMAX = 0.02; ! double overboughtThresholdMAX = 0.02; ! double stopLoss = 0.02; ! double takeProfit = 0.005; IStrategyForBacktester strategyForBacktester --- 195,207 ---- { //int inSampleDays = 90; ! int inSampleDays = 120; int numDaysBetweenEachOptimization = 5; int minNumOfEligiblesForValidOptimization = 20; ! double oversoldThreshold = 0.0055; ! double overboughtThreshold = 0.0055; ! double oversoldThresholdMAX = 0.015; ! double overboughtThresholdMAX = 0.015; ! double stopLoss = 0.01; ! double takeProfit = 0.0045; IStrategyForBacktester strategyForBacktester *************** *** 216,220 **** historicalMarketValueProviderForInSample, historicalMarketValueProviderForOutOfSample, ! inefficiencyLengthInMinutes , maxOpeningLengthInMinutes, this.getDailyTimes(), stopLoss , takeProfit ); return strategyForBacktester; --- 217,223 ---- historicalMarketValueProviderForInSample, historicalMarketValueProviderForOutOfSample, ! inefficiencyLengthInMinutes , ! this.minutesFromLastInefficiencyTimeToWaitBeforeOpening, ! maxOpeningLengthInMinutes, this.getDailyTimes(), stopLoss , takeProfit ); return strategyForBacktester; *************** *** 237,240 **** --- 240,244 ---- dailyTimes.Add(new Time("14:30:00") ); dailyTimes.Add(new Time("15:00:00") ); + dailyTimes.Add(new Time("15:30:00") ); dailyTimes.Add(new Time("16:00:00") ); return dailyTimes; Index: PVOPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/PVOPositions.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PVOPositions.cs 29 Sep 2008 21:18:13 -0000 1.4 --- PVOPositions.cs 12 Jan 2009 18:11:01 -0000 1.5 *************** *** 128,132 **** --- 128,134 ---- string benchmark, HistoricalMarketValueProvider quoteProvider, + double oversoldThreshold, double maxOversoldThreshold, + double overboughtThreshold, double maxOverboughtThreshold) { *************** *** 136,143 **** this.getOscillatingPeriodReturn(beginOfPeriod, endOfPeriod, benchmark, quoteProvider); ! if(oscillatingPeriodReturn >= this.overboughtThreshold && oscillatingPeriodReturn <= maxOverboughtThreshold) returnValue = PVOPositionsStatus.Overbought; ! else if(oscillatingPeriodReturn <= -this.oversoldThreshold && Math.Abs(oscillatingPeriodReturn) <= maxOversoldThreshold) returnValue = PVOPositionsStatus.Oversold; --- 138,145 ---- this.getOscillatingPeriodReturn(beginOfPeriod, endOfPeriod, benchmark, quoteProvider); ! if(oscillatingPeriodReturn >= overboughtThreshold && oscillatingPeriodReturn <= maxOverboughtThreshold) returnValue = PVOPositionsStatus.Overbought; ! else if(oscillatingPeriodReturn <= -oversoldThreshold && Math.Abs(oscillatingPeriodReturn) <= maxOversoldThreshold) returnValue = PVOPositionsStatus.Oversold; *************** *** 151,154 **** --- 153,169 ---- } + public PVOPositionsStatus GetStatus(DateTime beginOfPeriod, + DateTime endOfPeriod, + string benchmark, + HistoricalMarketValueProvider quoteProvider, + double maxOversoldThreshold, + double maxOverboughtThreshold) + { + return this.GetStatus(beginOfPeriod, endOfPeriod, + benchmark, quoteProvider, + this.oversoldThreshold, maxOversoldThreshold, + this.overboughtThreshold, maxOverboughtThreshold ); + } + public bool AreAllTickersMovingTogetherUpOrDown(DateTime beginOfPeriod, DateTime endOfPeriod, |
|
From: Glauco S. <gla...@us...> - 2009-01-11 20:38:26
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/DatabaseManagement In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17077/Downloader/OpenTickDownloader/DatabaseManagement Modified Files: DataBaseWriter.cs Log Message: Old commented code has been removed Index: DataBaseWriter.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/DatabaseManagement/DataBaseWriter.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DataBaseWriter.cs 4 Jan 2009 17:46:44 -0000 1.3 --- DataBaseWriter.cs 11 Jan 2009 20:38:14 -0000 1.4 *************** *** 82,123 **** } - // #region getSqlCommand - // - // #region getSqlCommand_getValues - // 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 + "' , " + - // DataBaseWriter.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 ) { --- 82,85 ---- *************** *** 127,133 **** bar.Ticker , bar.Exchange , dateTimeForOpenInESTTime , bar.Interval , bar.Open , bar.High , bar.Low , bar.Close , bar.Volume ); - // string sqlCommand = - // this.getSqlCommand( bar ); - // SqlExecutor.ExecuteNonQuery( sqlCommand ); } private void riseDatabaseUpdatedEvent( Bar bar ) --- 89,92 ---- *************** *** 173,195 **** this.writeToDataBaseThread.Start(); } - - // /// <summary> - // /// Builds a date to be used in a Sql query - // /// </summary> - // /// <param name="dateTime"></param> - // /// <returns></returns> - // public static string GetDateConstant( DateTime dateTime ) - // { - // string dateConstant = - // "#" + - // dateTime.Month + "/" + - // dateTime.Day + "/" + - // dateTime.Year + " " + - // dateTime.Hour + ":" + - // dateTime.Minute + ":" + - // dateTime.Second + - // "#"; - // return dateConstant; - // } } } --- 132,135 ---- |
|
From: Glauco S. <gla...@us...> - 2009-01-11 20:38:22
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17077/Downloader/OpenTickDownloader Modified Files: BarQueueFiller.cs BarsDownloader.cs Log Message: Old commented code has been removed Index: BarsDownloader.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/BarsDownloader.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BarsDownloader.cs 20 Jul 2008 20:30:06 -0000 1.2 --- BarsDownloader.cs 11 Jan 2009 20:38:14 -0000 1.3 *************** *** 3,7 **** BarsDownloader.cs ! Copyright (C) 2008 Glauco Siliprandi --- 3,7 ---- BarsDownloader.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; --- 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; *************** *** 48,66 **** 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 --- 48,55 ---- *************** *** 82,92 **** string openTickUser , string openTickPassword - // , - // string ticker , - // DateTime firstDate , - // DateTime lastDate , - // int barInterval , - // DateTime firstBarOpenTime , - // int numberOfBarsToBeDownloadedForEachDay ) { --- 71,74 ---- *************** *** 96,123 **** 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() { --- 78,84 ---- *************** *** 147,158 **** this.exchangeSelector , this.oTManager , ! // this.ticker , ! // this.mainExchangeFinder.MainExchange , ! // this.firstDate , ! // this.lastDate , ! // this.barInterval , ! // this.firstBarOpenTime , ! // this.numberOfBarsToBeDownloadedForEachDay , ! this.barQueue ); this.barQueueFiller.NewOHLCRequest += --- 108,112 ---- this.exchangeSelector , this.oTManager , ! this.barQueue ); this.barQueueFiller.NewOHLCRequest += *************** *** 198,217 **** 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(); } --- 152,158 ---- private void onLoginEventHandler() { ! this.initializeDownloadingObjects(); ! this.startThreadToFillBarQueue(); ! this.startThreadToWriteBarsFromBuffersToTheDatabase(); } Index: BarQueueFiller.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/BarQueueFiller.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** BarQueueFiller.cs 18 Aug 2008 21:03:52 -0000 1.3 --- BarQueueFiller.cs 11 Jan 2009 20:38:14 -0000 1.4 *************** *** 47,57 **** 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; --- 47,50 ---- *************** *** 59,64 **** private Thread fillQueueThread; - // private bool working; - // private DateTime currentDate; /// <summary> --- 52,55 ---- *************** *** 84,94 **** IExchangeSelector exchangeSelector , OTManager oTManager , - // string ticker , - // string exchange , - // DateTime firstDate , - // DateTime lastDate , - // long barInterval , - // DateTime firstBarOpenTime , - // int numberOfBarsToBeDownloadedForEachDay , BarQueue barQueue ) --- 75,78 ---- *************** *** 103,114 **** 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; } --- 87,90 ---- *************** *** 167,181 **** #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_requestBar private void fillQueue_requestBar_actually( --- 143,147 ---- #region fillQueue_requestBarsForEachMarketDay ! #region fillQueue_requestBar private void fillQueue_requestBar_actually( *************** *** 207,218 **** this.fillQueue_requestBar_actually( barIdentifier , exchange ); } - // private void fillQueue_requestBars( DateTime currentDate ) - // { - // for ( int currentDailyBarIndex = 0 ; - // currentDailyBarIndex < this.numberOfBarsToBeDownloadedForEachDay ; - // currentDailyBarIndex++ ) - // this.fillQueue_requestBar( - // currentDate , currentDailyBarIndex ); - // } #endregion fillQueue_requestBar --- 173,176 ---- *************** *** 222,232 **** 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 --- 180,183 ---- |
|
From: Glauco S. <gla...@us...> - 2009-01-11 20:38:21
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/OTManagement In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17077/Downloader/OpenTickDownloader/OTManagement Modified Files: OTManager.cs Log Message: Old commented code has been removed Index: OTManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/OTManagement/OTManager.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** OTManager.cs 30 Nov 2008 22:42:37 -0000 1.3 --- OTManager.cs 11 Jan 2009 20:38:14 -0000 1.4 *************** *** 68,77 **** private static OTClient oTClient; - /// <summary> - /// used to lock OTManager.oTClient: we use a dummy BarRequest - /// but any reference type would have done the job - /// </summary> - // private static BarRequest oTClientCreatorLocker = - // new BarRequest( "A" , "A" , new DateTime( 1 , 1 , 2008 ) ); static OTManager() --- 68,71 ---- *************** *** 105,109 **** public OTManager() { - // this.logFileName = ""; this.commonInitialization(); } --- 99,102 ---- *************** *** 181,187 **** { BarRequest barRequest = this.GetBarRequest( requestId ); - // DateTime dateTimeForRequest = (DateTime) - // this.requestsThatAreNotCompletedYet[ requestId ]; - // this.requestsThatAreNotCompletedYet.Remove( requestId ); string completeMessage = message + "---" + "Ticker: " + oTDataEntity.Symbol + "---" + --- 174,177 ---- *************** *** 281,293 **** OTManager.oTClient.onMessage += new OTMessageEvent( this.onMessageEventHandler ); - // if ( oTClientWasJustCreated ) - // // oTClient was null. We want only one OTManager instance - // // to monitor (and possibly log) oTClient status changes - // { - // OTManager.oTClient.onLogin += new OTLoginEvent( - // OTManager.onLoginEventHandler ); - // OTManager.oTClient.onStatusChanged += new OTStatusChangedEvent( - // OTManager.onStatusChangedEventHandler ); - // } OTManager.oTClient.onHistoricalOHLC += new OTOHLCEvent( this.onHistoricalOHLC ); --- 271,274 ---- *************** *** 310,342 **** OTManager.oTClient.addHost( "feed1.opentick.com" , 10010 ); //OTManager.oTClient.addHost( "delayed1.opentick.com" , 10010 ); - // string username = - // System.Configuration.ConfigurationManager.AppSettings[ - // "usrnm" ]; - // string password = - // System.Configuration.ConfigurationManager.AppSettings[ - // "pswd" ]; OTManager.oTClient.login( openTickUser , openTickPassword ); } - // /// <summary> - // /// This method can be - // /// </summary> - // public void SubmitLogin() - // { - // bool oTCLientWasNullWhenThisMethodBegan; - // // TO DO add a lock to the following two statements - //// lock( ??? what could I use here??? ) - //// { - //// oTCLientWasNullWhenThisMethodBegan = - //// ( OTManager.oTClient == null ); - //// if ( oTCLientWasNullWhenThisMethodBegan ) - //// OTManager.oTClient = new OTClient(); - //// } - // this.setOTClientEventHandlers( oTCLientWasNullWhenThisMethodBegan ); - // if ( oTCLientWasNullWhenThisMethodBegan ) - // this.submitLogin(); - // } - - - public BarRequest GetBarRequest( int requestId ) --- 291,296 ---- |
|
From: Glauco S. <gla...@us...> - 2009-01-11 20:37:56
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17034/Downloader/OpenTickDownloader Modified Files: OTTickerDownloader.cs Log Message: - old commented code has been removed - the log creation statement has been commented out Index: OTTickerDownloader.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/OTTickerDownloader.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** OTTickerDownloader.cs 7 Jan 2009 23:27:15 -0000 1.6 --- OTTickerDownloader.cs 11 Jan 2009 20:37:47 -0000 1.7 *************** *** 46,62 **** private List<Time> dailyTimes; 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 --- 46,53 ---- *************** *** 110,118 **** List<Time> dailyTimes , DateTime firstDate, - // int fromHour , - // int fromMinute , - // int fromSecond , int barInterval , - // int numberOfDailyBars , DateTime dateTimeForOverWritingQuotes, bool checkForMissingQuotes, --- 101,105 ---- *************** *** 133,141 **** this.dailyTimes = dailyTimes; 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; --- 120,124 ---- *************** *** 203,208 **** this.barInterval , this.dailyTimes ); - // this.firstBarOpenTimeInNewYorkTimeZone , - // this.numberOfDailyBars ); else // all quotes are to be downloaded, even if they --- 186,189 ---- *************** *** 215,220 **** this.barInterval , this.dailyTimes ); - // this.firstBarOpenTimeInNewYorkTimeZone , - // this.numberOfDailyBars ); } private void setExchangeSelector() --- 196,199 ---- *************** *** 244,255 **** 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( --- 223,226 ---- *************** *** 259,265 **** this.openTickPassword ); this.setBarsDownloader_setEventHandlers(); - // this.barsDownloader.NewOHLCRequest += - // new NewOHLCRequestEventHandler ( - // this.newOHLCRequestEventHandler ); } #endregion setBarsDownloader --- 230,233 ---- *************** *** 281,286 **** this.messageManager = new MessageManager( this.getLogFileName() ); ! this.messageManager.Monitor( ! this.barsDownloader ); } #endregion setMessageManager --- 249,254 ---- this.messageManager = new MessageManager( this.getLogFileName() ); ! // uncomment the following line if you want to see the log file ! // this.messageManager.Monitor( this.barsDownloader ); } #endregion setMessageManager |
|
From: Glauco S. <gla...@us...> - 2009-01-11 20:16:42
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv15676/b2_DataAccess Modified Files: DataBase.cs Log Message: A new boolean method has been added to detect if a given exception is due to an attempt to insert a record that would lead to a duplicate a key in the database Index: DataBase.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/DataBase.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** DataBase.cs 30 Dec 2008 00:11:44 -0000 1.13 --- DataBase.cs 11 Jan 2009 20:16:35 -0000 1.14 *************** *** 29,32 **** --- 29,34 ---- using System.Windows.Forms; + using MySql.Data.MySqlClient; + using QuantProject.ADT; using QuantProject.ADT.Histories; *************** *** 308,311 **** --- 310,337 ---- } #endregion GetBarOpenHistory + + /// <summary> + /// true iif exception is risen by the attempt to duplicate a value in + /// a table + /// </summary> + /// <param name="exception"></param> + /// <returns></returns> + public static bool IsExceptionForForbiddenDataDuplication( + Exception exception ) + { + bool isExceptionForForbiddenDataDuplication = + ( + ( + ( exception is OleDbException ) && + exception.Message.Contains( "duplicate values" ) + ) + || + ( + ( exception is MySqlException ) && + exception.Message.Contains( "Duplicate entry" ) + ) + ); + return isExceptionForForbiddenDataDuplication; + } } } |
|
From: Glauco S. <gla...@us...> - 2009-01-11 20:15:29
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv15587/b2_DataAccess/Tables Modified Files: Bars.cs Log Message: If a duplicate bar is asked to be inserted, now the exception is handled (and the program can go on) Index: Bars.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables/Bars.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Bars.cs 7 Jan 2009 23:23:07 -0000 1.5 --- Bars.cs 11 Jan 2009 20:15:17 -0000 1.6 *************** *** 537,541 **** ticker , exchange , dateTimeForOpenInESTTime , interval , open , high , low , close , volume ); ! SqlExecutor.ExecuteNonQuery( sqlCommand ); } #endregion AddBar --- 537,550 ---- ticker , exchange , dateTimeForOpenInESTTime , interval , open , high , low , close , volume ); ! try ! { ! SqlExecutor.ExecuteNonQuery( sqlCommand ); ! } ! catch( Exception exception ) ! { ! if ( !DataBase.IsExceptionForForbiddenDataDuplication( exception ) ) ! // the exception is not due to a duplicated bar ! throw exception; ! } } #endregion AddBar |
|
From: Glauco S. <gla...@us...> - 2009-01-07 23:28:30
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/UserForms In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv23797/Downloader/OpenTickDownloader/UserForms Modified Files: OTWebDownloader.cs Log Message: the form now downloads (not necessarily adiacent) daily bars according to a given list of Time(s) Index: OTWebDownloader.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/UserForms/OTWebDownloader.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** OTWebDownloader.cs 6 Jan 2009 17:24:33 -0000 1.7 --- OTWebDownloader.cs 7 Jan 2009 23:28:20 -0000 1.8 *************** *** 461,470 **** new OTTickerDownloader( this.TickersToDownload, ! this.StartingNewYorkDateTime, ! this.CheckedDailyTimes[0].Hour , ! this.CheckedDailyTimes[0].Minute , ! this.CheckedDailyTimes[0].Second , Convert.ToInt32( this.timeFrameInSeconds.Value ) , ! 1 , this.dateTimeOverwriteQuotesBefore.Value, this.checkBoxCheckingForMissingQuotes.Checked, --- 461,472 ---- new OTTickerDownloader( this.TickersToDownload, ! this.CheckedDailyTimes , ! this.dateTimePickerStartingDate.Value , ! // this.StartingNewYorkDateTime, ! // this.CheckedDailyTimes[0].Hour , ! // this.CheckedDailyTimes[0].Minute , ! // this.CheckedDailyTimes[0].Second , Convert.ToInt32( this.timeFrameInSeconds.Value ) , ! // 1 , this.dateTimeOverwriteQuotesBefore.Value, this.checkBoxCheckingForMissingQuotes.Checked, |
|
From: Glauco S. <gla...@us...> - 2009-01-07 23:27:32
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv23732/Downloader/OpenTickDownloader Modified Files: OTTickerDownloader.cs Log Message: the class now downloads (not necessarely adiacent) daily bars according to a given list of Time(s) Index: OTTickerDownloader.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/OTTickerDownloader.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** OTTickerDownloader.cs 3 Jan 2009 18:38:31 -0000 1.5 --- OTTickerDownloader.cs 7 Jan 2009 23:27:15 -0000 1.6 *************** *** 21,24 **** --- 21,25 ---- */ using System; + using System.Collections.Generic; using System.Data; using System.Threading; *************** *** 26,29 **** --- 27,31 ---- using QuantProject.ADT; + using QuantProject.ADT.Timing; using QuantProject.Presentation; *************** *** 42,59 **** { 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 --- 44,62 ---- { private string[] tickersToDownload; + private List<Time> dailyTimes; 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 *************** *** 105,114 **** public OTTickerDownloader( string[] tickersToDownload, DateTime firstDate, ! int fromHour , ! int fromMinute , ! int fromSecond , int barInterval , ! int numberOfDailyBars , DateTime dateTimeForOverWritingQuotes, bool checkForMissingQuotes, --- 108,118 ---- public OTTickerDownloader( string[] tickersToDownload, + List<Time> dailyTimes , DateTime firstDate, ! // int fromHour , ! // int fromMinute , ! // int fromSecond , int barInterval , ! // int numberOfDailyBars , DateTime dateTimeForOverWritingQuotes, bool checkForMissingQuotes, *************** *** 127,136 **** 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; --- 131,141 ---- openTickPassword); this.tickersToDownload = tickersToDownload; + this.dailyTimes = dailyTimes; 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; *************** *** 197,202 **** this.setBarsSelector_getDate( DateTime.Now ) , this.barInterval , ! this.firstBarOpenTimeInNewYorkTimeZone , ! this.numberOfDailyBars ); else // all quotes are to be downloaded, even if they --- 202,208 ---- this.setBarsSelector_getDate( DateTime.Now ) , this.barInterval , ! this.dailyTimes ); ! // this.firstBarOpenTimeInNewYorkTimeZone , ! // this.numberOfDailyBars ); else // all quotes are to be downloaded, even if they *************** *** 208,218 **** this.setBarsSelector_getDate( DateTime.Now ) , this.barInterval , ! this.firstBarOpenTimeInNewYorkTimeZone , ! this.numberOfDailyBars ); } private void setExchangeSelector() { ! this.exchangeSelector = ! new MostLiquidExchangeSelector(); } #region setBarsDownloaderAndRunIt --- 214,225 ---- this.setBarsSelector_getDate( DateTime.Now ) , this.barInterval , ! this.dailyTimes ); ! // this.firstBarOpenTimeInNewYorkTimeZone , ! // this.numberOfDailyBars ); } private void setExchangeSelector() { ! this.exchangeSelector = ! new MostLiquidExchangeSelector(); } #region setBarsDownloaderAndRunIt *************** *** 264,268 **** // @"C:\Quant\OpenTickDownloader\textFilesForLoggingNotification\textFileForLoggingNotification"; string logFileName = ! Application.StartupPath + "\\textFileForLoggingNotification"; logFileName = logFileName + "_" + ExtendedDateTime.GetCompleteShortDescriptionForFileName( --- 271,275 ---- // @"C:\Quant\OpenTickDownloader\textFilesForLoggingNotification\textFileForLoggingNotification"; string logFileName = ! Application.StartupPath + "\\textFileForLoggingNotification"; logFileName = logFileName + "_" + ExtendedDateTime.GetCompleteShortDescriptionForFileName( |
|
From: Glauco S. <gla...@us...> - 2009-01-07 23:25:56
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/BarsSelectors In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv23628/Downloader/OpenTickDownloader/BarsSelectors Modified Files: MissingDailyBarsSelector.cs Log Message: the class now selects missing daily bars according to a given list of Time(s) Index: MissingDailyBarsSelector.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/BarsSelectors/MissingDailyBarsSelector.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MissingDailyBarsSelector.cs 4 Jan 2009 17:47:57 -0000 1.2 --- MissingDailyBarsSelector.cs 7 Jan 2009 23:25:44 -0000 1.3 *************** *** 23,26 **** --- 23,27 ---- using System; using System.Collections; + using System.Collections.Generic; using System.Data; *************** *** 55,60 **** DateTime lastDate , int barInterval , ! DateTime firstBarOpenTimeInNewYorkTimeZone , ! int numberOfBarsToBeDownloadedForEachDay ) : base( tickers , --- 56,63 ---- DateTime lastDate , int barInterval , ! List<Time> dailyTimes ) : ! ! // DateTime firstBarOpenTimeInNewYorkTimeZone , ! // int numberOfBarsToBeDownloadedForEachDay ) : base( tickers , *************** *** 62,67 **** lastDate , barInterval , ! firstBarOpenTimeInNewYorkTimeZone , ! numberOfBarsToBeDownloadedForEachDay ) { } --- 65,71 ---- lastDate , barInterval , ! dailyTimes ) ! // firstBarOpenTimeInNewYorkTimeZone , ! // numberOfBarsToBeDownloadedForEachDay ) { } *************** *** 114,138 **** ! private Time getLastBarOpenTimeInNewYorkTimeZone() ! { ! int secondsToBeAdded = this.barInterval * ! ( this.numberOfBarsToBeDownloadedForEachDay - 1 ); ! DateTime lastBarOpenDateTimeInNewYorkTimeZone = ! this.firstBarOpenTimeInNewYorkTimeZone.AddSeconds( ! secondsToBeAdded ); ! Time lastBarOpenTimeInNewYorkTimeZone = ! new Time( lastBarOpenDateTimeInNewYorkTimeZone ); ! return lastBarOpenTimeInNewYorkTimeZone; ! } private DataTable getBarsInTheDatabase( string ticker ) { ! Time lastBarOpenTimeInNewYorkTimeZone = ! this.getLastBarOpenTimeInNewYorkTimeZone(); DataTable barsInTheDatabase = new QuantProject.Data.DataTables.Bars( ticker , this.firstDate , this.lastDate , ! new Time( this.firstBarOpenTimeInNewYorkTimeZone ) , ! lastBarOpenTimeInNewYorkTimeZone , this.barInterval ); // string sql = --- 118,146 ---- ! // private Time getLastBarOpenTimeInNewYorkTimeZone() ! // { ! //// int secondsToBeAdded = this.barInterval * ! //// ( this.numberOfBarsToBeDownloadedForEachDay - 1 ); ! //// DateTime lastBarOpenDateTimeInNewYorkTimeZone = ! //// this.firstBarOpenTimeInNewYorkTimeZone.AddSeconds( ! //// secondsToBeAdded ); ! //// Time lastBarOpenTimeInNewYorkTimeZone = ! //// new Time( lastBarOpenDateTimeInNewYorkTimeZone ); ! // int indexForTheLastDailyTime = this.dailyTimes.Count - 1; ! // Time lastBarOpenTimeInNewYorkTimeZone = ! // this.dailyTimes[ indexForTheLastDailyTime ]; ! // return lastBarOpenTimeInNewYorkTimeZone; ! // } private DataTable getBarsInTheDatabase( string ticker ) { ! // Time lastBarOpenTimeInNewYorkTimeZone = ! // this.getLastBarOpenTimeInNewYorkTimeZone(); DataTable barsInTheDatabase = new QuantProject.Data.DataTables.Bars( ticker , this.firstDate , this.lastDate , ! this.dailyTimes , ! // new Time( this.firstBarOpenTimeInNewYorkTimeZone ) , ! // lastBarOpenTimeInNewYorkTimeZone , this.barInterval ); // string sql = |
|
From: Glauco S. <gla...@us...> - 2009-01-07 23:25:32
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/BarsSelectors In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv23591/Downloader/OpenTickDownloader/BarsSelectors Modified Files: DailyBarsSelector.cs Log Message: the class now selects daily bars according to a given list of Time(s) Index: DailyBarsSelector.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/BarsSelectors/DailyBarsSelector.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DailyBarsSelector.cs 3 Jan 2009 18:45:12 -0000 1.3 --- DailyBarsSelector.cs 7 Jan 2009 23:25:18 -0000 1.4 *************** *** 3,7 **** DailyBarsSelector.cs ! Copyright (C) 2008 Glauco Siliprandi --- 3,7 ---- DailyBarsSelector.cs ! Copyright (C) 2008 Glauco Siliprandi *************** *** 19,26 **** 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 --- 19,29 ---- 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 QuantProject.ADT.Timing; namespace QuantProject.Applications.Downloader.OpenTickDownloader *************** *** 38,43 **** /// </summary> protected int barInterval; ! protected DateTime firstBarOpenTimeInNewYorkTimeZone; ! protected int numberOfBarsToBeDownloadedForEachDay; /// <summary> --- 41,47 ---- /// </summary> protected int barInterval; ! protected List<Time> dailyTimes; ! // protected DateTime firstBarOpenTimeInNewYorkTimeZone; ! // protected int numberOfBarsToBeDownloadedForEachDay; /// <summary> *************** *** 50,54 **** /// </summary> private int currentDailyBar; ! public bool AreAllBarsAlredyGiven { --- 54,58 ---- /// </summary> private int currentDailyBar; ! public bool AreAllBarsAlredyGiven { *************** *** 58,63 **** ( this.currentTickerIndex == ( this.tickers.Length - 1 ) ) && ( ( this.currentDate.CompareTo( this.lastDate ) == 0 ) && ! ( this.currentDailyBar == ! this.numberOfBarsToBeDownloadedForEachDay - 1 ) ); return areAllBarsAlredyGiven; } } --- 62,68 ---- ( this.currentTickerIndex == ( this.tickers.Length - 1 ) ) && ( ( this.currentDate.CompareTo( this.lastDate ) == 0 ) && ! ( this.currentDailyBar == ! this.dailyTimes.Count - 1 ) ); ! // this.numberOfBarsToBeDownloadedForEachDay - 1 ) ); return areAllBarsAlredyGiven; } } *************** *** 82,90 **** DateTime lastDate , int barInterval , ! DateTime firstBarOpenTimeInNewYorkTimeZone , ! int numberOfBarsToBeDownloadedForEachDay ) { this.checkParameters( ! firstDate , lastDate , numberOfBarsToBeDownloadedForEachDay ); this.tickers = tickers; --- 87,97 ---- DateTime lastDate , int barInterval , ! List<Time> dailyTimes ) ! // DateTime firstBarOpenTimeInNewYorkTimeZone , ! // int numberOfBarsToBeDownloadedForEachDay ) { this.checkParameters( ! firstDate , lastDate , dailyTimes ); ! // numberOfBarsToBeDownloadedForEachDay ); this.tickers = tickers; *************** *** 92,104 **** 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(); --- 99,113 ---- this.lastDate = lastDate; this.barInterval = barInterval; ! this.dailyTimes = dailyTimes; ! // this.firstBarOpenTimeInNewYorkTimeZone = ! // firstBarOpenTimeInNewYorkTimeZone; ! // this.numberOfBarsToBeDownloadedForEachDay = ! // numberOfBarsToBeDownloadedForEachDay; this.currentTickerIndex = 0; this.currentDate = this.firstDate.AddDays( - 1 ); this.currentDailyBar = ! this.dailyTimes.Count - 1; ! // numberOfBarsToBeDownloadedForEachDay - 1; this.moveToTheNextSelectedBar(); *************** *** 116,128 **** 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 --- 125,141 ---- private void checkParameters( DateTime firstDate , DateTime lastDate , ! List<Time> dailyTimes ) ! // int numberOfBarsToBeDownloadedForEachDay ) { this.checkParameters_checkNoTime( firstDate ); this.checkParameters_checkNoTime( lastDate ); if ( firstDate.CompareTo( lastDate ) > 0 ) ! throw new Exception( "firstDate cannot follow lastDate" ); ! if ( dailyTimes.Count == 0 ) throw new Exception( ! "At least one daily bar has to be chosen" ); ! // if ( numberOfBarsToBeDownloadedForEachDay <= 0 ) ! // throw new Exception( ! // "numberOfBarsToBeDownloadedForEachDay must be greater than zero!" ); } #endregion checkParameters *************** *** 161,165 **** { if ( this.currentDailyBar == ! ( this.numberOfBarsToBeDownloadedForEachDay - 1 ) ) // the current bar identifier is the last one for the // current (ticker,date) --- 174,179 ---- { if ( this.currentDailyBar == ! ( this.dailyTimes.Count - 1 ) ) ! // ( this.numberOfBarsToBeDownloadedForEachDay - 1 ) ) // the current bar identifier is the last one for the // current (ticker,date) *************** *** 210,214 **** // !this.isTheCurrentBarSelectable() ) while ( !this.AreAllBarsAlredyGiven && ! !this.isTheCurrentBarSelectable() ) this.doNextStep(); // DateTime currentDate = this.firstDate; --- 224,228 ---- // !this.isTheCurrentBarSelectable() ) while ( !this.AreAllBarsAlredyGiven && ! !this.isTheCurrentBarSelectable() ) this.doNextStep(); // DateTime currentDate = this.firstDate; *************** *** 232,235 **** --- 246,250 ---- protected DateTime getDateTimeForCurrentCandidateBarOpenInNewYorkTimeZone() { + Time currentDailyTime = this.dailyTimes[ this.currentDailyBar ]; DateTime dateTimeForCurrentCandidateBarOpenInNewYorkTimeZone = new DateTime( *************** *** 237,244 **** currentDate.Month , currentDate.Day , ! this.firstBarOpenTimeInNewYorkTimeZone.Hour , ! this.firstBarOpenTimeInNewYorkTimeZone.Minute , ! this.firstBarOpenTimeInNewYorkTimeZone.Second ).AddSeconds( ! this.currentDailyBar * this.barInterval ); return dateTimeForCurrentCandidateBarOpenInNewYorkTimeZone; } --- 252,262 ---- currentDate.Month , currentDate.Day , ! currentDailyTime.Hour , ! currentDailyTime.Minute , ! currentDailyTime.Second ); ! // this.firstBarOpenTimeInNewYorkTimeZone.Hour , ! // this.firstBarOpenTimeInNewYorkTimeZone.Minute , ! // this.firstBarOpenTimeInNewYorkTimeZone.Second ).AddSeconds( ! // this.currentDailyBar * this.barInterval ); return dateTimeForCurrentCandidateBarOpenInNewYorkTimeZone; } |
|
From: Glauco S. <gla...@us...> - 2009-01-07 23:24:11
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataTables In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv23478/b3_Data/DataTables Modified Files: Bars.cs Log Message: - a new constructor has been added, to fill the DataTable with daily bars selected by a list of Time(s) Index: Bars.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataTables/Bars.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Bars.cs 4 Jan 2009 17:50:22 -0000 1.5 --- Bars.cs 7 Jan 2009 23:23:54 -0000 1.6 *************** *** 74,78 **** } - #region Bars /// <summary> /// returns all daily bars between firstBarOpenTimeInNewYorkTimeZone and --- 74,77 ---- *************** *** 96,100 **** this.setPrimaryKeys(); } ! #endregion Bars --- 95,117 ---- this.setPrimaryKeys(); } ! ! /// <summary> ! /// returns all daily bars at the given daily times ! /// </summary> ! /// <param name="ticker"></param> ! /// <param name="startDateTime"></param> ! /// <param name="endDateTime"></param> ! /// <param name="dailyTimes"></param> ! /// <param name="intervalFrameInSeconds"></param> ! public Bars( ! string ticker , DateTime startDateTime , DateTime endDateTime , ! List<Time> dailyTimes , int intervalFrameInSeconds ) ! { ! QuantProject.DataAccess.Tables.Bars.SetDataTable( ! ticker , startDateTime , endDateTime , ! dailyTimes , ! this , intervalFrameInSeconds ); ! this.setPrimaryKeys(); ! } |
|
From: Glauco S. <gla...@us...> - 2009-01-07 23:23:25
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv23410/b2_DataAccess/Tables Modified Files: Bars.cs Log Message: - the method public static void SetDataTable() has been overloaded to fill the DataTable with daily bars selected by a list of Time(s) - all the class' code has been reindentent Index: Bars.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables/Bars.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Bars.cs 4 Jan 2009 17:49:26 -0000 1.4 --- Bars.cs 7 Jan 2009 23:23:07 -0000 1.5 *************** *** 3,7 **** Bars.cs ! Copyright (C) 2008 Marco Milletti --- 3,7 ---- Bars.cs ! Copyright (C) 2008 Marco Milletti *************** *** 19,26 **** along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ using System; using System.Collections; using System.Data; using System.Text; --- 19,27 ---- along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ using System; using System.Collections; + using System.Collections.Generic; using System.Data; using System.Text; *************** *** 38,45 **** public class Bars { ! // these static fields provide field name in the database table // They are intended to be used through intellisense when necessary public static string TickerFieldName = "baTicker"; // Ticker cannot be simply used because ! public static string Exchange = "baExchange"; public static string DateTimeForOpen = "baDateTimeForOpen"; public static string IntervalFrameInSeconds = "baInterval"; --- 39,46 ---- public class Bars { ! // these static fields provide field name in the database table // They are intended to be used through intellisense when necessary public static string TickerFieldName = "baTicker"; // Ticker cannot be simply used because ! public static string Exchange = "baExchange"; public static string DateTimeForOpen = "baDateTimeForOpen"; public static string IntervalFrameInSeconds = "baInterval"; *************** *** 48,53 **** public static string Low = "baLow"; public static string Close = "baClose"; ! public static string Volume = "baVolume"; ! public Bars( string ticker) { --- 49,54 ---- public static string Low = "baLow"; public static string Close = "baClose"; ! public static string Volume = "baVolume"; ! public Bars( string ticker) { *************** *** 69,73 **** DataTable dataTable = SqlExecutor.GetDataTable( "select min(" + Bars.DateTimeForOpen + ") as minDate from bars " + ! "where " + Bars.TickerFieldName + "='" + ticker + "' and " + Bars.IntervalFrameInSeconds + "='" + intervalFrameInSeconds + "' " + "group by " + Bars.TickerFieldName + ")" ); --- 70,74 ---- DataTable dataTable = SqlExecutor.GetDataTable( "select min(" + Bars.DateTimeForOpen + ") as minDate from bars " + ! "where " + Bars.TickerFieldName + "='" + ticker + "' and " + Bars.IntervalFrameInSeconds + "='" + intervalFrameInSeconds + "' " + "group by " + Bars.TickerFieldName + ")" ); *************** *** 83,219 **** { DataTable dataTable = SqlExecutor.GetDataTable( ! "select * from bars where " + Bars.TickerFieldName + "='" + ticker + "' and " + Bars.IntervalFrameInSeconds + "='" + intervalFrameInSeconds + "' " + "order by " + Bars.DateTimeForOpen + " DESC"); return (DateTime)(dataTable.Rows[0][ Bars.DateTimeForOpen ]); } ! /// <summary> ! /// Returns the number of Bars for the given ticker ! /// </summary> ! /// <param name="ticker">ticker for which the number of bars has to be returned</param> ! /// <param name="intervalFrameInSeconds">interval frame in seconds for the ticker's bars</param> ! /// <returns></returns> ! public static int GetNumberOfBars( string ticker, int intervalFrameInSeconds ) ! { ! DataTable dataTable = SqlExecutor.GetDataTable( ! "select * from bars " + ! "where " + Bars.TickerFieldName + "='" + ticker + "' and " + Bars.IntervalFrameInSeconds + "='" + intervalFrameInSeconds + "' " ); ! return dataTable.Rows.Count; ! } ! /// <summary> ! /// Returns the number of bars at which the given ticker has been effectively traded ! /// (volume > 0) ! /// </summary> ! /// <param name="ticker">ticker for which the number of bars has to be returned</param> ! /// <param name="intervalFrameInSeconds">interval frame in seconds for the ticker's bars</param> ! /// <returns></returns> ! public static int GetNumberOfBarsWithEffectiveTrades( string ticker, DateTime firstDateTime, ! DateTime lastDateTime, int intervalFrameInSeconds) ! { ! DataTable dataTable = SqlExecutor.GetDataTable( ! "select * from bars " + ! "WHERE " + Bars.TickerFieldName + "='" + ticker + "' and " + Bars.IntervalFrameInSeconds + "='" + intervalFrameInSeconds + "' " + ! "and " + Bars.Volume + ">0" + " and " + Bars.DateTimeForOpen + " BETWEEN " + SQLBuilder.GetDateConstant(firstDateTime) + " " + ! "and " + SQLBuilder.GetDateConstant(lastDateTime) ); ! return dataTable.Rows.Count; ! } ! ! /// <summary> ! /// Returns the close for the given ticker at the specified date ! /// time ! /// </summary> ! /// <param name="ticker">ticker for which the close has to be returned</param> ! /// <param name="intervalFrameInSeconds">interval frame in seconds for the ticker's bars</param> ! /// <returns></returns> ! public static float GetClose( string ticker, DateTime dateTime, int intervalFrameInSeconds ) ! { ! DataTable dataTable = SqlExecutor.GetDataTable( ! "select " + Bars.Close + " from bars " + ! "where " + Bars.TickerFieldName + "='" + ticker + "' and " + Bars.IntervalFrameInSeconds + "='" + intervalFrameInSeconds + "' " + ! "and " + Bars.DateTimeForOpen + "=" + SQLBuilder.GetDateConstant(dateTime) ); ! return (float)dataTable.Rows[0][0]; ! } ! /// <summary> ! /// Returns the open for the given ticker at the specified date ! /// time ! /// </summary> ! /// <param name="ticker">ticker for which the raw open has to be returned</param> ! /// <param name="intervalFrameInSeconds">interval frame in seconds for the ticker's bars</param> ! /// <returns></returns> ! public static float GetOpen( string ticker, DateTime dateTime, int intervalFrameInSeconds ) ! { ! DataTable dataTable = SqlExecutor.GetDataTable( ! "select " + Bars.Open + " from bars " + ! "where " + Bars.TickerFieldName + "='" + ticker + "' and " + Bars.IntervalFrameInSeconds + "='" + intervalFrameInSeconds + "' " + ! "and " + Bars.DateTimeForOpen + "=" + SQLBuilder.GetDateConstant(dateTime) ); ! return (float)dataTable.Rows[0][0]; ! } ! ! ! // /// <summary> ! // /// It provides deletion of the quote from the table "quotes" for ! // /// the given ticker for a specified date ! // /// </summary> ! // public static void Delete( string ticker, DateTime dateOfTheQuoteToBeDeleted ) ! // { ! // try ! // { ! // SqlExecutor.ExecuteNonQuery("DELETE * FROM quotes " + ! // "WHERE quTicker ='" + ! // ticker + "' AND quDate =" + ! // SQLBuilder.GetDateConstant(dateOfTheQuoteToBeDeleted)); ! // } ! // catch(Exception ex) ! // { ! // string notUsed = ex.ToString(); ! // } ! // } ! // /// <summary> ! // /// It provides deletion of the quote from the table "quotes" for ! // /// the given ticker for the specified interval ! // /// </summary> ! // public static void Delete( string ticker, DateTime fromDate, ! // DateTime toDate) ! // { ! // try ! // { ! // SqlExecutor.ExecuteNonQuery("DELETE * FROM quotes " + ! // "WHERE quTicker ='" + ! // ticker + "' AND quDate >=" + ! // SQLBuilder.GetDateConstant(fromDate) + " " + ! // "AND quDate<=" + SQLBuilder.GetDateConstant(toDate)); ! // } ! // catch(Exception ex) ! // { ! // string notUsed = ex.ToString(); ! // } ! // } ! // /// <summary> ! // /// It provides addition of the given quote's values into table "quotes" ! // /// </summary> ! // public static void Add( string ticker, DateTime date, double open, ! // double high, double low, double close, ! // double volume, double adjustedClose) ! // { ! // try ! // { ! // SqlExecutor.ExecuteNonQuery("INSERT INTO quotes(quTicker, quDate, quOpen, " + ! // "quHigh, quLow, quClose, quVolume, quAdjustedClose) " + ! // "VALUES('" + ticker + "', " + SQLBuilder.GetDateConstant(date) + ", " + ! // open + ", " + high + ", " + low + ", " + close + ", " + ! // volume + ", " + adjustedClose + ")"); ! // } ! // catch(Exception ex) ! // { ! // string notUsed = ex.ToString(); ! // } ! // } ! ! /// <summary> /// returns the bars DataTable for the given ticker /// </summary> --- 84,220 ---- { DataTable dataTable = SqlExecutor.GetDataTable( ! "select * from bars where " + Bars.TickerFieldName + "='" + ticker + "' and " + Bars.IntervalFrameInSeconds + "='" + intervalFrameInSeconds + "' " + "order by " + Bars.DateTimeForOpen + " DESC"); return (DateTime)(dataTable.Rows[0][ Bars.DateTimeForOpen ]); } ! /// <summary> ! /// Returns the number of Bars for the given ticker ! /// </summary> ! /// <param name="ticker">ticker for which the number of bars has to be returned</param> ! /// <param name="intervalFrameInSeconds">interval frame in seconds for the ticker's bars</param> ! /// <returns></returns> ! public static int GetNumberOfBars( string ticker, int intervalFrameInSeconds ) ! { ! DataTable dataTable = SqlExecutor.GetDataTable( ! "select * from bars " + ! "where " + Bars.TickerFieldName + "='" + ticker + "' and " + Bars.IntervalFrameInSeconds + "='" + intervalFrameInSeconds + "' " ); ! return dataTable.Rows.Count; ! } ! /// <summary> ! /// Returns the number of bars at which the given ticker has been effectively traded ! /// (volume > 0) ! /// </summary> ! /// <param name="ticker">ticker for which the number of bars has to be returned</param> ! /// <param name="intervalFrameInSeconds">interval frame in seconds for the ticker's bars</param> ! /// <returns></returns> ! public static int GetNumberOfBarsWithEffectiveTrades( string ticker, DateTime firstDateTime, ! DateTime lastDateTime, int intervalFrameInSeconds) ! { ! DataTable dataTable = SqlExecutor.GetDataTable( ! "select * from bars " + ! "WHERE " + Bars.TickerFieldName + "='" + ticker + "' and " + Bars.IntervalFrameInSeconds + "='" + intervalFrameInSeconds + "' " + ! "and " + Bars.Volume + ">0" + " and " + Bars.DateTimeForOpen + " BETWEEN " + SQLBuilder.GetDateConstant(firstDateTime) + " " + ! "and " + SQLBuilder.GetDateConstant(lastDateTime) ); ! return dataTable.Rows.Count; ! } ! ! /// <summary> ! /// Returns the close for the given ticker at the specified date ! /// time ! /// </summary> ! /// <param name="ticker">ticker for which the close has to be returned</param> ! /// <param name="intervalFrameInSeconds">interval frame in seconds for the ticker's bars</param> ! /// <returns></returns> ! public static float GetClose( string ticker, DateTime dateTime, int intervalFrameInSeconds ) ! { ! DataTable dataTable = SqlExecutor.GetDataTable( ! "select " + Bars.Close + " from bars " + ! "where " + Bars.TickerFieldName + "='" + ticker + "' and " + Bars.IntervalFrameInSeconds + "='" + intervalFrameInSeconds + "' " + ! "and " + Bars.DateTimeForOpen + "=" + SQLBuilder.GetDateConstant(dateTime) ); ! return (float)dataTable.Rows[0][0]; ! } ! /// <summary> ! /// Returns the open for the given ticker at the specified date ! /// time ! /// </summary> ! /// <param name="ticker">ticker for which the raw open has to be returned</param> ! /// <param name="intervalFrameInSeconds">interval frame in seconds for the ticker's bars</param> ! /// <returns></returns> ! public static float GetOpen( string ticker, DateTime dateTime, int intervalFrameInSeconds ) ! { ! DataTable dataTable = SqlExecutor.GetDataTable( ! "select " + Bars.Open + " from bars " + ! "where " + Bars.TickerFieldName + "='" + ticker + "' and " + Bars.IntervalFrameInSeconds + "='" + intervalFrameInSeconds + "' " + ! "and " + Bars.DateTimeForOpen + "=" + SQLBuilder.GetDateConstant(dateTime) ); ! return (float)dataTable.Rows[0][0]; ! } ! ! ! // /// <summary> ! // /// It provides deletion of the quote from the table "quotes" for ! // /// the given ticker for a specified date ! // /// </summary> ! // public static void Delete( string ticker, DateTime dateOfTheQuoteToBeDeleted ) ! // { ! // try ! // { ! // SqlExecutor.ExecuteNonQuery("DELETE * FROM quotes " + ! // "WHERE quTicker ='" + ! // ticker + "' AND quDate =" + ! // SQLBuilder.GetDateConstant(dateOfTheQuoteToBeDeleted)); ! // } ! // catch(Exception ex) ! // { ! // string notUsed = ex.ToString(); ! // } ! // } ! // /// <summary> ! // /// It provides deletion of the quote from the table "quotes" for ! // /// the given ticker for the specified interval ! // /// </summary> ! // public static void Delete( string ticker, DateTime fromDate, ! // DateTime toDate) ! // { ! // try ! // { ! // SqlExecutor.ExecuteNonQuery("DELETE * FROM quotes " + ! // "WHERE quTicker ='" + ! // ticker + "' AND quDate >=" + ! // SQLBuilder.GetDateConstant(fromDate) + " " + ! // "AND quDate<=" + SQLBuilder.GetDateConstant(toDate)); ! // } ! // catch(Exception ex) ! // { ! // string notUsed = ex.ToString(); ! // } ! // } ! // /// <summary> ! // /// It provides addition of the given quote's values into table "quotes" ! // /// </summary> ! // public static void Add( string ticker, DateTime date, double open, ! // double high, double low, double close, ! // double volume, double adjustedClose) ! // { ! // try ! // { ! // SqlExecutor.ExecuteNonQuery("INSERT INTO quotes(quTicker, quDate, quOpen, " + ! // "quHigh, quLow, quClose, quVolume, quAdjustedClose) " + ! // "VALUES('" + ticker + "', " + SQLBuilder.GetDateConstant(date) + ", " + ! // open + ", " + high + ", " + low + ", " + close + ", " + ! // volume + ", " + adjustedClose + ")"); ! // } ! // catch(Exception ex) ! // { ! // string notUsed = ex.ToString(); ! // } ! // } ! ! /// <summary> /// returns the bars DataTable for the given ticker /// </summary> *************** *** 223,252 **** public static DataTable GetTickerBars( string ticker, int intervalFrameInSeconds ) { ! string sql = "select * from bars " + ! "where " + Bars.TickerFieldName + "='" + ticker + "' and " + Bars.IntervalFrameInSeconds + "='" + intervalFrameInSeconds + "' " + "order by " + Bars.DateTimeForOpen; return SqlExecutor.GetDataTable( sql ); } ! ! /// <summary> ! /// returns the bars DataTable for the given ticker ! /// </summary> ! /// <param name="ticker">ticker whose quotes are to be returned</param> ! /// <param name="firstBarDateTime">The first bar date time</param> ! /// <param name="lastBarDateTime">The last bar date time</param> ! /// <param name="intervalFrameInSeconds">interval frame in seconds for the ticker's bars</param> ! /// <returns></returns> ! public static DataTable GetTickerBars( string ticker, DateTime firstBarDateTime, ! DateTime lastBarDateTime, int intervalFrameInSeconds) ! { ! string sql = "select * from bars " + ! "where " + Bars.TickerFieldName + "='" + ticker + "' and " + Bars.IntervalFrameInSeconds + "='" + intervalFrameInSeconds + "' " + ! "and " + Bars.DateTimeForOpen + " between " + SQLBuilder.GetDateConstant(firstBarDateTime) + " " + ! "and " + SQLBuilder.GetDateConstant(lastBarDateTime) + " " + ! "order by " + Bars.DateTimeForOpen; ! return SqlExecutor.GetDataTable( sql ); ! } /// <summary> /// Returns the bars for the given instrument , since startDateTime to endDateTime --- 224,253 ---- public static DataTable GetTickerBars( string ticker, int intervalFrameInSeconds ) { ! string sql = "select * from bars " + ! "where " + Bars.TickerFieldName + "='" + ticker + "' and " + Bars.IntervalFrameInSeconds + "='" + intervalFrameInSeconds + "' " + "order by " + Bars.DateTimeForOpen; return SqlExecutor.GetDataTable( sql ); } ! ! /// <summary> ! /// returns the bars DataTable for the given ticker ! /// </summary> ! /// <param name="ticker">ticker whose quotes are to be returned</param> ! /// <param name="firstBarDateTime">The first bar date time</param> ! /// <param name="lastBarDateTime">The last bar date time</param> ! /// <param name="intervalFrameInSeconds">interval frame in seconds for the ticker's bars</param> ! /// <returns></returns> ! public static DataTable GetTickerBars( string ticker, DateTime firstBarDateTime, ! DateTime lastBarDateTime, int intervalFrameInSeconds) ! { ! string sql = "select * from bars " + ! "where " + Bars.TickerFieldName + "='" + ticker + "' and " + Bars.IntervalFrameInSeconds + "='" + intervalFrameInSeconds + "' " + ! "and " + Bars.DateTimeForOpen + " between " + SQLBuilder.GetDateConstant(firstBarDateTime) + " " + ! "and " + SQLBuilder.GetDateConstant(lastBarDateTime) + " " + ! "order by " + Bars.DateTimeForOpen; ! return SqlExecutor.GetDataTable( sql ); ! } /// <summary> /// Returns the bars for the given instrument , since startDateTime to endDateTime *************** *** 258,262 **** /// <returns></returns> public static void SetDataTable( string tickerOrGroupID , DateTime startDateTime , DateTime endDateTime , ! DataTable dataTable, int intervalFrameInSeconds) { string sql; --- 259,263 ---- /// <returns></returns> public static void SetDataTable( string tickerOrGroupID , DateTime startDateTime , DateTime endDateTime , ! DataTable dataTable, int intervalFrameInSeconds) { string sql; *************** *** 264,268 **** sql = "select * from bars INNER JOIN tickers_tickerGroups ON " + "bars." + Bars.TickerFieldName + "=tickers_tickerGroups." + Tickers_tickerGroups.Ticker + " " + ! "where " + Tickers_tickerGroups.GroupID + "='" + tickerOrGroupID + "' and " + Bars.IntervalFrameInSeconds + "=" + intervalFrameInSeconds + " " + "and " + Bars.DateTimeForOpen + ">=" + SQLBuilder.GetDateTimeConstant( startDateTime ) + " " + --- 265,269 ---- sql = "select * from bars INNER JOIN tickers_tickerGroups ON " + "bars." + Bars.TickerFieldName + "=tickers_tickerGroups." + Tickers_tickerGroups.Ticker + " " + ! "where " + Tickers_tickerGroups.GroupID + "='" + tickerOrGroupID + "' and " + Bars.IntervalFrameInSeconds + "=" + intervalFrameInSeconds + " " + "and " + Bars.DateTimeForOpen + ">=" + SQLBuilder.GetDateTimeConstant( startDateTime ) + " " + *************** *** 271,275 **** else sql = "select * from bars " + ! "where " + Bars.TickerFieldName + "='" + tickerOrGroupID + "' and " + Bars.IntervalFrameInSeconds + "=" + intervalFrameInSeconds + " " + "and " + Bars.DateTimeForOpen + ">=" + SQLBuilder.GetDateTimeConstant( startDateTime ) + " " + --- 272,276 ---- else sql = "select * from bars " + ! "where " + Bars.TickerFieldName + "='" + tickerOrGroupID + "' and " + Bars.IntervalFrameInSeconds + "=" + intervalFrameInSeconds + " " + "and " + Bars.DateTimeForOpen + ">=" + SQLBuilder.GetDateTimeConstant( startDateTime ) + " " + *************** *** 291,300 **** foreach (string ticker in tickerCollection) if ( returnValue == "" ) ! // this is the first ticker to handle ! returnValue += setDataTable_getTickerListWhereClause_getSingleTickerWhereClause( ticker ); ! else ! // this is not the first ticker to handle ! returnValue += " or " + ! setDataTable_getTickerListWhereClause_getSingleTickerWhereClause( ticker ); return "( " + returnValue + " )"; } --- 292,301 ---- foreach (string ticker in tickerCollection) if ( returnValue == "" ) ! // this is the first ticker to handle ! returnValue += setDataTable_getTickerListWhereClause_getSingleTickerWhereClause( ticker ); ! else ! // this is not the first ticker to handle ! returnValue += " or " + ! setDataTable_getTickerListWhereClause_getSingleTickerWhereClause( ticker ); return "( " + returnValue + " )"; } *************** *** 311,315 **** string sql; sql = "select * from bars " + ! "where " + setDataTable_getTickerListWhereClause( tickerCollection ) + " and " + Bars.IntervalFrameInSeconds + "='" + intervalFrameInSeconds + "' " + " and " + Bars.DateTimeForOpen + "=" + SQLBuilder.GetDateTimeConstant( dateTime ) + " " + --- 312,316 ---- string sql; sql = "select * from bars " + ! "where " + setDataTable_getTickerListWhereClause( tickerCollection ) + " and " + Bars.IntervalFrameInSeconds + "='" + intervalFrameInSeconds + "' " + " and " + Bars.DateTimeForOpen + "=" + SQLBuilder.GetDateTimeConstant( dateTime ) + " " + *************** *** 319,326 **** } #endregion ! #region SetDataTable - #region getSql private static string getSql( string ticker , DateTime firstDate , DateTime lastDate , --- 320,326 ---- } #endregion ! #region SetDataTable private static string getSql( string ticker , DateTime firstDate , DateTime lastDate , *************** *** 339,343 **** SQLBuilder.GetFilterForTime( "baDateTimeForOpen" , SqlComparisonOperator.GreaterThanOrEqual , ! firstBarOpenTimeInNewYorkTimeZone ) + // "(Format([baDateTimeForOpen],'hh:mm:ss')>='" + // this.getSqlTimeConstantForFirstDailyBar() + --- 339,343 ---- SQLBuilder.GetFilterForTime( "baDateTimeForOpen" , SqlComparisonOperator.GreaterThanOrEqual , ! firstBarOpenTimeInNewYorkTimeZone ) + // "(Format([baDateTimeForOpen],'hh:mm:ss')>='" + // this.getSqlTimeConstantForFirstDailyBar() + *************** *** 351,355 **** return sql; } - #endregion getSql /// <summary> --- 351,354 ---- *************** *** 378,381 **** --- 377,474 ---- + #region SetDataTable + + #region getSql + + #region getFilterForTimeList + + #region getFilterForTimeList_withTailToBeRemoved + private static string getFilterForTimeList( Time time ) + { + string filterForTimeList = + SQLBuilder.GetFilterForTime( + "baDateTimeForOpen" , SqlComparisonOperator.Equal , time ) + + " OR "; + return filterForTimeList; + } + private static string getFilterForTimeList_withTailToBeRemoved( + List<Time> dailyTimes ) + { + string filterForTimeList_withTailToBeRemoved = ""; + foreach ( Time time in dailyTimes ) + filterForTimeList_withTailToBeRemoved += + Bars.getFilterForTimeList( time ); + return filterForTimeList_withTailToBeRemoved; + } + #endregion getFilterForTimeList_withTailToBeRemoved + + private static string getFilterForTimeList( + List<Time> dailyTimes ) + { + // TO DO + // a "where ... in ..." statement could be used here, it would lead to a + // shorter Sql statement + string filterWithTailToBeRemoved = + Bars.getFilterForTimeList_withTailToBeRemoved( dailyTimes ); + string filterForTimeList = + filterWithTailToBeRemoved.Substring( + 0 , filterWithTailToBeRemoved.Length - " OR ".Length ); + return filterForTimeList; + } + #endregion getFilterForTimeList + + private static string getSql( + string ticker , DateTime firstDate , DateTime lastDate , + List<Time> dailyTimes , int intervalFrameInSeconds ) + { + string sql = + "select baDateTimeForOpen from bars " + + "where (baTicker='" + ticker + "') and " + + "(baInterval=" + intervalFrameInSeconds + ") and" + + "(baDateTimeForOpen>=" + + SQLBuilder.GetDateConstant( firstDate ) + ") and" + + "(baDateTimeForOpen<" + + SQLBuilder.GetDateConstant( lastDate.AddDays( 1 ) ) + + ") and (" + + Bars.getFilterForTimeList( dailyTimes ) + + // SQLBuilder.GetFilterForTime( + // "baDateTimeForOpen" , SqlComparisonOperator.GreaterThanOrEqual , + // firstBarOpenTimeInNewYorkTimeZone ) + + //// "(Format([baDateTimeForOpen],'hh:mm:ss')>='" + + //// this.getSqlTimeConstantForFirstDailyBar() + + // ") and (" + + // SQLBuilder.GetFilterForTime( + // "baDateTimeForOpen" , SqlComparisonOperator.LessThanOrEqual , + // lastBarOpenTimeInNewYorkTimeZone ) + + //// "(Format([baDateTimeForOpen],'hh:mm:ss')<='" + + //// this.getSqlTimeConstantForLastDailyBar() + + ");"; + return sql; + } + #endregion getSql + + /// <summary> + /// fills the parameter dataTable with all the daily bars at the given + /// daily times + /// </summary> + /// <param name="ticker"></param> + /// <param name="firstDate"></param> + /// <param name="lastDate"></param> + /// <param name="dailyTimes"></param> + /// <param name="dataTable"></param> + /// <param name="intervalFrameInSeconds"></param> + public static void SetDataTable( + string ticker , DateTime firstDate , DateTime lastDate , + List<Time> dailyTimes , + DataTable dataTable, int intervalFrameInSeconds ) + { + string sql = Bars.getSql( + ticker , firstDate , lastDate , + dailyTimes , + intervalFrameInSeconds ); + SqlExecutor.SetDataTable( sql , dataTable ); + } + #endregion SetDataTable + #region AddBar |
|
From: Marco M. <mi...@us...> - 2009-01-06 17:32:45
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Timing In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14728/b1_ADT/Timing Modified Files: Time.cs Log Message: Added method GetFormattedString(), which returns a string of type "hh:mm:ss" for the current Time instance. Index: Time.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Timing/Time.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Time.cs 16 Dec 2008 23:18:20 -0000 1.7 --- Time.cs 6 Jan 2009 17:32:40 -0000 1.8 *************** *** 219,222 **** --- 219,243 ---- } + /// <summary> + /// Returns a formatted string ("hh:mm:ss") for the current instance + /// </summary> + /// <returns></returns> + public string GetFormattedString() + { + string hour, minute, second; + hour = this.Hour.ToString(); + if( hour.Length < 2 ) + hour = "0" + hour; + minute = this.Minute.ToString(); + if( minute.Length < 2 ) + minute = "0" + minute; + second = this.Second.ToString(); + if ( second.Length < 2 ) + second = "0" + second; + string returnValue = hour + ":" + minute + ":" + second; + + return returnValue; + } + #region CheckStrictlyAscending private static void checkStrictlyAscending( |
|
From: Marco M. <mi...@us...> - 2009-01-06 17:28:39
|
Update of /cvsroot/quantproject/QuantProject/b91_QuantProject In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14527/b91_QuantProject Modified Files: QuantProject_SD.csproj Log Message: Updated SD project's file Index: QuantProject_SD.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b91_QuantProject/QuantProject_SD.csproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** QuantProject_SD.csproj 29 Aug 2007 10:34:59 -0000 1.2 --- QuantProject_SD.csproj 6 Jan 2009 17:28:36 -0000 1.3 *************** *** 40,43 **** --- 40,44 ---- <ItemGroup> <Reference Include="System" /> + <Reference Include="System.Configuration" /> <Reference Include="System.Data" /> <Reference Include="System.Drawing" /> |
|
From: Marco M. <mi...@us...> - 2009-01-06 17:27:13
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/InSample In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14476/b4_Business/a2_Strategies/InSample Modified Files: BasicChooserFromSavedBackTestLog.cs Log Message: Added the Serializable attribute Index: BasicChooserFromSavedBackTestLog.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/InSample/BasicChooserFromSavedBackTestLog.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** BasicChooserFromSavedBackTestLog.cs 29 Sep 2008 21:14:23 -0000 1.4 --- BasicChooserFromSavedBackTestLog.cs 6 Jan 2009 17:27:08 -0000 1.5 *************** *** 41,44 **** --- 41,45 ---- /// log items already saved in a BackTestLog saved to disk /// </summary> + [Serializable] public abstract class BasicChooserFromSavedBackTestLog : IInSampleChooser { |
|
From: Marco M. <mi...@us...> - 2009-01-06 17:24:37
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/UserForms In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14342/Downloader/OpenTickDownloader/UserForms Modified Files: OTWebDownloader.cs Log Message: The interface for the OT Ticker Downloader has been changed: now it is possible to select manually the daily times for the bar to be downloaded. The box "number of bars" has been deleted. Index: OTWebDownloader.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/UserForms/OTWebDownloader.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** OTWebDownloader.cs 30 Nov 2008 22:42:37 -0000 1.6 --- OTWebDownloader.cs 6 Jan 2009 17:24:33 -0000 1.7 *************** *** 23,26 **** --- 23,27 ---- using System.Drawing; using System.Collections; + using System.Collections.Generic; using System.ComponentModel; using System.Windows.Forms; *************** *** 30,33 **** --- 31,36 ---- using System.IO; using System.Threading; + + using QuantProject.ADT.Timing; using QuantProject.DataAccess; using QuantProject.DataAccess.Tables; *************** *** 60,64 **** private string[] tickersToDownload; private SortedList downloadingTickersSortedList; ! private int indexOfCurrentUpdatingTicker; private DateTime currentUpdatingTickerDateTimeOfLastBarUpdate; --- 63,67 ---- private string[] tickersToDownload; private SortedList downloadingTickersSortedList; ! private int indexOfCurrentUpdatingTicker; private DateTime currentUpdatingTickerDateTimeOfLastBarUpdate; *************** *** 128,140 **** 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(); --- 131,134 ---- *************** *** 147,157 **** this.startingDownloadingTimeLabel = new System.Windows.Forms.Label(); 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(); // --- 141,149 ---- this.startingDownloadingTimeLabel = new System.Windows.Forms.Label(); this.signallingLabel = new System.Windows.Forms.Label(); + this.checkedListOfDailyTimes = new System.Windows.Forms.CheckedListBox(); + this.button1 = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit(); this.groupBoxWebDownloaderOptions.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.timeFrameInSeconds)).BeginInit(); this.SuspendLayout(); // *************** *** 164,173 **** this.dataGrid1.Name = "dataGrid1"; this.dataGrid1.ReadOnly = true; ! this.dataGrid1.Size = new System.Drawing.Size(352, 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); --- 156,165 ---- this.dataGrid1.Name = "dataGrid1"; this.dataGrid1.ReadOnly = true; ! this.dataGrid1.Size = new System.Drawing.Size(352, 469); this.dataGrid1.TabIndex = 1; // // buttonDownloadQuotesOfSelectedTickers // ! this.buttonDownloadQuotesOfSelectedTickers.Location = new System.Drawing.Point(5, 418); this.buttonDownloadQuotesOfSelectedTickers.Name = "buttonDownloadQuotesOfSelectedTickers"; this.buttonDownloadQuotesOfSelectedTickers.Size = new System.Drawing.Size(72, 32); *************** *** 208,214 **** 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(336, 134); this.groupBoxWebDownloaderOptions.TabIndex = 13; this.groupBoxWebDownloaderOptions.TabStop = false; --- 200,206 ---- this.groupBoxWebDownloaderOptions.Controls.Add(this.dateTimePickerStartingDate); this.groupBoxWebDownloaderOptions.Controls.Add(this.labelStartingDateTime); ! this.groupBoxWebDownloaderOptions.Location = new System.Drawing.Point(12, 122); this.groupBoxWebDownloaderOptions.Name = "groupBoxWebDownloaderOptions"; ! this.groupBoxWebDownloaderOptions.Size = new System.Drawing.Size(336, 141); this.groupBoxWebDownloaderOptions.TabIndex = 13; this.groupBoxWebDownloaderOptions.TabStop = false; *************** *** 217,221 **** // radioButtonDownloadOnlyAfterMax // ! this.radioButtonDownloadOnlyAfterMax.Location = new System.Drawing.Point(8, 75); this.radioButtonDownloadOnlyAfterMax.Name = "radioButtonDownloadOnlyAfterMax"; this.radioButtonDownloadOnlyAfterMax.Size = new System.Drawing.Size(307, 55); --- 209,213 ---- // radioButtonDownloadOnlyAfterMax // ! this.radioButtonDownloadOnlyAfterMax.Location = new System.Drawing.Point(6, 79); this.radioButtonDownloadOnlyAfterMax.Name = "radioButtonDownloadOnlyAfterMax"; this.radioButtonDownloadOnlyAfterMax.Size = new System.Drawing.Size(307, 55); *************** *** 226,230 **** // label1 // ! this.label1.Location = new System.Drawing.Point(10, 243); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(80, 41); --- 218,222 ---- // label1 // ! this.label1.Location = new System.Drawing.Point(10, 269); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(80, 41); *************** *** 234,238 **** // dateTimeOverwriteQuotesBefore // ! this.dateTimeOverwriteQuotesBefore.Location = new System.Drawing.Point(96, 247); this.dateTimeOverwriteQuotesBefore.Name = "dateTimeOverwriteQuotesBefore"; this.dateTimeOverwriteQuotesBefore.Size = new System.Drawing.Size(229, 20); --- 226,230 ---- // dateTimeOverwriteQuotesBefore // ! this.dateTimeOverwriteQuotesBefore.Location = new System.Drawing.Point(98, 269); this.dateTimeOverwriteQuotesBefore.Name = "dateTimeOverwriteQuotesBefore"; this.dateTimeOverwriteQuotesBefore.Size = new System.Drawing.Size(229, 20); *************** *** 247,251 **** 0, 0}); ! this.timeFrameInSeconds.Location = new System.Drawing.Point(114, 56); this.timeFrameInSeconds.Maximum = new decimal(new int[] { 3600, --- 239,243 ---- 0, 0}); ! this.timeFrameInSeconds.Location = new System.Drawing.Point(299, 55); this.timeFrameInSeconds.Maximum = new decimal(new int[] { 3600, *************** *** 269,273 **** // label2 // ! this.label2.Location = new System.Drawing.Point(6, 58); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(102, 20); --- 261,265 ---- // label2 // ! this.label2.Location = new System.Drawing.Point(191, 57); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(102, 20); *************** *** 275,394 **** 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.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(59, 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); --- 267,273 ---- this.label2.Text = "Time Frame (sec.)"; // // txtOpenTickUser // ! this.txtOpenTickUser.Location = new System.Drawing.Point(63, 382); this.txtOpenTickUser.Name = "txtOpenTickUser"; this.txtOpenTickUser.Size = new System.Drawing.Size(78, 20); *************** *** 397,401 **** // label8 // ! this.label8.Location = new System.Drawing.Point(6, 361); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(37, 23); --- 276,280 ---- // label8 // ! this.label8.Location = new System.Drawing.Point(6, 382); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(37, 23); *************** *** 405,409 **** // label9 // ! this.label9.Location = new System.Drawing.Point(169, 361); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(58, 23); --- 284,288 ---- // label9 // ! this.label9.Location = new System.Drawing.Point(169, 382); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(58, 23); *************** *** 413,417 **** // txtOpenTickPassword // ! this.txtOpenTickPassword.Location = new System.Drawing.Point(247, 361); this.txtOpenTickPassword.Name = "txtOpenTickPassword"; this.txtOpenTickPassword.Size = new System.Drawing.Size(78, 20); --- 292,296 ---- // txtOpenTickPassword // ! this.txtOpenTickPassword.Location = new System.Drawing.Point(247, 382); this.txtOpenTickPassword.Name = "txtOpenTickPassword"; this.txtOpenTickPassword.Size = new System.Drawing.Size(78, 20); *************** *** 421,425 **** // checkBoxCheckingForMissingQuotes // ! this.checkBoxCheckingForMissingQuotes.Location = new System.Drawing.Point(12, 331); this.checkBoxCheckingForMissingQuotes.Name = "checkBoxCheckingForMissingQuotes"; this.checkBoxCheckingForMissingQuotes.Size = new System.Drawing.Size(315, 24); --- 300,304 ---- // checkBoxCheckingForMissingQuotes // ! this.checkBoxCheckingForMissingQuotes.Location = new System.Drawing.Point(12, 352); this.checkBoxCheckingForMissingQuotes.Name = "checkBoxCheckingForMissingQuotes"; this.checkBoxCheckingForMissingQuotes.Size = new System.Drawing.Size(315, 24); *************** *** 430,434 **** // checkBoxOverWrite // ! this.checkBoxOverWrite.Location = new System.Drawing.Point(12, 287); this.checkBoxOverWrite.Name = "checkBoxOverWrite"; this.checkBoxOverWrite.Size = new System.Drawing.Size(246, 38); --- 309,313 ---- // checkBoxOverWrite // ! this.checkBoxOverWrite.Location = new System.Drawing.Point(12, 308); this.checkBoxOverWrite.Name = "checkBoxOverWrite"; this.checkBoxOverWrite.Size = new System.Drawing.Size(246, 38); *************** *** 439,453 **** // 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 = "."; --- 318,332 ---- // label10 // ! this.label10.Location = new System.Drawing.Point(12, 0); this.label10.Name = "label10"; this.label10.Size = new System.Drawing.Size(131, 23); this.label10.TabIndex = 34; ! this.label10.Text = "New York Local Times"; // // endingDownloadingTimeLabel // ! this.endingDownloadingTimeLabel.Location = new System.Drawing.Point(83, 452); this.endingDownloadingTimeLabel.Name = "endingDownloadingTimeLabel"; ! this.endingDownloadingTimeLabel.Size = new System.Drawing.Size(262, 20); this.endingDownloadingTimeLabel.TabIndex = 36; this.endingDownloadingTimeLabel.Text = "."; *************** *** 455,461 **** // 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 = "."; --- 334,340 ---- // startingDownloadingTimeLabel // ! this.startingDownloadingTimeLabel.Location = new System.Drawing.Point(83, 405); this.startingDownloadingTimeLabel.Name = "startingDownloadingTimeLabel"; ! this.startingDownloadingTimeLabel.Size = new System.Drawing.Size(262, 22); this.startingDownloadingTimeLabel.TabIndex = 37; this.startingDownloadingTimeLabel.Text = "."; *************** *** 463,475 **** // signallingLabel // ! this.signallingLabel.Location = new System.Drawing.Point(84, 415); this.signallingLabel.Name = "signallingLabel"; ! this.signallingLabel.Size = new System.Drawing.Size(274, 12); this.signallingLabel.TabIndex = 38; // // OTWebDownloader // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); ! this.ClientSize = new System.Drawing.Size(734, 459); this.Controls.Add(this.signallingLabel); this.Controls.Add(this.startingDownloadingTimeLabel); --- 342,375 ---- // signallingLabel // ! this.signallingLabel.Location = new System.Drawing.Point(83, 427); this.signallingLabel.Name = "signallingLabel"; ! this.signallingLabel.Size = new System.Drawing.Size(274, 23); this.signallingLabel.TabIndex = 38; // + // checkedListOfDailyTimes + // + this.checkedListOfDailyTimes.FormattingEnabled = true; + this.checkedListOfDailyTimes.Location = new System.Drawing.Point(12, 22); + this.checkedListOfDailyTimes.Name = "checkedListOfDailyTimes"; + this.checkedListOfDailyTimes.Size = new System.Drawing.Size(173, 94); + this.checkedListOfDailyTimes.TabIndex = 39; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(227, 12); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(66, 23); + this.button1.TabIndex = 40; + this.button1.Text = "button1"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Visible = false; + this.button1.Click += new System.EventHandler(this.Button1Click); + // // OTWebDownloader // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); ! this.ClientSize = new System.Drawing.Size(734, 469); ! this.Controls.Add(this.button1); ! this.Controls.Add(this.checkedListOfDailyTimes); this.Controls.Add(this.signallingLabel); this.Controls.Add(this.startingDownloadingTimeLabel); *************** *** 482,494 **** 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); --- 382,385 ---- *************** *** 505,515 **** 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.Label endingDownloadingTimeLabel; --- 396,404 ---- this.groupBoxWebDownloaderOptions.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.timeFrameInSeconds)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); } + private System.Windows.Forms.Button button1; + private System.Windows.Forms.CheckedListBox checkedListOfDailyTimes; private System.Windows.Forms.Label signallingLabel; private System.Windows.Forms.Label endingDownloadingTimeLabel; *************** *** 523,536 **** 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; --- 412,416 ---- *************** *** 576,588 **** { 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, --- 456,470 ---- { try{ + if(this.CheckedDailyTimes.Count == 0) + throw new Exception("Check at least one daily time!"); OTTickerDownloader tickerDownloader = new OTTickerDownloader( this.TickersToDownload, this.StartingNewYorkDateTime, ! this.CheckedDailyTimes[0].Hour , ! this.CheckedDailyTimes[0].Minute , ! this.CheckedDailyTimes[0].Second , Convert.ToInt32( this.timeFrameInSeconds.Value ) , ! 1 , this.dateTimeOverwriteQuotesBefore.Value, this.checkBoxCheckingForMissingQuotes.Checked, *************** *** 654,663 **** 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)); } } --- 536,543 ---- get { ! return Time.GetDateTimeFromMerge( new DateTime(this.dateTimePickerStartingDate.Value.Year, ! this.dateTimePickerStartingDate.Value.Month, ! this.dateTimePickerStartingDate.Value.Day) , ! new Time((string)this.checkedListOfDailyTimes.CheckedItems[0]) ); } } *************** *** 669,679 **** } } ! public int NumberOfBars { ! get { ! return Convert.ToInt32(this.numberOfBars.Value); } } public string[] TickersToDownload { --- 549,569 ---- } } ! ! public List<Time> CheckedDailyTimes { ! get { ! List<Time> checkedDailyTimes = ! new List<Time>(); ! for(int i = 0; ! i < this.checkedListOfDailyTimes.CheckedItems.Count; ! i++) ! checkedDailyTimes.Add(new Time((string)this.checkedListOfDailyTimes.CheckedItems[i]) ); ! ! return checkedDailyTimes; } } + + public string[] TickersToDownload { *************** *** 699,703 **** } ! #endregion private void otWebDownloaderLoad_setStyleForDataGrid() --- 589,593 ---- } ! #endregion properties private void otWebDownloaderLoad_setStyleForDataGrid() *************** *** 762,769 **** this.otWebDownloaderLoad_setStyleForDataGrid(); } ! private void otWebDownloaderLoad(object sender, EventArgs e) { this.otWebDownloaderLoad_fillDataGridWithTickersToBeDownloaded(); } --- 652,672 ---- this.otWebDownloaderLoad_setStyleForDataGrid(); } + + private void otWebDownloaderLoad_populateCheckedListOfDailyTimes() + { + Time firstTimeToAdd = new Time(9,30,0); + Time lastTimeToAdd = new Time(16,0,0); + Time currentTimeToAdd = firstTimeToAdd; + while( currentTimeToAdd <= lastTimeToAdd ) + { + this.checkedListOfDailyTimes.Items.Add(currentTimeToAdd.GetFormattedString(), false); + currentTimeToAdd = currentTimeToAdd.AddMinutes( 1 ); + } + } ! private void otWebDownloaderLoad(object sender, EventArgs e) { this.otWebDownloaderLoad_fillDataGridWithTickersToBeDownloaded(); + this.otWebDownloaderLoad_populateCheckedListOfDailyTimes(); } *************** *** 842,845 **** --- 745,754 ---- this.OTWebDownloaderPaint_refreshEndingDownloadingTimeLabel(); } + + void Button1Click(object sender, EventArgs e) + { + List<Time> listDT = + this.CheckedDailyTimes; + } } } |
|
From: Glauco S. <gla...@us...> - 2009-01-04 17:51:24
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv7102/b2_DataAccess Modified Files: SQLBuilder.cs Log Message: A new method internal static string FormatDoubleForSql( double value ) has been added Index: SQLBuilder.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/SQLBuilder.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SQLBuilder.cs 30 Dec 2008 00:14:52 -0000 1.5 --- SQLBuilder.cs 4 Jan 2009 17:51:12 -0000 1.6 *************** *** 265,268 **** --- 265,280 ---- return setStandardDeviationFunctionName; } + + /// <summary> + /// returns a string that can be used in a Sql query + /// </summary> + /// <param name="value"></param> + /// <returns></returns> + internal static string FormatDoubleForSql( double value ) + { + string formattedValue = + value.ToString().Replace( ',' , '.' ); + return formattedValue; + } } } |
|
From: Glauco S. <gla...@us...> - 2009-01-04 17:50:28
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataTables In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv6860/b3_Data/DataTables Modified Files: Bars.cs Log Message: A new constructor has been adde, to build a Bars DataTable with all daily bars between two given Time(s) Index: Bars.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataTables/Bars.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Bars.cs 18 Nov 2008 22:59:29 -0000 1.4 --- Bars.cs 4 Jan 2009 17:50:22 -0000 1.5 *************** *** 74,77 **** --- 74,102 ---- } + #region Bars + /// <summary> + /// returns all daily bars between firstBarOpenTimeInNewYorkTimeZone and + /// lastBarOpenTimeInNewYorkTimeZone + /// </summary> + /// <param name="ticker"></param> + /// <param name="startDateTime"></param> + /// <param name="endDateTime"></param> + /// <param name="firstBarOpenTimeInNewYorkTimeZone"></param> + /// <param name="lastBarOpenTimeInNewYorkTimeZone"></param> + /// <param name="intervalFrameInSeconds"></param> + public Bars( + string ticker , DateTime startDateTime , DateTime endDateTime , + Time firstBarOpenTimeInNewYorkTimeZone , Time lastBarOpenTimeInNewYorkTimeZone , + int intervalFrameInSeconds ) + { + QuantProject.DataAccess.Tables.Bars.SetDataTable( + ticker , startDateTime , endDateTime , + firstBarOpenTimeInNewYorkTimeZone , lastBarOpenTimeInNewYorkTimeZone , + this , intervalFrameInSeconds ); + this.setPrimaryKeys(); + } + #endregion Bars + + /// <summary> /// builds a Bars data table containing the ticker's bars for the |
|
From: Glauco S. <gla...@us...> - 2009-01-04 17:49:33
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv6571/b2_DataAccess/Tables Modified Files: Bars.cs Log Message: A new method public static void AddBar() has been added. Use this method whenever a new bar has to be added to the database Index: Bars.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables/Bars.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Bars.cs 18 Nov 2008 22:56:54 -0000 1.3 --- Bars.cs 4 Jan 2009 17:49:26 -0000 1.4 *************** *** 26,31 **** --- 26,33 ---- using System.Text; using System.Windows.Forms; + using QuantProject.ADT; using QuantProject.ADT.Histories; + using QuantProject.ADT.Timing; namespace QuantProject.DataAccess.Tables *************** *** 317,320 **** --- 319,450 ---- } #endregion + + #region SetDataTable + + #region getSql + private static string getSql( + string ticker , DateTime firstDate , DateTime lastDate , + Time firstBarOpenTimeInNewYorkTimeZone , Time lastBarOpenTimeInNewYorkTimeZone , + int intervalFrameInSeconds ) + { + string sql = + "select baDateTimeForOpen from bars " + + "where (baTicker='" + ticker + "') and " + + "(baInterval=" + intervalFrameInSeconds + ") and" + + "(baDateTimeForOpen>=" + + SQLBuilder.GetDateConstant( firstDate ) + ") and" + + "(baDateTimeForOpen<" + + SQLBuilder.GetDateConstant( lastDate.AddDays( 1 ) ) + + ") and (" + + SQLBuilder.GetFilterForTime( + "baDateTimeForOpen" , SqlComparisonOperator.GreaterThanOrEqual , + firstBarOpenTimeInNewYorkTimeZone ) + + // "(Format([baDateTimeForOpen],'hh:mm:ss')>='" + + // this.getSqlTimeConstantForFirstDailyBar() + + ") and (" + + SQLBuilder.GetFilterForTime( + "baDateTimeForOpen" , SqlComparisonOperator.LessThanOrEqual , + lastBarOpenTimeInNewYorkTimeZone ) + + // "(Format([baDateTimeForOpen],'hh:mm:ss')<='" + + // this.getSqlTimeConstantForLastDailyBar() + + ");"; + return sql; + } + #endregion getSql + + /// <summary> + /// fills the parameter dataTable with all the daily bars between + /// firstBarOpenTimeInNewYorkTimeZone and lastBarOpenTimeInNewYorkTimeZone + /// </summary> + /// <param name="ticker"></param> + /// <param name="firstDate"></param> + /// <param name="lastDate"></param> + /// <param name="firstBarOpenTimeInNewYorkTimeZone"></param> + /// <param name="lastBarOpenTimeInNewYorkTimeZone"></param> + /// <param name="dataTable"></param> + /// <param name="intervalFrameInSeconds"></param> + public static void SetDataTable( + string ticker , DateTime firstDate , DateTime lastDate , + Time firstBarOpenTimeInNewYorkTimeZone , Time lastBarOpenTimeInNewYorkTimeZone , + DataTable dataTable, int intervalFrameInSeconds ) + { + string sql = Bars.getSql( + ticker , firstDate , lastDate , + firstBarOpenTimeInNewYorkTimeZone , lastBarOpenTimeInNewYorkTimeZone , + intervalFrameInSeconds ); + SqlExecutor.SetDataTable( sql , dataTable ); + } + #endregion SetDataTable + + + #region AddBar + + #region getSqlCommand + + // #region getSqlCommand_getValues + // private string getSqlCommandFor_AddBar( double value ) + // { + // string formattedValue = + // value.ToString().Replace( ',' , '.' ); + // return formattedValue; + // } + private static string getSqlCommandFor_AddBar_getValues( + string ticker , string exchange , DateTime dateTimeForOpenInESTTime , long interval , + double open , double high , double low , double close , double volume ) + { + string values = + "'" + ticker + "' , " + + "'" + exchange + "' , " + + SQLBuilder.GetDateTimeConstant( dateTimeForOpenInESTTime ) + " , " + + interval + " , " + + SQLBuilder.FormatDoubleForSql( open ) + " , " + + SQLBuilder.FormatDoubleForSql( high ) + " , " + + SQLBuilder.FormatDoubleForSql( low ) + " , " + + SQLBuilder.FormatDoubleForSql( close ) + " , " + + volume + " , " + + SQLBuilder.GetDateTimeConstant( DateTime.Now ); + return values; + } + // #endregion getSqlCommand_getValues + + private static string getSqlCommandFor_AddBar( + string ticker , string exchange , DateTime dateTimeForOpenInESTTime , long interval , + double open , double high , double low , double close , double volume ) + { + string sqlCommand = + "INSERT INTO bars " + + "( baTicker, baExchange, baDateTimeForOpen, baInterval, " + + "baOpen, baHigh, baLow, baClose, baVolume, baWhenAdded ) " + + "SELECT " + + Bars.getSqlCommandFor_AddBar_getValues( + ticker , exchange , dateTimeForOpenInESTTime , interval , + open , high , low , close , volume ) + ";"; + return sqlCommand; + } + #endregion getSqlCommand + + /// <summary> + /// Adds a bar to the database. A new record is added to the table 'bars' + /// </summary> + /// <param name="ticker"></param> + /// <param name="exchange"></param> + /// <param name="dateTimeForOpenInESTTime"></param> + /// <param name="interval"></param> + /// <param name="open"></param> + /// <param name="high"></param> + /// <param name="low"></param> + /// <param name="close"></param> + /// <param name="volume"></param> + public static void AddBar( + string ticker , string exchange , DateTime dateTimeForOpenInESTTime , long interval , + double open , double high , double low , double close , double volume ) + { + string sqlCommand = + Bars.getSqlCommandFor_AddBar( + ticker , exchange , dateTimeForOpenInESTTime , interval , + open , high , low , close , volume ); + SqlExecutor.ExecuteNonQuery( sqlCommand ); + } + #endregion AddBar } } |