Help Needed for Selling Put Options

Back

I am looking to write an algorithm in which I can sell put options for stocks while analyzing the ideal strike price and expiration period to maximize my profit. I am a beginner in QuantConnect so I wasn't sure if help for my project was available in the Options documentation I read. Any help is greatly appreciated. Thank you all in advance. 

Update Backtest







 
0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Hi Praveen,

We provide various options strategy implementations here.

Best,
Shile Wen

0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Hi Shile,

I tried implementing my idea with the given documentation, but I am having trouble analyzing the backtesting results attached. How can I determine where my Net Profit number is coming from, how many put options I sold, and how many assets I hold?

0


Hi Praveen,

We can get the unrealized profit of a contract using self.Portfolio[contractSymbol].UnrealizedProfit. To get the profit of all options, we can do sum([x.UnrealizedProfit for x in self.Portfolio.Values if x.Type == SecurityType.Option]). Furthermore, we can count the options sold by creating a variable self.options_sold and adding to it in OnOrderEvent. We can keep track of the number of assets we hold using len([x for x in self.Portfolio.Values if x.Invested]). Please see the attached backtest for reference.

Best,
Shile Wen

0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Hi Shile,

I decided to make a quick algorithm to see if I shorted put options for SPY for the last 3 months, how much money would I make. I believe I have correctly implemented this idea, but I am having trouble reading the backtest. I don't understand how the option profits are so high when premiums are usually under $10. Also, it shows that I have no non-option assets after selling 12 options. I feel like I have a clear mistake. Any help is appreciated.

Thanks,

Praveen

0


Hi Praveen,

That is because the profits are multiplied by some lot size, as options are bought and sold in lots. To find the lot size, we can use ContractMultiplier. As for why there are no assets, there will only be assets if the puts are ITM on expiration or exercised early, which would cause the put holders, whom you sold the puts to, exercise their puts.

Best,
Shile Wen

0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Hi Shile, 

Thank you for that information. Can this contract multiplier be changed? I tried setting self.option.ContractMultiplier = 1 but there are no changes reflected in the option profits. When I deploy for live trading, I will only look to sell a small amount. 

Thanks,

Praveen

0


Hi Praveen,

It's not possible to change the contract multiplier. It is set by the exchange.

Best,
Derek Melchin

0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


In the backtest I have attached, my code is for selling SPY put options and plotting various metrics to understand what is happening. However, I do not understand how Option Profit values are calculated. 

What does it mean for the Options Profit to be negative? I initially thought it meant spending to acquire SPY assets to fulfill an executed ITM Put agreement, but my non-option asset count stays at 0. 

Is the bid price the premium I sold the option for? Are the Option Profits supposed to be sum(premium * contract multiplier)?

Any help is appreciated.

Praveen

0


Hi Praveen,

The unrealized profits for all securities are tracked solely through the price of the security, so it can be negative if the security falls. The bid has nothing to do with the premium, it is the best price from buyers for the option contract. So the formula for profits is (initial contract price - current contract price) * quantity, and options are not a special case.

Best,
Shile Wen

0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed