quantproject-developers Mailing List for QuantProject (Page 24)
Brought to you by:
glauco_1
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(7) |
Nov
(103) |
Dec
(67) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(52) |
Feb
(9) |
Mar
(69) |
Apr
(53) |
May
(80) |
Jun
(23) |
Jul
(24) |
Aug
(112) |
Sep
(9) |
Oct
|
Nov
(58) |
Dec
(93) |
| 2005 |
Jan
(90) |
Feb
(93) |
Mar
(61) |
Apr
(56) |
May
(37) |
Jun
(61) |
Jul
(55) |
Aug
(68) |
Sep
(25) |
Oct
(46) |
Nov
(41) |
Dec
(37) |
| 2006 |
Jan
(33) |
Feb
(7) |
Mar
(19) |
Apr
(27) |
May
(73) |
Jun
(49) |
Jul
(83) |
Aug
(66) |
Sep
(45) |
Oct
(16) |
Nov
(15) |
Dec
(7) |
| 2007 |
Jan
(14) |
Feb
(33) |
Mar
|
Apr
(21) |
May
|
Jun
(34) |
Jul
(18) |
Aug
(100) |
Sep
(39) |
Oct
(55) |
Nov
(12) |
Dec
(2) |
| 2008 |
Jan
(120) |
Feb
(133) |
Mar
(129) |
Apr
(104) |
May
(42) |
Jun
(2) |
Jul
(52) |
Aug
(99) |
Sep
(134) |
Oct
|
Nov
(137) |
Dec
(48) |
| 2009 |
Jan
(48) |
Feb
(55) |
Mar
(61) |
Apr
(3) |
May
(2) |
Jun
(1) |
Jul
|
Aug
(51) |
Sep
|
Oct
(7) |
Nov
|
Dec
|
| 2010 |
Jan
(7) |
Feb
(1) |
Mar
(145) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(8) |
Dec
|
| 2011 |
Jan
(78) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(88) |
Sep
(6) |
Oct
(1) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
(1) |
Mar
|
Apr
(6) |
May
(5) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2013 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
| 2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Glauco S. <gla...@us...> - 2009-01-04 17:48:02
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/BarsSelectors In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv6211/Downloader/OpenTickDownloader/BarsSelectors Modified Files: MissingDailyBarsSelector.cs Log Message: Sql code has been removed from this class: a new constructor for QuantProject.Data.DataTables.Bars has been added Index: MissingDailyBarsSelector.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/BarsSelectors/MissingDailyBarsSelector.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MissingDailyBarsSelector.cs 20 Jul 2008 20:27:09 -0000 1.1 --- MissingDailyBarsSelector.cs 4 Jan 2009 17:47:57 -0000 1.2 *************** *** 3,7 **** MissingDailyBarsSelector.cs ! Copyright (C) 2008 Glauco Siliprandi --- 3,7 ---- MissingDailyBarsSelector.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; *************** *** 26,29 **** --- 26,30 ---- using QuantProject.ADT.Collections; + using QuantProject.ADT.Timing; using QuantProject.Data; using QuantProject.DataAccess; *************** *** 50,54 **** public MissingDailyBarsSelector( ! string[] tickers , DateTime firstDate , DateTime lastDate , --- 51,55 ---- public MissingDailyBarsSelector( ! string[] tickers , DateTime firstDate , DateTime lastDate , *************** *** 75,132 **** #region getBarsInTheDatabase ! private string getSqlTimeConstant( DateTime time ) ! { ! string sqlTimeConstant = ! time.Hour.ToString().PadLeft( 2 , '0' ) + ":" + ! time.Minute.ToString().PadLeft( 2 , '0' ) + ":" + ! time.Second.ToString().PadLeft( 2 , '0' ); ! return sqlTimeConstant; ! } ! private string getSqlTimeConstantForFirstDailyBar() ! { ! string sqlTimeConstantForFirstDailyBar = ! this.getSqlTimeConstant( ! this.firstBarOpenTimeInNewYorkTimeZone ); ! return sqlTimeConstantForFirstDailyBar; ! } ! #region getSqlTimeConstantForLastDailyBar ! private DateTime getLastBarOpenTimeInNewYorkTimeZone() { int secondsToBeAdded = this.barInterval * ( this.numberOfBarsToBeDownloadedForEachDay - 1 ); ! DateTime lastBarOpenTimeInNewYorkTimeZone = this.firstBarOpenTimeInNewYorkTimeZone.AddSeconds( secondsToBeAdded ); return lastBarOpenTimeInNewYorkTimeZone; } - private string getSqlTimeConstantForLastDailyBar() - { - DateTime lastBarOpenTimeInNewYorkTimeZone = - this.getLastBarOpenTimeInNewYorkTimeZone(); - string sqlTimeConstantForLastDailyBar = - this.getSqlTimeConstant( - lastBarOpenTimeInNewYorkTimeZone ); - return sqlTimeConstantForLastDailyBar; - } - #endregion getSqlTimeConstantForLastDailyBar private DataTable getBarsInTheDatabase( string ticker ) { ! string sql = ! "select baDateTimeForOpen from bars " + ! "where (baTicker='" + ticker + "') and " + ! "(baInterval=" + this.barInterval + ") and" + ! "(baDateTimeForOpen>=" + ! DataBaseWriter.GetDateConstant( this.firstDate ) + ") and" + ! "(baDateTimeForOpen<" + ! DataBaseWriter.GetDateConstant( this.lastDate.AddDays( 1 ) ) ! + ") and" + ! "(Format([baDateTimeForOpen],'hh:mm:ss')>='" + ! this.getSqlTimeConstantForFirstDailyBar() + "') and" + ! "(Format([baDateTimeForOpen],'hh:mm:ss')<='" + ! this.getSqlTimeConstantForLastDailyBar() + "');"; DataTable barsInTheDatabase = ! SqlExecutor.GetDataTable( sql ); return barsInTheDatabase; } --- 76,154 ---- #region getBarsInTheDatabase ! // private string getSqlTimeConstant( DateTime time ) ! // { ! // string sqlTimeConstant = ! // time.Hour.ToString().PadLeft( 2 , '0' ) + ":" + ! // time.Minute.ToString().PadLeft( 2 , '0' ) + ":" + ! // time.Second.ToString().PadLeft( 2 , '0' ); ! // return sqlTimeConstant; ! // } ! // private string getSqlTimeConstantForFirstDailyBar() ! // { ! // string sqlTimeConstantForFirstDailyBar = ! // this.getSqlTimeConstant( ! // this.firstBarOpenTimeInNewYorkTimeZone ); ! // return sqlTimeConstantForFirstDailyBar; ! // } ! // #region getSqlTimeConstantForLastDailyBar ! // private DateTime getLastBarOpenTimeInNewYorkTimeZone() ! // { ! // int secondsToBeAdded = this.barInterval * ! // ( this.numberOfBarsToBeDownloadedForEachDay - 1 ); ! // DateTime lastBarOpenTimeInNewYorkTimeZone = ! // this.firstBarOpenTimeInNewYorkTimeZone.AddSeconds( ! // secondsToBeAdded ); ! // return lastBarOpenTimeInNewYorkTimeZone; ! // } ! // private string getSqlTimeConstantForLastDailyBar() ! // { ! // DateTime lastBarOpenTimeInNewYorkTimeZone = ! // this.getLastBarOpenTimeInNewYorkTimeZone(); ! // string sqlTimeConstantForLastDailyBar = ! // this.getSqlTimeConstant( ! // lastBarOpenTimeInNewYorkTimeZone ); ! // return sqlTimeConstantForLastDailyBar; ! // } ! // #endregion getSqlTimeConstantForLastDailyBar ! ! ! private Time getLastBarOpenTimeInNewYorkTimeZone() { int secondsToBeAdded = this.barInterval * ( this.numberOfBarsToBeDownloadedForEachDay - 1 ); ! DateTime lastBarOpenDateTimeInNewYorkTimeZone = this.firstBarOpenTimeInNewYorkTimeZone.AddSeconds( secondsToBeAdded ); + Time lastBarOpenTimeInNewYorkTimeZone = + new Time( lastBarOpenDateTimeInNewYorkTimeZone ); return lastBarOpenTimeInNewYorkTimeZone; } private DataTable getBarsInTheDatabase( string ticker ) { ! Time lastBarOpenTimeInNewYorkTimeZone = ! this.getLastBarOpenTimeInNewYorkTimeZone(); DataTable barsInTheDatabase = ! new QuantProject.Data.DataTables.Bars( ! ticker , this.firstDate , this.lastDate , ! new Time( this.firstBarOpenTimeInNewYorkTimeZone ) , ! lastBarOpenTimeInNewYorkTimeZone , ! this.barInterval ); ! // string sql = ! // "select baDateTimeForOpen from bars " + ! // "where (baTicker='" + ticker + "') and " + ! // "(baInterval=" + this.barInterval + ") and" + ! // "(baDateTimeForOpen>=" + ! // DataBaseWriter.GetDateConstant( this.firstDate ) + ") and" + ! // "(baDateTimeForOpen<" + ! // DataBaseWriter.GetDateConstant( this.lastDate.AddDays( 1 ) ) ! // + ") and" + ! // "(Format([baDateTimeForOpen],'hh:mm:ss')>='" + ! // this.getSqlTimeConstantForFirstDailyBar() + "') and" + ! // "(Format([baDateTimeForOpen],'hh:mm:ss')<='" + ! // this.getSqlTimeConstantForLastDailyBar() + "');"; ! // DataTable barsInTheDatabase = ! // SqlExecutor.GetDataTable( sql ); return barsInTheDatabase; } |
|
From: Glauco S. <gla...@us...> - 2009-01-04 17:46:54
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/DatabaseManagement In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv5889/Downloader/OpenTickDownloader/DatabaseManagement Modified Files: DataBaseWriter.cs Log Message: Sql code has been removed: now the new method QuantProject.DataAccess.Tables.Bars..AddBar() is invoked Index: DataBaseWriter.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/DatabaseManagement/DataBaseWriter.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DataBaseWriter.cs 20 Jul 2008 20:32:24 -0000 1.2 --- DataBaseWriter.cs 4 Jan 2009 17:46:44 -0000 1.3 *************** *** 25,28 **** --- 25,29 ---- using QuantProject.DataAccess; + using QuantProject.DataAccess.Tables; namespace QuantProject.Applications.Downloader.OpenTickDownloader *************** *** 81,127 **** } ! #region getSqlCommand ! ! #region getSqlCommand_getValues ! private string formatDoubleForSql( double value ) ! { ! string formattedValue = ! value.ToString().Replace( ',' , '.' ); ! return formattedValue; ! } ! private string getSqlCommand_getValues( Bar bar ) ! { ! DateTime utcDateTimeForOpen = ! TimeZoneManager.ConvertToEST( bar.DateTimeForOpenInUTCTime ); ! string values = ! "'" + bar.Ticker + "' , " + ! "'" + bar.Exchange + "' , " + ! DataBaseWriter.GetDateConstant( utcDateTimeForOpen ) + " , " + ! bar.Interval + " , " + ! formatDoubleForSql( bar.Open ) + " , " + ! formatDoubleForSql( bar.High ) + " , " + ! formatDoubleForSql( bar.Low ) + " , " + ! formatDoubleForSql( bar.Close ) + " , " + ! bar.Volume; ! return values; ! } ! #endregion getSqlCommand_getValues ! ! private string getSqlCommand( Bar bar ) ! { ! string sqlCommand = ! "INSERT INTO bars " + ! "( baTicker, baExchange, baDateTimeForOpen, baInterval, baOpen, baHigh, baLow, baClose, baVolume ) " + ! "SELECT " + this.getSqlCommand_getValues( bar ) + ";"; ! // "SELECT 'MSFT' , 'Q' , #12/13/2004 15:16:17# , 60 , 30.2 , 30.5 , 29.9 , 30.3 , 100000 ;"; ! return sqlCommand; ! } ! #endregion getSqlCommand private void writeToDataBaseActually( Bar bar ) { ! string sqlCommand = ! this.getSqlCommand( bar ); ! SqlExecutor.ExecuteNonQuery( sqlCommand ); } private void riseDatabaseUpdatedEvent( Bar bar ) --- 82,133 ---- } ! // #region getSqlCommand ! // ! // #region getSqlCommand_getValues ! // private string formatDoubleForSql( double value ) ! // { ! // string formattedValue = ! // value.ToString().Replace( ',' , '.' ); ! // return formattedValue; ! // } ! // private string getSqlCommand_getValues( Bar bar ) ! // { ! // DateTime utcDateTimeForOpen = ! // TimeZoneManager.ConvertToEST( bar.DateTimeForOpenInUTCTime ); ! // string values = ! // "'" + bar.Ticker + "' , " + ! // "'" + bar.Exchange + "' , " + ! // DataBaseWriter.GetDateConstant( utcDateTimeForOpen ) + " , " + ! // bar.Interval + " , " + ! // formatDoubleForSql( bar.Open ) + " , " + ! // formatDoubleForSql( bar.High ) + " , " + ! // formatDoubleForSql( bar.Low ) + " , " + ! // formatDoubleForSql( bar.Close ) + " , " + ! // bar.Volume; ! // return values; ! // } ! // #endregion getSqlCommand_getValues ! // ! // private string getSqlCommand( Bar bar ) ! // { ! // string sqlCommand = ! // "INSERT INTO bars " + ! // "( baTicker, baExchange, baDateTimeForOpen, baInterval, baOpen, baHigh, baLow, baClose, baVolume ) " + ! // "SELECT " + this.getSqlCommand_getValues( bar ) + ";"; ! //// "SELECT 'MSFT' , 'Q' , #12/13/2004 15:16:17# , 60 , 30.2 , 30.5 , 29.9 , 30.3 , 100000 ;"; ! // return sqlCommand; ! // } ! // #endregion getSqlCommand private void writeToDataBaseActually( Bar bar ) { ! DateTime dateTimeForOpenInESTTime = ! TimeZoneManager.ConvertToEST( bar.DateTimeForOpenInUTCTime ); ! Bars.AddBar( ! bar.Ticker , bar.Exchange , dateTimeForOpenInESTTime , bar.Interval , ! bar.Open , bar.High , bar.Low , bar.Close , bar.Volume ); ! // string sqlCommand = ! // this.getSqlCommand( bar ); ! // SqlExecutor.ExecuteNonQuery( sqlCommand ); } private void riseDatabaseUpdatedEvent( Bar bar ) *************** *** 168,189 **** } ! /// <summary> ! /// Builds a date to be used in a Sql query ! /// </summary> ! /// <param name="dateTime"></param> ! /// <returns></returns> ! public static string GetDateConstant( DateTime dateTime ) ! { ! string dateConstant = ! "#" + ! dateTime.Month + "/" + ! dateTime.Day + "/" + ! dateTime.Year + " " + ! dateTime.Hour + ":" + ! dateTime.Minute + ":" + ! dateTime.Second + ! "#"; ! return dateConstant; ! } } } --- 174,195 ---- } ! // /// <summary> ! // /// Builds a date to be used in a Sql query ! // /// </summary> ! // /// <param name="dateTime"></param> ! // /// <returns></returns> ! // public static string GetDateConstant( DateTime dateTime ) ! // { ! // string dateConstant = ! // "#" + ! // dateTime.Month + "/" + ! // dateTime.Day + "/" + ! // dateTime.Year + " " + ! // dateTime.Hour + ":" + ! // dateTime.Minute + ":" + ! // dateTime.Second + ! // "#"; ! // return dateConstant; ! // } } } |
|
From: Glauco S. <gla...@us...> - 2009-01-03 18:45:22
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/BarsSelectors In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv30455/Downloader/OpenTickDownloader/BarsSelectors Modified Files: DailyBarsSelector.cs Log Message: bug fixed: the previous version threw out an unhandled exception after having requested the last bar (it happened just in some cases, for instance it happened if the last date was not on a market day) Index: DailyBarsSelector.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/BarsSelectors/DailyBarsSelector.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DailyBarsSelector.cs 20 Jul 2008 20:31:54 -0000 1.2 --- DailyBarsSelector.cs 3 Jan 2009 18:45:12 -0000 1.3 *************** *** 178,187 **** #endregion doNextStep ! private bool isTheCurrentBarBeyondTheLastDate() ! { ! bool isBeyondTheLastDate = ! ( this.currentDate.CompareTo( this.lastDate ) > 0 ); ! return isBeyondTheLastDate; ! } #region isTheCurrentBarSelectable --- 178,187 ---- #endregion doNextStep ! // private bool isTheCurrentBarBeyondTheLastDate() ! // { ! // bool isBeyondTheLastDate = ! // ( this.currentDate.CompareTo( this.lastDate ) > 0 ); ! // return isBeyondTheLastDate; ! // } #region isTheCurrentBarSelectable *************** *** 207,211 **** { this.doNextStep(); ! while ( !this.isTheCurrentBarBeyondTheLastDate() && !this.isTheCurrentBarSelectable() ) this.doNextStep(); --- 207,213 ---- { this.doNextStep(); ! // while ( !this.isTheCurrentBarBeyondTheLastDate() && ! // !this.isTheCurrentBarSelectable() ) ! while ( !this.AreAllBarsAlredyGiven && !this.isTheCurrentBarSelectable() ) this.doNextStep(); |
|
From: Glauco S. <gla...@us...> - 2009-01-03 18:42:01
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/TimeZoneManaging In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv29990/Downloader/OpenTickDownloader/TimeZoneManaging Modified Files: TimeZoneManager.cs Log Message: - an exception is now thrown if daylight saving time information are requested for years that are too old and are not managed by the class - the code has been refactored and it is more readable, now Index: TimeZoneManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/TimeZoneManaging/TimeZoneManager.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TimeZoneManager.cs 9 Jul 2008 22:22:23 -0000 1.1 --- TimeZoneManager.cs 3 Jan 2009 18:41:53 -0000 1.2 *************** *** 3,7 **** TimeZoneManager.cs ! Copyright (C) 2008 Glauco Siliprandi --- 3,7 ---- TimeZoneManager.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; *************** *** 40,43 **** --- 40,47 ---- #region IsDaylightSavingTime + #region getDstPeriod + + #region initialize_dstPeriods_ifTheCase + #region initialize_dstPeriods *************** *** 76,79 **** --- 80,121 ---- #endregion initialize_dstPeriods + private static void initialize_dstPeriods_ifTheCase() + { + if ( dSTPeriods == null ) + initialize_dstPeriods(); + } + #endregion initialize_dstPeriods_ifTheCase + + #region getDstPeriod_withInitialized_dstPeriods + private static void getDstPeriod_withInitialized_dstPeriods_checkParameters( + DateTime dateTimeInNewYorkTimeZone ) + { + if ( !TimeZoneManager.dSTPeriods.ContainsKey( dateTimeInNewYorkTimeZone.Year ) ) + throw new Exception( + "We don't have DaylightSavingTime information for the year " + + dateTimeInNewYorkTimeZone.Year + ". Please check the method " + + "initialize_dstPeriods() and possibly complete it with more years" ); + } + private static DSTPeriod getDstPeriod_withInitialized_dstPeriods( + DateTime dateTimeInNewYorkTimeZone ) + { + TimeZoneManager.getDstPeriod_withInitialized_dstPeriods_checkParameters( + dateTimeInNewYorkTimeZone ); + DSTPeriod dSTPeriod = + (DSTPeriod)dSTPeriods[ dateTimeInNewYorkTimeZone.Year ]; + return dSTPeriod; + } + #endregion getDstPeriod_withInitialized_dstPeriods + + private static DSTPeriod getDstPeriod( DateTime dateTimeInNewYorkTimeZone ) + { + TimeZoneManager.initialize_dstPeriods_ifTheCase(); + DSTPeriod dSTPeriod = + TimeZoneManager.getDstPeriod_withInitialized_dstPeriods( + dateTimeInNewYorkTimeZone ); + return dSTPeriod; + } + #endregion getDstPeriod + /// <summary> /// True iif the given DateTime is a daylightSavingTime *************** *** 84,95 **** DateTime dateTimeInNewYorkTimeZone ) { - if ( dSTPeriods == null ) - initialize_dstPeriods(); DSTPeriod dSTPeriod = ! (DSTPeriod)dSTPeriods[ dateTimeInNewYorkTimeZone.Year ]; bool isDaylightSavingTime = ( dSTPeriod.Begin.CompareTo( dateTimeInNewYorkTimeZone ) < 0 ) && ( dSTPeriod.End.CompareTo( dateTimeInNewYorkTimeZone ) > 0 ); ! return isDaylightSavingTime; } #endregion IsDaylightSavingTime --- 126,135 ---- DateTime dateTimeInNewYorkTimeZone ) { DSTPeriod dSTPeriod = ! TimeZoneManager.getDstPeriod( dateTimeInNewYorkTimeZone ); bool isDaylightSavingTime = ( dSTPeriod.Begin.CompareTo( dateTimeInNewYorkTimeZone ) < 0 ) && ( dSTPeriod.End.CompareTo( dateTimeInNewYorkTimeZone ) > 0 ); ! return isDaylightSavingTime; } #endregion IsDaylightSavingTime *************** *** 121,124 **** return dateTimeInEST; } ! } } --- 161,164 ---- return dateTimeInEST; } ! } } |
|
From: Glauco S. <gla...@us...> - 2009-01-03 18:38:42
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv29731/Downloader/OpenTickDownloader Modified Files: OTTickerDownloader.cs Log Message: the path for textFileForLoggingNotification has been generalized Index: OTTickerDownloader.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/OTTickerDownloader.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** OTTickerDownloader.cs 22 Aug 2008 22:57:43 -0000 1.4 --- OTTickerDownloader.cs 3 Jan 2009 18:38:31 -0000 1.5 *************** *** 23,26 **** --- 23,27 ---- using System.Data; using System.Threading; + using System.Windows.Forms; using QuantProject.ADT; *************** *** 260,265 **** private string getLogFileName() { string logFileName = ! @"C:\Quant\OpenTickDownloader\textFilesForLoggingNotification\textFileForLoggingNotification"; logFileName = logFileName + "_" + ExtendedDateTime.GetCompleteShortDescriptionForFileName( --- 261,268 ---- private string getLogFileName() { + // string logFileName = + // @"C:\Quant\OpenTickDownloader\textFilesForLoggingNotification\textFileForLoggingNotification"; string logFileName = ! Application.StartupPath + "\\textFileForLoggingNotification"; logFileName = logFileName + "_" + ExtendedDateTime.GetCompleteShortDescriptionForFileName( |
|
From: Marco M. <mi...@us...> - 2009-01-01 13:45:03
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13372/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator Modified Files: PVOStrategyIntraday.cs PVOStrategyIntradayMain.cs Log Message: Some new parameters have been added to the PVOStrategyIntraday. Index: PVOStrategyIntraday.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/PVOStrategyIntraday.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PVOStrategyIntraday.cs 23 Nov 2008 17:13:23 -0000 1.1 --- PVOStrategyIntraday.cs 1 Jan 2009 13:44:57 -0000 1.2 *************** *** 23,26 **** --- 23,27 ---- using System.Data; using System.Collections; + using System.Collections.Generic; using QuantProject.ADT; *************** *** 87,91 **** protected PVOPositionsStatus positionsForOutOfSampleStatus; - protected DateTime lastTimerDateTimeAfterLastExit; protected DateTime lastOptimizationDateTime; protected Account account; --- 88,91 ---- *************** *** 99,106 **** // private bool optimalPositionsHaveBeenUpdated; ! protected Time timeForCheckingCrossingThresholds_begin; ! protected Time timeForCheckingCrossingThresholds_end; ! protected Time timeForEntry; ! protected Time timeForExit; private string description_GetDescriptionForChooser() --- 99,112 ---- // private bool optimalPositionsHaveBeenUpdated; ! protected bool stopLossConditionReached; ! protected bool takeProfitConditionReached; ! protected double inefficiencyLengthInMinutes; ! protected double maxOpeningLengthInMinutes; ! protected Time lastEntryTime; ! protected List<Time> openingTimesForAvailableBars; ! protected double currentAccountValue; ! protected double previousAccountValue; ! protected double stopLoss; ! protected double takeProfit; private string description_GetDescriptionForChooser() *************** *** 112,115 **** --- 118,130 ---- } + private Time getLastEventTimeWithCachedBars() + { + return this.openingTimesForAvailableBars[openingTimesForAvailableBars.Count - 1]; + } + private Time getFirstEventTimeWithCachedBars() + { + return this.openingTimesForAvailableBars[0]; + } + public string Description { *************** *** 153,160 **** HistoricalMarketValueProvider historicalMarketValueProviderForInSample, HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample, ! Time timeForCheckingCrossingThresholds_begin, ! Time timeForCheckingCrossingThresholds_end, ! Time timeForEntry, ! Time timeForExit) { this.eligiblesSelector = eligiblesSelector; --- 168,175 ---- HistoricalMarketValueProvider historicalMarketValueProviderForInSample, HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample, ! double inefficiencyLengthInMinutes, ! double maxOpeningLengthInMinutes, ! List<Time> openingTimesForAvailableBars, ! double stopLoss, double takeProfit) { this.eligiblesSelector = eligiblesSelector; *************** *** 170,179 **** this.historicalMarketValueProviderForInSample = historicalMarketValueProviderForInSample; this.historicalMarketValueProviderForOutOfSample = historicalMarketValueProviderForOutOfSample; ! this.timeForCheckingCrossingThresholds_begin = timeForCheckingCrossingThresholds_begin; ! this.timeForCheckingCrossingThresholds_end = timeForCheckingCrossingThresholds_end; ! this.timeForEntry = timeForEntry; ! this.timeForExit = timeForExit; this.lastOptimizationDateTime = DateTime.MinValue; this.pvoStrategyIntraday_checkTimeParameters(); // this.optimalPositionsHaveBeenUpdated = false; } --- 185,197 ---- this.historicalMarketValueProviderForInSample = historicalMarketValueProviderForInSample; this.historicalMarketValueProviderForOutOfSample = historicalMarketValueProviderForOutOfSample; ! this.inefficiencyLengthInMinutes = inefficiencyLengthInMinutes; ! this.maxOpeningLengthInMinutes = maxOpeningLengthInMinutes; ! this.openingTimesForAvailableBars = openingTimesForAvailableBars; ! this.stopLoss = stopLoss; ! this.takeProfit = takeProfit; this.lastOptimizationDateTime = DateTime.MinValue; + this.pvoStrategyIntraday_checkTimeParameters(); + this.lastEntryTime = new Time("00:00:00"); // this.optimalPositionsHaveBeenUpdated = false; } *************** *** 191,198 **** HistoricalMarketValueProvider historicalMarketValueProviderForInSample, HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample, ! Time timeForCheckingCrossingThresholds_begin, ! Time timeForCheckingCrossingThresholds_end, ! Time timeForEntry, ! Time timeForExit) { --- 209,216 ---- HistoricalMarketValueProvider historicalMarketValueProviderForInSample, HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample, ! double inefficiencyLengthInMinutes, ! double maxOpeningLengthInMinutes, ! List<Time> openingTimesForAvailableBars, ! double stopLoss, double takeProfit) { *************** *** 203,209 **** historicalMarketValueProviderForInSample, historicalMarketValueProviderForOutOfSample, ! timeForCheckingCrossingThresholds_begin, ! timeForCheckingCrossingThresholds_end, ! timeForEntry, timeForExit); this.inSampleChooser = inSampleChooser; } --- 221,228 ---- historicalMarketValueProviderForInSample, historicalMarketValueProviderForOutOfSample, ! inefficiencyLengthInMinutes, ! maxOpeningLengthInMinutes, ! openingTimesForAvailableBars, ! stopLoss, takeProfit); this.inSampleChooser = inSampleChooser; } *************** *** 219,226 **** HistoricalMarketValueProvider historicalMarketValueProviderForInSample, HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample, ! Time timeForCheckingCrossingThresholds_begin, ! Time timeForCheckingCrossingThresholds_end, ! Time timeForEntry, ! Time timeForExit) { --- 238,245 ---- HistoricalMarketValueProvider historicalMarketValueProviderForInSample, HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample, ! double inefficiencyLengthInMinutes, ! double maxOpeningLengthInMinutes, ! List<Time> openingTimesForAvailableBars, ! double stopLoss, double takeProfit) { *************** *** 231,237 **** historicalMarketValueProviderForInSample, historicalMarketValueProviderForOutOfSample, ! timeForCheckingCrossingThresholds_begin, ! timeForCheckingCrossingThresholds_end, ! timeForEntry, timeForExit); this.inSampleChooser = inSampleChooser; } --- 250,257 ---- historicalMarketValueProviderForInSample, historicalMarketValueProviderForOutOfSample, ! inefficiencyLengthInMinutes, ! maxOpeningLengthInMinutes, ! openingTimesForAvailableBars, ! stopLoss, takeProfit); this.inSampleChooser = inSampleChooser; } *************** *** 248,255 **** HistoricalMarketValueProvider historicalMarketValueProviderForInSample, HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample, ! Time timeForCheckingCrossingThresholds_begin, ! Time timeForCheckingCrossingThresholds_end, ! Time timeForEntry, ! Time timeForExit) { --- 268,275 ---- HistoricalMarketValueProvider historicalMarketValueProviderForInSample, HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample, ! double inefficiencyLengthInMinutes, ! double maxOpeningLengthInMinutes, ! List<Time> openingTimesForAvailableBars, ! double stopLoss, double takeProfit) { *************** *** 260,266 **** historicalMarketValueProviderForInSample, historicalMarketValueProviderForOutOfSample, ! timeForCheckingCrossingThresholds_begin, ! timeForCheckingCrossingThresholds_end, ! timeForEntry, timeForExit); this.chosenPVOPositions = chosenPVOPositions; } --- 280,287 ---- historicalMarketValueProviderForInSample, historicalMarketValueProviderForOutOfSample, ! inefficiencyLengthInMinutes, ! maxOpeningLengthInMinutes, ! openingTimesForAvailableBars, ! stopLoss, takeProfit); this.chosenPVOPositions = chosenPVOPositions; } *************** *** 275,283 **** HistoricalMarketValueProvider historicalMarketValueProviderForInSample, HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample, ! Time timeForCheckingCrossingThresholds_begin, ! Time timeForCheckingCrossingThresholds_end, ! Time timeForEntry, ! Time timeForExit) ! { this.pvoStrategyIntraday(eligiblesSelector, minimumNumberOfEligiblesForValidOptimization, --- 296,303 ---- HistoricalMarketValueProvider historicalMarketValueProviderForInSample, HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample, ! double inefficiencyLengthInMinutes, ! double maxOpeningLengthInMinutes, ! List<Time> openingTimesForAvailableBars, ! double stopLoss, double takeProfit) { this.pvoStrategyIntraday(eligiblesSelector, minimumNumberOfEligiblesForValidOptimization, *************** *** 287,294 **** historicalMarketValueProviderForInSample, historicalMarketValueProviderForOutOfSample, ! timeForCheckingCrossingThresholds_begin, ! timeForCheckingCrossingThresholds_end, ! timeForEntry, ! timeForExit); this.chosenPVOPositions = chosenPVOPositions; } --- 307,314 ---- historicalMarketValueProviderForInSample, historicalMarketValueProviderForOutOfSample, ! inefficiencyLengthInMinutes, ! maxOpeningLengthInMinutes, ! openingTimesForAvailableBars, ! stopLoss, takeProfit); this.chosenPVOPositions = chosenPVOPositions; } *************** *** 399,449 **** #endregion #region newDateTimeEventHandler_closePositions ! private void newDateTimeEventHandler_closePositions() { ! AccountManager.ClosePositions( this.account ); } #endregion newDateTimeEventHandler_closePositions #region newDateTimeEventHandler_openPositions ! private void newDateTimeEventHandler_openPositions() { ! switch (this.positionsForOutOfSampleStatus) { ! case PVOPositionsStatus.Overbought: { ! #region manage Overbought case ! this.positionsForOutOfSample.WeightedPositions.Reverse(); ! try { ! AccountManager.OpenPositions( this.positionsForOutOfSample.WeightedPositions, ! this.account ); } ! catch(Exception ex) { ! string forBreakpoint = ex.Message; forBreakpoint = forBreakpoint + ""; } ! finally { ! this.positionsForOutOfSample.WeightedPositions.Reverse(); } - #endregion - break; - } - case PVOPositionsStatus.Oversold: - { - AccountManager.OpenPositions( this.positionsForOutOfSample.WeightedPositions, - this.account ); - break; - } - case PVOPositionsStatus.InTheMiddle://that is - { //pvoPositionsForOutOfSample has not been set - - break; - } - default: - { - //it should never been reached - break; } } --- 419,521 ---- #endregion + private bool allTickersAreExchanged(DateTime dateTime, + string[] tickers) + { + bool returnValue = true; + try{ + for( int i = 0; i < tickers.Length; i++ ) + { + if(!this.historicalMarketValueProviderForOutOfSample.WasExchanged( tickers[i], dateTime ) ) + { + returnValue = false; + i = tickers.Length; //exit from for + } + } + } + catch(Exception ex){ + string forBreakpoint = ex.Message; + forBreakpoint = forBreakpoint + ""; + returnValue = false; + } + return returnValue; + } + #region newDateTimeEventHandler_closePositions ! ! private void newDateTimeEventHandler_closePositions(Time currentDailyTime) { ! if( this.account.Portfolio.Count > 0 && ! (this.lastEntryTime.AddMinutes(maxOpeningLengthInMinutes) == currentDailyTime || ! this.stopLossConditionReached || this.takeProfitConditionReached ) && ! allTickersAreExchanged( this.now(), AccountManager.GetTickersInOpenedPositions(this.account) ) ) ! { ! AccountManager.ClosePositions( this.account ); ! this.lastEntryTime = new Time("00:00:00"); ! } } #endregion newDateTimeEventHandler_closePositions #region newDateTimeEventHandler_openPositions ! private void newDateTimeEventHandler_openPositions(Time currentDailyTime) { ! Time timeForClose = currentDailyTime.AddMinutes(maxOpeningLengthInMinutes); ! DateTime dateTimeForClose = Time.GetDateTimeFromMerge( this.now(), timeForClose ); ! if( this.account.Portfolio.Count == 0 && ! this.positionsForOutOfSample != null && ! timeForClose <= getLastEventTimeWithCachedBars() && ! this.allTickersAreExchanged( this.now(), this.positionsForOutOfSample.WeightedPositions.SignedTickers.Tickers ) && ! this.allTickersAreExchanged( dateTimeForClose, this.positionsForOutOfSample.WeightedPositions.SignedTickers.Tickers ) ) { ! switch (this.positionsForOutOfSampleStatus) { ! case PVOPositionsStatus.Overbought: { ! #region manage Overbought case ! this.positionsForOutOfSample.WeightedPositions.Reverse(); ! try ! { ! AccountManager.OpenPositions( this.positionsForOutOfSample.WeightedPositions, ! this.account ); ! this.lastEntryTime = currentDailyTime; ! this.previousAccountValue = this.account.GetMarketValue(); ! } ! catch(Exception ex) ! { ! string forBreakpoint = ex.Message; forBreakpoint = forBreakpoint + ""; ! } ! finally ! { ! this.positionsForOutOfSample.WeightedPositions.Reverse(); ! } ! #endregion ! break; } ! case PVOPositionsStatus.Oversold: { ! #region manage Oversold case ! try ! { ! AccountManager.OpenPositions( this.positionsForOutOfSample.WeightedPositions, ! this.account ); ! this.lastEntryTime = currentDailyTime; ! this.previousAccountValue = this.account.GetMarketValue(); ! } ! catch(Exception ex) ! { ! string forBreakpoint = ex.Message; forBreakpoint = forBreakpoint + ""; ! } ! #endregion oversold case ! break; } ! case PVOPositionsStatus.InTheMiddle://that is ! { //pvoPositionsForOutOfSample has not been set ! ! break; ! } ! default: { ! //it should never been reached ! break; } } } *************** *** 452,468 **** #region newDateTimeEventHandler_updateStatus ! private void newDateTimeEventHandler_setPositionsAndStatus() { DateTime beginOfOscillatingPeriod = ! Time.GetDateTimeFromMerge(this.now() , this.timeForCheckingCrossingThresholds_begin); DateTime endOfOscillatingPeriod = ! Time.GetDateTimeFromMerge(this.now() , this.timeForCheckingCrossingThresholds_end); for(int i = 0; i<this.chosenPVOPositions.Length; i++) { if(this.chosenPVOPositions[i] != null) ! this.positionsForOutOfSampleStatus = ! ((PVOPositions)this.chosenPVOPositions[i]).GetStatus(beginOfOscillatingPeriod, endOfOscillatingPeriod, this.benchmark.Ticker, this.historicalMarketValueProviderForOutOfSample, this.oversoldThresholdMAX, this.overboughtThresholdMAX); if(this.positionsForOutOfSampleStatus == PVOPositionsStatus.Oversold || this.positionsForOutOfSampleStatus == PVOPositionsStatus.Overbought ) --- 524,546 ---- #region newDateTimeEventHandler_updateStatus ! private void newDateTimeEventHandler_setPositionsAndStatus(Time currentDailyTime) { DateTime beginOfOscillatingPeriod = ! Time.GetDateTimeFromMerge(this.now() , currentDailyTime.AddMinutes(-inefficiencyLengthInMinutes) ); DateTime endOfOscillatingPeriod = ! Time.GetDateTimeFromMerge(this.now() , currentDailyTime); ! this.positionsForOutOfSample = null; ! this.positionsForOutOfSampleStatus = ! PVOPositionsStatus.InTheMiddle; for(int i = 0; i<this.chosenPVOPositions.Length; i++) { if(this.chosenPVOPositions[i] != null) ! try{ ! this.positionsForOutOfSampleStatus = ! ((PVOPositions)this.chosenPVOPositions[i]).GetStatus(beginOfOscillatingPeriod, endOfOscillatingPeriod, this.benchmark.Ticker, this.historicalMarketValueProviderForOutOfSample, this.oversoldThresholdMAX, this.overboughtThresholdMAX); + }catch(Exception ex){string str = ex.ToString();} + if(this.positionsForOutOfSampleStatus == PVOPositionsStatus.Oversold || this.positionsForOutOfSampleStatus == PVOPositionsStatus.Overbought ) *************** *** 475,489 **** #endregion newDateTimeEventHandler_updateStatus public virtual void NewDateTimeEventHandler( Object sender , DateTime dateTime ) { Time currentTime = new Time( dateTime ); ! if( timeForCheckingCrossingThresholds_end == currentTime ) ! this.newDateTimeEventHandler_setPositionsAndStatus(); ! else if( timeForEntry == currentTime ) ! this.newDateTimeEventHandler_openPositions(); ! else if( timeForExit == currentTime ) ! this.newDateTimeEventHandler_closePositions(); ! else if( currentTime > timeForExit ) this.newDateTimeEventHandler_updateTestingPositions( dateTime ); } --- 553,607 ---- #endregion newDateTimeEventHandler_updateStatus + #region newDateTimeEventHandler_updateStopLossAndTakeProfitConditions + protected virtual void newDateTimeEventHandler_updateStopLossAndTakeProfitConditions() + { + //this.previousAccountValue has been set at opening positions + this.stopLossConditionReached = false; + this.takeProfitConditionReached = false; + if(this.account.Portfolio.Count > 0) + { + try{ + this.currentAccountValue = this.account.GetMarketValue(); + double portfolioGainOrLoss = (this.currentAccountValue - this.previousAccountValue) + /this.previousAccountValue; + + if(!double.IsInfinity(portfolioGainOrLoss) && + portfolioGainOrLoss <= -this.stopLoss ) + { + this.stopLossConditionReached = true; + this.takeProfitConditionReached = false; + } + else if (!double.IsInfinity(portfolioGainOrLoss) && + portfolioGainOrLoss >= this.takeProfit ) + + { + this.stopLossConditionReached = false; + this.takeProfitConditionReached = true; + } + } + catch(Exception ex) + {string forBreakpoint = ex.Message; forBreakpoint = forBreakpoint + "";} + } + } + + #endregion newDateTimeEventHandler_updateStopLossAndTakeProfitConditions + public virtual void NewDateTimeEventHandler( Object sender , DateTime dateTime ) { Time currentTime = new Time( dateTime ); ! this.newDateTimeEventHandler_updateStopLossAndTakeProfitConditions(); ! this.newDateTimeEventHandler_closePositions(currentTime); ! if( currentTime < getLastEventTimeWithCachedBars() && ! currentTime >= ! getFirstEventTimeWithCachedBars().AddMinutes(inefficiencyLengthInMinutes) && ! this.chosenPVOPositions != null ) ! //it's possible to compute inefficiency and optimization ! //has been done ! { ! this.newDateTimeEventHandler_setPositionsAndStatus(currentTime); ! this.newDateTimeEventHandler_openPositions(currentTime); ! } ! if( currentTime == getLastEventTimeWithCachedBars() ) this.newDateTimeEventHandler_updateTestingPositions( dateTime ); } *************** *** 538,543 **** DateTime dateTime ) { - this.lastTimerDateTimeAfterLastExit = dateTime; - this.numDaysElapsedSinceLastOptimization++; //OLD - numDaysBetweenEachOptimization --> market days // if( this.account.Transactions.Count <= 1 || --- 656,659 ---- *************** *** 551,555 **** this.updateTestingPositions( dateTime ); //sets tickers to be chosen next time - this.numDaysElapsedSinceLastOptimization = 0; this.lastOptimizationDateTime = this.now(); } --- 667,670 ---- Index: PVOStrategyIntradayMain.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/PVOStrategyIntradayMain.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PVOStrategyIntradayMain.cs 23 Nov 2008 17:13:23 -0000 1.1 --- PVOStrategyIntradayMain.cs 1 Jan 2009 13:44:57 -0000 1.2 *************** *** 64,71 **** private HistoricalMarketValueProvider historicalMarketValueProviderForInSample; private HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample; ! private Time timeForCheckingCrossingThreshold_begin; ! private Time timeForCheckingCrossingThreshold_end; ! private Time timeForEntry; ! private Time timeForExit; private Timer timerForBackTester; private DateTime firstDateTime; --- 64,69 ---- private HistoricalMarketValueProvider historicalMarketValueProviderForInSample; private HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample; ! private double inefficiencyLengthInMinutes; ! private double maxOpeningLengthInMinutes; private Timer timerForBackTester; private DateTime firstDateTime; *************** *** 76,89 **** { //this.benchmark = new Benchmark( "^GSPC" ); ! this.timeForCheckingCrossingThreshold_begin = ! new Time("10:00:00"); ! this.timeForCheckingCrossingThreshold_end = ! new Time("11:00:00"); ! this.timeForEntry = this.timeForCheckingCrossingThreshold_end; ! // new Time("11:01:00"); ! this.timeForExit = ! new Time("12:00:00"); ! this.firstDateTime = new DateTime( 2007 , 1 , 1 ); ! this.lastDateTime = new DateTime( 2007 , 1, 31 ); this.intervalFrameInSeconds = 60; this.benchmark = new Benchmark( "MSFT" ); --- 74,82 ---- { //this.benchmark = new Benchmark( "^GSPC" ); ! this.inefficiencyLengthInMinutes = 30; ! this.maxOpeningLengthInMinutes = 120; ! ! this.firstDateTime = new DateTime( 2006 , 1 , 1 ); ! this.lastDateTime = new DateTime( 2007 , 12, 31 ); this.intervalFrameInSeconds = 60; this.benchmark = new Benchmark( "MSFT" ); *************** *** 166,171 **** double maxCorrelationAllowed = 0.96; ! int numberOfBestTestingPositionsToBeReturned = 100; ! numberOfBestTestingPositionsToBeReturned = 100; bool balancedWeightsOnVolatilityBase = true; float minimumAbsoluteReturnValue = 0.000001f; --- 159,164 ---- double maxCorrelationAllowed = 0.96; ! int numberOfBestTestingPositionsToBeReturned = 50; ! numberOfBestTestingPositionsToBeReturned = 50; bool balancedWeightsOnVolatilityBase = true; float minimumAbsoluteReturnValue = 0.000001f; *************** *** 201,211 **** { //int inSampleDays = 90; ! int inSampleDays = 10; int numDaysBetweenEachOptimization = 5; int minNumOfEligiblesForValidOptimization = 20; ! double oversoldThreshold = 0.0075; ! double overboughtThreshold = 0.0075; double oversoldThresholdMAX = 0.02; double overboughtThresholdMAX = 0.02; IStrategyForBacktester strategyForBacktester --- 194,206 ---- { //int inSampleDays = 90; ! int inSampleDays = 150; int numDaysBetweenEachOptimization = 5; int minNumOfEligiblesForValidOptimization = 20; ! double oversoldThreshold = 0.0065; ! double overboughtThreshold = 0.0065; double oversoldThresholdMAX = 0.02; double overboughtThresholdMAX = 0.02; + double stopLoss = 0.02; + double takeProfit = 0.005; IStrategyForBacktester strategyForBacktester *************** *** 221,226 **** historicalMarketValueProviderForInSample, historicalMarketValueProviderForOutOfSample, ! timeForCheckingCrossingThreshold_begin, timeForCheckingCrossingThreshold_end, ! timeForEntry, timeForExit); return strategyForBacktester; } --- 216,221 ---- historicalMarketValueProviderForInSample, historicalMarketValueProviderForOutOfSample, ! inefficiencyLengthInMinutes , maxOpeningLengthInMinutes, this.getDailyTimes(), ! stopLoss , takeProfit ); return strategyForBacktester; } *************** *** 231,239 **** { List<Time> dailyTimes = new List<Time>(); ! dailyTimes.Add(this.timeForCheckingCrossingThreshold_begin); ! dailyTimes.Add(this.timeForCheckingCrossingThreshold_end); ! if(this.timeForEntry > this.timeForCheckingCrossingThreshold_end) ! dailyTimes.Add(this.timeForEntry); ! dailyTimes.Add(this.timeForExit); return dailyTimes; } --- 226,241 ---- { List<Time> dailyTimes = new List<Time>(); ! dailyTimes.Add( new Time("10:00:00") ); ! dailyTimes.Add( new Time("10:30:00") ); ! dailyTimes.Add( new Time("11:00:00") ); ! dailyTimes.Add( new Time("11:30:00") ); ! dailyTimes.Add( new Time("12:00:00") ); ! dailyTimes.Add( new Time("12:30:00") ); ! dailyTimes.Add( new Time("13:00:00") ); ! dailyTimes.Add( new Time("13:30:00") ); ! dailyTimes.Add(new Time("14:00:00") ); ! dailyTimes.Add(new Time("14:30:00") ); ! dailyTimes.Add(new Time("15:00:00") ); ! dailyTimes.Add(new Time("16:00:00") ); return dailyTimes; } *************** *** 264,268 **** // new InteractiveBrokerAccountProvider(fixedPercentageSlippage); double cashToStart = 25000; ! double maxRunningHours = 0.40; HistoricalMarketValueProvider quoteProviderForBackTester = this.historicalMarketValueProviderForOutOfSample; --- 266,270 ---- // new InteractiveBrokerAccountProvider(fixedPercentageSlippage); double cashToStart = 25000; ! double maxRunningHours = 5; HistoricalMarketValueProvider quoteProviderForBackTester = this.historicalMarketValueProviderForOutOfSample; *************** *** 278,282 **** return endOfDayStrategyBackTester; } ! protected override string getPathForTheMainFolderWhereScriptsResultsAreToBeSaved() { --- 280,289 ---- return endOfDayStrategyBackTester; } ! ! protected override string getCustomSmallTextForFolderName() ! { ! return "PVOIntraday"; ! } ! protected override string getPathForTheMainFolderWhereScriptsResultsAreToBeSaved() { *************** *** 285,294 **** return pathForTheMainFolderWhereScriptsResultsAreToBeSaved; } ! ! protected override string getCustomSmallTextForFolderName() ! { ! return "PVOIntraday"; ! } ! protected override string getFullPathFileNameForMain() { --- 292,296 ---- return pathForTheMainFolderWhereScriptsResultsAreToBeSaved; } ! protected override string getFullPathFileNameForMain() { |
|
From: Marco M. <mi...@us...> - 2009-01-01 13:42:42
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13081/Tables Modified Files: Quotes.cs Log Message: Fixed minor bug in static method GetOpenToCloseStandardDeviation: now the method returns a double.Nan when the standardDeviation cannot be computed (so the caller can manage this value). Index: Quotes.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables/Quotes.cs,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** Quotes.cs 30 Dec 2008 00:14:16 -0000 1.35 --- Quotes.cs 1 Jan 2009 13:42:36 -0000 1.36 *************** *** 813,816 **** --- 813,817 ---- { DataTable dt; + double returnValue; string sql = "SELECT quotes.quTicker, " + SQLBuilder.GetStandardDeviationFunctionName() + *************** *** 822,826 **** " GROUP BY quotes.quTicker"; dt = SqlExecutor.GetDataTable( sql ); ! return (double)dt.Rows[0]["OpenToCloseStandDev"]; } --- 823,831 ---- " GROUP BY quotes.quTicker"; dt = SqlExecutor.GetDataTable( sql ); ! if( dt.Rows[0]["OpenToCloseStandDev"] is System.DBNull ) ! returnValue = double.NaN; ! else ! returnValue = (double)dt.Rows[0]["OpenToCloseStandDev"]; ! return returnValue; } |
|
From: Glauco S. <gla...@us...> - 2008-12-31 02:35:22
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13751/b7_Scripts/WalkForwardTesting/PairsTrading Modified Files: PairsTradingMain.cs Log Message: Minor changes to the script's parameters Index: PairsTradingMain.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/PairsTradingMain.cs,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** PairsTradingMain.cs 30 Dec 2008 00:16:05 -0000 1.26 --- PairsTradingMain.cs 31 Dec 2008 02:35:16 -0000 1.27 *************** *** 134,138 **** string tickersGroupId = "SP500"; // uncomment the following line for a faster script ! tickersGroupId = "fastTest"; // IEligiblesSelector eligiblesSelector = --- 134,138 ---- string tickersGroupId = "SP500"; // uncomment the following line for a faster script ! // tickersGroupId = "fastTest"; // IEligiblesSelector eligiblesSelector = *************** *** 165,169 **** int numberOfBestTestingPositionsToBeReturned = 50; // uncomment the following line for a faster script ! numberOfBestTestingPositionsToBeReturned = 10; IDecoderForTestingPositions decoderForWeightedPositions = --- 165,169 ---- int numberOfBestTestingPositionsToBeReturned = 50; // uncomment the following line for a faster script ! // numberOfBestTestingPositionsToBeReturned = 10; IDecoderForTestingPositions decoderForWeightedPositions = *************** *** 286,292 **** // uncomment the following two lines for a faster script firstDateTime = new DateTime( 2006 , 1 , 2 ); ! lastDateTime = new DateTime( 2006 , 1 , 31 ); ! double maxRunningHours = .3; EndOfDayStrategyBackTester endOfDayStrategyBackTester = --- 286,293 ---- // uncomment the following two lines for a faster script firstDateTime = new DateTime( 2006 , 1 , 2 ); ! lastDateTime = new DateTime( 2007 , 12 , 31 ); ! // lastDateTime = new DateTime( 2006 , 1 , 31 ); ! double maxRunningHours = 2.5; EndOfDayStrategyBackTester endOfDayStrategyBackTester = |
|
From: Glauco S. <gla...@us...> - 2008-12-31 02:34:47
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataProviders/Bars/Caching In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13693/b3_Data/DataProviders/Bars/Caching Modified Files: DailyBarCache.cs Log Message: Original constant values have been restored: debugging tasks required them to be momentarily changed Index: DailyBarCache.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataProviders/Bars/Caching/DailyBarCache.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** DailyBarCache.cs 31 Dec 2008 02:29:44 -0000 1.6 --- DailyBarCache.cs 31 Dec 2008 02:34:41 -0000 1.7 *************** *** 70,75 **** // this.hasTheCacheBeenCleanedUpInThePreviousUpdateActually = false; ! // int maxNumberOfItemsIn_barOpenValues = 100000; ! int maxNumberOfItemsIn_barOpenValues = 1000; int numberOfItemsToBeRemovedFrom_barOpenValues_whenCacheIsCleanedUp = maxNumberOfItemsIn_barOpenValues / 2; --- 70,75 ---- // this.hasTheCacheBeenCleanedUpInThePreviousUpdateActually = false; ! int maxNumberOfItemsIn_barOpenValues = 100000; ! // int maxNumberOfItemsIn_barOpenValues = 1000; // use to debug, only int numberOfItemsToBeRemovedFrom_barOpenValues_whenCacheIsCleanedUp = maxNumberOfItemsIn_barOpenValues / 2; *************** *** 84,89 **** // this.numberOfBarsIn_barOpenValues = 0; ! // int maxNumberOfItemsIn_barsMissingInTheDatabase = 100000; ! int maxNumberOfItemsIn_barsMissingInTheDatabase = 1000; int numberOfItemsToBeRemovedFrom_barsMissingInTheDatabase_whenCacheIsCleanedUp = maxNumberOfItemsIn_barsMissingInTheDatabase / 2; --- 84,89 ---- // this.numberOfBarsIn_barOpenValues = 0; ! int maxNumberOfItemsIn_barsMissingInTheDatabase = 100000; ! // int maxNumberOfItemsIn_barsMissingInTheDatabase = 1000; // use to debug, only int numberOfItemsToBeRemovedFrom_barsMissingInTheDatabase_whenCacheIsCleanedUp = maxNumberOfItemsIn_barsMissingInTheDatabase / 2; |
|
From: Glauco S. <gla...@us...> - 2008-12-31 02:29:52
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataProviders/Bars/Caching In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13492/b3_Data/DataProviders/Bars/Caching Modified Files: DailyBarCache.cs Log Message: Bug fixed: in the previous revision it could have happened that a bar was thrown out as a missing one, although it was in the database Index: DailyBarCache.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataProviders/Bars/Caching/DailyBarCache.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DailyBarCache.cs 30 Dec 2008 00:11:44 -0000 1.5 --- DailyBarCache.cs 31 Dec 2008 02:29:44 -0000 1.6 *************** *** 54,57 **** --- 54,59 ---- // List<DateTime> dateTimesForCleaningUp_barsMissingInTheDatabase; // List<string> tickersForCleaningUp_barsMissingInTheDatabase; + + // private bool hasTheCacheBeenCleanedUpInThePreviousUpdateActually; *************** *** 65,70 **** this.roughNumberOfItemsToBeCachedWithASingleQuery = 100; ! int maxNumberOfItemsIn_barOpenValues = 100000; int numberOfItemsToBeRemovedFrom_barOpenValues_whenCacheIsCleanedUp = maxNumberOfItemsIn_barOpenValues / 2; --- 67,75 ---- this.roughNumberOfItemsToBeCachedWithASingleQuery = 100; + + // this.hasTheCacheBeenCleanedUpInThePreviousUpdateActually = false; ! // int maxNumberOfItemsIn_barOpenValues = 100000; ! int maxNumberOfItemsIn_barOpenValues = 1000; int numberOfItemsToBeRemovedFrom_barOpenValues_whenCacheIsCleanedUp = maxNumberOfItemsIn_barOpenValues / 2; *************** *** 73,83 **** 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 = ! maxNumberOfItemsIn_barOpenValues / 2; this.barsMissingInTheDatabase = new BarCacheData( --- 78,91 ---- maxNumberOfItemsIn_barOpenValues , numberOfItemsToBeRemovedFrom_barOpenValues_whenCacheIsCleanedUp ); + // this.barOpenValues.CleaningUp += + // new CleaningUpEventHandler( this.cleaningUpEventHandler ); // this.barOpenValues = new Dictionary< DateTime , Dictionary< string , double > >(); // this.numberOfBarsIn_barOpenValues = 0; ! // int maxNumberOfItemsIn_barsMissingInTheDatabase = 100000; ! int maxNumberOfItemsIn_barsMissingInTheDatabase = 1000; int numberOfItemsToBeRemovedFrom_barsMissingInTheDatabase_whenCacheIsCleanedUp = ! maxNumberOfItemsIn_barsMissingInTheDatabase / 2; this.barsMissingInTheDatabase = new BarCacheData( *************** *** 87,90 **** --- 95,112 ---- } + // private void cleaningUpEventHandler( object sender ) + // { + // if ( this.hasTheCacheBeenCleanedUpInThePreviousUpdateActually ) + // throw new Exception( + // "The cache has reached its size limit twice while doing a single " + + // "this.update_barOpenValues() method. It should never happen, it looks like " + + // "the cache max size is too small" ); + // else + // // the cache has reached its limit size while doing + // // the this.update_barOpenValues_actually() method, and it's not the second + // // time in a row (a second chance will be given) + // this.hasTheCacheBeenCleanedUpInThePreviousUpdateActually = true; + // } + #region checkParameters *************** *** 185,189 **** #region update_barOpenValues ! private void addBarOpenValue( string ticker, DateTime dateTime , History barOpenValuesFromDatabase ) { --- 207,214 ---- #region update_barOpenValues ! #region update_barOpenValues_actually ! ! #region update_barOpenValues_addBarForCurrent_dateTimeIndex ! private void update_barOpenValues_addBarFor_currentDateTime( string ticker, DateTime dateTime , History barOpenValuesFromDatabase ) { *************** *** 193,202 **** ticker , dateTime , barOpenValue ); } private void update_barOpenValues( string ticker, History barOpenValuesFromDatabase ) { ! foreach ( DateTime dateTime in barOpenValuesFromDatabase.TimeLine ) ! this.addBarOpenValue( ticker , dateTime , barOpenValuesFromDatabase ); } #endregion update_barOpenValues --- 218,274 ---- ticker , dateTime , barOpenValue ); } + private void update_barOpenValues_addBarForCurrent_dateTimeIndex( + string ticker , int dateTimeIndex , History barOpenValuesFromDatabase ) + { + DateTime currentDateTime = + (DateTime)barOpenValuesFromDatabase.GetKey( dateTimeIndex ); + this.update_barOpenValues_addBarFor_currentDateTime( + ticker , currentDateTime , barOpenValuesFromDatabase ); + } + #endregion update_barOpenValues_addBarForCurrent_dateTimeIndex + + private void update_barOpenValues_actually( + string ticker, History barOpenValuesFromDatabase ) + { + for ( int dateTimeIndex = barOpenValuesFromDatabase.Count - 1 ; + dateTimeIndex >=0 ; dateTimeIndex-- ) + // we use a descending order because we want to be sure that + // the first date time of the History will be in the cache, + // at the end of the cycle; + // we don't want the first date time to be removed by the cache, + // and that could happen if dateTime(s) were added after the first one + // in the History; + // notice that the bar requested by the GetMarketValue() that lead to + // this point, if present in the database, is the first date time in + // the History, so we absolutely want it to be in the cache, + // when this method is done; the first date time in the History is the + // last one to be inserted into the cache, because we don't want to run the risk + // that the cache is cleaned up after it has been inserted + this.update_barOpenValues_addBarForCurrent_dateTimeIndex( + ticker , dateTimeIndex , barOpenValuesFromDatabase ); + // foreach ( DateTime dateTime in barOpenValuesFromDatabase.TimeLine ) + // this.addBarOpenValue( ticker , dateTime , barOpenValuesFromDatabase ); + } + #endregion update_barOpenValues_actually + // private void updateAgainIfCacheHasBeenCleanedUpInThePreviousUpdate( + // string ticker, History barOpenValuesFromDatabase ) + // { + // if ( this.hasTheCacheBeenCleanedUpInThePreviousUpdateActually ) + // // executing this.update_barOpenValues_actually() the cache has reached + // // its size limit and then it has removed some items; + // // we want to be sure that barOpenValuesFromDatabase are not removed by that event + // // thus we add them again + // { + // this.update_barOpenValues_actually( ticker , barOpenValuesFromDatabase ); + // this.hasTheCacheBeenCleanedUpInThePreviousUpdateActually = false; + // } + // } private void update_barOpenValues( string ticker, History barOpenValuesFromDatabase ) { ! this.update_barOpenValues_actually( ticker , barOpenValuesFromDatabase ); ! // this.updateAgainIfCacheHasBeenCleanedUpInThePreviousUpdate( ! // ticker , barOpenValuesFromDatabase ); } #endregion update_barOpenValues *************** *** 395,399 **** try { ! this.GetMarketValue( ticker , dateTime ); } catch ( MissingBarException missingBarException ) --- 467,471 ---- try { ! this.GetMarketValue( ticker , dateTime ); } catch ( MissingBarException missingBarException ) |
|
From: Glauco S. <gla...@us...> - 2008-12-31 02:25:08
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataProviders/Bars/Caching In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13153/b3_Data/DataProviders/Bars/Caching Modified Files: BarCacheData.cs Log Message: The code has been refactored to be better organized and more readable Index: BarCacheData.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataProviders/Bars/Caching/BarCacheData.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BarCacheData.cs 18 Dec 2008 20:06:27 -0000 1.2 --- BarCacheData.cs 31 Dec 2008 02:24:57 -0000 1.3 *************** *** 27,30 **** --- 27,36 ---- { /// <summary> + /// this event is risen when the cache has reached it max size and it needs to + /// remove some items + /// </summary> + public delegate void CleaningUpEventHandler( object sender ); + + /// <summary> /// Basic data structure used by bar caches: each IBarCache will use its own /// strategy, but it will probably use this class for adding bars to the cache *************** *** 33,36 **** --- 39,44 ---- public class BarCacheData { + public event CleaningUpEventHandler CleaningUp; + private int maxNumberOfItemsIn_bars; private int numberOfItemsToBeRemovedFrom_bars_whenCacheIsCleanedUp; *************** *** 72,86 **** #region AddBar - private void add_dateTime_toCacheIfTheCase( - DateTime dateTime ) - { - if ( !this.bars.ContainsKey( dateTime ) ) - // no data is yet in cache for this dateTime and a - this.bars.Add( dateTime , new Dictionary< string , double >() ); - } ! #region addBar_with_dateTime_alreadyInCache ! ! #region addBar_actually #region removeValuesFromTheCacheIfMaxSizeHasBeenReached --- 80,85 ---- #region AddBar ! #region addNonPresentBar #region removeValuesFromTheCacheIfMaxSizeHasBeenReached *************** *** 133,138 **** #region removeCurrentItemFrom_bars_actually - - #region removeCurrentItemFrom_bars_only private void removeCurrentDateTimeFromCache_ifAllBarsHaveBeenRemovedForThatDateTime( DateTime dateTimeForLastBarRemovedFromCache ) --- 132,135 ---- *************** *** 142,146 **** this.bars.Remove( dateTimeForLastBarRemovedFromCache ); } ! private void removeCurrentItemFrom_bars_only() { DateTime dateTimeForCurrentBarToBeRemoved = --- 139,143 ---- this.bars.Remove( dateTimeForLastBarRemovedFromCache ); } ! private void removeCurrentItemFrom_bars_actually() { DateTime dateTimeForCurrentBarToBeRemoved = *************** *** 153,157 **** dateTimeForCurrentBarToBeRemoved ); } ! #endregion removeCurrentItemFrom_bars_only #region updateMembersUsedToCleanUp_bars --- 150,161 ---- dateTimeForCurrentBarToBeRemoved ); } ! #endregion removeCurrentItemFrom_bars_actually ! ! private void removeCurrentItemFrom_bars() ! { ! removeCurrentItemFrom_bars_actually(); ! this.numberOfBarsIn_bars--; ! } ! #endregion removeCurrentItemFrom_bars #region updateMembersUsedToCleanUp_bars *************** *** 174,191 **** #endregion updateMembersUsedToCleanUp_bars - private void removeCurrentItemFrom_bars_actually() - { - this.removeCurrentItemFrom_bars_only(); - // this.updateMembersUsedToCleanUp_bars(); - } - #endregion removeCurrentItemFrom_bars_actually - - private void removeCurrentItemFrom_bars() - { - removeCurrentItemFrom_bars_actually(); - this.numberOfBarsIn_bars--; - } - #endregion removeCurrentItemFrom_bars - private void removeNextItemFrom_bars() { --- 178,181 ---- *************** *** 215,259 **** if ( this.numberOfBarsIn_bars >= this.maxNumberOfItemsIn_bars ) // the cache is full this.removeValuesFromTheCache(); } #endregion removeValuesFromTheCacheIfMaxSizeHasBeenReached ! private void addBar_actually( ! string ticker, double barOpenValue , ! Dictionary< string , double > barsInDictionaryForTheGivenDateTime ) { ! this.removeValuesFromTheCacheIfMaxSizeHasBeenReached(); ! barsInDictionaryForTheGivenDateTime.Add( ticker , barOpenValue ); ! this.numberOfBarsIn_bars++; } - #endregion addBar_actually ! private void addBar( string ticker, double barOpenValue , Dictionary< string , double > barsInDictionaryForTheGivenDateTime ) { ! if ( !barsInDictionaryForTheGivenDateTime.ContainsKey( ticker ) ) ! // the cache doesn't contain the open value ! // for the given ticker and the given dateTime ! this.addBar_actually( ! ticker , barOpenValue , barsInDictionaryForTheGivenDateTime); } ! // private void addBarOpenValue( ! // Dictionary< string , double > barOpenValuesInCacheForGivenDateTime , ! // string ticker, DateTime dateTime , double theValue ) // { ! // this.addBarOpenValue( ! // barOpenValuesInCacheForGivenDateTime , ticker , barOpenValue ); // } ! private void addBar_with_dateTime_alreadyInCache( string ticker, DateTime dateTime , double theValue ) { Dictionary< string , double > barsInDictionaryForTheGivenDateTime = this.bars[ dateTime ]; ! this.addBar( ticker , theValue , barsInDictionaryForTheGivenDateTime ); } #endregion addBar_with_dateTime_alreadyInCache /// <summary> /// adds a bar to the cache; if there is no more space in the cache, (supposed) --- 205,273 ---- if ( this.numberOfBarsIn_bars >= this.maxNumberOfItemsIn_bars ) // the cache is full + { + if ( this.CleaningUp != null ) + this.CleaningUp( this ); this.removeValuesFromTheCache(); + } } #endregion removeValuesFromTheCacheIfMaxSizeHasBeenReached ! #region addBarWithEnsuredSpaceInTheCache ! private void add_dateTime_toCacheIfTheCase( ! DateTime dateTime ) { ! if ( !this.bars.ContainsKey( dateTime ) ) ! // no data is yet in cache for this dateTime and a ! this.bars.Add( dateTime , new Dictionary< string , double >() ); } ! #region addBar_with_dateTime_alreadyInCache ! ! private void addNonPresentBar_actually( string ticker, double barOpenValue , Dictionary< string , double > barsInDictionaryForTheGivenDateTime ) { ! // this.removeValuesFromTheCacheIfMaxSizeHasBeenReached(); ! barsInDictionaryForTheGivenDateTime.Add( ticker , barOpenValue ); ! this.numberOfBarsIn_bars++; } ! ! // private void addBar( ! // string ticker, double barOpenValue , ! // Dictionary< string , double > barsInDictionaryForTheGivenDateTime ) // { ! // if ( !barsInDictionaryForTheGivenDateTime.ContainsKey( ticker ) ) ! // // the cache doesn't contain the open value ! // // for the given ticker and the given dateTime ! // this.addBar_actually( ! // ticker , barOpenValue , barsInDictionaryForTheGivenDateTime); // } ! private void addNonPresentBar_with_dateTime_alreadyInCache( string ticker, DateTime dateTime , double theValue ) { Dictionary< string , double > barsInDictionaryForTheGivenDateTime = this.bars[ dateTime ]; ! this.addNonPresentBar_actually( ticker , theValue , barsInDictionaryForTheGivenDateTime ); } #endregion addBar_with_dateTime_alreadyInCache + private void addNonPresentBarWithEnsuredSpaceInTheCache( + string ticker, DateTime dateTime , double theValue ) + { + this.add_dateTime_toCacheIfTheCase( dateTime ); + this.addNonPresentBar_with_dateTime_alreadyInCache( + ticker , dateTime , theValue ); + } + #endregion addBarWithEnsuredSpaceInTheCache + + private void addNonPresentBar( + string ticker, DateTime dateTime , double theValue ) + { + this.removeValuesFromTheCacheIfMaxSizeHasBeenReached(); + this.addNonPresentBarWithEnsuredSpaceInTheCache( ticker , dateTime , theValue ); + } + #endregion addNonPresentBar + /// <summary> /// adds a bar to the cache; if there is no more space in the cache, (supposed) *************** *** 266,272 **** string ticker, DateTime dateTime , double theValue ) { ! this.add_dateTime_toCacheIfTheCase( dateTime ); ! this.addBar_with_dateTime_alreadyInCache( ! ticker , dateTime , theValue ); } #endregion AddBar --- 280,285 ---- string ticker, DateTime dateTime , double theValue ) { ! if ( !this.ContainsBar( ticker , dateTime ) ) ! this.addNonPresentBar( ticker , dateTime , theValue ); } #endregion AddBar |
|
From: Glauco S. <gla...@us...> - 2008-12-30 00:36:07
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv21010/Downloader Modified Files: QuantDownloader_SD.csproj Log Message: - OpenTickDownloader\UserForms\OTWebDownloader.resx has been removed - WebDownloader.resx has been removed Index: QuantDownloader_SD.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/QuantDownloader_SD.csproj,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** QuantDownloader_SD.csproj 30 Dec 2008 00:17:45 -0000 1.6 --- QuantDownloader_SD.csproj 30 Dec 2008 00:35:57 -0000 1.7 *************** *** 105,114 **** <None Include="app.config" /> <None Include="App.ico" /> - <EmbeddedResource Include="OpenTickDownloader\UserForms\OTWebDownloader.resx"> - <DependentUpon>OTWebDownloader.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="WebDownloader.resx"> - <DependentUpon>WebDownloader.cs</DependentUpon> - </EmbeddedResource> </ItemGroup> <ItemGroup> --- 105,108 ---- |
|
From: Glauco S. <gla...@us...> - 2008-12-30 00:29:16
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv20069/b2_DataAccess Modified Files: DataAccess_SD.csproj Log Message: - ConfigurationManagement\DbTypeChooser.resx has been removed - ConfigurationManagement\MySqlConnectionForm.resx has been removed Index: DataAccess_SD.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/DataAccess_SD.csproj,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DataAccess_SD.csproj 30 Dec 2008 00:06:27 -0000 1.5 --- DataAccess_SD.csproj 30 Dec 2008 00:29:04 -0000 1.6 *************** *** 80,89 **** <Compile Include="Tables\EventType.cs" /> <Compile Include="MissingQuoteException.cs" /> - <EmbeddedResource Include="ConfigurationManagement\DbTypeChooser.resx"> - <DependentUpon>DbTypeChooser.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="ConfigurationManagement\MySqlConnectionForm.resx"> - <DependentUpon>MySqlConnectionForm.cs</DependentUpon> - </EmbeddedResource> </ItemGroup> <ItemGroup> --- 80,83 ---- |
|
From: Glauco S. <gla...@us...> - 2008-12-30 00:19:31
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/TickerSelectors In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18031/Downloader/TickerSelectors Modified Files: TickerGroupsViewer.cs TickerViewer.cs Log Message: Now both Access and MySql are supported Index: TickerGroupsViewer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/TickerSelectors/TickerGroupsViewer.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** TickerGroupsViewer.cs 2 Jul 2006 19:59:01 -0000 1.10 --- TickerGroupsViewer.cs 30 Dec 2008 00:19:20 -0000 1.11 *************** *** 3,7 **** TickerGroupsViewer.cs ! Copyright (C) 2003 Marco Milletti --- 3,7 ---- TickerGroupsViewer.cs ! Copyright (C) 2003 Marco Milletti [...1395 lines suppressed...] ! private void listViewGroupsAndTickers_DragEnter(object sender, System.Windows.Forms.DragEventArgs e) ! { ! //MessageBox.Show("Drag here?"); ! } ! private void listViewGroupsAndTickers_ColumnClick(object sender, System.Windows.Forms.ColumnClickEventArgs e) ! { ! if(this.lastSorting == SortOrder.None || ! this.lastSorting == SortOrder.Descending) ! this.listViewGroupsAndTickers.Sorting = SortOrder.Ascending; ! else ! this.listViewGroupsAndTickers.Sorting = SortOrder.Descending; ! this.listViewGroupsAndTickers.Sort(); ! this.lastSorting = this.listViewGroupsAndTickers.Sorting; ! this.listViewGroupsAndTickers.Sorting = SortOrder.None; ! } ! Index: TickerViewer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/TickerSelectors/TickerViewer.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TickerViewer.cs 8 Apr 2006 14:11:28 -0000 1.8 --- TickerViewer.cs 30 Dec 2008 00:19:20 -0000 1.9 *************** *** 679,685 **** DataTable changedData = this.tableTickers.GetChanges(); this.skipRowChangedEvent = true; ! OleDbSingleTableAdapter adapter = new OleDbSingleTableAdapter(); adapter.SetAdapter("tickers"); ! adapter.OleDbDataAdapter.Update(changedData); this.tableTickers.AcceptChanges(); } --- 679,685 ---- DataTable changedData = this.tableTickers.GetChanges(); this.skipRowChangedEvent = true; ! SingleTableDbDataAdapter adapter = new SingleTableDbDataAdapter(); adapter.SetAdapter("tickers"); ! adapter.DbDataAdapter.Update(changedData); this.tableTickers.AcceptChanges(); } |
|
From: Glauco S. <gla...@us...> - 2008-12-30 00:19:10
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17910/Downloader Modified Files: WebDownloader.cs Log Message: Now both Access and MySql are supported Index: WebDownloader.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/WebDownloader.cs,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** WebDownloader.cs 30 Nov 2008 22:52:04 -0000 1.22 --- WebDownloader.cs 30 Dec 2008 00:18:53 -0000 1.23 *************** *** 5,9 **** using System.Windows.Forms; using System.Data; ! using System.Data.OleDb; using System.Net; using System.IO; --- 5,9 ---- using System.Windows.Forms; using System.Data; ! using System.Data.Common; using System.Net; using System.IO; *************** *** 22,26 **** public class WebDownloader : System.Windows.Forms.Form, ITickerSelector { ! public OleDbConnection OleDbConnection1 = ConnectionProvider.OleDbConnection; public System.Windows.Forms.DataGrid dataGrid1; private System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter1; --- 22,26 ---- public class WebDownloader : System.Windows.Forms.Form, ITickerSelector { ! // public DbConnection DbConnection1 = ConnectionProvider.DbConnection; public System.Windows.Forms.DataGrid dataGrid1; private System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter1; *************** *** 29,33 **** private System.Data.OleDb.OleDbCommand oleDbUpdateCommand1; private System.Data.OleDb.OleDbCommand oleDbDeleteCommand1; - private System.Data.OleDb.OleDbCommand oleDbCommand1; public DataSet1 DsTickerCurrentlyDownloaded = new DataSet1(); private System.Windows.Forms.Button buttonDownloadQuotesOfSelectedTickers; --- 29,32 ---- *************** *** 129,133 **** { this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WebDownloader)); this.dataGrid1 = new System.Windows.Forms.DataGrid(); this.oleDbDataAdapter1 = new System.Data.OleDb.OleDbDataAdapter(); --- 128,131 ---- *************** *** 136,140 **** this.oleDbSelectCommand1 = new System.Data.OleDb.OleDbCommand(); this.oleDbUpdateCommand1 = new System.Data.OleDb.OleDbCommand(); - this.oleDbCommand1 = new System.Data.OleDb.OleDbCommand(); this.buttonDownloadQuotesOfSelectedTickers = new System.Windows.Forms.Button(); this.dateTimePickerStartingDate = new System.Windows.Forms.DateTimePicker(); --- 134,137 ---- *************** *** 183,187 **** // oleDbDeleteCommand1 // - this.oleDbDeleteCommand1.CommandText = resources.GetString("oleDbDeleteCommand1.CommandText"); this.oleDbDeleteCommand1.Parameters.AddRange(new System.Data.OleDb.OleDbParameter[] { new System.Data.OleDb.OleDbParameter("Original_quId", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, false, ((byte)(10)), ((byte)(0)), "quId", System.Data.DataRowVersion.Original, null), --- 180,183 ---- *************** *** 218,222 **** // oleDbUpdateCommand1 // - this.oleDbUpdateCommand1.CommandText = resources.GetString("oleDbUpdateCommand1.CommandText"); this.oleDbUpdateCommand1.Parameters.AddRange(new System.Data.OleDb.OleDbParameter[] { new System.Data.OleDb.OleDbParameter("quClose", System.Data.OleDb.OleDbType.Single, 0, System.Data.ParameterDirection.Input, false, ((byte)(7)), ((byte)(0)), "quClose", System.Data.DataRowVersion.Current, null), --- 214,217 ---- *************** *** 240,248 **** new System.Data.OleDb.OleDbParameter("Original_quTicker1", System.Data.OleDb.OleDbType.VarWChar, 8, System.Data.ParameterDirection.Input, false, ((byte)(0)), ((byte)(0)), "quTicker", System.Data.DataRowVersion.Original, null)}); // - // oleDbCommand1 - // - this.oleDbCommand1.CommandText = "DELETE quotes.* FROM quotes INNER JOIN tickers ON quotes.quTicker = tickers.tiTic" + - "ker"; - // // buttonDownloadQuotesOfSelectedTickers // --- 235,238 ---- *************** *** 580,597 **** private void openDbAndSetOleDbCommand() { ! try ! { ! if (this.OleDbConnection1.State != ConnectionState.Open) ! this.OleDbConnection1.Open(); ! oleDbCommand1.Connection = this.OleDbConnection1; ! } ! catch(Exception ex) ! { ! MessageBox.Show(ex.ToString()); ! } ! finally ! { ! this.OleDbConnection1.Close(); ! } } --- 570,587 ---- private void openDbAndSetOleDbCommand() { ! // try ! // { ! // if (this.DbConnection1.State != ConnectionState.Open) ! // this.DbConnection1.Open(); ! // oleDbCommand1.Connection = this.DbConnection1; ! // } ! // catch(Exception ex) ! // { ! // MessageBox.Show(ex.ToString()); ! // } ! // finally ! // { ! // this.DbConnection1.Close(); ! // } } |
|
From: Glauco S. <gla...@us...> - 2008-12-30 00:18:38
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17826/Downloader Modified Files: TickerDownloader.cs Log Message: Now both Access and MySql are supported Index: TickerDownloader.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/TickerDownloader.cs,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** TickerDownloader.cs 30 Nov 2008 22:52:04 -0000 1.22 --- TickerDownloader.cs 30 Dec 2008 00:18:26 -0000 1.23 *************** *** 2,5 **** --- 2,6 ---- using System.Threading; using System.Data; + using System.Data.Common; using System.IO; using System.Net; *************** *** 16,20 **** public class TickerDownloader { ! private System.Data.OleDb.OleDbConnection oleDbConnection1; private WebDownloader p_myForm; private int numOfTickersToDownload; --- 17,21 ---- public class TickerDownloader { ! // private DbConnection dbConnection1; private WebDownloader p_myForm; private int numOfTickersToDownload; *************** *** 37,41 **** private int numberOfQuotesInDatabase; private DataTable downloadedValuesFromSource; ! private OleDbSingleTableAdapter adapter; private Stream stream; private StreamReader streamReader; --- 38,42 ---- private int numberOfQuotesInDatabase; private DataTable downloadedValuesFromSource; ! private SingleTableDbDataAdapter adapter; private Stream stream; private StreamReader streamReader; *************** *** 64,70 **** p_myForm = myForm; this.tickerDownloader_copyPropertiesFromForm( myForm ); ! this.oleDbConnection1 = myForm.OleDbConnection1; this.downloadedValuesFromSource = new DataTable("quotes"); ! this.adapter = new OleDbSingleTableAdapter("SELECT * FROM quotes WHERE 1=2", this.downloadedValuesFromSource); this.downloadedValuesFromSource.Columns[Quotes.AdjustedCloseToCloseRatio].DefaultValue = 0; --- 65,71 ---- p_myForm = myForm; this.tickerDownloader_copyPropertiesFromForm( myForm ); ! // this.dbConnection1 = myForm.DbConnection1; this.downloadedValuesFromSource = new DataTable("quotes"); ! this.adapter = new SingleTableDbDataAdapter("SELECT * FROM quotes WHERE 1=2", this.downloadedValuesFromSource); this.downloadedValuesFromSource.Columns[Quotes.AdjustedCloseToCloseRatio].DefaultValue = 0; *************** *** 150,164 **** private void addTickerToFaultyTickers() { ! System.Data.OleDb.OleDbCommand odc = new System.Data.OleDb.OleDbCommand(); ! odc.CommandText = "insert into faultyTickers ( ftTicker , ftDateTime ) " + ! "values ( '" + currentTicker + "' , #" + ! DateTime.Now.Month + "/" + ! DateTime.Now.Day + "/" + ! DateTime.Now.Year + " " + ! DateTime.Now.Hour + "." + ! DateTime.Now.Minute + "." + ! DateTime.Now.Second + "# )"; ! odc.Connection = this.oleDbConnection1; ! odc.ExecuteNonQuery(); } --- 151,175 ---- private void addTickerToFaultyTickers() { ! string sqlNonQuery = ! "insert into faultyTickers ( ftTicker , ftDateTime ) " + ! "values ( '" + currentTicker + "' , #" + ! DateTime.Now.Month + "/" + ! DateTime.Now.Day + "/" + ! DateTime.Now.Year + " " + ! DateTime.Now.Hour + "." + ! DateTime.Now.Minute + "." + ! DateTime.Now.Second + "# )"; ! SqlExecutor.ExecuteNonQuery( sqlNonQuery ); ! // System.Data.OleDb.OleDbCommand odc = new System.Data.OleDb.OleDbCommand(); ! // odc.CommandText = "insert into faultyTickers ( ftTicker , ftDateTime ) " + ! // "values ( '" + currentTicker + "' , #" + ! // DateTime.Now.Month + "/" + ! // DateTime.Now.Day + "/" + ! // DateTime.Now.Year + " " + ! // DateTime.Now.Hour + "." + ! // DateTime.Now.Minute + "." + ! // DateTime.Now.Second + "# )"; ! // odc.Connection = this.dbConnection1; ! // odc.ExecuteNonQuery(); } *************** *** 521,526 **** if(this.isComputeCloseToCloseRatioSelected) QuantProject.DataAccess.Tables.Quotes.ComputeCloseToCloseValues(this.downloadedValuesFromSource); ! this.adapter.OleDbDataAdapter.ContinueUpdateOnError = true; ! int rowsUpdated = this.adapter.OleDbDataAdapter.Update(this.downloadedValuesFromSource); if(rowsUpdated > 0) this.updateCurrentStatusDatabaseUpdated("Added " + rowsUpdated.ToString() + " rows"); --- 532,537 ---- if(this.isComputeCloseToCloseRatioSelected) QuantProject.DataAccess.Tables.Quotes.ComputeCloseToCloseValues(this.downloadedValuesFromSource); ! this.adapter.DbDataAdapter.ContinueUpdateOnError = true; ! int rowsUpdated = this.adapter.DbDataAdapter.Update(this.downloadedValuesFromSource); if(rowsUpdated > 0) this.updateCurrentStatusDatabaseUpdated("Added " + rowsUpdated.ToString() + " rows"); |
|
From: Glauco S. <gla...@us...> - 2008-12-30 00:17:54
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17708/Downloader Modified Files: QuantDownloader_SD.csproj Log Message: Minor change to the OTFeed_NET.dll reference in the project Index: QuantDownloader_SD.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/QuantDownloader_SD.csproj,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** QuantDownloader_SD.csproj 20 Jul 2008 20:27:52 -0000 1.5 --- QuantDownloader_SD.csproj 30 Dec 2008 00:17:45 -0000 1.6 *************** *** 32,36 **** <ItemGroup> <Reference Include="OTFeed_NET"> ! <HintPath>..\..\OTFeed_NET\OTFeed_NET.dll</HintPath> <SpecificVersion>False</SpecificVersion> </Reference> --- 32,36 ---- <ItemGroup> <Reference Include="OTFeed_NET"> ! <HintPath>..\..\OTFeed_NET.dll</HintPath> <SpecificVersion>False</SpecificVersion> </Reference> *************** *** 108,111 **** --- 108,114 ---- <DependentUpon>OTWebDownloader.cs</DependentUpon> </EmbeddedResource> + <EmbeddedResource Include="WebDownloader.resx"> + <DependentUpon>WebDownloader.cs</DependentUpon> + </EmbeddedResource> </ItemGroup> <ItemGroup> |
|
From: Glauco S. <gla...@us...> - 2008-12-30 00:16:21
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17345/b7_Scripts/WalkForwardTesting/PairsTrading Modified Files: PairsTradingMain.cs Log Message: Minor changes to the strategy parameters Index: PairsTradingMain.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/PairsTradingMain.cs,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** PairsTradingMain.cs 18 Dec 2008 20:08:16 -0000 1.25 --- PairsTradingMain.cs 30 Dec 2008 00:16:05 -0000 1.26 *************** *** 134,138 **** string tickersGroupId = "SP500"; // uncomment the following line for a faster script ! // tickersGroupId = "fastTest"; // IEligiblesSelector eligiblesSelector = --- 134,138 ---- string tickersGroupId = "SP500"; // uncomment the following line for a faster script ! tickersGroupId = "fastTest"; // IEligiblesSelector eligiblesSelector = *************** *** 215,219 **** // uncomment the following line for a faster script // inSampleDays = 5; ! // inSampleDays = 60; IIntervalsSelector intervalsSelectorForOutOfSample = --- 215,219 ---- // uncomment the following line for a faster script // inSampleDays = 5; ! inSampleDays = 60; IIntervalsSelector intervalsSelectorForOutOfSample = *************** *** 286,292 **** // uncomment the following two lines for a faster script firstDateTime = new DateTime( 2006 , 1 , 2 ); ! lastDateTime = new DateTime( 2007 , 12 , 31 ); ! double maxRunningHours = 5; EndOfDayStrategyBackTester endOfDayStrategyBackTester = --- 286,292 ---- // uncomment the following two lines for a faster script firstDateTime = new DateTime( 2006 , 1 , 2 ); ! lastDateTime = new DateTime( 2006 , 1 , 31 ); ! double maxRunningHours = .3; EndOfDayStrategyBackTester endOfDayStrategyBackTester = |
|
From: Glauco S. <gla...@us...> - 2008-12-30 00:15:47
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataTables In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17196/b3_Data/DataTables Modified Files: VisuallyValidatedQuotes.cs Log Message: Now bot Access and MySql are supported Index: VisuallyValidatedQuotes.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataTables/VisuallyValidatedQuotes.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** VisuallyValidatedQuotes.cs 25 May 2004 15:18:07 -0000 1.1 --- VisuallyValidatedQuotes.cs 30 Dec 2008 00:15:34 -0000 1.2 *************** *** 47,52 **** "vvTicker='" + quotes.Ticker + "' and " + "vvDate=" + FilterBuilder.GetDateConstant( quoteDate ) ); ! OleDbSingleTableAdapter oleDbSingleTableAdapter = ! new OleDbSingleTableAdapter( "select * from visuallyValidatedQuotes where 1=2" ); string hashValue = getHashValue( quotes , quoteDate ); --- 47,52 ---- "vvTicker='" + quotes.Ticker + "' and " + "vvDate=" + FilterBuilder.GetDateConstant( quoteDate ) ); ! SingleTableDbDataAdapter oleDbSingleTableAdapter = ! new SingleTableDbDataAdapter( "select * from visuallyValidatedQuotes where 1=2" ); string hashValue = getHashValue( quotes , quoteDate ); *************** *** 58,62 **** oleDbSingleTableAdapter.DataTable.Rows[ 0 ][ VisuallyValidatedQuotes.HashValue ] = hashValue; oleDbSingleTableAdapter.DataTable.Rows[ 0 ][ VisuallyValidatedQuotes.EditDate ] = DateTime.Now; ! oleDbSingleTableAdapter.OleDbDataAdapter.Update( oleDbSingleTableAdapter.DataTable ); } catch ( Exception ex ) --- 58,62 ---- oleDbSingleTableAdapter.DataTable.Rows[ 0 ][ VisuallyValidatedQuotes.HashValue ] = hashValue; oleDbSingleTableAdapter.DataTable.Rows[ 0 ][ VisuallyValidatedQuotes.EditDate ] = DateTime.Now; ! oleDbSingleTableAdapter.DbDataAdapter.Update( oleDbSingleTableAdapter.DataTable ); } catch ( Exception ex ) |
|
From: Glauco S. <gla...@us...> - 2008-12-30 00:15:47
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17196/b2_DataAccess/Tables Modified Files: Tickers_tickerGroups.cs ValidatedTickers.cs Log Message: Now bot Access and MySql are supported Index: ValidatedTickers.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables/ValidatedTickers.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ValidatedTickers.cs 27 May 2004 16:47:49 -0000 1.5 --- ValidatedTickers.cs 30 Dec 2008 00:15:34 -0000 1.6 *************** *** 58,63 **** SqlExecutor.ExecuteNonQuery( "delete * from validatedTickers " + "where " + ValidatedTickers.Ticker + "='" + ticker + "'" ); ! OleDbSingleTableAdapter oleDbSingleTableAdapter = ! new OleDbSingleTableAdapter(); oleDbSingleTableAdapter.SetAdapter( "validatedTickers" ); oleDbSingleTableAdapter.DataTable.Rows.Add( oleDbSingleTableAdapter.DataTable.NewRow() ); --- 58,63 ---- SqlExecutor.ExecuteNonQuery( "delete * from validatedTickers " + "where " + ValidatedTickers.Ticker + "='" + ticker + "'" ); ! SingleTableDbDataAdapter oleDbSingleTableAdapter = ! new SingleTableDbDataAdapter(); oleDbSingleTableAdapter.SetAdapter( "validatedTickers" ); oleDbSingleTableAdapter.DataTable.Rows.Add( oleDbSingleTableAdapter.DataTable.NewRow() ); *************** *** 66,70 **** oleDbSingleTableAdapter.DataTable.Rows[ 0 ][ ValidatedTickers.EndDate ] = endDate; oleDbSingleTableAdapter.DataTable.Rows[ 0 ][ ValidatedTickers.HashValue ] = hashValue; ! oleDbSingleTableAdapter.OleDbDataAdapter.Update( oleDbSingleTableAdapter.DataTable ); } catch ( Exception ex ) --- 66,70 ---- oleDbSingleTableAdapter.DataTable.Rows[ 0 ][ ValidatedTickers.EndDate ] = endDate; oleDbSingleTableAdapter.DataTable.Rows[ 0 ][ ValidatedTickers.HashValue ] = hashValue; ! oleDbSingleTableAdapter.DbDataAdapter.Update( oleDbSingleTableAdapter.DataTable ); } catch ( Exception ex ) Index: Tickers_tickerGroups.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables/Tickers_tickerGroups.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Tickers_tickerGroups.cs 7 Apr 2008 20:46:43 -0000 1.8 --- Tickers_tickerGroups.cs 30 Dec 2008 00:15:34 -0000 1.9 *************** *** 3,7 **** Tickers_tickerGroups.cs ! Copyright (C) 2003 Marco Milletti --- 3,7 ---- Tickers_tickerGroups.cs ! Copyright (C) 2003 Marco Milletti *************** *** 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.Data; using System.Windows.Forms; - using QuantProject.DataAccess; - namespace QuantProject.DataAccess.Tables --- 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.Data; using System.Windows.Forms; namespace QuantProject.DataAccess.Tables *************** *** 36,185 **** { ! // these static fields provide field name in the database table ! // They are intended to be used through intellisense when necessary ! public static string GroupID = "ttTgId"; ! public static string Ticker = "ttTiId"; ! public static string EventTypeFieldName = "ttEventType"; ! public static string EventDate = "ttEventDate"; ! public Tickers_tickerGroups() ! { ! ! } ! ! /// <summary> ! /// It fills the given dataTable with tickers belonging to a given group ! /// </summary> ! /// <param name="groupID">The groupID corresponding to the tickers whose ! /// values have to be stored in the given Data Table</param> ! /// <param name="dataTable">The dataTable where to store tickers</param> ! /// <returns></returns> ! public static void SetDataTable( string groupID , DataTable dataTable) ! { ! string sql; ! sql = "SELECT " + Tickers_tickerGroups.Ticker + " FROM tickers_tickerGroups " + ! "WHERE " + Tickers_tickerGroups.GroupID + "='" + ! groupID + "'"; ! SqlExecutor.SetDataTable( sql , dataTable ); ! } ! /// <summary> ! /// It provides deletion of the single ticker from the specified group ! /// </summary> ! public static void Delete( string tickerToDelete, ! string fromGroupID) ! { ! try ! { ! SqlExecutor.ExecuteNonQuery("DELETE * FROM tickers_tickerGroups " + ! "WHERE " + Tickers_tickerGroups.Ticker + "='" + ! tickerToDelete + "' AND " + Tickers_tickerGroups.GroupID + "='" + ! fromGroupID + "'"); ! } ! catch(Exception ex) ! { ! MessageBox.Show(ex.ToString()); ! } ! } ! ! private static string insert_getEventTypeCode(EventType eventType) ! { ! string returnValue = "I";//default value for Exit eventType ! switch (eventType) ! { ! case EventType.Exit: ! returnValue = "O"; ! break; ! } ! return returnValue; ! ! } ! ! /// <summary> ! /// Adds a new row into tickers_tickerGroups ! /// </summary> ! public static void Add( string ticker, string groupId, EventType eventType, ! DateTime eventDate) ! { ! string eventTypeCode = insert_getEventTypeCode(eventType); ! SqlExecutor.ExecuteNonQuery("INSERT INTO tickers_tickerGroups(ttTiId, ttTgId, ttEventType, ttEventDate) " + ! "VALUES('" + ticker + "','" + groupId + "','" + eventTypeCode + ! "'," + SQLBuilder.GetDateConstant(eventDate)+ ")"); ! } ! /// <summary> ! /// It provides deletion of an entire group of tickers ! /// </summary> ! public static void Delete( string groupToDelete) ! { ! try ! { ! SqlExecutor.ExecuteNonQuery("DELETE * FROM tickers_tickerGroups " + ! "WHERE " + Tickers_tickerGroups.GroupID + "='" + ! groupToDelete + "'"); ! } ! catch(Exception ex) ! { ! MessageBox.Show(ex.ToString()); ! } ! } ! ! /// <summary> ! /// It returns a table containing tickers of a given groupID ! /// </summary> ! public static DataTable GetTickers( string groupID) ! { ! /// TO DO use a join in order to return a table with tiTicker and company name ! string sql = "SELECT DISTINCT " + Tickers_tickerGroups.Ticker + " FROM tickers_tickerGroups " + ! "WHERE " + Tickers_tickerGroups.GroupID + "='" + ! groupID + "'"; return SqlExecutor.GetDataTable( sql ); ! } ! ! /// <summary> ! /// It returns a table containing tickers effectively contained ! /// in the given group at the given Date ! /// </summary> ! public static DataTable GetTickers( string groupID, DateTime date) ! { ! ! string sqlTickersAtTheGivenDate = "SELECT ttTiId AS TickerID FROM tickers_tickerGroups " + ! "WHERE ttTgId='" + groupID + "' AND " + ! "ttEventDate<=" + SQLBuilder.GetDateConstant(date) + " " + ! "GROUP BY ttTiId " + ! "HAVING Right(Max(Year([ttEventDate]) & " + ! "IIf(Month([ttEventDate])<10,'0' & Month([ttEventDate]),Month([ttEventDate])) & " + ! "IIf(Day([ttEventDate])<10,'0' & Day([ttEventDate]),Day([ttEventDate])) & " + ! "[ttEventType]),1)='I'"; ! ! return SqlExecutor.GetDataTable(sqlTickersAtTheGivenDate); ! } ! /* /// <summary> ! /// It returns a table containing all the tickers /// gained through a recursion through all the groups contained in the given groupID /// </summary> public static DataTable GetTickersWithRecursionInsideGroup( string groupID) { ! /// TO DO use a join in order to return a table with tiTicker and company name } ! */ ! ! /// <summary> ! /// It returns true if some tickers are grouped in the given groupID ! /// </summary> ! public static bool HasTickers( string groupID) ! { ! /// TO DO use a join in order to return a table with tiTicker and company name ! DataTable tickers = SqlExecutor.GetDataTable("SELECT " + Tickers_tickerGroups.Ticker + " FROM tickers_tickerGroups " + ! "WHERE " + Tickers_tickerGroups.GroupID + "='" + ! groupID + "'"); ! return tickers.Rows.Count > 0; ! } ! ! } } --- 34,232 ---- { ! // these static fields provide field name in the database table ! // They are intended to be used through intellisense when necessary ! public static string GroupID = "ttTgId"; ! public static string Ticker = "ttTiId"; ! public static string EventTypeFieldName = "ttEventType"; ! public static string EventDate = "ttEventDate"; ! public Tickers_tickerGroups() ! { ! ! } ! ! /// <summary> ! /// It fills the given dataTable with tickers belonging to a given group ! /// </summary> ! /// <param name="groupID">The groupID corresponding to the tickers whose ! /// values have to be stored in the given Data Table</param> ! /// <param name="dataTable">The dataTable where to store tickers</param> ! /// <returns></returns> ! public static void SetDataTable( string groupID , DataTable dataTable) ! { ! string sql; ! sql = "SELECT " + Tickers_tickerGroups.Ticker + " FROM tickers_tickerGroups " + ! "WHERE " + Tickers_tickerGroups.GroupID + "='" + ! groupID + "'"; ! SqlExecutor.SetDataTable( sql , dataTable ); ! } ! /// <summary> ! /// It provides deletion of the single ticker from the specified group ! /// </summary> ! public static void Delete( string tickerToDelete, ! string fromGroupID) ! { ! try ! { ! SqlExecutor.ExecuteNonQuery("DELETE * FROM tickers_tickerGroups " + ! "WHERE " + Tickers_tickerGroups.Ticker + "='" + ! tickerToDelete + "' AND " + Tickers_tickerGroups.GroupID + "='" + ! fromGroupID + "'"); ! } ! catch(Exception ex) ! { ! MessageBox.Show(ex.ToString()); ! } ! } ! ! private static string insert_getEventTypeCode(EventType eventType) ! { ! string returnValue = "I";//default value for Exit eventType ! switch (eventType) ! { ! case EventType.Exit: ! returnValue = "O"; ! break; ! } ! return returnValue; ! ! } ! ! /// <summary> ! /// Adds a new row into tickers_tickerGroups ! /// </summary> ! public static void Add( string ticker, string groupId, EventType eventType, ! DateTime eventDate) ! { ! string eventTypeCode = insert_getEventTypeCode(eventType); ! SqlExecutor.ExecuteNonQuery("INSERT INTO tickers_tickerGroups(ttTiId, ttTgId, ttEventType, ttEventDate) " + ! "VALUES('" + ticker + "','" + groupId + "','" + eventTypeCode + ! "'," + SQLBuilder.GetDateConstant(eventDate)+ ")"); ! } ! /// <summary> ! /// It provides deletion of an entire group of tickers ! /// </summary> ! public static void Delete( string groupToDelete) ! { ! try ! { ! SqlExecutor.ExecuteNonQuery("DELETE * FROM tickers_tickerGroups " + ! "WHERE " + Tickers_tickerGroups.GroupID + "='" + ! groupToDelete + "'"); ! } ! catch(Exception ex) ! { ! MessageBox.Show(ex.ToString()); ! } ! } ! ! /// <summary> ! /// It returns a table containing tickers of a given groupID ! /// </summary> ! public static DataTable GetTickers( string groupID) ! { ! /// TO DO use a join in order to return a table with tiTicker and company name ! string sql = "SELECT DISTINCT " + Tickers_tickerGroups.Ticker + " FROM tickers_tickerGroups " + ! "WHERE " + Tickers_tickerGroups.GroupID + "='" + ! groupID + "'"; return SqlExecutor.GetDataTable( sql ); ! } ! ! #region GetTickers ! ! #region getSqlForTickersAtGivenDate ! private static string getSqlForTickersAtGivenDateForAccess( string groupID, DateTime date ) ! { ! string sqlForTickersAtTheGivenDateForAccess = ! "SELECT ttTiId AS TickerID FROM tickers_tickerGroups " + ! "WHERE ttTgId='" + groupID + "' AND " + ! "ttEventDate<=" + SQLBuilder.GetDateConstant(date) + " " + ! "GROUP BY ttTiId " + ! "HAVING Right(Max(Year([ttEventDate]) & " + ! "IIf(Month([ttEventDate])<10,'0' & Month([ttEventDate]),Month([ttEventDate])) & " + ! "IIf(Day([ttEventDate])<10,'0' & Day([ttEventDate]),Day([ttEventDate])) & " + ! "[ttEventType]),1)='I'"; ! return sqlForTickersAtTheGivenDateForAccess; ! } ! private static string getSqlForTickersAtGivenDateForMySql( string groupID, DateTime date ) ! { ! string sqlForTickersAtTheGivenDateForMySql = ! "SELECT ttTiId AS TickerID " + ! "FROM tickers_tickerGroups " + ! "WHERE ttTgId='" + groupID + "' AND " + ! "ttEventDate<=" + SQLBuilder.GetDateConstant(date) + " " + ! "GROUP BY ttTiId " + ! "HAVING Right(Max(concat( " + ! "Year(ttEventDate) , " + ! "If(Month(ttEventDate)<10,'0' & Month(ttEventDate),Month(ttEventDate)) , " + ! "If(Day(ttEventDate)<10,'0' & Day(ttEventDate),Day(ttEventDate)) , " + ! "ttEventType " + ! ")),1)='I'"; ! return sqlForTickersAtTheGivenDateForMySql; ! } ! private static string getSqlForTickersAtGivenDate( string groupID, DateTime date ) ! { ! string sqlForTickersAtGivenDate = null; ! switch ( ConnectionProvider.DbType ) ! { ! case DbType.Access: ! sqlForTickersAtGivenDate = ! Tickers_tickerGroups.getSqlForTickersAtGivenDateForAccess( ! groupID , date ); ! break; ! case DbType.MySql: ! sqlForTickersAtGivenDate = ! Tickers_tickerGroups.getSqlForTickersAtGivenDateForMySql( ! groupID , date ); ! break; ! default: ! throw new Exception( ! "Unknown database type. Complete the switch statement, please" ); ! } ! return sqlForTickersAtGivenDate; ! } ! #endregion getSqlForTickersAtGivenDate ! ! /// <summary> ! /// It returns a table containing tickers effectively contained ! /// in the given group at the given Date ! /// </summary> ! public static DataTable GetTickers( string groupID, DateTime date) ! { ! string sqlForTickersAtTheGivenDate = ! Tickers_tickerGroups.getSqlForTickersAtGivenDate( groupID , date ); ! return SqlExecutor.GetDataTable(sqlForTickersAtTheGivenDate); ! } ! #endregion GetTickers ! ! /* /// <summary> ! /// It returns a table containing all the tickers /// gained through a recursion through all the groups contained in the given groupID /// </summary> public static DataTable GetTickersWithRecursionInsideGroup( string groupID) { ! /// TO DO use a join in order to return a table with tiTicker and company name } ! */ ! ! /// <summary> ! /// It returns true if some tickers are grouped in the given groupID ! /// </summary> ! public static bool HasTickers( string groupID) ! { ! /// TO DO use a join in order to return a table with tiTicker and company name ! DataTable tickers = SqlExecutor.GetDataTable("SELECT " + Tickers_tickerGroups.Ticker + " FROM tickers_tickerGroups " + ! "WHERE " + Tickers_tickerGroups.GroupID + "='" + ! groupID + "'"); ! return tickers.Rows.Count > 0; ! } ! ! } } |
|
From: Glauco S. <gla...@us...> - 2008-12-30 00:15:46
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a0_Validation In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17196/b4_Business/a0_Validation Modified Files: ValidateDataTable.cs Log Message: Now bot Access and MySql are supported Index: ValidateDataTable.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a0_Validation/ValidateDataTable.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ValidateDataTable.cs 26 May 2004 15:31:52 -0000 1.4 --- ValidateDataTable.cs 30 Dec 2008 00:15:34 -0000 1.5 *************** *** 1,5 **** using System; using System.Data; ! using System.Data.OleDb; using QuantProject.ADT; using QuantProject.Business.Validation.Validators; --- 1,5 ---- using System; using System.Data; ! using System.Data.Common; using QuantProject.ADT; using QuantProject.Business.Validation.Validators; *************** *** 17,22 **** { private string selectStatement; ! private OleDbCommandBuilder oleDbCommandBuilder; ! private OleDbDataAdapter oleDbDataAdapter; private DataTable tableOfTickersToBeValidated; --- 17,22 ---- { private string selectStatement; ! private DbCommandBuilder dbCommandBuilder; ! private DbDataAdapter dbDataAdapter; private DataTable tableOfTickersToBeValidated; *************** *** 42,50 **** this.selectStatement = "select * from quotes where 1=2"; ! this.oleDbDataAdapter = ! new OleDbDataAdapter( selectStatement , ConnectionProvider.OleDbConnection ); ! this.oleDbCommandBuilder = new OleDbCommandBuilder( oleDbDataAdapter ); ! this.oleDbDataAdapter.UpdateCommand = this.oleDbCommandBuilder.GetUpdateCommand(); ! this.oleDbDataAdapter.Fill( this ); DataColumn dataColumn = new DataColumn( "CloseToCloseHasBeenVisuallyValidated" , System.Type.GetType( "System.Boolean" ) ); --- 42,53 ---- this.selectStatement = "select * from quotes where 1=2"; ! this.dbDataAdapter = ! DbDataAdapterProvider.GetDbDataAdapter( this.selectStatement ); ! // new OleDbDataAdapter( selectStatement , ConnectionProvider.DbConnection ); ! // this.oleDbCommandBuilder = new OleDbCommandBuilder( dbDataAdapter ); ! this.dbCommandBuilder = ! DbCommandBuilderProvider.GetDbCommanBuilder( dbDataAdapter ); ! this.dbDataAdapter.UpdateCommand = this.dbCommandBuilder.GetUpdateCommand(); ! this.dbDataAdapter.Fill( this ); DataColumn dataColumn = new DataColumn( "CloseToCloseHasBeenVisuallyValidated" , System.Type.GetType( "System.Boolean" ) ); *************** *** 125,129 **** try { ! this.oleDbDataAdapter.Update( this ); this.AcceptChanges(); } --- 128,132 ---- try { ! this.dbDataAdapter.Update( this ); this.AcceptChanges(); } |
|
From: Glauco S. <gla...@us...> - 2008-12-30 00:15:09
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17032/b2_DataAccess Modified Files: SQLBuilder.cs SqlExecutor.cs Log Message: Now bot Access and MySql are supported Index: SQLBuilder.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/SQLBuilder.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SQLBuilder.cs 24 Nov 2008 21:05:12 -0000 1.4 --- SQLBuilder.cs 30 Dec 2008 00:14:52 -0000 1.5 *************** *** 40,58 **** } ! internal static string GetDateConstant( DateTime dateTime ) { ! string getDateConstant; ! getDateConstant = "#" + dateTime.Month + "/" + dateTime.Day + "/" + dateTime.Year + "#"; return getDateConstant; } ! /// <summary> ! /// returns a string to be used as a DateTime constant for a query ! /// for an Access database ! /// </summary> ! /// <param name="dateTime"></param> ! /// <returns></returns> ! internal static string GetDateTimeConstant( DateTime dateTime ) { string dateTimeConstant = --- 40,87 ---- } ! #region GetDateConstant ! private static string getDateConstantForAccess( DateTime dateTime ) { ! string dateConstantForAccess = "#" + dateTime.Month + "/" + dateTime.Day + "/" + dateTime.Year + "#"; + return dateConstantForAccess; + } + private static string getDateConstantForMySQL( DateTime dateTime ) + { + string dateConstantForMySql = + "'" + + dateTime.Year + "-" + + dateTime.Month + "-" + + dateTime.Day + + // " " + + // dateTime.Hour + ":" + + // dateTime.Minute + ":" + + // dateTime.Second + + "'"; + return dateConstantForMySql; + } + internal static string GetDateConstant( DateTime dateTime ) + { + string getDateConstant = null; + switch ( ConnectionProvider.DbType ) + { + case DbType.Access: + getDateConstant = + SQLBuilder.getDateConstantForAccess( dateTime ); + break; + case DbType.MySql: + getDateConstant = + SQLBuilder.getDateConstantForMySQL( dateTime ); + break; + default: + throw new Exception( + "Unknown database type. Complete the switch statement, please" ); + } return getDateConstant; } + #endregion GetDateConstant ! #region GetDateTimeConstant ! private static string getDateTimeConstantForAccess( DateTime dateTime ) { string dateTimeConstant = *************** *** 65,70 **** --- 94,138 ---- dateTime.Second + "#"; + return dateTimeConstant; + } + private static string getDateTimeConstantForMySQL( DateTime dateTime ) + { + string dateTimeConstant = + "'" + + dateTime.Year + "-" + + dateTime.Month + "-" + + dateTime.Day + " " + + dateTime.Hour + ":" + + dateTime.Minute + ":" + + dateTime.Second + + "'"; + return dateTimeConstant; + } + /// <summary> + /// returns a string to be used as a DateTime constant for a query + /// for an Access database + /// </summary> + /// <param name="dateTime"></param> + /// <returns></returns> + internal static string GetDateTimeConstant( DateTime dateTime ) + { + string dateTimeConstant = null; + switch ( ConnectionProvider.DbType ) + { + case DbType.Access: + dateTimeConstant = + SQLBuilder.getDateTimeConstantForAccess( dateTime ); + break; + case DbType.MySql: + dateTimeConstant = + SQLBuilder.getDateTimeConstantForMySQL( dateTime ); + break; + default: + throw new Exception( + "Unknown database type. Complete the switch statement, please" ); + } return dateTimeConstant; } + #endregion GetDateTimeConstant #region GetTimeConstant *************** *** 83,93 **** // private static void getFilterForTime_checkParameters( DateTime time ) // { ! //// if ( ( comparisonOperator != "=" ) && ! //// ( comparisonOperator != "<" ) && ! //// ( comparisonOperator != "<=" ) && ! //// ( comparisonOperator != ">" ) && ! //// ( comparisonOperator != ">=" ) ) ! //// throw new Exception( ! //// "comparisonOperator can either be '=' or '<' or '<=' or '>' or '>='" ); // if ( !ExtendedDateTime.IsTime( time ) ) // throw new Exception( --- 151,161 ---- // private static void getFilterForTime_checkParameters( DateTime time ) // { ! //// if ( ( comparisonOperator != "=" ) && ! //// ( comparisonOperator != "<" ) && ! //// ( comparisonOperator != "<=" ) && ! //// ( comparisonOperator != ">" ) && ! //// ( comparisonOperator != ">=" ) ) ! //// throw new Exception( ! //// "comparisonOperator can either be '=' or '<' or '<=' or '>' or '>='" ); // if ( !ExtendedDateTime.IsTime( time ) ) // throw new Exception( *************** *** 97,100 **** --- 165,189 ---- #region getFilterForTime_actually + + #region getFormatFunctionForTime + private static string getFormatFunctionForTime( string dateTimeFieldName ) + { + string formatFunctionForTime = null; + switch ( ConnectionProvider.DbType ) + { + case DbType.Access: + formatFunctionForTime = "Format([" + dateTimeFieldName + "],'hh.mm.ss')"; + break; + case DbType.MySql: + formatFunctionForTime = "Date_Format(" + dateTimeFieldName + ",'%H.%i.%s')"; + break; + default: + throw new Exception( + "Unknown database type. Complete the switch statement, please" ); + } + return formatFunctionForTime; + } + #endregion getFormatFunctionForTime + private static string getSqlStringForComparisonOperator( SqlComparisonOperator sqlComparisonOperator ) *************** *** 125,129 **** { string filterForDailyTime = ! "(Format([baDateTimeForOpen],'hh.mm.ss')" + SQLBuilder.getSqlStringForComparisonOperator( sqlComparisonOperator ) + SQLBuilder.GetTimeConstant( time ) + ")"; --- 214,220 ---- { string filterForDailyTime = ! // "(Format([baDateTimeForOpen],'hh.mm.ss')" + ! "(" + ! SQLBuilder.getFormatFunctionForTime( "baDateTimeForOpen" ) + SQLBuilder.getSqlStringForComparisonOperator( sqlComparisonOperator ) + SQLBuilder.GetTimeConstant( time ) + ")"; *************** *** 151,154 **** --- 242,268 ---- } #endregion GetFilterForTime + + /// <summary> + /// returns the name of the function used by the current database type, + /// to compute the standard deviation + /// </summary> + /// <returns></returns> + public static string GetStandardDeviationFunctionName() + { + string setStandardDeviationFunctionName = null; + switch ( ConnectionProvider.DbType ) + { + case DbType.Access: + setStandardDeviationFunctionName = "StDev"; + break; + case DbType.MySql: + setStandardDeviationFunctionName = "STDDEV_POP"; + break; + default: + throw new Exception( + "Unknown database type. Complete the switch statement, please" ); + } + return setStandardDeviationFunctionName; + } } } Index: SqlExecutor.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/SqlExecutor.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SqlExecutor.cs 8 May 2004 17:17:47 -0000 1.3 --- SqlExecutor.cs 30 Dec 2008 00:14:52 -0000 1.4 *************** *** 1,5 **** using System; using System.Data; ! using System.Data.OleDb; namespace QuantProject.DataAccess --- 1,5 ---- using System; using System.Data; ! using System.Data.Common; namespace QuantProject.DataAccess *************** *** 19,39 **** { DataTable dataTable = new DataTable(); ! OleDbDataAdapter oleDbDataAdapter = new OleDbDataAdapter( SqlQuery , ConnectionProvider.OleDbConnection ); ! oleDbDataAdapter.Fill( dataTable ); return dataTable; } ! public static void SetDataTable( string SqlQuery , DataTable dataTable ) { ! OleDbDataAdapter oleDbDataAdapter = new OleDbDataAdapter( SqlQuery , ConnectionProvider.OleDbConnection ); ! oleDbDataAdapter.Fill( dataTable ); } ! public static void ExecuteNonQuery( string SqlNonQuery ) { ! if(ConnectionProvider.OleDbConnection.State != ConnectionState.Open) ! ConnectionProvider.OleDbConnection.Open(); ! OleDbCommand oleDbCommand = new OleDbCommand( SqlNonQuery , ! ConnectionProvider.OleDbConnection ); ! ! oleDbCommand.ExecuteNonQuery(); } } --- 19,43 ---- { DataTable dataTable = new DataTable(); ! // OleDbDataAdapter oleDbDataAdapter = new OleDbDataAdapter( SqlQuery , ConnectionProvider.DbConnection ); ! DbDataAdapter dbDataAdapter = ! DbDataAdapterProvider.GetDbDataAdapter( SqlQuery ); ! dbDataAdapter.Fill( dataTable ); return dataTable; } ! public static void SetDataTable( string sqlQuery , DataTable dataTable ) { ! DbDataAdapter dbDataAdapter = ! DbDataAdapterProvider.GetDbDataAdapter( sqlQuery ); ! dbDataAdapter.Fill( dataTable ); } ! public static int ExecuteNonQuery( string sqlNonQuery ) { ! if(ConnectionProvider.DbConnection.State != ConnectionState.Open) ! ConnectionProvider.DbConnection.Open(); ! // OleDbCommand oleDbCommand = new OleDbCommand( SqlNonQuery , ! // ConnectionProvider.DbConnection ); ! DbCommand dbCommand = DbCommandProvider.GetDbCommand( sqlNonQuery ); ! int numberOfRowsAffected = dbCommand.ExecuteNonQuery(); ! return numberOfRowsAffected; } } |
|
From: Glauco S. <gla...@us...> - 2008-12-30 00:14:27
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv16941/b2_DataAccess/Tables Modified Files: Quotes.cs Log Message: Now bot Access and MySql are supported Index: Quotes.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables/Quotes.cs,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** Quotes.cs 14 Aug 2008 23:22:49 -0000 1.34 --- Quotes.cs 30 Dec 2008 00:14:16 -0000 1.35 *************** *** 14,24 **** public class Quotes { ! ! private DataTable quotes; ! // these static fields provide field name in the database table // They are intended to be used through intellisense when necessary public static string TickerFieldName = "quTicker"; // Ticker cannot be simply used because ! // it is already used below public static string Date = "quDate"; [...1805 lines suppressed...] "WHERE tickers_tickerGroups.ttTgId='" + groupID + "' " + --- 1161,1165 ---- { string sql = "SELECT quotes.quTicker, quotes.quDate, quotes.quAdjustedClose, " + ! "tickers_tickerGroups.ttTgId FROM quotes INNER JOIN " + "tickers_tickerGroups ON quotes.quTicker = tickers_tickerGroups.ttTiId " + "WHERE tickers_tickerGroups.ttTgId='" + groupID + "' " + *************** *** 1156,1160 **** return SqlExecutor.GetDataTable( sql ); } ! */ } } --- 1167,1171 ---- return SqlExecutor.GetDataTable( sql ); } ! */ } } |
|
From: Glauco S. <gla...@us...> - 2008-12-30 00:14:26
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataTables In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv16941/b3_Data/DataTables Modified Files: Quotes.cs Log Message: Now bot Access and MySql are supported Index: Quotes.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataTables/Quotes.cs,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** Quotes.cs 18 Aug 2008 21:05:39 -0000 1.37 --- Quotes.cs 30 Dec 2008 00:14:16 -0000 1.38 *************** *** 205,236 **** /// </summary> public static DataTable GetTickersByOpenToCloseVolatility( bool orderByASC, ! DataTable setOfTickers, ! DateTime firstQuoteDate, ! DateTime lastQuoteDate, ! long maxNumOfReturnedTickers) { ! if(!setOfTickers.Columns.Contains("OpenToCloseStandDev")) ! setOfTickers.Columns.Add("OpenToCloseStandDev", System.Type.GetType("System.Double")); ! double OTCStdDev; ! foreach(DataRow row in setOfTickers.Rows) ! { ! try ! { ! row["OpenToCloseStandDev"] = -1000000.0; ! OTCStdDev = QuantProject.DataAccess.Tables.Quotes.GetOpenToCloseStandardDeviation((string)row[0], ! firstQuoteDate, ! lastQuoteDate); ! if( !Double.IsInfinity(OTCStdDev) && !Double.IsNaN(OTCStdDev) ) ! row["OpenToCloseStandDev"] = OTCStdDev; ! } ! catch(Exception ex) ! { string forBreakpoint = ex.Message; forBreakpoint = forBreakpoint + ""; } ! } ! DataTable getTickersByVolatility = ExtendedDataTable.CopyAndSort(setOfTickers, ! "OpenToCloseStandDev>-1000000.0", ! "OpenToCloseStandDev", ! orderByASC); ! ExtendedDataTable.DeleteRows(getTickersByVolatility, maxNumOfReturnedTickers); ! return getTickersByVolatility; } --- 205,236 ---- /// </summary> public static DataTable GetTickersByOpenToCloseVolatility( bool orderByASC, ! DataTable setOfTickers, ! DateTime firstQuoteDate, ! DateTime lastQuoteDate, ! long maxNumOfReturnedTickers) { ! if(!setOfTickers.Columns.Contains("OpenToCloseStandDev")) ! setOfTickers.Columns.Add("OpenToCloseStandDev", System.Type.GetType("System.Double")); ! double OTCStdDev; ! foreach(DataRow row in setOfTickers.Rows) ! { ! // try ! // { ! row["OpenToCloseStandDev"] = -1000000.0; ! OTCStdDev = QuantProject.DataAccess.Tables.Quotes.GetOpenToCloseStandardDeviation((string)row[0], ! firstQuoteDate, ! lastQuoteDate); ! if( !Double.IsInfinity(OTCStdDev) && !Double.IsNaN(OTCStdDev) ) ! row["OpenToCloseStandDev"] = OTCStdDev; ! // } ! // catch(Exception ex) ! // { string forBreakpoint = ex.Message; forBreakpoint = forBreakpoint + ""; } ! } ! DataTable getTickersByVolatility = ExtendedDataTable.CopyAndSort(setOfTickers, ! "OpenToCloseStandDev>-1000000.0", ! "OpenToCloseStandDev", ! orderByASC); ! ExtendedDataTable.DeleteRows(getTickersByVolatility, maxNumOfReturnedTickers); ! return getTickersByVolatility; } |
|
From: Glauco S. <gla...@us...> - 2008-12-30 00:13:30
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv16793/b2_DataAccess Modified Files: OleDbSingleTableAdapter.cs Log Message: Now bot Access and MySql are supported Index: OleDbSingleTableAdapter.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/OleDbSingleTableAdapter.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** OleDbSingleTableAdapter.cs 4 Jul 2004 18:00:29 -0000 1.7 --- OleDbSingleTableAdapter.cs 30 Dec 2008 00:13:18 -0000 1.8 *************** *** 23,35 **** using System; using System.Data; ! using System.Data.OleDb; namespace QuantProject.DataAccess { /// <summary> ! /// Returns a complete OleDbDataAdapter (with proper edit commands already set) to work with /// the given table /// </summary> ! public class OleDbSingleTableAdapter { private string tableName; --- 23,35 ---- using System; using System.Data; ! using System.Data.Common; namespace QuantProject.DataAccess { /// <summary> ! /// Returns a complete DbDataAdapter (with proper edit commands already set) to work with /// the given table /// </summary> ! public class SingleTableDbDataAdapter { private string tableName; *************** *** 39,46 **** set { this.tableName = value; } } ! private OleDbDataAdapter oleDbDataAdapter; ! public OleDbDataAdapter OleDbDataAdapter { ! get { return this.oleDbDataAdapter; } } --- 39,46 ---- set { this.tableName = value; } } ! private DbDataAdapter dbDataAdapter; ! public DbDataAdapter DbDataAdapter { ! get { return this.dbDataAdapter; } } *************** *** 55,65 **** try { ! this.oleDbDataAdapter = ! new OleDbDataAdapter( selectStatement , ConnectionProvider.OleDbConnection ); ! OleDbCommandBuilder oleDbCommandBuilder = new OleDbCommandBuilder( oleDbDataAdapter ); ! this.oleDbDataAdapter.InsertCommand = oleDbCommandBuilder.GetInsertCommand(); ! this.oleDbDataAdapter.UpdateCommand = oleDbCommandBuilder.GetUpdateCommand(); ! this.oleDbDataAdapter.DeleteCommand = oleDbCommandBuilder.GetDeleteCommand(); ! this.oleDbDataAdapter.Fill( this.dataTable ); } catch ( Exception ex ) --- 55,68 ---- try { ! // this.dbDataAdapter = ! // new DbDataAdapter( selectStatement , ConnectionProvider.DbConnection ); ! this.dbDataAdapter = DbDataAdapterProvider.GetDbDataAdapter( selectStatement ); ! // DbCommandBuilder oleDbCommandBuilder = new DbCommandBuilder( dbDataAdapter ); ! DbCommandBuilder dbCommandBuilder = ! DbCommandBuilderProvider.GetDbCommanBuilder( this.dbDataAdapter ); ! this.dbDataAdapter.InsertCommand = dbCommandBuilder.GetInsertCommand(); ! this.dbDataAdapter.UpdateCommand = dbCommandBuilder.GetUpdateCommand(); ! this.dbDataAdapter.DeleteCommand = dbCommandBuilder.GetDeleteCommand(); ! this.dbDataAdapter.Fill( this.dataTable ); } catch ( Exception ex ) *************** *** 71,81 **** } ! public OleDbSingleTableAdapter( string selectStatement ) { this.dataTable = new DataTable(); ! setAdapter( selectStatement ); } ! public OleDbSingleTableAdapter(string selectStatement, DataTable table ) { this.dataTable = table; --- 74,84 ---- } ! public SingleTableDbDataAdapter( string selectStatement ) { this.dataTable = new DataTable(); ! this.setAdapter( selectStatement ); } ! public SingleTableDbDataAdapter(string selectStatement, DataTable table ) { this.dataTable = table; *************** *** 83,87 **** } ! public OleDbSingleTableAdapter() { this.dataTable = new DataTable(); --- 86,90 ---- } ! public SingleTableDbDataAdapter() { this.dataTable = new DataTable(); |