quantproject-developers Mailing List for QuantProject (Page 139)
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: Marco M. <mi...@us...> - 2004-04-25 17:33:53
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataTables In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7953/b3_Data/DataTables Added Files: TickerDataTable.cs Log Message: TickerDataTable moved to the new DataTables folder in the Data layer --- NEW FILE: TickerDataTable.cs --- /* QuantDownloader - Quantitative Finance Library TickerDataTable.cs Copyright (C) 2003 Marco Milletti 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 QuantProject.DataAccess.Tables; namespace QuantProject.Data.DataTables { /// <summary> /// The DataTable where to store tickers. /// It has the same structure of DB's table /// </summary> public class TickerDataTable : DataTable { private static TickerDataTable clipboard; public static TickerDataTable Clipboard { get{ return TickerDataTable.clipboard; } set{ TickerDataTable.clipboard = value; } } public TickerDataTable() { this.setStructure(); } private void setStructure() { DataColumn ticker = new DataColumn(Tickers.Ticker, System.Type.GetType("System.String")); ticker.Unique = true; ticker.AllowDBNull = false; DataColumn companyName = new DataColumn(Tickers.CompanyName, System.Type.GetType("System.String")); this.Columns.Add(ticker); this.Columns.Add(companyName); } public static TickerDataTable ConvertToTickerDataTable(DataTable dataTableToConvert) { TickerDataTable tickerDataTable = new TickerDataTable(); DataRow rowToAdd; try { foreach(DataRow row in dataTableToConvert.Rows) { rowToAdd = tickerDataTable.NewRow(); rowToAdd[Tickers.Ticker] = row[Tickers.Ticker]; rowToAdd[Tickers.CompanyName] = row[Tickers.CompanyName]; tickerDataTable.Rows.Add(rowToAdd); } } catch(Exception ex) { string notUsed = ex.ToString(); } return tickerDataTable; } } } |
|
From: Marco M. <mi...@us...> - 2004-04-25 17:33:08
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/Selectors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8841/b3_Data/Selectors Added Files: SelectionRule.cs SelectionType.cs TickerSelector.cs Log Message: Added new classes TickerSelector with the subsidiary SelectionRule class, for advanced selection of tickers (types of selections are in the SelectionType enumeration) --- NEW FILE: SelectionRule.cs --- /* QuantProject - Quantitative Finance Library SelectionRule.cs Copyright (C) 2003 Marco Milletti 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; namespace QuantProject.Data.Selectors { /// <summary> /// Selection rule used by the TickerSelector /// </summary> /// <remarks> /// Selection process is based on quotes /// </remarks> public class SelectionRule { private SelectionType typeOfSelection; private string groupID = ""; private DateTime firstQuoteDate = QuantProject.ADT.ConstantsProvider.InitialDateTimeForDownload; private DateTime lastQuoteDate = DateTime.Now; private long maxNumOfReturnedTickers = 0; /// <summary> /// SelectionRule constructor /// </summary> /// <param name="typeOfSelection">Type of selection rule to be applied</param> /// <param name="groupID">GroupID to which ticker to be selected has to belong</param> /// <param name="firstQuoteDate">First date of selection for the quotes</param> /// <param name="lastQuoteDate">Last date of selection for the quotes</param> /// <param name="maxNumOfReturnedTickers">Max number of tickers to be returned</param> public SelectionRule(SelectionType typeOfSelection, string groupID, DateTime firstQuoteDate, DateTime lastQuoteDate, long maxNumOfReturnedTickers) { this.typeOfSelection = typeOfSelection; this.groupID = groupID; this.firstQuoteDate = firstQuoteDate; this.lastQuoteDate = lastQuoteDate; this.maxNumOfReturnedTickers = maxNumOfReturnedTickers; } /// <summary> /// GroupID from which tickers have to be selected /// </summary> public string GroupID { get{return this.groupID;} } /// <summary> /// First date of selection for the quotes /// </summary> public DateTime FirstQuoteDate { get{return this.firstQuoteDate;} } /// <summary> /// Last date of selection for the quotes /// </summary> public DateTime LastQuoteDate { get{return this.lastQuoteDate;} } /// <summary> /// Max number of tickers to be returned /// </summary> public long MaxNumOfReturnedTickers { get{return this.maxNumOfReturnedTickers;} } /// <summary> /// Type of selection provided by the rule /// </summary> public SelectionType TypeOfSelection { get{return this.typeOfSelection;} } } } --- NEW FILE: SelectionType.cs --- /* QuantProject - Quantitative Finance Library SelectionType.cs Copyright (C) 2004 Marco Milletti 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.Data.Selectors { /// <summary> /// Enum for SelectionRule class /// </summary> public enum SelectionType { MostLiquid/*, LessVolatile, BestPerformer, LessStatisticallyCorrelated*/ } } --- NEW FILE: TickerSelector.cs --- /* QuantProject - Quantitative Finance Library TickerSelector.cs Copyright (C) 2003 Marco Milletti 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 QuantProject.DataAccess.Tables; using QuantProject.Data.DataTables; namespace QuantProject.Data.Selectors { /// <summary> /// Class for advanced selections on tickers /// </summary> /// <remarks> /// Filter/selection results depend on the SelectionRule used for the instanciation /// of a new TickerSelector /// </remarks> public class TickerSelector : ITickerSelector { private SelectionRule selectionRule; public TickerSelector(SelectionRule selectionRule) { this.selectionRule = selectionRule; } public DataTable GetSelectedTickers() { //TODO: implement switching code to the proper method of selection return Quotes.GetMostLiquidTickers(this.selectionRule.GroupID, this.selectionRule.FirstQuoteDate, this.selectionRule.LastQuoteDate, this.selectionRule.MaxNumOfReturnedTickers); } //implementation of ITickerSelector public TickerDataTable GetTableOfSelectedTickers() { return TickerDataTable.ConvertToTickerDataTable(this.GetSelectedTickers()); } public void SelectAllTickers() { ; } // end of implementation of ITickerSelector } } |
|
From: Marco M. <mi...@us...> - 2004-04-25 17:29:21
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/TickerSelectors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7483/Downloader/TickerSelectors Removed Files: ITickerReceiver.cs ITickerSelector.cs Log Message: ITickerSelector and ITickerReceiver interfaces moved to the Selectors folder in the Data layer --- ITickerReceiver.cs DELETED --- --- ITickerSelector.cs DELETED --- |
|
From: Marco M. <mi...@us...> - 2004-04-25 17:23:01
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/Selectors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5671/Selectors Log Message: Directory /cvsroot/quantproject/QuantProject/b3_Data/Selectors added to the repository |
|
From: Glauco S. <gla...@us...> - 2004-04-21 12:08:28
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10524/b2_DataAccess Modified Files: b2_DataAccess.csproj Log Message: The ValidatedTickers class has been added Index: b2_DataAccess.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/b2_DataAccess.csproj,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** b2_DataAccess.csproj 17 Apr 2004 14:02:09 -0000 1.7 --- b2_DataAccess.csproj 21 Apr 2004 12:07:52 -0000 1.8 *************** *** 138,141 **** --- 138,146 ---- /> <File + RelPath = "Tables\ValidatedTickers.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Tables\TickerDataTable.cs" SubType = "Component" |
|
From: Glauco S. <gla...@us...> - 2004-04-21 12:05:33
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/Validate/Validators In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9917/Downloader/Validate/Validators Modified Files: MultiValidator.cs Log Message: A new Validate method has been defined (not implemented yet) Index: MultiValidator.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/Validate/Validators/MultiValidator.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MultiValidator.cs 24 Mar 2004 18:26:39 -0000 1.2 --- MultiValidator.cs 21 Apr 2004 12:04:56 -0000 1.3 *************** *** 78,81 **** --- 78,89 ---- this.validate_RangeToRange( dataTable ); } + /// <summary> + /// Validates the instrument quotes for the given ticker + /// </summary> + /// <param name="ticker">Instrument's ticker</param> + public void Validate( string ticker ) + { + + } } #endregion |
|
From: Glauco S. <gla...@us...> - 2004-04-21 12:01:42
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9316/b2_DataAccess Modified Files: DataBaseVersionManager.cs Log Message: The vtHashValue field has been added to the ValidatedTickers table Index: DataBaseVersionManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/DataBaseVersionManager.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** DataBaseVersionManager.cs 28 Mar 2004 20:03:57 -0000 1.10 --- DataBaseVersionManager.cs 21 Apr 2004 12:00:55 -0000 1.11 *************** *** 113,117 **** // been validated. The quotes are meant to be ok from vtStartDate to vtEndDate. this.executeCommand( "CREATE TABLE validatedTickers " + ! "( vtTicker TEXT(8) , vtStartDate DATETIME , vtEndDate DATETIME , vtEditDate DATETIME, " + "CONSTRAINT myKey PRIMARY KEY ( vtTicker ) )" ); // visuallyValidatedQuotes will contain a record for each --- 113,118 ---- // been validated. The quotes are meant to be ok from vtStartDate to vtEndDate. this.executeCommand( "CREATE TABLE validatedTickers " + ! "( vtTicker TEXT(8) , vtStartDate DATETIME , vtEndDate DATETIME , " + ! "vtHashValue TEXT(50) , vtEditDate DATETIME, " + "CONSTRAINT myKey PRIMARY KEY ( vtTicker ) )" ); // visuallyValidatedQuotes will contain a record for each |
|
From: Glauco S. <gla...@us...> - 2004-04-21 11:58:45
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8852/b2_DataAccess/Tables Added Files: ValidatedTickers.cs Log Message: Class to access the ValidatedTickers table --- NEW FILE: ValidatedTickers.cs --- using System; using System.Data; namespace QuantProject.DataAccess.Tables { /// <summary> /// Class to access the ValidatedTickers table. /// </summary> public class ValidatedTickers { public ValidatedTickers() { // // TODO: Add constructor logic here // } public static string Ticker = "vtTicker"; public static string StartDate = "vtStartDate"; public static string EndDate = "vtEndDate"; public static string HashValue = "vtHashValue"; public static string EditDate = "vtEditDate"; /// <summary> /// Returns the hash value for the given instrument /// </summary> /// <param name="ticker">Instrument's ticker</param> /// <param name="startDate">Starting instrument quote's date, for hash value computation</param> /// <param name="endDate">Ending instrument quote's date, for hash value computation</param> /// <returns></returns> private static string getHashValue( string ticker , DateTime startDate , DateTime endDate ) { Quotes quotes = new Quotes( ticker ); return quotes.GetHashValue( startDate , endDate ); } /// <summary> /// Checks if the instrument is valid (since the first date to the last date in the quotes table) /// </summary> /// <param name="ticker">Instrument's ticker</param> /// <returns></returns> public static bool IsValid( string ticker ) { DataTable validatedTicker = SqlExecutor.GetDataTable( "select * from validatedTickers where vvTicker='" + ticker + "'" ); return ( ( validatedTicker.Rows.Count > 0 ) && ( (string)validatedTicker.Rows[ 0 ][ ValidatedTickers.HashValue ] == getHashValue( ticker , (DateTime)validatedTicker.Rows[ 0 ][ ValidatedTickers.StartDate ] , (DateTime)validatedTicker.Rows[ 0 ][ ValidatedTickers.EndDate ] ) ) ); } } } |
|
From: Marco M. <mi...@us...> - 2004-04-17 14:16:38
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5867/Downloader Modified Files: DataBaseImporter.cs Downloader.csproj Main.cs Log Message: Modified DataBase importer Index: Main.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/Main.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Main.cs 21 Mar 2004 16:39:58 -0000 1.7 --- Main.cs 17 Apr 2004 14:16:29 -0000 1.8 *************** *** 4,7 **** --- 4,8 ---- using System.ComponentModel; using System.Windows.Forms; + using QuantProject.Applications.Downloader.TickerSelectors; namespace QuantProject.Applications.Downloader Index: DataBaseImporter.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/DataBaseImporter.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DataBaseImporter.cs 21 Mar 2004 19:46:51 -0000 1.5 --- DataBaseImporter.cs 17 Apr 2004 14:16:29 -0000 1.6 *************** *** 3,6 **** --- 3,7 ---- using System.Data.OleDb; using System.IO; + using QuantProject.DataAccess.Tables; namespace QuantProject.Applications.Downloader *************** *** 40,43 **** --- 41,45 ---- } } + /* private void deleteExistingQuote(string tickerToDelete, DateTime dateOfQuoteToDelete) { *************** *** 46,63 **** if(this.overWriteExistingRecords == false) return; ! this.oleDbDataAdapter.DeleteCommand = new OleDbCommand("DELETE * FROM quotes " + ! "WHERE quTicker ='" + ! tickerToDelete + "' AND " + ! "quDate =#" + ! dateOfQuoteToDelete + "#"); ! this.oleDbDataAdapter.DeleteCommand.ExecuteNonQuery(); } catch(Exception ex) { - // no consequences if there are some lines that are not inserted (due to key violation) string notUsed = ex.ToString(); } } ! public void ImportTicker( string ticker ) --- 48,64 ---- if(this.overWriteExistingRecords == false) return; ! //this.oleDbDataAdapter.DeleteCommand = new OleDbCommand("DELETE * FROM quotes " + ! // "WHERE quTicker ='" + ! // tickerToDelete + "' AND " + ! // "quDate =#" + ! // dateOfQuoteToDelete + "#"); ! //this.oleDbDataAdapter.DeleteCommand.ExecuteNonQuery(); } catch(Exception ex) { string notUsed = ex.ToString(); } } ! */ public void ImportTicker( string ticker ) *************** *** 66,70 **** string[] LineIn; ! string strAccessSelect = "Select * from quotes where 1=2"; OleDbCommand myAccessCommand = new OleDbCommand( strAccessSelect , oleDbConnection ); --- 67,71 ---- string[] LineIn; ! /* string strAccessSelect = "Select * from quotes where 1=2"; OleDbCommand myAccessCommand = new OleDbCommand( strAccessSelect , oleDbConnection ); *************** *** 77,90 **** myDataAdapter.MissingSchemaAction = MissingSchemaAction.Add; myDataAdapter.MissingMappingAction = MissingMappingAction.Passthrough; ! myDataAdapter.Fill( myDataSet , "Data" ); Line = streamReader.ReadLine(); Line = streamReader.ReadLine(); ! while ( Line != null ) { LineIn=Line.Split(','); ! DataRow myRow=myDataSet.Tables["Data"].NewRow(); myRow[ "quTicker" ] = ticker; --- 78,91 ---- myDataAdapter.MissingSchemaAction = MissingSchemaAction.Add; myDataAdapter.MissingMappingAction = MissingMappingAction.Passthrough; ! myDataAdapter.Fill( myDataSet , "Data" );*/ Line = streamReader.ReadLine(); Line = streamReader.ReadLine(); ! while ( Line != null && ! Line.StartsWith("<")) { LineIn=Line.Split(','); ! /*DataRow myRow=myDataSet.Tables["Data"].NewRow(); myRow[ "quTicker" ] = ticker; *************** *** 96,131 **** myRow[ "quVolume" ]=Double.Parse( LineIn[5] ); myRow[ "quAdjustedClose" ]=Double.Parse( LineIn[6] ); - //myRow[ "quAdjustedOpen" ]=Convert.ToDouble(myRow[ "quOpen" ])* - // (Convert.ToDouble(myRow[ "quAdjustedClose" ])/Convert.ToDouble(myRow[ "quOpen" ])); - - // myRow["date"]=DateTime.Parse(LineIn[0]); - // myRow["time"]=DateTime.Parse(LineIn[1]); - // myRow["sv1485ri"]=Double.Parse(LineIn[2]); - // myRow["sv14856s"]=Double.Parse(LineIn[3]); - // myRow["d4461"]=Double.Parse(LineIn[4]); - // myRow["d6sf"]=Double.Parse(LineIn[5]); - // myRow["d6sdp"]=Double.Parse(LineIn[6]); - // myRow["oppai"]=Double.Parse(LineIn[7]); - // myRow["oppbi"]=Double.Parse(LineIn[8]); - // myRow["opps"]=Double.Parse(LineIn[9]); - // myRow["o24hrtf"]=Double.Parse(LineIn[10]); - // myRow["oif"]=Double.Parse(LineIn[11]); - // myRow["otct"]=Double.Parse(LineIn[12]); - // myRow["d1abt"]=Double.Parse(LineIn[13]); - // myRow["d1bbt"]=Double.Parse(LineIn[14]); - // myRow["d3bt"]=Double.Parse(LineIn[15]); - // myRow["d2bt"]=Double.Parse(LineIn[16]); - // myRow["d5bt"]=Double.Parse(LineIn[17]); - // myRow["d6bt"]=Double.Parse(LineIn[18]); - // myRow["cv1480cvpi"]=Double.Parse(LineIn[19]); - // myRow["cv1481cvpi"]=Double.Parse(LineIn[20]); ! myDataSet.Tables["Data"].Rows.Add(myRow); ! this.deleteExistingQuote(ticker, DateTime.Parse(LineIn[0])); //the corresponding record is deleted if in the web downloader form // the radio button "over Write existing record" is checked ! Line = this.streamReader.ReadLine(); } ! this.updateDataBase(myDataAdapter, myDataSet,"Data"); } --- 97,113 ---- myRow[ "quVolume" ]=Double.Parse( LineIn[5] ); myRow[ "quAdjustedClose" ]=Double.Parse( LineIn[6] ); ! myDataSet.Tables["Data"].Rows.Add(myRow);*/ ! //the corresponding record is deleted if in the web downloader form // the radio button "over Write existing record" is checked ! if(this.overWriteExistingRecords) ! Quotes.Delete(ticker, DateTime.Parse( LineIn[0] )); ! Quotes.Add(ticker,DateTime.Parse( LineIn[0] ), Double.Parse( LineIn[1] ), ! Double.Parse(LineIn[2]), Double.Parse(LineIn[3]), Double.Parse(LineIn[4]), ! Double.Parse(LineIn[5]), Double.Parse(LineIn[6])); ! Line = this.streamReader.ReadLine(); } ! //this.updateDataBase(myDataAdapter, myDataSet,"Data"); } Index: Downloader.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/Downloader.csproj,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Downloader.csproj 28 Mar 2004 22:11:44 -0000 1.15 --- Downloader.csproj 17 Apr 2004 14:16:29 -0000 1.16 *************** *** 166,179 **** /> <File - RelPath = "GroupEditor.cs" - SubType = "Form" - BuildAction = "Compile" - /> - <File - RelPath = "GroupEditor.resx" - DependentUpon = "GroupEditor.cs" - BuildAction = "EmbeddedResource" - /> - <File RelPath = "Main.cs" SubType = "Form" --- 166,169 ---- *************** *** 206,229 **** /> <File - RelPath = "TickerGroupsViewer.cs" - SubType = "Form" - BuildAction = "Compile" - /> - <File - RelPath = "TickerGroupsViewer.resx" - DependentUpon = "TickerGroupsViewer.cs" - BuildAction = "EmbeddedResource" - /> - <File - RelPath = "TickerViewer.cs" - SubType = "Form" - BuildAction = "Compile" - /> - <File - RelPath = "TickerViewer.resx" - DependentUpon = "TickerViewer.cs" - BuildAction = "EmbeddedResource" - /> - <File RelPath = "WebDownloader.cs" SubType = "Form" --- 196,199 ---- *************** *** 351,354 **** --- 321,369 ---- /> <File + RelPath = "TickerSelectors\GroupEditor.cs" + SubType = "Form" + BuildAction = "Compile" + /> + <File + RelPath = "TickerSelectors\ITickerReceiver.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "TickerSelectors\ITickerSelector.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "TickerSelectors\TickerGroupsListViewMenu.cs" + SubType = "Component" + BuildAction = "Compile" + /> + <File + RelPath = "TickerSelectors\TickerGroupsListViewMenu.resx" + DependentUpon = "TickerGroupsListViewMenu.cs" + BuildAction = "EmbeddedResource" + /> + <File + RelPath = "TickerSelectors\TickerGroupsViewer.cs" + SubType = "Form" + BuildAction = "Compile" + /> + <File + RelPath = "TickerSelectors\TickerViewer.cs" + SubType = "Form" + BuildAction = "Compile" + /> + <File + RelPath = "TickerSelectors\TickerViewerMenu.cs" + SubType = "Component" + BuildAction = "Compile" + /> + <File + RelPath = "TickerSelectors\TickerViewerMenu.resx" + DependentUpon = "TickerViewerMenu.cs" + BuildAction = "EmbeddedResource" + /> + <File RelPath = "Validate\IValidator.cs" SubType = "Code" |
|
From: Marco M. <mi...@us...> - 2004-04-17 14:14:50
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5513/Downloader Modified Files: TickerDownloader.cs WebDownloader.cs Log Message: TickerDownloader now works with new options provided by a new web downloader form Index: WebDownloader.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/WebDownloader.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** WebDownloader.cs 21 Mar 2004 19:34:12 -0000 1.9 --- WebDownloader.cs 17 Apr 2004 14:14:41 -0000 1.10 *************** *** 10,13 **** --- 10,15 ---- using System.Threading; using QuantProject.DataAccess; + using QuantProject.DataAccess.Tables; + using QuantProject.Applications.Downloader.TickerSelectors; namespace QuantProject.Applications.Downloader *************** *** 16,20 **** /// Summary description for Form1. /// </summary> ! public class WebDownloader : System.Windows.Forms.Form { public OleDbConnection OleDbConnection1 = ConnectionProvider.OleDbConnection; --- 18,22 ---- /// Summary description for Form1. /// </summary> ! public class WebDownloader : System.Windows.Forms.Form, ITickerSelector { public OleDbConnection OleDbConnection1 = ConnectionProvider.OleDbConnection; *************** *** 43,46 **** --- 45,49 ---- internal System.Windows.Forms.CheckBox checkBoxIsDicotomicSearchActivated; private System.Windows.Forms.RadioButton radioButtonDownloadBeforeMinAndAfterMax; + private System.Windows.Forms.RadioButton radioButtonDownloadOnlyAfterMax; /// <summary> /// Required designer variable. *************** *** 102,109 **** private void commonInitialization() { ! this.radioButtonAllAvailableUntilNow.Checked = true; ! this.dateTimePickerStartingDate.Value = new DateTime(1980,1,1); //this.dateTimePickerStartingDate.Refresh(); ! this.radioButtonOverWriteNo.Checked = true; } --- 105,113 ---- private void commonInitialization() { ! this.dateTimePickerStartingDate.Value = QuantProject.ADT.ConstantsProvider.InitialDateTimeForDownload; //this.dateTimePickerStartingDate.Refresh(); ! this.radioButtonAllAvailableUntilNow.Checked = true; ! this.radioButtonDownloadOnlyAfterMax.Checked = true; ! this.dataGrid1.ContextMenu = new TickerViewerMenu(this); } *************** *** 134,137 **** --- 138,142 ---- this.checkBoxIsDicotomicSearchActivated = new System.Windows.Forms.CheckBox(); this.groupBoxUpdateDatabaseOptions = new System.Windows.Forms.GroupBox(); + this.radioButtonDownloadOnlyAfterMax = new System.Windows.Forms.RadioButton(); this.radioButtonDownloadBeforeMinAndAfterMax = new System.Windows.Forms.RadioButton(); this.radioButtonOverWriteNo = new System.Windows.Forms.RadioButton(); *************** *** 144,148 **** // button1 // ! this.button1.Location = new System.Drawing.Point(88, 320); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(112, 32); --- 149,153 ---- // button1 // ! this.button1.Location = new System.Drawing.Point(88, 352); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(112, 32); *************** *** 155,161 **** this.dataGrid1.DataMember = ""; this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText; ! this.dataGrid1.Location = new System.Drawing.Point(304, 8); this.dataGrid1.Name = "dataGrid1"; ! this.dataGrid1.Size = new System.Drawing.Size(272, 432); this.dataGrid1.TabIndex = 1; // --- 160,166 ---- this.dataGrid1.DataMember = ""; this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText; ! this.dataGrid1.Location = new System.Drawing.Point(328, 8); this.dataGrid1.Name = "dataGrid1"; ! this.dataGrid1.Size = new System.Drawing.Size(304, 456); this.dataGrid1.TabIndex = 1; // *************** *** 239,243 **** // buttonDownloadQuotesOfSelectedTickers // ! this.buttonDownloadQuotesOfSelectedTickers.Location = new System.Drawing.Point(88, 360); this.buttonDownloadQuotesOfSelectedTickers.Name = "buttonDownloadQuotesOfSelectedTickers"; this.buttonDownloadQuotesOfSelectedTickers.Size = new System.Drawing.Size(112, 32); --- 244,248 ---- // buttonDownloadQuotesOfSelectedTickers // ! this.buttonDownloadQuotesOfSelectedTickers.Location = new System.Drawing.Point(88, 392); this.buttonDownloadQuotesOfSelectedTickers.Name = "buttonDownloadQuotesOfSelectedTickers"; this.buttonDownloadQuotesOfSelectedTickers.Size = new System.Drawing.Size(112, 32); *************** *** 248,252 **** // labelNumberOfTickersToDownload // ! this.labelNumberOfTickersToDownload.Location = new System.Drawing.Point(152, 408); this.labelNumberOfTickersToDownload.Name = "labelNumberOfTickersToDownload"; this.labelNumberOfTickersToDownload.Size = new System.Drawing.Size(48, 24); --- 253,257 ---- // labelNumberOfTickersToDownload // ! this.labelNumberOfTickersToDownload.Location = new System.Drawing.Point(152, 440); this.labelNumberOfTickersToDownload.Name = "labelNumberOfTickersToDownload"; this.labelNumberOfTickersToDownload.Size = new System.Drawing.Size(48, 24); *************** *** 256,260 **** // labelTickersLeft // ! this.labelTickersLeft.Location = new System.Drawing.Point(8, 408); this.labelTickersLeft.Name = "labelTickersLeft"; this.labelTickersLeft.Size = new System.Drawing.Size(136, 24); --- 261,265 ---- // labelTickersLeft // ! this.labelTickersLeft.Location = new System.Drawing.Point(8, 440); this.labelTickersLeft.Name = "labelTickersLeft"; this.labelTickersLeft.Size = new System.Drawing.Size(136, 24); *************** *** 292,296 **** this.radioButtonAllAvailableUntilNowSinceStartingDate.Size = new System.Drawing.Size(272, 24); this.radioButtonAllAvailableUntilNowSinceStartingDate.TabIndex = 12; ! this.radioButtonAllAvailableUntilNowSinceStartingDate.Text = "Change starting date"; // // groupBoxWebDownloaderOptions --- 297,301 ---- this.radioButtonAllAvailableUntilNowSinceStartingDate.Size = new System.Drawing.Size(272, 24); this.radioButtonAllAvailableUntilNowSinceStartingDate.TabIndex = 12; ! this.radioButtonAllAvailableUntilNowSinceStartingDate.Text = "All available quotes until now, changing starting date"; // // groupBoxWebDownloaderOptions *************** *** 301,305 **** this.groupBoxWebDownloaderOptions.Location = new System.Drawing.Point(8, 8); this.groupBoxWebDownloaderOptions.Name = "groupBoxWebDownloaderOptions"; ! this.groupBoxWebDownloaderOptions.Size = new System.Drawing.Size(288, 88); this.groupBoxWebDownloaderOptions.TabIndex = 13; this.groupBoxWebDownloaderOptions.TabStop = false; --- 306,310 ---- this.groupBoxWebDownloaderOptions.Location = new System.Drawing.Point(8, 8); this.groupBoxWebDownloaderOptions.Name = "groupBoxWebDownloaderOptions"; ! this.groupBoxWebDownloaderOptions.Size = new System.Drawing.Size(312, 88); this.groupBoxWebDownloaderOptions.TabIndex = 13; this.groupBoxWebDownloaderOptions.TabStop = false; *************** *** 310,314 **** this.checkBoxIsDicotomicSearchActivated.Checked = true; this.checkBoxIsDicotomicSearchActivated.CheckState = System.Windows.Forms.CheckState.Checked; ! this.checkBoxIsDicotomicSearchActivated.Location = new System.Drawing.Point(16, 288); this.checkBoxIsDicotomicSearchActivated.Name = "checkBoxIsDicotomicSearchActivated"; this.checkBoxIsDicotomicSearchActivated.Size = new System.Drawing.Size(272, 24); --- 315,319 ---- this.checkBoxIsDicotomicSearchActivated.Checked = true; this.checkBoxIsDicotomicSearchActivated.CheckState = System.Windows.Forms.CheckState.Checked; ! this.checkBoxIsDicotomicSearchActivated.Location = new System.Drawing.Point(16, 320); this.checkBoxIsDicotomicSearchActivated.Name = "checkBoxIsDicotomicSearchActivated"; this.checkBoxIsDicotomicSearchActivated.Size = new System.Drawing.Size(272, 24); *************** *** 319,322 **** --- 324,328 ---- // this.groupBoxUpdateDatabaseOptions.Controls.AddRange(new System.Windows.Forms.Control[] { + this.radioButtonDownloadOnlyAfterMax, this.radioButtonDownloadBeforeMinAndAfterMax, this.radioButtonOverWriteNo, *************** *** 324,347 **** this.groupBoxUpdateDatabaseOptions.Location = new System.Drawing.Point(8, 136); this.groupBoxUpdateDatabaseOptions.Name = "groupBoxUpdateDatabaseOptions"; ! this.groupBoxUpdateDatabaseOptions.Size = new System.Drawing.Size(288, 144); this.groupBoxUpdateDatabaseOptions.TabIndex = 14; this.groupBoxUpdateDatabaseOptions.TabStop = false; this.groupBoxUpdateDatabaseOptions.Text = "Update Database options"; // // radioButtonDownloadBeforeMinAndAfterMax // ! this.radioButtonDownloadBeforeMinAndAfterMax.Enabled = false; ! this.radioButtonDownloadBeforeMinAndAfterMax.Location = new System.Drawing.Point(16, 24); this.radioButtonDownloadBeforeMinAndAfterMax.Name = "radioButtonDownloadBeforeMinAndAfterMax"; ! this.radioButtonDownloadBeforeMinAndAfterMax.Size = new System.Drawing.Size(248, 32); this.radioButtonDownloadBeforeMinAndAfterMax.TabIndex = 2; ! this.radioButtonDownloadBeforeMinAndAfterMax.Text = "Download only quotes that come before first quote or after last quote in database" + ! ""; // // radioButtonOverWriteNo // ! this.radioButtonOverWriteNo.Location = new System.Drawing.Point(16, 64); this.radioButtonOverWriteNo.Name = "radioButtonOverWriteNo"; ! this.radioButtonOverWriteNo.Size = new System.Drawing.Size(248, 32); this.radioButtonOverWriteNo.TabIndex = 1; this.radioButtonOverWriteNo.Text = "Download all quotes, adding to database only the missing ones"; --- 330,361 ---- this.groupBoxUpdateDatabaseOptions.Location = new System.Drawing.Point(8, 136); this.groupBoxUpdateDatabaseOptions.Name = "groupBoxUpdateDatabaseOptions"; ! this.groupBoxUpdateDatabaseOptions.Size = new System.Drawing.Size(312, 176); this.groupBoxUpdateDatabaseOptions.TabIndex = 14; this.groupBoxUpdateDatabaseOptions.TabStop = false; this.groupBoxUpdateDatabaseOptions.Text = "Update Database options"; // + // radioButtonDownloadOnlyAfterMax + // + this.radioButtonDownloadOnlyAfterMax.Checked = true; + this.radioButtonDownloadOnlyAfterMax.Location = new System.Drawing.Point(16, 24); + this.radioButtonDownloadOnlyAfterMax.Name = "radioButtonDownloadOnlyAfterMax"; + this.radioButtonDownloadOnlyAfterMax.Size = new System.Drawing.Size(288, 24); + this.radioButtonDownloadOnlyAfterMax.TabIndex = 3; + this.radioButtonDownloadOnlyAfterMax.TabStop = true; + this.radioButtonDownloadOnlyAfterMax.Text = "Download only quotes after last quote (fastest)"; + // // radioButtonDownloadBeforeMinAndAfterMax // ! this.radioButtonDownloadBeforeMinAndAfterMax.Location = new System.Drawing.Point(16, 56); this.radioButtonDownloadBeforeMinAndAfterMax.Name = "radioButtonDownloadBeforeMinAndAfterMax"; ! this.radioButtonDownloadBeforeMinAndAfterMax.Size = new System.Drawing.Size(288, 32); this.radioButtonDownloadBeforeMinAndAfterMax.TabIndex = 2; ! this.radioButtonDownloadBeforeMinAndAfterMax.Text = "Download only quotes before first quote and after last quote"; // // radioButtonOverWriteNo // ! this.radioButtonOverWriteNo.Location = new System.Drawing.Point(16, 96); this.radioButtonOverWriteNo.Name = "radioButtonOverWriteNo"; ! this.radioButtonOverWriteNo.Size = new System.Drawing.Size(288, 32); this.radioButtonOverWriteNo.TabIndex = 1; this.radioButtonOverWriteNo.Text = "Download all quotes, adding to database only the missing ones"; *************** *** 349,355 **** // radioButtonOverWriteYes // ! this.radioButtonOverWriteYes.Location = new System.Drawing.Point(16, 104); this.radioButtonOverWriteYes.Name = "radioButtonOverWriteYes"; ! this.radioButtonOverWriteYes.Size = new System.Drawing.Size(248, 32); this.radioButtonOverWriteYes.TabIndex = 0; this.radioButtonOverWriteYes.Text = "Download all quotes, overwriting the existing ones in database"; --- 363,369 ---- // radioButtonOverWriteYes // ! this.radioButtonOverWriteYes.Location = new System.Drawing.Point(16, 136); this.radioButtonOverWriteYes.Name = "radioButtonOverWriteYes"; ! this.radioButtonOverWriteYes.Size = new System.Drawing.Size(288, 32); this.radioButtonOverWriteYes.TabIndex = 0; this.radioButtonOverWriteYes.Text = "Download all quotes, overwriting the existing ones in database"; *************** *** 358,362 **** // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); ! this.ClientSize = new System.Drawing.Size(584, 446); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.groupBoxUpdateDatabaseOptions, --- 372,376 ---- // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); ! this.ClientSize = new System.Drawing.Size(664, 470); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.groupBoxUpdateDatabaseOptions, *************** *** 498,503 **** #endregion - private void downloadQuotes_withTickerDataSet_create_dsTickerCurrentlyDownloaded( DataTable dt ) { --- 512,547 ---- #endregion + #region ITickerSelector's implementation + public TickerDataTable GetTableOfSelectedTickers() + { + DataTable dataTableOfDataGrid1 = (DataTable)this.dataGrid1.DataSource; + TickerDataTable tableOfSelectedTickers = new TickerDataTable(); + int indexOfRow = 0; + while(indexOfRow != dataTableOfDataGrid1.Rows.Count) + { + if(this.dataGrid1.IsSelected(indexOfRow)) + { + DataRow dataRow = tableOfSelectedTickers.NewRow(); + dataRow[0] = (string)dataTableOfDataGrid1.Rows[indexOfRow][0]; + tableOfSelectedTickers.Rows.Add(dataRow); + } + indexOfRow++; + } + return tableOfSelectedTickers; + } + + public void SelectAllTickers() + { + DataTable dataTableOfDataGrid1 = (DataTable)this.dataGrid1.DataSource; + int indexOfRow = 0; + while(indexOfRow != dataTableOfDataGrid1.Rows.Count) + { + this.dataGrid1.Select(indexOfRow); + indexOfRow++; + } + } + #endregion + private void downloadQuotes_withTickerDataSet_create_dsTickerCurrentlyDownloaded( DataTable dt ) { *************** *** 508,511 **** --- 552,556 ---- new DataColumn( dt.Columns[ "tiTicker" ].ColumnName , dt.Columns[ "tiTicker" ].DataType ) ); this.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ].Columns.Add( "currentState" , System.Type.GetType( "System.String" ) ); + this.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ].Columns.Add( "adjustedClose" , System.Type.GetType( "System.String" ) ); this.dataGrid1.DataSource = this.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ]; } *************** *** 532,535 **** --- 577,581 ---- } Cursor.Current = Cursors.Default; + //newThread.Join(); //qd.downloadTicker(); *************** *** 566,570 **** { Cursor.Current = Cursors.WaitCursor; ! this.OleDbConnection1.Open(); oleDbCommand1.Connection = this.OleDbConnection1; //this.oleDbCommand1.ExecuteNonQuery(); --- 612,617 ---- { Cursor.Current = Cursors.WaitCursor; ! if (this.OleDbConnection1.State != ConnectionState.Open) ! this.OleDbConnection1.Open(); oleDbCommand1.Connection = this.OleDbConnection1; //this.oleDbCommand1.ExecuteNonQuery(); *************** *** 591,594 **** --- 638,642 ---- this.openDbAndSetOleDbCommand(); this.downloadQuotesOfAllTickers(); + this.button1.Enabled = false; } *************** *** 597,600 **** --- 645,649 ---- this.openDbAndSetOleDbCommand(); this.downloadQuotesOfSelectedTickers(); + this.buttonDownloadQuotesOfSelectedTickers.Enabled = false; } *************** *** 610,613 **** --- 659,679 ---- } } + + public bool IsUpdateOptionSelected + { + get + { + return (this.radioButtonDownloadBeforeMinAndAfterMax.Checked || + this.radioButtonDownloadOnlyAfterMax.Checked); + } + } + + public bool IsOnlyAfterLastQuoteSelected + { + get + { + return this.radioButtonDownloadOnlyAfterMax.Checked; + } + } } } Index: TickerDownloader.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/TickerDownloader.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TickerDownloader.cs 21 Mar 2004 19:30:28 -0000 1.3 --- TickerDownloader.cs 17 Apr 2004 14:14:41 -0000 1.4 *************** *** 4,7 **** --- 4,9 ---- using System.Net; using System.Windows.Forms; + using QuantProject.DataAccess.Tables; + using QuantProject.ADT; namespace QuantProject.Applications.Downloader *************** *** 17,20 **** --- 19,23 ---- private string p_quTicker; private int p_numRows; + private DateTime INITIAL_DATE = ConstantsProvider.InitialDateTimeForDownload; private DateTime startDate; private DateTime endDate = DateTime.Today; *************** *** 22,26 **** private int endMonth = DateTime.Now.Month; private int endYear = DateTime.Now.Year; ! private DateTime INITIAL_DATE = new DateTime(1980, 1, 1); public TickerDownloader( WebDownloader myForm, DataRow currentDataTickerRow, string quTicker , int numRows ) { --- 25,30 ---- private int endMonth = DateTime.Now.Month; private int endYear = DateTime.Now.Year; ! private int numberOfQuotesInDatabase; ! public TickerDownloader( WebDownloader myForm, DataRow currentDataTickerRow, string quTicker , int numRows ) { *************** *** 54,58 **** } } ! private void addTickerToFaultyTickers() { --- 58,71 ---- } } ! ! private void updateCurrentStatusAdjustedClose(string stateOfAdjustedCloseValue ) ! { ! lock( p_myForm.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ] ) ! { ! DataRow[] myRows = p_myForm.DsTickerCurrentlyDownloaded.Tables[ "Tickers" ].Select( "tiTicker='" + p_quTicker + "'" ); ! myRows[ 0 ][ "adjustedClose" ] = stateOfAdjustedCloseValue; ! p_myForm.dataGrid1.Refresh(); ! } ! } private void addTickerToFaultyTickers() { *************** *** 88,92 **** + a + "&b=" + b + "&c=" + c +"&d=" + d + "&e=" + e + "&f=" + f + "&s=" + p_quTicker + "&y=0&g=d&ignore=.csv"); Req.Method = "GET"; ! Req.Timeout = 25000; HttpWebResponse hwr = (HttpWebResponse)Req.GetResponse(); Stream strm = hwr.GetResponseStream(); --- 101,105 ---- + a + "&b=" + b + "&c=" + c +"&d=" + d + "&e=" + e + "&f=" + f + "&s=" + p_quTicker + "&y=0&g=d&ignore=.csv"); Req.Method = "GET"; ! Req.Timeout = ConstantsProvider.TimeOutValue; HttpWebResponse hwr = (HttpWebResponse)Req.GetResponse(); Stream strm = hwr.GetResponseStream(); *************** *** 98,104 **** sr.Close(); strm.Close(); ! hwr.Close(); ! updateCurrentStatus( d + "/" + e + "/" + f ); numTrials = 6 ; } --- 111,117 ---- sr.Close(); strm.Close(); ! //hwr.Close(); ! updateCurrentStatus( d + "/" + e + "/" + f ); numTrials = 6 ; } *************** *** 138,141 **** --- 151,155 ---- newRow[ "tiTicker" ] = p_quTicker; newRow[ "currentState" ] = "Searching ..."; + newRow[ "adjustedClose"] = "..."; try { *************** *** 151,174 **** } public void DownloadTicker() { // update grid in webdownloader form addTickerTo_gridDataSet(); ! /* if(tickerIsInDatabase && p_myForm.UpdateFlagYes) { ! // try to import ticker before the first quote ! ! // try to import ticker after the last quote } else ! // tickers'quotes are downloaded for the first time ! {*/ ! if(this.p_myForm.checkBoxIsDicotomicSearchActivated.Checked == true) ! this.startDate = firstAvailableDateOnYahoo(this.INITIAL_DATE, this.endDate); ! setTimeFrameAndImportTickerForEachTimeFrame(200); ! ! //} ! //Monitor.Pulse( p_myForm.dsTickerCurrentlyDownloaded.Tables[ "Tickers" ] ); } public void DownloadTicker(DateTime startingDate) --- 165,267 ---- } + private void resetStartDateIfNecessary() + { + if(this.p_myForm.checkBoxIsDicotomicSearchActivated.Checked == true) + this.startDate = firstAvailableDateOnYahoo(this.INITIAL_DATE, this.endDate); + } + + private void downloadTickerBeforeFirstQuote() + { + this.endDate = Quotes.GetStartDate(this.p_quTicker); + this.resetStartDateIfNecessary(); + this.setTimeFrameAndImportTickerForEachTimeFrame(200); + } + + private bool getResponseForRepeatedChecks(int numberOfRepeatedChecks) + { + bool response = false; + Quotes tickerQuotes = new Quotes(this.p_quTicker); + for(int i = 1; i< this.numberOfQuotesInDatabase; i += this.numberOfQuotesInDatabase/numberOfRepeatedChecks) + { + DateTime dateToCheck = tickerQuotes.GetPrecedingDate(this.startDate, i); + response = + Quotes.IsAdjustedCloseChanged(this.p_quTicker, dateToCheck, + this.adjustedCloseFromSource(dateToCheck)); + } + return response; + } + + private void checkForNewAdjustedValueFromSource() + { + try + { + if(this.getResponseForRepeatedChecks(ConstantsProvider.NumberOfCheckToPerformOnAdjustedValues)) + { + this.updateCurrentStatusAdjustedClose("Changed!"); + } + else + { + this.updateCurrentStatusAdjustedClose("OK"); + } + } + catch(Exception ex) + { + MessageBox.Show(ex.ToString()); + } + } + + + + private void downloadTickerAfterLastQuote() + { + this.startDate = Quotes.GetEndDate(this.p_quTicker); + this.endDate = DateTime.Today; + this.checkForNewAdjustedValueFromSource(); + this.setTimeFrameAndImportTickerForEachTimeFrame(200); + + } + + private float adjustedCloseFromSource(DateTime adjustedCloseDate) + { + string Line; + string[] LineIn = null; + StreamReader streamReader = this.getStreamReaderFromSource(adjustedCloseDate, 0); + Line = streamReader.ReadLine(); + Line = streamReader.ReadLine(); + if ( Line != null && ! Line.StartsWith("<")) + { + LineIn=Line.Split(','); + } + return Single.Parse(LineIn[6]); + } public void DownloadTicker() { // update grid in webdownloader form addTickerTo_gridDataSet(); ! this.numberOfQuotesInDatabase = Quotes.GetNumberOfQuotes(this.p_quTicker); ! if(this.numberOfQuotesInDatabase>0 && p_myForm.IsUpdateOptionSelected) ! // there are some ticker's quotes in the database and ! // the user has chosen to download new quotes (only after last quote ! // or both before first quote and after last quote) { ! if(this.p_myForm.IsOnlyAfterLastQuoteSelected) ! { ! this.downloadTickerAfterLastQuote(); ! } ! else ! { ! this.downloadTickerBeforeFirstQuote(); ! this.downloadTickerAfterLastQuote(); ! } } else ! // ticker's quotes are downloaded for the first time or ! // the user has chosen to download all quotes ! { ! this.resetStartDateIfNecessary(); ! setTimeFrameAndImportTickerForEachTimeFrame(200); ! } //Monitor.Pulse( p_myForm.dsTickerCurrentlyDownloaded.Tables[ "Tickers" ] ); + } public void DownloadTicker(DateTime startingDate) *************** *** 176,180 **** this.INITIAL_DATE = startingDate; this.DownloadTicker(); - } --- 269,272 ---- *************** *** 203,206 **** --- 295,335 ---- } + private StreamReader getStreamReaderFromSource( DateTime initialDateOfTheTimeWindow, + int daysOfTheTimeWindow ) + { + int a = initialDateOfTheTimeWindow.Month - 1; + int b = initialDateOfTheTimeWindow.Day; + int c = initialDateOfTheTimeWindow.Year; + DateTime endDateOfTheTimeWindow = initialDateOfTheTimeWindow.AddDays(daysOfTheTimeWindow); + int d = endDateOfTheTimeWindow.Month - 1; + int e = endDateOfTheTimeWindow.Day; + int f = endDateOfTheTimeWindow.Year; + HttpWebRequest Req; + HttpWebResponse hwr; + Stream strm; + StreamReader sr = null; + int numTrials = 1; + while(numTrials < 5) + { + try + { + Req = (HttpWebRequest)WebRequest.Create("http:" + "//table.finance.yahoo.com/table.csv?a=" + + a + "&b=" + b + "&c=" + c +"&d=" + d + "&e=" + e + "&f=" + f + "&s=" + p_quTicker + "&y=0&g=d&ignore=.csv"); + Req.Method = "GET"; + Req.Timeout = ConstantsProvider.TimeOutValue; + hwr = (HttpWebResponse)Req.GetResponse(); + strm = hwr.GetResponseStream(); + sr = new StreamReader(strm); + numTrials = 6; + + } + catch (Exception exception) + { + string notUsed = exception.ToString(); + numTrials++; + } + } + return sr; + } private bool getResponseForTimeWindow( DateTime initialDateOfTheTimeWindow, *************** *** 227,231 **** + a + "&b=" + b + "&c=" + c +"&d=" + d + "&e=" + e + "&f=" + f + "&s=" + p_quTicker + "&y=0&g=d&ignore=.csv"); Req.Method = "GET"; ! Req.Timeout = 20000; hwr = (HttpWebResponse)Req.GetResponse(); strm = hwr.GetResponseStream(); --- 356,360 ---- + a + "&b=" + b + "&c=" + c +"&d=" + d + "&e=" + e + "&f=" + f + "&s=" + p_quTicker + "&y=0&g=d&ignore=.csv"); Req.Method = "GET"; ! Req.Timeout = ConstantsProvider.TimeOutValue; hwr = (HttpWebResponse)Req.GetResponse(); strm = hwr.GetResponseStream(); *************** *** 234,243 **** sr.Close(); strm.Close(); ! hwr.Close(); numTrials = 6; } catch (Exception exception) { ! MessageBox.Show( exception.ToString() + "\n\n for: " + initialDateOfTheTimeWindow.ToString()); numTrials++; } --- 363,372 ---- sr.Close(); strm.Close(); ! //hwr.Close(); numTrials = 6; } catch (Exception exception) { ! string notUsed = exception.ToString(); numTrials++; } *************** *** 284,288 **** } } - } } --- 413,416 ---- |
|
From: Marco M. <mi...@us...> - 2004-04-17 14:12:44
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/TickerSelectors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5077/Downloader/TickerSelectors Added Files: GroupEditor.cs ITickerReceiver.cs ITickerSelector.cs TickerGroupsListViewMenu.cs TickerGroupsViewer.cs TickerViewer.cs TickerViewerMenu.cs Log Message: GroupEditor, TickerGroupsViewer and TickerViewer have been moved to a dedicated folder Added interfaces ITickerSelector and ITickerReceiver Added context menus to be used on Forms that implements these interfaces --- NEW FILE: TickerViewerMenu.cs --- /* QuantDownloader - Quantitative Finance Library TickerViewerMenu.cs Copyright (C) 2003 Marco Milletti 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.Windows.Forms; using QuantProject.DataAccess.Tables; namespace QuantProject.Applications.Downloader.TickerSelectors { /// <summary> /// The Context Menu used by TickerViewer /// It is the base class from which it is possible to derive /// other context menus used by any Form implementing ITickerSelector /// </summary> public class TickerViewerMenu : ContextMenu { // the form which contains the context Menu protected Form parentForm; private MenuItem menuItemSelectAll = new MenuItem("&Select all items"); private MenuItem menuItemDownload = new MenuItem("&Download selection"); private MenuItem menuItemValidate = new MenuItem("&Validate selection"); private MenuItem menuItemCopy = new MenuItem("&Copy selection"); //private MenuItem menuItemPaste = new MenuItem("&Paste"); private MenuItem menuItemQuotesEditor = new MenuItem("&Open Quotes Editor"); public TickerViewerMenu(Form ITickerSelectorForm) { this.parentForm = ITickerSelectorForm; //this.parentForm.ContextMenu = this; this.menuItemSelectAll.Click += new System.EventHandler(this.selectAllTickers); this.menuItemDownload.Click += new System.EventHandler(this.downloadSelectedTickers); this.menuItemValidate.Click += new System.EventHandler(this.validateSelectedTickers); this.menuItemCopy.Click += new System.EventHandler(this.copySelectedTickers); this.menuItemQuotesEditor.Click += new System.EventHandler(this.openQuotesEditor); this.MenuItems.Add(this.menuItemSelectAll); this.MenuItems.Add(this.menuItemDownload); this.MenuItems.Add(this.menuItemValidate); this.MenuItems.Add(this.menuItemCopy); this.MenuItems.Add(this.menuItemQuotesEditor); } private void selectAllTickers(object sender, System.EventArgs e) { ITickerSelector iTickerSelector = (ITickerSelector)this.parentForm; iTickerSelector.SelectAllTickers(); } private void copySelectedTickers(object sender, System.EventArgs e) { ITickerSelector iTickerSelector = (ITickerSelector)this.parentForm; Tickers.Clipboard = iTickerSelector.GetTableOfSelectedTickers(); } private void downloadSelectedTickers(object sender, System.EventArgs e) { ITickerSelector iTickerSelector = (ITickerSelector)this.parentForm; TickerDataTable tableOfSelectedTickers = iTickerSelector.GetTableOfSelectedTickers(); if(tableOfSelectedTickers.Rows.Count == 0) { MessageBox.Show("No ticker has been selected!\n\n" + "Click on the grey area on the left to " + "select a ticker", "QuantDownloader error message", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } WebDownloader webDownloader = new WebDownloader(tableOfSelectedTickers); webDownloader.Show(); } private void validateSelectedTickers(object sender, System.EventArgs e) { ITickerSelector iTickerSelector = (ITickerSelector)this.parentForm; TickerDataTable tableOfSelectedTickers = iTickerSelector.GetTableOfSelectedTickers(); if(tableOfSelectedTickers.Rows.Count == 0) { MessageBox.Show("No ticker has been selected!\n\n" + "Click on the grey area on the left to " + "select a ticker", "QuantDownloader error message", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } QuantProject.Applications.Downloader.Validate.ValidateForm validateForm = new Validate.ValidateForm(tableOfSelectedTickers); validateForm.Show(); } private void openQuotesEditor(object sender, System.EventArgs e) { ITickerSelector iTickerSelector = (ITickerSelector)this.parentForm; TickerDataTable tableOfSelectedTickers = iTickerSelector.GetTableOfSelectedTickers(); if(tableOfSelectedTickers.Rows.Count != 1) { MessageBox.Show("Choose just one ticker for the quote editor!\n\n" + "Click on the grey area on the left to " + "select only one ticker", "QuantDownloader error message", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } QuotesEditor quotesEditor = new QuotesEditor((string)tableOfSelectedTickers.Rows[0][0]); quotesEditor.Show(); } /* private void paste(object sender, System.EventArgs e) { MessageBox.Show("Possible only if ITickerReceiver"); } */ } } --- NEW FILE: TickerGroupsListViewMenu.cs --- /* QuantDownloader - Quantitative Finance Library TickerGroupsListViewMenu.cs Copyright (C) 2003 Marco Milletti 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.Windows.Forms; using QuantProject.DataAccess.Tables; namespace QuantProject.Applications.Downloader.TickerSelectors { /// <summary> /// It is the context menu used by the list view of the ticker groups viewer /// </summary> public class TickerGroupsListViewMenu : TickerViewerMenu { private MenuItem menuItemPaste = new MenuItem("&Paste copied tickers"); private MenuItem menuItemRemoveSelectedItems = new MenuItem("&Remove selected items"); public TickerGroupsListViewMenu(Form ITickerSelectorForm) : base(ITickerSelectorForm) { this.menuItemPaste.Click += new System.EventHandler(this.paste); this.menuItemRemoveSelectedItems.Click += new System.EventHandler(this.removeSelectedItems); this.MenuItems.Add(this.menuItemPaste); this.MenuItems.Add(this.menuItemRemoveSelectedItems); } private void paste(object sender, System.EventArgs e) { ITickerReceiver iTickerReceiver = (ITickerReceiver)this.parentForm; iTickerReceiver.ReceiveTickers(Tickers.Clipboard); } private void removeSelectedItems(object sender, System.EventArgs e) { MessageBox.Show(".... NOT IMPLEMENTED YET .... "); } } } --- NEW FILE: TickerGroupsViewer.cs --- /* QuantDownloader - Quantitative Finance Library TickerGroupsViewer.cs Copyright (C) 2003 Marco Milletti 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.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data.OleDb; using System.Data; using QuantProject.DataAccess; using QuantProject.DataAccess.Tables; namespace QuantProject.Applications.Downloader.TickerSelectors { /// <summary> /// TickerGroupsViewer. /// </summary> public class TickerGroupsViewer : System.Windows.Forms.Form, ITickerSelector, ITickerReceiver { private OleDbConnection oleDbConnection = ConnectionProvider.OleDbConnection; private OleDbDataAdapter oleDbDataAdapter; private DataTable table; private System.Windows.Forms.TreeView treeViewGroups; private System.Windows.Forms.Splitter splitter1; private System.Windows.Forms.ListView listViewGroupsAndTickers; private System.Windows.Forms.ContextMenu contextMenuTickerGroupsTreeView; private System.Windows.Forms.MenuItem menuItemAddNewGroup; private System.Windows.Forms.MenuItem menuItemRemoveGroup; private System.Windows.Forms.MenuItem menuItemRenameGroup; private string selectedGroupID; private string selectedGroupDescription; private System.Windows.Forms.ImageList imageListGroupsAndTickers; private System.ComponentModel.IContainer components; private const int GROUP_IMAGE = 0; private const int TICKER_IMAGE = 1; private const string FIRST_COLUMN_NAME = "Element Name"; private const string SECOND_COLUMN_NAME = "Element Type"; private const string THIRD_COLUMN_NAME = "Element Description"; public TickerGroupsViewer() { InitializeComponent(); // this.listViewGroupsAndTickers.ContextMenu = new TickerGroupsListViewMenu(this); this.listViewGroupsAndTickers.Columns.Add(FIRST_COLUMN_NAME, this.listViewGroupsAndTickers.Width - 30, HorizontalAlignment.Left); this.listViewGroupsAndTickers.Columns.Add(SECOND_COLUMN_NAME, this.listViewGroupsAndTickers.Width - 60, HorizontalAlignment.Left); this.listViewGroupsAndTickers.Columns.Add(THIRD_COLUMN_NAME, this.listViewGroupsAndTickers.Width - 90, HorizontalAlignment.Left); // } /// <summary> /// Clean all resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } /// <summary> /// It gets the groupID of the selected node in the treeView control of the object /// </summary> public string SelectedGroupID { get { return this.selectedGroupID; } } /// <summary> /// It gets the group Description of the selected node in the treeView control of the object /// </summary> public string SelectedGroupDescription { get { return this.selectedGroupDescription; } } private void addTickersToTable(DataTable tableToFill) { try { ; } catch(Exception ex) { string notUsed = ex.ToString(); } } private void addTickerToTable(DataTable tableToFill, string tickerID, string tickerDescription) { try { DataRow newRow = tableToFill.NewRow(); newRow[0] = tickerID; newRow[1] = tickerDescription; tableToFill.Rows.Add(newRow); } catch(Exception ex) { string notUsed = ex.ToString(); } } // implementation of ITickerSelector interface public void SelectAllTickers() { foreach(ListViewItem item in this.listViewGroupsAndTickers.Items) { item.Selected = true; } } public TickerDataTable GetTableOfSelectedTickers() { TickerDataTable tableOfSelectedTickers = new TickerDataTable(); foreach(ListViewItem item in this.listViewGroupsAndTickers.SelectedItems) { if(item.Tag is System.String) // the item contains in Tag property the ticker ID { this.addTickerToTable(tableOfSelectedTickers, (string)item.Tag, item.SubItems[2].Text); } else // the item references to a node in the treeView : // so it stands for a group of tickers { MessageBox.Show("NOT IMPLEMENTED YET"); } } return tableOfSelectedTickers; } #region Windows Form Designer generated code /// <summary> /// Don't modify content with the code editor /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(TickerGroupsViewer)); this.treeViewGroups = new System.Windows.Forms.TreeView(); this.contextMenuTickerGroupsTreeView = new System.Windows.Forms.ContextMenu(); this.menuItemAddNewGroup = new System.Windows.Forms.MenuItem(); this.menuItemRemoveGroup = new System.Windows.Forms.MenuItem(); this.menuItemRenameGroup = new System.Windows.Forms.MenuItem(); this.imageListGroupsAndTickers = new System.Windows.Forms.ImageList(this.components); this.splitter1 = new System.Windows.Forms.Splitter(); this.listViewGroupsAndTickers = new System.Windows.Forms.ListView(); this.SuspendLayout(); // // treeViewGroups // this.treeViewGroups.ContextMenu = this.contextMenuTickerGroupsTreeView; this.treeViewGroups.Dock = System.Windows.Forms.DockStyle.Left; this.treeViewGroups.ImageList = this.imageListGroupsAndTickers; this.treeViewGroups.Name = "treeViewGroups"; this.treeViewGroups.Size = new System.Drawing.Size(120, 326); this.treeViewGroups.TabIndex = 0; this.treeViewGroups.AfterExpand += new System.Windows.Forms.TreeViewEventHandler(this.treeViewGroups_AfterExpand); this.treeViewGroups.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeViewGroups_AfterSelect); // // contextMenuTickerGroupsTreeView // this.contextMenuTickerGroupsTreeView.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuItemAddNewGroup, this.menuItemRemoveGroup, this.menuItemRenameGroup}); // // menuItemAddNewGroup // this.menuItemAddNewGroup.Index = 0; this.menuItemAddNewGroup.Text = "&Add New Group"; this.menuItemAddNewGroup.Click += new System.EventHandler(this.menuItemAddNewGroup_Click); // // menuItemRemoveGroup // this.menuItemRemoveGroup.Index = 1; this.menuItemRemoveGroup.Text = "&Remove"; this.menuItemRemoveGroup.Click += new System.EventHandler(this.menuItemRemoveGroup_Click); // // menuItemRenameGroup // this.menuItemRenameGroup.Index = 2; this.menuItemRenameGroup.Text = "&Modify"; this.menuItemRenameGroup.Click += new System.EventHandler(this.menuItemRenameGroup_Click); // // imageListGroupsAndTickers // this.imageListGroupsAndTickers.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit; this.imageListGroupsAndTickers.ImageSize = new System.Drawing.Size(16, 16); this.imageListGroupsAndTickers.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageListGroupsAndTickers.ImageStream"))); this.imageListGroupsAndTickers.TransparentColor = System.Drawing.Color.Transparent; // // splitter1 // this.splitter1.BackColor = System.Drawing.SystemColors.Highlight; this.splitter1.Location = new System.Drawing.Point(120, 0); this.splitter1.Name = "splitter1"; this.splitter1.Size = new System.Drawing.Size(3, 326); this.splitter1.TabIndex = 1; this.splitter1.TabStop = false; // // listViewGroupsAndTickers // this.listViewGroupsAndTickers.Activation = System.Windows.Forms.ItemActivation.TwoClick; this.listViewGroupsAndTickers.Dock = System.Windows.Forms.DockStyle.Fill; this.listViewGroupsAndTickers.Location = new System.Drawing.Point(123, 0); this.listViewGroupsAndTickers.Name = "listViewGroupsAndTickers"; this.listViewGroupsAndTickers.Size = new System.Drawing.Size(397, 326); this.listViewGroupsAndTickers.SmallImageList = this.imageListGroupsAndTickers; this.listViewGroupsAndTickers.TabIndex = 2; this.listViewGroupsAndTickers.View = System.Windows.Forms.View.Details; this.listViewGroupsAndTickers.ItemActivate += new System.EventHandler(this.listViewGroupsAndTickers_ItemActivate); // // TickerGroupsViewer // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(520, 326); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.listViewGroupsAndTickers, this.splitter1, this.treeViewGroups}); this.Name = "TickerGroupsViewer"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Ticker-Groups Viewer"; this.Load += new System.EventHandler(this.TickerGroupsViewer_Load); this.ResumeLayout(false); } #endregion #region Tree View Paintig on Load /// <summary> /// fill Tree View with existing groups (at root level) /// </summary> private void fillTreeViewAtRootLevel() { this.oleDbDataAdapter = new OleDbDataAdapter("SELECT * FROM tickerGroups WHERE tgTgId IS NULL" , this.oleDbConnection); this.table = new DataTable(); this.oleDbDataAdapter.Fill(this.table); TreeNode rootNode = new TreeNode("GROUPS"); rootNode.Tag = ""; this.treeViewGroups.Nodes.Add(rootNode); foreach (DataRow row in this.table.Rows) { TreeNode node = new TreeNode((string)row["tgDescription"]); node.Tag = (string)row["tgId"]; rootNode.Nodes.Add(node); } } /// <summary> /// fill the current node with existing groups from the DB /// </summary> private void addNodeChildsToCurrentNode(TreeNode currentNode) { this.oleDbDataAdapter.SelectCommand.CommandText = "SELECT * FROM tickerGroups WHERE tgTgId = '" + (string)currentNode.Tag + "'"; DataTable groupsChild = new DataTable(); this.oleDbDataAdapter.Fill(groupsChild); foreach (DataRow row in groupsChild.Rows) { TreeNode node = new TreeNode((string)row["tgDescription"]); node.Tag = (string)row["tgId"]; currentNode.Nodes.Add(node); } } private void TickerGroupsViewer_Load(object sender, System.EventArgs e) { try { Cursor.Current = Cursors.WaitCursor; if(this.oleDbConnection.State != ConnectionState.Open) this.oleDbConnection.Open(); fillTreeViewAtRootLevel(); foreach(TreeNode node in this.treeViewGroups.Nodes[0].Nodes) { addNodeChildsToCurrentNode(node); } } catch(Exception ex) { MessageBox.Show(ex.ToString()); } finally { Cursor.Current = Cursors.Default; this.oleDbConnection.Close(); } } #endregion #region Paint Child Nodes During selection private void treeViewGroups_AfterExpand(object sender, System.Windows.Forms.TreeViewEventArgs e) { if((string)this.treeViewGroups.SelectedNode.Tag != "") return; try { Cursor.Current = Cursors.WaitCursor; if(this.oleDbConnection.State != ConnectionState.Open) this.oleDbConnection.Open(); foreach(TreeNode node in this.treeViewGroups.SelectedNode.Nodes) { foreach(TreeNode childNode in node.Nodes) { if(childNode.Nodes.Count == 0) addNodeChildsToCurrentNode(childNode); } } } catch(Exception ex) { MessageBox.Show(ex.ToString()); } finally { Cursor.Current = Cursors.Default; this.oleDbConnection.Close(); } } #endregion private void treeViewGroups_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e) { this.selectedGroupID = (string)this.treeViewGroups.SelectedNode.Tag; this.selectedGroupDescription = this.treeViewGroups.SelectedNode.Text; this.updateListView(this.treeViewGroups.SelectedNode); } #region Update List View private void updateGroupsInListView(TreeNode selectedNode) { foreach(TreeNode node in selectedNode.Nodes) { ListViewItem listViewItem = new ListViewItem(node.Text, GROUP_IMAGE); listViewItem.Tag = node; this.listViewGroupsAndTickers.Items.Add(listViewItem); listViewItem.SubItems.Add("Group"); } } private void updateTickersInListView(TreeNode selectedNode) { try { Cursor.Current = Cursors.WaitCursor; if(this.oleDbConnection.State != ConnectionState.Open) this.oleDbConnection.Open(); this.oleDbDataAdapter.SelectCommand.CommandText = "SELECT ttTiId, tiCompanyName, ttTgId FROM tickers INNER JOIN " + "tickers_tickerGroups ON tickers.tiTicker = tickers_tickerGroups.ttTiId WHERE ttTgId ='" + (string)selectedNode.Tag + "'"; DataTable tickers = new DataTable(); this.oleDbDataAdapter.Fill(tickers); foreach (DataRow row in tickers.Rows) { ListViewItem listViewItem = new ListViewItem((string)row[0], TICKER_IMAGE); listViewItem.Tag = (string)row[0]; this.listViewGroupsAndTickers.Items.Add(listViewItem); listViewItem.SubItems.Add("Ticker"); listViewItem.SubItems.Add((string)row[1]); } } catch(Exception ex) { MessageBox.Show(ex.ToString()); } finally { Cursor.Current = Cursors.Default; this.oleDbConnection.Close(); } } private void updateListView(TreeNode selectedNode) { this.listViewGroupsAndTickers.Items.Clear(); this.updateGroupsInListView(selectedNode); this.updateTickersInListView(selectedNode); } #endregion #region Add group private void addNodeGroupToCurrentNode(string groupID, string groupDescription) { TreeNode node = new TreeNode(groupDescription); node.Tag = groupID; this.treeViewGroups.SelectedNode.Nodes.Add(node); this.updateListView(this.treeViewGroups.SelectedNode); } internal void AddNewGroupToDataBase(string groupID, string groupDescription, string parentGroupID) { try { Cursor.Current = Cursors.WaitCursor; if(this.oleDbConnection.State != ConnectionState.Open) this.oleDbConnection.Open(); this.oleDbDataAdapter.InsertCommand = new OleDbCommand("INSERT INTO tickerGroups(tgId, tgDescription, tgTgId) " + "VALUES('" + groupID + "','" + groupDescription + "','" + parentGroupID + "')", this.oleDbConnection); int numRowInserted = this.oleDbDataAdapter.InsertCommand.ExecuteNonQuery(); if(numRowInserted > 0) this.addNodeGroupToCurrentNode(groupID, groupDescription); } catch(Exception ex) { MessageBox.Show(ex.ToString()); } finally { Cursor.Current = Cursors.Default; this.oleDbConnection.Close(); } } internal void AddNewGroupToDataBase(string groupID, string groupDescription) { try { Cursor.Current = Cursors.WaitCursor; if(this.oleDbConnection.State != ConnectionState.Open) this.oleDbConnection.Open(); this.oleDbDataAdapter.InsertCommand = new OleDbCommand("INSERT INTO tickerGroups(tgId, tgDescription) " + "VALUES('" + groupID + "','" + groupDescription + "')", this.oleDbConnection); this.oleDbDataAdapter.InsertCommand.ExecuteNonQuery(); this.addNodeGroupToCurrentNode(groupID, groupDescription); } catch(Exception ex) { MessageBox.Show(ex.ToString()); } finally { Cursor.Current = Cursors.Default; this.oleDbConnection.Close(); } } #endregion #region Modify current Node private void modifyCurrentNode(string newTag, string newText) { this.treeViewGroups.SelectedNode.Text = newText; this.treeViewGroups.SelectedNode.Tag = newTag; } internal void ModifyGroup(string oldGroupID, string groupDescription, string newGroupID) { try { Cursor.Current = Cursors.WaitCursor; this.oleDbConnection.Open(); this.oleDbDataAdapter.UpdateCommand = new OleDbCommand("UPDATE tickerGroups SET tgId ='" + newGroupID + "', tgDescription ='" + groupDescription + "' WHERE tgId ='" + oldGroupID + "'", this.oleDbConnection); int numUpdatedRows = this.oleDbDataAdapter.UpdateCommand.ExecuteNonQuery(); if(numUpdatedRows >0) this.modifyCurrentNode(newGroupID, groupDescription); } catch(Exception ex) { MessageBox.Show(ex.ToString()); } finally { Cursor.Current = Cursors.Default; this.oleDbConnection.Close(); } } #endregion #region Remove current Node private void removeCurrentNodeAndGroup() { if((string)this.treeViewGroups.SelectedNode.Tag == "") { MessageBox.Show("You can not delete the root node!", "Error message", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if(MessageBox.Show("Do you really want to delete the current group and " + "all its groups and tickers?", "Confirm deletion", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No) { return; } deleteCurrentGroup(this.treeViewGroups.SelectedNode); } private void deleteCurrentGroup(TreeNode nodeCorrespondingToGroup) { try { Cursor.Current = Cursors.WaitCursor; this.oleDbConnection.Open(); this.oleDbDataAdapter.DeleteCommand = new OleDbCommand("DELETE * FROM tickerGroups WHERE tgId = '" + nodeCorrespondingToGroup.Tag + "'", this.oleDbConnection); int numDeletedRows = this.oleDbDataAdapter.DeleteCommand.ExecuteNonQuery(); if (numDeletedRows > 0) this.treeViewGroups.SelectedNode.Remove(); } catch(Exception ex) { MessageBox.Show(ex.ToString()); } finally { Cursor.Current = Cursors.Default; this.oleDbConnection.Close(); } } #endregion private void menuItemAddNewGroup_Click(object sender, System.EventArgs e) { GroupEditor groupEditor = new GroupEditor(this); groupEditor.Show(); } private void menuItemRemoveGroup_Click(object sender, System.EventArgs e) { this.removeCurrentNodeAndGroup(); } private void menuItemRenameGroup_Click(object sender, System.EventArgs e) { if((string)this.treeViewGroups.SelectedNode.Tag == "") // it is the root node { MessageBox.Show("The root node can't be modified!"); return; } GroupEditor groupEditor = new GroupEditor(this, this.treeViewGroups.SelectedNode); groupEditor.Show(); } private bool isRowInsertedInDataBase(DataRow row) { try { this.oleDbDataAdapter.InsertCommand = new OleDbCommand("INSERT INTO tickers_tickerGroups(ttTiId, ttTgId) " + "VALUES('" + (string)row[0] + "','" + (string)this.treeViewGroups.SelectedNode.Tag + "')", this.oleDbConnection); if(this.oleDbDataAdapter.InsertCommand.ExecuteNonQuery()>0) { return true; } else { return false; } } catch(Exception ex) { string neverUsed = ex.ToString(); return false; } } private void listViewGroupsAndTickers_ItemActivate(object sender, System.EventArgs e) { if(this.listViewGroupsAndTickers.SelectedItems[0].Tag is TreeNode) { this.treeViewGroups.SelectedNode.Expand(); foreach (TreeNode node in this.treeViewGroups.SelectedNode.Nodes) { if(node.Equals(this.listViewGroupsAndTickers.SelectedItems[0].Tag)) { node.Expand(); this.treeViewGroups.SelectedNode = node; this.updateListView(this.treeViewGroups.SelectedNode); break; } } } } //implementation of ITickerReceiver interface for this object public void ReceiveTickers(TickerDataTable tickers) { try { if(tickers == null) { MessageBox.Show("No ticker has been copied to ClipBoard!\n\n" + "Select some tickers before trying again!", "Paste operation failure", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if((string)this.treeViewGroups.SelectedNode.Tag == "") { MessageBox.Show("Selected tickers can't be copied inside " + "the root node: change group and try again!", "Paste operation failure", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // end of checks Cursor.Current = Cursors.WaitCursor; if(this.oleDbConnection.State != ConnectionState.Open) this.oleDbConnection.Open(); int numRowsInserted = 0; foreach (DataRow row in tickers.Rows) { if(this.isRowInsertedInDataBase(row)) numRowsInserted ++; } if(numRowsInserted != tickers.Rows.Count) MessageBox.Show("Some selected tickers have not been added", "Warning after paste operation", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.updateListView(this.treeViewGroups.SelectedNode); } catch(Exception ex) { MessageBox.Show(ex.ToString()); } finally { Cursor.Current = Cursors.Default; this.oleDbConnection.Close(); } } } } --- NEW FILE: ITickerReceiver.cs --- /* QuantDownloader - Quantitative Finance Library ITickerReceiver.cs Copyright (C) 2003 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.DataAccess.Tables; namespace QuantProject.Applications.Downloader.TickerSelectors { /// <summary> /// Interface to be implemented by objects that can receive tickers /// </summary> public interface ITickerReceiver { void ReceiveTickers(TickerDataTable tickersToReceive); } } --- NEW FILE: TickerViewer.cs --- /* QuantDownloader - Quantitative Finance Library TickerViewer.cs Copyright (C) 2003 Marco Milletti 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.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Data.OleDb; using QuantProject.DataAccess; using QuantProject.DataAccess.Tables; namespace QuantProject.Applications.Downloader.TickerSelectors { /// <summary> /// It finds tickers that match criteria entered by the user /// </summary> public class TickerViewer : System.Windows.Forms.Form, ITickerSelector { private System.Windows.Forms.TextBox textBoxStringToFind; private System.Windows.Forms.Label label1; private System.Windows.Forms.ToolTip toolTip1; private System.Windows.Forms.DataGrid dataGrid1; private System.Windows.Forms.Button buttonFindTickers; private System.ComponentModel.IContainer components; private System.Windows.Forms.TextBox textBoxStringToFindInName; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label3; private System.Windows.Forms.Panel panel2; private System.Windows.Forms.Splitter splitter1; private System.Windows.Forms.GroupBox groupBoxDateQuoteFilter; private System.Windows.Forms.RadioButton radioButtonDateQuoteFilter; private System.Windows.Forms.RadioButton radioButtonAnyTicker; private System.Windows.Forms.DateTimePicker dateTimePickerFirstDate; private System.Windows.Forms.DateTimePicker dateTimePickerLastDate; private System.Windows.Forms.Label label6; private System.Windows.Forms.Label label5; private System.Windows.Forms.Label label7; private System.Windows.Forms.ComboBox comboBoxFirstOperator; private System.Windows.Forms.ComboBox comboBoxSecondOperator; private DataTable tableTickers; public TickerViewer() { InitializeComponent(); this.dataGrid1.ContextMenu = new TickerViewerMenu(this); this.tableTickers = new DataTable("tickers"); this.dataGrid1.DataSource = this.tableTickers; this.setStyle_dataGrid1(); } /// <summary> /// clean up /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// do not modify the content with the editor /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.textBoxStringToFind = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.textBoxStringToFindInName = new System.Windows.Forms.TextBox(); this.dataGrid1 = new System.Windows.Forms.DataGrid(); this.buttonFindTickers = new System.Windows.Forms.Button(); this.label3 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.panel2 = new System.Windows.Forms.Panel(); this.groupBoxDateQuoteFilter = new System.Windows.Forms.GroupBox(); this.comboBoxSecondOperator = new System.Windows.Forms.ComboBox(); this.comboBoxFirstOperator = new System.Windows.Forms.ComboBox(); this.label7 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); this.dateTimePickerLastDate = new System.Windows.Forms.DateTimePicker(); this.dateTimePickerFirstDate = new System.Windows.Forms.DateTimePicker(); this.radioButtonDateQuoteFilter = new System.Windows.Forms.RadioButton(); this.radioButtonAnyTicker = new System.Windows.Forms.RadioButton(); this.splitter1 = new System.Windows.Forms.Splitter(); ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit(); this.panel2.SuspendLayout(); this.groupBoxDateQuoteFilter.SuspendLayout(); this.SuspendLayout(); // // textBoxStringToFind // this.textBoxStringToFind.Location = new System.Drawing.Point(48, 40); this.textBoxStringToFind.Name = "textBoxStringToFind"; this.textBoxStringToFind.Size = new System.Drawing.Size(88, 20); this.textBoxStringToFind.TabIndex = 0; this.textBoxStringToFind.Text = "%"; this.toolTip1.SetToolTip(this.textBoxStringToFind, "Type chars to filter tickers (you can use % and _ ) "); // // label1 // this.label1.Location = new System.Drawing.Point(48, 16); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(96, 16); this.label1.TabIndex = 1; this.label1.Text = "Ticker is like"; // // textBoxStringToFindInName // this.textBoxStringToFindInName.AllowDrop = true; this.textBoxStringToFindInName.Location = new System.Drawing.Point(216, 40); this.textBoxStringToFindInName.Name = "textBoxStringToFindInName"; this.textBoxStringToFindInName.Size = new System.Drawing.Size(120, 20); this.textBoxStringToFindInName.TabIndex = 4; this.textBoxStringToFindInName.Text = "%"; this.toolTip1.SetToolTip(this.textBoxStringToFindInName, "Type chars to filter companies (you can use % and _ ) "); // // dataGrid1 // this.dataGrid1.BorderStyle = System.Windows.Forms.BorderStyle.None; this.dataGrid1.DataMember = ""; this.dataGrid1.Dock = System.Windows.Forms.DockStyle.Left; this.dataGrid1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText; this.dataGrid1.Name = "dataGrid1"; this.dataGrid1.Size = new System.Drawing.Size(432, 478); this.dataGrid1.TabIndex = 2; // // buttonFindTickers // this.buttonFindTickers.Location = new System.Drawing.Point(136, 256); this.buttonFindTickers.Name = "buttonFindTickers"; this.buttonFindTickers.Size = new System.Drawing.Size(104, 24); this.buttonFindTickers.TabIndex = 3; this.buttonFindTickers.Text = "Find Tickers"; this.buttonFindTickers.Click += new System.EventHandler(this.buttonFindTickers_Click); // // label3 // this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.label3.Location = new System.Drawing.Point(160, 40); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(32, 16); this.label3.TabIndex = 6; this.label3.Text = "AND"; // // label2 // this.label2.Location = new System.Drawing.Point(216, 16); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(120, 16); this.label2.TabIndex = 5; this.label2.Text = "Company Name is like"; // // panel2 // this.panel2.Controls.AddRange(new System.Windows.Forms.Control[] { this.groupBoxDateQuoteFilter, this.textBoxStringToFind, this.buttonFindTickers, this.textBoxStringToFindInName, this.label2, this.label3, this.label1}); this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; this.panel2.ForeColor = System.Drawing.SystemColors.ControlText; this.panel2.Location = new System.Drawing.Point(432, 0); this.panel2.Name = "panel2"; this.panel2.Size = new System.Drawing.Size(392, 478); this.panel2.TabIndex = 7; // // groupBoxDateQuoteFilter // this.groupBoxDateQuoteFilter.Controls.AddRange(new System.Windows.Forms.Control[] { this.comboBoxSecondOperator, this.comboBoxFirstOperator, this.label7, this.label5, this.label6, this.dateTimePickerLastDate, this.dateTimePickerFirstDate, this.radioButtonDateQuoteFilter, this.radioButtonAnyTicker}); this.groupBoxDateQuoteFilter.Location = new System.Drawing.Point(8, 80); this.groupBoxDateQuoteFilter.Name = "groupBoxDateQuoteFilter"; this.groupBoxDateQuoteFilter.Size = new System.Drawing.Size(376, 160); this.groupBoxDateQuoteFilter.TabIndex = 14; this.groupBoxDateQuoteFilter.TabStop = false; this.groupBoxDateQuoteFilter.Text = "Quote filter"; // // comboBoxSecondOperator // this.comboBoxSecondOperator.Enabled = false; this.comboBoxSecondOperator.Items.AddRange(new object[] { "<=", ">="}); this.comboBoxSecondOperator.Location = new System.Drawing.Point(200, 96); this.comboBoxSecondOperator.Name = "comboBoxSecondOperator"; this.comboBoxSecondOperator.Size = new System.Drawing.Size(48, 21); this.comboBoxSecondOperator.TabIndex = 22; this.comboBoxSecondOperator.Text = "<="; // // comboBoxFirstOperator // this.comboBoxFirstOperator.Enabled = false; this.comboBoxFirstOperator.Items.AddRange(new object[] { "<=", ">="}); this.comboBoxFirstOperator.Location = new System.Drawing.Point(200, 64); this.comboBoxFirstOperator.Name = "comboBoxFirstOperator"; this.comboBoxFirstOperator.Size = new System.Drawing.Size(48, 21); this.comboBoxFirstOperator.TabIndex = 21; this.comboBoxFirstOperator.Text = ">="; // // label7 // this.label7.Location = new System.Drawing.Point(256, 96); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(32, 16); this.label7.TabIndex = 20; this.label7.Text = "than"; // // label5 // this.label5.Location = new System.Drawing.Point(256, 64); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(32, 16); this.label5.TabIndex = 18; this.label5.Text = "than"; // // label6 // this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.label6.Location = new System.Drawing.Point(24, 96); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(152, 16); this.label6.TabIndex = 17; this.label6.Text = "and last available quote is"; // // dateTimePickerLastDate // this.dateTimePickerLastDate.Enabled = false; this.dateTimePickerLastDate.Format = System.Windows.Forms.DateTimePickerFormat.Short; this.dateTimePickerLastDate.Location = new System.Drawing.Point(288, 96); this.dateTimePickerLastDate.Name = "dateTimePickerLastDate"; this.dateTimePickerLastDate.Size = new System.Drawing.Size(88, 20); this.dateTimePickerLastDate.TabIndex = 15; // // dateTimePickerFirstDate // this.dateTimePickerFirstDate.Enabled = false; this.dateTimePickerFirstDate.Format = System.Windows.Forms.DateTimePickerFormat.Short; this.dateTimePickerFirstDate.Location = new System.Drawing.Point(288, 64); this.dateTimePickerFirstDate.Name = "dateTimePickerFirstDate"; this.dateTimePickerFirstDate.Size = new System.Drawing.Size(88, 20); this.dateTimePickerFirstDate.TabIndex = 13; // // radioButtonDateQuoteFilter // this.radioButtonDateQuoteFilter.Location = new System.Drawing.Point(8, 56); this.radioButtonDateQuoteFilter.Name = "radioButtonDateQuoteFilter"; this.radioButtonDateQuoteFilter.Size = new System.Drawing.Size(184, 24); this.radioButtonDateQuoteFilter.TabIndex = 12; this.radioButtonDateQuoteFilter.Text = "Only tickers whose first quote is"; this.radioButtonDateQuoteFilter.CheckedChanged += new System.EventHandler(this.radioButtonDateQuoteFilter_CheckedChanged); // // radioButtonAnyTicker // this.radioButtonAnyTicker.Checked = true; this.radioButtonAnyTicker.Location = new System.Drawing.Point(8, 24); this.radioButtonAnyTicker.Name = "radioButtonAnyTicker"; this.radioButtonAnyTicker.Size = new System.Drawing.Size(248, 24); this.radioButtonAnyTicker.TabIndex = 10; this.radioButtonAnyTicker.TabStop = true; this.radioButtonAnyTicker.Text = "Any ticker, with or without quotes"; // // splitter1 // this.splitter1.BackColor = System.Drawing.SystemColors.Highlight; this.splitter1.Location = new System.Drawing.Point(432, 0); this.splitter1.Name = "splitter1"; this.splitter1.Size = new System.Drawing.Size(3, 478); this.splitter1.TabIndex = 8; this.splitter1.TabStop = false; // // TickerViewer // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(824, 478); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.splitter1, this.panel2, this.dataGrid1}); this.Name = "TickerViewer"; this.Text = "Ticker Viewer"; ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit(); this.panel2.ResumeLayout(false); this.groupBoxDateQuoteFilter.ResumeLayout(false); this.ResumeLayout(false); } #endregion #region Style for dataGrid1 private void setStyle_dataGrid1() { DataGridTableStyle dataGrid1TableStyle = new DataGridTableStyle(); dataGrid1TableStyle.MappingName = this.tableTickers.TableName; dataGrid1TableStyle.ColumnHeadersVisible = true; dataGrid1TableStyle.ReadOnly = true; dataGrid1TableStyle.SelectionBackColor = Color.DimGray ; DataGridTextBoxColumn columnStyle_tiTicker = new DataGridTextBoxColumn(); columnStyle_tiTicker.MappingName = "tiTicker"; columnStyle_tiTicker.HeaderText = "Ticker"; columnStyle_tiTicker.TextBox.Enabled = false; columnStyle_tiTicker.NullText = ""; columnStyle_tiTicker.Width = 60; DataGridTextBoxColumn columnStyle_tiCompanyName = new DataGridTextBoxColumn(); columnStyle_tiCompanyName.MappingName = "tiCompanyName"; columnStyle_tiCompanyName.HeaderText = "Company Name"; columnStyle_tiCompanyName.TextBox.Enabled = false; columnStyle_tiCompanyName.NullText = ""; columnStyle_tiCompanyName.Width = 150; DataGridTextBoxColumn columnStyle_FirstQuote = new DataGridTextBoxColumn(); columnStyle_FirstQuote.MappingName = "FirstQuote"; columnStyle_FirstQuote.HeaderText = "First Quote"; columnStyle_FirstQuote.TextBox.Enabled = false; columnStyle_FirstQuote.NullText = ""; columnStyle_FirstQuote.Width = 80; DataGridTextBoxColumn columnStyle_LastQuote = new DataGridTextBoxColumn(); columnStyle_LastQuote.MappingName = "LastQuote"; columnStyle_LastQuote.HeaderText = "Last Quote"; columnStyle_LastQuote.TextBox.Enabled = false; columnStyle_LastQuote.NullText = ""; columnStyle_LastQuote.Width = 80; dataGrid1TableStyle.GridColumnStyles.Add(columnStyle_tiTicker); dataGrid1TableStyle.GridColumnStyles.Add(columnStyle_tiCompanyName); dataGrid1TableStyle.GridColumnStyles.Add(columnStyle_FirstQuote); dataGrid1TableStyle.GridColumnStyles.Add(columnStyle_LastQuote); this.dataGrid1.TableStyles.Add(dataGrid1TableStyle); } #endregion private void buttonFindTickers_Click(object sender, System.EventArgs e) { try { Cursor.Current = Cursors.WaitCursor; if(this.radioButtonAnyTicker.Checked) //all tickers with or without quotes { this.tableTickers = Tickers.GetTableOfFilteredTickers(this.textBoxStringToFind.Text, this.textBoxStringToFindInName.Text); } else //all tickers with first date quote and last date quote within a specified interval { this.tableTickers = Tickers.GetTableOfFilteredTickers(this.textBoxStringToFind.Text, this.textBoxStringToFindInName.Text, this.comboBoxFirstOperator.Text, this.dateTimePickerFirstDate.Value, this.comboBoxSecondOperator.Text, this.dateTimePickerLastDate.Value); } // these two lines in order to avoid "strange" exceptions ... this.dataGrid1.DataSource = null; this.dataGrid1.DataSource = this.tableTickers; // this.dataGrid1.Refresh(); } catch(Exception ex) { MessageBox.Show(ex.ToString()); } finally { Cursor.Current = Cursors.Default; } } // implementation of ITickerSelector interface public TickerDataTable GetTableOfSelectedTickers() { DataTable dataTableOfDataGrid1 = (DataTable)this.dataGrid1.DataSource; TickerDataTable tableOfSelectedTickers = new TickerDataTable(); int indexOfRow = 0; while(indexOfRow != dataTableOfDataGrid1.Rows.Count) { if(this.dataGrid1.IsSelected(indexOfRow)) { DataRow dataRow = tableOfSelectedTickers.NewRow(); dataRow[0] = (string)dataTableOfDataGrid1.Rows[indexOfRow][0]; dataRow[1] = (string)dataTableOfDataGrid1.Rows[indexOfRow][1]; tableOfSelectedTickers.Rows.Add(dataRow); } indexOfRow++; } return tableOfSelectedTickers; } public void SelectAllTickers() { DataTable dataTableOfDataGrid1 = (DataTable)this.dataGrid1.DataSource; int indexOfRow = 0; while(indexOfRow != dataTableOfDataGrid1.Rows.Count) { this.dataGrid1.Select(indexOfRow); indexOfRow++; } } private void radioButtonDateQuoteFilter_CheckedChanged(object sender, System.EventArgs e) { if(this.radioButtonDateQuoteFilter.Checked == true) { this.dateTimePickerFirstDate.Enabled = true; this.dateTimePickerLastDate.Enabled = true; this.comboBoxFirstOperator.Enabled = true; this.comboBoxSecondOperator.Enabled = true; } else { this.dateTimePickerFirstDate.Enabled = false; this.dateTimePickerLastDate.Enabled = false; this.comboBoxFirstOperator.Enabled = false; this.comboBoxSecondOperator.Enabled = false; } } } } --- NEW FILE: GroupEditor.cs --- /* QuantDownloader - Quantitative Finance Library TickerGroupsViewer.cs Copyright (C) 2003 Marco Milletti 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.Collections; using System.ComponentModel; using System.Windows.Forms; using QuantProject.Applications.Downloader.TickerSelectors; namespace QuantProject.Applications.Downloader { /// <summary> /// It has to be used for editing group names and ID in the /// TickerGroupsViewer passed as the actual parameter in the constructor /// </summary> public class GroupEditor : System.Windows.Forms.Form { private System.Windows.Forms.Label labelGroupID; private System.Windows.Forms.Label labelGroupDescription; private System.Windows.Forms.TextBox textBoxGroupDescription; private System.Windows.Forms.TextBox textBoxGroupID; private TickerGroupsViewer tickerGroupsViewer; private TreeNode selectedNodeInTickerGroupsViewer; private System.Windows.Forms.Button buttonAdd; private System.Windows.Forms.Button buttonModify; /// <summary> /// components /// </summary> private System.ComponentModel.Container components = null; public GroupEditor(TickerGroupsViewer tickerGroupsViewer) { InitializeComponent(); // this.tickerGroupsViewer = tickerGroupsViewer; this.Text = "Add new group inside: " + this.tickerGroupsViewer.SelectedGroupDescription; this.buttonModify.Visible = false; // } public GroupEditor(TickerGroupsViewer tickerGroupsViewer, TreeNode nodeToBeModified) { InitializeComponent(); // this.tickerGroupsViewer = tickerGroupsViewer; this.selectedNodeInTickerGroupsViewer = nodeToBeModified; this.Text = "Modify group"; this.textBoxGroupDescription.Text = nodeToBeModified.Text; this.textBoxGroupID.Text = (string)nodeToBeModified.Tag; this.buttonAdd.Visible = false; this.buttonModify.Location = new System.Drawing.Point(144,112); // } /// <summary> /// Clean up resources being used /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// Metodo necessario per il supporto della finestra di progettazione. Non modificare /// il contenuto del metodo con l'editor di codice. /// </summary> private void InitializeComponent() { this.buttonAdd = new System.Windows.Forms.Button(); this.textBoxGroupID = new System.Windows.Forms.TextBox(); this.labelGroupID = new System.Windows.Forms.Label(); this.labelGroupDescription = new System.Windows.Forms.Label(); this.textBoxGroupDescription = new System.Windows.Forms.TextBox(); this.buttonModify = new System.Windows.Forms.Button(); this.SuspendLayout(); // // buttonAdd // this.buttonAdd.Location = new System.Drawing.Point(144, 112); this.buttonAdd.Name = "buttonAdd"; this.buttonAdd.TabIndex = 0; this.buttonAdd.Text = "&ADD"; this.buttonAdd.Click += new System.EventHandler(this.buttonOK_Click); // // textBoxGroupID // this.textBoxGroupID.Location = new System.Drawing.Point(144, 24); this.textBoxGroupID.Name = "textBoxGroupID"; this.textBoxGroupID.Size = new System.Drawing.Size(112, 20); this.textBoxGroupID.TabIndex = 1; this.textBoxGroupID.Text = "GroupID"; // // labelGroupID // this.labelGroupID.Location = new System.Drawing.Point(8, 24); this.labelGroupID.Name = "labelGroupID"; this.labelGroupID.Size = new System.Drawing.Size(128, 23); this.labelGroupID.TabIndex = 2; this.labelGroupID.Text = "Group ID (max 8 chr)"; // // labelGroupDescription // this.labelGroupDescription.Location = new System.Drawing.Point(8, 64); this.labelGroupDescription.Name = "labelGroupDescription"; this.labelGroupDescription.TabIndex = 4; this.labelGroupDescription.Text = "Group Description"; // // textBoxGroupDescription // this.textBoxGroupDescription.Location = new System.Drawing.Point(144, 64); this.textBoxGroupDescription.Name = "textBoxGroupDescription"; this.textBoxGroupDescription.Size = new System.Drawing.Size(252, 20); this.textBoxGroupDescription.TabIndex = 3; this.textBoxGroupDescription.Text = "Group Description"; // // buttonModify // this.buttonModify.Location = new System.Drawing.Point(232, 112); this.buttonModify.Name = "buttonModify"; this.buttonModify.TabIndex = 5; this.buttonModify.Text = "&MODIFY"; this.buttonModify.Click += new System.EventHandler(this.buttonModify_Click); // // GroupEditor // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(418, 152); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.buttonModify, this.labelGroupDescription, this.textBoxGroupDescription, this.labelGroupID, this.textBoxGroupID, this.buttonAdd}); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.Name = "GroupEditor"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Group Editor"; this.ResumeLayout(false); } #endregion private bool FormIsNotComplete() { if(this.textBoxGroupID.Text == "" || this.textBoxGroupDescription.Text == "") { MessageBox.Show("Type both Group ID and Group Description!", "Updating or Adding group not possible", MessageBoxButtons.OK, MessageBoxIcon.Error); return true; } else { return false; } } private void buttonOK_Click(object sender, System.EventArgs e) { if(this.FormIsNotComplete()) return; if(this.tickerGroupsViewer.SelectedGroupID == "") // it is a group to be added under the root node { this.tickerGroupsViewer.AddNewGroupToDataBase(this.textBoxGroupID.Text, this.textBoxGroupDescription.Text); } else //// it is a group to be added under the selected group { this.tickerGroupsViewer.AddNewGroupToDataBase(this.textBoxGroupID.Text, this.textBoxGroupDescription.Text, this.tickerGroupsViewer.SelectedGroupID); } this.Close(); } private void buttonModify_Click(object sender, System.EventArgs e) { if(this.FormIsNotComplete()) return; this.tickerGroupsViewer.ModifyGroup((string)this.selectedNodeInTickerGroupsViewer.Tag, this.textBoxGroupDescription.Text, this.textBoxGroupID.Text); this.Close(); } } } --- NEW FILE: ITickerSelector.cs --- /* QuantDownloader - Quantitative Finance Library ITickerSelector.cs Copyright (C) 2003 Marco Milletti 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 wi... [truncated message content] |
|
From: Marco M. <mi...@us...> - 2004-04-17 14:08:39
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4199/Downloader Removed Files: GroupEditor.cs TickerGroupsViewer.cs TickerViewer.cs Log Message: GroupEditor, TickerGroupsViewer and TickerViewer have been moved to a dedicated folder --- TickerGroupsViewer.cs DELETED --- --- TickerViewer.cs DELETED --- --- GroupEditor.cs DELETED --- |
|
From: Marco M. <mi...@us...> - 2004-04-17 14:03:40
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/TickerSelectors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3357/TickerSelectors Log Message: Directory /cvsroot/quantproject/QuantDownloader/Downloader/TickerSelectors added to the repository |
|
From: Marco M. <mi...@us...> - 2004-04-17 14:02:18
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2982/b2_DataAccess Modified Files: b2_DataAccess.csproj Log Message: Added Tickers and TickerDataTable classes Index: b2_DataAccess.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/b2_DataAccess.csproj,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** b2_DataAccess.csproj 28 Mar 2004 20:16:03 -0000 1.6 --- b2_DataAccess.csproj 17 Apr 2004 14:02:09 -0000 1.7 *************** *** 138,141 **** --- 138,156 ---- /> <File + RelPath = "Tables\TickerDataTable.cs" + SubType = "Component" + BuildAction = "Compile" + /> + <File + RelPath = "Tables\TickerDataTable.resx" + DependentUpon = "TickerDataTable.cs" + BuildAction = "EmbeddedResource" + /> + <File + RelPath = "Tables\Tickers.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Tables\VisuallyValidatedQuotes.cs" SubType = "Code" |
|
From: Marco M. <mi...@us...> - 2004-04-17 14:02:18
|
Update of /cvsroot/quantproject/QuantProject/b91_QuantProject In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2982/b91_QuantProject Modified Files: Main.cs Log Message: Added Tickers and TickerDataTable classes Index: Main.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b91_QuantProject/Main.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Main.cs 28 Nov 2003 16:35:22 -0000 1.3 --- Main.cs 17 Apr 2004 14:02:09 -0000 1.4 *************** *** 224,228 **** //try { ! new RunMSFTsimpleTest().Run(); //new RunOneRank().Run(); //new RunMSFTwalkForward().Run(); --- 224,229 ---- //try { ! //new RunMSFTsimpleTest().Run(); ! new RunMSFTsimpleTest_2().Run(); //new RunOneRank().Run(); //new RunMSFTwalkForward().Run(); |
|
From: Marco M. <mi...@us...> - 2004-04-17 14:01:25
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2782/b2_DataAccess/Tables Modified Files: Quotes.cs Log Message: Added and modified some methods in Quotes and SqlExecutor Index: Quotes.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables/Quotes.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Quotes.cs 28 Mar 2004 19:55:54 -0000 1.2 --- Quotes.cs 17 Apr 2004 14:01:17 -0000 1.3 *************** *** 13,16 **** --- 13,17 ---- { private DataTable quotes; + /// <summary> *************** *** 35,39 **** { DataTable dataTable = SqlExecutor.GetDataTable( ! "select * from quotes where quTicker='" + ticker + "'" ); return (DateTime)(dataTable.Rows[ 0 ][ "quDate" ]); } --- 36,41 ---- { DataTable dataTable = SqlExecutor.GetDataTable( ! "select * from quotes where quTicker='" + ticker + "' " + ! "order by quDate"); return (DateTime)(dataTable.Rows[ 0 ][ "quDate" ]); } *************** *** 46,52 **** { DataTable dataTable = SqlExecutor.GetDataTable( ! "select * from quotes where quTicker='" + ticker + "'" ); ! return (DateTime)(dataTable.Rows[ 0 ][ "quDate" ]); } #region GetHashValue private string getHashValue_getQuoteString_getRowString_getSingleValueString( Object value ) --- 48,133 ---- { DataTable dataTable = SqlExecutor.GetDataTable( ! "select * from quotes where quTicker='" + ticker + "' " + ! "order by quDate DESC"); ! return (DateTime)(dataTable.Rows[0][ "quDate" ]); } + /// <summary> + /// Returns the number of quotes for the given ticker + /// </summary> + /// <param name="ticker">ticker for which the number of quotes has to be returned</param> + /// <returns></returns> + public static int GetNumberOfQuotes( string ticker ) + { + DataTable dataTable = SqlExecutor.GetDataTable( + "select * from quotes where quTicker='" + ticker + "'" ); + return dataTable.Rows.Count; + } + + /// <summary> + /// It provides deletion of the quote from the table "quotes" for + /// the given ticker for a specified date + /// </summary> + public static void Delete( string ticker, DateTime dateOfTheQuoteToBeDeleted ) + { + try + { + SqlExecutor.ExecuteNonQuery("DELETE * FROM quotes " + + "WHERE quTicker ='" + + ticker + "' AND quDate =" + + SQLBuilder.GetDateConstant(dateOfTheQuoteToBeDeleted)); + } + catch(Exception ex) + { + string notUsed = ex.ToString(); + } + } + + /// <summary> + /// It provides addition of the given quote's values into table "quotes" + /// </summary> + public static void Add( string ticker, DateTime date, double open, + double high, double low, double close, + double volume, double adjustedClose) + { + try + { + SqlExecutor.ExecuteNonQuery("INSERT INTO quotes(quTicker, quDate, quOpen, " + + "quHigh, quLow, quClose, quVolume, quAdjustedClose) " + + "VALUES('" + ticker + "', " + SQLBuilder.GetDateConstant(date) + ", " + + open + ", " + high + ", " + low + ", " + close + ", " + + volume + ", " + adjustedClose + ")"); + } + catch(Exception ex) + { + string notUsed = ex.ToString(); + } + } + + public static bool IsAdjustedCloseChanged(string ticker, DateTime dateToCheck, + float currentAdjustedValueFromSource) + { + bool isAdjustedCloseChanged = false; + try + { + float adjustedCloseInDatabase; + double absoluteRelativeDifference; + DataTable tableOfSingleRow = + SqlExecutor.GetDataTable("SELECT * FROM quotes WHERE quTicker='" + + ticker + "' AND quDate=" + + SQLBuilder.GetDateConstant(dateToCheck)); + adjustedCloseInDatabase = (float)(tableOfSingleRow.Rows[0]["quAdjustedClose"]); + absoluteRelativeDifference = + Math.Abs((currentAdjustedValueFromSource - adjustedCloseInDatabase)/currentAdjustedValueFromSource); + if(absoluteRelativeDifference>ConstantsProvider.MaxRelativeDifferenceForAdjustedValues) + isAdjustedCloseChanged = true; + return isAdjustedCloseChanged; + } + catch(Exception ex) + { + string notUsed = ex.ToString(); + return isAdjustedCloseChanged; + } + } + #region GetHashValue private string getHashValue_getQuoteString_getRowString_getSingleValueString( Object value ) |
|
From: Marco M. <mi...@us...> - 2004-04-17 14:01:25
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2782/b2_DataAccess Modified Files: SqlExecutor.cs Log Message: Added and modified some methods in Quotes and SqlExecutor Index: SqlExecutor.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/SqlExecutor.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SqlExecutor.cs 21 Mar 2004 16:10:14 -0000 1.1 --- SqlExecutor.cs 17 Apr 2004 14:01:16 -0000 1.2 *************** *** 25,31 **** public static void ExecuteNonQuery( string SqlNonQuery ) { ! OleDbCommand oleDbCommand = new OleDbCommand( SqlNonQuery , ConnectionProvider.OleDbConnection ); ! oleDbCommand.ExecuteNonQuery(); } } --- 25,34 ---- public static void ExecuteNonQuery( string SqlNonQuery ) { ! if(ConnectionProvider.OleDbConnection.State != ConnectionState.Open) ! ConnectionProvider.OleDbConnection.Open(); ! OleDbCommand oleDbCommand = new OleDbCommand( SqlNonQuery , ConnectionProvider.OleDbConnection ); ! ! oleDbCommand.ExecuteNonQuery(); } } |
|
From: Marco M. <mi...@us...> - 2004-04-17 14:01:25
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2782/b1_ADT Modified Files: AssemblyInfo.cs Log Message: Added and modified some methods in Quotes and SqlExecutor Index: AssemblyInfo.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/AssemblyInfo.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** AssemblyInfo.cs 13 Oct 2003 21:57:16 -0000 1.1.1.1 --- AssemblyInfo.cs 17 Apr 2004 14:01:16 -0000 1.2 *************** *** 14,18 **** [assembly: AssemblyCopyright("")] [assembly: AssemblyTrademark("")] ! [assembly: AssemblyCulture("")] // --- 14,18 ---- [assembly: AssemblyCopyright("")] [assembly: AssemblyTrademark("")] ! [assembly: AssemblyCulture("")] // |
|
From: Marco M. <mi...@us...> - 2004-04-17 13:59:38
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2273/b2_DataAccess/Tables Added Files: TickerDataTable.cs Tickers.cs Log Message: Added new classes to access tickers --- NEW FILE: Tickers.cs --- /* QuantDownloader - Quantitative Finance Library Tickers.cs Copyright (C) 2003 Marco Milletti 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 QuantProject.DataAccess; namespace QuantProject.DataAccess.Tables { /// <summary> /// Class to access the Tickers table /// </summary> public class Tickers { private TickerDataTable tickerDataTable; private static TickerDataTable clipboard; private int count; public Tickers() { this.tickerDataTable = (TickerDataTable)SqlExecutor.GetDataTable("SELECT * FROM tickers"); this.count = this.Table.Rows.Count; } /// <summary> /// Ticker Table containing tickers to use like a clipboard /// </summary> public static TickerDataTable Clipboard { get { return Tickers.clipboard; } set { Tickers.clipboard = value; } } /// <summary> /// Table containing all records of the DB table "tickers" /// </summary> public TickerDataTable Table { get { return this.tickerDataTable; } } /// <summary> /// Number of tickers in tickers table /// </summary> public int Count { get { return this.count; } } public static DataTable GetTableOfFilteredTickers(string tickerSymbolIsLike, string tickerCompanyNameIsLike) { string sqlSelectString = Tickers.buildSqlSelectString(tickerSymbolIsLike, tickerCompanyNameIsLike); return SqlExecutor.GetDataTable(sqlSelectString); } public static DataTable GetTableOfFilteredTickers(string tickerSymbolIsLike, string tickerCompanyNameIsLike, string firstOperatorInHavingStatement, DateTime firstQuoteDate, string secondOperatorInHavingStatement, DateTime lastQuoteDate) { string sqlSelectString = Tickers.buildSqlSelectString(tickerSymbolIsLike, tickerCompanyNameIsLike, firstOperatorInHavingStatement, firstQuoteDate, secondOperatorInHavingStatement, lastQuoteDate); return SqlExecutor.GetDataTable(sqlSelectString); } #region buildSqlSelectString private static string buildSqlSelectString(string tickerSymbolIsLike, string tickerCompanyNameIsLike) { string sqlSelectString = ""; sqlSelectString = "SELECT tiTicker, tiCompanyName " + "FROM tickers WHERE tiTicker LIKE '" + tickerSymbolIsLike + "' " + "AND tiCompanyName LIKE '" + tickerCompanyNameIsLike + "'"; return sqlSelectString; } private static string buildSqlSelectString(string tickerSymbolIsLike, string tickerCompanyNameIsLike, string firstOperatorInHavingStatement, DateTime firstQuoteDate, string secondOperatorInHavingStatement, DateTime lastQuoteDate) { string sqlSelectString = ""; if(firstQuoteDate.CompareTo(lastQuoteDate)>0) throw new Exception("Last Date can't be previous of First date!"); sqlSelectString = "SELECT tiTicker, tiCompanyName, Min(quotes.quDate) AS FirstQuote, Max(quotes.quDate) AS LastQuote " + "FROM quotes INNER JOIN tickers ON quotes.quTicker = tickers.tiTicker " + "WHERE tiTicker LIKE '" + tickerSymbolIsLike + "' " + "AND tiCompanyName LIKE '" + tickerCompanyNameIsLike + "' " + "GROUP BY tickers.tiTicker, tickers.tiCompanyName " + "HAVING Min(quotes.quDate)" + firstOperatorInHavingStatement + SQLBuilder.GetDateConstant(firstQuoteDate) + "AND Max(quotes.quDate)" + secondOperatorInHavingStatement + SQLBuilder.GetDateConstant(lastQuoteDate); return sqlSelectString; } #endregion } } --- NEW FILE: TickerDataTable.cs --- /* QuantDownloader - Quantitative Finance Library TickerDataTable.cs Copyright (C) 2003 Marco Milletti 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; namespace QuantProject.DataAccess.Tables { /// <summary> /// The DataTable where to store tickers. /// It has the same structure of DB's table and it contains static string fields /// providing the name of the corresponding table's field /// NOTE: Static fields are intended to be used with intellisense /// </summary> public class TickerDataTable : DataTable { // these static fields provide field name in the database table // They are intended to be used through intellisense when necessary static string tiTicker = "tiTicker"; static string tiCompanyName = "tiCompanyName"; public TickerDataTable() { this.setStructure(); } private void setStructure() { DataColumn tiTicker = new DataColumn(TickerDataTable.tiTicker, System.Type.GetType("System.String")); tiTicker.Unique = true; tiTicker.AllowDBNull = false; DataColumn tiCompanyName = new DataColumn(TickerDataTable.tiCompanyName, System.Type.GetType("System.String")); this.Columns.Add(tiTicker); this.Columns.Add(tiCompanyName); } } } |
|
From: Marco M. <mi...@us...> - 2004-04-17 13:49:32
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32326/b1_ADT Modified Files: ConstantsProvider.cs Log Message: Added new constants for the hole project Index: ConstantsProvider.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/ConstantsProvider.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ConstantsProvider.cs 28 Mar 2004 20:06:50 -0000 1.1 --- ConstantsProvider.cs 17 Apr 2004 13:49:24 -0000 1.2 *************** *** 16,19 **** --- 16,23 ---- public static int SuspiciousRatio = 3; public static int PrecedingDaysForVisualValidation = 20; + public static DateTime InitialDateTimeForDownload = new DateTime(1985,1,1); + public static int TimeOutValue = 15000; + public static int NumberOfCheckToPerformOnAdjustedValues = 3; + public static double MaxRelativeDifferenceForAdjustedValues = 0.0005; } } |
|
From: Glauco S. <gla...@us...> - 2004-04-01 16:08:17
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/Validate/Validators In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13403/Downloader/Validate/Validators Modified Files: RangeToRangeValidator.cs Log Message: Now, a row is not suspicious if it has already been visually validated Index: RangeToRangeValidator.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/Validate/Validators/RangeToRangeValidator.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RangeToRangeValidator.cs 24 Mar 2004 18:27:52 -0000 1.1 --- RangeToRangeValidator.cs 1 Apr 2004 15:56:18 -0000 1.2 *************** *** 1,5 **** --- 1,7 ---- using System; + using System.Collections; using System.Data; using QuantProject.ADT.Histories; + using QuantProject.DataAccess.Tables; using QuantProject.Applications.Downloader.Validate; *************** *** 14,17 **** --- 16,21 ---- private double suspiciousRatio = 3; + private ArrayList rangeToRangeVisuallyValidated; + public double SuspiciousRatio { *************** *** 46,56 **** Convert.ToDouble( this.dataTableToBeValidated.Rows[ localCurrentRowIndex ][ "quAdjustedClose" ] ) / Convert.ToDouble( this.dataTableToBeValidated.Rows[ localCurrentRowIndex ][ "quClose" ] ); - // double previousRange = - // ( Convert.ToDouble( this.dataTableToBeValidated.Rows[ localCurrentRowIndex - 1 ][ "quHigh" ] ) - - // Convert.ToDouble( this.dataTableToBeValidated.Rows[ localCurrentRowIndex - 1 ][ "quLow" ] ) ) * - // Convert.ToDouble( this.dataTableToBeValidated.Rows[ localCurrentRowIndex - 1 ][ "quAdjustedClose" ] ) / - // Convert.ToDouble( this.dataTableToBeValidated.Rows[ localCurrentRowIndex - 1 ][ "quClose" ] ); - // rangeToRange.Add( this.dataTableToBeValidated.Rows[ localCurrentRowIndex ][ "quDate" ] , - // currentRange - previousRange ); rangeToRange.Add( this.dataTableToBeValidated.Rows[ localCurrentRowIndex ][ "quDate" ] , currentRange ); localCurrentRowIndex++; --- 50,53 ---- *************** *** 61,67 **** DataRow quoteRow , double currentValue , double averageValue ) { ! if ( Math.Abs( currentValue / averageValue ) > this.suspiciousRatio ) // the current close to close value is suspiciously larger // than the average close to close ratio this.SuspiciousDataRow( this , new SuspiciousDataRowEventArgs( quoteRow , ValidationWarning.SuspiciousRangeToRangeRatio ) ); --- 58,66 ---- DataRow quoteRow , double currentValue , double averageValue ) { ! if ( ( Math.Abs( currentValue / averageValue ) > this.suspiciousRatio ) && ! ( this.rangeToRangeVisuallyValidated.IndexOf( quoteRow[ "quDate" ] ) < 0 ) ) // the current close to close value is suspiciously larger // than the average close to close ratio + // and it has not been visually validated yet this.SuspiciousDataRow( this , new SuspiciousDataRowEventArgs( quoteRow , ValidationWarning.SuspiciousRangeToRangeRatio ) ); *************** *** 76,83 **** try { - // validate_currentTicker_withHistories_validateRow( - // this.dataTableToBeValidated.Rows[ i ] , - // (double)rangeToRange.GetByIndex( i - currentTickerStartingRowIndex ) , - // (double)rangeToRangeMovingAverage.GetByIndex( i - currentTickerStartingRowIndex ) ); validate_currentTicker_withHistories_validateRow( this.dataTableToBeValidated.Rows[ i ] , --- 75,78 ---- *************** *** 92,95 **** --- 87,91 ---- private int validate_currentTicker( string currentTicker , int currentTickerStartingRowIndex ) { + this.rangeToRangeVisuallyValidated = VisuallyValidatedQuotes.GetRangeToRangeValidated( currentTicker ); History rangeToRange = new History(); History rangeToRangeMovingAverage; |
|
From: Glauco S. <gla...@us...> - 2004-04-01 15:55:03
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10666/b2_DataAccess/Tables Modified Files: VisuallyValidatedQuotes.cs Log Message: Added the GetRangeToRangeValidated method Index: VisuallyValidatedQuotes.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables/VisuallyValidatedQuotes.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** VisuallyValidatedQuotes.cs 28 Mar 2004 20:10:05 -0000 1.1 --- VisuallyValidatedQuotes.cs 1 Apr 2004 15:43:02 -0000 1.2 *************** *** 4,7 **** --- 4,8 ---- using QuantProject.DataAccess; + using System.Collections; namespace QuantProject.DataAccess.Tables { *************** *** 17,20 **** --- 18,35 ---- // } + + + /// <summary> + /// Returns the hash value to be stored/read into/from the visuallyValidatedQuotes table + /// </summary> + /// <param name="quoteDate">Date whose neighborhood quotes are to be hashed</param> + /// <returns></returns> + private static string getHashValue( Quotes quotes , DateTime quoteDate ) + { + return quotes.GetHashValue( + quotes.GetPrecedingDate( quoteDate , ConstantsProvider.PrecedingDaysForVisualValidation ) , + quotes.GetFollowingDate( quoteDate , ConstantsProvider.PrecedingDaysForVisualValidation ) ); + } + /// <summary> /// writes to the database the visual validation of the Close to Close suspicious ratios *************** *** 33,39 **** new OleDbSingleTableAdapter( "select * from visuallyValidatedQuotes where 1=2" ); ! string hashValue = quotes.GetHashValue( ! quotes.GetPrecedingDate( quoteDate , ConstantsProvider.PrecedingDaysForVisualValidation ) , ! quotes.GetFollowingDate( quoteDate , ConstantsProvider.PrecedingDaysForVisualValidation ) ); oleDbSingleTableAdapter.DataTable.Rows.Add( oleDbSingleTableAdapter.DataTable.NewRow() ); oleDbSingleTableAdapter.DataTable.Rows[ 0 ][ "vvTicker" ] = quotes.Ticker; --- 48,52 ---- new OleDbSingleTableAdapter( "select * from visuallyValidatedQuotes where 1=2" ); ! string hashValue = getHashValue( quotes , quoteDate ); oleDbSingleTableAdapter.DataTable.Rows.Add( oleDbSingleTableAdapter.DataTable.NewRow() ); oleDbSingleTableAdapter.DataTable.Rows[ 0 ][ "vvTicker" ] = quotes.Ticker; *************** *** 51,54 **** --- 64,86 ---- } } + + /// <summary> + /// Returns the list of validated quote dates for the given ticker + /// </summary> + /// <param name="ticker">Instrument ticker whose validated quote dates are to be found</param> + /// <returns></returns> + public static ArrayList GetRangeToRangeValidated( string ticker ) + { + ArrayList tickers = new ArrayList(); + Quotes quotes = new Quotes( ticker ); + DataTable validatedQuotes = + SqlExecutor.GetDataTable( "select * from visuallyValidatedQuotes where vvTicker='" + ticker + "'" ); + foreach ( DataRow dataRow in validatedQuotes.Rows ) + if ( (string)dataRow[ "vvHashValue" ] == getHashValue( quotes , (DateTime)dataRow[ "vvDate" ] ) ) + // the current quote date had been visually validated with respect to the neighborhood quotes + tickers.Add( dataRow[ "vvDate" ] ); + /// TO DO !!! add else branch to raise event 'broken hash value' + return tickers; + } } } |
|
From: Glauco S. <gla...@us...> - 2004-03-28 22:23:08
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20378/Downloader Modified Files: Downloader.csproj Log Message: visualValidatedTickers table is dropped and visualValidatedQuotes is handled now Index: Downloader.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/Downloader.csproj,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Downloader.csproj 24 Mar 2004 18:29:51 -0000 1.14 --- Downloader.csproj 28 Mar 2004 22:11:44 -0000 1.15 *************** *** 241,244 **** --- 241,249 ---- /> <File + RelPath = "QuotesEditor\QuotesChart.resx" + DependentUpon = "QuotesChart.cs" + BuildAction = "EmbeddedResource" + /> + <File RelPath = "QuotesEditor\QuotesEditor.cs" SubType = "Form" |
|
From: Glauco S. <gla...@us...> - 2004-03-28 22:23:08
|
Update of /cvsroot/quantproject/QuantDownloader In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20378 Modified Files: QuantDownloader.suo Log Message: visualValidatedTickers table is dropped and visualValidatedQuotes is handled now Index: QuantDownloader.suo =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/QuantDownloader.suo,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 Binary files /tmp/cvsDTVvKE and /tmp/cvsXACQk9 differ |
|
From: Glauco S. <gla...@us...> - 2004-03-28 22:14:26
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/QuotesEditor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18586/Downloader/QuotesEditor Modified Files: VisualValidationTabPage.cs Log Message: ConstantsProvider.PrecedingDaysForVisualValidation is used instead of the 20 constant Index: VisualValidationTabPage.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/QuotesEditor/VisualValidationTabPage.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** VisualValidationTabPage.cs 21 Mar 2004 16:45:52 -0000 1.1 --- VisualValidationTabPage.cs 28 Mar 2004 22:03:02 -0000 1.2 *************** *** 2,5 **** --- 2,6 ---- using System.Drawing; using System.Windows.Forms; + using QuantProject.ADT; using QuantProject.Presentation.Charting; *************** *** 56,59 **** --- 57,61 ---- (DateTime)this.VisualValidationDataGrid[ this.VisualValidationDataGrid.CurrentRowIndex , 0 ]; this.VisualValidationDataGrid.Height = this.Height - 10; + this.VisualValidationChart.PrecedingDays = ConstantsProvider.PrecedingDaysForVisualValidation; this.VisualValidationChart.Width = this.Width - this.VisualValidationDataGridWidth - 5; this.VisualValidationChart.Height = this.Height - 10; |