Home  Search  Register  Login  Recent Posts

Information on DTN's Industries:
DTN Oil & Gas | DTN Trading | DTN Agriculture | DTN Weather
Follow DTNMarkets on Twitter
DTN.IQ/IQFeed on Twitter
DTN News and Analysis on Twitter
»Forums Index »Archive (2017 and earlier) »IQFeed Developer Support »Problems retrieving History in C# .NET via COM
Author Topic: Problems retrieving History in C# .NET via COM (6 messages, Page 1 of 1)

nelsonandara
-Interested User-
Posts: 3
Joined: Aug 21, 2006


Posted: Aug 21, 2006 12:21 AM          Msg. 1 of 6
I created a program based on a posting from January 2005 from Dennis. THey program compiles and runs, everything works well when requesting real time Level 1 data. However, when I request Tick History using RequestTickHistory, the call does not cause a runtime error, but the event handlers associated with this call ( TickProgress or TickCompleted ) do not fire.

In this example I am using the IQFEED_DEMO application name. I have tried replacing with my own credentials and the symptoms are the same.

I have been able to see that the connection is registered by the IQConnect Manager. I am appending the frmMain.cs contents of my project. Any help on this issue will be greatly appreciated.

Regards,

Nelson Andara

// Sample application to request level1 and History via COM
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using DTNHISTORYLOOKUPLib;

namespace CSharpLevel1Com
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class frmMain : System.Windows.Forms.Form
{
string strSymbol = "";
private bool reporting_history = false;
private System.Windows.Forms.Label lblSymbol;
private System.Windows.Forms.TextBox txtSymbol;
private System.Windows.Forms.Button cmdGetData;
private System.Windows.Forms.ListBox lstData;
private AxIQFEEDYLib.AxIQFeedY axIQFeedY1;
private HistoryLookupClass m_HistoryLookupClass;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public frmMain()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//

this.m_HistoryLookupClass = new HistoryLookupClass();
this.m_HistoryLookupClass.MinuteCompleted += new _IHistoryLookupEvents_MinuteCompletedEventHandler(m_HistoryLookupClass_MinuteCompleted);
this.m_HistoryLookupClass.TickCompleted += new _IHistoryLookupEvents_TickCompletedEventHandler(m_HistoryLookupClass_TickCompleted);
this.m_HistoryLookupClass.TickProgress += new _IHistoryLookupEvents_TickProgressEventHandler(m_HistoryLookupClass_TickProgress);
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}

this.axIQFeedY1.RemoveClientApp();
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmMain));
this.lblSymbol = new System.Windows.Forms.Label();
this.txtSymbol = new System.Windows.Forms.TextBox();
this.cmdGetData = new System.Windows.Forms.Button();
this.lstData = new System.Windows.Forms.ListBox();
this.axIQFeedY1 = new AxIQFEEDYLib.AxIQFeedY();
((System.ComponentModel.ISupportInitialize)(this.axIQFeedY1)).BeginInit();
this.SuspendLayout();
//
// lblSymbol
//
this.lblSymbol.Location = new System.Drawing.Point(8, 8);
this.lblSymbol.Name = "lblSymbol";
this.lblSymbol.Size = new System.Drawing.Size(48, 16);
this.lblSymbol.TabIndex = 0;
this.lblSymbol.Text = "Symbol: ";
//
// txtSymbol
//
this.txtSymbol.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
this.txtSymbol.Location = new System.Drawing.Point(72, 8);
this.txtSymbol.Name = "txtSymbol";
this.txtSymbol.Size = new System.Drawing.Size(136, 20);
this.txtSymbol.TabIndex = 1;
this.txtSymbol.Text = "TXTSYMBOL";
//
// cmdGetData
//
this.cmdGetData.Location = new System.Drawing.Point(216, 8);
this.cmdGetData.Name = "cmdGetData";
this.cmdGetData.Size = new System.Drawing.Size(88, 24);
this.cmdGetData.TabIndex = 2;
this.cmdGetData.Text = "&Get Data";
this.cmdGetData.Click += new System.EventHandler(this.cmdGetData_Click);
//
// lstData
//
this.lstData.HorizontalScrollbar = true;
this.lstData.Location = new System.Drawing.Point(8, 40);
this.lstData.Name = "lstData";
this.lstData.Size = new System.Drawing.Size(656, 316);
this.lstData.TabIndex = 3;
//
// axIQFeedY1
//
this.axIQFeedY1.Enabled = true;
this.axIQFeedY1.Location = new System.Drawing.Point(408, 16);
this.axIQFeedY1.Name = "axIQFeedY1";
this.axIQFeedY1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axIQFeedY1.OcxState")));
this.axIQFeedY1.Size = new System.Drawing.Size(100, 50);
this.axIQFeedY1.TabIndex = 4;
this.axIQFeedY1.Visible = false;
this.axIQFeedY1.SystemMessage += new AxIQFEEDYLib._DIQFeedYEvents_SystemMessageEventHandler(this.IQFeed_SystemMessage);
this.axIQFeedY1.SummaryMessage += new AxIQFEEDYLib._DIQFeedYEvents_SummaryMessageEventHandler(this.IQFeed_SummaryMessage);
this.axIQFeedY1.FundamentalMessage += new AxIQFEEDYLib._DIQFeedYEvents_FundamentalMessageEventHandler(this.IQFeed_FundamentalMessage);
this.axIQFeedY1.TimeStampMessage += new AxIQFEEDYLib._DIQFeedYEvents_TimeStampMessageEventHandler(this.IQFeed_TimeStampMessage);
this.axIQFeedY1.QuoteMessage += new AxIQFEEDYLib._DIQFeedYEvents_QuoteMessageEventHandler(this.IQFeed_QuoteMessage);

