Backtrader Community

    • 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/

    [Bug?]: `PyFolio. get_pf_items` Only returns 1 dataset and Cash weight

    General Code/Help
    2
    2
    339
    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.
    • S
      Scott Lee last edited by Scott Lee

      Hi, recently I am using pyfolio analyzer to make backtrader work with pyfolio. One thing I notice is that, for the most recent version of backtrader, if the backtest contains multiple data feeds,

      returns, positions, transactions, gross_lev = pyfoliozer.get_pf_items()
      

      The positions will only contains two columns, the last added dataset's weight and cash's weight. After digging into the source code, I think the problem is caused by

      ps = [[k] + v[-2:] for k, v in iteritems(pss)]
      

      In the get_pf_items function. After changing it to

      ps = [[k] + v[:] for k, v in iteritems(pss)]
      

      Fixed this issue.

      Would like to know if only showing the most recent dataset is a designed feature. Thanks. (Let me know if you need a minimum code to replicate it)

      1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators last edited by

        The pyfolio API keeps on changing and it is not even guaranteed to work, like it happens (or used to happen) with the test sample.

        • https://www.backtrader.com/docu/analyzers/pyfolio.html

        Neither a feature nor a bug.

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors