Few queries on the working of Algorithm Framework to implement Swing trading strategy

Back

I am creating a new Swing trading strategy based algorithm using the Algorithm framework.

This algorithm is based on couple of indicators like Moving average & RSI and is using daily resolution.

Although I have read the documentation but could not get answers to some of my below mentioned questions:

1) I have created a custom Alpha model which on the basis of indicators generate insights, however, Insight object expects expiry date. As this is a swing trading based strategy, I am not sure about the expiry of an insight or an entry signal. The algo will close the position as soon as it gets the exit signal. This could be between 5 days to a month - may be more than that. so in this case, what date should ideally be used in insight as an expiry?

2) Where should I handle the logic to close the existing positions. Is that in the Portfolio construction or Risk management model?

3) Since the resolution being used is daily, what time of the day an Update method will be called in Alpha Creation?

4) Although the resolution is daily, I still want to keep a check on my positions on an hourly basis and exit from my positions as soon as my stop loss is hit. How do I achieve this? Which model can be used to implement this?

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.


Hey Nitesh,

1) When using the framework, The AlphaModel must emit insights, which are essentially predictions on the price movement of a symbol over a period of time in the future. Insights require a duration for which that prediction is valid. Generally, when using the framework, the goal is to create accurate predictions which can be acted on.

However, It sounds like your strategy requires precise control over your positions. Don't feel forced to use the framework when it isn't compatible with your strategy. You will be able to more precisely control your trades and positions with a classic algorithm, which acts on the basis of orders (MarketOrder, LimitOrder, StopMarketOrder, etc) rather than insights.

2) If you use a classic algorithm, you can precisely code in your exit logic. If you decide to use a framework algorithm, you can emit a flat insight to sign an exit.

There are already many built-in portfolio construction models & risk management models which handle unloading positions.

3) The Update and OnData methods are called every time a new set of bars is available for your symbols, which is at the end of the day for daily resolution data.

4) It is possible to do this by setting your data subscriptions/universe resolution to the hourly resolution, and using daily consolidators for your indicators.

self.UniverseSettings.Resolution. = Resolution.Hour

 

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.


Thanks Rahul for your precise answer.

The only reason I am more inclined to use Framework is due to separation of concerns. For now, I will just carry on using the framework and see if I could achieve the same output otherwise I will resort to Classic Algorithm method. 

0

I have similar logic as yours with the Framework and it works quite well. I don't use the default *model implementations.

- Alpha model to generate insights, insights have a expire date

- ExecutionModel decides on the trade execution, enter & exit points. Sometimes insights to enter a trade are never executed, because execution model decides whether to enter or not

- Risk Management to generate insights to close trades.

For my risk/execution, I will need data every minute, but my trades are longer than a day, sometimes a trade will run many months. It's very unusual to have intraday trades.

 

0

Erik Bengtson 

Hi Eric,

Thanks for your response.

On what basis do you generate insights if you use ExecutionModel for entry and Exit points. Do you check an opportunity twice - once in Alpha model and then in execution model before entering into trade?

How do you decide about the expiry date of an insight?

Do you use consolidators to warm up your indicators if you use any?

thanks

 

1

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