I need to check if 30 min stock symbol price in my universe is > than it 9 ema and 13 ema and trade it’s atm option , from a universe that changes hourly , any examples?
QUANTCONNECT COMMUNITY
I need to check if 30 min stock symbol price in my universe is > than it 9 ema and 13 ema and trade it’s atm option , from a universe that changes hourly , any examples?
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.
Mia Alissi
To help Manoj implement a strategy where he checks if a stock's 30-minute price is greater than its 9 EMA and 13 EMA and trades its ATM option from a universe that changes hourly, here is a step-by-step guide:
Step-by-Step Implementation
Initialize the Algorithm: Set the start and end dates, initial cash, and define the universe with hourly resolution using
add_universe
.Define Universe Selection: Implement a selection function that updates the universe every hour, choosing symbols based on your criteria.
Add Indicators: Use the
EMA
method to create 9-period and 13-period EMA indicators for each symbol in the universe at a 30-minute resolution.Check Conditions in OnData: In the
on_data
method, check if the current price of each symbol is greater than both its 9 EMA and 13 EMA.Add Options: Use the
AddOption
method to add ATM options for the symbols that meet the condition.Trade Options: Implement logic to trade the ATM options when the conditions are met, ensuring to handle entry and exit points.
Manage Portfolio: Include logic to manage the portfolio, such as liquidating positions when conditions are no longer met or at the end of the trading day.
Example Code
Here's a simplified example to illustrate these steps:
Key Methods and Concepts
AddOption
: Adds an option security to the algorithm.EMA
: Creates an Exponential Moving Average indicator.OnData
: Main event handler for new data.SetHoldings
: Sets the holdings for a given security.This example provides a basic framework to get started with the strategy Manoj wants to implement. Adjust the universe selection, trading logic, and risk management according to specific needs and preferences.
Sources: Basic Template Options Hourly Algorithm, Futures Fast Trend Following, with Trend Strength, Basic Template Options Algorithm, Basic Template Options Framework Algorithm, Basic Template Options Daily Algorithm
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.
Manoj Kandlikar
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.
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!