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/

    InfluxDB feed bug.

    General Code/Help
    2
    5
    477
    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.
    • Nikolai
      Nikolai last edited by Nikolai

      Hi, i see that issues on GitHub are disabled. He is a bug.

      backtrader/feeds/influxfeed.py
      line 91

      qstr = ('SELECT mean("{open_f}") AS "open", mean("{high_f}") AS "high", '
                      'mean("{low_f}") AS "low", mean("{close_f}") AS "close", '
                      'mean("{vol_f}") AS "volume", mean("{oi_f}") AS "openinterest" '
                      'FROM "{dataname}" '
                      'WHERE time {begin} '
                      'GROUP BY time({timeframe}) fill(none)').format(
                          open_f=self.p.open, high_f=self.p.high,
                          low_f=self.p.low, close_f=self.p.close,
                          vol_f=self.p.volume, oi_f=self.p.ointerest,
                          timeframe=tf, begin=st, dataname=self.p.dataname)
      

      Wrong parameter name: dataname=self.p.dataname should be dataname=self.p.database

      The feed starts working after change.

      1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators last edited by

        This was a contribution. And have you tried using the parameter dataname?

        Nikolai 1 Reply Last reply Reply Quote 0
        • Nikolai
          Nikolai @backtrader last edited by Nikolai

          @backtrader yes. there is no such parameter. Only database

          params = (
                  ('host', '127.0.0.1'),
                  ('port', '8086'),
                  ('username', None),
                  ('password', None),
                  ('database', None),
                  ('timeframe', bt.TimeFrame.Days),
                  ('startdate', None),
                  ('high', 'high_p'),
                  ('low', 'low_p'),
                  ('open', 'open_p'),
                  ('close', 'close_p'),
                  ('volume', 'volume'),
                  ('ointerest', 'oi'),
              )
          
          1 Reply Last reply Reply Quote 0
          • B
            backtrader administrators last edited by backtrader

            @backtrader said in InfluxDB feed bug.:

            And have you tried using the parameter dataname?

            @nikolai said in InfluxDB feed bug.:

            @backtrader yes.

            You obviously haven't tried it.

            @nikolai said in InfluxDB feed bug.:

            there is no such parameter. Only database

            dataname is a parameter common to all data feeds in the ecosystem. The meaning of the database parameter is left to the original author, but the use of dataname in the context in which is used in the code is 100% ok.

            Furhtermore, the parameters for each data feed are listed in the documentation. See

            • Doc - Datafeed Reference
            1 Reply Last reply Reply Quote 1
            • Nikolai
              Nikolai last edited by

              @backtrader, thanks for help. I finally figured out the problem. There should be both parameters. database is used for DB connection and dataname is used for DB query.

              data = bt.feeds.InfluxDB(host='xxx.xxx.xxx.xxx', port='8086',
                                          username='admin',
                                          password=keyring.get_password("system", "admin"),
                                          database='MOEX_RTS_3_19',
                                          dataname='MOEX_RTS_3_19',
                                          timeframe=bt.TimeFrame.Minutes,
                                          startdate='2019-01-13T12:00:00Z',
                                          high='high',
                                          low='low',
                                          open='open',
                                          close='close',
                                          volume='volume',
                                          ointerest='oi')
              
              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors