[Quantproject-developers] QuantDownloader/Downloader/OpenTickDownloader/BarsSelectors DailyBarsSel
Brought to you by:
glauco_1
|
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; } |