this is an example of backtesting and automating options trading strategy with native Interactive Brokers python API (ibapi). Bot buys call spread on SPY when close price > sma, exits after 5 days or when abrupt downtrend is detected with bayesian change point detection algorithm (BOCD).
- Interactive Brokers account with market data subscriptions
- ibapi package 10.22
- TWS or IB Gateway
- python 3.9 or later
- pyqstrat
- start tws and open 'trades' tab
- launch main.py file after market opens