Back

Option Backtesting Framework v2

Alright, I've tried to fix some further bugs:

  • In-the-money and out-the-money is now relative to option type

  • Fixed some logic in the maturity declarations

  • Fixed the way options are referred to



The way we can refer to options is now (when using "MONTHLY" options):

Order("SPY.CALL.1.0", 80*100);

which means: Buy 80 CALL contracts with the first in-the-money strike price with the maturity in this month.

Or, an example for "WEEKLY" options:

Order("SPY.PUT.-2.2", 80*100);

which means: Buy 80 PUT contracts with the second out-the-money strike price with the maturity in two weeks.

Another example:

Order("SPY.CALL.-2.0", 80*100);

which means: Buy 80 CALL contracts with the second out-the-money strike price with the maturity in this week.

As I'm currently doing my master's (Quant Finance of course), I won't be able to spend any more time on this framework. I hope it can suffice as a help (or inspiration) to the formal framework that Jared&Team are developing.

Mind you, however, that I'm calculating the theoretical price of European options. Calculating the price of American options is a bit more difficult. Maybe QuantConnect can reach out to iVolatility, which have a very good calculator for both option types. Maybe they are willing to share their code? (Even CBOE uses their calculator)

Anyway, I wish you guys good luck with the formal framework!
Update Backtest






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.



As you can see from the backtest, I'm still having troubles with the 0$ value error. This is probably because I'm creating my own assets and the logic is quite complex. Maybe someone is able to solve this. Anyway, this is all I can help with the new option backtesting framework.

I propose that we don't just put options in QuantConnect, but that we built a complete option backtesting framework including all greeks and other option properties. QuantConnect is already superior, but if we can fully backtest options including all option bells and whistles, it will be unrivaled! :)
1

Epic algorithm share! Very cool! Insane to see a full Black Scholes implementation in an option data type! :)
1

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.


@Jared Thank you for the compliment! The framework is still far from finished and I noticed that it still contains some bugs when I clone the backtest from this page. Nevertheless, I hope it can be of use for the development of the formal option-backtesting framework :)

And, as I said before, it might be a good idea to contact iVolatility to see if you can, maybe, use their code (even if in encrypted API version, like a DLL) to calculate the theoretical prices of options more easily. Would of course be awesome to be able to base option strategy on statistics such as implied volatility and the greeks!
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