Back

Simulation of options exercise is messing up the results

I had been trying to code up short strangles strategy. I was trying it for Google for the year 2017 with the code that I had modified and adapted from one of the posts in the discussion forum.

It seems that the back testing engine is going to simulate options exercise at random. In general, it is a good thing. However, I am not able to understand the results . It looks to me that it is being done at the price of the underlying Google stock instead of the options.

For example, this is one of the rows that I see

2017-05-15T04:00:00Z    GOOG  170519C00862500    871.2121212    -12    Option Exercise    Filled    -10454.54545    Simulated option assignment before expiration     -1045454.545
it seems that it is actually 12 shares of the Google stock at $ 871.

How do I reconcile this with the results?

Update Backtest








At the expiration date, an open option position will be exercised or assigned automatically if you do not liquidate it before the expiration. This simple example can help you understand how option algorithm works on LEAN. 

In this case, the algorithm purchases 1 put option "IBM 170217P00200000" with the strike price $200.  At the expiration date, the IBM price is $180.6500 < $200, the put option will be exercised automatically, it means you sell 100 shares of IBM stock at the price $200.

You can add OnOrderEvent() method to check the order details

def OnOrderEvent(self, orderEvent):
self.Log(str(orderEvent))
2017-02-01 09:31:00 : Time: 2/1/2017 2:31:00 PM OrderID: 1 Symbol: IBM 170217P00200000 Status: Submitted
2017-02-01 09:31:00 : Time: 2/1/2017 2:31:00 PM OrderID: 1 Symbol: IBM 170217P00200000 Status: Filled Quantity: 1 FillPrice: 27 USD OrderFee: 0.25 USD
2017-02-17 16:00:00 : IBM Price 180.6500
2017-02-17 16:00:00 : Time: 2/17/2017 9:00:00 PM OrderID: 2 Symbol: IBM 170217P00200000 Status: Submitted
2017-02-17 16:01:00 : Time: 2/17/2017 9:01:00 PM OrderID: 2 Symbol: IBM 170217P00200000 Status: Filled Quantity: -1 FillPrice: 0 Message: Adjusting(or removing) the exercised/assigned option
2017-02-17 16:01:00 : Time: 2/17/2017 9:01:00 PM OrderID: 2 Symbol: IBM Status: Filled Quantity: -100 FillPrice: 200 Message: Option Exercise/Assignment
0


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