For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

backtesting error from getvaluesize:



  • ---------------------------------------------------------------------------
    ValueError                                Traceback (most recent call last)
    <ipython-input-414-3bfb3089a414> in <module>
         11 #cerebro.addanalyzer(bt.analyzers.TradeAnalyzer, _name='myTradesStats')
         12 #cerebro.broker.setcommission(commission=0.001)
    ---> 13 results = cerebro.run()
    
    /data/NFS/akhil/python-env/lib64/python3.6/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:
    
    /data/NFS/akhil/python-env/lib64/python3.6/site-packages/backtrader/cerebro.py in runstrategies(self, iterstrat, predata)
       1291                     self._runonce_old(runstrats)
       1292                 else:
    -> 1293                     self._runonce(runstrats)
       1294             else:
       1295                 if self.p.oldsync:
    
    /data/NFS/akhil/python-env/lib64/python3.6/site-packages/backtrader/cerebro.py in _runonce(self, runstrats)
       1686                         return
       1687 
    -> 1688             self._brokernotify()
       1689             if self._event_stop:  # stop if requested
       1690                 return
    
    /data/NFS/akhil/python-env/lib64/python3.6/site-packages/backtrader/cerebro.py in _brokernotify(self)
       1358         notification to the strategy
       1359         '''
    -> 1360         self._broker.next()
       1361         while True:
       1362             order = self._broker.get_notification()
    
    /data/NFS/akhil/python-env/lib64/python3.6/site-packages/backtrader/brokers/bbroker.py in next(self)
       1219 
       1220             else:
    -> 1221                 self._try_exec(order)
       1222                 if order.alive():
       1223                     self.pending.append(order)
    
    /data/NFS/akhil/python-env/lib64/python3.6/site-packages/backtrader/brokers/bbroker.py in _try_exec(self, order)
       1065 
       1066         if order.exectype == Order.Market:
    -> 1067             self._try_exec_market(order, popen, phigh, plow)
       1068 
       1069         elif order.exectype == Order.Close:
    
    /data/NFS/akhil/python-env/lib64/python3.6/site-packages/backtrader/brokers/bbroker.py in _try_exec_market(self, order, popen, phigh, plow)
        875             p = self._slip_down(plow, exprice, doslip=self.p.slip_open)
        876 
    --> 877         self._execute(order, ago=0, price=p, dtcoc=dtcoc)
        878 
        879     def _try_exec_close(self, order, pclose):
    
    /data/NFS/akhil/python-env/lib64/python3.6/site-packages/backtrader/brokers/bbroker.py in _execute(self, order, ago, price, cash, position, dtcoc)
        749             # Adjust to returned value for closed items & acquired opened items
        750             if self.p.shortcash:
    --> 751                 closedvalue = comminfo.getvaluesize(-closed, pprice_orig)
        752             else:
        753                 closedvalue = comminfo.getoperationcost(closed, pprice_orig)
    
    /data/NFS/akhil/python-env/lib64/python3.6/site-packages/backtrader/comminfo.py in getvaluesize(self, size, price)
        210             return abs(size) * self.get_margin(price)
        211 
    --> 212         return size * price
        213 
        214     def getvalue(self, position, price):
    
    ValueError: cannot copy sequence with size 1047 to array axis with dimension 8954
    ![alt text](image url)
    

    Can anyone help with this?


Log in to reply
 

});