backtrader.analyzers.total_value module¶
TotalValue Analyzer Module - Portfolio value tracking.
This module provides the TotalValue analyzer for tracking the total portfolio value over time.
- Classes:
TotalValue: Analyzer that records portfolio value at each step.
示例
>>> cerebro = bt.Cerebro()
>>> cerebro.addanalyzer(bt.analyzers.TotalValue, _name='val')
>>> results = cerebro.run()
>>> print(results[0].analyzers.val.get_analysis())
- class backtrader.analyzers.total_value.TotalValue[源代码]¶
基类:
AnalyzerThis analyzer will get total value from every next.
Params: .. method:: - Get_analysis
Returns a dictionary with returns as values and the datetime points for each return as keys
- params = ()¶
- rets = None¶
- start()[源代码]¶
Initialize the analyzer at the start of the backtest.
Creates the ordered dictionary to store value history.
- next()[源代码]¶
Record the total portfolio value for the current bar.
Gets the current portfolio value from the broker and stores it keyed by datetime.