LEAN is the open source
algorithmic trading engine powering QuantConnect. Founded in 2013 LEAN has been built by a
global community of 80+ engineers and powers more than a dozen hedge funds today.
Alpha League Competition: $1,000 Weekly Prize Pool
Qualifying Alpha Streams Reentered Weekly Learn
more
I am trying to add multiple time consolidators to the multiple symbol consolidation algorithm. I want to use both 5 and 15 minute time frames. The problem is the algorithm is only trading the last symbol in the equity list but Im not sure where the problem is. Any help would be appriciated.
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.
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.
Michael Manus
10.2k Pro
,
for symbol in self.Data.keys():
symbolData = self.Data[symbol]
you loop through and safe only the last one? maybe its this line
0
Jack Simonson
Pro
,
Hi Eric,
Looks like Michael found the right spot. Given the way the for-loops in the OnData section are currently written, the algorithm will only trade the last equity in the list. Instead, if I understand the general idea of the code correctly, the algorithm should evaluate the trade logic inside the for-loop rather than outside of it. Take a look at the code snippet below and this should solve the problem.
def OnData(self,data):
# Loop through symbols. Since symbols are ordered for both dictionaries,
# 'symbol' with properly access both self.Data and self.Data15
for symbol in self.Data.keys():
symbolData = self.Data[symbol]
symbolData15 = self.Data15[symbol]
## Keep trade logic inside for-loop to enrue all assets are traded
if not self.Portfolio[symbol].Invested and
symbolData15.MACD15.Current.Value > symbolData15.MACD15.Signal.Current.Value and
symbolData.MACD.Current.Value > 0 :
self.SetHoldings(symbol, self.PositionSize)
if self.Portfolio[symbol].Invested and symbolData.MACD.Current.Value < 0 :
self.Liquidate(symbol)
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...
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!