Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. Yousuf
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
    Y
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 2
    • Best 0
    • Groups 0

    Yousuf

    @Yousuf

    0
    Reputation
    148
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    Yousuf Unfollow Follow

    Latest posts made by Yousuf

    • RE: PyFolio performance issues on Pandas Data Frame

      Apologies for not articulating the problem well enough in the first post. However, you have correctly inferred that I am facing issues with not being able to see intraday positions and returns from PyFolio analyzer.

      My run strat function looks like this:

      def runstrat1():
      
      args = parse_args()
      
      # Create a cerebro entity
      cerebro = bt.Cerebro(stdstats=True)
      
      # Add a strategy
      cerebro.addstrategy(strategy1.TestStrategy)
      
      # Get a pandas dataframe
      datapath = ('./dataset/data2.csv')
      dataframe = pd.read_csv(datapath,parse_dates=True,index_col=0)
      
      # Pass it to the backtrader datafeed and add it to the cerebro
      data = PandasDataExpanded(dataname=dataframe)
      
      cerebro.adddata(data)
      
      # Add PyFolio Analyzer
      cerebro.addanalyzer(bt.analyzers.PyFolio, _name='pyfolio')
      
      # Run over everything
      strats = cerebro.run()
      
      returns, positions, transactions, gross_lev = pyfoliozer.get_pf_items()
      
          for each in strat0.analyzers:
              each.print()
      
          print(positions['cash'])
      
          # Plot the result
          if not args.noplot:
              cerebro.plot(style='bar')
      
          return positions
      

      My class for pandas data feed look like this:

      class PandasDataExpanded(btfeeds.PandasData):
      
      lines = ('barCount',)
      params = (('barCount', -1),)
      
      posted in Indicators/Strategies/Analyzers
      Y
      Yousuf
    • PyFolio performance issues on Pandas Data Frame

      0_1531641830697_Screen Shot 2018-07-15 at 4.03.15 PM.png

      PyFolio is returning a single value for each day when generating data frame for returns and positions. Meanwhile, transaction data frame shows intra-day execution.

      When the data is ingested from Generic CSV feed, PyFolio is able to iterate through each data observation and return positions and returns value

      posted in Indicators/Strategies/Analyzers
      Y
      Yousuf