brndnmtthws / thetagang

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

Rolling puts with increasing Delta #347

Open algoeng opened 10 months ago

algoeng commented 10 months ago

So when configuring with delta of 0.3 (which is the default), first time writing a put looks fine, say the put is written for the strike of S. But as the price of the underlying rises, looks like rolling just happens and we are stuck with the strike of S, now floating with delta way below 0.3. Is this intended? I looked at the code and I see the roll_positions() just does a min of config's strike_limit and position.contract.strike (plus cost so downward moving of price works correctly) to get a strike_limit, so I don't think the is a way to configure it so that we actually increase the strike and follow our 0.3 configuration for rolling puts?

brndnmtthws commented 10 months ago

This is indeed how it's intended to work, so I'll explain why this happens. First, let me present a hypothetical situation:

Imagine you have a $10,000 account, with no other positions (just cash), and you want to write 1 ATM put (~0.5 delta) to buy a stock at a strike of $100 (100 x $100 = $10,000). Also suppose the premium you collect from that put is $1.00 per contract.

After you sell that put, you should now have $10,100 in your account.

Now, some time passes, and the underlying stock price jumps from $100 to $110 (imagine a bull run like we've had recently). The cost to purchase 100 shares goes from $10k to $11k, but you only have $10,100 (i.e., you can't afford it). In this case, if you rolled the put from $100 to $110, you'd be adding margin risk (if you get assigned, your cash balance would become negative).

Okay, so given what we know here, we shouldn't be rolling from $100 to $110 because we don't want to blow up our account.

So how does thetagang handle this? The trouble is that it gets quite tricky to figure out in a sane way how to handle this situation when you have a margin account with different positions and yadda yadda. So thetagang takes a pretty simple approach and limits the next strike to the previous strike + credit collected.

To illustrate, in the example above we sold the put for $1, so if we assume that the option chain has contracts at every dollar increment ($100, $101, $102, ...) then it's not going to be possible to roll the contract up at all, because we'll never collect that full $1 unless it expires worthless. Thetagang will likely just roll it to the next $100 strike, however delta is going to be much lower as a result. This creates an issue with diminishing returns in bull markets.

In another scenario, imagine we sold the same put for $2.00 at a $100 strike. Suppose some time passes, and the put is up 50% (in other words, it's now worth $1), so we have effectively earned $1 per contract. In this case, thetagang can roll from the $100 strike to $101 (i.e., $100 + $1, the credit earned). Even in this case, during a bull run you're going to underperform.

Thetagang only deals with position sizing when writing new puts. It looks at the account net liquidation value, and the amounts you've allocated per position, and only writes new puts when you are underweight and all the other conditions are met. It doesn't try to be clever when it comes to rolling positions. Thetagang doesn't do anything that would add or multiply risk, beyond what you've specified in terms of sizing the initial positions. The market can always go back down swiftly.

If you don't like this behaviour, the alternative would be to avoid rolling puts. You can adjust the settings to close the positions when you hit some P&L, and the cycle will continue by writing new puts next time around.

However, keep one thing in mind: you will pretty much never be able to outperform in a bull market by writing puts. You will miss out on the upside if you don't actually hold the underlying, and if you have covered calls then your upside is always going to be capped.

FWIW, thetagang does provide quite a few knobs to adjust this behaviour to your taste. And generally speaking you need to adapt and adjust your strategy as you go to account for changes to market conditions.

algoeng commented 10 months ago

Thank you for the thorough explanation. Diminishing returns in a bull market is exactly the issue I am concerned about. And I fully understand that we are going to underperform. However, imagine setting up Thetagang for SPY on March of 2020, and it would have gotten stuck rolling puts at strike $220. I actually thought about setting a lower profit target for closing than rolling, but since I run it once a day it would mean it will leave me out of the market for a day, which is not a behavior I like. I think a config option to roll up the puts until, as you mentioned, we no longer can afford it (which would be the strike_limit at that point) would be nice. So I guess I am asking for a feature... :-)

robby28-11 commented 5 months ago

If you don't like this behaviour, the alternative would be to avoid rolling puts. You can adjust the settings to close the positions when you hit some P&L, and the cycle will continue by writing new puts next time around.

That would be nice if this would work sequentally.

Short explanation what is in my mind: Selling Puts, Underlying increases, rolling will not find a suitable contract (e.g. too low premium) then check if Pnl to close position is reached, and possibly close position. Does that makes sense to you?

Second option would be to reduce the options. The rolling process looks to me to always roll the same amount. But when 3 options now exceed the weight, we could reduce to 2 options.

Btw is there anywhere some room to chat about this stuff? Discord? The Element channel does not seem to work?

brndnmtthws commented 5 months ago

That would be nice if this would work sequentally.

Short explanation what is in my mind: Selling Puts, Underlying increases, rolling will not find a suitable contract (e.g. too low premium) then check if Pnl to close position is reached, and possibly close position. Does that makes sense to you?

That's interesting, it should be fairly easy to do something like this. Personally I don't like having a lot of gamma risk so I prefer to always roll or close rather than letting contracts expire worthless.

Second option would be to reduce the options. The rolling process looks to me to always roll the same amount. But when 3 options now exceed the weight, we could reduce to 2 options.

This seems a bit tricky, and I worry about edge cases.

Btw is there anywhere some room to chat about this stuff? Discord? The Element channel does not seem to work?

The matrix chat was broken for a while (my bad, config error), but it should be working now. I'm in there, and I'll generally respond when I can.