[Quantproject-developers] QuantDownloader/Downloader WebDownloader.cs, 1.20, 1.21 TickerDownloader.
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2006-07-02 20:04:21
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv17725/Downloader Modified Files: WebDownloader.cs TickerDownloader.cs Log Message: It is now possible to download only a single quote for a specified date. Fixed a serious bug when the overWrite option is selected: quotes are deleted from DB only for corresponding dates downloaded from source. Index: WebDownloader.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/WebDownloader.cs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** WebDownloader.cs 8 Apr 2006 13:54:10 -0000 1.20 --- WebDownloader.cs 2 Jul 2006 20:04:15 -0000 1.21 *************** *** 53,56 **** --- 53,58 ---- private System.Windows.Forms.ToolTip toolTip1; internal System.Windows.Forms.CheckBox checkBoxDownloadOnlyAfterCloseToCloseCheck; + private System.Windows.Forms.DateTimePicker dateTimePickerSelectedDate; + private System.Windows.Forms.RadioButton radioButtonDownloadSingleQuote; private System.ComponentModel.IContainer components; *************** *** 155,158 **** --- 157,162 ---- this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.checkBoxDownloadOnlyAfterCloseToCloseCheck = new System.Windows.Forms.CheckBox(); + this.dateTimePickerSelectedDate = new System.Windows.Forms.DateTimePicker(); + this.radioButtonDownloadSingleQuote = new System.Windows.Forms.RadioButton(); ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit(); this.groupBoxWebDownloaderOptions.SuspendLayout(); *************** *** 337,340 **** --- 341,346 ---- // this.groupBoxUpdateDatabaseOptions.Controls.AddRange(new System.Windows.Forms.Control[] { + this.radioButtonDownloadSingleQuote, + this.dateTimePickerSelectedDate, this.radioButtonDownloadOnlyAfterMax, this.radioButtonDownloadBeforeMinAndAfterMax, *************** *** 361,378 **** // this.radioButtonDownloadBeforeMinAndAfterMax.Enabled = false; ! this.radioButtonDownloadBeforeMinAndAfterMax.Location = new System.Drawing.Point(16, 56); this.radioButtonDownloadBeforeMinAndAfterMax.Name = "radioButtonDownloadBeforeMinAndAfterMax"; ! this.radioButtonDownloadBeforeMinAndAfterMax.Size = new System.Drawing.Size(256, 32); this.radioButtonDownloadBeforeMinAndAfterMax.TabIndex = 2; this.radioButtonDownloadBeforeMinAndAfterMax.Text = "Download only quotes before first quote and after last quote (TO BE TESTED)"; // // radioButtonOverWriteNo // this.radioButtonOverWriteNo.Enabled = false; ! this.radioButtonOverWriteNo.Location = new System.Drawing.Point(16, 96); this.radioButtonOverWriteNo.Name = "radioButtonOverWriteNo"; ! this.radioButtonOverWriteNo.Size = new System.Drawing.Size(256, 32); this.radioButtonOverWriteNo.TabIndex = 1; this.radioButtonOverWriteNo.Text = "Download all quotes, adding to database only the missing ones (TO BE TESTED)"; // // radioButtonOverWriteYes --- 367,386 ---- // this.radioButtonDownloadBeforeMinAndAfterMax.Enabled = false; ! this.radioButtonDownloadBeforeMinAndAfterMax.Location = new System.Drawing.Point(200, 104); this.radioButtonDownloadBeforeMinAndAfterMax.Name = "radioButtonDownloadBeforeMinAndAfterMax"; ! this.radioButtonDownloadBeforeMinAndAfterMax.Size = new System.Drawing.Size(40, 32); this.radioButtonDownloadBeforeMinAndAfterMax.TabIndex = 2; this.radioButtonDownloadBeforeMinAndAfterMax.Text = "Download only quotes before first quote and after last quote (TO BE TESTED)"; + this.radioButtonDownloadBeforeMinAndAfterMax.Visible = false; // // radioButtonOverWriteNo // this.radioButtonOverWriteNo.Enabled = false; ! this.radioButtonOverWriteNo.Location = new System.Drawing.Point(240, 104); this.radioButtonOverWriteNo.Name = "radioButtonOverWriteNo"; ! this.radioButtonOverWriteNo.Size = new System.Drawing.Size(40, 32); this.radioButtonOverWriteNo.TabIndex = 1; this.radioButtonOverWriteNo.Text = "Download all quotes, adding to database only the missing ones (TO BE TESTED)"; + this.radioButtonOverWriteNo.Visible = false; // // radioButtonOverWriteYes *************** *** 413,416 **** --- 421,443 ---- "ed values respect current close to close ratio "); // + // dateTimePickerSelectedDate + // + this.dateTimePickerSelectedDate.Enabled = false; + this.dateTimePickerSelectedDate.Location = new System.Drawing.Point(24, 96); + this.dateTimePickerSelectedDate.Name = "dateTimePickerSelectedDate"; + this.dateTimePickerSelectedDate.Size = new System.Drawing.Size(184, 20); + this.dateTimePickerSelectedDate.TabIndex = 7; + // + // radioButtonDownloadSingleQuote + // + this.radioButtonDownloadSingleQuote.Checked = true; + this.radioButtonDownloadSingleQuote.Location = new System.Drawing.Point(16, 56); + this.radioButtonDownloadSingleQuote.Name = "radioButtonDownloadSingleQuote"; + this.radioButtonDownloadSingleQuote.Size = new System.Drawing.Size(256, 24); + this.radioButtonDownloadSingleQuote.TabIndex = 8; + this.radioButtonDownloadSingleQuote.TabStop = true; + this.radioButtonDownloadSingleQuote.Text = "Download single quote"; + this.radioButtonDownloadSingleQuote.CheckedChanged += new System.EventHandler(this.radioButtonDownloadSingleQuote_CheckedChanged); + // // WebDownloader // *************** *** 757,760 **** --- 784,795 ---- this.downloadThread.Abort(); } + + private void radioButtonDownloadSingleQuote_CheckedChanged(object sender, System.EventArgs e) + { + if(this.radioButtonDownloadSingleQuote.Checked) + this.dateTimePickerSelectedDate.Enabled = true; + else + this.dateTimePickerSelectedDate.Enabled = false; + } public bool IsComputeCloseToCloseRatioSelected *************** *** 810,813 **** --- 845,862 ---- } } + public bool IsSingleQuoteSelected + { + get + { + return this.radioButtonDownloadSingleQuote.Checked; + } + } + public DateTime SelectedDateForSingleQuote + { + get + { + return this.dateTimePickerSelectedDate.Value; + } + } } } Index: TickerDownloader.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/TickerDownloader.cs,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** TickerDownloader.cs 8 Apr 2006 13:54:10 -0000 1.19 --- TickerDownloader.cs 2 Jul 2006 20:04:15 -0000 1.20 *************** *** 251,266 **** DateTime currBeginDate = new DateTime(); currBeginDate = startDate; ! while ( currBeginDate < endDate ) { ! DateTime currEndDate = new DateTime(); ! if ( DateTime.Compare( DateTime.Today , currBeginDate.AddDays( numDaysOfTimeFrame ) ) < 0 ) ! currEndDate = DateTime.Today; ! else ! currEndDate = currBeginDate.AddDays( numDaysOfTimeFrame ); ! this.importTickerForCurrentTimeFrame ( currBeginDate , currEndDate ); ! currBeginDate = currEndDate.AddDays( 1 ); } - return this.downloadedValuesFromSource; - } --- 251,279 ---- DateTime currBeginDate = new DateTime(); currBeginDate = startDate; ! if(currBeginDate == endDate) ! //just a single quote requested: initial date is 10 day before end date ! //just for close to close direct computation { ! this.importTickerForCurrentTimeFrame ( currBeginDate.AddDays(-10) , endDate ); ! int rowsDownloaded = this.downloadedValuesFromSource.Rows.Count; ! for(int i = rowsDownloaded-1;i>1 ;i--) ! //for the computation of ctc ratio it is necessary to have previous quote ! this.downloadedValuesFromSource.Rows.RemoveAt(i); ! return this.downloadedValuesFromSource; ! } ! else ! { ! while ( currBeginDate < endDate ) ! { ! DateTime currEndDate = new DateTime(); ! if ( DateTime.Compare( DateTime.Today , currBeginDate.AddDays( numDaysOfTimeFrame ) ) < 0 ) ! currEndDate = DateTime.Today; ! else ! currEndDate = currBeginDate.AddDays( numDaysOfTimeFrame ); ! this.importTickerForCurrentTimeFrame ( currBeginDate , currEndDate ); ! currBeginDate = currEndDate.AddDays( 1 ); ! } ! return this.downloadedValuesFromSource; } } *************** *** 348,352 **** this.downloadedValuesFromSource = this.getTableOfDownloadedValues(Quotes.GetEndDate(this.p_quTicker), DateTime.Now); ! this.commitDownloadedValuesToDatabase(); } } --- 361,365 ---- this.downloadedValuesFromSource = this.getTableOfDownloadedValues(Quotes.GetEndDate(this.p_quTicker), DateTime.Now); ! this.commitDownloadedValuesToDatabase(); } } *************** *** 374,377 **** --- 387,396 ---- } + private void downloadTickerForTheSelectedDate(DateTime date) + { + this.startDate = date; + this.endDate = date; + this.checkForNewAdjustedAndContinueOrStop(); + } private void downloadTickerAfterLastQuote() *************** *** 399,403 **** { if(this.p_myForm.IsOverWriteYesSelected) ! Quotes.Delete(this.p_quTicker); if(this.p_myForm.IsComputeCloseToCloseRatioSelected) QuantProject.DataAccess.Tables.Quotes.ComputeCloseToCloseValues(this.downloadedValuesFromSource); --- 418,425 ---- { if(this.p_myForm.IsOverWriteYesSelected) ! { ! foreach(DataRow row in this.downloadedValuesFromSource.Rows) ! Quotes.Delete(this.p_quTicker, (DateTime)row["quDate"]); ! } if(this.p_myForm.IsComputeCloseToCloseRatioSelected) QuantProject.DataAccess.Tables.Quotes.ComputeCloseToCloseValues(this.downloadedValuesFromSource); *************** *** 452,455 **** --- 474,485 ---- this.resetAndImportTicker(); } + else if(this.p_myForm.IsSingleQuoteSelected) + { + if(Quotes.GetTickerQuotes(this.p_quTicker, + this.p_myForm.SelectedDateForSingleQuote, + this.p_myForm.SelectedDateForSingleQuote).Rows.Count == 0) + //there's no quote for the ticker at the given date + this.downloadTickerForTheSelectedDate(this.p_myForm.SelectedDateForSingleQuote); + } Cursor.Current = Cursors.Default; |