Ibkr Python API

Disclaimer - These IBKR sessions are for training and research purpose only. Please consult your investment advisor before making any investment decisions.

Use Case

Sample usage of IBKR Python API

  • Use Python API and IBKR paper trading account to test some trading strategies
  • IBKR C++ API (For basic trading Python API should be sufficient)

References

  1. https://interactivebrokers.github.io/tws-api/index.html
  2. https://github.com/extrange/ibkr-docker

Dataflow Diagram

Source Code

Session 1:

  • Topics Discussed:
    1. Start the IBKR API container in docker
    2. Using VS Code remote development run the API test samples
    3. Place SPY Limit and Market Orders
    4. Cancel the placed Limit and Market Orders

Video explanation of the code

IBKR-Python-API

Session 2:

  • Topics Discussed:
    1. Fetch Stock Details
    2. Fetch Future Details
    3. Fetch Option Contract Details

Video explanation of the code

IBKR-Python-API

Source Code

Session 3:

  • Topics Discussed:
    1. Order Create
    2. Order Query
    3. Order Update
    4. Order Cancel
    5. Order Global Cancel

Video explanation of the code

IBKR-Python-API

Source Code

References

Reference - IBKR Python API Videos

Session 4:

  • Topics Discussed:
    1. Advanced Orders
      1. Bracket Order
      2. Combo Order

Video explanation of the code

IBKR-Python-API

Source Code

Session 5:

Use Case

Create a short list of instruments based on a theme:

  1. Show contracts with the highest percent price increase between the last trade and opening price
  2. Most Active by Volume
  3. Options by Put/Call volume/open interest ratio
  4. Many scenarios are supported per IBKR API Guide
  • Topics Discussed:
    1. Market Scanner:
      1. Request Market Scanner Parameters
      2. Request stocks with the highest percent price INCREASE between the last trade and opening prices
      3. Request US Traded futures

Video explanation of the code

IBKR-Python-API

Source Code

References

IBKR Python API Videos
IBKR API Reference Guide
Query Contract Details

comments powered by Disqus