Join the 80,000 other DTN customers who enjoy the fastest, most reliable data available. There is no better value than DTN!

(Move your cursor to this area to pause scrolling)




"You are either overstaffed or people just don't have problems with your feed because customer support always answers the phone quickly." - Comment from Jay via Email
"After all the anxiety I had with my previous data provider it is a relief not to have to worry about data speed and integrity." - Comment from Eamonn
"Thanks for all of your help. Great customer service deserves to be recognized which one the reasons I've been a customer of DTN for over 10 years!" - Comment from Stuart
"DTN feed was the only feed that consistently matched Bloomberg feed for BID/ASK data verification work these past years......DTN feed is a must for my supply & demand based trading using Cumulative Delta" - Comment from Public Forum Post
"You have an excellent product !!!!!!" - Comment from Arely
"I ran your IQFeed DDE vs. my broker vs. a level II window for some slow-moving options. I would see the level II quote change, then your feed update instantaneously. My broker's DDE, however, would take as much as 30 seconds to update. I am not chasing milliseconds, but half a minute is unacceptable." - Comment from Rob
"Previously I was using *******. IQFeed is WAY more economical, and for my charting needs is just as good, if not better." - Comment from Public Forum Post
"Its working FABULOUSLY for me!! Holy cow...there has been so much I've been missing lately, and with this feed and Linnsoft software...I'm in the game now." - Comment from Chris R.
"IQFeed version 4 is a real screamer compared to anything else I have seen." - Comment from Tom
"IQ feed is brilliant. The support is mind-bending. What service!" - Comment from Public Forum Post
Home  Search  Register  Login  Blogs Recent Posts

Information on DTN's Industries:
DTN Oil & Gas | DTN Trading | DTN Agriculture | DTN Weather
Follow DTN_IQFeed on Twitter
DTN.IQ/IQFeed on Twitter
DTN News and Analysis on Twitter
»Forums Index »IQFeed Developer »IQFeed Developer Support »Open source IQFeed C# Socket Client now available supporting protocol 5.2
Author Topic: Open source IQFeed C# Socket Client now available supporting protocol 5.2 (9 messages, Page 1 of 1)

mathpaquette
-Interested User-
Posts: 12
Joined: May 18, 2018


Posted: May 18, 2018 06:41 AM          Msg. 1 of 9
Hello everyone,

I've developed and released to the open source community with the aim to be the more efficient, a C# IQFeed socket client. Have a look at the project. I'll develop all the features needed to support all the IQFeed functionalities.

https://github.com/mathpaquette/IQFeed.CSharpApiClient

Your feedbacks are welcome!
Mathieu

data_collector
-Interested User-
Posts: 4
Joined: Aug 9, 2018


Posted: Aug 9, 2018 09:59 AM          Msg. 2 of 9
Hi Mathieu,

Really appreciate your work. As a C# noob, I have a question:

In your historical example, you conclude with making a request and assigning it to ticksMessages. How can I view this in a data table format? I tried just viewing it via Console.WriteLine but it just seems to show the var like below:

