Documentation ¶
Index ¶
- Constants
- Variables
- type Amount
- func (a Amount) Float() *big.Float
- func (a *Amount) MarshalJSON() ([]byte, error)
- func (a *Amount) Mul(x, y *Amount) (*Amount, big.Accuracy)
- func (a *Amount) Reciprocal() (*Amount, big.Accuracy)
- func (a *Amount) SetExp(e int) *Amount
- func (a Amount) String() string
- func (a *Amount) UnmarshalJSON(b []byte) error
- type Order
- type OrderFlags
- type OrderMeta
- type OrderStatus
- type OrderType
- type PairName
- type Signature
- type SignedOrder
- type TimeId
- type TimeIdUnique
- type Trade
Constants ¶
const TimeIdDataLen = 16 // number of bytes in a timeid
Variables ¶
var ( ErrOrderIdMissing = errors.New("order id is required") ErrBrokerIdMissing = errors.New("broker id is required") ErrOrderTypeNotValid = errors.New("order type is not valid") ErrOrderStatusNotValid = errors.New("order status is not valid") ErrOrderNeedsAmount = errors.New("order amount or spend limit is required") )
Functions ¶
This section is empty.
Types ¶
type Amount ¶
Amount is a fixed point value
func NewAmountFromFloat ¶
NewAmountFromFloat return a new Amount initialized with the value f stored with the specified number of decimals
func NewAmountFromFloat64 ¶
NewAmountFromFloat64 return a new Amount initialized with the value f stored with the specified number of decimals
func NewAmountFromString ¶
NewAmountFromString return a new Amount initialized with the passed string value
func (*Amount) MarshalJSON ¶
func (*Amount) Reciprocal ¶
Reciprocal returns 1/a in a newly allocated Amount
func (*Amount) SetExp ¶ added in v0.0.2
SetExp sets the number of decimals (exponent) of the amount, truncating or adding zeroes as needed
func (*Amount) UnmarshalJSON ¶ added in v0.0.2
type Order ¶
type Order struct { OrderId string `json:"id"` // order ID assigned by the broker BrokerId string `json:"iss"` // id of the broker RequestTime uint64 `json:"iat"` // unix timestamp when the order was placed Unique *TimeId `json:"uniq,omitempty"` // unique ID allocated on order igress Pair PairName `json:"pair"` // the name of the pair the order is on Type OrderType `json:"type"` // type of order (buy or sell) Status OrderStatus `json:"status"` // new orders will always be in "pending" state Flags OrderFlags `json:"flags,omitempty"` // order flags Amount *Amount `json:"amount,omitempty"` // optional amount, if nil SpendLimit must be set Price *Amount `json:"price,omitempty"` // price, if nil this will be a market order SpendLimit *Amount `json:"spend_limit,omitempty"` // optional spending limit, if nil Amount must be set StopPrice *Amount `json:"stop_price,omitempty"` // ignored if flag Stop is not set }
type OrderFlags ¶
type OrderFlags int
const ( FlagImmediateOrCancel OrderFlags = 1 << iota // do not create an open order after execution FlagFillOrKill // if order can't be fully executed, cancel FlagStop )
func (OrderFlags) MarshalJSON ¶
func (f OrderFlags) MarshalJSON() ([]byte, error)
func (*OrderFlags) UnmarshalJSON ¶
func (f *OrderFlags) UnmarshalJSON(j []byte) error
type OrderStatus ¶
type OrderStatus int
const ( OrderInvalid OrderStatus = -1 OrderPending OrderStatus = iota OrderRunning OrderOpen OrderStop // pending for a trigger OrderDone OrderCancel // cancelled or overwritten order )
func OrderStatusByString ¶
func OrderStatusByString(s string) OrderStatus
func (OrderStatus) IsValid ¶
func (s OrderStatus) IsValid() bool
func (OrderStatus) String ¶
func (s OrderStatus) String() string
type OrderType ¶
type OrderType int
func OrderTypeByString ¶
func (OrderType) MarshalJSON ¶ added in v0.0.3
func (*OrderType) UnmarshalJSON ¶ added in v0.0.3
type SignedOrder ¶
type TimeId ¶
type TimeId struct { Unix uint64 `json:"unix"` Nano uint32 `json:"nano"` // [0, 999999999] Index uint32 `json:"idx"` // index if multiple ids are generated with the same unix/nano values }
func NewUniqueTimeId ¶ added in v0.0.2
func NewUniqueTimeId() *TimeId
NewUniqueTimeId returns a unique (in the local process) TimeId
func (TimeId) Bytes ¶
func (t TimeId) Bytes() [TimeIdDataLen]byte
Bytes returns a 128bits bigendian sortable version of this TimeId
type TimeIdUnique ¶ added in v0.0.2
type TimeIdUnique struct {
Last TimeId
}
func (*TimeIdUnique) Unique ¶ added in v0.0.2
func (u *TimeIdUnique) Unique(t *TimeId)
Unique ensures the provided TimeId is always higher than the latest one and will update it if not the case