FORUMS BROKERS SOFTWARE
Home
 
    Forums > Technically Speaking > Programming > Interactive brokers - API - HistoricalDataEventArgs!?


Reply
 
Thread Tools
Old Aug 19th, 2012, 03:12 PM   #1
bluematrix
 
 
Join Date: Jan 2012
Posts: 146
Can someone help me figure how to read back the data request through the IB API?

the historicaldata event fires HistoricalDataEventArgs - I can read this i.e. .high or .low so it has data in it.. but it's suppose to have all the historical for the chosen date range - and doesn't have getenumerator..

so question is: how do you convert this into meaningful bars/ticks - do you implement some class yourself? any examples anywhere? what needs to be done?

appreciate any input.

thanks
    Quote
Old Aug 19th, 2012, 04:51 PM   #2
vicirek
 
 
Join Date: Dec 2011
Posts: 504
IB is event driven and returns 1 bar per event and the date/time field is how you can put it into desired series of bars. Usually it would be collection or array of OHLC structures or class instances or any other database design of your choice. You can index it as well because they come in order but it is always safer to check yourself by date and time if your request came back in order and complete. So when you request your bars in a separate request IB API will return all the requested bars in sequence (now up to 2000 bars per request ) one by one through the event. Then you process it there one by one.
    Quote
Old Aug 19th, 2012, 05:06 PM   #3
bluematrix
 
 
Join Date: Jan 2012
Posts: 146
Quote:
Quote from vicirek:

IB is event driven and returns 1 bar per event and the date/time field is how you can put it into desired series of bars. Usually it would be collection or array of OHLC structures or class instances or any other database design of your choice. You can index it as well because they come in order but it is always safer to check yourself by date and time if your request came back in order and complete. So when you request your bars in a separate request IB API will return all the requested bars in sequence (now up to 2000 bars per request ) one by one through the event. Then you process it there one by one.
ok thanks - but when I request the bar through assigning client.HistoricalData to a event handler - I'm only getting 1 data point - even thought I've requested 5 days worth of daily data? What am I missing? thanks

edit: here is a quick example - using the c# wrapper - when I request my historical data I expect multiple events to fire in sequence (if you say it's all event based?) or may e had some array structure. but neither is correct. I only get the first element of the sequence and nothing else.. any thoughts?

void client_HistoricalData(object sender, HistoricalDataEventArgs e)
{

MessageBox.Show(e.Date.ToString());

throw new NotImplementedException();
}
    Quote
Old Aug 19th, 2012, 06:03 PM   #4
vicirek
 
 
Join Date: Dec 2011
Posts: 504
First please check how you request your bars and start with just one day 1 or 5 minute bars to see if your request and handler are wired properly. IB Demo may not return historical data properly and same might apply to paper account so you have to watch for that. Weekends are also not the best time to try because some servers are off.
    Quote
Old Aug 19th, 2012, 06:07 PM   #5
bluematrix
 
 
Join Date: Jan 2012
Posts: 146
Quote:
Quote from vicirek:

First please check how you request your bars and start with just one day 1 or 5 minute bars to see if your request and handler are wired properly. IB Demo may not return historical data properly and same might apply to paper account so you have to watch for that. Weekends are also not the best time to try because some servers are off.
I'm simply using client.RequestHistoricalData from another method.. and it seems to be working fine - as e.RecordTotal returns the correct number of elements as I change the date range for the historical data.. yet I only can read one element through a.close etc..
    Quote
Old Aug 19th, 2012, 06:26 PM   #6
vicirek
 
 
Join Date: Dec 2011
Posts: 504
By the way e.date is string so you have to split it into date format. e.date. tostring will return object I guess. But in any case You should get multiple message boxes with this code if the rest is correct.
    Quote
 
Reply
Thread Tools

Forum Jump



   Conduct Rules   Privacy Policy   Sitemap Copyright © 2014, Elite Trader. All rights reserved.   

WHILE YOU'RE HERE, TAKE A MINUTE TO VISIT SOME OF OUR SPONSORS:
Advantage Futures
Futures Trading & Clearing
Alpha 7 Trading Academy
Proprietary Trading Education
AMP Global Clearing
Futures and FX Trading
Bright Trading
Professional Equities Trading
CTS
Futures Trading Software
DaytradingBias.com
Professional Trading Analytics
ECHOtrade
Professional Trading Firm
eSignal
Trading Software Provider
FXCM
Forex Trading Services
Global Futures
Futures, Options & FX Trading
Interactive Brokers
Pro Gateway to World Markets
JC Trading Group
Direct Access Trading
MB Trading
Direct Access Trading
MultiCharts
Trading Software Provider
NinjaTrader
Trading Software Provider
OANDA
Currency Trading
optionshouse
Option Trading & Education
Rithmic
Futures Trade Execution Platform
SpeedTrader
Direct Access Trading
SpreadProfessor
Spread Trading Instruction
thinkorswim by TD Ameritrade
Direct Access TradingAdvertisement
TradersStudio
System Building & Backtesting
Trading Technologies
Trading Software Provider
Trend Following
Trading Systems Provider