Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BuyOrder ¶
type BuyOrder interface { // GetID returns the unique identifier used to identify this // record in persistent storage GetID() string // GetPrice returns the price the order was purchased at // in increments of 1/1000 of a penny GetPrice() int // GetQuantity returns the quantity of stock purchased GetQuantity() int // GetTicker returns the stock ticker code GetTicker() string // GetTimestamp returns the timestamp from when the order was made GetTimestamp() time.Time // GetUserID returns the user who will be paying the order GetUserID() string }
BuyOrder represents a purchase order for a specific stock
type OrdersService ¶
type OrdersService interface { // CreateBuyOrder will persist a new order at the market rate // for the given ticker. The market rate will be subtracted // from the given profile's riches and the user's stock // quantity for this ticker will go up. CreateBuyOrder(userID, ticker string, quantity int) (BuyOrder, error) // GetBuyOrder will retrieve a buy order for a given user & id GetBuyOrder(userID, id string) (BuyOrder, error) // GetSellOrder will retrieve a sell order for a given user & id GetSellOrder(userID, id string) (SellOrder, error) // ListBuyOrders returns all orders for a user ListBuyOrders(userID string) ([]BuyOrder, error) // ListSellOrders returns all orders for a user ListSellOrders(userID string) ([]SellOrder, error) // CreateSellOrder will persist a new sell order at the market rate // for the given ticker. The market rate will be added // to the given user's riches and the user's stock quantity // for this ticker will go down. It will return an error if // the user doesn't own enough of the stock CreateSellOrder(userID, ticker string, quantity int) (SellOrder, error) }
OrdersService manages CRUD for buy & sell orders
func New ¶
func New(mongoDB *mgo.Session, usersService usersservice.UsersService) OrdersService
New constructs a new BuyOrdersService that will persist data using the provided mongo session
type SellOrder ¶
type SellOrder interface { // GetID returns the unique identifier used to identify this // record in persistent storage GetID() string // GetPrice returns the price the order was purchased at // in increments of 1/1000 of a penny GetPrice() int // GetQuantity returns the quantity of stock sold GetQuantity() int // GetTicker returns the stock ticker code GetTicker() string // GetTimestamp returns the timestamp from when the order was created GetTimestamp() time.Time // GetUserID returns the user who will be paying the order GetUserID() string }
SellOrder represents a sell order for a specific stock
Click to show internal directories.
Click to hide internal directories.