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/

    why does panda calculate different sma than btlib ot ta-lib

    Indicators/Strategies/Analyzers
    1
    1
    48
    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.
    • B
      bobaleaux last edited by

      Hi everyone,

      hopefully someone can enlighten me why the difference.

      I'm retrieving data from Polygon and using python, calculating SMA20, SMA50 and EMA8 on the fly and store them along with the ohlc data in a sqlite3 table.

      the default python calculations

      sma20 = barsets['close'].rolling(window=20).mean()
      

      eed80f0f-7853-4420-9a18-65414d0c9f79-image.png

      VS

      self.sma_20 = bt.indicators.SimpleMovingAverage(
      self.datas[0], period=20)
      

      91ec5d62-911d-4f22-a59a-b3330faa5c3a-image.png

      I am using my Schwab account charts to compare my results and the default python values have always been exactly the same and because these are my benchmarks.

      I don't think this is a Backtrader thing but it does force me to use pre calculated values
      any ideas?

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      • First post
        Last post
      Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
      $(document).ready(function () { app.coldLoad(); }); }