For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

Extracting variables defined in strategy



  • Hi,
    There are usually a bunch of variables defined in a strategy. For example, what I would like to do is:

    class MyStrategy(Strategy):
        def __init__(self):
            self.sstc = indicators.Stochastic(data, ....)
            self.sma = indicators.SimpleMovingAverage(data, ...)
    
            self.indicators_log = {"sstc": self.sstc, "sma": self.sma}
    

    To extract the variables in the strategy, e.g. indicators_log, I tried to add analyzer:

    class MyAnalyzer(Analyzer):
        def get_analysis(self):
            indicators_log = self.indicators_log
            ... do something ...
            return indicators_log
    

    But obviously it doesn't work
    So my question is..
    (1) Is it possible to extract the variables defined in the strategy, e.g. indicator_log, in analyzer?
    (2) If not, are there any recommendations to get the variables? (better including their name, for me to do further analysis in some later time)

    Thanks


  • administrators

    @JohnShiu said in Extracting variables defined in strategy:

    (1) Is it possible to extract the variables defined in the strategy, e.g. indicator_log, in analyzer?

    See Docs - Analyzers

    Each analyzer has automatically an attribute named strategy which obviously points to the strategy in which the analyzer is inserted.