Backtrader Community

    • 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/

    Quickstart guide - results not as stated

    General Discussion
    quickstart
    1
    1
    170
    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.
    • S
      somebodyElse last edited by

      Hi,

      I am new to backtrader and tried out the samples in the quickstart guide.
      The sample for "Adding an indicator" (link) results in the following, according to the guide:

      Starting Portfolio Value: 1000.00
      2000-01-24T00:00:00, Close, 25.55
      2000-01-25T00:00:00, Close, 26.61
      2000-01-25T00:00:00, BUY CREATE, 26.61
      2000-01-26T00:00:00, BUY EXECUTED, Size 10, Price: 26.76, Cost: 267.60, Commission 0.00
      2000-01-26T00:00:00, Close, 25.96
      2000-01-27T00:00:00, Close, 24.43
      2000-01-27T00:00:00, SELL CREATE, 24.43
      2000-01-28T00:00:00, SELL EXECUTED, Size 10, Price: 24.28, Cost: 242.80, Commission 0.00
      2000-01-28T00:00:00, OPERATION PROFIT, GROSS -24.80, NET -24.80
      2000-01-28T00:00:00, Close, 22.34
      2000-01-31T00:00:00, Close, 23.55
      2000-02-01T00:00:00, Close, 25.46
      2000-02-02T00:00:00, Close, 25.61
      2000-02-02T00:00:00, BUY CREATE, 25.61
      2000-02-03T00:00:00, BUY EXECUTED, Size 10, Price: 26.11, Cost: 261.10, Commission 0.00
      ...

      When I run it, I get

      Starting Portfolio Value: 1000.00
      2000-01-24, Close, 24.10
      2000-01-25, Close, 25.10
      2000-01-25, BUY CREATE, 25.10
      2000-01-26, BUY EXECUTED, Price: 25.24, Cost: 252.40, Comm 0.00
      2000-01-26, Close, 24.49
      2000-01-27, Close, 23.04
      2000-01-27, SELL CREATE, 23.04
      2000-01-28, SELL EXECUTED, Price: 22.90, Cost: 252.40, Comm 0.00
      2000-01-28, OPERATION PROFIT, GROSS -23.40, NET -23.40
      2000-01-28, Close, 21.07
      2000-01-31, Close, 22.22
      2000-02-01, Close, 24.02
      2000-02-02, Close, 24.16
      2000-02-02, BUY CREATE, 24.16
      2000-02-03, BUY EXECUTED, Price: 24.63, Cost: 246.30, Comm 0.00
      ...

      There are two differences:

      1. Prices are different
      2. According to the guide, "Cost" for "sell" depends on the price for selling. When I run it, it is not, but has the same value as the "Cost" of buying.

      The quickstart guide seems out of date, which is a little concerning for a new users, because this could be a sign of low quality standards, at least regarding documentation.

      How does the correct code look? Is backtrader easy to use? Or is the quickstart guide just the tip of the iceberg of struggling until one gets it done?
      Thanks.

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