okex

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FlateDecompress

func FlateDecompress(data []byte) ([]byte, error)

func HmacSha256Base64Signer

func HmacSha256Base64Signer(message string, secretKey string) (string, error)

Types

type Api

type Api struct {
	ApiKey     string
	SecretKey  string
	Passphrase string
}

func (*Api) Candles

func (self *Api) Candles(instId, bar, before string) [][]string

获取所有交易产品K线数据 获取K线数据。K线数据按请求的粒度分组返回,K线数据每个粒度最多可获取最近1440条。 bar 1m/3m/5m/15m/30m/1H/2H/4H/6H/12H/1D/1W/1M/3M/6M/1Y

func (*Api) EstimatedPrice

func (self *Api) EstimatedPrice(instId string) []*EstimatedPrice

获取预估交割/行权价格 获取交割合约和期权预估交割/行权价。交割/行权预估价只有交割/行权前一小时才有返回值

func (*Api) ExchangeRate

func (self *Api) ExchangeRate() []*UsdCny

获取法币汇率 该接口提供的是2周的平均汇率数据

func (*Api) InitApiKeys

func (self *Api) InitApiKeys(apikey, secretkey, passphrase string)

初始化 Key

func (*Api) Instruments

func (self *Api) Instruments(instType, uly, instId string) []*Instrument

获取所有可交易产品的信息列表

func (*Api) Order

func (self *Api) Order(instId, tdMode, side, posSide string, px, sz float32) []*OrderRes

交易数量,表示要购买或者出售的数量。 当币币/币币杠杆以限价买入和卖出时,指交易货币数量。 当币币/币币杠杆以市价买入时,指计价货币的数量。 当币币/币币杠杆以市价卖出时,指交易货币的数量。 当交割、永续、期权买入和卖出时,指合约张数。

func (*Api) PriceLimit

func (self *Api) PriceLimit(instId string) []*PriceLimit

查询单个交易产品的最高买价和最低卖价 仅适用于交割/永续/期权

func (*Api) SysTime

func (self *Api) SysTime() []*SysTime

func (*Api) Ticker

func (self *Api) Ticker(instId string) []*Ticker

获取单个产品行情信息

func (*Api) Tickers

func (self *Api) Tickers(instType, uly string) []*Ticker

获取所有产品行情信息

type Balance

type Balance struct {
	AdjEq   string `json:"adjEq"`
	Details []struct {
		AvailBal      string `json:"availBal"`
		AvailEq       string `json:"availEq"`
		CashBal       string `json:"cashBal"`
		Ccy           string `json:"ccy"`
		CrossLiab     string `json:"crossLiab"`
		DisEq         string `json:"disEq"`
		Eq            string `json:"eq"`
		EqUsd         string `json:"eqUsd"`
		FrozenBal     string `json:"frozenBal"`
		Interest      string `json:"interest"`
		IsoEq         string `json:"isoEq"`
		IsoLiab       string `json:"isoLiab"`
		IsoUpl        string `json:"isoUpl"`
		Liab          string `json:"liab"`
		MaxLoan       string `json:"maxLoan"`
		MgnRatio      string `json:"mgnRatio"`
		NotionalLever string `json:"notionalLever"`
		OrdFrozen     string `json:"ordFrozen"`
		Twap          string `json:"twap"`
		UTime         string `json:"uTime"`
		Upl           string `json:"upl"`
		UplLiab       string `json:"uplLiab"`
		StgyEq        string `json:"stgyEq"`
	} `json:"details"`
	Imr         string `json:"imr"`
	IsoEq       string `json:"isoEq"`
	MgnRatio    string `json:"mgnRatio"`
	Mmr         string `json:"mmr"`
	NotionalUsd string `json:"notionalUsd"`
	OrdFroz     string `json:"ordFroz"`
	TotalEq     string `json:"totalEq"`
	UTime       string `json:"uTime"`
}

type Base

type Base struct {
	*Api
	*Ws
}

func (*Base) Balance

func (self *Base) Balance(symbol conset.SYMBOL) float32

func (*Base) Init

func (self *Base) Init(strings []string)

func (*Base) Orders

func (self *Base) Orders(symbol conset.SYMBOL, period conset.PERIOD, direct conset.OPERATION, price, sz float32) bool

func (*Base) Period

func (self *Base) Period(period conset.PERIOD) string

func (*Base) Plat

func (self *Base) Plat() conset.PLAT

func (*Base) Price

func (self *Base) Price(symbol conset.SYMBOL) float32

func (*Base) Pull