//
// frmMain
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(672, 364);
this.Controls.Add(this.axIQFeedY1);
this.Controls.Add(this.lstData);
this.Controls.Add(this.cmdGetData);
this.Controls.Add(this.txtSymbol);
this.Controls.Add(this.lblSymbol);
this.MaximizeBox = false;
this.Name = "frmMain";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "frmMain";
this.Load += new System.EventHandler(this.frmMain_Load);
((System.ComponentModel.ISupportInitialize)(this.axIQFeedY1)).EndInit();
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new frmMain());
}

//Form load handler, register client app here
private void frmMain_Load(object sender, System.EventArgs e)
{
this.Text = "CSharp Level1 COM";
this.txtSymbol.Text = "";
this.txtSymbol.Enabled = false;

string strName = "IQFEED_DEMO";
string strVersion = "1.0";
string strKey = "1.0";

this.axIQFeedY1.RegisterClientApp( ref strName, ref strVersion, ref strKey );
}

//Watch symbol when the get data button is clicked
private void cmdGetData_Click(object sender, System.EventArgs e)
{
string strSymbol = txtSymbol.Text.Trim();
if( strSymbol != "" )
{
axIQFeedY1.WatchSymbol( ref strSymbol );
}
}

//Received fundamental message, add to list box
private void IQFeed_FundamentalMessage(object sender, AxIQFEEDYLib._DIQFeedYEvents_FundamentalMessageEvent e)
{
string strData = e.strFundamentalData;
lstData.Items.Insert(0,strData);
}

//Received summary message, add to list box
private void IQFeed_SummaryMessage(object sender, AxIQFEEDYLib._DIQFeedYEvents_SummaryMessageEvent e)
{
string strData = e.strSummaryData;
lstData.Items.Insert(0,strData);
}

//Received quote message, add to list box
private void IQFeed_QuoteMessage(object sender, AxIQFEEDYLib._DIQFeedYEvents_QuoteMessageEvent e)
{
string strData = e.strQuoteData;
lstData.Items.Insert(0,strData);
}

// First Time you receive the System message indicates you are connected.
private void IQFeed_SystemMessage(object sender,AxIQFEEDYLib._DIQFeedYEvents_SystemMessageEvent e)
{
string strData = e.strSystemData ;
txtSymbol.Enabled = true;
lstData.Items.Insert(0,strData);
}

//Received Time Stamp message, add to list box, request history
private void IQFeed_TimeStampMessage( object sender, AxIQFEEDYLib._DIQFeedYEvents_TimeStampMessageEvent e)
{
string strData = e.strTimeStampData;
lstData.Items.Add(strData);
strSymbol = txtSymbol.Text.Trim();
if ( strSymbol != "" )
{
this.m_HistoryLookupClass.RequestTickHistory(strSymbol,1);
}
Console.Write(" TImeStampMessage Received\n");
}
private void m_HistoryLookupClass_TickProgress( int iTicksReceived)
{
Console.Write( "{0} ticks received ",iTicksReceived);
}
private void m_HistoryLookupClass_TickCompleted( int iTicksReceived,
object Time,
object Ask,
object Bid,
object Volume,
object TradePrice,
object TradeSize)
{
if(!reporting_history)
{
reporting_history = true;
DateTime[] m_TimeArray = (DateTime[]) Time;
double[] m_AskArray = (double[]) Ask;
double[] m_BidArray = (double[]) Bid;
int[] m_VolumeArray = (int[]) Volume;
double[] m_TradePriceArray = (double[]) TradePrice;
int[] m_TradeSizeArray = (int[]) TradeSize;

for (long i = iTicksReceived; i>0; i--)
{
Console.Write("Time: {0}, ", m_TimeArray.GetValue(i));
Console.Write("Ask: {0,8:F}, ",m_AskArray.GetValue(i));
Console.Write("Bid: {0,8:F}, ",m_BidArray.GetValue(i));
Console.Write("Volume:{0,6}, ", m_VolumeArray.GetValue(i));
Console.Write("Trade Price: {0,8:F}, ",m_TradePriceArray.GetValue(i));
Console.Write("Trade Size: {0,6}, ",m_TradeSizeArray.GetValue(i));
}
}
Console.Write("TickCompleted executed\n");
}

