bitmex

package
v0.0.0-...-df03107 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2020 License: BSD-3-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResponseErrCode = 3001
)

Variables

Functions

func GenerateSign

func GenerateSign(apiSecret, verb, urlpath string,
	nonce int64, data map[string]interface{}) ([]byte, error)

Generates an API signature. A signature is HMAC_SHA256(secret, verb + path + nonce + data), hex encoded. Verb must be uppercased, url is relative, nonce must be an increasing 64-bit integer and the data, if present, must be JSON without whitespace between keys.

For example, in psuedocode (and in real code below):

verb=POST url=/api/v1/order nonce=1416993995705 data={"symbol":"XBTZ14","quantity":1,"price":395.01} signature = HEX(HMAC_SHA256(secret, 'POST/api/v1/order1416993995705{"symbol":"XBTZ14","quantity":1,"price":395.01}'))

Types

type Auth

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

func NewAuth

func NewAuth(apiKey, apiSecret string, expire int) *Auth

func (*Auth) GetOperateArgs

func (auth *Auth) GetOperateArgs() []string

func (*Auth) Serialize

func (auth *Auth) Serialize() ([]byte, error)

type Bitmex

type Bitmex struct {
	APIKey    string
	APISecret string

	BaseUrl string
	// contains filtered or unexported fields
}

func CreateBitmex

func CreateBitmex(
	ctx context.Context, interval []int,
	cfg *config.ExchangeConfig, httpCfg *config.HttpConfig,
	msgManager *msgmanager.MessageManager) *Bitmex

func (*Bitmex) BuyOrSell

func (bitmex *Bitmex) BuyOrSell(
	ord *api.TradeOrd) (map[string]interface{}, error)

发送买入/卖出指令

func (*Bitmex) EditLeverage

func (bitmex *Bitmex) EditLeverage(
	symbol string, leverage float64) (map[string]interface{}, error)

调整某品种的杠杆

func (*Bitmex) GetExchangeName

func (bm *Bitmex) GetExchangeName() string

func (*Bitmex) GetHistoryFunding

func (bitmex *Bitmex) GetHistoryFunding(
	symbol string, start, end time.Time) ([]*model.Funding, error)

func (*Bitmex) GetHistoryKline

func (bitmex *Bitmex) GetHistoryKline(
	symbol, interval string, start, end time.Time) ([]*model.Kline, error)

func (*Bitmex) GetWsAuthHandler

func (bm *Bitmex) GetWsAuthHandler() api.WsAuthSubscribeHandler

func (*Bitmex) GetWsSubscribeHandler

func (bm *Bitmex) GetWsSubscribeHandler() api.WsAuthSubscribeHandler

func (*Bitmex) HandleFunding

func (bitmex *Bitmex) HandleFunding(value *resp)

func (*Bitmex) HandleLiquidation

func (bitmex *Bitmex) HandleLiquidation(value *resp)

func (*Bitmex) HandleMessage

func (bitmex *Bitmex) HandleMessage(data api.ParsedData)

func (*Bitmex) HandleOrder

func (bitmex *Bitmex) HandleOrder(value *resp)

func (*Bitmex) HandleOrderBookL2_25

func (bitmex *Bitmex) HandleOrderBookL2_25(value *resp)

func (*Bitmex) HandlePosition

func (bitmex *Bitmex) HandlePosition(value *resp)

func (*Bitmex) HandleQuote

func (bitmex *Bitmex) HandleQuote(value *resp)

func (*Bitmex) HandleTrade

func (bitmex *Bitmex) HandleTrade(value *resp)

func (*Bitmex) Parse

func (bitmex *Bitmex) Parse(data []byte) (*api.ParsedData, error)

func (*Bitmex) StopOrd

func (bitmex *Bitmex) StopOrd(
	ord *api.TradeOrd) (map[string]interface{}, error)

发送止损/止盈单

type Subscribe

type Subscribe struct {
	Op   string   `json:"op"`
	Args []string `json:"args"`
}

func NewSubscribe

func NewSubscribe(symbols []string, args ...string) *Subscribe

func (*Subscribe) GetOperateArgs

func (sub *Subscribe) GetOperateArgs() []string

func (*Subscribe) Serialize

func (sub *Subscribe) Serialize() ([]byte, error)

Jump to

Keyboard shortcuts

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