spot

package
v0.5.10 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OrderSideBuy      = "buy"
	OrderSideSell     = "sell"
	OrderTypeMarket   = "market"
	OrderTypeLimit    = "limit"
	OrderTypeNoraml   = "0"
	OrderTypePostOnly = "1"
	OrderTypeFOK      = "2"
	OrderTypeIOC      = "3"

	CreateOrderEndPoint = "/api/spot/v3/orders"
)
View Source
const (
	AccountEndPoint = "/api/spot/v3/accounts"
)
View Source
const (
	FillsEndPoint = "/api/spot/v3/fills"
)
View Source
const (
	TradeTable = "spot/trade"
)

Variables

This section is empty.

Functions

func Init added in v0.3.0

func Init(ctx context.Context) error

func NewDepth5Channel

func NewDepth5Channel(sym exchange.SpotSymbol) exchange.Channel

func NewTickerChannel

func NewTickerChannel(sym exchange.SpotSymbol) exchange.Channel

func ParseSymbol added in v0.3.0

func ParseSymbol(symbol string) (exchange.SpotSymbol, error)

func TestnetInit added in v0.3.0

func TestnetInit(ctx context.Context) error

Types

type AccountResp added in v0.3.0

type AccountResp struct {
	ID        string          `json:"id"`
	Available decimal.Decimal `json:"available"`
	Balance   decimal.Decimal `json:"balance"`
	Currency  string          `json:"currency"`
	Hold      decimal.Decimal `json:"hold"`
	Frozen    decimal.Decimal `json:"frozen"`
	Holds     decimal.Decimal `json:"holds"`
}

type Accounts added in v0.3.0

type Accounts []AccountResp

type Depth5

type Depth5 struct {
	Asks   []DepthElem
	Bids   []DepthElem
	Symbol exchange.SpotSymbol
	Time   time.Time
}

Depth5

type Depth5Channel

type Depth5Channel struct {
	// contains filtered or unexported fields
}

func (*Depth5Channel) String

func (dc *Depth5Channel) String() string

type DepthElem

type DepthElem struct {
	Price  decimal.Decimal
	Amount decimal.Decimal
	Orders decimal.Decimal
}

type FetchOrderResponse added in v0.3.0

type FetchOrderResponse struct {
	OrderID        string `json:"order_id"`
	ClientOID      string `json:"client_oid"`
	Price          string `json:"price"`
	Size           string `json:"size"`
	OrderType      string `json:"order_type"`
	Notional       string `json:"notional"`
	InstrumentID   string `json:"instrument_id"`
	Side           string `json:"side"`
	Type           string `json:"type"`
	Timestamp      string `json:"timestamp"`
	FilledSize     string `json:"filled_size"`
	FilledNotional string `json:"filled_notional"`
	State          string `json:"state"`
	PriceAvg       string `json:"price_avg"`
	FeeCurrency    string `json:"fee_currency"`
	Fee            string `json:"fee"`
	RebateCurrency string `json:"rebate_currency"`
	Rebate         string `json:"rebate"`
}

func (*FetchOrderResponse) Transform added in v0.3.0

func (fResp *FetchOrderResponse) Transform() (*exchange.Order, error)

type Fill added in v0.3.0

type Fill struct {
	LedgerID     string          `json:"ledger_id"`
	TradeID      string          `json:"trade_id"`
	InstrumentID string          `json:"instrument_id"`
	Price        decimal.Decimal `json:"price"`
	Size         decimal.Decimal `json:"size"`
	OrderID      string          `json:"order_id"`
	ExecType     string          `json:"exec_type"`
	Timestamp    string          `json:"timestamp"`
	Fee          decimal.Decimal `json:"fee"`
	Side         string          `json:"side"`
	Currency     string          `json:"currency"`
}

type OkexSymbol added in v0.3.0

type OkexSymbol struct {
	InstrumentID  string          `json:"instrument_id"`
	BaseCurrency  string          `json:"base_currency"`
	QuoteCurrency string          `json:"quote_currency"`
	MinSize       decimal.Decimal `json:"min_size"`
	SizeIncrement decimal.Decimal `json:"size_increment"`
	TickSize      decimal.Decimal `json:"tick_size"`
	Category      string          `json:"category"`
}

