asemx / ibkrbox

box spread utility for interactive brokers
Apache License 2.0
12 stars 1 forks source link

ibkrbox

Constructs a Box Spread combo order for SPX or ES futures option, only required arguments are amount you want to lend or borrow , and for how many months.

This utility will automatically look up current treasury rates, and add .30 to get the yield rate. This will be used to calculate limit price. rate or limit price can be overridden as needed.

It can also automatically calculate the right strikes and spread, with approximate expiry for given duration. All of these can be overridden as needed.

This utility is easy to install and use with existing IBKR TWS or gateway session. Just make sure to enable API access in the GUI of IBKR TWS or gateway.

Please file a issue if you notice any problem(s).

Installation

pip install ibkrbox

Usage

ibkrbox -h
image

1. construct a combo SPX Box Spread lending for 50K, duration 4 months (use "--execute" option to send the order to IBKR)

This will not execute the order, so you can safely run this. When executing, it will retry orders until "offset" limit.

ibkrbox -a 50000 -m 4 --offset .50
image

2. same as above but using Options on ES Futures (use "--execute" option to send the order to IBKR)

This will not execute the order, so you can safely run this.

ibkrbox -a 50000 -m 4 --es
image

3. construct a combo SPX Box Spread borrowing for 50K, duration 4 months (use "--execute" option to send the order to IBKR)

This will not execute the order, so you can safely run this.

ibkrbox -a 50000 -m 4 --short