For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
Define which specific method you want to inherit from strategy.
-
I want to inherit some functions in my strategy from a parent class (BaseStrategy).
Let's use this example:
def notify_cashvalue(self, cash, value): if value < starting_cash * self.terminate_threshold: self.log(f'Stopping strategy at due drop below {self.terminate_threshold * 100}% of initial cash.') self.cerebro.runstop()
This would be the function inside BaseStrategy and my actual strategy would inherit. This function requires that the terminate_threshold is defined in the child strategy. This could be a nuisance if I want to inherit the BaseStrategy, but I don't want that particular method. I know I could rewrite notify_cashvalue, however I would prefer to add the methods I want inherit instead of removing them. I want to customly compose the strategy instead of inheriting everything.