Backtrader Community

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. arrr
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
    A
    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 10
    • Best 0
    • Controversial 0
    • Groups 0

    arrr

    @arrr

    0
    Reputation
    211
    Profile views
    10
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    arrr Unfollow Follow

    Latest posts made by arrr

    • RE: Problem with custom ohlc vars

      @backtrader said in Problem with custom ohlc vars:

      @arrr said in Problem with custom ohlc vars:

      However if I call same self.make_ohlc() from self.next() - it works

      I fail to understand what the problem is. You have for sure a very clear idea about what troubles you, but you have already said it works. What you want to do with the data is of course unknown.

      Sorry for confusing explanation. It technically works, but I did not check if it returns correct data and, as for me, the code looks pretty weird :)

      posted in General Discussion
      A
      arrr
    • RE: Problem with custom ohlc vars

      @backtrader said in Problem with custom ohlc vars:

      @arrr said in Problem with custom ohlc vars:

      this gonna work fine, considering I'm using data replay?

      What should work fine? The info you have provided in this thread is close to none. You simply say that you cannot get data in __init__, which is something obvious.

      I mean calling self.make_ohlc() on every next() and operating what it returns as ohlc data

      posted in General Discussion
      A
      arrr
    • RE: Problem with custom ohlc vars

      @backtrader this gonna work fine, considering I'm using data replay?

      posted in General Discussion
      A
      arrr
    • Problem with custom ohlc vars

      I'm trying to maintain code compatibility with my production environment, where I'm storing ohlc data in a dict:
      self.ohlc = {-3: {'o': 153.252, 'h': 155.84, 'l': 149.49, 'c': 152.42, 'vol': 155395.333}, -2: {'o': 152.417, 'h': 162.4, 'l': 149.78, 'c': 155.65, 'vol': 255543.915}, -1: {'o': 155.7, 'h': 161.04, 'l': 150.88, 'c': 158.48, 'vol': 297664.05400000006}, 0: {'o': 158.71, 'h': 167.0, 'l': 158.51, 'c': 162.0, 'vol': 189163.71099999998}}
      where self.ohlc[0]['l] is the low if the current bar and self.ohlc[-3]['h'] stands for high 3 bars ago.
      I was trying to replicate the same with backtrader by doing:

          def make_ohlc(self):
              ohlc_dict = {}
              for x in range(-3, 1):
                  ohlc = {'o': self.datas[0].open[x], 'h': self.datas[0].high[x], 'l': self.datas[0].low[x], 'c': self.datas[0].close[x]}
                  ohlc_dict[x] = ohlc
              return ohlc_dict
      

      and calling it from init:
      self.ohlc = self.make_ohlc()
      But once I do that - I'm getting weird error:

        File "/Users/arrrr/PycharmProjects/backtrader/reverse.py", line 217, in <module>
          cerebro.run()
        File "/Users/arrrr/PycharmProjects/backtrader/venv/lib/python3.6/site-packages/backtrader/cerebro.py", line 1127, in run
          runstrat = self.runstrategies(iterstrat)
        File "/Users/arrrr/PycharmProjects/backtrader/venv/lib/python3.6/site-packages/backtrader/cerebro.py", line 1217, in runstrategies
          strat = stratcls(*sargs, **skwargs)
        File "/Users/arrrr/PycharmProjects/backtrader/venv/lib/python3.6/site-packages/backtrader/metabase.py", line 88, in __call__
          _obj, args, kwargs = cls.doinit(_obj, *args, **kwargs)
        File "/Users/arrrr/PycharmProjects/backtrader/venv/lib/python3.6/site-packages/backtrader/metabase.py", line 78, in doinit
          _obj.__init__(*args, **kwargs)
        File "/Users/arrrr/PycharmProjects/backtrader/reverse.py", line 50, in __init__
          self.make_ohlc()
        File "/Users/arrrr/PycharmProjects/backtrader/reverse.py", line 55, in make_ohlc
          ohlc = {'o': self.dataopen[x], 'h': self.datahigh[x], 'l': self.datalow[x],
        File "/Users/arrrr/PycharmProjects/backtrader/venv/lib/python3.6/site-packages/backtrader/linebuffer.py", line 163, in __getitem__
          return self.array[self.idx + ago]
      IndexError: array index out of range
      

      However if I call same self.make_ohlc() from self.next() - it works (it's obvious that calling it every bar is not a proper way to handle this)
      Any ideas what I'm doing wrong?

      posted in General Discussion
      A
      arrr
    • RE: Order update still unavailable?

      @backtrader When using 2 data feeds backtrader will call next() on every bar in each feed. Since bt takes bars from both feeds, sorts them from oldest to newest and then runs in a single flow, feeds become "mixed". My problem is that I don't know which bar from which feed is currently calling next() and therefore I can't call indicator functions on daily feed and skip them on minute one. So my question is how do I know which feed a certain bar comes from?

      posted in General Discussion
      A
      arrr
    • RE: Order update still unavailable?

      @backtrader I mean, that if you run it with 2 data feeds, but without looping them. So it will basically mix data from both sources in a single output. Long story short: is there any way to determine which feed a bar comes from?

      posted in General Discussion
      A
      arrr
    • RE: Order update still unavailable?

      I've googled about using multiple datafeeds with backtrader and it seems, that all available examples (including the docs) are looping thru the datasets, however I would like to use them simultaneously, is that possible?

      posted in General Discussion
      A
      arrr
    • RE: Order update still unavailable?

      Btw is it possible to use 2 sets of data: daily bars for indicators and smaller (hourly, 15 min or whatever) to place and process orders? In this case updating order (cancel + placing the new one) will take 2 small bars instead of skipping a full day.

      posted in General Discussion
      A
      arrr
    • RE: Order update still unavailable?

      I see. Any time estimates on v2?

      posted in General Discussion
      A
      arrr
    • Order update still unavailable?

      Hi
      I've got a strategy, where I need to update my order (or cancel and immediately place a new one) almost every period, however it seems to be impossible with backtrader right now. The only thing I can do is: cancel my order => wait for the next() run => place a new order, which means I've got a period without any live orders.
      Is there any way to handle this properly?

      posted in General Discussion
      A
      arrr