Back

Trading monthly option

Hi, I'm new here.

Here's what I try to do. 

1. I only trade on the 4th Monday of the month

2. I only look at the monthly contract, to be exact 1 month from now, and at the beginning of the hour (not by the minute)

3. I want to get strike price between 0.9*price and 1.1*price

 

I wonder what is the best way to do it. I have the following code. Even though my start date is 2015/8/24, but I found the program start on 2015/9/14, not sure why.

 

Thanks.

Dan

 

 

-----------------------------------------

 

import pandas as pd

 

class QuantumVentralAutosequencers(QCAlgorithm):

 

    def Initialize(self):

        self.SetStartDate(2015, 8, 24)  #Set Start Date

        self.SetEndDate(2015, 9, 19)  #Set End Date

        self.SetCash(100000)  #Set Strategy Cash

        equity = self.AddEquity("QQQ", Resolution.Minute) # Add the underlying stock: QQQ

        option = self.AddOption("QQQ", Resolution.Minute) # Add the option corresponding to underlying stock

        self.symbol = option.Symbol

        option.SetFilter(-10, +10, timedelta(26), timedelta(32))     

 

 

    def OnData(self, slice):

        for i in slice.OptionChains:

            self.Log(str(self.Time))

            # print(i.key)

            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))

 

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.


Hi Danfeng,
I'd suggest reviewing the examples provided by QC for options, as there are multiple ways of managing the options universe, as well as some specific things that have to be done such as setting raw data normalization mode and using warmup.
You can setup an hourly data consolidator or use hourly time points if you only want to monitor or trade hourly data.
You can also use the debugger feature to try to diagnose bugs, otherwise logging can be useful.
Also you may find the latest Idea Streams Episode 5 useful as there is a python example provided which buys and manages put options which could provide a basic framework for what you are trying to do.
 

 

0

Thanks, Ernest,

Since I'm new here, could you please let me know where I can find "the latest Idea Streams Episode 5"? 

Thanks.

Dan

 

0

The Idea Streams episodes are on the right side of the front page in the algorithms lab when you have no projects open.
Just scroll down under the "QuantConnect News and Releases" section to see episode 5.
This is a youtube link and within the comments you will find the link to a basic python sample.
And for the LEAN examples you can find these at github:
https://github.com/QuantConnect/Lean/blob/master/Algorithm.Python/

0

Thanks a lot, Ernest. This is very helpful. 

Dan

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