So I have created this custom class and relevant code like this -
Search for "rsiSelectionData.update(sec.EndTime, sec.AdjustedPrice, sec.DollarVolume)".
While debugging, the debugger goes to this line, but nest step it goes to next line
"validBuyValues = filter(lambda x : x.isBuyZone, self.stateData.values())"
Not sure why the debugger does not go into the custom update method?
I get the debt statements though. Any ideas? thank you
from Alphas.RsiAlphaModel import RsiAlphaModel
from Execution.ImmediateExecutionModel import ImmediateExecutionModel
from System import *
from System.Collections.Generic import List
from QuantConnect import *
from QuantConnect.Algorithm import QCAlgorithm
from QuantConnect.Data.UniverseSelection import *
'''
Simple testing strategy so that find all stocks for which the RSI is more than 20
Buy. - if RSI of today is more than 25, but yesterday was less than 25
Liquidate - if RSI of open positions goes above 75
SELL - if RSI today is less than 75 but yesterday was more than 75
Liquidate - if RSI of open positions goes below 25
'''
class ResistanceVentralThrustAssembly(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2019, 11, 20) # Set Start Date
self.SetEndDate(2019, 11, 21)
self.SetCash(10000) # Set Strategy Cash
# Strategy is for Daily data
self.UniverseSettings.Resolution = Resolution.Daily
#self.AddUniverse(self.MyCoarseFilterFunction, self.FineSelectionFunction)
self.AddUniverse(self.MyCoarseFilterFunction)
self.SetWarmUp(timedelta(20))
self.AddAlpha(RsiAlphaModel(60, Resolution.Daily))
self.SetExecution(ImmediateExecutionModel())
self.SetPortfolioConstruction(InsightWeightingPortfolioConstructionModel())
self.SetRiskManagement(TrailingStopRiskManagementModel(0.03))
self.__numberOfSymbols = 10
self.stateData = {}
def OnData(self, data):
'''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
Arguments:
data: Slice object keyed by symbol containing the stock data
'''
# if not self.Portfolio.Invested:
# self.SetHoldings("SPY", 1)
pass
def MyCoarseFilterFunction(self, coarse):
# Get all symbols by dollar volume
sortedByDollarVolume = sorted(coarse, key=lambda x: x.DollarVolume, reverse=True)
filtered = [x for x in sortedByDollarVolume
if x.Price > 10 ][:5]
for sec in filtered:
if sec.Symbol not in self.stateData:
self.stateData[sec.Symbol] = SelectionData(self, sec.Symbol, 14)
rsiSelectionData = self.stateData[sec.Symbol]
rsiSelectionData.update(sec.EndTime, sec.AdjustedPrice, sec.DollarVolume)
validBuyValues = filter(lambda x : x.isBuyZone, self.stateData.values())
return [x.Symbol for x in filtered[:1] ]
class SelectionData(object):
def __init__(self, algo, symbol, period):
self.symbol = symbol
self.rsi = ExponentialMovingAverage(period)
self.isBuyZone = False
self.volume = 0
self.algo = algo
def update(self, time, price, volume):
self.algo.Debug('test')
self.volume = volume
self.rsi.Update(time, price)
self.algo.Debug('rsi----')
self.algo.Debug(self.rsi)
Ray Trader
HOw can I close a discussion if I do not ned any more?
Jared Broad
Hey Ray! Mind posting the solution you discovered for others to learn?
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.
Ray Trader
I exacfly did not find a solution, but I worked my way around the step by step debug by multiple ways
So I can get the results I need
There should be a way to accept my comment as answer otherwise it troubles my OCD brain that this thing is still open
Ray Trader
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!