Backtrader Community

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

    Topics created by Jerzy

    • J

      ./panda-test.py --noheaders -> AttributeError: 'numpy.int64' object has no attribute 'lower
      General Code/Help • • Jerzy

      3
      0
      Votes
      3
      Posts
      360
      Views

      J

      python ./panda-test.py --noheaders from __future__ import (absolute_import, division, print_function, unicode_literals) import argparse import backtrader as bt import backtrader.feeds as btfeeds import pandas def runstrat(): args = parse_args() # Create a cerebro entity cerebro = bt.Cerebro(stdstats=False) # Add a strategy cerebro.addstrategy(bt.Strategy) # Get a pandas dataframe datapath = ('../../datas/2006-day-001.txt') # Simulate the header row isn't there if noheaders requested skiprows = 1 if args.noheaders else 0 header = None if args.noheaders else 0 dataframe = pandas.read_csv(datapath, skiprows=skiprows, header=header, parse_dates=True, index_col=0) if not args.noprint: print('--------------------------------------------------') print(dataframe) print('--------------------------------------------------') # Pass it to the backtrader datafeed and add it to the cerebro data = bt.feeds.PandasData(dataname=dataframe) cerebro.adddata(data) # Run over everything cerebro.run() # Plot the result cerebro.plot(style='bar') def parse_args(): parser = argparse.ArgumentParser( description='Pandas test script') parser.add_argument('--noheaders', action='store_true', default=False, required=False, help='Do not use header rows') parser.add_argument('--noprint', action='store_true', default=False, help='Print the dataframe') return parser.parse_args() if __name__ == '__main__': runstrat()
    • J

      Execution price does not match opening price: quickstart:
      General Code/Help • • Jerzy

      3
      0
      Votes
      3
      Posts
      190
      Views

      J

      thank you very much, it did help

    • 1 / 1