match

package
v0.0.0-...-73bab27 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2020 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
const (
	MapDefaultSize      int  = 100
	DefaultClientExpire uint = 24 * 14 // hours
	DefaultOrderExpire  uint = 24      // hours
	DefaultDealExpire   uint = 24      // hours
	ExpireCheck         uint = 1       // hours = Frequency to check expirations
	Precision           uint = 1000    // Price precision multiplier
)

Config Constants

View Source
const (
	StatusNew                string = "new"
	StatusActive             string = "active"
	StatusFilled             string = "filled"
	StatusPartial            string = "partial"
	StatusCancelled          string = "cancelled"
	StatusCancelledSelfTrade string = "cancelled remainder self trade"
	StatusCancelledPostOnly  string = "cancelled post only"
	StatusCancelledFAK       string = "cancelled remainder fill and kill"
	StatusCancelledFOK       string = "cancelled fill or kill"
)

Order Status Constants

View Source
const (
	ModifierPostOnly string = "post only"
	ModifierFAK      string = "fill and kill"
	ModifierFOK      string = "fill or kill"
)

Order Modifier Constants

View Source
const (
	Buy  bool = false
	Sell bool = true
)

Direction Constants

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Address        string `json:"client_address,omitempty"`
	ClearerAddress string `json:"clearer_address,omitempty"`
	Approved       bool   `json:"approved,omitempty"`
	Expire         uint
	Orders         map[uint]*list.Element
	Balances       map[string]uint `json:"balances"`
}

Client is a Server-created Client Instance

type DB

type DB struct {
	Orderbooks     map[string]*list.List
	Clients        map[string]*Client
	Deals          map[uint]*Deal
	ClearerAddress string
}

DB is a Global Data Storage Instance

func NewDB

func NewDB(address string) *DB

NewDB initializes a Data Storage Instance

func (*DB) AddOrder

func (db *DB) AddOrder(o *Order) error

AddOrder adds an Order to the Order Book or Matches it

func (*DB) CancelOrder

func (db *DB) CancelOrder(o *Order) error

CancelOrder finds a Resting Order from the Order Book using Client Orders, and Cancels it

func (*DB) CheckExpired

func (db *DB) CheckExpired()

CheckExpired searches for Expiring Objects and deletes them. Updates expiration counters. To be called at ExpireCheck frequency

func (*DB) GetDeals

func (db *DB) GetDeals(d *Deal) ([]*Deal, error)

GetDeals finds and Returns all Deals

func (*DB) GetOrders

func (db *DB) GetOrders(o *Order) ([]*Order, error)

GetOrders finds and Returns all resting Client Orders from the Order Book using the Client Orders array If an Order ID is provided, one Client Order will be returned if it exists

func (*DB) UpdateClient

func (db *DB) UpdateClient(c *Client) error

UpdateClient updates a Client in the Client DB

type Deal

type Deal struct {
	ID             uint   `json:"id,omitempty"`
	ClearerAddress string `json:"clearer_address,omitempty"`
	MakerFill      Fill   `json:"maker_fill,omitempty"`
	TakerFill      Fill   `json:"taker_fill,omitempty"`
	Expire         uint   `json:"expire,omitempty"`
}

Deal is a Server-created Deal Instance

type Fill

type Fill struct {
	ClientAddress string `json:"client_address,omitempty"`
	ClientOrderID uint   `json:"client_order_id,omitempty"`
	BuyProduct    string `json:"buy_product,omitempty"`
	BuyQuantity   uint   `json:"buy_quantity,omitempty"`
	SellProduct   string `json:"sell_product,omitempty"`
	SellQuantity  uint   `json:"sell_quantity,omitempty"`
}

Fill is a Server-created Fill Instance

type Order

type Order struct {
	ClientAddress  string `json:"client_address,omitempty"`
	ClearerAddress string `json:"clearer_address,omitempty"`
	BuyProduct     string `json:"buy_product,omitempty"`
	BuyQuantity    uint   `json:"buy_quantity,omitempty"`
	SellProduct    string `json:"sell_product,omitempty"`
	SellQuantity   uint   `json:"sell_quantity,omitempty"`
	Status         string `json:"status,omitempty"`
	Modifier       string `json:"modifier,omitempty"`
	Expire         uint   `json:"expire,omitempty"` // hours
	ClientOrderID  uint   `json:"client_order_id,omitempty"`
}

Order is a Client-created Order Instance

Jump to

Keyboard shortcuts

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