bitget

package
v0.0.0-...-41d977e Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChannelSpotOrderBook   = "/spotMarket/level2Depth5:"
	ChannelSpotTicker      = "/market/ticker:"
	ChannelSpotPublicTrade = "/market/match:"
)

spot channels

View Source
const (
	Login       = "login"
	Subscribe   = "subscribe"
	UnSubscribe = "unsubscribe"
)
View Source
const (

	/*
	 * http headers
	 */
	ContentType        = "Content-Type"
	BgAccessKey        = "ACCESS-KEY"
	BgAccessSign       = "ACCESS-SIGN"
	BgAccessTimestamp  = "ACCESS-TIMESTAMP"
	BgAccessPassphrase = "ACCESS-PASSPHRASE"
	ApplicationJson    = "application/json"

	EN_US  = "en_US"
	ZH_CN  = "zh_CN"
	LOCALE = "locale="

	/*
	 * websocket
	 */
	WsAuthMethod        = "GET"
	WsAuthPath          = "/user/verify"
	WsOpLogin           = "login"
	WsOpUnsubscribe     = "unsubscribe"
	WsOpSubscribe       = "subscribe"
	TimerIntervalSecond = 5
	ReconnectWaitSecond = 60

	/*
	 * SignType
	 */
	RSA    = "RSA"
	SHA256 = "SHA256"
)
View Source
const (
	BaseUrl = "https://api.bitget.com"
	WsUrl   = "wss://ws.bitget.com/mix/v1/stream"

	ApiKey        = ""
	SecretKey     = ""
	PASSPHRASE    = ""
	TimeoutSecond = 30
	SignType      = SHA256
)

Variables

This section is empty.

Functions

func BuildGetParams

func BuildGetParams(params map[string]string) string

func BuildJsonParams

func BuildJsonParams(params map[string]string) (string, error)

func Headers

func Headers(request *http.Request, apikey string, timestamp string, sign string, passphrase string)

*

  • get header

func NewParams

func NewParams() map[string]string

func RSASign

func RSASign(src []byte, priKey []byte, hash crypto.Hash) ([]byte, error)

func TimesStamp

func TimesStamp() string

func TimesStampSec

func TimesStampSec() string

Types

type ApiResponse

type ApiResponse struct {
	Code    string          `json:"code"`
	RawData json.RawMessage `json:"data"` // delay parsing
	Message string          `json:"msg"`
}

返回的数据结构

type Bitget

type Bitget struct {
	Accesskey  string
	Secretkey  string
	Passphrase string
	Signer     *Signer
	// contains filtered or unexported fields
}

func New

func New(client *http.Client, accesskey, secretkey, passphrase string) *Bitget

func (*Bitget) CancelOrder

func (p *Bitget) CancelOrder(orderId string, currencyPair CurrencyPair) (bool, error)

func (*Bitget) DoGet

func (p *Bitget) DoGet(uri string, params map[string]string) ([]byte, error)

func (*Bitget) DoPost

func (p *Bitget) DoPost(uri string, params string) ([]byte, error)

func (*Bitget) GetAccount

func (p *Bitget) GetAccount() (*Account, error)

func (*Bitget) GetBestTicker

func (p *Bitget) GetBestTicker(currencyPair CurrencyPair) (*BestTicker, error)

func (*Bitget) GetCurrencyPairs

func (p *Bitget) GetCurrencyPairs() ([]CurrencyPair, error)

获取所有交易对

func (*Bitget) GetDepth

func (p *Bitget) GetDepth(size int, currencyPair CurrencyPair) (*Depth, error)

func (*Bitget) GetExchangeName

func (g *Bitget) GetExchangeName() string

func (*Bitget) GetKlineRecords

func (p *Bitget) GetKlineRecords(currencyPair CurrencyPair, period KlinePeriod, size int, optional ...OptionalParameter) ([]Kline, error)

func (*Bitget) GetOneOrder

func (p *Bitget) GetOneOrder(orderId string, currencyPair CurrencyPair) (*Order, error)

func (*Bitget) GetOrderHistorys

func (p *Bitget) GetOrderHistorys(currencyPair CurrencyPair, optional ...OptionalParameter) ([]Order, error)

func (*Bitget) GetSubAccount

func (p *Bitget) GetSubAccount(coin Currency) (*SubAccount, error)

func (*Bitget) GetSubAccounts

func (p *Bitget) GetSubAccounts() ([]SubAccount, error)

func (*Bitget) GetTicker

func (p *Bitget) GetTicker(currencyPair CurrencyPair) (*Ticker, error)

func (*Bitget) GetTradeFee

func (p *Bitget) GetTradeFee(currencyPair CurrencyPair) (*TradeFee, error)

私有权限,交易手续费用在V2版本未见此接口,用回V1版本接口

func (*Bitget) GetTrades

func (p *Bitget) GetTrades(currencyPair CurrencyPair, size int64) ([]Trade, error)

非个人,整个交易所的交易记录

func (*Bitget) GetUnfinishOrders

func (p *Bitget) GetUnfinishOrders(currencyPair CurrencyPair) ([]Order, error)

查询指定交易对所有挂单

func (*Bitget) LimitBuy

func (p *Bitget) LimitBuy(amount, price string, currencyPair CurrencyPair, optional ...LimitOrderOptionalParameter) (*Order, error)

限价买单

func (*Bitget) LimitSell

