LEAN is the open source
algorithmic trading engine powering QuantConnect. Founded in 2013 LEAN has been built by a
global community of 80+ engineers and powers more than a dozen hedge funds today.
Alpha League Competition: $1,000 Weekly Prize Pool
Qualifying Alpha Streams Reentered Weekly Learn
more
I'm trying to figure out how to choose options contract base on time and not price, e.g buy an AAPL CALL contract at 10:00 (whatever the underlaying price is) and sell the next day at 16:00.
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.
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.
Soumya sen
133
,
Please check out this tutorial on Options and you should be able to place the orders.
Whan I run the code from the tutorial I'm getting this runtime error:
Runtime Error: UnboundLocalError : local variable 'i' referenced before assignment at OnData in main.py:line 82 :: optionchain = i.Value UnboundLocalError : local variable 'i' referenced before assignment (Open Stacktrace).
def OnData(self,slice):
for i in slice.OptionChains:
if i.Key != self.symbol: continue
optionchain = i.Value
self.Log("underlying price:" + str(optionchain.Underlying.Price))
df = pd.DataFrame([[x.Right,float(x.Strike),x.Expiry,float(x.BidPrice),float(x.AskPrice)] for x in optionchain],
index=[x.Symbol.Value for x in optionchain],
columns=['type(call 0, put 1)', 'strike', 'expiry', 'ask price', 'bid price'])
self.Log(str(df))
0
Alexandre Catarino
,
Hi Tal Shoham ,
I cloned the backtest from the tutorial soumya sen proposed and it doesn't reproduce the runtime error.
0
Alexandre Catarino
,
Hi Tal Shoham ,
I have modified the example above to use Schedule Events to buy the call at 10 am. It is a starting point for the strategy you want to implement.
Please note that since the schedule event method is parameterless, therefore we need to use self.CurrentSlice instead of the parameter slice in OnData method.
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...
To unlock posting to the community forums please complete at least 30% of Boot Camp. You can
continue your Boot Camp training progress from the terminal. We
hope to see you in the community soon!