exchange

package
v0.0.0-...-6165795 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2015 License: MIT Imports: 7 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoPermission = errors.New("Permission denied")
View Source
var NoSuchEntity = errors.New("No such entity")
View Source
var NotTrading = errors.New("Trading currently prohibited")
View Source
var UnqualifiedAsker = errors.New("Asker is unqualified")
View Source
var UnqualifiedBidder = errors.New("Bidder is unqualified")

Functions

This section is empty.

Types

type Action

type Action uint
const (
	A_NONE Action = iota
	A_BID
	A_ASK
)

func (Action) String

func (i Action) String() string

type Auction

type Auction struct {
	ID         AuctionID
	Seller     LicenseID
	Stock      Symbol
	Open       bool
	Length     time.Duration `ask:"min=1"`
	Ask        float32       `ask:"min=0"`
	Number     uint64        `ask:"min=1"`
	Bids       []Bid
	Adjudicate func([]Bid) Bid
	Winner     Bid
}

func (Auction) Win

func (a Auction) Win() Bid

type AuctionID

type AuctionID struct{ uuid.UUID }

func (AuctionID) String

func (a AuctionID) String() string

type Auctioner

type Auctioner interface {
	Auctions() []Auction
	Auction(AuctionID) (Auction, error)
	Ask(Auction) (AuctionID, error)
	Bid(Bid) (BidID, error)
	Finish(AuctionID) error
	Cancel(AuctionID) error
}

type Bid

type Bid struct {
	ID     BidID
	Placed time.Time
	Bidder LicenseID
	Number uint64  `place:"min=1"`
	Price  float32 `place:"min=0"`
}

type BidID

type BidID struct {
	Auction AuctionID
	Bid     uint64
}

func (BidID) String

func (b BidID) String() string

type Deal

type Deal struct {
	Buyer  LicenseID
	Volume uint64
}

type Dealer

type Dealer interface {
	SellPrice(Symbol) (float32, error)
	BuyPrice(Symbol) (float32, error)

	Stocks() []Symbol

	Sell(Deal) Response
	Buy(Deal) Response
}

type Dealership

type Dealership interface {
	RegisterDealer(Dealer)
	Resolve(Symbol) []Dealer
	Dealers() []Dealer
}

type Duration

type Duration int

type LicenseID

type LicenseID uint

type Lister

type Lister interface {
	List() []Stock
}

type Mode

type Mode uint
const (
	M_AUCTION Mode = iota
	M_DEALER
	M_BOTH
)

func (Mode) String

func (i Mode) String() string

type Order

type Order struct {
	Buyer      LicenseID
	Action     Action
	Price      float32
	Target     Symbol
	Size       uint
	Expiration Duration
	ID         OrderID
}

type OrderID

type OrderID uuid.UUID

type Reason

type Reason uint
const (
	R_OK           Reason = 0
	R_NONE         Reason = iota + 1
	R_NOT_TRADING         // Default cop-out
	R_PROHIBITED          // I can't sell what I have, period.
	R_RESTRICTED          // I can't sell what I have TO YOU.
	R_PRICE_LOW           // Probably not issued when buying.
	R_PRICE_HIGH          // Probably not for selling either.
	R_UNACCEPTABLE        // Like ^ but more vauge. Try changing something and get back to me.
	R_CANT_PAY            // I can not pay
)

func (Reason) String

func (i Reason) String() string

type Response

type Response struct {
	OK     bool
	Reason Reason
}

type Sector

type Sector uint

type Stamp

type Stamp struct {
	Day  int
	Time int
}

type Status

type Status uint
const (
	S_OPEN Status = iota
	S_CLOSE
	S_PAUSE
	S_RESUME
	S_QUOTA_REACHED
)

func (Status) String

func (i Status) String() string

type Statuser

type Statuser interface {
	Status(Status)
}

type Stock

type Stock struct {
	Name    string
	Trading bool
	Symbol  Symbol
	Sectors []Sector
	Shares  uint
	Mode    Mode
}

type SumLen

type SumLen uint
const (
	SL_DAY SumLen = iota
	SL_WEEK
	SL_CYCLE
)

func (SumLen) String

func (i SumLen) String() string

type Summary

type Summary struct {
	Traders uint64
	Volume  uint64
	Trades  []Trade
}

func Combine

func Combine([]Summary) Summary

func (Summary) String

func (s Summary) String() string

type Symbol

type Symbol string

type Timer

type Timer struct {
	C chan time.Time
	// contains filtered or unexported fields
}

func NewTimer

func NewTimer(tt time.Duration) *Timer

func (*Timer) Pause

func (t *Timer) Pause()

func (*Timer) Resume

func (t *Timer) Resume()

func (*Timer) Stop

func (t *Timer) Stop()

type Trade

type Trade struct {
	Seller   LicenseID
	Volume   uint64
	Buyer    LicenseID
	Duration time.Time
}

type TradeStatus

type TradeStatus uint
const (
	TS_UNKNOWN      TradeStatus = iota // I know nothing of this item.
	TS_SUBMITTED                       // I posted this item.
	TS_ACKNOWLEDGED                    // I have won the bid, or finalized the deal; and am committed to paying.
	TS_PAID                            // I have paid or transfered the assets.
	TS_RECIEVED                        // I have recieved payment.
	TS_CLOSED                          // I have completed this interaction successfully.
	TS_ABORTED                         // I broke off this interaction.
	TS_ERROR_ME                        // I have made some error.
	TS_ERROR_YOU                       // The other party has made some error.
	TS_ROLLBACK                        // I have attempted to repair my error.
	TS_FAULT_ME                        // I can not complete this transaction.
	TS_FAULT_YOU                       // The other party can not complete this transaction.
)

func (TradeStatus) String

func (i TradeStatus) String() string

type TraderCfg

type TraderCfg struct {
	Type  string
	Count uint64
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL