brndnmtthws / thetagang

ThetaGang is an IBKR bot for collecting money
GNU Affero General Public License v3.0
1.89k stars 248 forks source link

Optionally calculate net shorts #355

Closed brndnmtthws closed 5 months ago

brndnmtthws commented 5 months ago

In the event we want to use calendar spreads, we can have ThetaGang be a little more intelligent when calculating whether to write new positions or roll our current short contracts by computing the net short contracts. In effect, we count the short-dated contracts and subtract any longer-dated positions from those, giving us the net position. We also check that the long strikes are safely higher/lower (put/call) to avoid any traps.

This can be enabled by setting write_when.calculate_net_contracts = true.