Skip to content

Instantly share code, notes, and snippets.

@mbloms
Last active November 19, 2019 16:08
Show Gist options
  • Save mbloms/5c165d7e1ab9e2892610b667a9114a4a to your computer and use it in GitHub Desktop.
Save mbloms/5c165d7e1ab9e2892610b667a9114a4a to your computer and use it in GitHub Desktop.
object Bank {
def placeFillOrKillBuyOrder(price: Double, vol: Int, stock: StockID, buyer: UserID): Unit {
val (askPrice,askVol) = OrderDepth.getLowestAsk(stock)
if (price >= askPrice && vol <= askVol) {
/* The Bank updates the user's account to reflect
the trade which it was able to fill at once. */
Account.decreaseBalance(UserID, price * vol)
Account.increaseStock(UserID, stock, vol)
Account.notify("Stock bought successfully")
/* The Bank buys the amount of stock that it
owes the user */
OrderBook.placeBuyOrder(price, vol, stock, Bank.userid)
}
}
}
object OrderBook {
def placeBuyOrder(price: Double, vol: Int, stock: StockID, buyer: UserID): Unit {
...
...
matchOrder(stock)
}
def matchOrder(stock: StockID) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment