quantproject-developers Mailing List for QuantProject (Page 28)
Brought to you by:
glauco_1
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(7) |
Nov
(103) |
Dec
(67) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(52) |
Feb
(9) |
Mar
(69) |
Apr
(53) |
May
(80) |
Jun
(23) |
Jul
(24) |
Aug
(112) |
Sep
(9) |
Oct
|
Nov
(58) |
Dec
(93) |
| 2005 |
Jan
(90) |
Feb
(93) |
Mar
(61) |
Apr
(56) |
May
(37) |
Jun
(61) |
Jul
(55) |
Aug
(68) |
Sep
(25) |
Oct
(46) |
Nov
(41) |
Dec
(37) |
| 2006 |
Jan
(33) |
Feb
(7) |
Mar
(19) |
Apr
(27) |
May
(73) |
Jun
(49) |
Jul
(83) |
Aug
(66) |
Sep
(45) |
Oct
(16) |
Nov
(15) |
Dec
(7) |
| 2007 |
Jan
(14) |
Feb
(33) |
Mar
|
Apr
(21) |
May
|
Jun
(34) |
Jul
(18) |
Aug
(100) |
Sep
(39) |
Oct
(55) |
Nov
(12) |
Dec
(2) |
| 2008 |
Jan
(120) |
Feb
(133) |
Mar
(129) |
Apr
(104) |
May
(42) |
Jun
(2) |
Jul
(52) |
Aug
(99) |
Sep
(134) |
Oct
|
Nov
(137) |
Dec
(48) |
| 2009 |
Jan
(48) |
Feb
(55) |
Mar
(61) |
Apr
(3) |
May
(2) |
Jun
(1) |
Jul
|
Aug
(51) |
Sep
|
Oct
(7) |
Nov
|
Dec
|
| 2010 |
Jan
(7) |
Feb
(1) |
Mar
(145) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(8) |
Dec
|
| 2011 |
Jan
(78) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(88) |
Sep
(6) |
Oct
(1) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
(1) |
Mar
|
Apr
(6) |
May
(5) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2013 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
| 2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Glauco S. <gla...@us...> - 2008-11-22 18:14:39
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3314/b4_Business/a07_DataProviders Removed Files: HistoricalEndOfDayDataStreamer.cs Log Message: a07_DataProviders\HistoricalEndOfDayDataStreamer.cs has been replaced by a07_DataProviders\HistoricalDataStreamer.cs --- HistoricalEndOfDayDataStreamer.cs DELETED --- |
|
From: Glauco S. <gla...@us...> - 2008-11-22 18:12:50
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3233/b4_Business/a07_DataProviders Added Files: HistoricalDataStreamer.cs Log Message: a07_DataProviders\HistoricalEndOfDayDataStreamer.cs has been replaced by a07_DataProviders\HistoricalDataStreamer.cs --- NEW FILE: HistoricalDataStreamer.cs --- /* QuantProject - Quantitative Finance Library HistoricalDataStreamer.cs Copyright (C) 2008 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Collections; using QuantProject.ADT; using QuantProject.Business.Timing; using QuantProject.Data.DataProviders; using QuantProject.Data.DataProviders.Quotes; namespace QuantProject.Business.DataProviders { /// <summary> /// IDataStreamer implementation using end of day historical data /// </summary> [Serializable] public class HistoricalDataStreamer : IDataStreamer { private Timer timer; private HistoricalMarketValueProvider historicalMarketValueProvider; public HistoricalDataStreamer( Timer timer , HistoricalMarketValueProvider historicalMarketValueProvider ) { this.timer = timer; this.historicalMarketValueProvider = historicalMarketValueProvider; } /// <summary> /// Returns the current bid for the given ticker /// </summary> /// <param name="ticker"></param> /// <returns></returns> public double GetCurrentBid( string ticker ) { double currentBid = this.historicalMarketValueProvider.GetMarketValue( ticker , this.timer.GetCurrentDateTime() ); return currentBid; } /// <summary> /// Returns the current ask for the given ticker /// </summary> /// <param name="ticker"></param> /// <returns></returns> public double GetCurrentAsk( string ticker ) { return this.GetCurrentBid( ticker ); } /// <summary> /// true iif the ticker was exchanged at the given date time /// </summary> /// <param name="ticker"></param> /// <returns></returns> public bool IsExchanged( string ticker ) { return this.historicalMarketValueProvider.WasExchanged( ticker , this.timer.GetCurrentDateTime() ); } } } |
|
From: Glauco S. <gla...@us...> - 2008-11-20 20:58:04
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Strategies In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv341/b7_Scripts/WalkForwardTesting/PairsTrading/Strategies Modified Files: PairsTradingIntradayStrategy.cs Log Message: bug fixed: positions can be open only if optimal in sample positions are available Index: PairsTradingIntradayStrategy.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Strategies/PairsTradingIntradayStrategy.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PairsTradingIntradayStrategy.cs 17 Nov 2008 19:47:26 -0000 1.1 --- PairsTradingIntradayStrategy.cs 20 Nov 2008 20:57:53 -0000 1.2 *************** *** 36,39 **** --- 36,40 ---- /// Pairs trading strategy with intraday bars /// </summary> + [Serializable] public class PairsTradingIntradayStrategy : BasicStrategyForBacktester { *************** *** 104,107 **** --- 105,111 ---- { bool areToBeOpened = ( this.time() == this.lastTimeToTestInefficiency ); + areToBeOpened = + ( areToBeOpened && + ( this.bestTestingPositionsInSample != null ) ); return ( areToBeOpened ); } |
|
From: Glauco S. <gla...@us...> - 2008-11-20 20:57:43
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Strategies In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv303/b7_Scripts/WalkForwardTesting/PairsTrading/Strategies Modified Files: PairsTradingStrategy.cs Log Message: bug fixed: positions can be open only if optimal in sample positions are available Index: PairsTradingStrategy.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Strategies/PairsTradingStrategy.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PairsTradingStrategy.cs 17 Nov 2008 19:53:58 -0000 1.6 --- PairsTradingStrategy.cs 20 Nov 2008 20:57:38 -0000 1.7 *************** *** 106,109 **** --- 106,111 ---- ( this.now() == this.lastIntervalAppended().Begin ); + bool areToBeOpened = + ( beginsTheLastInterval && this.bestTestingPositionsInSample != null ); return ( beginsTheLastInterval ); } |
|
From: Glauco S. <gla...@us...> - 2008-11-20 20:56:41
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32637/b7_Scripts/WalkForwardTesting/PairsTrading Modified Files: PairsTradingMain.cs Log Message: minor change: changed the backtest period Index: PairsTradingMain.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/PairsTradingMain.cs,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** PairsTradingMain.cs 17 Nov 2008 19:49:02 -0000 1.21 --- PairsTradingMain.cs 20 Nov 2008 20:56:34 -0000 1.22 *************** *** 97,100 **** --- 97,102 ---- dailyTimes.Add( new Time( 14 , 0 , 0 ) ); dailyTimes.Add( new Time( 15 , 0 , 0 ) ); + // dailyTimes.Add( new Time( + // HistoricalEndOfDayTimer.GetOneHourAfterMarketClose( DateTime.Now ) ) ); return dailyTimes; } *************** *** 274,278 **** // uncomment the following two lines for a faster script firstDateTime = new DateTime( 2006 , 2 , 1 ); ! lastDateTime = new DateTime( 2006 , 2 , 28 ); double maxRunningHours = 0.05; --- 276,280 ---- // uncomment the following two lines for a faster script firstDateTime = new DateTime( 2006 , 2 , 1 ); ! lastDateTime = new DateTime( 2006 , 2 , 15 ); double maxRunningHours = 0.05; |
|
From: Glauco S. <gla...@us...> - 2008-11-20 20:55:47
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32461/b4_Business/a2_Strategies Modified Files: EndOfDayStrategyBackTester.cs Log Message: the backtester was bug about deciding when to stop (and to produce and save the report) Index: EndOfDayStrategyBackTester.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/EndOfDayStrategyBackTester.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** EndOfDayStrategyBackTester.cs 18 Nov 2008 23:01:52 -0000 1.12 --- EndOfDayStrategyBackTester.cs 20 Nov 2008 20:55:36 -0000 1.13 *************** *** 153,157 **** private void checkThisPropertyRequiresBacktestIsCompleted() { ! if ( this.actualLastDateTime == DateTime.MinValue ) // the timer has not been stopped yet throw new Exception( "This property cannot be invoked " + --- 153,158 ---- private void checkThisPropertyRequiresBacktestIsCompleted() { ! // if ( this.actualLastDateTime == DateTime.MinValue ) ! if ( !this.timer.IsDone ) // the timer has not been stopped yet throw new Exception( "This property cannot be invoked " + *************** *** 294,297 **** --- 295,312 ---- } #endregion run_addEventHandlers + + private void completeTheScript() + { + this.actualLastDateTime = + ExtendedDateTime.Min( + this.lastDateTime , this.timer.GetCurrentDateTime() ); + this.realDateTimeWhenTheBackTestIsStopped = DateTime.Now; + this.accountReport = this.account.CreateReport( + "" , 1 , + this.timer.GetCurrentDateTime() , this.benchmark.Ticker , + this.historicalMarketValueProvider ); + this.accountReport.Name = this.Description; + } + /// <summary> /// Performes the actual backtest *************** *** 308,311 **** --- 323,327 ---- // this.progressBarForm.Show(); this.timer.Start(); + this.completeTheScript(); } #endregion Run *************** *** 313,354 **** #region newDateTimeEventHandler ! private bool isTimeToStop( DateTime currentTime ) { DateTime maxEndingDateTimeForScript = this.startingTimeForScript.AddHours( this.maxRunningHours ); DateTime realTime = DateTime.Now; ! bool scriptTimeElapsed = ( realTime >= maxEndingDateTimeForScript ); bool stopBacktestIfMaxRunningHoursHasBeenReached = this.strategyForBacktester.StopBacktestIfMaxRunningHoursHasBeenReached; return ( ( currentTime > this.lastDateTime ) || ! ( scriptTimeElapsed && ! stopBacktestIfMaxRunningHoursHasBeenReached ) ); } ! // private void removeTimerEventHandlers() ! // { ! // foreach( NewDateTimeEventHandler newDateTimeEventHandler in ! // this.timer.NewDateTime.GetInvocationList()) ! // { ! // this.timer.NewDateTime -= newDateTimeEventHandler; ! // } ! // } #region stopTheScript private void stopTheScript( DateTime currentDateTime ) { ! this.actualLastDateTime = ! ExtendedDateTime.Min( this.lastDateTime , currentDateTime ); this.timer.Stop(); ! // this.removeTimerEventHandlers(); ! // this.timer.NewDateTime -= ! // new NewDateTimeEventHandler( ! // this.strategyForBacktester.NewDateTimeEventHandler ); ! this.realDateTimeWhenTheBackTestIsStopped = DateTime.Now; ! this.accountReport = this.account.CreateReport( ! "" , ! 1 , currentDateTime , this.benchmark.Ticker , ! this.historicalMarketValueProvider ); ! this.accountReport.Name = this.Description; } // private void stopTheScriptIfTheCase( Object sender ) --- 329,370 ---- #region newDateTimeEventHandler ! #region isTimeToStop ! private bool getIsMaxScriptRealTimeElapsed() { DateTime maxEndingDateTimeForScript = this.startingTimeForScript.AddHours( this.maxRunningHours ); DateTime realTime = DateTime.Now; ! bool isMaxScriptRealTimeElapsed = ( realTime >= maxEndingDateTimeForScript ); ! return isMaxScriptRealTimeElapsed; ! } ! private bool isTimeToStop( DateTime currentTime ) ! { ! bool isMaxScriptRealTimeElapsed = ! this.getIsMaxScriptRealTimeElapsed(); bool stopBacktestIfMaxRunningHoursHasBeenReached = this.strategyForBacktester.StopBacktestIfMaxRunningHoursHasBeenReached; + bool hasTheTimerAlreadyThrownOutAllItsNewDateTime = this.timer.IsDone; return ( ( currentTime > this.lastDateTime ) || ! ( isMaxScriptRealTimeElapsed && ! stopBacktestIfMaxRunningHoursHasBeenReached ) || ! hasTheTimerAlreadyThrownOutAllItsNewDateTime ); } ! #endregion isTimeToStop #region stopTheScript private void stopTheScript( DateTime currentDateTime ) { ! // this.actualLastDateTime = ! // ExtendedDateTime.Min( this.lastDateTime , currentDateTime ); ! this.timer.Stop(); ! ! // this.realDateTimeWhenTheBackTestIsStopped = DateTime.Now; ! // this.accountReport = this.account.CreateReport( ! // "" , ! // 1 , currentDateTime , this.benchmark.Ticker , ! // this.historicalMarketValueProvider ); ! // this.accountReport.Name = this.Description; } // private void stopTheScriptIfTheCase( Object sender ) |
|
From: Glauco S. <gla...@us...> - 2008-11-20 20:54:03
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32202/b4_Business/a2_Strategies Modified Files: BasicStrategyForBacktester.cs Log Message: now optimal positions can be updated only one hour after market close Index: BasicStrategyForBacktester.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/BasicStrategyForBacktester.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BasicStrategyForBacktester.cs 17 Nov 2008 19:46:06 -0000 1.1 --- BasicStrategyForBacktester.cs 20 Nov 2008 20:53:51 -0000 1.2 *************** *** 80,83 **** --- 80,87 ---- && ( ( this.lastOptimizationDateTime == DateTime.MinValue ) ) ) || ( currentSimulatedDateTime >= dateTimeForNextOptimization ) ); + areToBeUpdated = ( + areToBeUpdated && + HistoricalEndOfDayTimer.IsOneHourAfterMarketClose( + currentSimulatedDateTime ) ); return areToBeUpdated; } |
|
From: Glauco S. <gla...@us...> - 2008-11-20 20:52:39
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31977/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables Modified Files: Summary.cs Log Message: the class BenchmarkPercentageReturn has been changed to always used an HistoricalAdjustedQuoteProvider for this computation (not tested, yet) Index: Summary.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables/Summary.cs,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** Summary.cs 29 Sep 2008 21:14:43 -0000 1.22 --- Summary.cs 20 Nov 2008 20:52:28 -0000 1.23 *************** *** 265,269 **** this.returnOnAccount = new ReturnOnAccount( this ); this.benchmarkPercentageReturn = ! new BenchmarkPercentageReturn( this , this.historicalMarketValueProvider ); this.numberWinningPeriods = new NumberWinningPeriods( this ); this.numberLosingPeriods = new NumberLosingPeriods( this ); --- 265,270 ---- this.returnOnAccount = new ReturnOnAccount( this ); this.benchmarkPercentageReturn = ! new BenchmarkPercentageReturn( this ); ! // , this.historicalMarketValueProvider ); this.numberWinningPeriods = new NumberWinningPeriods( this ); this.numberLosingPeriods = new NumberLosingPeriods( this ); |
|
From: Glauco S. <gla...@us...> - 2008-11-20 20:51:16
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31813/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows Modified Files: BenchmarkPercentageReturn.cs Log Message: it has been changed to always used an HistoricalAdjustedQuoteProvider for this computation (not tested, yet) Index: BenchmarkPercentageReturn.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows/BenchmarkPercentageReturn.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** BenchmarkPercentageReturn.cs 29 Sep 2008 21:13:46 -0000 1.3 --- BenchmarkPercentageReturn.cs 20 Nov 2008 20:51:10 -0000 1.4 *************** *** 15,21 **** public class BenchmarkPercentageReturn : PercentageSummaryRow { ! public BenchmarkPercentageReturn( Summary summary , ! HistoricalMarketValueProvider historicalMarketValueProvider ) { if ( summary.AccountReport.Benchmark != "" ) { --- 15,23 ---- public class BenchmarkPercentageReturn : PercentageSummaryRow { ! public BenchmarkPercentageReturn( Summary summary ) ! // HistoricalMarketValueProvider historicalMarketValueProvider ) { + HistoricalAdjustedQuoteProvider historicalMarketValueProvider = + new HistoricalAdjustedQuoteProvider(); if ( summary.AccountReport.Benchmark != "" ) { |
|
From: Glauco S. <gla...@us...> - 2008-11-20 20:50:05
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31656/b4_Business/a07_DataProviders Modified Files: HistoricalMarketValueProvider.cs Log Message: the method public bool WasExchanged( string ticker , DateTime dateTime ); is now abstract Index: HistoricalMarketValueProvider.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders/HistoricalMarketValueProvider.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HistoricalMarketValueProvider.cs 29 Sep 2008 21:02:42 -0000 1.1 --- HistoricalMarketValueProvider.cs 20 Nov 2008 20:49:58 -0000 1.2 *************** *** 60,70 **** /// <param name="dateTime"></param> /// <returns></returns> ! public bool WasExchanged( string ticker , ! DateTime dateTime ) ! { ! bool wasExchanged = ! HistoricalQuotesProvider.WasExchanged( ticker , dateTime ); ! return wasExchanged; ! } #region GetQuotes --- 60,78 ---- /// <param name="dateTime"></param> /// <returns></returns> ! // public bool WasExchanged( string ticker , ! // DateTime dateTime ) ! // { ! // bool wasExchanged = ! // HistoricalQuotesProvider.WasExchanged( ticker , dateTime ); ! // return wasExchanged; ! // } ! ! /// <summary> ! /// True iif the given ticker was traded at the given DateTime ! /// </summary> ! /// <param name="ticker"></param> ! /// <param name="dateTime"></param> ! /// <returns></returns> ! public abstract bool WasExchanged( string ticker , DateTime dateTime ); #region GetQuotes |
|
From: Glauco S. <gla...@us...> - 2008-11-20 20:49:02
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31544/b4_Business/a07_DataProviders Modified Files: HistoricalBarProvider.cs Log Message: - marked as Serializable - it now implements the method public bool WasExchanged(string ticker, DateTime dateTime) Index: HistoricalBarProvider.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders/HistoricalBarProvider.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** HistoricalBarProvider.cs 18 Nov 2008 23:01:28 -0000 1.2 --- HistoricalBarProvider.cs 20 Nov 2008 20:48:50 -0000 1.3 *************** *** 31,34 **** --- 31,35 ---- /// Returns historical bars /// </summary> + [Serializable] public class HistoricalBarProvider : HistoricalMarketValueProvider { *************** *** 65,68 **** --- 66,76 ---- return "barProvider"; } + + public override bool WasExchanged(string ticker, DateTime dateTime) + { + bool wasExchanged = + this.historicalBarProvider.WasExchanged( ticker , dateTime ); + return wasExchanged; + } } } |
|
From: Glauco S. <gla...@us...> - 2008-11-20 20:48:08
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31440/b4_Business/a07_DataProviders Modified Files: HistoricalAdjustedQuoteProvider.cs HistoricalRawQuoteProvider.cs Log Message: now HistoricalQuoteProvider is inherited (it was HistoricalMarketValueProvider in the previous revision) Index: HistoricalRawQuoteProvider.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders/HistoricalRawQuoteProvider.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** HistoricalRawQuoteProvider.cs 29 Sep 2008 21:22:23 -0000 1.6 --- HistoricalRawQuoteProvider.cs 20 Nov 2008 20:47:57 -0000 1.7 *************** *** 33,37 **** /// </summary> [Serializable] ! public class HistoricalRawQuoteProvider : HistoricalMarketValueProvider { public HistoricalRawQuoteProvider() --- 33,37 ---- /// </summary> [Serializable] ! public class HistoricalRawQuoteProvider : HistoricalQuoteProvider { public HistoricalRawQuoteProvider() *************** *** 55,58 **** --- 55,65 ---- return "raw"; } + + // public override bool WasExchanged(string ticker, DateTime dateTime) + // { + // bool wasExchanged = + // HistoricalQuotesProvider.WasExchanged( ticker , dateTime ); + // return wasExchanged; + // } } } Index: HistoricalAdjustedQuoteProvider.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders/HistoricalAdjustedQuoteProvider.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** HistoricalAdjustedQuoteProvider.cs 29 Sep 2008 21:22:23 -0000 1.7 --- HistoricalAdjustedQuoteProvider.cs 20 Nov 2008 20:47:57 -0000 1.8 *************** *** 33,37 **** /// </summary> [Serializable] ! public class HistoricalAdjustedQuoteProvider : HistoricalMarketValueProvider { public HistoricalAdjustedQuoteProvider() --- 33,37 ---- /// </summary> [Serializable] ! public class HistoricalAdjustedQuoteProvider : HistoricalQuoteProvider { public HistoricalAdjustedQuoteProvider() *************** *** 98,101 **** --- 98,108 ---- return "adj"; } + + // public override bool WasExchanged(string ticker, DateTime dateTime) + // { + // bool wasExchanged = + // HistoricalQuotesProvider.WasExchanged( ticker , dateTime ); + // return wasExchanged; + // } } } |
|
From: Glauco S. <gla...@us...> - 2008-11-20 20:47:02
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31305/b4_Business/a05_Timing Modified Files: IndexBasedHistoricalTimer.cs Log Message: - the method protected bool isDone() has been overridden (implemented) - now a NewDateTime event is sent out (every market day) for one hour after market close (to be used by strategies, for in sample optimization) Index: IndexBasedHistoricalTimer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing/IndexBasedHistoricalTimer.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IndexBasedHistoricalTimer.cs 18 Nov 2008 23:00:33 -0000 1.3 --- IndexBasedHistoricalTimer.cs 20 Nov 2008 20:46:55 -0000 1.4 *************** *** 34,37 **** --- 34,38 ---- /// index is quoted at those DateTime(s) /// </summary> + [Serializable] public class IndexBasedHistoricalTimer : Timer { *************** *** 62,65 **** --- 63,128 ---- #region initialize_dateTimesToBeThrown + + #region addDateTimeAndIfTheCaseAddEndOfDayDateTime + + #region addOneHourAfterMarketCloseDateTimeIfTheCase + + #region isOneHourAfterMarktetCloseToBeInserted + private bool isOneHourAfterMarktetCloseToBeInserted_withOneAdded( + DateTime nextDateTimeToBeAdded ) + { + Date dateForLastDateTimeAdded = + new Date( this.dateTimesToBeThrown[ this.dateTimesToBeThrown.Count - 1 ] ); + Date dateForNextDateTimeToBeAdded = + new Date( nextDateTimeToBeAdded ); + bool isToBeInserted = ( dateForNextDateTimeToBeAdded > dateForLastDateTimeAdded ); + return isToBeInserted; + } + private bool isOneHourAfterMarktetCloseToBeInserted( DateTime nextDateTimeToBeAdded ) + { + bool isToBeInserted = false; + if ( this.dateTimesToBeThrown.Count > 0 ) + // at least one DateTime has already been added + isToBeInserted = isOneHourAfterMarktetCloseToBeInserted_withOneAdded( + nextDateTimeToBeAdded ); + return isToBeInserted; + } + #endregion isOneHourAfterMarktetCloseToBeInserted + + #region addOneHourAfterMarketCloseDateTime + private DateTime getOneHourAfterMarketCloseForLastDateTimeAdded() + { + DateTime dateTimeForLastDateTimeAdded = + this.dateTimesToBeThrown[ this.dateTimesToBeThrown.Count - 1 ]; + DateTime oneHourAfterMarketCloseForLastDateTimeAdded = + HistoricalEndOfDayTimer.GetOneHourAfterMarketClose( + dateTimeForLastDateTimeAdded ); + return oneHourAfterMarketCloseForLastDateTimeAdded; + } + private void addOneHourAfterMarketCloseDateTime( DateTime dateTime ) + { + DateTime oneHourAfterMarketCloseForLastDateTimeAdded = + this.getOneHourAfterMarketCloseForLastDateTimeAdded(); + this.dateTimesToBeThrown.Add( + oneHourAfterMarketCloseForLastDateTimeAdded ); + } + #endregion addOneHourAfterMarketCloseDateTime + + private void addOneHourAfterMarketCloseDateTimeIfTheCase( + DateTime nextDateTimeToBeAdded ) + { + if ( this.isOneHourAfterMarktetCloseToBeInserted( nextDateTimeToBeAdded ) ) + this.addOneHourAfterMarketCloseDateTime( nextDateTimeToBeAdded ); + } + #endregion addOneHourAfterMarketCloseDateTimeIfTheCase + + private void addDateTimeAndIfTheCaseAddOneHourAfterMarketCloseDateTime( + DateTime nextDateTimeToBeAdded ) + { + this.addOneHourAfterMarketCloseDateTimeIfTheCase( nextDateTimeToBeAdded ); + this.dateTimesToBeThrown.Add( nextDateTimeToBeAdded ); + } + #endregion addDateTimeAndIfTheCaseAddEndOfDayDateTime + private void initialize_dateTimesToBeThrown( History dateTimesToBeThrownHistory ) *************** *** 67,71 **** this.dateTimesToBeThrown = new List< DateTime >(); foreach ( DateTime dateTime in dateTimesToBeThrownHistory.Keys ) ! this.dateTimesToBeThrown.Add( dateTime ); } private void initialize_dateTimesToBeThrown() --- 130,134 ---- this.dateTimesToBeThrown = new List< DateTime >(); foreach ( DateTime dateTime in dateTimesToBeThrownHistory.Keys ) ! this.addDateTimeAndIfTheCaseAddOneHourAfterMarketCloseDateTime( dateTime ); } private void initialize_dateTimesToBeThrown() *************** *** 90,109 **** private void checkIfNoMoreDateTimesAreToBeThrown() { ! if ( this.currentDateTimeIndex >= this.dateTimesToBeThrown.Count ) throw new Exception( "This timer has no other DateTime(s) to be thrown out. " + "This should never happen, the backtest should have invoked the method " + ! "QuantProject.Business.Timing.Timer.Stop() before gettint to this " + "point." ); ! } ! private void moveNext_actually() { ! this.currentDateTimeIndex++; ! this.currentDateTime = this.dateTimesToBeThrown[ currentDateTimeIndex ]; } protected override void moveNext() { ! this.checkIfNoMoreDateTimesAreToBeThrown(); ! this.moveNext_actually(); } #endregion moveNext --- 153,182 ---- private void checkIfNoMoreDateTimesAreToBeThrown() { ! if ( this.currentDateTimeIndex >= this.dateTimesToBeThrown.Count - 1 ) throw new Exception( "This timer has no other DateTime(s) to be thrown out. " + "This should never happen, the backtest should have invoked the method " + ! "QuantProject.Business.Timing.Timer.Stop() before getting to this " + "point." ); ! } ! ! protected override bool isDone() { ! bool isThisTimerDone = ! ( this.currentDateTimeIndex >= ( this.dateTimesToBeThrown.Count - 1 ) ); ! return isThisTimerDone; } + // + // private void moveNext_actually() + // { + // this.currentDateTimeIndex++; + // this.currentDateTime = this.dateTimesToBeThrown[ currentDateTimeIndex ]; + // this.setCompleteIfTheCase(); + // } + protected override void moveNext() { ! this.currentDateTimeIndex++; ! this.currentDateTime = this.dateTimesToBeThrown[ currentDateTimeIndex ]; } #endregion moveNext |
|
From: Glauco S. <gla...@us...> - 2008-11-20 20:44:20
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv30975/b4_Business/a05_Timing Modified Files: Timer.cs Log Message: - a new property has been added: public bool IsDone - some bugs have been fixed Index: Timer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing/Timer.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Timer.cs 29 Sep 2008 21:02:41 -0000 1.1 --- Timer.cs 20 Nov 2008 20:44:14 -0000 1.2 *************** *** 38,51 **** public event NewDateTimeEventHandler NewDateTime; ! protected bool isActive; // true iff the timer is started and not stopped protected DateTime currentDateTime; ! public bool IsActive { ! get { return this.isActive; } } public Timer() { } --- 38,60 ---- public event NewDateTimeEventHandler NewDateTime; ! private bool hasTheTimerBeenStarted; ! private bool hasTheTimerBeenStopped; // true iff the timer was stop protected DateTime currentDateTime; ! #region IsDone ! protected abstract bool isDone(); ! /// <summary> ! /// true iif all DateTime(s) have been thrown out by this timer ! /// </summary> ! public bool IsDone { ! get { return this.isDone(); } } + #endregion IsDone public Timer() { + this.hasTheTimerBeenStarted = false; + this.hasTheTimerBeenStopped = false; } *************** *** 59,65 **** public virtual DateTime GetCurrentDateTime() { ! if ( !this.isActive ) throw new Exception( - "Either Start() has not been invoked yet, or " + "Stop() has already been invoked" ); return this.currentDateTime; --- 68,76 ---- public virtual DateTime GetCurrentDateTime() { ! if ( !this.hasTheTimerBeenStarted ) ! throw new Exception( ! "Start() has not been invoked yet" ); ! if ( this.hasTheTimerBeenStopped ) throw new Exception( "Stop() has already been invoked" ); return this.currentDateTime; *************** *** 72,76 **** { this.initializeTimer(); ! this.isActive = true; } #endregion activateTimer --- 83,87 ---- { this.initializeTimer(); ! this.hasTheTimerBeenStarted = true; } #endregion activateTimer *************** *** 91,107 **** this.currentDateTime.Minute , this.currentDateTime.Second ) ); ! ! // if ( ( this.MarketOpen != null ) && ( this.currentTime.EndOfDaySpecificTime == ! // EndOfDaySpecificTime.MarketOpen ) ) ! // this.MarketOpen( this , new EndOfDayTimingEventArgs( this.currentTime ) ); ! // if ( ( this.FiveMinutesBeforeMarketClose != null ) && ( this.currentTime.EndOfDaySpecificTime == ! // EndOfDaySpecificTime.FiveMinutesBeforeMarketClose ) ) ! // this.FiveMinutesBeforeMarketClose( this , new EndOfDayTimingEventArgs( this.currentTime ) ); ! // if ( ( this.MarketClose != null ) && ( this.currentTime.EndOfDaySpecificTime == ! // EndOfDaySpecificTime.MarketClose ) ) ! // this.MarketClose( this , new EndOfDayTimingEventArgs( this.currentTime ) ); ! // if ( ( this.OneHourAfterMarketClose != null ) && ( this.currentTime.EndOfDaySpecificTime == ! // EndOfDaySpecificTime.OneHourAfterMarketClose ) ) ! // this.OneHourAfterMarketClose( this , new EndOfDayTimingEventArgs( this.currentTime ) ); } /// <summary> --- 102,111 ---- this.currentDateTime.Minute , this.currentDateTime.Second ) ); ! } ! private void moveNextIfPossible() ! { ! if ( !this.IsDone ) ! // there is at least one more bar to be thrown out, yet ! this.moveNext(); } /// <summary> *************** *** 111,118 **** { this.activateTimer(); ! while ( this.isActive ) { this.callEvents(); ! this.moveNext(); } } --- 115,122 ---- { this.activateTimer(); ! while ( !this.hasTheTimerBeenStopped && !this.IsDone ) { this.callEvents(); ! this.moveNextIfPossible(); } } *************** *** 124,128 **** public void Stop() { ! this.isActive = false; } } --- 128,132 ---- public void Stop() { ! this.hasTheTimerBeenStopped = true; } } |
|
From: Glauco S. <gla...@us...> - 2008-11-20 20:43:49
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv30919/b4_Business/a05_Timing Modified Files: HistoricalEndOfDayTimer.cs Log Message: - a new property has been added: public bool IsDone - some bugs have been fixed Index: HistoricalEndOfDayTimer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing/HistoricalEndOfDayTimer.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** HistoricalEndOfDayTimer.cs 29 Sep 2008 21:22:23 -0000 1.10 --- HistoricalEndOfDayTimer.cs 20 Nov 2008 20:43:43 -0000 1.11 *************** *** 120,123 **** --- 120,128 ---- } #endregion moveNext + + protected override bool isDone() + { + return false; + } /// <summary> |
|
From: Glauco S. <gla...@us...> - 2008-11-20 20:42:34
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataProviders/Bars/Caching In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv30800/b3_Data/DataProviders/Bars/Caching Modified Files: IBarCache.cs Log Message: - a new method has been added: bool WasExchanged( string ticker , DateTime dateTime ); - comments have been improved Index: IBarCache.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataProviders/Bars/Caching/IBarCache.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IBarCache.cs 8 Nov 2008 20:20:19 -0000 1.1 --- IBarCache.cs 20 Nov 2008 20:42:23 -0000 1.2 *************** *** 30,34 **** --- 30,49 ---- public interface IBarCache { + /// <summary> + /// the value of the ticker at the given dateTime; a MissingBarException + /// is thrown if the database doesn't contain the requested bar + /// </summary> + /// <param name="ticker"></param> + /// <param name="dateTime"></param> + /// <returns></returns> double GetMarketValue( string ticker , DateTime dateTime ); + + /// <summary> + /// true iif the ticker was exchange at the given dateTime + /// </summary> + /// <param name="ticker"></param> + /// <param name="dateTime"></param> + /// <returns></returns> + bool WasExchanged( string ticker , DateTime dateTime ); } } |
|
From: Glauco S. <gla...@us...> - 2008-11-20 20:41:37
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataProviders/Bars/Caching In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv30724/b3_Data/DataProviders/Bars/Caching Modified Files: DailyBarCache.cs Log Message: Several bugs have been fixed, but it doesn't work fine, yet Index: DailyBarCache.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataProviders/Bars/Caching/DailyBarCache.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DailyBarCache.cs 12 Nov 2008 20:38:21 -0000 1.2 --- DailyBarCache.cs 20 Nov 2008 20:41:30 -0000 1.3 *************** *** 73,80 **** maxNumberOfItemsIn_barOpenValues , numberOfItemsToBeRemovedFrom_barOpenValues_whenCacheIsCleanedUp ); ! // this.barOpenValues = new Dictionary< DateTime , Dictionary< string , double > >(); // this.numberOfBarsIn_barOpenValues = 0; ! int maxNumberOfItemsIn_barsMissingInTheDatabase = 100000; int numberOfItemsToBeRemovedFrom_barsMissingInTheDatabase_whenCacheIsCleanedUp = --- 73,80 ---- maxNumberOfItemsIn_barOpenValues , numberOfItemsToBeRemovedFrom_barOpenValues_whenCacheIsCleanedUp ); ! // this.barOpenValues = new Dictionary< DateTime , Dictionary< string , double > >(); // this.numberOfBarsIn_barOpenValues = 0; ! int maxNumberOfItemsIn_barsMissingInTheDatabase = 100000; int numberOfItemsToBeRemovedFrom_barsMissingInTheDatabase_whenCacheIsCleanedUp = *************** *** 89,108 **** #region checkParameters - #region checkDailyTimesAreActuallyTimes - // private void checkIfItActuallyIsATime( DateTime dateTime ) - // { - // if ( !ExtendedDateTime.IsTime( dateTime ) ) - // throw new Exception( - // "dailyTimes have to be times: use the method " + - // "QuantProject.ADT.ExtendedDateTime.GetTime() " + - // "to build them" ); - // } - // private void checkDailyTimesAreActuallyTimes( DateTime[] dailyTimes ) - // { - // foreach ( DateTime dateTime in dailyTimes ) - // this.checkIfItActuallyIsATime( dateTime ); - // } - #endregion checkDailyTimesAreActuallyTimes - #region checkIfDailyTimesAreInStrictAscendingOrder private void checkIfDailyTimesAreInStrictAscendingOrder( --- 89,92 ---- *************** *** 186,190 **** #endregion getLastDateTime ! private History getBarOpenValues( string ticker, DateTime firstDateTime ) { DateTime lastDateTime = this.getLastDateTime( firstDateTime ); --- 170,174 ---- #endregion getLastDateTime ! private History getBarOpenValuesFromDatabase( string ticker, DateTime firstDateTime ) { DateTime lastDateTime = this.getLastDateTime( firstDateTime ); *************** *** 202,209 **** private void addBarOpenValue( ! string ticker, DateTime dateTime , History barOpenValuesFromQuery ) { ! double barOpenValue = ! (double)barOpenValuesFromQuery[ dateTime ]; this.barOpenValues.AddBar( ticker , dateTime , barOpenValue ); --- 186,193 ---- private void addBarOpenValue( ! string ticker, DateTime dateTime , History barOpenValuesFromDatabase ) { ! float barOpenValue = ! (float)barOpenValuesFromDatabase[ dateTime ]; this.barOpenValues.AddBar( ticker , dateTime , barOpenValue ); *************** *** 211,218 **** private void update_barOpenValues( ! string ticker, History barOpenValuesFromQuery ) { ! foreach ( DateTime dateTime in barOpenValuesFromQuery.TimeLine ) ! this.addBarOpenValue( ticker , dateTime , barOpenValuesFromQuery ); } #endregion update_barOpenValues --- 195,202 ---- private void update_barOpenValues( ! string ticker, History barOpenValuesFromDatabase ) { ! foreach ( DateTime dateTime in barOpenValuesFromDatabase.TimeLine ) ! this.addBarOpenValue( ticker , dateTime , barOpenValuesFromDatabase ); } #endregion update_barOpenValues *************** *** 221,242 **** #region getDateTimesForMissingBarsToBeAdded - // private List< DateTime > getDateTimesIn_barOpenValues() - // { - // List< DateTime > dateTimesIn_barOpenValues = - // new List<DateTime>( this.barOpenValues.Bars.Keys ); - // dateTimesIn_barOpenValues.Sort(); - // return dateTimesIn_barOpenValues; - // } ! #region removeThisDateIfItIsNotToBeAddedToMissingBars ! ! // private bool isIn_barsMissingInTheDatabase( ! // string ticker , DateTime dateTime ) ! // { ! // bool isInCacheForMissingBars = ! // ( ( this.barsMissingInTheDatabase.Bars.ContainsKey( dateTime ) ) && ! // this.barOpenValues.Bars[ dateTime ].ContainsKey( ticker ) ); ! // return isInCacheForMissingBars; ! // } private bool hasToBeAddedToMissingBars( string ticker , --- 205,210 ---- #region getDateTimesForMissingBarsToBeAdded ! #region addThisDateIfItHasToBeAddedToMissingBars private bool hasToBeAddedToMissingBars( string ticker , *************** *** 253,281 **** return hasToBeAdded; } ! private void removeThisDateIfItIsNotToBeAddedToMissingBars( string ticker , DateTime firstDateTime , DateTime lastDateTime , DateTime candidateDateTime , ! List< DateTime > dateTimesForMissingBarsToBeAdded ) { ! if ( !this.hasToBeAddedToMissingBars( ticker , firstDateTime , lastDateTime , candidateDateTime ) ) ! dateTimesForMissingBarsToBeAdded.Remove( candidateDateTime ); } ! private void removeThisDateIfItIsNotToBeAddedToMissingBars( string ticker , DateTime firstDateTime , DateTime lastDateTime , int indexFor_dateTimesForMissingBarsToBeAdded , ! List< DateTime > dateTimesForMissingBarsToBeAdded ) { DateTime candidateDateTime = ! dateTimesForMissingBarsToBeAdded[ indexFor_dateTimesForMissingBarsToBeAdded ]; ! this.removeThisDateIfItIsNotToBeAddedToMissingBars( ticker , firstDateTime , lastDateTime , candidateDateTime , ! dateTimesForMissingBarsToBeAdded ); } ! #endregion removeThisDateIfItIsNotToBeAddedToMissingBars private List< DateTime > getDateTimesForMissingBarsToBeAdded( --- 221,251 ---- return hasToBeAdded; } ! private void addThisDateIfItHasToBeAddedToMissingBars( string ticker , DateTime firstDateTime , DateTime lastDateTime , DateTime candidateDateTime , ! List< DateTime > dateTimesIn_barOpenValues , ! List< DateTime > dateTimesForMissingBarsToBeAdded ) { ! if ( this.hasToBeAddedToMissingBars( ticker , firstDateTime , lastDateTime , candidateDateTime ) ) ! dateTimesForMissingBarsToBeAdded.Add( candidateDateTime ); } ! private void addThisDateIfItHasToBeAddedToMissingBars( string ticker , DateTime firstDateTime , DateTime lastDateTime , int indexFor_dateTimesForMissingBarsToBeAdded , ! List< DateTime > dateTimesIn_barOpenValues , ! List< DateTime > dateTimesForMissingBarsToBeAdded ) { DateTime candidateDateTime = ! dateTimesIn_barOpenValues[ indexFor_dateTimesForMissingBarsToBeAdded ]; ! this.addThisDateIfItHasToBeAddedToMissingBars( ticker , firstDateTime , lastDateTime , candidateDateTime , ! dateTimesIn_barOpenValues , dateTimesForMissingBarsToBeAdded ); } ! #endregion addThisDateIfItHasToBeAddedToMissingBars private List< DateTime > getDateTimesForMissingBarsToBeAdded( *************** *** 283,299 **** DateTime firstDateTime , DateTime lastDateTime , ! List< DateTime > dateTimesForMissingBarsToBeAdded ) { int indexFor_dateTimesForMissingBarsToBeAdded = 0; while ( ( indexFor_dateTimesForMissingBarsToBeAdded < ! dateTimesForMissingBarsToBeAdded.Count ) && ! ( dateTimesForMissingBarsToBeAdded[ indexFor_dateTimesForMissingBarsToBeAdded ] <= lastDateTime ) ) ! this.removeThisDateIfItIsNotToBeAddedToMissingBars( ticker , firstDateTime , lastDateTime , indexFor_dateTimesForMissingBarsToBeAdded , ! dateTimesForMissingBarsToBeAdded ); ! return dateTimesForMissingBarsToBeAdded; } private List< DateTime > getDateTimesForMissingBarsToBeAdded( --- 253,274 ---- DateTime firstDateTime , DateTime lastDateTime , ! List< DateTime > dateTimesIn_barOpenValues ! ) { + List< DateTime > dateTimesForMissingBarsToBeAdded = new List< DateTime >(); int indexFor_dateTimesForMissingBarsToBeAdded = 0; while ( ( indexFor_dateTimesForMissingBarsToBeAdded < ! dateTimesIn_barOpenValues.Count ) && ! ( dateTimesIn_barOpenValues[ indexFor_dateTimesForMissingBarsToBeAdded ] <= lastDateTime ) ) ! { ! this.addThisDateIfItHasToBeAddedToMissingBars( ticker , firstDateTime , lastDateTime , indexFor_dateTimesForMissingBarsToBeAdded , ! dateTimesIn_barOpenValues , dateTimesForMissingBarsToBeAdded ); ! indexFor_dateTimesForMissingBarsToBeAdded++; ! } ! return dateTimesIn_barOpenValues; } private List< DateTime > getDateTimesForMissingBarsToBeAdded( *************** *** 319,391 **** #endregion getDateTimesForMissingBarsToBeAdded - #region update_barsMissingInTheDatabase - // - // #region addBarTo_barsMissingInTheDatabase - // - // #region removeValuesFrom_barsMissingInTheDatabase_ifMaxSizeHasBeenReached - // - // #region removeValuesFrom_barsMissingInTheDatabase - // - // #region initializeMembersForCleaningUp_barsMissingInTheDatabase - // private void initialize_dateTimesForCleaningUp_barsMissingInTheDatabase() - // { - // this.dateTimesForCleaningUp_barsMissingInTheDatabase = - // new List<DateTime>( this.barsMissingInTheDatabase.Keys ); - // this.dateTimesForCleaningUp_barsMissingInTheDatabase.Sort(); - // } - // - // #region initialize_tickersForCleaningUp_barsMissingInTheDatabase - // private List< string > - // getTickersForTheCurrentDateTimeToBeCleanedUpInMissingBars() - // { - // DateTime currentDateTimeForCleaningUp_barsMissingInTheDatabase = - // this.dateTimesForCleaningUp_barsMissingInTheDatabase[ 0 ]; - // List< string > - // tickersForTheCurrentDateTimeToBeCleanedUpInMissingBars = - // this.barsMissingInTheDatabase[ - // currentDateTimeForCleaningUp_barsMissingInTheDatabase ]; - // return tickersForTheCurrentDateTimeToBeCleanedUpInMissingBars; - // } - // private void initialize_tickersForCleaningUp_barsMissingInTheDatabase() - // { - // this.tickersForCleaningUp_barOpenValues = - // this.getTickersForTheCurrentDateTimeToBeCleanedUpInMissingBars(); - // } - // #endregion initialize_tickersForCleaningUp_barsMissingInTheDatabase - // - // private void initializeMembersForCleaningUp_barsMissingInTheDatabase() - // { - // this.initialize_dateTimesForCleaningUp_barsMissingInTheDatabase(); - // this.initialize_tickersForCleaningUp_barsMissingInTheDatabase(); - // } - // #endregion initializeMembersForCleaningUp_barsMissingInTheDatabase - // - // private void removeValuesFrom_barsMissingInTheDatabase() - // { - // this.initializeMembersForCleaningUp_barsMissingInTheDatabase(); - // while ( this.numberOfBarsIn_barsMissingInTheDatabase > - // this.maxNumberOfItemsIn_barsMissingInTheDatabase - - // this.numberOfItemsToBeRemovedFrom_barsMissingInTheDatabase_whenCacheIsCleanedUp ) - // this.removeNextItemFrom_barsMissingInTheDatabase(); - // } - // #endregion removeValuesFrom_barsMissingInTheDatabase - // - // private void removeValuesFrom_barsMissingInTheDatabase_ifMaxSizeHasBeenReached() - // { - // if ( this.numberOfBarsIn_barsMissingInTheDatabase >= - // this.maxNumberOfItemsIn_barsMissingInTheDatabase ) - // // the cache for missing bars is full - // this.removeValuesFrom_barsMissingInTheDatabase(); - // } - // #endregion removeValuesFrom_barsMissingInTheDatabase_ifMaxSizeHasBeenReached - // - // private void addBarTo_barsMissingInTheDatabase( - // string ticker, DateTime dateTime ) - // { - // this.removeValuesFrom_barsMissingInTheDatabase_ifMaxSizeHasBeenReached(); - // this.addBarTo_barsMissingInTheDatabase_withFreeSpaceAssured(); - // } - // #endregion addBarTo_barsMissingInTheDatabase - // private void update_barsMissingInTheDatabase( string ticker, List< DateTime > dateTimesForMissingBarsToBeAdded ) --- 294,297 ---- *************** *** 395,402 **** // this.addBarTo_barsMissingInTheDatabase( ticker , dateTime ); } - #endregion update_barsMissingInTheDatabase private void update_barsMissingInTheDatabase( ! string ticker, DateTime firstDateTime , History barOpenValues ) { List< DateTime > dateTimesForMissingBarsToBeAdded = --- 301,307 ---- // this.addBarTo_barsMissingInTheDatabase( ticker , dateTime ); } private void update_barsMissingInTheDatabase( ! string ticker, DateTime firstDateTime ) { List< DateTime > dateTimesForMissingBarsToBeAdded = *************** *** 409,423 **** private void updateDictionaries( ! string ticker, DateTime dateTime , History barOpenValues ) { ! this.update_barOpenValues( ticker, barOpenValues ); ! this.update_barsMissingInTheDatabase( ! ticker , dateTime , barOpenValues ); } private void updateDictionaries( string ticker, DateTime dateTime ) { ! History barOpenValues = this.getBarOpenValues( ticker , dateTime ); ! this.updateDictionaries( ticker , dateTime , barOpenValues ); } #endregion updateDictionaries --- 314,328 ---- private void updateDictionaries( ! string ticker, DateTime dateTime , History barOpenValuesFromDatabase ) { ! this.update_barOpenValues( ticker, barOpenValuesFromDatabase ); ! this.update_barsMissingInTheDatabase( ticker , dateTime ); } private void updateDictionaries( string ticker, DateTime dateTime ) { ! History barOpenValuesFromDatabase = ! this.getBarOpenValuesFromDatabase( ticker , dateTime ); ! this.updateDictionaries( ticker , dateTime , barOpenValuesFromDatabase ); } #endregion updateDictionaries *************** *** 435,439 **** marketValue = this.barOpenValues.GetBarValue( ticker , dateTime ); return marketValue; ! } #endregion getMarketValueWithUpdatedDictionaries --- 340,344 ---- marketValue = this.barOpenValues.GetBarValue( ticker , dateTime ); return marketValue; ! } #endregion getMarketValueWithUpdatedDictionaries *************** *** 484,487 **** --- 389,400 ---- } #endregion GetMarketValue + + public bool WasExchanged( string ticker , DateTime dateTime ) + { + // forces bar caching + this.GetMarketValue( ticker , dateTime ); + bool wasExchanged = this.barOpenValues.ContainsBar( ticker , dateTime ); + return wasExchanged; + } } } |
|
From: Glauco S. <gla...@us...> - 2008-11-20 20:41:00
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataProviders/Bars In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv30639/b3_Data/DataProviders/Bars Modified Files: HistoricalBarProvider.cs Log Message: - the class has been marked as Serializable - but the private cache has been marked as non NonSerialized (to get smaller reports) Index: HistoricalBarProvider.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataProviders/Bars/HistoricalBarProvider.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HistoricalBarProvider.cs 8 Nov 2008 20:24:09 -0000 1.1 --- HistoricalBarProvider.cs 20 Nov 2008 20:40:49 -0000 1.2 *************** *** 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; *************** *** 30,35 **** --- 30,37 ---- /// Returns historical bars, playing with caching /// </summary> + [Serializable] public class HistoricalBarProvider { + [NonSerialized] IBarCache barCache; *************** *** 41,47 **** public double GetMarketValue( string ticker , DateTime dateTime ) { ! double marketValue = barCache.GetMarketValue( ticker , dateTime ); return marketValue; } } } --- 43,61 ---- public double GetMarketValue( string ticker , DateTime dateTime ) { ! double marketValue = this.barCache.GetMarketValue( ticker , dateTime ); return marketValue; } + + /// <summary> + /// true iif the ticker was exchange at the given dateTime + /// </summary> + /// <param name="ticker"></param> + /// <param name="dateTime"></param> + /// <returns></returns> + public bool WasExchanged( + string ticker , DateTime dateTime ) + { + return this.barCache.WasExchanged( ticker , dateTime ); + } } } |
|
From: Glauco S. <gla...@us...> - 2008-11-20 20:39:15
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv30455/b2_DataAccess Modified Files: DataBase.cs Log Message: A bug has been fixed in the following method: public static History GetBarOpenHistory( string ticker , int barInterval , DateTime firstDateTime , DateTime lastDateTime , List< Time > dailyTimes ) Index: DataBase.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/DataBase.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** DataBase.cs 12 Nov 2008 20:36:28 -0000 1.11 --- DataBase.cs 20 Nov 2008 20:39:03 -0000 1.12 *************** *** 222,228 **** SQLBuilder.GetFilterForTime( "baDateTimeForOpen" , SqlComparisonOperator.Equal , time ) + ! " and "; filterForDailyTimes = filterForDailyTimes.Substring( ! 0 , filterForDailyTimes.Length - " and ".Length ); return filterForDailyTimes; } --- 222,228 ---- SQLBuilder.GetFilterForTime( "baDateTimeForOpen" , SqlComparisonOperator.Equal , time ) + ! " or "; filterForDailyTimes = filterForDailyTimes.Substring( ! 0 , filterForDailyTimes.Length - " or ".Length ); return filterForDailyTimes; } *************** *** 238,242 **** { string sql = ! "select baOpen from bars " + "where (baTicker='" + ticker + "') and " + "(baInterval=" + barInterval + ") and" + --- 238,243 ---- { string sql = ! "select " + BarFieldNames.DateTimeForOpen + "," + BarFieldNames.Open + ! " from bars " + "where (baTicker='" + ticker + "') and " + "(baInterval=" + barInterval + ") and" + *************** *** 245,250 **** "(baDateTimeForOpen<=" + SQLBuilder.GetDateTimeConstant( lastDateTime ) ! + ") and" + ! DataBase.getFilterForDailyTimes( dailyTimes ); // "(Format([baDateTimeForOpen],'hh:mm:ss')>='" + // DataBase.getSqlTimeConstantForFirstDailyBar() + "') and" + --- 246,252 ---- "(baDateTimeForOpen<=" + SQLBuilder.GetDateTimeConstant( lastDateTime ) ! + ") and (" + ! DataBase.getFilterForDailyTimes( dailyTimes ) + ! ")"; // "(Format([baDateTimeForOpen],'hh:mm:ss')>='" + // DataBase.getSqlTimeConstantForFirstDailyBar() + "') and" + |
|
From: Glauco S. <gla...@us...> - 2008-11-20 20:38:07
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Timing In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv30351/b1_ADT/Timing Modified Files: Time.cs Log Message: marked as serializable Index: Time.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Timing/Time.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Time.cs 18 Nov 2008 22:31:29 -0000 1.3 --- Time.cs 20 Nov 2008 20:37:59 -0000 1.4 *************** *** 28,49 **** /// Represent a time (for any possible date) /// </summary> public struct Time : IEquatable<Time> , IComparable<Time> { public static bool IsValidTimeFormat ( string stringRepresentingTime ) { ! int hour = Convert.ToInt32(stringRepresentingTime.Substring(0,2)); ! int minute = Convert.ToInt32(stringRepresentingTime.Substring(3,2)); ! int second = Convert.ToInt32(stringRepresentingTime.Substring(6,2)); ! string firstSeparator = stringRepresentingTime.Substring(2,1); ! string secondSeparator = stringRepresentingTime.Substring(5,1); ! return (stringRepresentingTime.Length == 8) && ! (hour >= 0 && hour <= 24) && ! (firstSeparator == ":") && ! (minute >= 0 && minute <= 59) && ! (secondSeparator == ":") && ! (second >= 0 && second <= 59); } ! /// <summary> /// Returns a new DateTime, having the date as the given dateTime --- 28,76 ---- /// Represent a time (for any possible date) /// </summary> + [Serializable] public struct Time : IEquatable<Time> , IComparable<Time> { + #region IsValidTimeFormat public static bool IsValidTimeFormat ( string stringRepresentingTime ) { ! bool returnValue = false; ! char[] chars = stringRepresentingTime.ToCharArray(); ! if( ! //first - hour ! (chars[0]=='0' || chars[0]=='1' || chars[0]=='2') && ! //second - hour ! ( (chars[0]=='0' || chars[0]=='1') && ! (chars[1]=='0' || chars[1]=='1' || chars[1]=='2' || ! chars[1]=='3' || chars[1]=='4' || chars[1]=='5' || ! chars[1]=='6' || chars[1]=='7' || chars[1]=='8' || chars[1]=='9') || ! chars[0] == '2' && ! (chars[1]=='0' || chars[1]=='1' || chars[1]=='2' || ! chars[1]=='3' || chars[1]=='4') ) && ! //third - separator ! (chars[2]==':') && ! //fourth - minute ! (chars[3]=='0' || chars[3]=='1' || chars[3]=='2' || ! chars[3]=='3' || chars[3]=='4' || chars[3]=='5') && ! //fifth - minute ! (chars[4]=='0' || chars[4]=='1' || chars[4]=='2' || ! chars[4]=='3' || chars[4]=='4' || chars[4]=='5' || ! chars[4]=='6' || chars[4]=='7' || chars[4]=='8' || chars[4]=='9') && ! //sixth - separator ! (chars[5]==':') && ! //seventh - second ! (chars[6]=='0' || chars[6]=='1' || chars[6]=='2' || ! chars[6]=='3' || chars[6]=='4' || chars[6]=='5') && ! //eighth - second ! (chars[7]=='0' || chars[7]=='1' || chars[7]=='2' || ! chars[7]=='3' || chars[7]=='4' || chars[7]=='5' || ! chars[7]=='6' || chars[7]=='7' || chars[7]=='8' || chars[7]=='9') ! ) ! returnValue = true; ! return returnValue; } ! #endregion isValidTimeFormat ! ! /// <summary> /// Returns a new DateTime, having the date as the given dateTime *************** *** 58,62 **** time.Hour , time.Minute , time.Second ); } ! private DateTime standardDateTime; --- 85,90 ---- time.Hour , time.Minute , time.Second ); } ! ! private DateTime standardDateTime; *************** *** 94,98 **** int minute = Convert.ToInt32(stringRepresentingTime.Substring(3,2)); int second = Convert.ToInt32(stringRepresentingTime.Substring(6,2)); - return new DateTime(1900, 1, 1, hour, minute, second); } --- 122,125 ---- *************** *** 100,104 **** private void time_checkParameter ( string stringRepresentingTime ) { ! if( !Time.IsValidTimeFormat( stringRepresentingTime ) ) throw new Exception("string is not in the requested time-format hh:mm:ss"); } --- 127,132 ---- private void time_checkParameter ( string stringRepresentingTime ) { ! if( stringRepresentingTime.Length != 8 || ! !Time.IsValidTimeFormat( stringRepresentingTime ) ) throw new Exception("string is not in the requested time-format hh:mm:ss"); } |
|
From: Glauco S. <gla...@us...> - 2008-11-20 20:36:36
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Histories In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv30205/b1_ADT/Histories Modified Files: History.cs Log Message: A new property has been added: public List< DateTime > DateTimes Index: History.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Histories/History.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** History.cs 9 Nov 2008 19:23:02 -0000 1.15 --- History.cs 20 Nov 2008 20:36:30 -0000 1.16 *************** *** 3,7 **** History.cs ! Copyright (C) 2003 Glauco Siliprandi --- 3,7 ---- History.cs ! Copyright (C) 2003 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; using System.Collections; using System.Data; using QuantProject.ADT; --- 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 QuantProject.ADT; *************** *** 106,110 **** foreach ( DateTime dateTime in selectingHistory.Keys ) if ( this.ContainsKey( dateTime ) ) ! returnValue.Add( dateTime , this.GetValue( dateTime ) ); return returnValue; } --- 107,111 ---- foreach ( DateTime dateTime in selectingHistory.Keys ) if ( this.ContainsKey( dateTime ) ) ! returnValue.Add( dateTime , this.GetValue( dateTime ) ); return returnValue; } *************** *** 122,126 **** foreach ( DateTime dateTime in comparingHistory.Keys ) if ( ! this.ContainsKey( ExtendedDateTime.GetDate( dateTime ) ) ) ! returnValue = false; return returnValue; } --- 123,127 ---- foreach ( DateTime dateTime in comparingHistory.Keys ) if ( ! this.ContainsKey( ExtendedDateTime.GetDate( dateTime ) ) ) ! returnValue = false; return returnValue; } *************** *** 135,139 **** foreach ( DateTime dateTime in comparingHistoryOfDateTimes.Keys ) if ( ! this.ContainsKey( dateTime ) ) ! returnValue = false; return returnValue; } --- 136,140 ---- foreach ( DateTime dateTime in comparingHistoryOfDateTimes.Keys ) if ( ! this.ContainsKey( dateTime ) ) ! returnValue = false; return returnValue; } *************** *** 151,166 **** foreach ( DateTime dateTime in comparingHistoryOfDateTimes.Keys ) if ( this.ContainsKey( dateTime ) ) ! numberOfContainedDateTimes++; ! return numberOfContainedDateTimes >= ! (percentageOfDateTimes * numberOfComparingDateTimes)/100; } public void Interpolate( ICollection dateTimeCollection , ! IInterpolationMethod interpolationMethod ) { foreach ( DateTime dateTime in dateTimeCollection ) if ( !this.ContainsKey( dateTime ) ) ! this.Add( dateTime , interpolationMethod.GetValue( this , dateTime ) ); } --- 152,167 ---- foreach ( DateTime dateTime in comparingHistoryOfDateTimes.Keys ) if ( this.ContainsKey( dateTime ) ) ! numberOfContainedDateTimes++; ! return numberOfContainedDateTimes >= ! (percentageOfDateTimes * numberOfComparingDateTimes)/100; } public void Interpolate( ICollection dateTimeCollection , ! IInterpolationMethod interpolationMethod ) { foreach ( DateTime dateTime in dateTimeCollection ) if ( !this.ContainsKey( dateTime ) ) ! this.Add( dateTime , interpolationMethod.GetValue( this , dateTime ) ); } *************** *** 229,233 **** History returnValue = new History(); foreach ( DateTime key in this.Keys ) ! { double currentValue = this.multiplyBy_getCurrentValue( key ); returnValue.Add( key , currentValue * factor ); --- 230,234 ---- History returnValue = new History(); foreach ( DateTime key in this.Keys ) ! { double currentValue = this.multiplyBy_getCurrentValue( key ); returnValue.Add( key , currentValue * factor ); *************** *** 259,264 **** //millo ! #region "GetFunctionHistory" ! /// <summary> /// Gets a History object based on a statistical available function --- 260,265 ---- //millo ! #region "GetFunctionHistory" ! /// <summary> /// Gets a History object based on a statistical available function *************** *** 280,295 **** /// /// <param name="endDateTime"> /// It sets the end date for the time interval containing the returned History ! /// </param> /// public History GetFunctionHistory(Function functionToBeCalculated, int onEachPeriodOf, ! DateTime startDateTime , DateTime endDateTime ) { History functionHistory = new History(); ! int currentHistoryIndex = this.IndexOfKeyOrPrevious(startDateTime); double[] data = new double[onEachPeriodOf]; //the array contains the set of data whose length is specified by the user double periodIndex = 0; //in the while statement, if it isn't equal to Floor(currentHistoryIndex/onEachPeriodOf) ! //the current index belongs to the period with periodIndex increased by one int cursorThroughDataArray = 0; while ( --- 281,296 ---- /// /// <param name="endDateTime"> /// It sets the end date for the time interval containing the returned History ! /// </param> /// public History GetFunctionHistory(Function functionToBeCalculated, int onEachPeriodOf, ! DateTime startDateTime , DateTime endDateTime ) { History functionHistory = new History(); ! int currentHistoryIndex = this.IndexOfKeyOrPrevious(startDateTime); double[] data = new double[onEachPeriodOf]; //the array contains the set of data whose length is specified by the user double periodIndex = 0; //in the while statement, if it isn't equal to Floor(currentHistoryIndex/onEachPeriodOf) ! //the current index belongs to the period with periodIndex increased by one int cursorThroughDataArray = 0; while ( *************** *** 297,317 **** ( ((IComparable)this.GetKey( currentHistoryIndex )).CompareTo( endDateTime ) <= 0 ) ) { ! if (Math.Floor(Convert.ToDouble(currentHistoryIndex/onEachPeriodOf)) == periodIndex && ! cursorThroughDataArray < onEachPeriodOf) //currentHistoryIndex belongs to the current period ! { data[cursorThroughDataArray] = Convert.ToDouble(this.GetByIndex(currentHistoryIndex)); cursorThroughDataArray++; functionHistory.Add(this.GetKey( currentHistoryIndex ), null); currentHistoryIndex++; ! } else //currentHistoryIndex doesn't belong to the current period //so a new item can be added to the object History to be returned ! { cursorThroughDataArray = 0; DateTime dateTime = (DateTime)this.GetKey( currentHistoryIndex - onEachPeriodOf); --- 298,318 ---- ( ((IComparable)this.GetKey( currentHistoryIndex )).CompareTo( endDateTime ) <= 0 ) ) { ! if (Math.Floor(Convert.ToDouble(currentHistoryIndex/onEachPeriodOf)) == periodIndex && ! cursorThroughDataArray < onEachPeriodOf) //currentHistoryIndex belongs to the current period ! { data[cursorThroughDataArray] = Convert.ToDouble(this.GetByIndex(currentHistoryIndex)); cursorThroughDataArray++; functionHistory.Add(this.GetKey( currentHistoryIndex ), null); currentHistoryIndex++; ! } else //currentHistoryIndex doesn't belong to the current period //so a new item can be added to the object History to be returned ! { cursorThroughDataArray = 0; DateTime dateTime = (DateTime)this.GetKey( currentHistoryIndex - onEachPeriodOf); *************** *** 320,329 **** case Function.SimpleAverage: functionHistory.SetByIndex(currentHistoryIndex - onEachPeriodOf, ! BasicFunctions.SimpleAverage(data)); //functionHistory.Add( dateTime , BasicFunctions.SimpleAverage(data) ); break; case Function.StandardDeviation : functionHistory.SetByIndex(currentHistoryIndex - onEachPeriodOf, ! BasicFunctions.StdDev(data)); //functionHistory.Add( dateTime , BasicFunctions.StdDev(data) ); break; --- 321,330 ---- case Function.SimpleAverage: functionHistory.SetByIndex(currentHistoryIndex - onEachPeriodOf, ! BasicFunctions.SimpleAverage(data)); //functionHistory.Add( dateTime , BasicFunctions.SimpleAverage(data) ); break; case Function.StandardDeviation : functionHistory.SetByIndex(currentHistoryIndex - onEachPeriodOf, ! BasicFunctions.StdDev(data)); //functionHistory.Add( dateTime , BasicFunctions.StdDev(data) ); break; *************** *** 338,498 **** } ! #endregion ! ! /// <summary> ! /// It returns true if the current History item value is not null ! /// and is less than the immediate previous History item whose value is not null ! /// </summary> ! /// <param name="dateTime">The date key for current History item</param> ! public bool IsDecreased(DateTime dateTime) ! { ! bool isDecreased = false; ! int index = this.IndexOfKey(dateTime); ! int previousIndex = index - 1; ! if ( index <= 0) ! isDecreased = false; ! else ! { ! if(this.GetByIndex(index) != null) ! { while (this.GetByIndex(previousIndex) == null) ! { previousIndex --; } ! isDecreased = Convert.ToDouble( this.GetByIndex(index)) < ! Convert.ToDouble( this.GetByIndex(previousIndex) ); ! } ! } ! return isDecreased; ! } ! #region "GetSimpleMovingAverage( int , DateTime , int )" ! private double currentContributionToCurrentSum( ! int index, ! DateTime dateTime , ! int numPeriods ! ) ! { ! double currentContribution; ! currentContribution = Convert.ToDouble( this.GetByIndex( index ) ); ! if ( index >= numPeriods ) ! currentContribution -= ! Convert.ToDouble( this.GetByIndex( index - numPeriods ) ); ! return currentContribution; ! } ! ! public History GetSimpleMovingAverage( int numPeriods , DateTime startDateTime , DateTime endDateTime ) ! { ! History simpleMovingAverage = new History(); ! int index = this.IndexOfKeyOrPrevious( startDateTime ); ! double currentSum = 0; ! while ( ! ( index < this.Count ) && ! ( ((IComparable)this.GetKey( index )).CompareTo( endDateTime ) <= 0 ) ) ! { ! DateTime dateTime = (DateTime)this.GetKey( index ); ! currentSum = currentSum + ! currentContributionToCurrentSum( index , dateTime , numPeriods ); ! if ( index < ( numPeriods - 1 ) ) ! // current period is not after numPeriods ! simpleMovingAverage.Add( this.GetKey( index ) , null ); ! else ! { ! simpleMovingAverage.Add( dateTime , currentSum/numPeriods ); ! } ! index++; ! } ! return simpleMovingAverage; ! } ! #endregion ! public History GetSimpleMovingAverage( int numPeriods ) ! { ! // History simpleMovingAverage = new History(); ! // double currentSum = 0; ! // foreach (DictionaryEntry dictionaryEntry in this) ! // { ! // currentSum = currentSum + ! // currentContributionToCurrentSum( dictionaryEntry , numPeriods ); ! // if ( this.IndexOfKey( dictionaryEntry.Key ) >= numPeriods ) ! // { ! // simpleMovingAverage.Add( dictionaryEntry.Key , currentSum/numPeriods ); ! // } ! // else ! // // current period is not after numPeriods ! // simpleMovingAverage.Add( dictionaryEntry.Key , null ); ! // } ! // return simpleMovingAverage; ! return GetSimpleMovingAverage( numPeriods , ! (DateTime) this.GetKey( 0 ) , (DateTime) this.GetKey( this.Count - 1 ) ); ! } ! #region "Cross" ! private bool wasLessThan( History history , DateTime dateTime ) ! { ! int backStep = 1; ! while ((backStep < this.IndexOfKey( dateTime )) && ! (this.GetByIndex(history.IndexOfKey( dateTime )-backStep) != null) && ! (history.GetByIndex(history.IndexOfKey( dateTime )-backStep) != null) && ! (Convert.ToDouble( this.GetByIndex(this.IndexOfKey( dateTime )-backStep) )== ! Convert.ToDouble(history.GetByIndex(history.IndexOfKey( dateTime )-backStep) ! ))) ! backStep ++; ! return ! (this.GetByIndex(history.IndexOfKey( dateTime )-backStep) != null) && ! (history.GetByIndex(history.IndexOfKey( dateTime )-backStep) != null) && ! (Convert.ToDouble( this.GetByIndex(this.IndexOfKey( dateTime )-backStep) )< ! Convert.ToDouble(history.GetByIndex(history.IndexOfKey( dateTime )-backStep) ! )); ! } ! public bool Cross( History history , DateTime dateTime ) ! { ! bool cross; ! if ( ( this.IndexOfKey( dateTime ) <= 0 ) || ( history.IndexOfKey( dateTime ) <= 0 ) ) ! cross = false; ! else ! { ! cross = ( ( Convert.ToDouble( this[ dateTime ] ) ) > ! ( Convert.ToDouble( history[ dateTime ] ) ) ) && ! ( wasLessThan( history , dateTime ) ); ! } ! return cross; ! } ! #endregion ! #region "ToString" ! private string singleToString( DateTime dateTime , Object historyValue ) ! { ! return "\nDate: " + dateTime + ! " Value: " + historyValue.ToString(); ! } ! private string dictionaryEntryToString( DictionaryEntry dictionaryEntry ) ! { ! string returnString = ""; ! if ( dictionaryEntry.Value.GetType() != Type.GetType( "System.Collections.ArrayList" ) ) ! // a single value is stored for this DateTime ! returnString = singleToString( (DateTime)dictionaryEntry.Key , dictionaryEntry.Value ); ! else ! // possibly multivalues are stored for this DateTime ! foreach (Object historyValue in ((ArrayList)dictionaryEntry.Value) ) ! returnString += singleToString( (DateTime)dictionaryEntry.Key , historyValue ); ! return returnString; ! } ! public override string ToString() ! { ! string toString = ""; ! foreach ( DictionaryEntry dictionaryEntry in this ) ! toString += dictionaryEntryToString( dictionaryEntry ); ! return toString; ! } ! #endregion ! public void ReportToConsole() ! { ! Console.Write( this.ToString() ); ! } ! } } --- 339,512 ---- } ! #endregion ! ! /// <summary> ! /// It returns true if the current History item value is not null ! /// and is less than the immediate previous History item whose value is not null ! /// </summary> ! /// <param name="dateTime">The date key for current History item</param> ! public bool IsDecreased(DateTime dateTime) ! { ! bool isDecreased = false; ! int index = this.IndexOfKey(dateTime); ! int previousIndex = index - 1; ! if ( index <= 0) ! isDecreased = false; ! else ! { ! if(this.GetByIndex(index) != null) ! { while (this.GetByIndex(previousIndex) == null) ! { previousIndex --; } ! isDecreased = Convert.ToDouble( this.GetByIndex(index)) < ! Convert.ToDouble( this.GetByIndex(previousIndex) ); ! } ! } ! return isDecreased; ! } ! #region "GetSimpleMovingAverage( int , DateTime , int )" ! private double currentContributionToCurrentSum( ! int index, ! DateTime dateTime , ! int numPeriods ! ) ! { ! double currentContribution; ! currentContribution = Convert.ToDouble( this.GetByIndex( index ) ); ! if ( index >= numPeriods ) ! currentContribution -= ! Convert.ToDouble( this.GetByIndex( index - numPeriods ) ); ! return currentContribution; ! } ! ! public History GetSimpleMovingAverage( int numPeriods , DateTime startDateTime , DateTime endDateTime ) ! { ! History simpleMovingAverage = new History(); ! int index = this.IndexOfKeyOrPrevious( startDateTime ); ! double currentSum = 0; ! while ( ! ( index < this.Count ) && ! ( ((IComparable)this.GetKey( index )).CompareTo( endDateTime ) <= 0 ) ) ! { ! DateTime dateTime = (DateTime)this.GetKey( index ); ! currentSum = currentSum + ! currentContributionToCurrentSum( index , dateTime , numPeriods ); ! if ( index < ( numPeriods - 1 ) ) ! // current period is not after numPeriods ! simpleMovingAverage.Add( this.GetKey( index ) , null ); ! else ! { ! simpleMovingAverage.Add( dateTime , currentSum/numPeriods ); ! } ! index++; ! } ! return simpleMovingAverage; ! } ! #endregion ! public History GetSimpleMovingAverage( int numPeriods ) ! { ! // History simpleMovingAverage = new History(); ! // double currentSum = 0; ! // foreach (DictionaryEntry dictionaryEntry in this) ! // { ! // currentSum = currentSum + ! // currentContributionToCurrentSum( dictionaryEntry , numPeriods ); ! // if ( this.IndexOfKey( dictionaryEntry.Key ) >= numPeriods ) ! // { ! // simpleMovingAverage.Add( dictionaryEntry.Key , currentSum/numPeriods ); ! // } ! // else ! // // current period is not after numPeriods ! // simpleMovingAverage.Add( dictionaryEntry.Key , null ); ! // } ! // return simpleMovingAverage; ! return GetSimpleMovingAverage( numPeriods , ! (DateTime) this.GetKey( 0 ) , (DateTime) this.GetKey( this.Count - 1 ) ); ! } ! #region "Cross" ! private bool wasLessThan( History history , DateTime dateTime ) ! { ! int backStep = 1; ! while ((backStep < this.IndexOfKey( dateTime )) && ! (this.GetByIndex(history.IndexOfKey( dateTime )-backStep) != null) && ! (history.GetByIndex(history.IndexOfKey( dateTime )-backStep) != null) && ! (Convert.ToDouble( this.GetByIndex(this.IndexOfKey( dateTime )-backStep) )== ! Convert.ToDouble(history.GetByIndex(history.IndexOfKey( dateTime )-backStep) ! ))) ! backStep ++; ! return ! (this.GetByIndex(history.IndexOfKey( dateTime )-backStep) != null) && ! (history.GetByIndex(history.IndexOfKey( dateTime )-backStep) != null) && ! (Convert.ToDouble( this.GetByIndex(this.IndexOfKey( dateTime )-backStep) )< ! Convert.ToDouble(history.GetByIndex(history.IndexOfKey( dateTime )-backStep) ! )); ! } ! public bool Cross( History history , DateTime dateTime ) ! { ! bool cross; ! if ( ( this.IndexOfKey( dateTime ) <= 0 ) || ( history.IndexOfKey( dateTime ) <= 0 ) ) ! cross = false; ! else ! { ! cross = ( ( Convert.ToDouble( this[ dateTime ] ) ) > ! ( Convert.ToDouble( history[ dateTime ] ) ) ) && ! ( wasLessThan( history , dateTime ) ); ! } ! return cross; ! } ! #endregion ! public List< DateTime > DateTimes ! { ! get ! { ! List<DateTime> dateTimes = ! new List<DateTime>(); ! foreach ( DateTime dateTime in this.Keys ) ! dateTimes.Add( dateTime ); ! return dateTimes; ! } ! } ! ! #region "ToString" ! private string singleToString( DateTime dateTime , Object historyValue ) ! { ! return "\nDate: " + dateTime + ! " Value: " + historyValue.ToString(); ! } ! private string dictionaryEntryToString( DictionaryEntry dictionaryEntry ) ! { ! string returnString = ""; ! if ( dictionaryEntry.Value.GetType() != Type.GetType( "System.Collections.ArrayList" ) ) ! // a single value is stored for this DateTime ! returnString = singleToString( (DateTime)dictionaryEntry.Key , dictionaryEntry.Value ); ! else ! // possibly multivalues are stored for this DateTime ! foreach (Object historyValue in ((ArrayList)dictionaryEntry.Value) ) ! returnString += singleToString( (DateTime)dictionaryEntry.Key , historyValue ); ! return returnString; ! } ! public override string ToString() ! { ! string toString = ""; ! foreach ( DictionaryEntry dictionaryEntry in this ) ! toString += dictionaryEntryToString( dictionaryEntry ); ! return toString; ! } ! #endregion ! ! public void ReportToConsole() ! { ! Console.Write( this.ToString() ); ! } ! } } |
|
From: Glauco S. <gla...@us...> - 2008-11-20 20:35:41
|
Update of /cvsroot/quantproject/QuantProject/b4_Business In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv30060/b4_Business Modified Files: Business_SD.csproj Log Message: a07_DataProviders\HistoricalQuoteProvider.cs has been added Index: Business_SD.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/Business_SD.csproj,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** Business_SD.csproj 17 Nov 2008 19:46:39 -0000 1.33 --- Business_SD.csproj 20 Nov 2008 20:35:34 -0000 1.34 *************** *** 50,53 **** --- 50,54 ---- <Compile Include="a07_DataProviders\HistoricalBarProvider.cs" /> <Compile Include="a07_DataProviders\HistoricalMarketValueProvider.cs" /> + <Compile Include="a07_DataProviders\HistoricalQuoteProvider.cs" /> <Compile Include="a07_DataProviders\TickerNotExchangedException.cs" /> <Compile Include="a1_Financial\a2_Accounting\AccountProviding\IAccountProvider.cs" /> |
|
From: Glauco S. <gla...@us...> - 2008-11-20 20:35:17
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv29957/b4_Business/a07_DataProviders Added Files: HistoricalQuoteProvider.cs Log Message: To be extended by those HistoricalMarketValueProvider who will use the Quote table --- NEW FILE: HistoricalQuoteProvider.cs --- /* QuantProject - Quantitative Finance Library HistoricalQuoteProvider.cs Copyright (C) 2008 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.Data.DataProviders.Quotes; namespace QuantProject.Business.DataProviders { /// <summary> /// To be extended by those HistoricalMarketValueProvider who will use the Quote table /// </summary> public abstract class HistoricalQuoteProvider : HistoricalMarketValueProvider { public HistoricalQuoteProvider() { } protected abstract override string getDescription(); public override bool WasExchanged(string ticker, DateTime dateTime) { bool wasExchanged = HistoricalQuotesProvider.WasExchanged( ticker , dateTime ); return wasExchanged; } } } |
|
From: Glauco S. <gla...@us...> - 2008-11-20 20:26:41
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv28723/b1_ADT Modified Files: ADT_SD.csproj Log Message: Timing\Date.cs has been added Index: ADT_SD.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/ADT_SD.csproj,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ADT_SD.csproj 12 Nov 2008 20:32:06 -0000 1.12 --- ADT_SD.csproj 20 Nov 2008 20:26:29 -0000 1.13 *************** *** 98,101 **** --- 98,102 ---- <Compile Include="Collections\FloatArrayManager.cs" /> <Compile Include="Collections\Set.cs" /> + <Compile Include="Timing\Date.cs" /> <Compile Include="Timing\Time.cs" /> </ItemGroup> |
|
From: Glauco S. <gla...@us...> - 2008-11-20 20:26:11
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Timing In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv28641/b1_ADT/Timing Added Files: Date.cs Log Message: Represents a date (for any possible time) --- NEW FILE: Date.cs --- /* QuantProject - Quantitative Finance Library Date.cs Copyright (C) 2008 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; namespace QuantProject.ADT.Timing { /// <summary> /// Represents a date (for any possible time) /// </summary> public struct Date : IEquatable<Date> { DateTime standardDateTime; // Represents a date (for any possible time) public Date( DateTime dateTime ) { this.standardDateTime = new DateTime( dateTime.Year , dateTime.Month , dateTime.Day , 0 , 0 , 0 ); } // Represents a date (for any possible time) public Date( int year , int month , int day ) { this.standardDateTime = new DateTime( year , month , day , 0 , 0 , 0 ); } #region Equals and GetHashCode implementation // The code in this region is useful if you want to use this structure in collections. // If you don't need it, you can just remove the region and the ": IEquatable<Date>" declaration. public override bool Equals(object obj) { if (obj is Date) return Equals((Date)obj); // use Equals method below else return false; } public bool Equals(Date other) { // add comparisions for all members here return this.standardDateTime == other.standardDateTime; } public override int GetHashCode() { // combine the hash codes of all members here (e.g. with XOR operator ^) return standardDateTime.GetHashCode(); } public static bool operator ==(Date lhs, Date rhs) { return lhs.Equals(rhs); } public static bool operator !=(Date lhs, Date rhs) { return !(lhs.Equals(rhs)); // use operator == and negate result } public static bool operator <=(Date lhs, Date rhs) { bool isLessThanOrEqual = ( lhs.standardDateTime <= rhs.standardDateTime ); return isLessThanOrEqual; } public static bool operator >=(Date lhs, Date rhs) { bool isGreaterThanOrEqual = ( lhs.standardDateTime >= rhs.standardDateTime ); return isGreaterThanOrEqual; } public static bool operator <(Date lhs, Date rhs) { bool isLessThan = ( lhs.standardDateTime < rhs.standardDateTime ); return isLessThan; } public static bool operator >(Date lhs, Date rhs) { bool isGreaterThan = ( lhs.standardDateTime > rhs.standardDateTime ); return isGreaterThan; } #endregion } } |