ex

package
v0.0.0-...-536937c Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MapDefaultSize        int  = 100
	DefaultFillExpire     uint = 24      // hours
	DefaultClientExpire   uint = 24 * 14 // hours
	DefaultClearerExpire  uint = 24 * 14 // hours
	DefaultOrderExpire    uint = 24      // hours
	DefaultFeedbackRating uint = 100
	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 Clearer

type Clearer struct {
	Address string
	Expire  uint
	Fills   map[uint]*ClearerFill
}

Clearer is a Server-created Clearer Instance

type ClearerFill

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

ClearerFill is a Server-created Clearer Fill Instance

type Client

type Client struct {
	Address        string
	FeedbackRating uint
	TransactCount  uint
	BadFeedback    uint
	Expire         uint
	Orders         map[uint]*list.Element
}

Client is a Server-created Client Instance

type ClientFill

type ClientFill 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"`
}

ClientFill is a Server-created Client Fill Instance

type DB

type DB struct {
	Orderbooks map[string]*list.List
	Clients    map[string]*Client
	Clearers   map[string]*Clearer
}

DB is a Global Data Storage Instance

func NewDB

func NewDB() *DB

NewDB initializes a Data Storage Instance

func (*DB) AddFeedback

func (db *DB) AddFeedback(f *Feedback) error

AddFeedback updates a Client's Feedback

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 delete thems. Updates expiration counters. To be called at ExpireCheck frequency

func (*DB) GetFills

func (db *DB) GetFills(cf *ClearerFill) ([]*ClearerFill, error)

GetFills finds and Returns all resting Clearer Fills from the Clearer Fills array

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

type Feedback

type Feedback struct {
	ClearerAddress string `json:"clearer_address,omitempty"`
	ClearerFillID  uint   `json:"clearer_fill_id,omitempty"`
	MakerAddress   string `json:"maker_address,omitempty"`
	MakerFeedback  bool   `json:"maker_feedback,omitempty"` // 1 = Negative
	TakerAddress   string `json:"taker_address,omitempty"`
	TakerFeedback  bool   `json:"taker_feedback,omitempty"` // 1 = Negative
}

Feedback is a Clearer-created Feedback 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"`
	MinFeedback    uint   `json:"min_feedback,omitempty"`
	MinTransact    uint   `json:"min_transact,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