Back

Dynamically-generated custom asset

I am trying to create a framework for option backtesting for the community to use.

I have everything ready to go but there is one major problem:

I can't make my own custom class a tradeable asset!

So what I want to do is on every OnData(TradeBars data) event of the underlying stock, I will create a new option instance. I will then calculate the theoretical price of this option and populate all its other fields. After this, it should then become a tradable asset such that we can call Order() on it. I've tried creating my own custom data with AddData<.Option.>("AAPL.CALL", Resolution.Hourly); (the dots are to escape the brackets for this post) but this class only reads data before starting the backtest. I need to be able to add data to this asset on the fly.

However, this isn't possible! And if I can't do that, we can't backtest actually buying and selling the option.

Can anyone help me out with this? If we can solve this I can have the option backtesting framework ready within the week.
Thanks in advance :)
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.



I just thought of something else. Alternatively I can use the new History() method to calculate the option prices up front but then I still need to be able to populate the custom data feed with local variables opposed to remote data. That is also not possible as of now.
0

Hey JP B, I've thrown together an example of creating another security using tradebar equity data, have a peek and let me know what you think!

I didn't put any models in here, so there's no accuracy, but it does show how you can create any type of derived data :)
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.


That is exactly what I need! I knew a little hack was needed to get it to work but I didn't know that it was possible to simply use the config of another symbol.

Very neat piece of code. Now I can definitely make it work.
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