krs43 / ib-csharp

Interactive Brokers C# Api
MIT License
69 stars 54 forks source link

historical data is one day old #12

Open ghost opened 10 years ago

ghost commented 10 years ago

When i pull Historical data after 8 am EST, i can get till EOD yesterday. If i pull it before 8 AM EST, i get data ie 2 days old. Can anyone duplicate it.

ghost commented 10 years ago

Actually IB is sending the data in localtime and not in GMT. The code has a bug as it assumes GMT fixed my copy locally but did not know how to checkin and so cut and pasted my patch here, Hopfully someone can update the repository,

region Process Message

    /// <summary>Overridden in subclass.</summary>
    private bool ProcessMsg(IncomingMessage msgId)

.......................

case IncomingMessage.HistoricalData:

if(longDate < 30000000) // timeStamp = new DateTime(Int32.Parse(date.Substring(0, 4)), Int32.Parse(date.Substring(4, 2)), Int32.Parse(date.Substring(6, 2)), 0, 0, 0, DateTimeKind.Utc).ToLocalTime(); timeStamp = new DateTime(Int32.Parse(date.Substring(0, 4)), Int32.Parse(date.Substring(4, 2)), Int32.Parse(date.Substring(6, 2)), 0, 0, 0, DateTimeKind.Local).ToLocalTime(); else timeStamp = new DateTime(1970,1,1,0,0,0,DateTimeKind.Utc).AddSeconds(longDate).ToLocalTime();