backtrader.analyzers.positions module¶
Positions Analyzer Module - Position value tracking.
This module provides the PositionsValue analyzer for tracking the value of positions across all data feeds.
- Classes:
PositionsValue: Analyzer that reports position values over time.
示例
>>> cerebro = bt.Cerebro()
>>> cerebro.addanalyzer(bt.analyzers.PositionsValue, _name='posval')
>>> results = cerebro.run()
>>> print(results[0].analyzers.posval.get_analysis())
- class backtrader.analyzers.positions.PositionsValue[源代码]¶
基类:
AnalyzerThis analyzer reports the value of the positions of the current set of datas
Params:
timeframe (default:
None) IfNonethen the timeframe of the first data of the system will be usedcompression (default:
None)Only used for sub-day timeframes to, for example, work on an hourly timeframe by specifying "TimeFrame.Minutes" and 60 as compression
If None, then the compression of the first data in the system will be used
headers (default:
False)Add an initial key to the dictionary holding the results with the names of the data 'Datetime' as a key
cash (default:
False)Include the actual cash as an extra position (for the header 'cash' will be used as name)
- - get_analysis
Returns a dictionary with returns as values and the datetime points for each return as keys
- params = (('headers', False), ('cash', False))¶
- __init__(*args, **kwargs)[源代码]¶
Initialize the PositionsValue analyzer.
- 参数:
*args -- Positional arguments.
**kwargs -- Keyword arguments for analyzer parameters.