Documentation ¶
Overview ¶
Package simmarket implements a simple market simulation. See: https://download.tuxfamily.org/moneta/documents/LARC-2010-03.pdf Heavily based on: https://github.com/zond/gomarket
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Carrier ¶
Carrier is the interface for a carrier of resources. NOTE: A carrier is responsible for fulfilling orders. I don't know why this is a separate interface from the trader.
type Market ¶
type Market struct {
// contains filtered or unexported fields
}
Market represents a single market where resources are traded.
type Order ¶
type Order struct { Carrier Carrier // Creator of the offer Resource Resource // Resource to trade Units float64 // Number of units to trade Price float64 // Proposed price }
Order represents a request to trade an amount of a resource for a given price.
type Resources ¶
Resources is a map of resource type to amount or price.
type StandardTrader ¶
type StandardTrader struct { Carrier // contains filtered or unexported fields }
StandardTrader implements the Trader interface.
func NewStandardTrader ¶
func NewStandardTrader(carrier Carrier) *StandardTrader
NewStandardTrader returns a new StandardTrader using a given carrier.
func (*StandardTrader) Ask ¶
func (a *StandardTrader) Ask(units float64, resource Resource, price float64)
Ask creates a new ask for a number of units of a given resource for the given price.
func (*StandardTrader) Asks ¶
func (a *StandardTrader) Asks() []*Order
Asks returns all outstanding asks.
func (*StandardTrader) Bid ¶
func (a *StandardTrader) Bid(units float64, resource Resource, price float64)
func (*StandardTrader) Bids ¶
func (a *StandardTrader) Bids() []*Order
Bids returns all outstanding bids.