thank you very much, it did help
Best posts made by Jerzy
-
RE: Execution price does not match opening price: quickstart:
-
RE: ./panda-test.py --noheaders -> AttributeError: 'numpy.int64' object has no attribute 'lower
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()
Latest posts made by Jerzy
-
RE: ./panda-test.py --noheaders -> AttributeError: 'numpy.int64' object has no attribute 'lower
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()
-
./panda-test.py --noheaders -> AttributeError: 'numpy.int64' object has no attribute 'lower
the example ./panda-test.py --noheaders in Data-Feed panda section of the documentatioin gives an error:
feeds/pandafeed.py", line 212, in <listcomp> colnames = [x.lower() for x in self.p.dataname.columns.values] AttributeError: 'numpy.int64' object has no attribute 'lower'
without --noheaders works just fine.
What is a problem with --noheaders -
RE: Execution price does not match opening price: quickstart:
thank you very much, it did help
-
Execution price does not match opening price: quickstart:
the very first BUY/SELL example in https://www.backtrader.com/docu/quickstart/quickstart/ (Do not only buy … but SELL) has problem that the execution price
of a market order is NOT the opening price of the next bar
Datafile at datapath = os.path.join(modpath, '../../datas/orcl-1995-2014.txt')
has the following content:
Date,Open,High,Low,Close,Adj Close,Volume
....
2000-01-05,25.406250,26.593750,24.000000,25.500000,22.681999,166054000
2000-01-06,25.039049,26.250000,23.671875,24.000000,21.347761,109880000the output from the example says this:
2000-01-05, Close, 22.68
2000-01-05, BUY CREATE, 22.68
2000-01-06, BUY EXECUTED, 22.27
2000-01-06, Close, 21.35so the opening price at 2000-01-06 is 26.593750
but the execution price is 22.27
how comes: it is not even in the trade range for this day.second problem: the data in the webpage example does not match the data in
the file orcl-1995-2014.txt
the data in the webpage gives:
2000-01-05T00:00:00, Close, 24.05
2000-01-05T00:00:00, BUY CREATE, 24.05
2000-01-06T00:00:00, BUY EXECUTED, 23.61
2000-01-06T00:00:00, Close, 22.63third:
how and where is the execution price set and how to find it out
some sort of trace functions calls?please help