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)




"If someone needs the best quality data and backfill beyond what their broker provides at a rate that is the best in the industry, I highly recommend IQFeed." - Comment from Josh via Public Forum
"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
"I just wanted to let u know that your data feed/service is by far the best!!! Your unfiltered tick data is excellent for reading order flow and none of your competitors delivers this quality of data!" - Comment from Peter via Email
"I just wanted to tell you what a fine job you have been doing. While *******, from what I hear, has been down and out, off and on, IQ feed has held like a champ this week." - Comment from Shirin
"If you want customer service that answers the phone, your best bet is IQFeed. I cannot stop praising them or their technical support. They are always there for you, and they are quick. I have used ****** too but the best value is IQFeed." - Comment from Public Forum
"I started a trial a few weeks back before the market went wild. DTN.IQ didn’t miss anything and beat my other provider. I decided to stay with you because of the great service through all the volatility." - Comment from Mike
"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
"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
"I just wanted to let you know how fast and easy I found it to integrate IQFeed into our existing Java code using your JNI client. In my experience, such things almost never go so smoothly - great job!" - Comment from Nate
"You have an excellent product !!!!!!" - Comment from Arely
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 »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: 22
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: 6
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: 22
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: 6
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: 6
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: 22
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: 6
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: Sat May 18, 2024 1:52 PM CFBB v1.2.0 10 ms.
© AderSoftware 2002-2003