[Quantproject-developers] QuantDownloader/Downloader/OpenTickDownloader BarQueueFiller.cs, 1.4, 1.
Brought to you by:
glauco_1
|
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() { |