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)




"I had always used ******* but for the past 2 weeks have been trying DTN IQFeed. Customer support has been extraordinary. They call just to make sure your problem hasn't recurred." - Comment from Public Forum
"Just a quick one to say I'm very impressed so far :) The documentation for developers is excellent and I've quickly managed to get an app written to do historical downloads. The system is very robust and pretty quick considering the extent of data that's available. The support guys have been very helpful too, in combination with the forums it's been plain sailing so far!" - Comment from Adam
"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
"IQ feed is brilliant. The support is mind-bending. What service!" - Comment from Public Forum Post
"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 was with ******* for 4 years at $230 a month, this is a huge savings for me, GOD BLESS YOU PEOPLE," - Comment from T.S. via Email
"I "bracket trade" all major news releases and I have not found one lag or glitch with DTN.IQ feed. I am very comfortable with their feed under all typical news conditions (Fed releases, employment numbers, etc)." - Comment from Public Forum
"I will tell others who want to go into trading that DTN ProphetX is an invaluable tool, I don't think anyone can trade without it..." - Comment from Luther
"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
"Awesome response, as usual. It is a sincere and refreshing pleasure to do business with DTN, compared to your competition." - Comment from Ryan
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: Tue January 22, 2019 11:10 AM CFBB v1.2.0 15 ms.
© AderSoftware 2002-2003