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
-
- looks like Yahoo data feed uses adjusted prices by default, and csv files has real prices therefore you can see
22.27 = 25.039 (open) x 21.347761 (adj close) / 24.00 (close)
try to use parameter
adjclose=False
with the data feed, and you should see the prices from the csv file.-
web page was made long time ago with the adjusted prices from that period, and csv file was downloaded couple years ago, prices are changes since new dividends and split might happen.
-
move forward on quickstart and you will learn it
-
thank you very much, it did help