System.Collections.Generic.List`1[IQFeed.CSharpApiClient.Lookup.Historical.Messages.TickMessage]


Thank you,
T

mathpaquette
-Interested User-
Posts: 12
Joined: May 18, 2018


Posted: Aug 9, 2018 04:45 PM          Msg. 3 of 9
Hi T,

Well, if you wish to see the result as a data table, I suggest you to use the Raw facade, i.e. lookupClient.Historical.Raw.ReqHistoryTickDatapointsAsync method and then open up the return filename in Excel as a CSV file.

The reason you it in that format its because I didnt override the ToString in the TickMessage class.

Please dont forget to star the project on github and you can also ask question over there!

Thank you,
Mathieu

AK786
-Interested User-
Posts: 21
Joined: Jul 17, 2018


Posted: Aug 9, 2018 05:30 PM          Msg. 4 of 9
data_collector, here is something i did to parse out the code from Matt P. I am storing Flat Files - you can write all teh data to a C# datatable object.

His code is awesome and has saved me 50+ hours - higher performance than the IQFeed examples IMO.

Also if there is bug, he serves us by fixing it in just a few hours if you send him an email


var tickData = await lookupClient.Historical.ReqHistoryTickTimeframeAsync(symbol, requestStartDate, requestEndDate, null, null, null, DataDirection.Oldest);

CreateTaskStoreTickMessages(symbol, tickData);



void CreateTaskStoreTickMessages(string symbol, IEnumerable<TickMessage> tickMessages)
{

Task.Factory.StartNew(() => StoreTickMessages(symbol, tickMessages, TickDirectory));
}

List<double> tickMessagesStoreRunTime = new List<double>();
object tickMessagesStoreLockObject = new object();
static string TickFileHeader = "Timestamp,Last,LastSize,TotalVolume,Bid,Ask,TickId,BasisForLast,TradeMarketCenter,TradeConditions";
void StoreTickMessages(string symbol, IEnumerable<TickMessage> tickMessages, string baseTickDirectory)
{
DateTime storeTickMessagesStartTime = DateTime.Now;

// All the Tick Data gets stored into "Date" Created Files By Symbol Name
List<TickMessage> tickMessagesCurrentDate = new List<TickMessage>();

DateTime previousDate = DateTime.MaxValue;
List<DateTime> datesProcessing = new List<DateTime>();

foreach (TickMessage message in tickMessages)
{
DateTime dateTime = message.Timestamp;
DateTime date = message.Timestamp.Date;

// New Date in Tick Messages
if (!datesProcessing.Contains(date))
{
datesProcessing.Add(date);

// Record Previous Date for the First Time
if (previousDate == DateTime.MaxValue)
{
previousDate = date;
}
else // Store the Previous Dates Data once New TimeStamp is triggered
{
StoreTickMessagesByDate(baseTickDirectory, previousDate, symbol, tickMessagesCurrentDate);

// Reset Data Structures
tickMessagesCurrentDate = new List<TickMessage>();

previousDate = date;
}
}

tickMessagesCurrentDate.Add(message);
}

// Store Data from Last Date
StoreTickMessagesByDate(baseTickDirectory, previousDate, symbol, tickMessagesCurrentDate);

TimeSpan storeTickMessagesRunTime = DateTime.Now.Subtract(storeTickMessagesStartTime);
double runTimeSeconds = Math.Round(storeTickMessagesRunTime.TotalSeconds, 4);
double avgRunTimeSeconds = 0;

lock (tickMessagesStoreLockObject)
{
tickMessagesStoreRunTime.Add(runTimeSeconds);

avgRunTimeSeconds = Math.Round(GetAverage(tickMessagesStoreRunTime), 2);
}

logger.Trace("StoreTickMessages: " + " Symbol: " + symbol + " Run Secs: " + runTimeSeconds + " Avg Run Secs: " + avgRunTimeSeconds);
}



void StoreTickMessagesByDate(string TickDirectory, DateTime date, string symbol, List<TickMessage> tickMessages)
{
string TickDirectoryDate = TickDirectory + date.ToString(SystemInfrastructure.DateFormat) + "\\";

// Create Date Directory only once
if (false == Directory.Exists(TickDirectoryDate))
{
Directory.CreateDirectory(TickDirectoryDate);
}

string symbolFileName = TickDirectoryDate + symbol + ".csv";

using (StreamWriter sw = new StreamWriter(symbolFileName))
{
sw.WriteLine(TickFileHeader);

foreach (TickMessage tickMessage in tickMessages)
{
string timeStamp = tickMessage.Timestamp.ToString(IQFeed.CSharpApiClient.Lookup.Historical.Messages.TickMessage.TickDateTimeFormat);
double Last = Math.Round(tickMessage.Last, 4);
int LastSize = tickMessage.LastSize;
long TotalVolume = tickMessage.TotalVolume;
double Bid = Math.Round(tickMessage.Bid, 2);
double Ask = Math.Round(tickMessage.Ask, 2);
long TickId = tickMessage.TickId;
char BasisForLast = tickMessage.BasisForLast;
int TradeMarketCenter = tickMessage.TradeMarketCenter;
string TradeConditions = tickMessage.TradeConditions;

string tickMessageCSV = TickMessageCSV(timeStamp, Last, LastSize, TotalVolume, Bid, Ask, TickId, BasisForLast, TradeMarketCenter, TradeConditions);

sw.WriteLine(tickMessageCSV);
}
}
}

AK786

data_collector
-Interested User-
Posts: 4
Joined: Aug 9, 2018


Posted: Aug 10, 2018 04:10 PM          Msg. 5 of 9
Haven't gotten around to playing around your code more but getting around to it now.

Thank you both and agree that it's been a huge help!

data_collector
-Interested User-
Posts: 4
Joined: Aug 9, 2018


Posted: Aug 14, 2018 09:14 PM          Msg. 6 of 9
AK786, I'm going through your code -- do you have def to the TickMessageCSV() function you use at the end, just before sw.WriteLine?

Sorry, I'm completely new to C# so taking a while for me to understand all of Mathieu's and your code but thank you for your help.

AK786
-Interested User-
Posts: 21
Joined: Jul 17, 2018


Posted: Aug 14, 2018 09:52 PM          Msg. 7 of 9
string TickMessageCSV(string timeStamp, double last, int lastSize, long totalVolume, double bid, double ask, long tickId, char basisForLast, int tradeMarketCenter, string tradeConditions)
{
StringBuilder sb = new StringBuilder(1000);

sb.Append(timeStamp).Append(",");
sb.Append(last).Append(",");
sb.Append(lastSize).Append(",");
sb.Append(totalVolume).Append(",");
sb.Append(bid).Append(",");
sb.Append(ask).Append(",");
sb.Append(tickId).Append(",");
sb.Append(basisForLast).Append(",");
sb.Append(tradeMarketCenter).Append(",");
sb.Append(tradeConditions).Append(",");

return sb.ToString();
}

I will post all my code here soon. I am in the process of Writing my Data Collection and storage handlers.

AK786

mathpaquette
-Interested User-
Posts: 12
Joined: May 18, 2018


Posted: Aug 15, 2018 06:24 AM          Msg. 8 of 9
Guys, dont hesitate to open an issue on GitHub rather than posting on this site.... I think its more related to the project itself.

Will always happy to help you out with that.
Mathieu

data_collector
-Interested User-
Posts: 4
Joined: Aug 9, 2018


Posted: Aug 15, 2018 08:21 AM          Msg. 9 of 9
@AK, THANK YOU!

Mathieur, will post if I come across more questions. Thank you.
 

 

Time: Thu November 15, 2018 6:52 AM CFBB v1.2.0 16 ms.
© AderSoftware 2002-2003