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/

    Somehow EMA is slightly off

    Indicators/Strategies/Analyzers
    ema indicator indicators
    1
    1
    92
    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.
    • K
      kfue last edited by

      There's no way I'm not doing something real dumb and this is going to be a simple answer..

      I'm trying to use the 100 period EMA of the VIX in my strategy. non trading tickers are always the first data to be added.

      ("non_trading_tickers", ["VIX"])
      ...
      self.non_trading_ticker_data = self.datas[0:len(self.p.non_trading_tickers)]
      ...
      self.vix_index = [i for i, d in enumerate(self.non_trading_ticker_data) if d._name == "VIX"][0]
      self.non_trading_ema["VIX"] = bt.ind.ExponentialMovingAverage(self.non_trading_ticker_data[self.vix_index], period=100)
      

      I'm looking at the VIX on trading view on CBOE and through yahoo finance (where I'm getting the data). When I look at May 29th 2019 I see the vix 100 period EMA at 15.9 on both data sources, when I output the 100 period EMA on that date I get

      self.log([self.non_trading_ema["VIX"][0], self.non_trading_ema["VIX"][-1]])
      self.log(self.non_trading_ticker_data[self.vix_index].close[0])
      
      2019-05-29T00:00:00, 15.682198154811706
      2019-05-29T00:00:00, 17.899999618530273
      

      15.68 as you can see above. The close is 0.0000001 off but there's no way slight floating point errors would cause a difference of 0.22. I've also spot checked other closes and they are all right (minus floating point error)

      I believe I've given enough details, if you want more feel free to ask

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