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 to use VWR
Russell Turner last edited by
I am new to backtrader and a novice at python. I was trying to figure out how to use the "VWR" analyzer.
from __future__ import (absolute_import, division, print_function, unicode_literals) from datetime import datetime import backtrader as bt import backtrader.analyzers as btanalyzers cerebro = bt.Cerebro() data = bt.feeds.YahooFinanceData(dataname='SPY', fromdate=datetime(2019, 1, 1), todate=datetime(2019, 12, 31)) cerebro.adddata(data) # Analyzer cerebro.addanalyzer(btanalyzers.VWR, _name='myvwr') thestrats = cerebro.run() thestrat = thestrats print('VWR: ', thestrat.analyzers.myvwr.get_analysis())
I get this as a result:
VWR: OrderedDict([('vwr', 0.0)])
I think the result shouldn't be 0.0 so i think i did something wrong. Or maybe I need to show more decimal places? But i couldn't figure out how to do that?
You have no strategies to back test in your code, so it should be zero.