betcode-org/flumine

Simulated fill or kill bets matched as regular bets

Closed this issue · 2 comments

mzaja commented

I ran the simulation on a couple of greyhound place markets and tried placing £1000 fill or kill bets. The table below shows the price and size matched versus the best price available and the volume at that price at the time instant of bet placement. Given that the requested volume is much higher than the volume available at the requested price, the expected result is that SIZE_MATCHED is roughly equal to BACK_VOLUME (the unmatched part gets immediately cancelled). However, the table below shows that SIZE_MATCHED is much larger than BACK_VOLUME, which is clearly wrong.

I re-ran the simulation placing non-fill-or-kill bets and got identical results. Therefore, there is a bug in the code which results in fill or kill orders not getting cancelled, staying in the market and getting filled - just like regular orders.

SIDE SIZE_MATCHED PRICE_MATCHED BACK_PRICE BACK_VOLUME
BACK 477.26 2.5 2.5 99.69
BACK 71.68 2.12 2.12 23.2
BACK 47.22 2.42 2.42 2
BACK 20.98 3.6 3.6 5.66
BACK 295.53 2.14 2.14 15.67
BACK 541.13 2.02 2.02 1.13
BACK 22.15 2.54 2.54 1.13
BACK 1.13 2.32 2.32 1.13
BACK 446.89 2.44 2.44 2
BACK 907.35 1.67 1.67 11.03
BACK 327.59 3.15 3.15 101.35
BACK 5.26 2.9 2.9 1.13
BACK 441.81 1.68 1.68 8.94
BACK 37 1.31 1.31 2
BACK 10.2 2.54 2.54 5.1
BACK 615.81 2.04 2.04 2
BACK 5.42 2.14 2.14 2.87
BACK 22.21 2.9 2.9 4.03
BACK 68.2 2.96 2.96 2.86
BACK 27.2 5.5 5.5 6.63
BACK 363.59 2.56 2.56 2.21
BACK 10.46 4.4 4.4 1.95
mzaja commented

Pull request created: #655

mzaja commented

Re-ran the simulation again after the fix, data looking good (size=5, min_fill_size=2):

   Selection ID |   Price matched |   Size matched |   Price available |   Size available
----------------+-----------------+----------------+-------------------+------------------
       43682317 |            2.5  |           5    |              2.5  |            99.69
       42867408 |            2.12 |           5    |              2.12 |            23.2
       41313528 |            2.42 |           2    |              2.42 |             2
       36336893 |            3.6  |           5    |              3.6  |             5.66
       45529737 |            2.14 |           5    |              2.14 |            15.67
       45329477 |            0    |           0    |              2.02 |             1.13
       41492850 |            0    |           0    |              2.54 |             1.13
       45258085 |            0    |           0    |              2.32 |             1.13
       45150293 |            2.44 |           2    |              2.44 |             2
       41237794 |            1.67 |           5    |              1.67 |            11.03
       41412370 |            3.15 |           5    |              3.15 |           101.35
       41669383 |            0    |           0    |              2.9  |             1.13
       43066681 |            1.68 |           5    |              1.68 |             8.94
       40009337 |            1.31 |           2    |              1.31 |             2
       21874819 |            2.54 |           5    |              2.54 |             5.1
       36186114 |            2.04 |           2    |              2.04 |             2
       38251939 |            2.14 |           2.87 |              2.14 |             2.87
       44018611 |            2.9  |           4.03 |              2.9  |             4.03
       39450298 |            2.96 |           2.86 |              2.96 |             2.86
       41402543 |            5.5  |           5    |              5.5  |             6.63
       44669888 |            2.56 |           2.21 |              2.56 |             2.21
       36425928 |            0    |           0    |              4.4  |             1.95