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.

Example

>>> 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[source]

Bases: Analyzer

This 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()[source]

Initialize the analyzer at the start of the backtest.

Creates the ordered dictionary to store value history.

next()[source]

Record the total portfolio value for the current bar.

Gets the current portfolio value from the broker and stores it keyed by datetime.

get_analysis()[source]

Return the total value analysis results.

Returns:

Dictionary mapping datetimes to portfolio values.

Return type:

OrderedDict