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/

    Execution price does not match opening price: quickstart:

    General Code/Help
    2
    3
    163
    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.
    • J
      Jerzy last edited by

      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,109880000

      the 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.35

      so 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.63

      third:
      how and where is the execution price set and how to find it out
      some sort of trace functions calls?

      please help

      1 Reply Last reply Reply Quote 0
      • A
        ab_trader last edited by

        1. 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.

        1. 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.

        2. move forward on quickstart and you will learn it

        • If my answer helped, hit reputation up arrow at lower right corner of the post.
        • Python Debugging With Pdb
        • New to python and bt - check this out
        1 Reply Last reply Reply Quote 3
        • J
          Jerzy last edited by

          thank you very much, it did help

          1 Reply Last reply Reply Quote 1
          • 1 / 1
          • First post
            Last post
          Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors