Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    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

    General Discussion
    2
    2
    42
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Russell Turner
      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[0]
      
      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?

      1 Reply Last reply Reply Quote 0
      • A
        ab_trader last edited by

        You have no strategies to back test in your code, so it should be zero.

        1 Reply Last reply Reply Quote 2
        • 1 / 1
        • First post
          Last post
        Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
        $(document).ready(function () { app.coldLoad(); }); }