Back

Convert orders into insights

Hello,

I have a difficult time understanding why some of the times the orders (and total trades) in some of my algorithms are also counted towards the total insight count, but other times with other of my algorithms the insights are not created while the algorithm makes trades and orders as normal. I would like to know how to convert the orders of the algorithm into insights so that every order and trade the algorithm makes is also counted towards the total insights created.

Thank you!

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

You can use self.EmitInsights to emit insights for each order you create. For example, let's say our algorithm purchases shares if a simple moving average crossover occurs.  We can emit an upwards insight when we enter long and a flat insight for when we exit. A downwards insight can be emitted when we enter a short position. The duration of the insight should be the duration of the prediction for price movements in that direction and not necessarily how long you will stay in that position.

def Initialize(self):
self.SetStartDate(2020, 1, 1)
self.SetEndDate(2020, 2, 1)
self.SetCash(100000)
self.aapl = self.AddEquity("AAPL", Resolution.Daily).Symbol
self.fast_sma = self.SMA("AAPL", 14, Resolution.Daily)
self.slow_sma = self.SMA("AAPL", 28, Resolution.Daily)

def OnData(self, data):

if not self.fast_sma.IsReady or self.slow_sma.IsReady:
return

if self.fast_sma.Current.Value > self.slow_sma.Current.Value:
if not self.Portfolio[self.aapl].Invested:
self.SetHoldings(self.aapl, 1)
insight = Insight.Price(self.aapl, timedelta(days=14), InsightDirection.Up)
self.EmitInsights(insight)
else:
if self.Portfolio[self.aapl].Invested:
self.SetHoldings(self.aapl, 0)
insight = Insight.Price(self.aapl, timedelta(days=14), InsightDirection.Flat)
self.EmitInsights(insight)

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.


Thank you! This was very helpful!

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