betcode-org/flumine

Traded amount can be negative during limit order fills

Closed this issue · 0 comments

BetFair reports their "traded" as double what was matched - they count both buyers and sellers.

To use the traded in a simulator (for replay fills), the traded has to be divided by 2. For odd multiples of the original traded, this can give replay fill traded amounts with 3dp e.g. BF report traded as 100.05, giving a fill traded amount of 100.05/2 = 50.025.

This rounding mismatch in simulated_order.py can give small negative traded amounts, as the self._piq can end up having 3dp. When this is then multiplied by 2 in _matched = (self._pix + size) * 2 an error of a penny can be introduced.