ib-api-reloaded / ib_async

Python sync/async framework for Interactive Brokers API (replaces ib_insync)
BSD 2-Clause "Simplified" License
463 stars 73 forks source link

Timing out on reqHistoricalData #34

Closed eddieh800 closed 4 months ago

eddieh800 commented 4 months ago

Hi, I am having issues pulling historical stock data. I am connecting via IB Gateway, can confirm that the API Client is connected and can check my positions, orders, trades, but not stock data.

Subscriptions that I have on IBKR: NYSE (Network A/CTA) (NP,L1) NASDAQ (Network C/UTP)(NP,L1)

Code for the IB Gateway API:

from ib_insync import *

contract = Stock('TSLA', 'SMART', 'USD')

bars = ib.reqHistoricalData(
contract,
endDateTime='', # End date/time (leave empty for most recent data)
durationStr='1 Y', # Duration (e.g., '1 Y' for 1 year)
barSizeSetting='1 day', # Bar size ('1 day' for daily data)
whatToShow='TRADES', # Type of data ('TRADES' for historical trades)
useRTH=True, # Regular trading hours only
formatDate=1 # Format as Unix timestamp
)

Error Message: ib_insync.ib:reqHistoricalData: Timeout for Stock(symbol='TSLA', exchange='SMART', currency='USD')

Can you please help?

baichen111 commented 4 months ago

this works for me : contract = Stock('TSLA', 'ISLAND','USD')

can you change exchange to 'ISLAND' and try ?

eddieh800 commented 4 months ago

Hi @baichen111 ! Just gave it a try, still hitting the timeout error. I was reading through this repo and saw the discussion on ib_insync being deprecated for ib_async. Which one are you using? I may try to work this with ib_async

EDIT: Nope, still hitting the same timeout with ib_async

baichen111 commented 4 months ago

@eddieh800
I tried both ib_insync and ib_async . Both are working on my side.

eddieh800 commented 4 months ago

Must be some configuration or subscription issue then on my side. I am working with IBKR support to double check the subscription activation, although I do see these as subscribed on Account Management. Will report back. NYSE (Network A/CTA) (NP,L1) NASDAQ (Network C/UTP)(NP,L1)

eddieh800 commented 4 months ago

Resolved with IBKR support, was just a configuration problem. Thanks all!