SmartQuant Discussion
http://www.smartquant.com/forums/

IQFeed - downloading Extendend session as well
http://www.smartquant.com/forums/viewtopic.php?f=86&t=14668
Page 1 of 1

Author:  mikembb [ Tue Dec 20, 2016 12:09 am ]
Post subject:  IQFeed - downloading Extendend session as well

Dear all,

in OQ2014 - when I connect to IQFeed to download historical data, and I have the UseExtended Trades = false, how come, the plugin downloads data beyond the regular trading session for the bars? I requested 60s and 86400s bars.

It downloads for the whole history all trading sessions and not just the regular session.

Thanks
Mike

Author:  skuvv [ Fri Dec 23, 2016 10:11 am ]
Post subject:  Re: IQFeed - downloading Extendend session as well

IQFeed not sends additional info of bar, so it cannot be filtered for RTH.

Author:  mikembb [ Thu Jan 19, 2017 12:30 pm ]
Post subject:  Re: IQFeed - downloading Extendend session as well

ok. I see that.

You could ammend it though in a way, that you give the user the starttime preference and endtime preference to pass that to IQ feed. Since OQ2014 can specify that in the history commands for the download of time bars:
Below is the request string for historical bars:
// request in the format:
// HIT,SYMBOL,INTERVAL,BEGINDATE BEGINTIME,ENDDATE ENDTIME,,BEGINFILTERTIME,ENDFILTERTIME,DIRECTION,REQUESTID,DATAPOINTSPERSEND,INTERVALTYPE<CR><LF>

Thanks
Mike

Author:  skuvv [ Thu Jan 19, 2017 1:46 pm ]
Post subject:  Re: IQFeed - downloading Extendend session as well

You can do it programatically:
Code:
         var iqfeed = ProviderManager.GetHistoricalDataProvider(ProviderId.IQFeed);
         var instrument = InstrumentManager.Instruments["AAPL"];
         var date = new DateTime(2017, 01, 17);
         var time1 = new TimeSpan(09, 30, 00);
         var time2 = new TimeSpan(17, 00, 00);
         
         while(!iqfeed.IsConnected)
         {
            iqfeed.Connect();
            System.Threading.Thread.Sleep(1000);
         }
         
         var bars = DataManager.GetHistoricalBars(iqfeed, instrument, date.Add(time1), date.AddDays(-1).Add(time2), BarType.Time, 60);
         
         if (bars != null)
         {
            int barsToShow = 5;
            
            Console.WriteLine("bars loaded: {0}", bars.Count);
            Console.WriteLine("last {0} bars", barsToShow);
            
            for (int i = bars.Count - 1; i >= 0 && i >= bars.Count - barsToShow; i--)
               Console.WriteLine(bars[i]);
         }


result:
Code:
last 5 bars
Bar [1/17/2017 16:59:00.000 - 1/17/2017 17:00:00.000] Instrument=0 Type=Time Size=60 Open=119.97 High=119.99 Low=119.97 Close=119.97 Volume=20100
Bar [1/17/2017 16:58:00.000 - 1/17/2017 16:59:00.000] Instrument=0 Type=Time Size=60 Open=119.97 High=119.99 Low=119.97 Close=119.99 Volume=10150
Bar [1/17/2017 16:57:00.000 - 1/17/2017 16:58:00.000] Instrument=0 Type=Time Size=60 Open=119.98 High=119.98 Low=119.98 Close=119.98 Volume=700
Bar [1/17/2017 16:56:00.000 - 1/17/2017 16:57:00.000] Instrument=0 Type=Time Size=60 Open=119.97 High=119.97 Low=119.97 Close=119.97 Volume=4900
Bar [1/17/2017 16:53:00.000 - 1/17/2017 16:54:00.000] Instrument=0 Type=Time Size=60 Open=119.97 High=119.97 Low=119.97 Close=119.97 Volume=5000


and for time2 = new TimeSpan(18, 30, 00);
Code:
last 5 bars
Bar [1/17/2017 18:13:00.000 - 1/17/2017 18:14:00.000] Instrument=0 Type=Time Size=60 Open=119.97 High=119.97 Low=119.97 Close=119.97 Volume=200
Bar [1/17/2017 18:08:00.000 - 1/17/2017 18:09:00.000] Instrument=0 Type=Time Size=60 Open=119.92 High=119.92 Low=119.92 Close=119.92 Volume=100
Bar [1/17/2017 18:06:00.000 - 1/17/2017 18:07:00.000] Instrument=0 Type=Time Size=60 Open=119.92 High=119.92 Low=119.92 Close=119.92 Volume=100
Bar [1/17/2017 17:58:00.000 - 1/17/2017 17:59:00.000] Instrument=0 Type=Time Size=60 Open=119.91 High=119.91 Low=119.91 Close=119.91 Volume=170
Bar [1/17/2017 17:55:00.000 - 1/17/2017 17:56:00.000] Instrument=0 Type=Time Size=60 Open=119.92 High=119.92 Low=119.92 Close=119.92 Volume=100


PS You should load bars by one day per request otherwise you will load all data outside rth

Page 1 of 1 All times are UTC + 3 hours
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/