Skip to content

Commit

Permalink
fix: ORDER PUT event occurs for every new order
Browse files Browse the repository at this point in the history
  • Loading branch information
lispc committed Jun 12, 2021
1 parent 735041c commit 247449b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/matchengine/market/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,21 @@ impl Market {
quote_limit: &Decimal,
) -> Order {
log::debug!("execute_order {:?}", taker);

// the the older version, PUT means being inserted into orderbook
// so if an order is matched instantly, only 'FINISH' event will occur, no 'PUT' event
// now PUT means being created
// we can revisit this decision later
persistor.put_order(&taker, OrderEventType::PUT);

let taker_is_ask = taker.side == OrderSide::ASK;
let taker_is_bid = !taker_is_ask;
let maker_is_bid = taker_is_ask;
let maker_is_ask = !maker_is_bid;
let is_limit_order = taker.type_ == OrderType::LIMIT;
let is_market_order = !is_limit_order;
let is_post_only_order = taker.post_only;
//let mut quote_available = *quote_limit;

let mut quote_sum = Decimal::zero();

let mut finished_orders = Vec::new();
Expand Down Expand Up @@ -440,7 +447,6 @@ impl Market {
if taker.remain.is_zero() {
persistor.put_order(&taker, OrderEventType::FINISH);
} else {
persistor.put_order(&taker, OrderEventType::PUT);
// `insert_order` will update the order info
taker = self.insert_order(taker);
self.frozen_balance(balance_manager, &taker);
Expand Down

0 comments on commit 247449b

Please sign in to comment.