Hi all,
I have just started studying Quantconnect, i did the bootcamps but i'm trying to deal directly with the algorithmic framework as it is more in line with my thinking (separation of concerns).
I am trying to write an algo purely for debugging purposes. I have to admit that one of the biggest challenges for me is to understand which data is spit out of the different event handlers. Would you have any hint on how to overcome this issue? I suspect that this is because everything here is treated as a “complex” object and therefore cannot be represented just by a pandas dataframe. You need to look into the objects to find which methods are actually returning one.
In the below algo i cannot start the backtest as it stops automatically after processing the execution method. Would you have an idea of why? Unfortunately i cannot attach any backtest as it returns “[STOPPED] Backtest stopped”
from AlgorithmImports import *
class LiquidValueStocks(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2017, 5, 15)
self.SetEndDate(2017, 9, 15)
self.SetCash(100000)
symbols = [Symbol.Create("CL", SecurityType.Future, Market.NYMEX), Symbol.Create("NG", SecurityType.Future, Market.NYMEX)]
self.AddUniverseSelection(ManualUniverseSelectionModel(symbols))
self.SetAlpha(CarverModel())
self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel())
self.SetExecution(ImmediateExecutionModel())
#self.UniverseSettings.dataNormalizationMode = DataNormalizationMode.BackwardsPanamaCanal
class CarverModel(AlphaModel):
def __init__(self):
self.data = []
def OnData(self, data):
for symbol, symbol_data in self.data.items():
if slice.Bars.ContainsKey(symbol):
return
def OnSecuritiesChanged(self, algorithm, changes):
self.data = [x for x in changes.AddedSecurities]
return
def Update(self, algorithm, data):
return
class SymbolData:
def __init__(self, algorithm, future):
self._future = future
self.Symbol = future.Symbol
self.dch = DonchianChannel(100,35)
algorithm.WarmUpIndicator(self.Symbol, self.dch, Resolution.Daily)
@property
def Update(self, bar):
self.dch.Update(bar.EndTime, bar.Close)
@property
def Multiplier(self):
return self._future.SymbolProperties.ContractMultiplier
@property
def Value(self):
if self.dch.IsReady:
return self.dch.Current.Value
Non Compete
I suggest adding some debug statements to see exactly where it stops. I'm not sure what you mean by after the execution method.
Louis Szeto
Hi Gianluca
Several issues here
Hope this gives you some insight on how to fix the issues. We recommend read through the docs of framework.
Best
Louis
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.
Gianluca Giuliano
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!