Interactive Brokers API in Python: GEX levels and open interest from FinzData
Interactive Brokers TWS does not take indicator plugins, so IBKR traders work through the TWS API in Python. Our free scripts put FinzData's gamma flip, call wall, put wall and futures open interest next to your live IB price, using ib_insync and a free FinzData API key.
What the Interactive Brokers pack does
- ib_gex_levels_live.py streams your live IB price for SPX, NDX, RUT or any stock or ETF through the TWS API and prints the distance to the FinzData gamma flip, call wall and put wall, flagging when price crosses the flip. It is read-only and never places orders.
- ib_open_interest_report.py prints total and front-month open interest, with the daily change, for any of the 139 FinzData futures markets.
- finzdata_ib.py is a small Python client for your own IBKR API strategies.
Download the Interactive Brokers pack (source code included).
Install with the TWS API and ib_insync
- Run
pip install ib_insync(Python 3.9 or newer). - Get a free API key with just your email at https://finzdata.com and set
FINZDATA_API_KEY. - Start TWS or IB Gateway with the API enabled, then run
python ib_gex_levels_live.py --ticker SPX.
The scripts connect to the TWS API on your own machine and read FinzData directly, so your IBKR API account settings stay untouched.
What are GEX levels and the gamma flip?
GEX (gamma exposure) measures how options dealers must hedge. Above the gamma flip, dealers are long gamma and their hedging tends to damp moves; below it, they are short gamma and hedging can feed moves. The call wall and put wall are the strikes with the largest call and put gamma, often acting as resistance and support. FinzData computes GEX levels for 11,200+ stocks, ETFs and indexes since 2010, and the scripts use the prior session's levels, so there is no look-ahead.
Futures open interest for IBKR futures traders
Open interest is the number of futures contracts still open at the end of a trading day. Rising open interest with a rising price points to new money entering; falling open interest points to positions being closed. The open interest report covers ES, NQ, CL, GC, ZN, 6E, FDAX and all 139 FinzData futures markets, with every contract since 2007, so you can compare CME open interest with volume across the whole curve.
Free key, full history
The free FinzData API key covers the last 30 days of futures and daily GEX. For the full history, buy once in the FinzData shop (one futures market is $39); the same key unlocks it with no change to your scripts. See every platform we support on the trading platform indicators page.
Questions
Can I add indicators to Interactive Brokers TWS?
TWS does not accept third-party indicator plugins, so FinzData works through the TWS API in Python instead: the scripts read your live IB price and FinzData's levels side by side.
Does the script place orders through my IBKR API connection?
No. It connects read-only and never places orders. It only streams prices and prints the distance to the gamma flip, call wall and put wall.
Do I need ib_insync?
Yes for the live script: install it with pip install ib_insync. The open interest report and finzdata_ib.py use only the Python standard library.
What does the free key include?
The last 30 days of futures and daily GEX. The full history is a one-time purchase in the FinzData shop, and the same key unlocks it.
Which markets are covered?
Open interest for all 139 FinzData futures markets, and GEX levels for single stocks, ETFs and the major indexes such as SPX, NDX and RUT.
Also for: Quantower · NinjaTrader 8 · ATAS · Sierra Chart · MotiveWave. All platforms: FinzData trading platform indicators.