Documentation
¶
Index ¶
Constants ¶
View Source
const MaxPrice float64 = float64(1 << 10) // Max price in our market is $1M+/share
View Source
const MinPrice float64 = 0.0
Variables ¶
View Source
var InvalidOrder = errors.New("Invalid order")
Functions ¶
This section is empty.
Types ¶
type Market ¶
type Market struct {
Stocks map[StockSymbol]*Stock
Orders map[StockSymbol][]*Order
// contains filtered or unexported fields
}
Establish the market
func (*Market) GetPriceForSymbol ¶
func (m *Market) GetPriceForSymbol(s StockSymbol) StockPrice
func (*Market) ReceiveOrder ¶
type Order ¶
type Order struct {
Symbol StockSymbol
BuySell OrderBuySellVal
OrderType OrderTypeVal
Value float64
OrderStatus
}
Represents an order to buy or sell
type OrderBuySellVal ¶
type OrderBuySellVal int
const ( BuyOrderType OrderBuySellVal = iota + 1 SellOrderType )
type OrderStatus ¶
type OrderStatus int
const ( OrderStatusOpen OrderStatus = iota + 1 OrderStatusFilled OrderStatusPartial OrderStatusCancelled )
type OrderTypeVal ¶
type OrderTypeVal int
const ( MarketOrderType OrderTypeVal = iota + 1 LimitOrderType )
func (OrderTypeVal) String ¶
func (o OrderTypeVal) String() string
type SortedOrders ¶
type SortedOrders []*Order
func (SortedOrders) Less ¶
func (s SortedOrders) Less(i, j int) bool
func (SortedOrders) Swap ¶
func (s SortedOrders) Swap(i, j int)
type Stock ¶
type Stock struct {
Symbol StockSymbol
Name string
Price StockPrice
}
Equity representing one stock
type StockPrice ¶
Represent the current price of a stock
var StartingPrice StockPrice = StockPrice{MinPrice, MaxPrice}
func (StockPrice) MidPrice ¶
func (sp StockPrice) MidPrice() float64
type StockSymbol ¶
type StockSymbol string
Click to show internal directories.
Click to hide internal directories.