Last active
November 19, 2019 16:08
-
-
Save mbloms/5c165d7e1ab9e2892610b667a9114a4a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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