Closed drhboss closed 4 years ago
Could be a weekend thing, try it after the IB weekend maintenance.
The code looks okay.
I don't think the issue is the weekly maintenance, just tested again using the native IBKR api and it works fine, here is the code using EWrapper/EClient., still same error as before when using ib_insync
Thank you
from ibapi.client import EClient
from ibapi.wrapper import EWrapper
from ibapi.contract import Contract
from ibapi.ticktype import TickTypeEnum
import time
class TestApp(EWrapper, EClient):
def __init__(self):
EClient.__init__(self, self)
def error(self, reqId, errorCode, errorString):
print("Error: ", reqId, " ", errorCode, " ", errorString)
def tickPrice(self, reqId, tickType, price, attrib):
print("Tick Price. Ticker Id:", reqId, "tickType:",
TickTypeEnum.to_str(tickType), "Price:", price, end=' ')
def histogramData(self, reqId, items):
print("HistogramData. ReqId:", reqId, "HistogramDataList:", "[%s]" % "; ".join(map(str, items)))
def tickSize(self, reqId, tickType, size):
print("Tick Size. Ticker Id:", reqId, "tickType:",
TickTypeEnum.to_str(tickType), "Size:", size)
def main():
app = TestApp()
app.connect("127.0.0.1", 4002, 0)
time.sleep(0.1)
contract = Contract()
contract.secType = "FUT"
contract.exchange = "GLOBEX"
contract.currency = "USD"
contract.lastTradeDateOrContractMonth="202006"
contract.symbol="ES"
app.reqHistogramData(1, contract, False, '5 days')
app.run()
if __name__ == "__main__":
main()
Thanks for the followup. It was indeed a bug in the ib_insync client which is now fixed in the repo. It will be released shortly in v0.9.60.
Thank you!, great work by the way, :-)
reqHistogramData complains about the format of the time-period. I use same format string for reqHistoricalData and it works fine,
Thank you for looking into it.
here is an example:
print(ib_insync.__version__)
contract = Stock('SPY', 'SMART', 'USD')
ib.reqHistogramData(contract, False, '3 days')