func (self *Base) Pull(symbol conset.SYMBOL, times conset.TIMES, start time.Time) bool

func (*Base) SetLeverage

func (self *Base) SetLeverage(symbol conset.SYMBOL, period conset.PERIOD, direct conset.OPERATION, level string) bool

func (*Base) Side

func (self *Base) Side(direct conset.OPERATION) (string, string)

func (*Base) SubscribeTickers

func (self *Base) SubscribeTickers(symbols []conset.SYMBOL, f func(conset.SYMBOL, float32))

func (*Base) Symbol

func (self *Base) Symbol(symbol conset.SYMBOL) string

func (*Base) TdMode

func (self *Base) TdMode(period conset.PERIOD) string

func (*Base) Times

func (self *Base) Times(times conset.TIMES) string

func (*Base) UsdCny

func (self *Base) UsdCny() float32

type Candle

type Candle [][]string

type EstimatedPrice

type EstimatedPrice struct {
	InstType string `json:"instType"`
	InstID   string `json:"instId"`
	SettlePx string `json:"settlePx"`
	Ts       string `json:"ts"`
}

type Instrument

type Instrument struct {
	InstType  string `json:"instType"`
	InstID    string `json:"instId"`
	Uly       string `json:"uly"`
	Category  string `json:"category"`
	BaseCcy   string `json:"baseCcy"`
	QuoteCcy  string `json:"quoteCcy"`
	SettleCcy string `json:"settleCcy"`
	CtVal     string `json:"ctVal"`
	CtMult    string `json:"ctMult"`
	CtValCcy  string `json:"ctValCcy"`
	OptType   string `json:"optType"`
	Stk       string `json:"stk"`
	ListTime  string `json:"listTime"`
	ExpTime   string `json:"expTime"`
	Lever     string `json:"lever"`
	TickSz    string `json:"tickSz"`
	LotSz     string `json:"lotSz"`
	MinSz     string `json:"minSz"`
	CtType    string `json:"ctType"`
	Alias     string `json:"alias"`
	State     string `json:"state"`
}

type OrderRes

type OrderRes struct {
	ClOrdID string `json:"clOrdId"`
	OrdID   string `json:"ordId"`
	Tag     string `json:"tag"`
	SCode   string `json:"sCode"`
	SMsg    string `json:"sMsg"`
}

type PriceLimit

type PriceLimit struct {
	InstType string `json:"instType"`
	InstID   string `json:"instId"`
	BuyLmt   string `json:"buyLmt"`
	SellLmt  string `json:"sellLmt"`
	Ts       string `json:"ts"`
}

type Response

type Response struct {
	Code string      `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

type SetLeverage

type SetLeverage struct {
	Lever   string `json:"lever"`
	MgnMode string `json:"mgnMode"`
	InstID  string `json:"instId"`
	PosSide string `json:"posSide"`
}

type SysTime

type SysTime struct {
	Ts string `json:"ts"`
}

type Ticker

type Ticker struct {
	InstType  string `json:"instType"`
	InstID    string `json:"instId"`
	Last      string `json:"last"`
	LastSz    string `json:"lastSz"`
	AskPx     string `json:"askPx"`
	AskSz     string `json:"askSz"`
	BidPx     string `json:"bidPx"`
	BidSz     string `json:"bidSz"`
	Open24H   string `json:"open24h"`
	High24H   string `json:"high24h"`
	Low24H    string `json:"low24h"`
	VolCcy24H string `json:"volCcy24h"`
	Vol24H    string `json:"vol24h"`
	Ts        string `json:"ts"`
	SodUtc0   string `json:"sodUtc0"`
	SodUtc8   string `json:"sodUtc8"`
}

type UsdCny

type UsdCny struct {
	UsdCny string `json:"usdCny"`
}

type Ws

type Ws struct {
	*ws.WsBuilder

	WsConn *ws.WsConn

	ApiKey     string
	SecretKey  string
	Passphrase string
	// contains filtered or unexported fields
}

func (*Ws) ConnectWs

func (self *Ws) ConnectWs()

func (*Ws) InitWsKeys

func (self *Ws) InitWsKeys(apikey, secretkey, passphrase string)

初始化 Key

func (*Ws) Subscribe

func (self *Ws) Subscribe(sub map[string]interface{}) error

func (*Ws) UUID

func (self *Ws) UUID() string

func (*Ws) WsTickers

func (self *Ws) WsTickers(instIds []string, f func(conset.SYMBOL, float32)) error

Jump to

Keyboard shortcuts

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