swap

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 (
	MarginModeFixed   = "fixed"
	MarginModeCrossed = "crossed"
)
View Source
const (
	FillsEndPoint = "/api/swap/v3/fills"
	ExecTypeTaker = "T"
	ExecTypeMaker = "M"

	TradeTable = "swap/trade"
)
View Source
const (
	TickerTable = "swap/ticker"
)

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.SwapSymbol) exchange.Channel

func NewOrderChannel

func NewOrderChannel(symbol exchange.SwapSymbol) exchange.Channel

func NewTickerChannel

func NewTickerChannel(sym exchange.SwapSymbol) exchange.Channel

func ParseSymbol added in v0.3.0

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

Types

type Depth5

type Depth5 struct {
	Asks   []DepthElem
	Bids   []DepthElem
	Symbol exchange.SwapSymbol
	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
	Liquid decimal.Decimal
}

type Fill added in v0.3.0

type Fill struct {
	TradeID      string          `json:"trade_id"`
	FillID       string          `json:"fill_id"`
	InstrumentID string          `json:"instrument_id"`
	OrderID      string          `json:"order_id"`
	Price        decimal.Decimal `json:"price"`
	OrderQty     decimal.Decimal `json:"order_qty"`
	Fee          decimal.Decimal `json:"fee"`
	Timestamp    string          `json:"timestamp"`
	ExecType     string          `json:"exec_type"`
	Side         string          `json:"side"`
	OrderSide    string          `json:"order_side"`
	Type         string          `json:"type"`
}

func (*Fill) Parse added in v0.3.0

func (f *Fill) Parse() (*exchange.Trade, error)

type MarginPosition

type MarginPosition struct {
	MarginMode string     `json:"margin_mode"`
	Timestamp  string     `json:"timestamp"`
	Holding    []Position `json:"holding"`
}

type OkexSymbol added in v0.3.0

type OkexSymbol struct {
	InstrumentID        string          `json:"instrument_id"`
	Underlying          string          `json:"underlying"`
	BaseCurrency        string          `json:"base_currency"`
	QuoteCurrency       string          `json:"quote_currency"`
	SettlementCurrency  string          `json:"settlement_currency"`
	ContractVal         decimal.Decimal `json:"contract_val"`
	Listing             string          `json:"listing"`
	Delivery            string          `json:"delivery"`
	SizeIncrement       decimal.Decimal `json:"size_increment"`
	TickSize            decimal.Decimal `json:"tick_size"`
	IsInverse           string          `json:"is_inverse"`
	Category            string          `json:"category"`
	ContractValCurrency string          `json:"contract_val_currency"`
	CurrencyIndex       string          `json:"currency_index"`
}

func (*OkexSymbol) Parse added in v0.3.0

func (os *OkexSymbol) Parse() (*Symbol, error)

type Order

type Order struct {
	InstrumentID string          `json:"instrument_id"`
	Size         decimal.Decimal `json:"size"`
	Timestamp    string          `json:"timestamp"`
	FilledQty    decimal.Decimal `json:"filled_qty"`
	Fee          decimal.Decimal `json:"fee"`
	OrderID      string          `json:"order_id"`
	ClientID     string          `json:"client_id"`
	Price        decimal.Decimal `json:"price"`
	PriceAvg     decimal.Decimal `json:"price_avg"`
	Type         string          `json:"type"`
	ContractVal  decimal.Decimal `json:"contract_val"`
	OrderType    string          `json:"order_type"`
	State        string          `json:"state"`
}

func (*Order) Transform

func (o *Order) Transform() (*exchange.Order, error)

type OrderChannel

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

func (*OrderChannel) String

func (oc *OrderChannel) String() string

type Position

type Position struct {
	LiquidationPrice decimal.Decimal `json:"liquidation_price"`
	Position         decimal.Decimal `json:"position"`
	AvailPosition    decimal.Decimal `json:"avail_position"`
	Margin           decimal.Decimal `json:"margin"`
	AvgCost          decimal.Decimal `json:"avg_cost"`
	SettlementPrice  decimal.Decimal `json:"settlement_price"`
	InstrumentID     string          `json:"instrument_id"`
	Leverage         decimal.Decimal `json:"leverage"`
	RealizedPNL      decimal.Decimal `json:"realized_pnl"`
	Side             string          `json:"side"`
	Timestamp        string          `json:"timestamp"`
	MaintMarginRatio decimal.Decimal `json:"maint_margin_ratio"`
	SettlePNL        decimal.Decimal `json:"settle_pnl"`
	Last             decimal.Decimal `json:"last"`
	UnRealizedPNL    decimal.Decimal `json:"unrealized_pnl"`
}

func (*Position) Transform

func (pos *Position) Transform(posMode exchange.PositionMode) (*exchange.Position, error)

type RestClient

type RestClient struct {
	*okex.RestClient
}

func NewRestClient added in v0.3.0

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

func (*RestClient) CancelOrder

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

func (*RestClient) CreateOrder

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

func (*RestClient) FetchPosition

func (rc *RestClient) FetchPosition(ctx context.Context, sym ...exchange.Symbol) ([]*exchange.Position, error)

func (*RestClient) Fills added in v0.3.0

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

func (*RestClient) Finance added in v0.3.0

func (*RestClient) Ledgers added in v0.3.0

func (rc *RestClient) Ledgers(ctx context.Context, instrumentID string, before, after, limit, typ string) ([]okex.Ledger, error)

func (*RestClient) Symbols

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

Symbols return swap symbol

func (*RestClient) Trades added in v0.3.0

func (rc *RestClient) Trades(ctx context.Context, req *exchange.TradeReqParam) ([]exchange.Trade, error)

type Symbol

type Symbol struct {
	*exchange.BaseSwapSymbol
	// contains filtered or unexported fields
}

func (*Symbol) String added in v0.3.0

func (s *Symbol) String() string

type Ticker

type Ticker struct {
	Symbol         exchange.SwapSymbol
	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
	Volume24H      decimal.Decimal
	VolumeToken24H decimal.Decimal
	OpenInterest   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.4

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.4

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

type TradeChannel added in v0.5.4

type TradeChannel struct {
	exchange.SwapSymbol
}

func NewTradeChannel added in v0.5.4

func NewTradeChannel(symbol exchange.SwapSymbol) *TradeChannel

func (*TradeChannel) String added in v0.5.4

func (s *TradeChannel) String() string

Jump to

Keyboard shortcuts

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