quantproject-developers Mailing List for QuantProject (Page 25)
Brought to you by:
glauco_1
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(7) |
Nov
(103) |
Dec
(67) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(52) |
Feb
(9) |
Mar
(69) |
Apr
(53) |
May
(80) |
Jun
(23) |
Jul
(24) |
Aug
(112) |
Sep
(9) |
Oct
|
Nov
(58) |
Dec
(93) |
| 2005 |
Jan
(90) |
Feb
(93) |
Mar
(61) |
Apr
(56) |
May
(37) |
Jun
(61) |
Jul
(55) |
Aug
(68) |
Sep
(25) |
Oct
(46) |
Nov
(41) |
Dec
(37) |
| 2006 |
Jan
(33) |
Feb
(7) |
Mar
(19) |
Apr
(27) |
May
(73) |
Jun
(49) |
Jul
(83) |
Aug
(66) |
Sep
(45) |
Oct
(16) |
Nov
(15) |
Dec
(7) |
| 2007 |
Jan
(14) |
Feb
(33) |
Mar
|
Apr
(21) |
May
|
Jun
(34) |
Jul
(18) |
Aug
(100) |
Sep
(39) |
Oct
(55) |
Nov
(12) |
Dec
(2) |
| 2008 |
Jan
(120) |
Feb
(133) |
Mar
(129) |
Apr
(104) |
May
(42) |
Jun
(2) |
Jul
(52) |
Aug
(99) |
Sep
(134) |
Oct
|
Nov
(137) |
Dec
(48) |
| 2009 |
Jan
(48) |
Feb
(55) |
Mar
(61) |
Apr
(3) |
May
(2) |
Jun
(1) |
Jul
|
Aug
(51) |
Sep
|
Oct
(7) |
Nov
|
Dec
|
| 2010 |
Jan
(7) |
Feb
(1) |
Mar
(145) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(8) |
Dec
|
| 2011 |
Jan
(78) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(88) |
Sep
(6) |
Oct
(1) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
(1) |
Mar
|
Apr
(6) |
May
(5) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2013 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
| 2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Glauco S. <gla...@us...> - 2008-12-30 00:13:29
|
Update of /cvsroot/quantproject/QuantProject/b3_Data In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv16793/b3_Data Modified Files: ExtendedDataTable.cs Log Message: Now bot Access and MySql are supported Index: ExtendedDataTable.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/ExtendedDataTable.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ExtendedDataTable.cs 7 Jul 2004 20:21:50 -0000 1.1 --- ExtendedDataTable.cs 30 Dec 2008 00:13:18 -0000 1.2 *************** *** 10,22 **** public class ExtendedDataTable : QuantProject.ADT.ExtendedDataTable { ! private OleDbSingleTableAdapter oleDbSingleTableAdapter; public ExtendedDataTable( string sql ) { ! this.oleDbSingleTableAdapter = new OleDbSingleTableAdapter( sql , this ); } public void Update() { ! this.oleDbSingleTableAdapter.OleDbDataAdapter.Update( this ); } } --- 10,22 ---- public class ExtendedDataTable : QuantProject.ADT.ExtendedDataTable { ! private SingleTableDbDataAdapter oleDbSingleTableAdapter; public ExtendedDataTable( string sql ) { ! this.oleDbSingleTableAdapter = new SingleTableDbDataAdapter( sql , this ); } public void Update() { ! this.oleDbSingleTableAdapter.DbDataAdapter.Update( this ); } } |
|
From: Glauco S. <gla...@us...> - 2008-12-30 00:12:01
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv16515/b2_DataAccess Modified Files: DataBase.cs DataBaseVersionManager.cs Log Message: Now bot Access and MySql are supported (but the DataBaseVersionManager will need some tuning in order to work with a MySQL database without structure) Index: DataBaseVersionManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/DataBaseVersionManager.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** DataBaseVersionManager.cs 27 Aug 2005 19:20:26 -0000 1.15 --- DataBaseVersionManager.cs 30 Dec 2008 00:11:44 -0000 1.16 *************** *** 23,29 **** --- 23,33 ---- using System; using System.Windows.Forms; + using System.Data.Common; using System.Data.OleDb; using System.Data; using System.Collections; + + using MySql.Data.MySqlClient; + using QuantProject.ADT; *************** *** 47,51 **** public class DataBaseVersionManager { ! private OleDbConnection oleDbConnection; delegate void updatingMethodHandler(); private ArrayList updatingMethods; --- 51,55 ---- public class DataBaseVersionManager { ! private DbConnection dbConnection; delegate void updatingMethodHandler(); private ArrayList updatingMethods; *************** *** 75,83 **** } ! public DataBaseVersionManager(OleDbConnection oleDbConnection) { try { ! this.oleDbConnection = oleDbConnection; this.initialize_updatingMethods(); } --- 79,87 ---- } ! public DataBaseVersionManager( DbConnection dbConnection) { try { ! this.dbConnection = dbConnection; this.initialize_updatingMethods(); } *************** *** 85,89 **** { MessageBox.Show(ex.ToString()); ! this.oleDbConnection.Close(); } } --- 89,93 ---- { MessageBox.Show(ex.ToString()); ! this.dbConnection.Close(); } } *************** *** 217,232 **** "AND tickers_tickerGroups.ttEventDate Is Null"); ! } private void executeCommand(string commandToBeExecuted) { try { ! OleDbCommand oleDbCommand = new OleDbCommand( commandToBeExecuted , this.oleDbConnection ); ! int checkCommandExecution = oleDbCommand.ExecuteNonQuery(); } catch(Exception ex) { string notUsed = ex.ToString();// to avoid warning after compilation ! } } --- 221,239 ---- "AND tickers_tickerGroups.ttEventDate Is Null"); ! } ! private void executeCommand(string commandToBeExecuted) { try { ! // DbCommand dbCommand = new DbCommand( commandToBeExecuted , this.dbConnection ); ! // DbCommand dbCommand = this.getDbCommand( commandToBeExecuted ); ! DbCommand dbCommand = DbCommandProvider.GetDbCommand( commandToBeExecuted ); ! int checkCommandExecution = dbCommand.ExecuteNonQuery(); } catch(Exception ex) { string notUsed = ex.ToString();// to avoid warning after compilation ! } } Index: DataBase.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/DataBase.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** DataBase.cs 20 Nov 2008 20:39:03 -0000 1.12 --- DataBase.cs 30 Dec 2008 00:11:44 -0000 1.13 *************** *** 25,28 **** --- 25,29 ---- using System.Collections.Generic; using System.Data; + using System.Data.Common; using System.Data.OleDb; using System.Windows.Forms; *************** *** 40,44 **** public class DataBase { ! private static OleDbConnection oleDbConnection = ConnectionProvider.OleDbConnection; public DataBase() --- 41,45 ---- public class DataBase { ! private static DbConnection dbConnection = ConnectionProvider.DbConnection; public DataBase() *************** *** 95,101 **** "and (quDate>=" + SQLBuilder.GetDateConstant( firstDate ) + ") " + "and (quDate<=" + SQLBuilder.GetDateConstant( lastDate ) + ")"; ! OleDbDataAdapter oleDbDataAdapter = new OleDbDataAdapter( commandString , oleDbConnection ); ! DataTable dataTable = new DataTable(); ! oleDbDataAdapter.Fill( dataTable ); history.Import( dataTable , "quDate" , getFieldName( quoteField ) ); return history; --- 96,103 ---- "and (quDate>=" + SQLBuilder.GetDateConstant( firstDate ) + ") " + "and (quDate<=" + SQLBuilder.GetDateConstant( lastDate ) + ")"; ! // OleDbDataAdapter oleDbDataAdapter = new OleDbDataAdapter( commandString , dbConnection ); ! // DataTable dataTable = new DataTable(); ! DataTable dataTable = SqlExecutor.GetDataTable( commandString ); ! // oleDbDataAdapter.Fill( dataTable ); history.Import( dataTable , "quDate" , getFieldName( quoteField ) ); return history; |
|
From: Glauco S. <gla...@us...> - 2008-12-30 00:11:55
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataProviders/Bars/Caching In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv16515/b3_Data/DataProviders/Bars/Caching Modified Files: DailyBarCache.cs Log Message: Now bot Access and MySql are supported (but the DataBaseVersionManager will need some tuning in order to work with a MySQL database without structure) Index: DailyBarCache.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataProviders/Bars/Caching/DailyBarCache.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DailyBarCache.cs 22 Nov 2008 18:25:22 -0000 1.4 --- DailyBarCache.cs 30 Dec 2008 00:11:44 -0000 1.5 *************** *** 189,193 **** { float barOpenValue = ! (float)barOpenValuesFromDatabase[ dateTime ]; this.barOpenValues.AddBar( ticker , dateTime , barOpenValue ); --- 189,193 ---- { float barOpenValue = ! Convert.ToSingle( barOpenValuesFromDatabase[ dateTime ] ); this.barOpenValues.AddBar( ticker , dateTime , barOpenValue ); |
|
From: Glauco S. <gla...@us...> - 2008-12-30 00:08:49
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv15656/b2_DataAccess Modified Files: ConnectionProvider.cs Log Message: Now a property public static DbConnection DbConnection is provided: it can be either an OleDbConnection or a MySqlDbConnection Index: ConnectionProvider.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/ConnectionProvider.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ConnectionProvider.cs 2 Jul 2006 19:27:32 -0000 1.5 --- ConnectionProvider.cs 30 Dec 2008 00:08:37 -0000 1.6 *************** *** 3,7 **** ConnectionProvider.cs ! Copyright (C) 2003 Glauco Siliprandi --- 3,7 ---- ConnectionProvider.cs ! Copyright (C) 2008 Glauco Siliprandi *************** *** 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.OleDb; ! using QuantProject.DataAccess; namespace QuantProject.DataAccess --- 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.Common; using System.Data.OleDb; ! ! using MySql.Data.MySqlClient; namespace QuantProject.DataAccess *************** *** 32,35 **** --- 34,133 ---- public class ConnectionProvider { + private static DbConnection dbConnection; + + #region DbConnection + #region getDbConnection + + #region getAccessDbConnection + + #region getAccessConnectionString + private static string getMdbPath() + { + string mdbPath = ConfigManager.MdbPath; + return mdbPath; + } + private static string getAccessConnectionString() + { + string mdbPath = ConnectionProvider.getMdbPath(); + string connectionString = + @"Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=" + + mdbPath + + @";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False"; + return connectionString; + } + #endregion getAccessConnectionString + + private static DbConnection getAccessDbConnection() + { + string connectionString = ConnectionProvider.getAccessConnectionString(); + DbConnection dbConnection = new OleDbConnection( connectionString ); + try + { + dbConnection.Open(); + } + catch(Exception ex) + { + System.Windows.Forms.MessageBox.Show(ex.ToString()); + dbConnection = null; + } + return dbConnection; + } + #endregion getAccessDbConnection + + #region getMySQLDbConnection + private static DbConnection getMySQLDbConnection() + { + DbConnection mySQLDbConnection = + new MySqlConnection( ConfigManager.MySqlConnectionString ); + return mySQLDbConnection; + } + #endregion getMySQLDbConnection + + private static DbConnection getDbConnection() + { + DbConnection dbConnection = null; + if ( ConfigManager.IsChosenDbTypeAccess ) + dbConnection = ConnectionProvider.getAccessDbConnection(); + else + // current db type is MySQL + dbConnection = ConnectionProvider.getMySQLDbConnection(); + return dbConnection; + } + #endregion getDbConnection + private static void updateDatabaseStructure() + { + DataBaseVersionManager dataBaseVersionManager = new DataBaseVersionManager(dbConnection); + dataBaseVersionManager.UpdateDataBaseStructure(); + } + /// <summary> + /// Returns an OleDbConnection to the database + /// </summary> + public static DbConnection DbConnection + { + get + { + if ( dbConnection == null ) + { + ConnectionProvider.dbConnection = + ConnectionProvider.getDbConnection(); + ConnectionProvider.updateDatabaseStructure(); + } + return dbConnection; + } + } + #endregion DbConnection + + public static DbType DbType + { + get + { + DbType dbType = DbType.Undefined; + if ( ConnectionProvider.DbConnection is OleDbConnection ) + dbType = DbType.Access; + if ( ConnectionProvider.DbConnection is MySqlConnection ) + dbType = DbType.MySql; + return dbType; + } + } public ConnectionProvider() { *************** *** 38,74 **** // } - private static OleDbConnection oleDbConnection; - - /// <summary> - /// Returns an OleDbConnection to the database - /// </summary> - public static OleDbConnection OleDbConnection - { - get - { - if ( oleDbConnection == null ) - { - DataBaseLocator dataBaseLocator = new DataBaseLocator("MDB"); - string mdbPath = dataBaseLocator.Path; - string connectionString = - @"Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=" + - mdbPath + - @";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False"; - oleDbConnection = new OleDbConnection( connectionString ); - try{ - oleDbConnection.Open(); - } - catch(Exception ex) - { - System.Windows.Forms.MessageBox.Show(ex.ToString()); - oleDbConnection = null; - } - DataBaseVersionManager dataBaseVersionManager = new DataBaseVersionManager(oleDbConnection); - dataBaseVersionManager.UpdateDataBaseStructure(); - - } - return oleDbConnection; - } - } } } --- 136,139 ---- |
|
From: Glauco S. <gla...@us...> - 2008-12-30 00:06:37
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14957/b2_DataAccess Modified Files: DataAccess_SD.csproj Log Message: - b2_DataAccess\DataBaseLocator.cs has been moved to b2_DataAccess\ConfigurationManagement\AccessDataBaseLocator.cs - ConfigurationManagement\ConfigManager.cs has been added - ConfigurationManagement\DbType.cs has been added - ConfigurationManagement\DbTypeChooser.cs has been added - ConfigurationManagement\DbTypeChooser.Designer.cs has been added - ConfigurationManagement\MySqlConnectionForm.cs has been added - ConfigurationManagement\MySqlConnectionForm.Designer.cs has been added - DbCommandBuilderProvider.cs has been added - DbCommandProvider.cs has been added - DbDataAdapterProvider.cs has been added Index: DataAccess_SD.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/DataAccess_SD.csproj,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DataAccess_SD.csproj 12 Nov 2008 20:34:34 -0000 1.4 --- DataAccess_SD.csproj 30 Dec 2008 00:06:27 -0000 1.5 *************** *** 5,9 **** <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{3D38C64D-1118-4C16-A88E-5F2FFD6481BA}</ProjectGuid> ! <RootNamespace>DataAccess</RootNamespace> <AssemblyName>QuantProject.DataAccess</AssemblyName> <OutputType>Library</OutputType> --- 5,9 ---- <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{3D38C64D-1118-4C16-A88E-5F2FFD6481BA}</ProjectGuid> ! <RootNamespace>QuantProject.DataAccess</RootNamespace> <AssemblyName>QuantProject.DataAccess</AssemblyName> <OutputType>Library</OutputType> *************** *** 38,42 **** --- 38,44 ---- </PropertyGroup> <ItemGroup> + <Reference Include="MySql.Data" /> <Reference Include="System" /> + <Reference Include="System.Configuration" /> <Reference Include="System.Data" /> <Reference Include="System.Drawing" /> *************** *** 47,54 **** <Compile Include="AssemblyInfo.cs" /> <Compile Include="BarFieldNames.cs" /> <Compile Include="ConnectionProvider.cs" /> <Compile Include="DataBase.cs" /> - <Compile Include="DataBaseLocator.cs" /> <Compile Include="DataBaseVersionManager.cs" /> <Compile Include="OleDbSingleTableAdapter.cs" /> <Compile Include="QuoteField.cs" /> --- 49,67 ---- <Compile Include="AssemblyInfo.cs" /> <Compile Include="BarFieldNames.cs" /> + <Compile Include="ConfigurationManagement\AccessDataBaseLocator.cs" /> + <Compile Include="ConfigurationManagement\ConfigManager.cs" /> + <Compile Include="ConfigurationManagement\DbType.cs" /> + <Compile Include="ConfigurationManagement\DbTypeChooser.cs" /> + <Compile Include="ConfigurationManagement\DbTypeChooser.Designer.cs" /> + <Compile Include="ConfigurationManagement\MySqlConnectionForm.cs" /> + <Compile Include="ConfigurationManagement\MySqlConnectionForm.Designer.cs"> + <DependentUpon>MySqlConnectionForm.cs</DependentUpon> + </Compile> <Compile Include="ConnectionProvider.cs" /> <Compile Include="DataBase.cs" /> <Compile Include="DataBaseVersionManager.cs" /> + <Compile Include="DbCommandBuilderProvider.cs" /> + <Compile Include="DbCommandProvider.cs" /> + <Compile Include="DbDataAdapterProvider.cs" /> <Compile Include="OleDbSingleTableAdapter.cs" /> <Compile Include="QuoteField.cs" /> *************** *** 67,70 **** --- 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> *************** *** 73,76 **** --- 92,96 ---- <Name>b1_ADT</Name> </ProjectReference> + <Folder Include="ConfigurationManagement" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
|
From: Glauco S. <gla...@us...> - 2008-12-30 00:02:58
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13929/b2_DataAccess Added Files: DbDataAdapterProvider.cs Log Message: Provides a DbDataAdapter for the given Sql command --- NEW FILE: DbDataAdapterProvider.cs --- /* QuantProject - Quantitative Finance Library DbDataAdapterProvider.cs Copyright (C) 2008 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Data; using System.Data.Common; using System.Data.OleDb; using MySql.Data.MySqlClient; namespace QuantProject.DataAccess { /// <summary> /// Provides a DbDataAdapter for the given Sql command /// </summary> public class DbDataAdapterProvider { public DbDataAdapterProvider() { } #region GetDbDataAdapter private static void ensureConnectionIsOpen() { if( ConnectionProvider.DbConnection.State != ConnectionState.Open ) ConnectionProvider.DbConnection.Open(); } private static DbDataAdapter getDbDataAdapter( string selectCommandText ) { DbDataAdapter dbDataAdapter = null; switch ( ConnectionProvider.DbType ) { case DbType.Access: dbDataAdapter = new OleDbDataAdapter( selectCommandText , (OleDbConnection)ConnectionProvider.DbConnection ); break; case DbType.MySql: dbDataAdapter = new MySqlDataAdapter( selectCommandText , (MySqlConnection)ConnectionProvider.DbConnection ); break; default: throw new Exception( "Unknown database type. Complete the switch statement, please" ); } // if ( ConnectionProvider.DbConnection is OleDbConnection ) // dbDataAdapter = new OleDbDataAdapter( // selectCommandText , (OleDbConnection)ConnectionProvider.DbConnection ); // if ( ConnectionProvider.DbConnection is MySqlConnection ) // dbDataAdapter = new MySqlDataAdapter( // selectCommandText , (MySqlConnection)ConnectionProvider.DbConnection ); return dbDataAdapter; } public static DbDataAdapter GetDbDataAdapter( string selectCommandText ) { DbDataAdapterProvider.ensureConnectionIsOpen(); DbDataAdapter dbDataAdapter = DbDataAdapterProvider.getDbDataAdapter( selectCommandText ); return dbDataAdapter; } #endregion GetDbDataAdapter } } |
|
From: Glauco S. <gla...@us...> - 2008-12-30 00:02:44
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13866 Added Files: DbCommandProvider.cs Log Message: Provides a DbCommand for the given sql command --- NEW FILE: DbCommandProvider.cs --- /* QuantProject - Quantitative Finance Library DbCommandProvider.cs Copyright (C) 2008 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Data.Common; using System.Data.OleDb; using MySql.Data.MySqlClient; namespace QuantProject.DataAccess { /// <summary> /// Provides a DbCommand for the given sql command /// </summary> public class DbCommandProvider { public DbCommandProvider() { } public static DbCommand GetDbCommand( string commandToBeExecuted ) { DbCommand dbCommand = null; switch ( ConnectionProvider.DbType ) { case DbType.Access: dbCommand = new OleDbCommand( commandToBeExecuted , (OleDbConnection)ConnectionProvider.DbConnection ); break; case DbType.MySql: dbCommand = new MySqlCommand( commandToBeExecuted , (MySqlConnection)ConnectionProvider.DbConnection ); break; default: throw new Exception( "Unknown database type. Complete the switch statement, please" ); } // if ( ConnectionProvider.DbConnection is OleDbConnection ) // dbCommand = new OleDbCommand( // commandToBeExecuted , (OleDbConnection)ConnectionProvider.DbConnection ); // if ( ConnectionProvider.DbConnection is MySqlConnection ) // dbCommand = new MySqlCommand( // commandToBeExecuted , (MySqlConnection)ConnectionProvider.DbConnection ); return dbCommand; } } } |
|
From: Glauco S. <gla...@us...> - 2008-12-30 00:02:32
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13789/b2_DataAccess Added Files: DbCommandBuilderProvider.cs Log Message: Provides a DbCommandBuilder for the given DbDataProvider --- NEW FILE: DbCommandBuilderProvider.cs --- /* QuantProject - Quantitative Finance Library DbCommandProvider.cs Copyright (C) 2008 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Data.Common; using System.Data.OleDb; using MySql.Data.MySqlClient; namespace QuantProject.DataAccess { /// <summary> /// Provides a DbCommandBuilder for the given DbDataProvider /// </summary> public class DbCommandBuilderProvider { public DbCommandBuilderProvider() { } public static DbCommandBuilder GetDbCommanBuilder( DbDataAdapter dbDataAdapter ) { DbCommandBuilder dbCommandBuilder = null; switch ( ConnectionProvider.DbType ) { case DbType.Access: dbCommandBuilder = new OleDbCommandBuilder( (OleDbDataAdapter)dbDataAdapter ); break; case DbType.MySql: dbCommandBuilder = new MySqlCommandBuilder( (MySqlDataAdapter)dbDataAdapter ); break; default: throw new Exception( "Unknown database type. Complete the switch statement, please" ); } // if ( dbDataAdapter is OleDbDataAdapter ) // dbCommandBuilder = new OleDbCommandBuilder( // (OleDbDataAdapter)dbDataAdapter ); // if ( dbDataAdapter is MySqlDataAdapter ) // dbCommandBuilder = new MySqlCommandBuilder( // (MySqlDataAdapter)dbDataAdapter ); return dbCommandBuilder; } } } |
|
From: Glauco S. <gla...@us...> - 2008-12-30 00:00:26
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess/ConfigurationManagement In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13471 Added Files: MySqlConnectionForm.cs MySqlConnectionForm.Designer.cs Log Message: Reads data from the user and returns the MySQL connection string for those data --- NEW FILE: MySqlConnectionForm.cs --- /* QuantProject - Quantitative Finance Library ConfigManager.cs Copyright (C) 2008 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Drawing; using System.Windows.Forms; namespace QuantProject.DataAccess { /// <summary> /// Reads data from the user and returns the MySQL connection string for those data /// </summary> public partial class MySqlConnectionForm : Form { private string mySqlConnectionString; public string MySqlConnectionString { get { return this.mySqlConnectionString; } } public MySqlConnectionForm() { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); // // TODO: Add constructor code after the InitializeComponent() call. // } #region ButtonOkClick void ButtonOkClick(object sender, EventArgs e) { this.mySqlConnectionString = "Database=" + this.textBoxDataBase.Text + ";Data Source=" + this.textBoxServerHost.Text + ";User Id=" + this.textBoxUsername.Text + ";Password=" + this.textBoxPassword.Text; this.Close(); } #endregion ButtonOkClick } } --- NEW FILE: MySqlConnectionForm.Designer.cs --- (This appears to be a binary file; contents omitted.) |
|
From: Glauco S. <gla...@us...> - 2008-12-29 23:59:58
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess/ConfigurationManagement In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13375 Added Files: DbTypeChooser.cs DbTypeChooser.Designer.cs Log Message: Use this form to let the user chose the database type to be used --- NEW FILE: DbTypeChooser.Designer.cs --- (This appears to be a binary file; contents omitted.) --- NEW FILE: DbTypeChooser.cs --- /* QuantProject - Quantitative Finance Library DbTypeChooser.cs Copyright (C) 2008 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Drawing; using System.Windows.Forms; namespace QuantProject.DataAccess { /// <summary> /// Use this form to let the user chose the database type to be used /// </summary> public partial class DbTypeChooser : Form { private DbType dbType; public DbType DbType { get { return this.dbType; } } public DbTypeChooser() { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); // // TODO: Add constructor code after the InitializeComponent() call. // } #region ButtonSelectClick private bool hasTheDatabaseTypeBeenSelected() { bool hasBeenSelected = ( this.radioButtonAccess.Checked || this.radioButtonMySql.Checked ); return hasBeenSelected; } private void assign_dbType() { if ( this.radioButtonAccess.Checked ) this.dbType = DbType.Access; if ( this.radioButtonMySql.Checked ) this.dbType = DbType.MySql; } void ButtonSelectClick(object sender, EventArgs e) { if ( this.hasTheDatabaseTypeBeenSelected() ) // at least a radio button has been selected this.assign_dbType(); else // no radio button has been selected MessageBox.Show( "Select the database type, please" ); this.Close(); } #endregion ButtonSelectClick void DbTypeChooserLoad(object sender, EventArgs e) { this.radioButtonAccess.Checked = false; } } } |
|
From: Glauco S. <gla...@us...> - 2008-12-29 23:59:00
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess/ConfigurationManagement In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13239 Added Files: DbType.cs Log Message: supported database types --- NEW FILE: DbType.cs --- /* QuantProject - Quantitative Finance Library DbType.cs Copyright (C) 2008 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; namespace QuantProject.DataAccess { /// <summary> /// supported database types /// </summary> public enum DbType { Undefined , Access , MySql } } |
|
From: Glauco S. <gla...@us...> - 2008-12-29 23:57:06
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess/ConfigurationManagement In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv12945 Added Files: ConfigManager.cs Log Message: Use this class to access (read/write) the config file --- NEW FILE: ConfigManager.cs --- /* QuantProject - Quantitative Finance Library ConfigManager.cs Copyright (C) 2008 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Configuration; using System.Windows.Forms; namespace QuantProject.DataAccess { /// <summary> /// Use this class to access (read/write) the config file /// </summary> public class ConfigManager { private static string keyFor_mdbPath = "mdbPath"; private static string keyFor_mySqlConnectionString = "mySqlConnectionString"; private static string keyFor_chosenDbType = "dbType"; private static string configValueForAccessDbType = "Access"; private static string configValueForMySqlDbType = "MySQL"; // /// <summary> // /// true iif the path for the Access file is configured // /// </summary> // public static bool IsMdbPathConfigured // { // get // { // bool isMdbPathConfigured = // ConfigManager.containsKey( ConfigManager.keyFor_mdbPath ); // return isMdbPathConfigured; // } // } #region MdbPath /// <summary> /// Full path to the Access database /// </summary> public static string MdbPath { get { return ConfigManager.getMdbPath(); } } #region getMdbPath private static void checkIfDbTypeIsAccess() { if ( !ConfigManager.IsChosenDbTypeAccess ) throw new Exception( "MdbPath can be read only if the chosen database type is Access" ); } #region getMdbPathActually #region setMdbPathReadingItFromUser private static string readMdbPathFromUser() { AccessDataBaseLocator dataBaseLocator = new AccessDataBaseLocator(); string mdbPath = dataBaseLocator.Path; return mdbPath; } private static void setMdbPathReadingItFromUser() { string mdbPath = ConfigManager.readMdbPathFromUser(); ConfigManager.setAppConfig( ConfigManager.keyFor_mdbPath , mdbPath ); } #endregion setMdbPathReadingItFromUser private static string getMdbPathActually() { if ( !ConfigManager.containsKey( ConfigManager.keyFor_mdbPath ) ) // the config value for the mdb path has not been configured yet ConfigManager.setMdbPathReadingItFromUser(); string mdbPath = ConfigManager.getAppConfig( ConfigManager.keyFor_mdbPath ); return mdbPath; } #endregion getMdbPathActually private static string getMdbPath() { ConfigManager.checkIfDbTypeIsAccess(); string mdbPath = ConfigManager.getMdbPathActually(); return mdbPath; } #endregion getMdbPath #endregion MdbPath #region MySqlConnectionString /// <summary> /// Connection string to the MySQL database /// </summary> public static string MySqlConnectionString { get { return ConfigManager.getMySqlConnectionString(); } } #region getMySqlConnectionString private static void checkIfDbTypeIsMySQL() { if ( !ConfigManager.IsChosenDbTypeMySql ) throw new Exception( "MySqlConnectionString can be read " + "only if the chosen database type is MySQL" ); } #region setConnectionStringReadingDataFromUser private static string getMySqlConnectionStringReadingDataFromUser() { MySqlConnectionForm mySqlConnectionForm = new MySqlConnectionForm(); mySqlConnectionForm.ShowDialog(); string connectionString = mySqlConnectionForm.MySqlConnectionString; return connectionString; } private static void setMySqlConnectionStringReadingDataFromUser() { string connectionString = ConfigManager.getMySqlConnectionStringReadingDataFromUser(); ConfigManager.setAppConfig( ConfigManager.keyFor_mySqlConnectionString , connectionString ); } #endregion setConnectionStringReadingDataFromUser private static string getMySqlConnectionStringActually() { if ( !ConfigManager.containsKey( ConfigManager.keyFor_mySqlConnectionString ) ) // the config value for the MySQL connection string has not been configured yet ConfigManager.setMySqlConnectionStringReadingDataFromUser(); string mySqlConnectionString = ConfigManager.getAppConfig( ConfigManager.keyFor_mySqlConnectionString ); return mySqlConnectionString; } private static string getMySqlConnectionString() { ConfigManager.checkIfDbTypeIsMySQL(); string mySqlConnectionString = ConfigManager.getMySqlConnectionStringActually(); return mySqlConnectionString; } #endregion getMySqlConnectionString #endregion MySqlConnectionString #region IsChosenDbTypeAccess #region getChosenDbType #region setChosenDbTypeIfTheCase private static bool isChosenDbTypeValid() { string configValueForChosenDbType = ConfigManager.getAppConfig( ConfigManager.keyFor_chosenDbType ); bool isValid = ( ( configValueForChosenDbType == ConfigManager.configValueForAccessDbType ) || ( configValueForChosenDbType == ConfigManager.configValueForMySqlDbType ) ); return isValid; } #region setDbType private static string getConfigValue( DbType dbType ) { string configValue = null; switch ( dbType ) { case DbType.Access: configValue = ConfigManager.configValueForAccessDbType; break; case DbType.MySql: configValue = ConfigManager.configValueForMySqlDbType; break; default: throw new Exception( "An unmanaged dbType has been given: complete the switch " + "statement to manage it" ); } return configValue; } private static void setDbType() { DbTypeChooser dbTypeChooser = new DbTypeChooser(); dbTypeChooser.ShowDialog(); string configValue = ConfigManager.getConfigValue( dbTypeChooser.DbType ); ConfigManager.setAppConfig( ConfigManager.keyFor_chosenDbType , configValue ); } #endregion setDbType private static void setChosenDbTypeIfTheCase() { if ( ( !ConfigManager.containsKey( ConfigManager.keyFor_chosenDbType ) ) || ( !ConfigManager.isChosenDbTypeValid() ) ) // either the database typer has not been defined yet, or // it has been defined, but the config value is invalid ConfigManager.setDbType(); } #endregion setChosenDbTypeIfTheCase // private static void checkIfKeyForChosenDbTypeIsDefined() // { // if ( !ConfigManager.containsKey( ConfigManager.keyFor_chosenDbType ) ) // throw new Exception( // "The config file doesn't contain the key '" + // ConfigManager.keyFor_chosenDbType + "'" ); // } // private static void checkIfConfigValueForChosenDbTypeIsAValidValue() // { // string chosenDbType = ConfigManager.getAppConfig( // ConfigManager.keyFor_chosenDbType ); // if ( // ( chosenDbType != ConfigManager.configValueForAccessDbType ) && // ( chosenDbType != ConfigManager.configValueForMySqlDbType ) ) // throw new Exception( // "An invalid database type value has been found in the config file. " + // "The key to be configured is '" + ConfigManager.keyFor_chosenDbType + "'. " + // "Allowed values are either '" + // ConfigManager.configValueForAccessDbType + "' or '" + // ConfigManager.configValueForMySqlDbType +"'" ); // } private static string getChosenDbType() { ConfigManager.setChosenDbTypeIfTheCase(); // ConfigManager.checkIfKeyForChosenDbTypeIsDefined(); // ConfigManager.checkIfConfigValueForChosenDbTypeIsAValidValue(); string chosenDbType = ConfigManager.getAppConfig( ConfigManager.keyFor_chosenDbType ); return chosenDbType; } #endregion getChosenDbType /// <summary> /// true iif the current chosen database type is set to Access /// </summary> /// <param name="mdbPath"></param> public static bool IsChosenDbTypeAccess { get { string chosenDbType = ConfigManager.getChosenDbType(); bool isChosenDbTypeAccess = ( chosenDbType == ConfigManager.configValueForAccessDbType ); return isChosenDbTypeAccess; } } #endregion IsChosenDbTypeAccess /// <summary> /// true iif the current chosen database type is set to MySQL /// </summary> public static bool IsChosenDbTypeMySql { get { string chosenDbType = ConfigManager.getChosenDbType(); bool isChosenDbTypeMySQL = ( chosenDbType == ConfigManager.configValueForMySqlDbType ); return isChosenDbTypeMySQL; } } public ConfigManager() { } public static void SetMdbPath( string mdbPath ) { ConfigManager.getAppConfig( ConfigManager.keyFor_mdbPath ); } private static void setAppConfig( string key , string configurationValue ) { Configuration configuration = ConfigurationManager.OpenExeConfiguration( Application.ExecutablePath ); configuration.AppSettings.Settings.Remove( key ); configuration.AppSettings.Settings.Add( key , configurationValue ); configuration.Save(); } private static string getAppConfig( string key ) { Configuration configuration = ConfigurationManager.OpenExeConfiguration( Application.ExecutablePath ); string configurationValue = configuration.AppSettings.Settings[ key ].Value; return configurationValue; } private static bool containsKey( string key ) { Configuration configuration = ConfigurationManager.OpenExeConfiguration( Application.ExecutablePath ); bool configurationContains = ( configuration.AppSettings.Settings[ key ] != null ); return configurationContains; } } } |
|
From: Glauco S. <gla...@us...> - 2008-12-29 23:56:45
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess/ConfigurationManagement In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv12868 Added Files: AccessDataBaseLocator.cs Log Message: b2_DataAccess\DataBaseLocator.cs has been moved to b2_DataAccess\ConfigurationManagement\AccessDataBaseLocator.cs --- NEW FILE: AccessDataBaseLocator.cs --- /* QuantProject - Quantitative Finance Library AccessDataBaseLocator.cs Copyright (C) 2008 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; //using System.Xml; //using System.IO; using System.Windows.Forms; namespace QuantProject.DataAccess { /// <summary> /// Locate the database /// </summary> public class AccessDataBaseLocator { // private string dataBaseType; // private StreamReader stream; // private XmlTextReader xmlTextReader; private string path; public string Path { get { return path; } } public AccessDataBaseLocator() { // if ( !ConfigManager.IsMdbPathConfigured ) // { this.path = this.selectDataBase(); // ConfigManager.SetMdbPath( this.path ); // } } private string selectDataBase() { string fileName = "QuantProject.mdb"; OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Title = "Select " + fileName + " please ..."; openFileDialog.Multiselect = false; openFileDialog.CheckFileExists = true; openFileDialog.Filter = fileName + "|" + fileName; openFileDialog.ShowDialog(); return openFileDialog.FileName; } } } |
|
From: Glauco S. <gla...@us...> - 2008-12-29 23:56:05
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess/ConfigurationManagement In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv12729/ConfigurationManagement Log Message: Directory /cvsroot/quantproject/QuantProject/b2_DataAccess/ConfigurationManagement added to the repository |
|
From: Glauco S. <gla...@us...> - 2008-12-29 23:55:18
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv12598/b2_DataAccess Removed Files: DataBaseLocator.cs Log Message: b2_DataAccess\DataBaseLocator.cs has been moved to b2_DataAccess\ConfigurationManagement\AccessDataBaseLocator.cs --- DataBaseLocator.cs DELETED --- |
|
From: Glauco S. <gla...@us...> - 2008-12-18 20:08:27
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv21977/b7_Scripts/WalkForwardTesting/PairsTrading Modified Files: PairsTradingMain.cs Log Message: the names for report and log objects have been improved: now minutes can be used Index: PairsTradingMain.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/PairsTradingMain.cs,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** PairsTradingMain.cs 10 Dec 2008 19:40:56 -0000 1.24 --- PairsTradingMain.cs 18 Dec 2008 20:08:16 -0000 1.25 *************** *** 94,98 **** { this.firstTimeToTestInefficiency = new Time( 10 , 0 , 0 ); ! this.lastTimeToTestInefficiency = new Time( 14 , 0 , 0 ); this.timeToClosePositions = new Time( 15 , 50 , 0 ); } --- 94,98 ---- { this.firstTimeToTestInefficiency = new Time( 10 , 0 , 0 ); ! this.lastTimeToTestInefficiency = new Time( 11 , 0 , 0 ); this.timeToClosePositions = new Time( 15 , 50 , 0 ); } *************** *** 234,238 **** OutOfSampleChooser outOfSampleChooser = new OutOfSampleChooserForSingleLongAndShort( ! 0.006 , 0.02 , 0.006 , 0.02 ); // outOfSampleChooser = // new OutOfSampleChooserForExactNumberOfBestLongPositions( --- 234,238 ---- OutOfSampleChooser outOfSampleChooser = new OutOfSampleChooserForSingleLongAndShort( ! 0.01 , 0.03 , 0.01 , 0.03 ); // outOfSampleChooser = // new OutOfSampleChooserForExactNumberOfBestLongPositions( *************** *** 285,289 **** // uncomment the following two lines for a faster script ! firstDateTime = new DateTime( 2006 , 2 , 1 ); lastDateTime = new DateTime( 2007 , 12 , 31 ); --- 285,289 ---- // uncomment the following two lines for a faster script ! firstDateTime = new DateTime( 2006 , 1 , 2 ); lastDateTime = new DateTime( 2007 , 12 , 31 ); *************** *** 310,320 **** } protected override string getCustomSmallTextForFolderName() { return "pairsTrdngIntrdy_" + ! this.firstTimeToTestInefficiency.Hour + "_" + ! this.lastTimeToTestInefficiency.Hour + "_" + ! this.timeToClosePositions.Hour; } protected override string getFullPathFileNameForMain() --- 310,332 ---- } + #region getCustomSmallTextForFolderName + private string getSmallText( Time time ) + { + string smallText = time.Hour.ToString(); + if ( time.Minute != 0 ) + smallText += "." + time.Minute.ToString(); + return smallText; + } protected override string getCustomSmallTextForFolderName() { return "pairsTrdngIntrdy_" + ! this.getSmallText( this.firstTimeToTestInefficiency ) + "_" + ! this.getSmallText( this.lastTimeToTestInefficiency ) + "_" + ! this.getSmallText( this.timeToClosePositions ); ! // this.firstTimeToTestInefficiency.Hour + "_" + ! // this.lastTimeToTestInefficiency.Hour + "_" + ! // this.timeToClosePositions.Hour; } + #endregion getCustomSmallTextForFolderName protected override string getFullPathFileNameForMain() |
|
From: Glauco S. <gla...@us...> - 2008-12-18 20:06:39
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataProviders/Bars/Caching In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv21867/b3_Data/DataProviders/Bars/Caching Modified Files: BarCacheData.cs Log Message: a couple of bugs have been fixed: they gave problems when the cache was cleaned up Index: BarCacheData.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataProviders/Bars/Caching/BarCacheData.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BarCacheData.cs 8 Nov 2008 20:13:55 -0000 1.1 --- BarCacheData.cs 18 Dec 2008 20:06:27 -0000 1.2 *************** *** 65,69 **** this.maxNumberOfItemsIn_bars = maxNumberOfItemsIn_bars; this.numberOfItemsToBeRemovedFrom_bars_whenCacheIsCleanedUp = ! numberOfBarsIn_bars; this.bars = new Dictionary< DateTime , Dictionary< string , double > >(); --- 65,69 ---- this.maxNumberOfItemsIn_bars = maxNumberOfItemsIn_bars; this.numberOfItemsToBeRemovedFrom_bars_whenCacheIsCleanedUp = ! numberOfItemsToBeRemovedFrom_bars_whenCacheIsCleanedUp; this.bars = new Dictionary< DateTime , Dictionary< string , double > >(); *************** *** 126,150 **** #endregion initializeMembersForCleaningUp_bars ! #region removeNextItemFrom_bars ! ! // private void update_tickersForCleaningUp_bars() ! // { ! // 344 ! // } ! #region removeNextItemFrom_bars_withUpdated_tickersForCleaningUp #region removeCurrentItemFrom_bars #region removeCurrentItemFrom_bars_actually private void removeCurrentItemFrom_bars_only() { ! DateTime dateTimeForCurrentItemToBeRemoved = this.dateTimesForCleaningUp_bars[ 0 ]; string tickerForCurrentItemToBeRemoved = this.tickersForCleaningUp_bars[ 0 ]; ! this.bars[ dateTimeForCurrentItemToBeRemoved ].Remove( tickerForCurrentItemToBeRemoved ); } #region updateMembersUsedToCleanUp_bars --- 126,157 ---- #endregion initializeMembersForCleaningUp_bars ! // #region removeNextItemFrom_bars ! #region removeNextItemFrom_bars #region removeCurrentItemFrom_bars #region removeCurrentItemFrom_bars_actually + + #region removeCurrentItemFrom_bars_only + private void removeCurrentDateTimeFromCache_ifAllBarsHaveBeenRemovedForThatDateTime( + DateTime dateTimeForLastBarRemovedFromCache ) + { + if ( this.bars[ dateTimeForLastBarRemovedFromCache ].Count == 0 ) + // all bars have been removed from the cache, for dateTimeForCurrentItemToBeRemoved + this.bars.Remove( dateTimeForLastBarRemovedFromCache ); + } private void removeCurrentItemFrom_bars_only() { ! DateTime dateTimeForCurrentBarToBeRemoved = this.dateTimesForCleaningUp_bars[ 0 ]; string tickerForCurrentItemToBeRemoved = this.tickersForCleaningUp_bars[ 0 ]; ! this.bars[ dateTimeForCurrentBarToBeRemoved ].Remove( tickerForCurrentItemToBeRemoved ); + this.removeCurrentDateTimeFromCache_ifAllBarsHaveBeenRemovedForThatDateTime( + dateTimeForCurrentBarToBeRemoved ); } + #endregion removeCurrentItemFrom_bars_only #region updateMembersUsedToCleanUp_bars *************** *** 170,174 **** { this.removeCurrentItemFrom_bars_only(); ! this.updateMembersUsedToCleanUp_bars(); } #endregion removeCurrentItemFrom_bars_actually --- 177,181 ---- { this.removeCurrentItemFrom_bars_only(); ! // this.updateMembersUsedToCleanUp_bars(); } #endregion removeCurrentItemFrom_bars_actually *************** *** 181,197 **** #endregion removeCurrentItemFrom_bars ! private void removeNextItemFrom_bars_withUpdated_tickersForCleaningUp() { this.removeCurrentItemFrom_bars(); this.updateMembersUsedToCleanUp_bars(); } - #endregion removeNextItemFrom_bars_withUpdated_tickersForCleaningUp - - private void removeNextItemFrom_bars() - { - this.removeNextItemFrom_bars_withUpdated_tickersForCleaningUp(); - } #endregion removeNextItemFrom_bars private void removeValuesFromTheCache() { --- 188,204 ---- #endregion removeCurrentItemFrom_bars ! private void removeNextItemFrom_bars() { this.removeCurrentItemFrom_bars(); this.updateMembersUsedToCleanUp_bars(); } #endregion removeNextItemFrom_bars + // private void removeNextItemFrom_bars() + // { + // this.removeNextItemFrom_bars_withUpdated_tickersForCleaningUp(); + // } + // #endregion removeNextItemFrom_bars + private void removeValuesFromTheCache() { |
|
From: Marco M. <mi...@us...> - 2008-12-16 23:18:27
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Timing In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv8871/b1_ADT/Timing Modified Files: Time.cs Log Message: Added instance method AddMinutes Index: Time.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Timing/Time.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Time.cs 13 Dec 2008 17:16:21 -0000 1.6 --- Time.cs 16 Dec 2008 23:18:20 -0000 1.7 *************** *** 50,53 **** --- 50,64 ---- #endregion isValidTimeFormat + /// <summary> + /// Adds the given minutes to the current instance's value + /// </summary> + /// <param name="minutesToAdd">minutes to add (if positive) or to + /// subtract (if negative) from the current instance</param> + public Time AddMinutes( double minutesToAdd ) + { + DateTime standardDateTimeWithMinutesAdded = + this.standardDateTime.AddMinutes(minutesToAdd); + return new Time(standardDateTimeWithMinutesAdded); + } /// <summary> *************** *** 64,68 **** } - private DateTime standardDateTime; --- 75,78 ---- |
|
From: Marco M. <mi...@us...> - 2008-12-13 17:16:28
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Timing In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv15544/b1_ADT/Timing Modified Files: Time.cs Log Message: The good code implementing IsValidTimeFormat method has been restored Index: Time.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Timing/Time.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Time.cs 10 Dec 2008 19:42:48 -0000 1.5 --- Time.cs 13 Dec 2008 17:16:21 -0000 1.6 *************** *** 35,73 **** public static bool IsValidTimeFormat ( string stringRepresentingTime ) { ! bool returnValue = false; ! char[] chars = stringRepresentingTime.ToCharArray(); ! if( ! //first - hour ! (chars[0]=='0' || chars[0]=='1' || chars[0]=='2') && ! //second - hour ! ( (chars[0]=='0' || chars[0]=='1') && ! (chars[1]=='0' || chars[1]=='1' || chars[1]=='2' || ! chars[1]=='3' || chars[1]=='4' || chars[1]=='5' || ! chars[1]=='6' || chars[1]=='7' || chars[1]=='8' || chars[1]=='9') || ! chars[0] == '2' && ! (chars[1]=='0' || chars[1]=='1' || chars[1]=='2' || ! chars[1]=='3' || chars[1]=='4') ) && ! //third - separator ! (chars[2]==':') && ! //fourth - minute ! (chars[3]=='0' || chars[3]=='1' || chars[3]=='2' || ! chars[3]=='3' || chars[3]=='4' || chars[3]=='5') && ! //fifth - minute ! (chars[4]=='0' || chars[4]=='1' || chars[4]=='2' || ! chars[4]=='3' || chars[4]=='4' || chars[4]=='5' || ! chars[4]=='6' || chars[4]=='7' || chars[4]=='8' || chars[4]=='9') && ! //sixth - separator ! (chars[5]==':') && ! //seventh - second ! (chars[6]=='0' || chars[6]=='1' || chars[6]=='2' || ! chars[6]=='3' || chars[6]=='4' || chars[6]=='5') && ! //eighth - second ! (chars[7]=='0' || chars[7]=='1' || chars[7]=='2' || ! chars[7]=='3' || chars[7]=='4' || chars[7]=='5' || ! chars[7]=='6' || chars[7]=='7' || chars[7]=='8' || chars[7]=='9') ! ) ! returnValue = true; ! ! return returnValue; } #endregion isValidTimeFormat --- 35,50 ---- public static bool IsValidTimeFormat ( string stringRepresentingTime ) { ! int hour = Convert.ToInt32(stringRepresentingTime.Substring(0,2)); ! int minute = Convert.ToInt32(stringRepresentingTime.Substring(3,2)); ! int second = Convert.ToInt32(stringRepresentingTime.Substring(6,2)); ! string firstSeparator = stringRepresentingTime.Substring(2,1); ! string secondSeparator = stringRepresentingTime.Substring(5,1); ! return (stringRepresentingTime.Length == 8) && ! (hour >= 0 && hour <= 24) && ! (firstSeparator == ":") && ! (minute >= 0 && minute <= 59) && ! (secondSeparator == ":") && ! (second >= 0 && second <= 59); ! } #endregion isValidTimeFormat *************** *** 128,133 **** private void time_checkParameter ( string stringRepresentingTime ) { ! if( stringRepresentingTime.Length != 8 || ! !Time.IsValidTimeFormat( stringRepresentingTime ) ) throw new Exception("string is not in the requested time-format hh:mm:ss"); } --- 105,109 ---- private void time_checkParameter ( string stringRepresentingTime ) { ! if( !Time.IsValidTimeFormat( stringRepresentingTime ) ) throw new Exception("string is not in the requested time-format hh:mm:ss"); } |
|
From: Marco M. <mi...@us...> - 2008-12-13 17:15:48
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv15506/b4_Business/a2_Strategies Modified Files: AccountManager.cs Log Message: Static method getTickersInOpenedPositions becomes public (it may be useful to scripts) Index: AccountManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/AccountManager.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** AccountManager.cs 6 Feb 2008 22:51:22 -0000 1.6 --- AccountManager.cs 13 Dec 2008 17:15:35 -0000 1.7 *************** *** 51,55 **** } ! static private string[] getTickersInOpenedPositions(Account account) { Position[] positions = new Position[account.Portfolio.Count]; --- 51,55 ---- } ! static public string[] GetTickersInOpenedPositions(Account account) { Position[] positions = new Position[account.Portfolio.Count]; *************** *** 63,67 **** static public void ClosePositions(Account account) { ! string[] tickers = getTickersInOpenedPositions( account ); foreach( string ticker in tickers) account.ClosePosition( ticker ); --- 63,67 ---- static public void ClosePositions(Account account) { ! string[] tickers = GetTickersInOpenedPositions( account ); foreach( string ticker in tickers) account.ClosePosition( ticker ); *************** *** 131,135 **** { double positionsAbsoluteValue = getWeightedPositions_getPositionsAbsoluteValue(account); ! string[] tickers = getTickersInOpenedPositions( account ); double[] weights = new double[tickers.Length]; for(int i = 0; i < tickers.Length; i++) --- 131,135 ---- { double positionsAbsoluteValue = getWeightedPositions_getPositionsAbsoluteValue(account); ! string[] tickers = GetTickersInOpenedPositions( account ); double[] weights = new double[tickers.Length]; for(int i = 0; i < tickers.Length; i++) |
|
From: Glauco S. <gla...@us...> - 2008-12-10 19:42:59
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Timing In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14611/b1_ADT/Timing Modified Files: Time.cs Log Message: - automatic indentation has been applied - a new method public static void CheckStrictlyAscending( List< Time > times ) has been added Index: Time.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Timing/Time.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Time.cs 20 Nov 2008 20:37:59 -0000 1.4 --- Time.cs 10 Dec 2008 19:42:48 -0000 1.5 *************** *** 22,25 **** --- 22,26 ---- using System; + using System.Collections.Generic; namespace QuantProject.ADT.Timing *************** *** 36,70 **** bool returnValue = false; char[] chars = stringRepresentingTime.ToCharArray(); ! if( ! //first - hour ! (chars[0]=='0' || chars[0]=='1' || chars[0]=='2') && ! //second - hour ! ( (chars[0]=='0' || chars[0]=='1') && ! (chars[1]=='0' || chars[1]=='1' || chars[1]=='2' || ! chars[1]=='3' || chars[1]=='4' || chars[1]=='5' || ! chars[1]=='6' || chars[1]=='7' || chars[1]=='8' || chars[1]=='9') || ! chars[0] == '2' && ! (chars[1]=='0' || chars[1]=='1' || chars[1]=='2' || ! chars[1]=='3' || chars[1]=='4') ) && ! //third - separator ! (chars[2]==':') && ! //fourth - minute ! (chars[3]=='0' || chars[3]=='1' || chars[3]=='2' || ! chars[3]=='3' || chars[3]=='4' || chars[3]=='5') && ! //fifth - minute ! (chars[4]=='0' || chars[4]=='1' || chars[4]=='2' || ! chars[4]=='3' || chars[4]=='4' || chars[4]=='5' || ! chars[4]=='6' || chars[4]=='7' || chars[4]=='8' || chars[4]=='9') && ! //sixth - separator ! (chars[5]==':') && ! //seventh - second ! (chars[6]=='0' || chars[6]=='1' || chars[6]=='2' || ! chars[6]=='3' || chars[6]=='4' || chars[6]=='5') && ! //eighth - second ! (chars[7]=='0' || chars[7]=='1' || chars[7]=='2' || ! chars[7]=='3' || chars[7]=='4' || chars[7]=='5' || ! chars[7]=='6' || chars[7]=='7' || chars[7]=='8' || chars[7]=='9') ! ) ! returnValue = true; return returnValue; --- 37,71 ---- bool returnValue = false; char[] chars = stringRepresentingTime.ToCharArray(); ! if( ! //first - hour ! (chars[0]=='0' || chars[0]=='1' || chars[0]=='2') && ! //second - hour ! ( (chars[0]=='0' || chars[0]=='1') && ! (chars[1]=='0' || chars[1]=='1' || chars[1]=='2' || ! chars[1]=='3' || chars[1]=='4' || chars[1]=='5' || ! chars[1]=='6' || chars[1]=='7' || chars[1]=='8' || chars[1]=='9') || ! chars[0] == '2' && ! (chars[1]=='0' || chars[1]=='1' || chars[1]=='2' || ! chars[1]=='3' || chars[1]=='4') ) && ! //third - separator ! (chars[2]==':') && ! //fourth - minute ! (chars[3]=='0' || chars[3]=='1' || chars[3]=='2' || ! chars[3]=='3' || chars[3]=='4' || chars[3]=='5') && ! //fifth - minute ! (chars[4]=='0' || chars[4]=='1' || chars[4]=='2' || ! chars[4]=='3' || chars[4]=='4' || chars[4]=='5' || ! chars[4]=='6' || chars[4]=='7' || chars[4]=='8' || chars[4]=='9') && ! //sixth - separator ! (chars[5]==':') && ! //seventh - second ! (chars[6]=='0' || chars[6]=='1' || chars[6]=='2' || ! chars[6]=='3' || chars[6]=='4' || chars[6]=='5') && ! //eighth - second ! (chars[7]=='0' || chars[7]=='1' || chars[7]=='2' || ! chars[7]=='3' || chars[7]=='4' || chars[7]=='5' || ! chars[7]=='6' || chars[7]=='7' || chars[7]=='8' || chars[7]=='9') ! ) ! returnValue = true; return returnValue; *************** *** 83,87 **** { return new DateTime( dateTime.Year , dateTime.Month , dateTime.Day, ! time.Hour , time.Minute , time.Second ); } --- 84,88 ---- { return new DateTime( dateTime.Year , dateTime.Month , dateTime.Day, ! time.Hour , time.Minute , time.Second ); } *************** *** 127,132 **** private void time_checkParameter ( string stringRepresentingTime ) { ! if( stringRepresentingTime.Length != 8 || ! !Time.IsValidTimeFormat( stringRepresentingTime ) ) throw new Exception("string is not in the requested time-format hh:mm:ss"); } --- 128,133 ---- private void time_checkParameter ( string stringRepresentingTime ) { ! if( stringRepresentingTime.Length != 8 || ! !Time.IsValidTimeFormat( stringRepresentingTime ) ) throw new Exception("string is not in the requested time-format hh:mm:ss"); } *************** *** 141,145 **** //just for compiling next two lines this.time_checkParameter( stringRepresentingTime ); ! this.standardDateTime = this.time_getStandardTimeFromString( stringRepresentingTime ); } --- 142,146 ---- //just for compiling next two lines this.time_checkParameter( stringRepresentingTime ); ! this.standardDateTime = this.time_getStandardTimeFromString( stringRepresentingTime ); } *************** *** 231,234 **** --- 232,252 ---- return returnValue; } + + #region CheckStrictlyAscending + private static void checkStrictlyAscending( + List< Time > times , int timeIndex ) + { + Time currentTime = times[ timeIndex ]; + Time nextTime = times[ timeIndex + 1 ]; + if ( currentTime >= nextTime ) + throw new Exception( + "Given times are not in strict ascending order" ); + } + public static void CheckStrictlyAscending( List< Time > times ) + { + for ( int i = 0 ; i < times.Count - 1 ; i++ ) + Time.checkStrictlyAscending( times , i ); + } + #endregion CheckStrictlyAscending } } |
|
From: Glauco S. <gla...@us...> - 2008-12-10 19:41:47
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Strategies In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14536/b7_Scripts/WalkForwardTesting/PairsTrading/Strategies Modified Files: PairsTradingStrategy.cs Log Message: - a new method private DateTime getDateTimeToClosePositions() has been added Index: PairsTradingStrategy.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Strategies/PairsTradingStrategy.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PairsTradingStrategy.cs 20 Nov 2008 20:57:38 -0000 1.7 --- PairsTradingStrategy.cs 10 Dec 2008 19:41:36 -0000 1.8 *************** *** 148,151 **** --- 148,158 ---- #endregion getLastDateTimeToTestInefficiency + private DateTime getDateTimeToClosePositions() + { + DateTime dateTimeToClosePositions = + this.returnIntervals.LastInterval.End; + return dateTimeToClosePositions; + } + private WeightedPositions getPositionsToBeOpened_withAtLeastASecondPhaseInterval() { *************** *** 154,157 **** --- 161,166 ---- DateTime lastDateTimeToTestInefficiency = this.getLastDateTimeToTestInefficiency(); + DateTime dateTimeToClosePositions = + this.getDateTimeToClosePositions(); WeightedPositions positionsToBeOpened = this.outOfSampleChooser.GetPositionsToBeOpened( *************** *** 159,162 **** --- 168,172 ---- firstDateTimeToTestInefficiency , lastDateTimeToTestInefficiency , + dateTimeToClosePositions , // this.returnIntervals , this.historicalMarketValueProviderForChosingPositionsOutOfSample , |
|
From: Glauco S. <gla...@us...> - 2008-12-10 19:41:12
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14483/b7_Scripts/WalkForwardTesting/PairsTrading Modified Files: PairsTradingMain.cs Log Message: code duplication is now avoided, by using three private members: private Time firstTimeToTestInefficiency; private Time lastTimeToTestInefficiency; private Time timeToClosePositions; Index: PairsTradingMain.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/PairsTradingMain.cs,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** PairsTradingMain.cs 24 Nov 2008 21:04:33 -0000 1.23 --- PairsTradingMain.cs 10 Dec 2008 19:40:56 -0000 1.24 *************** *** 57,60 **** --- 57,63 ---- private Benchmark benchmark; private HistoricalMarketValueProvider historicalMarketValueProviderForInSample; + private Time firstTimeToTestInefficiency; + private Time lastTimeToTestInefficiency; + private Time timeToClosePositions; private HistoricalMarketValueProvider historicalMarketValueProviderForChosingPositionsOutOfSample; *************** *** 85,89 **** // definition for the Fitness Evaluator ! // IEquityEvaluator equityEvaluator = new SharpeRatio(); } --- 88,99 ---- // definition for the Fitness Evaluator ! // IEquityEvaluator equityEvaluator = new SharpeRatio(); ! } ! ! protected override void doThisBeforeAnythingElse() ! { ! this.firstTimeToTestInefficiency = new Time( 10 , 0 , 0 ); ! this.lastTimeToTestInefficiency = new Time( 14 , 0 , 0 ); ! this.timeToClosePositions = new Time( 15 , 50 , 0 ); } *************** *** 94,100 **** { List< Time > dailyTimes = new List< Time >(); ! dailyTimes.Add( new Time( 13 , 0 , 0 ) ); ! dailyTimes.Add( new Time( 14 , 0 , 0 ) ); ! dailyTimes.Add( new Time( 15 , 0 , 0 ) ); // dailyTimes.Add( new Time( // HistoricalEndOfDayTimer.GetOneHourAfterMarketClose( DateTime.Now ) ) ); --- 104,110 ---- { List< Time > dailyTimes = new List< Time >(); ! dailyTimes.Add( this.firstTimeToTestInefficiency ); ! dailyTimes.Add( this.lastTimeToTestInefficiency ); ! dailyTimes.Add( this.timeToClosePositions ); // dailyTimes.Add( new Time( // HistoricalEndOfDayTimer.GetOneHourAfterMarketClose( DateTime.Now ) ) ); *************** *** 155,159 **** int numberOfBestTestingPositionsToBeReturned = 50; // uncomment the following line for a faster script ! // numberOfBestTestingPositionsToBeReturned = 5; IDecoderForTestingPositions decoderForWeightedPositions = --- 165,169 ---- int numberOfBestTestingPositionsToBeReturned = 50; // uncomment the following line for a faster script ! numberOfBestTestingPositionsToBeReturned = 10; IDecoderForTestingPositions decoderForWeightedPositions = *************** *** 205,209 **** // 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 = *************** *** 242,248 **** 7 , inSampleDays , intervalsSelectorForInSample , ! new Time( 13 , 0 , 0 ) , ! new Time( 14 , 0 , 0 ) , ! new Time( 15 , 0 , 0 ) , eligiblesSelector , inSampleChooser , this.historicalMarketValueProviderForInSample , --- 252,258 ---- 7 , inSampleDays , intervalsSelectorForInSample , ! this.firstTimeToTestInefficiency , ! this.lastTimeToTestInefficiency , ! this.timeToClosePositions , eligiblesSelector , inSampleChooser , this.historicalMarketValueProviderForInSample , *************** *** 276,282 **** // uncomment the following two lines for a faster script firstDateTime = new DateTime( 2006 , 2 , 1 ); ! lastDateTime = new DateTime( 2006 , 2 , 12 ); ! double maxRunningHours = 1; EndOfDayStrategyBackTester endOfDayStrategyBackTester = --- 286,292 ---- // uncomment the following two lines for a faster script firstDateTime = new DateTime( 2006 , 2 , 1 ); ! lastDateTime = new DateTime( 2007 , 12 , 31 ); ! double maxRunningHours = 5; EndOfDayStrategyBackTester endOfDayStrategyBackTester = *************** *** 302,306 **** protected override string getCustomSmallTextForFolderName() { ! return "pairsTrdngIntrdy_13_14_15"; } --- 312,319 ---- protected override string getCustomSmallTextForFolderName() { ! return "pairsTrdngIntrdy_" + ! this.firstTimeToTestInefficiency.Hour + "_" + ! this.lastTimeToTestInefficiency.Hour + "_" + ! this.timeToClosePositions.Hour; } |
|
From: Glauco S. <gla...@us...> - 2008-12-10 19:40:05
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Strategies In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14383/b7_Scripts/WalkForwardTesting/PairsTrading/Strategies Modified Files: PairsTradingIntradayStrategy.cs Log Message: - parameters checking has been added - a new method private DateTime getDateTimeToClosePositions() has been added Index: PairsTradingIntradayStrategy.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Strategies/PairsTradingIntradayStrategy.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PairsTradingIntradayStrategy.cs 20 Nov 2008 20:57:53 -0000 1.2 --- PairsTradingIntradayStrategy.cs 10 Dec 2008 19:39:53 -0000 1.3 *************** *** 69,72 **** --- 69,76 ---- historicalMarketValueProviderForInSample ) { + this.checkParameters( + firstTimeToTestInefficiency , + lastTimeToTestInefficiency , + timeToClosePositions ); this.firstTimeToTestInefficiency = firstTimeToTestInefficiency; this.lastTimeToTestInefficiency = lastTimeToTestInefficiency; *************** *** 77,80 **** --- 81,97 ---- } + private void checkParameters( + Time firstTimeToTestInefficiency , + Time lastTimeToTestInefficiency , + Time timeToClosePositions ) + { + if ( firstTimeToTestInefficiency >= lastTimeToTestInefficiency ) + throw new Exception( + "firstTimeToTestInefficiency must come before lastTimeToTestInefficiency" ); + if ( lastTimeToTestInefficiency >= timeToClosePositions ) + throw new Exception( + "lastTimeToTestInefficiency must come before timeToClosePositions" ); + } + protected override string getTextIdentifier() { *************** *** 112,135 **** #region getPositionsToBeOpened ! private DateTime getFirstDateTimeToTestInefficiency() { DateTime now = this.now(); ! DateTime firstDateTimeToTestInefficiency = new DateTime( now.Year , now.Month , now.Day , ! this.firstTimeToTestInefficiency.Hour , ! this.firstTimeToTestInefficiency.Minute , ! this.firstTimeToTestInefficiency.Second ); return firstDateTimeToTestInefficiency; } private DateTime getLastDateTimeToTestInefficiency() { ! DateTime now = this.now(); ! DateTime lastDateTimeToTestInefficiency = new DateTime( ! now.Year , now.Month , now.Day , ! this.lastTimeToTestInefficiency.Hour , ! this.lastTimeToTestInefficiency.Minute , ! this.lastTimeToTestInefficiency.Second ); return lastDateTimeToTestInefficiency; } protected override WeightedPositions getPositionsToBeOpened() { --- 129,170 ---- #region getPositionsToBeOpened ! private DateTime getDateTimeForCurrentDate( Time time ) { DateTime now = this.now(); ! DateTime dateTimeForCurrentDate = new DateTime( now.Year , now.Month , now.Day , ! time.Hour , time.Minute , time.Second ); ! return dateTimeForCurrentDate; ! } ! private DateTime getFirstDateTimeToTestInefficiency() ! { ! // DateTime now = this.now(); ! // DateTime firstDateTimeToTestInefficiency = new DateTime( ! // now.Year , now.Month , now.Day , ! // this.firstTimeToTestInefficiency.Hour , ! // this.firstTimeToTestInefficiency.Minute , ! // this.firstTimeToTestInefficiency.Second ); ! DateTime firstDateTimeToTestInefficiency = ! this.getDateTimeForCurrentDate( this.firstTimeToTestInefficiency ); return firstDateTimeToTestInefficiency; } private DateTime getLastDateTimeToTestInefficiency() { ! // DateTime now = this.now(); ! // DateTime lastDateTimeToTestInefficiency = new DateTime( ! // now.Year , now.Month , now.Day , ! // this.lastTimeToTestInefficiency.Hour , ! // this.lastTimeToTestInefficiency.Minute , ! // this.lastTimeToTestInefficiency.Second ); ! DateTime lastDateTimeToTestInefficiency = ! this.getDateTimeForCurrentDate( this.lastTimeToTestInefficiency ); return lastDateTimeToTestInefficiency; } + private DateTime getDateTimeToClosePositions() + { + DateTime dateTimeToClosePositions = + this.getDateTimeForCurrentDate( this.timeToClosePositions ); + return dateTimeToClosePositions; + } protected override WeightedPositions getPositionsToBeOpened() { *************** *** 138,141 **** --- 173,181 ---- DateTime lastDateTimeToTestInefficiency = this.getLastDateTimeToTestInefficiency(); + // attention! we are looking in the future here, but we do it + // just to avoid picking a ticker for which we don't have + // the market value when we will close the positions + DateTime dateTimeToClosePositions = + this.getDateTimeToClosePositions(); WeightedPositions weightedPositions = this.outOfSampleChooser.GetPositionsToBeOpened( *************** *** 143,146 **** --- 183,187 ---- firstDateTimeToTestInefficiency , lastDateTimeToTestInefficiency , + dateTimeToClosePositions , this.historicalMarketValueProviderForChosingPositionsOutOfSample , this.inSampleReturnsManager ); |
|
From: Glauco S. <gla...@us...> - 2008-12-10 19:38:55
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/OutOfSampleChoosers In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14317/b7_Scripts/WalkForwardTesting/PairsTrading/OutOfSampleChoosers Modified Files: OutOfSampleChooser.cs Log Message: the new revision choses positions only if market value are available to later close the positions. attention! we are looking in the future here, but we do it just to avoid picking a ticker for which we don't have the market value when we will close the positions Index: OutOfSampleChooser.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/OutOfSampleChoosers/OutOfSampleChooser.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** OutOfSampleChooser.cs 18 Nov 2008 23:03:15 -0000 1.4 --- OutOfSampleChooser.cs 10 Dec 2008 19:38:43 -0000 1.5 *************** *** 75,79 **** private void checkParameters( DateTime firstDateTimeToTestInefficiency , ! DateTime lastDateTimeToTestInefficiency ) { if ( firstDateTimeToTestInefficiency >= lastDateTimeToTestInefficiency ) --- 75,80 ---- private void checkParameters( DateTime firstDateTimeToTestInefficiency , ! DateTime lastDateTimeToTestInefficiency , ! DateTime dateTimeToClosePositions ) { if ( firstDateTimeToTestInefficiency >= lastDateTimeToTestInefficiency ) *************** *** 81,84 **** --- 82,89 ---- "The first date time to test inefficiency must be strictly before " + "the last date time to test inefficiency." ); + if ( lastDateTimeToTestInefficiency >= dateTimeToClosePositions ) + throw new Exception( + "The last date time to test inefficiency must be strictly before " + + "the date time to close positions." ); } *************** *** 165,170 **** } #endregion getReturnsManagerForLastSecondPhaseInterval ! #region getInefficientCouples #region addPositionsIfInefficiencyForCurrentCoupleIsInTheRange --- 170,213 ---- } #endregion getReturnsManagerForLastSecondPhaseInterval ! #region getInefficientCouples + + #region areAllNeededMarketValuesAvailableForTheCurrentCouple + private bool areAllNeededMarketValuesAvailableForTheCurrentCouple( + TestingPositions currentCouple , + DateTime dateTimeToClosePositions , + HistoricalMarketValueProvider + historicalMarketValueProviderForChosingPositionsOutOfSample ) + { + bool areAllAvailable = true; + foreach ( WeightedPosition weightedPosition in + currentCouple.WeightedPositions.Values ) + areAllAvailable = + ( + areAllAvailable && + // attention! we are looking in the future here, but we do it + // just to avoid picking a ticker for which we don't have + // the market value when we will close the positions + historicalMarketValueProviderForChosingPositionsOutOfSample.WasExchanged( + weightedPosition.Ticker , dateTimeToClosePositions ) + ); + return areAllAvailable; + } + private bool areAllNeededMarketValuesAvailableForTheCurrentCouple( + TestingPositions[] bestTestingPositionsInSample , + int currentTestingPositionsIndex , + DateTime dateTimeToClosePositions , + HistoricalMarketValueProvider + historicalMarketValueProviderForChosingPositionsOutOfSample ) + { + TestingPositions currentCouple = + bestTestingPositionsInSample[ currentTestingPositionsIndex ]; + bool areAllAvailable = + this.areAllNeededMarketValuesAvailableForTheCurrentCouple( + currentCouple , dateTimeToClosePositions , + historicalMarketValueProviderForChosingPositionsOutOfSample ); + return areAllAvailable; + } + #endregion areAllNeededMarketValuesAvailableForTheCurrentCouple #region addPositionsIfInefficiencyForCurrentCoupleIsInTheRange *************** *** 217,230 **** currentWeightedPositions ); if ( ( returnForTheLastSecondPhaseInterval >= ! this.minThresholdForGoingLong ) && ( returnForTheLastSecondPhaseInterval <= ! this.maxThresholdForGoingLong ) ) // it looks like there has been an inefficiency that // might be recovered, by going short weightedPositionsToBeOpened = currentWeightedPositions.Opposite; if ( ( -returnForTheLastSecondPhaseInterval >= ! this.minThresholdForGoingShort ) && ( -returnForTheLastSecondPhaseInterval <= ! this.maxThresholdForGoingShort ) ) // it looks like there has been an inefficiency that // might be recovered, by going long --- 260,273 ---- currentWeightedPositions ); if ( ( returnForTheLastSecondPhaseInterval >= ! this.minThresholdForGoingShort ) && ( returnForTheLastSecondPhaseInterval <= ! this.maxThresholdForGoingShort ) ) // it looks like there has been an inefficiency that // might be recovered, by going short weightedPositionsToBeOpened = currentWeightedPositions.Opposite; if ( ( -returnForTheLastSecondPhaseInterval >= ! this.minThresholdForGoingLong ) && ( -returnForTheLastSecondPhaseInterval <= ! this.maxThresholdForGoingLong ) ) // it looks like there has been an inefficiency that // might be recovered, by going long *************** *** 261,265 **** protected ArrayList getInefficientCouples( TestingPositions[] bestTestingPositionsInSample , ! ReturnsManager returnsManagerForLastSecondPhaseInterval ) { ArrayList inefficientCouples = new ArrayList(); --- 304,311 ---- protected ArrayList getInefficientCouples( TestingPositions[] bestTestingPositionsInSample , ! ReturnsManager returnsManagerForLastSecondPhaseInterval , ! DateTime dateTimeToClosePositions , ! HistoricalMarketValueProvider ! historicalMarketValueProviderForChosingPositionsOutOfSample ) { ArrayList inefficientCouples = new ArrayList(); *************** *** 267,275 **** currentTestingPositionsIndex < bestTestingPositionsInSample.Length ; currentTestingPositionsIndex++ ) ! this.addPositionsIfInefficiencyForCurrentCoupleIsInTheRange( bestTestingPositionsInSample , - returnsManagerForLastSecondPhaseInterval , currentTestingPositionsIndex , ! inefficientCouples ); return inefficientCouples; } --- 313,328 ---- currentTestingPositionsIndex < bestTestingPositionsInSample.Length ; currentTestingPositionsIndex++ ) ! { ! if ( this.areAllNeededMarketValuesAvailableForTheCurrentCouple( bestTestingPositionsInSample , currentTestingPositionsIndex , ! dateTimeToClosePositions , ! historicalMarketValueProviderForChosingPositionsOutOfSample ) ) ! this.addPositionsIfInefficiencyForCurrentCoupleIsInTheRange( ! bestTestingPositionsInSample , ! returnsManagerForLastSecondPhaseInterval , ! currentTestingPositionsIndex , ! inefficientCouples ); ! } return inefficientCouples; } *************** *** 281,284 **** --- 334,338 ---- DateTime firstDateTimeToTestInefficiency , DateTime lastDateTimeToTestInefficiency , + DateTime dateTimeToClosePositions , // ReturnIntervals outOfSampleReturnIntervals , HistoricalMarketValueProvider *************** *** 292,297 **** historicalMarketValueProviderForChosingPositionsOutOfSample ); ArrayList inefficientCouples = ! this.getInefficientCouples( bestTestingPositionsInSample , ! returnsManagerForLastSecondPhaseInterval ); return inefficientCouples; } --- 346,354 ---- historicalMarketValueProviderForChosingPositionsOutOfSample ); ArrayList inefficientCouples = ! this.getInefficientCouples( ! bestTestingPositionsInSample , ! returnsManagerForLastSecondPhaseInterval , ! dateTimeToClosePositions , ! historicalMarketValueProviderForChosingPositionsOutOfSample ); return inefficientCouples; } *************** *** 327,330 **** --- 384,388 ---- DateTime firstDateTimeToTestInefficiency , DateTime lastDateTimeToTestInefficiency , + DateTime dateTimeToClosePositions , // ReturnIntervals outOfSampleReturnIntervals , HistoricalMarketValueProvider *************** *** 336,339 **** --- 394,398 ---- firstDateTimeToTestInefficiency , lastDateTimeToTestInefficiency , + dateTimeToClosePositions , // outOfSampleReturnIntervals , historicalMarketValueProviderForChosingPositionsOutOfSample ); *************** *** 346,349 **** --- 405,409 ---- DateTime firstDateTimeToTestInefficiency , DateTime lastDateTimeToTestInefficiency , + DateTime dateTimeToClosePositions , // ReturnIntervals outOfSampleReturnIntervals , HistoricalMarketValueProvider *************** *** 358,361 **** --- 418,422 ---- firstDateTimeToTestInefficiency , lastDateTimeToTestInefficiency , + dateTimeToClosePositions , // outOfSampleReturnIntervals , historicalMarketValueProviderForChosingPositionsOutOfSample ); *************** *** 369,372 **** --- 430,434 ---- DateTime firstDateTimeToTestInefficiency , DateTime lastDateTimeToTestInefficiency , + DateTime dateTimeToClosePositions , // ReturnIntervals outOfSampleReturnIntervals , HistoricalMarketValueProvider *************** *** 380,383 **** --- 442,446 ---- firstDateTimeToTestInefficiency , lastDateTimeToTestInefficiency , + dateTimeToClosePositions , // outOfSampleReturnIntervals , historicalMarketValueProviderForChosingPositionsOutOfSample ); *************** *** 394,401 **** /// Selects the WeghtedPositions to actually be opened /// </summary> ! /// <param name="bestTestingPositionsInSample">most correlated couples, ! /// in sample</param> ! /// <param name="minThreshold">min requested inefficiency</param> ! /// <param name="maxThreshold">max allowed inefficiency</param> /// <param name="inSampleReturnsManager"></param> /// <returns></returns> --- 457,465 ---- /// Selects the WeghtedPositions to actually be opened /// </summary> ! /// <param name="bestTestingPositionsInSample"></param> ! /// <param name="firstDateTimeToTestInefficiency"></param> ! /// <param name="lastDateTimeToTestInefficiency"></param> ! /// <param name="timeToClosePositins"></param> ! /// <param name="historicalMarketValueProviderForChosingPositionsOutOfSample"></param> /// <param name="inSampleReturnsManager"></param> /// <returns></returns> *************** *** 404,407 **** --- 468,472 ---- DateTime firstDateTimeToTestInefficiency , DateTime lastDateTimeToTestInefficiency , + DateTime dateTimeToClosePositions , // ReturnIntervals outOfSampleReturnIntervals , HistoricalMarketValueProvider *************** *** 410,414 **** { this.checkParameters( ! firstDateTimeToTestInefficiency , lastDateTimeToTestInefficiency ); WeightedPositions positionsToBeOpened = this.getPositionsToBeOpened_actually( --- 475,481 ---- { this.checkParameters( ! firstDateTimeToTestInefficiency , ! lastDateTimeToTestInefficiency , ! dateTimeToClosePositions ); WeightedPositions positionsToBeOpened = this.getPositionsToBeOpened_actually( *************** *** 416,419 **** --- 483,487 ---- firstDateTimeToTestInefficiency , lastDateTimeToTestInefficiency , + dateTimeToClosePositions , historicalMarketValueProviderForChosingPositionsOutOfSample , inSampleReturnsManager ); |