For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
Bug in bbroker._try_exec_limit()
-
In the method:
def _try_exec_limit(self, order, popen, phigh, plow, plimit): if order.isbuy(): if plimit >= popen: # open smaller/equal than requested - buy cheaper pmax = min(phigh, plimit) p = self._slip_up(pmax, popen, doslip=self.p.slip_open, lim=True) self._execute(order, ago=0, price=p) elif plimit >= plow: # day low below req price ... match limit price self._execute(order, ago=0, price=plimit) else: # Sell if plimit <= popen: # open greater/equal than requested - sell more expensive pmin = max(plow, plimit) p = self._slip_down(plimit, popen, doslip=self.p.slip_open, lim=True) self._execute(order, ago=0, price=p) elif plimit <= phigh: # day high above req price ... match limit price self._execute(order, ago=0, price=plimit)
The line:
p = self._slip_down(plimit, popen, doslip=self.p.slip_open, lim=True)
Should use "pmin" instead of "plimit" (as it uses "pmax" in the buy case):
p = self._slip_down(pmin, popen, doslip=self.p.slip_open, lim=True)
It is not adjusting the limit price before calling _slip_down().