SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Sat Jul 20, 2019 5:00 pm

All times are UTC + 3 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: IBHistorical data broken
PostPosted: Wed May 01, 2019 10:57 am 
Offline

Joined: Thu Dec 06, 2018 1:57 am
Posts: 28
I've found some strange behavior while downloading historical currency data from IB. Sometimes a 1 day request such as:
dateTime2 = 04/24/2019 21:16:00.000
dateTime1 = 04/23/2019 21:16:00.000 (times in UTC)
Will return only 1 bar, despite there being many bars available for that date range. If I extend the size of my query I receive all the data for that original window. See the code and outputs below:

Code:
Console.WriteLine($"IBHistoricalDownloader::Requesting(IB, EURCHF, {dateTime1}, {dateTime2}, {BarType.Time}, 60)");
BarSeries barSeries = Framework.DataManager.GetHistoricalBars(ProviderManager.GetHistoricalDataProvider("IB"), EURCHF, dateTime1, dateTime2, BarType.Time, 60);
Console.WriteLine($"IBHistoricalDownloader::Recieved -> {barSeries.Count}, {barSeries.FirstDateTime}, {barSeries.LastDateTime}");

if (barSeries.Count < 100)
{
     foreach(Bar bar in barSeries)
     {
           if ( bar.DateTime >= dateTime1 && bar.DateTime <= dateTime2)
           {
                Console.WriteLine(bar);
           }
     }
     DateTime dateTime1Extended = dateTime1.AddDays(-3);
     Console.WriteLine($"IBHistoricalDownloader::Requesting(IB, {instrument.Symbol}, {dateTime1Extended}, {dateTime2}, {BarType.Time}, 60)");
     barSeries = Framework.DataManager.GetHistoricalBars(ProviderManager.GetHistoricalDataProvider("IB"), EURCHF, dateTime1Extended, dateTime2, BarType.Time, 60);
     Console.WriteLine($"IBHistoricalDownloader::Recieved -> {barSeries.Count}, {barSeries.FirstDateTime}, {barSeries.LastDateTime}");
     foreach (Bar bar in barSeries)
     {
          if (bar.DateTime >= dateTime1 && bar.DateTime <= dateTime2)
          {
                 Console.WriteLine(bar);
          }
     }
}



OutPut:

Requesting: EURCHF, Bid, 60, 04/23/2019 21:16:00.000 - 04/24/2019 21:16:00.000
IBHistoricalDownloader::GetHistoricalBars(EURCHF, Bid, 60, 04/23/2019 21:16:00.000 - 04/24/2019 21:16:00.000)
IBHistoricalDownloader::Requesting(IB, EURCHF, 04/23/2019 21:16:00.000, 04/24/2019 21:16:00.000, Time, 60)
IBHistoricalDownloader::Recieved -> 1, 04/24/2019 21:16:00.000, 04/24/2019 21:16:00.000
Bar [04/24/2019 21:15:00.000 - 04/24/2019 21:16:00.000] Instrument=23 Type=Time Size=60 Open=1.13805 High=1.1381 Low=1.138 Close=1.13803 Volume=-1

// After extending date range:
IBHistoricalDownloader::Requesting(IB, EURCHF, 04/20/2019 21:16:00.000, 04/24/2019 21:16:00.000, Time, 60)
IBHistoricalDownloader::Recieved -> 4171, 04/21/2019 23:01:00.000, 04/24/2019 21:16:00.000
Bar [04/23/2019 21:15:00.000 - 04/23/2019 21:16:00.000] Instrument=23 Type=Time Size=60 Open=1.1447 High=1.1451 Low=1.1447 Close=1.1451 Volume=-1
Bar [04/23/2019 21:16:00.000 - 04/23/2019 21:17:00.000] Instrument=23 Type=Time Size=60 Open=1.1451 High=1.1451 Low=1.1451 Close=1.1451 Volume=-1
Bar [04/23/2019 21:17:00.000 - 04/23/2019 21:18:00.000] Instrument=23 Type=Time Size=60 Open=1.1451 High=1.1451 Low=1.1451 Close=1.1451 Volume=-1
.
.
.
Bar [04/24/2019 20:58:00.000 - 04/24/2019 20:59:00.000] Instrument=23 Type=Time Size=60 Open=1.13817 High=1.13819 Low=1.13812 Close=1.13814 Volume=-1
Bar [04/24/2019 20:59:00.000 - 04/24/2019 21:00:00.000] Instrument=23 Type=Time Size=60 Open=1.13814 High=1.13833 Low=1.13803 Close=1.13805 Volume=-1
Bar [04/24/2019 21:15:00.000 - 04/24/2019 21:16:00.000] Instrument=23 Type=Time Size=60 Open=1.13805 High=1.1381 Low=1.138 Close=1.13803 Volume=-1

So to summarize, my problem is that a request for the date range 04/23/2019 21:16:00.000 - 04/24/2019 21:16:00.000, returns only 1 bar, but if I extend the range to 04/20/2019 21:16:00.000 - 04/24/2019 21:16:00.000, I get plenty of data covering the original date range.

any help here?


Top
 Profile  
 
PostPosted: Mon May 06, 2019 12:01 pm 
Offline

Joined: Wed May 05, 2010 9:49 pm
Posts: 485
Hello,
first thing to do is check Provider Errors tab in OQ2014 or subscribe to this event(framework.EventManager.Dispatcher.ProviderError) if you run the code standalone.

second, enable market data logs in TWS:
Settings->API->Settings->Include market data in API log file

Log file will placed inside of TWS folder, like C:\Jts\
Filename like api.1.Mon.log
This file will let us know what IB sends from servers.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group