enewhuis / liquibook

Modern C++ order matching engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue in usage of fill_cost when quantity is in decimal places.

Gordon-TheTurtle opened this issue · comments

In cb_order_fill callback:

Cost fill_cost = cb.price * cb.quantity;
Both price and quantity have been multiplied their respective precisions to convert to int64_t:
i.e. price = 100.00 USD -> 10000, quantity 5.00 -> 500

so according to the formula fill_cost is 10000 * 500 -> 5000000 or 50000.00
which is wrong,

Correct fill_cost = 100.00 * 5.00 = 500.00

It would be better to not calculate fill_cost as there is no need for it in liquibook and save computation.