func (p *Bitget) LimitSell(amount, price string, currencyPair CurrencyPair, optional ...LimitOrderOptionalParameter) (*Order, error)

func (*Bitget) MarketBuy

func (p *Bitget) MarketBuy(amount, price string, currencyPair CurrencyPair) (*Order, error)

func (*Bitget) MarketSell

func (p *Bitget) MarketSell(amount, price string, currencyPair CurrencyPair) (*Order, error)

func (*Bitget) PlaceOrder

func (p *Bitget) PlaceOrder(amount, price string, currencyPair CurrencyPair, orderType, orderSide string) (*Order, error)

限价买单

type KLineModel

type KLineModel []string

KLineModel represents the k lines for a symbol. Rates are returned in grouped buckets based on requested type.

type KLinesModel

type KLinesModel []*KLineModel

A KLinesModel is the set of *KLineModel.

type PartOrderBookModel

type PartOrderBookModel struct {
	Time string     `json:"ts"`
	Bids [][]string `json:"bids"`
	Asks [][]string `json:"asks"`
}

A PartOrderBookModel represents a list of open orders for a symbol, a part of Order Book within 100 depth for each side(ask or bid).

type Signer

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

func (*Signer) Init

func (p *Signer) Init(key string) *Signer

func (*Signer) Sign

func (p *Signer) Sign(method string, requestPath string, body string, timesStamp string) string

func (*Signer) SignByRSA

func (p *Signer) SignByRSA(method string, requestPath string, body string, timesStamp string) string

type SpotWs

type SpotWs struct {
	Signer *Signer
	// contains filtered or unexported fields
}

func NewSpotWs

func NewSpotWs(accesskey, secretkey, passphrase, proxy string) *SpotWs

func (*SpotWs) Auth

func (s *SpotWs) Auth()

func (*SpotWs) BestTickerCallback

func (s *SpotWs) BestTickerCallback(f func(ticker *gocoinex.BestTicker, exchange string))

func (*SpotWs) DepthCallback

func (s *SpotWs) DepthCallback(f func(depth *gocoinex.Depth, exchange string))

func (*SpotWs) HeartbeatData

func (s *SpotWs) HeartbeatData() []byte

func (*SpotWs) SubscribeBestTicker

func (s *SpotWs) SubscribeBestTicker(pair gocoinex.CurrencyPair) error

func (*SpotWs) SubscribeDepth

func (s *SpotWs) SubscribeDepth(pair gocoinex.CurrencyPair) error

func (*SpotWs) SubscribeTicker

func (s *SpotWs) SubscribeTicker(pair gocoinex.CurrencyPair) error

func (*SpotWs) SubscribeTrade

func (s *SpotWs) SubscribeTrade(pair gocoinex.CurrencyPair) error

func (*SpotWs) SubscribeUserBalance

func (s *SpotWs) SubscribeUserBalance() error

func (*SpotWs) SubscribeUserOrder

func (s *SpotWs) SubscribeUserOrder() error

func (*SpotWs) TickerCallback

func (s *SpotWs) TickerCallback(f func(ticker *gocoinex.Ticker, exchange string))

func (*SpotWs) TradeCallback

func (s *SpotWs) TradeCallback(f func(trade *gocoinex.Trade, exchange string))

func (*SpotWs) UnSubscribeBestTicker

func (s *SpotWs) UnSubscribeBestTicker(pair gocoinex.CurrencyPair) error

func (*SpotWs) UnSubscribeDepth

func (s *SpotWs) UnSubscribeDepth(pair gocoinex.CurrencyPair) error

func (*SpotWs) UnSubscribeTicker

func (s *SpotWs) UnSubscribeTicker(pair gocoinex.CurrencyPair) error

func (*SpotWs) UnSubscribeTrade

func (s *SpotWs) UnSubscribeTrade(pair gocoinex.CurrencyPair) error

func (*SpotWs) UnSubscribeUserBalance

func (s *SpotWs) UnSubscribeUserBalance() error

func (*SpotWs) UnSubscribeUserOrder

func (s *SpotWs) UnSubscribeUserOrder() error

func (*SpotWs) UserBalanceCallback

func (s *SpotWs) UserBalanceCallback(f func(trade *gocoinex.SubAccount, exchange string))

func (*SpotWs) UserOrderCallback

func (s *SpotWs) UserOrderCallback(f func(ticker *gocoinex.Order, exchange string))

type SubscribeReq

type SubscribeReq struct {
	InstType string `json:"instType"`
	Channel  string `json:"channel"`
	InstId   string `json:"instId"`
}

type WsBaseReq

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

webSocket 请求结构

type WsBaseResponse

type WsBaseResponse struct {
	Event   string        `json:"event"`
	Code    string        `json:"code"` //错误码,错误时才会返回
	Message string        `json:"msg"`
	Args    []interface{} `json:"args"`
}

webSocket 返回数据结构

type WsLoginBaseReq

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

type WsLoginReq

type WsLoginReq struct {
	ApiKey     string `json:"apiKey"`
	Passphrase string `json:"passphrase"`
	Timestamp  string `json:"timestamp"`
	Sign       string `json:"sign"`
}

type WsSubscribeBaseReq

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

type WsSubscribeBaseResponse

type WsSubscribeBaseResponse struct {
	Action string       `json:"action"`
	Arg    SubscribeReq `json:"arg"`
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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