SkillAgentSearch skills...

Thetagang

ThetaGang is an IBKR bot for collecting money

Install / Use

/learn @brndnmtthws/Thetagang
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Docker publish Python Publish Docker Pulls PyPI download month

💬 Join the Matrix chat, we can get money together.

Θ ThetaGang Θ

Beat the capitalists at their own game with ThetaGang 📈

Decay my sweet babies

ThetaGang is an IBKR trading bot that started as a basic implementation of "The Wheel" strategy and has grown into a broader, configurable portfolio automation tool. The Wheel is a strategy that surfaced on Reddit, but has been used by many in the past. ThetaGang still supports a modified version of The Wheel, and now also includes features like direct share rebalancing, cash management, VIX call hedging, regime-aware rebalancing, and exchange-hours gating.

Risk Disclaimer

⚠️ WARNING: Options trading involves substantial risk and is not suitable for all investors. Selling options can result in significant losses, potentially exceeding your initial investment. Selling naked puts has theoretically unlimited downside risk if the underlying asset goes to zero. This is not a "free money" strategy—you are being compensated for taking on real financial risk.

Before using ThetaGang:

  • Understand that you can lose money, especially in trending or volatile markets
  • Ensure you have sufficient capital to handle worst-case scenarios
  • Be prepared to own the underlying securities at potentially unfavorable prices
  • Consider paper trading first to understand the mechanics and risks
  • Consult with a financial advisor if you're unsure about the risks

How it works

Start by reading the Reddit post to get some background.

The strategy, as implemented here, does a few things differently from the one described in the post above. For one, it's intended to be used to augment a typical index-fund based portfolio with specific asset allocations. The default configuration includes a diversified portfolio with SPY (40%), QQQ (30%), TLT (20%), and smaller positions in individual stocks. This strategy reduces risk, but may also limit gains from big market swings. By reducing risk, one can increase leverage.

ThetaGang is quite configurable, and you can adjust the parameters to suit your preferences and needs, but the default configuration is designed to be a good starting point. ThetaGang makes some assumptions about how to run this strategy, but you can tweak it to your liking by modifying the thetagang.toml file.

The main difference between ThetaGang and simply buying and holding index funds is that this script will attempt to harvest volatility by selling options, rather than buying shares directly. This works because implied volatility is typically higher than realized volatility on average. Instead of buying shares, you write puts. This has pros and cons, which are outside the scope of this README.

ThetaGang can also be used in combination with other strategies such as PMCCs, Zebra, stock replacement, and so forth. For these strategies, however, ThetaGang will not manage long positions for you. You will need to manage these positions yourself. ThetaGang will, however, continue to execute the short legs of these strategies as long as you have the buying power available and set the appropriate configuration (in particular, by setting write_when.calculate_net_contracts = true).

Running multiple strategies safely

If you want to run materially different strategies, it is strongly recommended to use separate IBKR accounts (for example, separate linked sub-accounts) and fund each one independently.

Mixing multiple strategy styles in one account can produce confusing or harmful interactions because ThetaGang decisions are account-level. Buying power usage, position targeting, rebalancing logic, option rolls, cash management, and hedge logic all see the same combined portfolio and can interfere with each other in ways that are hard to reason about.

In practice, one strategy per account is usually the cleanest setup:

  • Cleaner risk boundaries and capital budgets
  • Cleaner performance attribution
  • Fewer unexpected cross-strategy side effects
  • Easier debugging when behavior is not what you expected

Over time, additional features were added to support different portfolio workflows and risk controls. You can enable or disable them independently via config:

  • Direct share rebalancing (buy-only and sell-only modes)
  • Cash management via a cash-equivalent fund
  • VIX call hedging
  • Regime-aware rebalancing gates
  • Exchange-hours enforcement

ThetaGang will try to acquire your desired allocation of each stock or ETF according to the weights you specify in the config. To acquire the positions, the script will write puts when conditions are met (config parameters, adequate buying power, acceptable contracts are available, enough shares needed, etc).

ThetaGang will continue to roll any open option positions indefinitely, with the only exception being ITM puts (although this is configurable). Once puts are in the money, they will be ignored until they expire and are exercised (after which you will own the underlying). When rolling puts, the strike of the new contracts are capped at the old strike plus the premium received (to prevent your account from blowing due to over-ratcheting up the buying power usage).

If puts are exercised due to being ITM at expiration, you will own the stock, and ThetaGang switches from writing puts to writing calls at a strike at least as high as the average cost of the stock held. To avoid missing out on upward moves, you can limit the number of calls that are written with write_when.calls.cap_factor, such as setting this to 0.5 to limit the number of calls to 50% of the shares held.

Please note: this strategy is based on the assumption that implied volatility is, on average, always higher than realized volatility. In cases where this is not true, this strategy will cause you to lose money.

In the case of deep ITM calls, the bot will prefer to roll the calls to next strike or expiration rather than allowing the underlying to get called away. If you don't have adequate buying power available in your account, it's possible that the options may get exercised instead of rolling forward and the process starts back at the beginning. Please keep in mind this may have tax implications, but that is outside the scope of this README.

In normal usage, you would run the script as a cronjob on a daily, weekly, or monthly basis according to your preferences. Running more frequently than daily is not recommended, but the choice is yours. Some features (like regime-aware rebalancing) assume a daily cadence.

Paper account sample output

VIX call hedging

ThetaGang can optionally hedge your account by purchasing VIX calls for the next month based on specified parameters. The strategy is based on the Cboe VIX Tail Hedge Index, which you can read about on the internet. You can enable this feature in thetagang.toml with:

[vix_call_hedge]
enabled = true

Default values are provided, based on the VXTH index, but you may configure them to your taste. Key parameters include:

[vix_call_hedge]
enabled = true
allocation = 0.01  # 1% of buying power
close_hedges_when_vix_exceeds = 50  # Auto-close at high VIX
ignore_dte = 5  # Don't hedge if expiry within 5 days

See thetagang.toml for all available options.

Buying VIX calls is not free, and it will create some drag on your portfolio, but in times of extreme volatility–such as the COVID-related 2020 market panic–VIX calls can provide outsized returns.

Cash management

At the time of writing, interest rates have reached yields that make bonds look attractive. To squeeze a little more juice, thetagang can do some simple cash management by purchasing a fund when you have extra cash. Although you do earn a yield on your cash balance, it's not the juiciest yield you can get, so a little optimization might help you earn 1 or 2 extra pennies to take the edge off your rent payments.

You can enable cash management with:

[cash_management]
enabled = true
fund = "SGOV"  # Default short-term treasury ETF
buy_threshold = 0.01  # Buy when cash > 1% of buying power
sell_threshold = 0.005  # Sell when cash < 0.5%

[cash_management.orders]
algo.strategy = "Vwap"  # Use VWAP for cash fund orders

This feature uses VWAP (Volume Weighted Average Price) orders by default to minimize market impact when moving in and out of cash positions. Refer to thetagang.toml for all the options.

Advanced Features

ThetaGang includes several advanced features that provide fine-grained control over your trading strategy:

Buy-Only Rebalancing

For symbols where options premiums are insufficient or unavailable, you can enable direct stock purchases for portfolio rebalancing:

[symbols.AAPL]
buy_only_rebalancing = true
buy_only_min_threshold_shares = 10  # Minimum shares to buy
buy_only_min_threshold

Related Skills

View on GitHub
GitHub Stars2.5k
CategoryDevelopment
Updated10h ago
Forks357

Languages

Python

Security Score

100/100

Audited on Mar 26, 2026

No findings