f1exapi

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OrderSideASK = "ASK"
	OrderSideBID = "BID"

	OrderTypeLimit  = "LIMIT"
	OrderTypeMarket = "MARKET"

	OrderStatePending = "PENDING"
	OrderStateDone    = "DONE"

	TransferSourceCancel = "CANCEL"
	TransferSourceRefund = "REFUND"
	TransferSourceMatch  = "MATCH"

	TradeSideMaker = "MAKER"
	TradeSideTaker = "TAKER"
)
View Source
const (
	Endpoint = "https://exchange.fox.one"
)

Variables

This section is empty.

Functions

func EncodeAuthMemo

func EncodeAuthMemo(key crypto.PublicKey) (string, error)

func SignToken

func SignToken(claim Claim, key interface{}) (string, error)

SignToken with ecdsa private key

func UseEndpoint

func UseEndpoint(endpoint string)

Types

type AssetTicker

type AssetTicker struct {
	AssetID string `json:"asset_id"`
	Symbol  string `json:"symbol"`

	Volume    decimal.Decimal `json:"volume"`
	Price     decimal.Decimal `json:"price"`
	Change    decimal.Decimal `json:"change"`
	PriceUSD  decimal.Decimal `json:"price_usd"`
	ChangeUSD decimal.Decimal `json:"change_usd"`
	PriceBTC  decimal.Decimal `json:"price_btc"`
	ChangeBTC decimal.Decimal `json:"change_btc"`
}

func ReadAssetTickers

func ReadAssetTickers(ctx context.Context) ([]*AssetTicker, error)

type Claim

type Claim struct {
	jwt.StandardClaims
	MerchantID string `json:"mid,omitempty"`
	UserID     string `json:"uid,omitempty"`
}

type Depth

type Depth struct {
	Asks []DepthOrder `json:"asks,omitempty"`
	Bids []DepthOrder `json:"bids,omitempty"`
	// version
	LastUpdateID int64 `json:"last_update_id,omitempty"`
}

func ReadDepth

func ReadDepth(ctx context.Context, symbol string, limit int) (*Depth, error)

type DepthOrder

type DepthOrder []decimal.Decimal

func (DepthOrder) Values

func (order DepthOrder) Values() (price, amount decimal.Decimal)

type Order

type Order struct {
	OrderID         string          `json:"id"`
	CreatedAt       int64           `json:"created_at"`
	OrderType       string          `json:"order_type"`
	UserID          string          `json:"user_id"`
	QuoteAssetID    string          `json:"quote_asset_id"`
	BaseAssetID     string          `json:"base_asset_id"`
	Symbol          string          `json:"symbol"`
	Side            string          `json:"side"`
	Price           decimal.Decimal `json:"price"`
	RemainingAmount decimal.Decimal `json:"remaining_amount"`
	FilledAmount    decimal.Decimal `json:"filled_amount"`
	RemainingFunds  decimal.Decimal `json:"remaining_fund"`
	FilledFunds     decimal.Decimal `json:"filled_fund"`
	State           string          `json:"state"`
}

func QueryOrder

func QueryOrder(ctx context.Context, token, orderID string) (*Order, error)

func QueryOrders

func QueryOrders(ctx context.Context, token string, input *QueryOrdersInput) ([]*Order, *pagination.Pagination, error)

type OrderAction

type OrderAction struct {
	S string    // side
	A uuid.UUID // asset
	P string    // price
	T string    // type
	O uuid.UUID // order id
	M uuid.UUID // merchant
	U []byte    // user public key
}

func ParsePutOrder

func ParsePutOrder(memo string) (*OrderAction, error)

func (*OrderAction) Encode

func (action *OrderAction) Encode() (string, error)

type Pair

type Pair struct {
	Symbol          string          `json:"symbol,omitempty"`
	Status          string          `json:"status,omitempty"`
	BaseAsset       string          `json:"base_asset,omitempty"`
	BaseAssetID     string          `json:"base_asset_id,omitempty"`
	QuoteAsset      string          `json:"quote_asset,omitempty"`
	QuoteAssetID    string          `json:"quote_asset_id,omitempty"`
	AmountPrecision int32           `json:"amount_precision,omitempty"`
	FundPrecision   int32           `json:"fund_precision,omitempty"`
	PricePrecision  int32           `json:"price_precision,omitempty"`
	BaseMinAmount   decimal.Decimal `json:"base_min_amount,omitempty"`
	BaseMaxAmount   decimal.Decimal `json:"base_max_amount,omitempty"`
	QuoteMinAmount  decimal.Decimal `json:"quote_min_amount,omitempty"`
	QuoteMaxAmount  decimal.Decimal `json:"quote_max_amount,omitempty"`
}

func ReadPairs

func ReadPairs(ctx context.Context) ([]*Pair, error)

type PutOrderInput

type PutOrderInput struct {
	Base       string `valid:"uuid,required"`
	Quote      string `valid:"uuid,required"`
	Side       string `valid:"in(ASK|BID),required"`
	Type       string `valid:"in(LIMIT|MARKET),required"`
	Price      string
	MerchantID string `valid:"uuid"`
}

type PutOrderOutput

type PutOrderOutput struct {
	AssetID  string
	Memo     string
	Opponent string
}

func PutOrder

func PutOrder(input *PutOrderInput) (*PutOrderOutput, error)

type QueryOrdersInput

type QueryOrdersInput struct {
	Symbol string
	Side   string
	Cursor string
	Limit  int
	Order  string
	State  string
	Start  int64 // 单位秒
	End    int64 // 单位秒
}

type TransferAction

type TransferAction struct {
	S string    // source
	O uuid.UUID // order
	A uuid.UUID // asset id
	P string    // price
	C string    // category, bid or ask
}

func ParseTransfer

func ParseTransfer(memo string) (*TransferAction, error)

Jump to

Keyboard shortcuts

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