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/

    Cerebro Stop Error

    General Code/Help
    2
    3
    29
    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.
    • H
      hyperex last edited by

      Hi,

      My cerebro run did not complete and exited with the following error.

      The error message does not help much to troubleshoot the issue.

      Anyone has encounter this before?

      Thanks.

      ---------------------------------------------------------------------------
      TypeError                                 Traceback (most recent call last)
       in 
            5 cerebro.addstrategy(StrategyA)
      ----> 6 cerebro.run(exactbars=200)
      
      ~/Library/Python/3.7/lib/python/site-packages/backtrader/cerebro.py in run(self, **kwargs)
         1125             # let's skip process "spawning"
         1126             for iterstrat in iterstrats:
      -> 1127                 runstrat = self.runstrategies(iterstrat)
         1128                 self.runstrats.append(runstrat)
         1129                 if self._dooptimize:
      
      ~/Library/Python/3.7/lib/python/site-packages/backtrader/cerebro.py in runstrategies(self, iterstrat, predata)
         1299 
         1300             for strat in runstrats:
      -> 1301                 strat._stop()
         1302 
         1303         self._broker.stop()
      
      ~/Library/Python/3.7/lib/python/site-packages/backtrader/strategy.py in _stop(self)
          481 
          482     def _stop(self):
      --> 483         self.stop()
          484 
          485         for analyzer in itertools.chain(self.analyzers, self._slave_analyzers):
      
      TypeError: 'SellOrder' object is not callable
      
      run-out 1 Reply Last reply Reply Quote 0
      • run-out
        run-out @hyperex last edited by

        @hyperex said in Cerebro Stop Error:

        acktrader/strategy.py in _stop(self)

        Sure. Could you include all of the code from your strategy class?

        1 Reply Last reply Reply Quote 0
        • H
          hyperex last edited by

          Thanks.
          I found the issue. I was assigning the stop order from bracket order into self.stop.

           self.order, self.stop, self.limit = self.buy_bracket(size=self.p.order_size,
                                                                                         exectype=bt.Order.Limit,
                                                                                         price=self.data.high[-1] + self.p.order_lvl_buffer,
                                                                                         stopprice=self.p.stopprice,
                                                                                         limitprice=self.p.limitprice)
          
          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(); }); }