func (*OkexSymbol) Transform added in v0.3.0

func (os *OkexSymbol) Transform() (exchange.SpotSymbol, error)

type OrderParam added in v0.3.0

type OrderParam struct {
	Type         string `json:"type"`
	Side         string `json:"side"`
	InstrumentID string `json:"instrument_id"`
	Size         string `json:"size"`
	ClinetOID    string `json:"client_oid"`
	Price        string `json:"price,omitempty"`
	OrderType    string `json:"order_type"`
	Notional     string `json:"notional,omitempty"`
}

type OrderResponse added in v0.3.0

type OrderResponse struct {
	OrderID      string `json:"order_id"`
	ClientID     string `json:"client_id"`
	Result       bool   `json:"result"`
	ErrorCode    string `json:"error_code"`
	ErrorMessage string `json:"error_message"`
}

func (*OrderResponse) Transform added in v0.3.0

func (resp *OrderResponse) Transform(sym exchange.Symbol) (*exchange.Order, error)

type RestClient added in v0.3.0

type RestClient struct {
	*okex.RestClient
}

func NewRestClient added in v0.3.0

func NewRestClient(key, secret, pass string) *RestClient

func NewTestRestClient added in v0.3.0

func NewTestRestClient(key, secret, pass string) *RestClient

func (*RestClient) CancelOrder added in v0.3.0

func (rc *RestClient) CancelOrder(ctx context.Context, order *exchange.Order) error

func (*RestClient) CreateOrder added in v0.3.0

func (rc *RestClient) CreateOrder(ctx context.Context, req *exchange.OrderRequest, options ...exchange.OrderReqOption) (*exchange.Order, error)

CreateOrder create a spot order

func (*RestClient) FetchAccounts added in v0.3.0

func (rc *RestClient) FetchAccounts(ctx context.Context) (Accounts, error)

func (*RestClient) FetchOrder added in v0.3.0

func (rc *RestClient) FetchOrder(ctx context.Context, order *exchange.Order) (*exchange.Order, error)

func (*RestClient) Fills added in v0.3.0

func (rc *RestClient) Fills(ctx context.Context, instrumentID, orderID string, before, after, limit string) ([]Fill, error)

Fills return okex fills in time descent order

func (*RestClient) Symbols added in v0.3.0

func (rc *RestClient) Symbols(ctx context.Context) ([]exchange.SpotSymbol, error)

type Symbol added in v0.3.0

type Symbol struct {
	*exchange.BaseSpotSymbol
}

func (*Symbol) String added in v0.3.0

func (s *Symbol) String() string

type Ticker

type Ticker struct {
	Symbol         exchange.SpotSymbol
	Last           decimal.Decimal
	LastQty        decimal.Decimal
	BestBid        decimal.Decimal
	BestBidSize    decimal.Decimal
	BestAsk        decimal.Decimal
	BestAskSize    decimal.Decimal
	Open24H        decimal.Decimal
	High24H        decimal.Decimal
	Low24H         decimal.Decimal
	BaseVolume24H  decimal.Decimal
	QuoteVolume24H decimal.Decimal
	Time           time.Time
}

type TickerChannel

type TickerChannel struct {
	// contains filtered or unexported fields
}

func (*TickerChannel) String

func (tc *TickerChannel) String() string

type Trade added in v0.5.1

type Trade struct {
	InstrumentID string `json:"instrument_id"`
	Price        string `json:"price"`
	Side         string `json:"side"`
	Size         string `json:"size"`
	Timestamp    string `json:"timestamp"`
	TradeID      string `json:"trade_id"`
}

func (*Trade) Transform added in v0.5.1

func (t *Trade) Transform() (*exchange.PublicTrade, error)

type TradeChannel added in v0.5.1

type TradeChannel struct {
	// contains filtered or unexported fields
}

func NewTradeChannel added in v0.5.1

func NewTradeChannel(sym exchange.Symbol) *TradeChannel

func (*TradeChannel) String added in v0.5.1

func (s *TradeChannel) String() string

Jump to

Keyboard shortcuts

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