Back

OptionChainProvider.GetOptionContractList example in C#

Hi All,

Is there any example for Options trading in c# that uses OptionChainProvider.GetOptionContractList ?

Thanks

Nik

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.



you know the github project. There I found this 

https://github.com/QuantConnect/Lean/blob/702bb5616deacd2efa1d3402815144ca46ae968c/Algorithm.CSharp/OptionChainProviderAlgorithm.cs
1

Thank you Michael and Gustavo!

1

hehe :)

0

Here is an example of selling Short Strangle (Call + Put) for premium. Options are monthly, Unfortunately, LEAN doesn't allow to get weekly and daily options. 

There is also an implementation fir SetFilter, but OptionChainProvider seems more reliable.

https://www.quantconnect.com/forum/discussion/3705/check-if-portfolio-has-shares-or-options-separately/p1
0


I think we can allow daily/weekly, by default its filtered out though.



All the data is there =)
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.


Weekly options in a Chain Provider would be a significant step forward. In the meantime, here are some other examples for C#. All examples are for MSFT and strike prices are pretty random, so strategies can definitely be optimized.

1. Long Strangle

http://www.theoptionsguide.com/long-strangle.aspx

0


0


0


0


0


0


0


0


Some strategies are harder to implement, because I can't see how to compare Bid / Ask prices of options in a chain. For example, Risk Reversal - I found some Put option that I'd like to sell, so now I need to find Call option that costs less that my Put option. Something like this.Now we found Put option whose strike price is from -$0 to -$3 below underlying price

var atmPuts =
from c in contracts
where c.ID.OptionRight == OptionRight.Put
where price - c.ID.StrikePrice < 3 && price - c.ID.StrikePrice >= 0
where (c.ID.Date - Time).TotalDays < 35 && (c.ID.Date - Time).TotalDays > 0
select c;

var contractAtmPut = atmPuts
.OrderBy(o => o.ID.Date)
.ThenByDescending(o => price - o.ID.StrikePrice)
.FirstOrDefault();

Now we have Put option that we want to sell and get its Premium. Let's assume Bid price of this option is 5.25, so we can get $525 by selling it. I'm neutral to bullish, and to increase probability of my trade I need to find Call option that can increase my profit but cost of that Call shouldn't exceed cost of the premium from my Put option, because I need this premium to compensate commission and possible market move against me, so I want to find Call option whose Ask price is not more than 4.25

var otmCalls = 
    from c in contracts
    where c.ID.OptionRight == OptionRight.Call
    where contractAtmPut.BidPrice - c.AskPrice <= 1.0 // difference should be more than $100
    where (c.ID.Date - Time).TotalDays < 35 && (c.ID.Date - Time).TotalDays > 0
    select c;

Question: how to get these Ask / Bid prices?

0

nice stuff

0

The correct approach to building spreads is based on Deltas rather than prices.

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