private void m_HistoryLookupClass_MinuteCompleted( int lMinutesLoaded,
object Time,
object Open,
object Close,
object High,
object Low,
object Volume,
object IntVolume)
{
if (!reporting_history)
{
reporting_history = true;

DateTime[] m_TimeArray = (DateTime[]) Time;
double[] m_OpenArray = (double[]) Open;
double[] m_CloseArray = (double[]) Close;
double[] m_HighArray = (double[]) High;
double[] m_LowArray = (double[]) Low;
int[] m_VolumeArray = (int[]) Volume;
int[] m_IntVolumeArray = (int[]) IntVolume;

for(long i = lMinutesLoaded; i> 0; i--)
{
Console.Write("Time: {0}, ", m_TimeArray.GetValue(i));
Console.Write("Open: {0,8:F}, ",m_OpenArray.GetValue(i));
Console.Write("Close: {0,8:F}, ",m_CloseArray.GetValue(i));
Console.Write("High: {0,8:F}, ",m_HighArray.GetValue(i));
Console.Write("Low: {0,8:F}, ",m_LowArray.GetValue(i));
Console.Write("Volume:{0,6}, ", m_VolumeArray.GetValue(i));
Console.Write("IntVolume:{0,6}, ",m_IntVolumeArray.GetValue(i));
}
}
}
}
}

Nelson Andara
nelsonandara@comcast.net

DTN_Steve_S
-DTN Guru-
Posts: 2096
Joined: Nov 21, 2005


Posted: Aug 21, 2006 09:51 AM          Msg. 2 of 6
Hello Nelson,

Briefly scanning through this I do not see what is causing the issue. I have sent you a PM with the developer support email address, please email me a copy of your project so that we can start from the same code base (including project settings) while working on this issue.

nelsonandara
-Interested User-
Posts: 3
Joined: Aug 21, 2006


Posted: Aug 21, 2006 10:59 AM          Msg. 3 of 6
Hi Steve, thanks for your quick response. I noticed that the application started receiving History data as soon as the market opened. Are there scheduled times when port 9100 is down?

I will move forward with my implementation in terms of better multithreading and front end.

I look forward to more information on the availability of port 9100 for historic data feeds.

Regards,

Nelson

Nelson Andara
nelsonandara@comcast.net

DTN_Steve_S
-DTN Guru-
Posts: 2096
Joined: Nov 21, 2005


Posted: Aug 21, 2006 11:12 AM          Msg. 4 of 6
Historical data isnt restricted to market hours.

I suspect that the issue is more along the lines of what you were requesting. History requests work on calander days (not market days). What this means is if you requested 1 day of Tick data anytime between 12:00am (midnight) on friday night through market open today, you would not have gotten any results.

So in order to recieve friday's tick data today, you would need to request 4 days of tick history.

the same concepts apply to all other history requests

jfcantin
-Interested User-
Posts: 20
Joined: May 18, 2004


Posted: Aug 21, 2006 03:19 PM          Msg. 5 of 6
Receiving History error messages doesn't seem to work. If you register with the AbortedLoad event like this :
m_HistoryLookup.AbortedLoad += new _IHistoryLookupEvents_AbortedLoadEventHandler(OnAbortedLoad)

You get an exception. If you don't register it then you can't tell if you gave a wrong symbol.

Anybody got a workaround?

best,

Jean-Francois

nelsonandara
-Interested User-
Posts: 3
Joined: Aug 21, 2006


Posted: Aug 22, 2006 04:29 PM          Msg. 6 of 6
Hi Jean Francois,

I noticed that when receiving History messages, if you have anymore than one event registered at a time, you get an exception that apparently comes from COM, not the C# code. I would also like to have the abillity to register more than one event ( at least TickProgress and TickCompleted ) at the same time.

If anyone knows about a way to accomplish this in .NET, please share.

Nelson Andara
nelsonandara@comcast.net
 

 

Time: Sat September 7, 2024 7:50 PM CFBB v1.2.0 12 ms.
© AderSoftware 2002-2003