For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
How does the backtrader get the cash or value of each step?
-
After the backtest, I want the value of funds for each step
results = cerebro.run()
After this code, what can I do to get it? I did not find a similar answer from the official document.
-
I use the following analyzer to get cash and value.
class CashMarket(bt.analyzers.Analyzer): """ Analyzer returning cash and market values """ def create_analysis(self): self.rets = {} self.vals = 0.0 def notify_cashvalue(self, cash, value): self.vals = (cash, value) self.rets[self.strategy.datetime.datetime()] = self.vals def get_analysis(self): return self.rets
-
Thank you for sharing your code.
Since the backtrader has a plot() function to draw the fund curve, it must store them internally. -
@MuSaCN said in How does the backtrader get the cash or value of each step?:
After this code, what can I do to get it?
one of the ways is using debugging tools get into
results
variable and check what data it contains.