Back

Framework Algorithm Style

Hi all,

when using the framework, one key part is to generate insights which are used to generate orders.

Besides the symbol and the direction a period is necessary for inside creation.

Insights.Add(Insight.Price(Symbol, insightPeriod, InsightDirection));

What is about algos which depend on distinct events like crossovers or other indicator values, where a period can not be determined beforehand. e.d. buy on SMA(short) > SMA(long), sell on SMA(short) < SMA(long).

How to create Insights or in general framwork components for such algorithms?

Is this style of algorithms meant for the framework at all?

Thx

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 Eugene,

In general, insights don't correlate directly to orders, rather they correlate to a prediction about market movements. The insight period should be the approximate time the prediction is valid. If an insight expires while the signal is still active because the period was too short, you can emit repeated insights to sustain a position.

There is no set way of determining the prediction interval. For example, for a SMA crossover strategy, you could use the period of the fast SMA. You can approximate how long the signal may be valid for.

Keep in mind, insights also require weights and other parameters. You can learn more about creating insights in the documentation

Best
Rahul

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.


Hi Eugene, Rahul,

I have also been struggling with this: which duration to set for insights when we cannot know in advance for how long the prediction will remain valid?

As much as I support the separation of concern and modularity explained by Rahul, it is very difficult in practice to think of insights in total abstraction of how they will actually be used... For example I would not want a position to be flattened just because I set a too short duration for the insight and it has expired (most portfolio construction models create flat targets for securities on insight expiry).

So far my solution has been:

  • To set a minimum frequency for insights emission (say at least once a week) - but it could be more often, depending on new data
  • Set the longest possible duration for all insights (e.g. 8 days in my example accounting for possible holiday), that way insights are systematically overridden before they expire
  • To explicitly emit flat insights when the expected outcome is to flatten the position (i.e. if the security is invested and the signal says flat, emit a flat insight)
Interested in additional advice or suggestions.Best
0

HI Pierre,

The three bullet points you've mentioned above are ways to work around using the framework to accomplish what you're intending, however: 

  • If your risk profile dictates you should be closing a position; you could use a risk module to adjust the portfolio target to 0-shares. The risk modules can override controls to directly manage the positions. 
  • If the fundamental signal changes you could emit a new one; or if it expires and is still valid you could re-up it. A fundamental change in thinking with the framework is to try and understand the predictive power of your signals. It hopes to encourage really considering whether the signal is predictive

The separation will become more important as you start reconstituting modules between projects. Emitting a down prediction for Apple might be an option-hedging opportunity for one algorithm. or a short, or a buy signal to set up for a long term investment. 

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 Jared, Pierre Rahul,

thx. for sharing your ideas/thoughts.

I ll try to implement the idea of predictiveness also from the time/expiration perspective, if possible.

And otherwise use the work around from Pierre. 

0

Hi Jared, Eugene,

I like the examples of separation of concern, this is really powerful.

Yet would there be a downside in allowing the alpha author to emit the insight with undetermined duration and later explicitly trigger its expiry if/when needed (rather than requiring the duration to be defined a priori)?

I kind of wish I could emit a prediction valid "until further notice" (or until some condition that I monitor is met).

Just a suggestion, as previously noted we can achieve what we want with the current features.

Regards

 

1

Thanks for the feedback, Pierre. I think the classic style of algorithm might be closer to what you're seeking. Alpha models should purely emit signals, and a key component of expected return is the time horizon. It is certainly harder but forces good habits. If the core signal is still valid as mentioned its perfectly fine to emit a follow-up signal. 

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.


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