masanorihirano/pams

Execution handling for orders placed at the same time

Closed this issue · 1 comments

pams/pams/market.py

Lines 547 to 549 in 8090db6

if buy_order.placed_at == sell_order.placed_at:
# ToDo: in the actual market, this doesn't occur
price = buy_order.price

In the simulations, we should consider the rare case that cannot occur in actual markets.
In this case, we faced the case that the orders are placed at the totally same time.
This occurs only when the max_normal_orders is more than 1 or one agent submits the buy and sell order at the same time and executed them, aka. wash sales (仮装売買 in japanese), which is strictly prohibitted.

This issue is not happening because the orders are placed at not exactly the same time and the order id is different. The latter update fixed this issue.