Crypto-toolbox / HFT-Orderbook

Limit Order Book for high-frequency trading (HFT), as described by WK Selph, implemented in Python3 and C
MIT License
1.02k stars 258 forks source link

balance wrong property #2

Closed alexeykarnachev closed 7 years ago

alexeykarnachev commented 7 years ago

It looks like a typo in lob.py (436:447).

    if self.balance_factor > 1:
        # right is heavier
        if self.right_child.balance < 0:
            # right_child.left is heavier, RL case
            self._rl_case()
        elif self.right_child.balance > 0:
            # right_child.right is heavier, RR case
            self._rr_case()
    elif self.balance_factor < -1:
        # left is heavier
        if self.left_child.balance < 0:
            # left_child.left is heavier, LL case
            self._ll_case()
        elif self.left_child.balance > 0:
            # left_child.right is heavier, LR case
            self._lr_case()

Should be changed to

    if self.balance_factor > 1:
        # right is heavier
        if self.right_child.balance_factor < 0:
            # right_child.left is heavier, RL case
            self._rl_case()
        elif self.right_child.balance_factor > 0:
            # right_child.right is heavier, RR case
            self._rr_case()
    elif self.balance_factor < -1:
        # left is heavier
        if self.left_child.balance_factor < 0:
            # left_child.left is heavier, LL case
            self._ll_case()
        elif self.left_child.balance_factor > 0:
            # left_child.right is heavier, LR case
            self._lr_case()

Because there is no such property "balance", but only "balance_factor"

deepbrook commented 7 years ago

You are correct. Thanks for reporting! I'll get on it right away.

deepbrook commented 7 years ago

Fixed