Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Approvedpush 20241205 basket off #1090

Merged
merged 10 commits into from
Dec 29, 2023
Next Next commit
#1025 updating internal order state's state when processing fill
  • Loading branch information
naleeha authored and chrisjstevo committed Dec 29, 2023
commit 5b61a39bd487311f520bcdf02a4df573a6bdf9f3
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ class InMemOmsApi(implicit val clock: Clock) extends OmsApi {
orderstate.copy(state = States.ACKED, nextEventTime = clock.now() + random.between(1000, MaxTimes.MAX_FILL_TIME_MS), orderId = orderId)
case 'A' =>
val remainingQty = orderstate.qty - orderstate.filledQty
val fillQty = if(remainingQty > 1) random.between(1, orderstate.qty - orderstate.filledQty) else 1
listeners.foreach(_.onFill(Fill(orderstate.orderId, fillQty, orderstate.price, orderstate.clientOrderId, orderstate.filledQty + fillQty, orderstate.qty)))
orderstate.copy(filledQty = orderstate.filledQty + fillQty, nextEventTime = clock.now() + random.between(1000, 5000))
val fillQty = if(remainingQty > 1) random.between(1, remainingQty) else 1
val totalFilledQty = orderstate.filledQty + fillQty
val state = if( orderstate.qty == totalFilledQty) States.FILLED else States.ACKED
listeners.foreach(_.onFill(Fill(orderstate.orderId, fillQty, orderstate.price, orderstate.clientOrderId, totalFilledQty, orderstate.qty)))
orderstate.copy(state = state, filledQty = totalFilledQty, nextEventTime = clock.now() + random.between(1000, 5000))
case _ =>
orderstate
}
Expand Down