Maintainers
Pricing
Enterprise
More
More
Documentation
Try Live
Rankings
Install
Blog
Docs7
Ask
New
Add Docs
IB Insync
https://ib-insync.readthedocs.io/en/latest/
Admin
IB Insync is a Python library that simplifies working with the Interactive Brokers Trader
...
Tokens:
932
Snippets:
2
Trust Score:
8.3
Update:
1 year ago
Context
Chat
Benchmark
50.75
Latest
Show doc for...
Code
Info
Show Results
Tokens:
Raw
Copy
Link
Tokens:
Raw
Copy
Link
### Download Historical Data with ib_insync Source: https://ib-insync.readthedocs.io/en/latest/index Example script to connect to Interactive Brokers TWS/Gateway and download historical data for a Forex contract. It then converts the data into a pandas DataFrame. Requires pandas to be installed. ```Python from ib_insync import * # util.startLoop() # uncomment this line when in a notebook ib = IB() ib.connect('127.0.0.1', 7497, clientId=1) contract = Forex('EURUSD') bars = ib.reqHistoricalData( contract, endDateTime='', durationStr='30 D', barSizeSetting='1 hour', whatToShow='MIDPOINT', useRTH=True) # convert to pandas dataframe (pandas needs to be installed): df = util.df(bars) print(df) ``` -------------------------------- ### Install ib_insync Source: https://ib-insync.readthedocs.io/en/latest/index Installs the ib_insync library using pip. Requires Python 3.6 or higher and a running TWS or IB Gateway application (version 1023 or higher) with the API port enabled. ```bash pip install ib_insync ```