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)




"With HUGE volume on AAPL and RIMM for 2 days, everyone in a trading room was whining about freezes, crashes and lag with *******, RealTick, TS and Cyber. InvestorRT with IQFeed was rock solid. I mean SOLID!" - Comment from Public IRC Chat
"I just wanted to say how happy I am with your service. I was able to download the API docs last week and I was able to replicate Interactive Brokers historical bar queries and realtime bar queries over the weekend. That was about one of the fastest integrations that I've ever done and it works perfectly!!!!" - Comment from Jason via Email
"As a past ******* customer(and not a happy one), IQ Feed by DTN is a much better and cheaper product with great customer support. I have had no problems at all since switching over." - Comment from Public Forum
"I've been using IQFeed 4 in a multi-threaded situation for the last week or two on 2600 symbols or so with 100 simultaneous daily charts, and I have had 100% responsiveness." - Comment from Scott
"I have been using IQFeed now for a few years in MultiCharts and I have zero complaints. Very, very rare to have any data hiccups or anything at all go wrong." - Comment from Public Forum
"I would just like to say that IQFeed version 4 is running very well and I am very happy with its performance. I would also like to extend a big thanks for the fast and efficient help that I always receive. My questions and concerns are always addressed promptly. Way to go!" - Comment from Josh in CO.
"The people at Nirvana have very nice things to say about your company and I can see why! Price and service is a potent combination." - Comment from Ed
"Everything is working great ! Very impressive client. The news refreshes better and is more pertinent than the ******* feed I paid $ 100/month for. I Also like the charts a lot." - Comment from Leon
"If you are serious about your trading I would not rely on IB data for serious daytrading. Took me a while to justify the cost of IQ Feed and in the end, it's just a 2 point stop on ES. Better safe than sorry" - Comment from Public Forum
"I noticed that ******* quotes locked up shortly after the interest rate announcement yesterday while yours stayed stable." - Comment from Ron in Utah
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: Sun November 18, 2018 11:07 PM CFBB v1.2.0 0 ms.
© AderSoftware 2002-2003