First, for future readers, here's a good post about downloading historical data from IB:
viewtopic.php?f=41&t=6305Second, some info about my config, which works fine now to download historical bars for FX spot pairs through IB with GetHistoricalBars().
IB Provider settings "Historical Data" tab (not sure all of them are important):
- UseRTH = false
- WhatToShow = BID
FX spot Instrument settings for IB:
- Symbol = "EUR USD" (can be set to anything, it's not used in the messages exchanges between IB and OQ)
- Currency = "USD"
- Exchange = "IDEALPRO"
- AltExchange = "IDEALPRO"
- AltSource = "IB"
- AltSymbol = "EUR"
- PriceFormat = "F5"
Code:
Code:
public override void OnStrategyStart()
{
var end = DateTime.Now;
var begin = end.AddHours(-13);
Console.WriteLine("getting bars for " + Instrument.Symbol);
Console.WriteLine("between " + begin + " - " + end);
var bars = DataManager.GetHistoricalBars("IB", Instrument, begin, end, 3600);
Console.WriteLine("# bars: " + bars.Count);
foreach (Bar bar in bars)
{
Console.WriteLine(bar.ToString());
}
}

IMPORTANT
- The provider set for Market Data in OQ's Options > Configuration > Modes > Live doesn't matter.
- This code requires an instrument to be added to the strategy, created using the above settings.
- If you set IB's "WhatToShow" property to "TRADES", it will return an error as there's no trade reporting in spot FX with IB
- If you set it to "BID_ASK", the bars downloaded will be very strange, they all look like Dojis (open ~= close)