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/

    pyfolio issue need help

    General Discussion
    1
    2
    19
    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.
    • P
      petehe last edited by

      I was doing a very simple test on pyfolio, but it gives me an error below,

      Does anyone know how this can be fixed?

      TypeError: create_full_tear_sheet() got an unexpected keyword argument 'gross_lev'

      code block

      if name == 'main':
      # Create a cerebro entity
      cerebro = bt.Cerebro()
      datapath = 'datas\orcl-1995-2014.txt'
      data = bt.feeds.YahooFinanceCSVData(
      dataname=datapath,
      # # Do not pass values before this date
      fromdate=datetime.datetime(2000, 1, 1),
      # # Do not pass values before this date
      todate=datetime.datetime(2010, 12, 31),
      # # Do not pass values after this date
      reverse=False
      )
      # Add the Data Feed to Cerebro
      cerebro.adddata(data)
      cerebro.addanalyzer(bt.analyzers.PyFolio, _name='pyfolio')
      thestrats = cerebro.run()
      pyfstats = thestrats[0].analyzers.getbyname('pyfolio')
      returns, positions, transactions, gross_lev = pyfstats.get_pf_items()
      import pyfolio as pf
      pf.create_full_tear_sheet(
      returns,
      positions=positions,
      transactions=transactions,
      gross_lev=gross_lev,
      live_start_date='2000-01-01', # This date is sample specific
      round_trips=True
      )
      ····# code block

      1 Reply Last reply Reply Quote 0
      • P
        petehe last edited by

        format it a bit better

        if __name__ == '__main__':
            # Create a cerebro entity
            cerebro = bt.Cerebro()
        
            datapath = 'datas\\orcl-1995-2014.txt'
            data = bt.feeds.YahooFinanceCSVData(
                dataname=datapath,
                # # Do not pass values before this date
                fromdate=datetime.datetime(2000, 1, 1),
                # # Do not pass values before this date
                todate=datetime.datetime(2010, 12, 31),
                # # Do not pass values after this date
                reverse=False
            )
        
            # Add the Data Feed to Cerebro
            cerebro.adddata(data)
            cerebro.addanalyzer(bt.analyzers.PyFolio, _name='pyfolio')
            thestrats = cerebro.run()
            pyfstats = thestrats[0].analyzers.getbyname('pyfolio')
            returns, positions, transactions, gross_lev = pyfstats.get_pf_items()
        
            import pyfolio as pf
        
            pf.create_full_tear_sheet(
                returns,
                positions=positions,
                transactions=transactions,
                gross_lev=gross_lev,
                live_start_date='2000-01-01',  # This date is sample specific
                round_trips=True
            )
        
        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
        $(document).ready(function () { app.coldLoad(); }); }