bitget

package
v1.0.23 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

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

	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="

	/*
	 * http methods
	 */
	GET  = "GET"
	POST = "POST"

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

	/*
	 * SignType
	 */
	RSA    = "RSA"
	SHA256 = "SHA256"
)

doc https://www.bitget.com/zh-CN/api-doc/spot/account/Get-Account-Assets

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 JSONToMap

func JSONToMap(str string) map[string]interface{}

func NewParams

func NewParams() map[string]string

func RSASign

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

func SortParams

func SortParams(params map[string]string) string

func TimesStamp

func TimesStamp() string

func TimesStampSec

func TimesStampSec() string

func ToJson

func ToJson(v interface{}) (string, error)

Types

type AssetsData

type AssetsData struct {
	Coin           string `json:"coin"`
	Available      string `json:"available"`
	Frozen         string `json:"frozen"`
	Locked         string `json:"locked"`
	LimitAvailable string `json:"limitAvailable"`
	UTime          string `json:"uTime"`
}

type AssetsResp

type AssetsResp struct {
	Code        string       `json:"code"`
	Message     string       `json:"message"`
	RequestTime int64        `json:"requestTime"`
	Data        []AssetsData `json:"data"`
}

type BatchOrdersData

type BatchOrdersData struct {
	SuccessList []struct {
		OrderId   string `json:"orderId"`
		ClientOid string `json:"clientOid"`
	} `json:"successList"`
	FailureList []struct {
		OrderId   string `json:"orderId"`
		ClientOid string `json:"clientOid"`
		ErrorMsg  string `json:"errorMsg"`
	} `json:"failureList"`
}

type BatchOrdersResp

type BatchOrdersResp struct {
	Code        string          `json:"code"`
	Msg         string          `json:"msg"`
	RequestTime int64           `json:"requestTime"`
	Data        BatchOrdersData `json:"data"`
}

type Bitget

type Bitget struct {
	exchange.Base
	// contains filtered or unexported fields
}

Bitget creates a mock custom exchange

func (*Bitget) AuthenticateWebsocket

func (b *Bitget) AuthenticateWebsocket(_ context.Context) error

AuthenticateWebsocket is a mock method for Bitget

func (*Bitget) CancelAllOrders

func (b *Bitget) CancelAllOrders(_ context.Context, _ *order.Cancel) (order.CancelAllResponse, error)

CancelAllOrders is a mock method for Bitget

func (*Bitget) CancelBatchOrders

func (b *Bitget) CancelBatchOrders(_ context.Context, ss []order.Cancel) (*order.CancelBatchResponse, error)

CancelBatchOrders is a mock method for Bitget

func (*Bitget) CancelOrder

func (b *Bitget) CancelOrder(_ context.Context, _ *order.Cancel) error

CancelOrder is a mock method for Bitget

func (*Bitget) CheckOrderExecutionLimits

func (b *Bitget) CheckOrderExecutionLimits(_ asset.Item, _ currency.Pair, _, _ float64, _ order.Type) error

CheckOrderExecutionLimits is a mock method for Bitget

func (*Bitget) DisableRateLimiter

func (b *Bitget) DisableRateLimiter() error

DisableRateLimiter is a mock method for Bitget

func (*Bitget) EnableRateLimiter

func (b *Bitget) EnableRateLimiter() error

EnableRateLimiter is a mock method for Bitget

func (*Bitget) FetchAccountInfo

func (b *Bitget) FetchAccountInfo(_ context.Context, _ asset.Item) (account.Holdings, error)

FetchAccountInfo is a mock method for Bitget

func (*Bitget) FetchOrderbook

func (b *Bitget) FetchOrderbook(_ context.Context, _ currency.Pair, _ asset.Item) (*orderbook.Base, error)

FetchOrderbook is a mock method for Bitget

func (*Bitget) FetchTicker

func (b *Bitget) FetchTicker(_ context.Context, pair currency.Pair, assetType asset.Item) (*ticker.Price, error)

FetchTicker is a mock method for Bitget

func (*Bitget) FetchTradablePairs

func (b *Bitget) FetchTradablePairs(_ context.Context, _ asset.Item) (currency.Pairs, error)

FetchTradablePairs is a mock method for Bitget

func (*Bitget) FlushWebsocketChannels

func (b *Bitget) FlushWebsocketChannels() error

FlushWebsocketChannels is a mock method for Bitget

func (*Bitget) FormatWithdrawPermissions

func (b *Bitget) FormatWithdrawPermissions() string

FormatWithdrawPermissions is a mock method for Bitget

func (*Bitget) GetAccountFundingHistory

func (b *Bitget) GetAccountFundingHistory(_ context.Context) ([]exchange.FundingHistory, error)

GetAccountFundingHistory is a mock method for Bitget

func (*Bitget) GetActiveOrders

func (b *Bitget) GetActiveOrders(_ context.Context, req *order.MultiOrderRequest) (order.FilteredOrders, error)

GetActiveOrders is a mock method for Bitget

func (*Bitget) GetAssetTypes

func (b *Bitget) GetAssetTypes(_ bool) asset.Items

GetAssetTypes is a mock method for Bitget

func (*Bitget) GetAvailablePairs

func (b *Bitget) GetAvailablePairs(_ asset.Item) (currency.Pairs, error)

GetAvailablePairs is a mock method for Bitget

func (*Bitget) GetDepositAddress

func (b *Bitget) GetDepositAddress(_ context.Context, _ currency.Code, _, _ string) (*deposit.Address, error)

GetDepositAddress is a mock method for Bitget

func (*Bitget) GetEnabledPairs

func (b *Bitget) GetEnabledPairs(_ asset.Item) (currency.Pairs, error)

GetEnabledPairs is a mock method for Bitget

func (*Bitget) GetFeeByType

func (b *Bitget) GetFeeByType(_ context.Context, _ *exchange.FeeBuilder) (float64, error)

GetFeeByType is a mock method for Bitget

func (*Bitget) GetFuturesContractDetails

func (b *Bitget) GetFuturesContractDetails(context.Context, asset.Item) ([]futures.Contract, error)

GetFuturesContractDetails returns all contracts from the exchange by asset type

func (*Bitget) GetHTTPClientUserAgent

func (b *Bitget) GetHTTPClientUserAgent() (string, error)

GetHTTPClientUserAgent is a mock method for Bitget

func (*Bitget) GetHistoricCandles

func (b *Bitget) GetHistoricCandles(_ context.Context, _ currency.Pair, _ asset.Item, _ kline.Interval, _, _ time.Time) (*kline.Item, error)

GetHistoricCandles is a mock method for Bitget

func (*Bitget) GetHistoricCandlesExtended

func (b *Bitget) GetHistoricCandlesExtended(_ context.Context, _ currency.Pair, _ asset.Item, _ kline.Interval, _, _ time.Time) (*kline.Item, error)

GetHistoricCandlesExtended is a mock method for Bitget

func (*Bitget) GetHistoricTrades

func (b *Bitget) GetHistoricTrades(_ context.Context, _ currency.Pair, _ asset.Item, _, _ time.Time) ([]trade.Data, error)

GetHistoricTrades is a mock method for Bitget

func (*Bitget) GetHistoricalFundingRates

func (b *Bitget) GetHistoricalFundingRates(_ context.Context, _ *fundingrate.HistoricalRatesRequest) (*fundingrate.HistoricalRates, error)

GetHistoricalFundingRates returns funding rates for a given asset and currency for a time period

func (*Bitget) GetLastPairsUpdateTime

func (b *Bitget) GetLastPairsUpdateTime() int64

GetLastPairsUpdateTime is a mock method for Bitget

func (*Bitget) GetLatestFundingRates

GetLatestFundingRates returns the latest funding rates data

func (*Bitget) GetName

func (b *Bitget) GetName() string

GetName is a mock method for Bitget

func (*Bitget) GetOrderExecutionLimits

func (b *Bitget) GetOrderExecutionLimits(_ asset.Item, _ currency.Pair) (order.MinMaxLevel, error)

GetOrderExecutionLimits is a mock method for Bitget

func (*Bitget) GetOrderHistory

func (b *Bitget) GetOrderHistory(_ context.Context, req *order.MultiOrderRequest) (order.FilteredOrders, error)

GetOrderHistory is a mock method for Bitget

func (*Bitget) GetOrderInfo

func (b *Bitget) GetOrderInfo(_ context.Context, _ string, _ currency.Pair, _ asset.Item) (*order.Detail, error)

GetOrderInfo is a mock method for Bitget

func (*Bitget) GetRecentTrades

func (b *Bitget) GetRecentTrades(_ context.Context, _ currency.Pair, _ asset.Item) ([]trade.Data, error)

GetRecentTrades is a mock method for Bitget

func (*Bitget) GetServerTime

func (b *Bitget) GetServerTime(context.Context, asset.Item) (time.Time, error)

GetServerTime is a mock method for Bitget

func (*Bitget) GetSubscriptions

func (b *Bitget) GetSubscriptions() ([]subscription.Subscription, error)

GetSubscriptions is a mock method for Bitget

func (*Bitget) GetWebsocket

func (b *Bitget) GetWebsocket() (*stream.Websocket, error)

GetWebsocket is a mock method for Bitget

func (*Bitget) GetWithdrawPermissions

func (b *Bitget) GetWithdrawPermissions() uint32

GetWithdrawPermissions is a mock method for Bitget

func (*Bitget) GetWithdrawalsHistory

func (b *Bitget) GetWithdrawalsHistory(_ context.Context, _ currency.Code, _ asset.Item) ([]exchange.WithdrawalHistory, error)

GetWithdrawalsHistory is a mock method for Bitget

func (*Bitget) IsAssetWebsocketSupported

func (b *Bitget) IsAssetWebsocketSupported(_ asset.Item) bool

IsAssetWebsocketSupported is a mock method for Bitget

func (*Bitget) IsEnabled

func (b *Bitget) IsEnabled() bool

IsEnabled is a mock method for Bitget

func (*Bitget) IsWebsocketEnabled

func (b *Bitget) IsWebsocketEnabled() bool

IsWebsocketEnabled is a mock method for Bitget

func (*Bitget) ModifyOrder

func (b *Bitget) ModifyOrder(_ context.Context, _ *order.Modify) (*order.ModifyResponse, error)

ModifyOrder is a mock method for Bitget

func (*Bitget) SetClientProxyAddress

func (b *Bitget) SetClientProxyAddress(_ string) error

SetClientProxyAddress is a mock method for Bitget

func (*Bitget) SetDefaults

func (b *Bitget) SetDefaults()

SetDefaults is a mock method for Bitget

func (*Bitget) SetEnabled

func (b *Bitget) SetEnabled(bool)

SetEnabled is a mock method for Bitget

func (*Bitget) SetHTTPClientUserAgent

func (b *Bitget) SetHTTPClientUserAgent(_ string) error

SetHTTPClientUserAgent is a mock method for Bitget

func (*Bitget) SetPairs

func (b *Bitget) SetPairs(_ currency.Pairs, _ asset.Item, _ bool) error

SetPairs is a mock method for Bitget

func (*Bitget) Setup

func (b *Bitget) Setup(_ *config.Exchange) error

Setup is a mock method for Bitget

func (*Bitget) SubmitOrder

func (b *Bitget) SubmitOrder(_ context.Context, _ *order.Submit) (*order.SubmitResponse, error)

SubmitOrder is a mock method for Bitget

func (*Bitget) SubmitOrders

func (b *Bitget) SubmitOrders(_ context.Context, ss ...*order.Submit) ([]*order.SubmitResponse, error)

SubmitOrder is a mock method for Bitget

func (*Bitget) SubscribeToWebsocketChannels

func (b *Bitget) SubscribeToWebsocketChannels(_ []subscription.Subscription) error

SubscribeToWebsocketChannels is a mock method for Bitget

func (*Bitget) SupportsAsset

func (b *Bitget) SupportsAsset(_ asset.Item) bool

SupportsAsset is a mock method for Bitget

func (*Bitget) SupportsAutoPairUpdates

func (b *Bitget) SupportsAutoPairUpdates() bool

SupportsAutoPairUpdates is a mock method for Bitget

func (*Bitget) SupportsREST

func (b *Bitget) SupportsREST() bool

SupportsREST is a mock method for Bitget

func (*Bitget) SupportsRESTTickerBatchUpdates

func (b *Bitget) SupportsRESTTickerBatchUpdates() bool

SupportsRESTTickerBatchUpdates is a mock method for Bitget

func (*Bitget) SupportsWebsocket

func (b *Bitget) SupportsWebsocket() bool

SupportsWebsocket is a mock method for Bitget

func (*Bitget) SupportsWithdrawPermissions

func (b *Bitget) SupportsWithdrawPermissions(_ uint32) bool

SupportsWithdrawPermissions is a mock method for Bitget

func (*Bitget) UnsubscribeToWebsocketChannels

func (b *Bitget) UnsubscribeToWebsocketChannels(_ []subscription.Subscription) error

UnsubscribeToWebsocketChannels is a mock method for Bitget

func (*Bitget) UpdateAccountInfo

func (b *Bitget) UpdateAccountInfo(_ context.Context, _ asset.Item) (account.Holdings, error)

UpdateAccountInfo is a mock method for Bitget

func (*Bitget) UpdateOrderExecutionLimits

func (b *Bitget) UpdateOrderExecutionLimits(_ context.Context, _ asset.Item) error

UpdateOrderExecutionLimits is a mock method for Bitget

func (*Bitget) UpdateOrderbook

func (b *Bitget) UpdateOrderbook(_ context.Context, pair currency.Pair, _ asset.Item) (*orderbook.Base, error)

UpdateOrderbook is a mock method for Bitget

func (*Bitget) UpdateTicker

func (b *Bitget) UpdateTicker(ctx context.Context, pair currency.Pair, a asset.Item) (*ticker.Price, error)

UpdateTicker is a mock method for Bitget

func (*Bitget) UpdateTickers

func (b *Bitget) UpdateTickers(ctx context.Context, pair asset.Item) error

UpdateTickers is a mock method for Bitget

func (*Bitget) UpdateTradablePairs

func (b *Bitget) UpdateTradablePairs(_ context.Context, _ bool) error

UpdateTradablePairs is a mock method for Bitget

func (*Bitget) ValidateAPICredentials

func (b *Bitget) ValidateAPICredentials(_ context.Context, _ asset.Item) error

ValidateAPICredentials is a mock method for Bitget

func (*Bitget) WithdrawCryptocurrencyFunds

func (b *Bitget) WithdrawCryptocurrencyFunds(_ context.Context, _ *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawCryptocurrencyFunds is a mock method for Bitget

func (*Bitget) WithdrawFiatFunds

func (b *Bitget) WithdrawFiatFunds(_ context.Context, _ *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawFiatFunds is a mock method for Bitget

func (*Bitget) WithdrawFiatFundsToInternationalBank

func (b *Bitget) WithdrawFiatFundsToInternationalBank(_ context.Context, _ *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawFiatFundsToInternationalBank is a mock method for Bitget

type BitgetRestClient

type BitgetRestClient struct {
	ApiKey       string
	ApiSecretKey string
	Passphrase   string
	BaseUrl      string
	HttpClient   http.Client
	Signer       *Signer
}

func (*BitgetRestClient) Assets

func (p *BitgetRestClient) Assets(params map[string]string) ([]AssetsData, error)

func (*BitgetRestClient) BatchCancelOrders

func (p *BitgetRestClient) BatchCancelOrders(params map[string]interface{}) (*BatchOrdersData, error)

func (*BitgetRestClient) BatchPlaceOrder

func (p *BitgetRestClient) BatchPlaceOrder(params map[string]interface{}) (*BatchOrdersData, error)

func (*BitgetRestClient) CancelOrder

func (p *BitgetRestClient) CancelOrder(params map[string]string) (string, error)

func (*BitgetRestClient) Credentials

func (p *BitgetRestClient) Credentials(cre *account.Credentials)

func (*BitgetRestClient) DoGet

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

func (*BitgetRestClient) DoGetWithCredentials

func (p *BitgetRestClient) DoGetWithCredentials(uri string, params map[string]string) ([]byte, error)

func (*BitgetRestClient) DoPost

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

func (*BitgetRestClient) Fills

func (p *BitgetRestClient) Fills(params map[string]string) ([]FillsData, error)

查询历史成交

func (*BitgetRestClient) Init

func (*BitgetRestClient) Orderbook

func (p *BitgetRestClient) Orderbook(params map[string]string) (*OrderbookData, error)

func (*BitgetRestClient) OrdersPending

func (p *BitgetRestClient) OrdersPending(params map[string]string) ([]UnfilledOrdersData, error)

func (*BitgetRestClient) Symbols

func (p *BitgetRestClient) Symbols(params map[string]string) (string, error)

func (*BitgetRestClient) Tickers

func (p *BitgetRestClient) Tickers(params map[string]string) ([]TickersData, error)

type FillsData

type FillsData struct {
	UserId    string `json:"userId"`
	Symbol    string `json:"symbol"`
	OrderId   string `json:"orderId"`
	TradeId   string `json:"tradeId"`
	OrderType string `json:"orderType"`
	Side      string `json:"side"`
	PriceAvg  string `json:"priceAvg"`
	Size      string `json:"size"`
	Amount    string `json:"amount"`
	FeeDetail struct {
		Deduction         string `json:"deduction"`
		FeeCoin           string `json:"feeCoin"`
		TotalDeductionFee string `json:"totalDeductionFee"`
		TotalFee          string `json:"totalFee"`
	} `json:"feeDetail"`
	TradeScope string `json:"tradeScope"`
	CTime      string `json:"cTime"`
	UTime      string `json:"uTime"`
}

type FillsResp

type FillsResp struct {
	Code        string      `json:"code"`
	Msg         string      `json:"msg"`
	RequestTime int64       `json:"requestTime"`
	Data        []FillsData `json:"data"`
}

type OrderbookData

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

type OrderbookResp

type OrderbookResp struct {
	Code        string        `json:"code"`
	Msg         string        `json:"msg"`
	RequestTime int64         `json:"requestTime"`
	Data        OrderbookData `json:"data"`
}

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 TickersData

type TickersData struct {
	Symbol       string `json:"symbol"`
	High24H      string `json:"high24h"`
	Open         string `json:"open"`
	Low24H       string `json:"low24h"`
	LastPr       string `json:"lastPr"`
	QuoteVolume  string `json:"quoteVolume"`
	BaseVolume   string `json:"baseVolume"`
	UsdtVolume   string `json:"usdtVolume"`
	BidPr        string `json:"bidPr"`
	AskPr        string `json:"askPr"`
	BidSz        string `json:"bidSz"`
	AskSz        string `json:"askSz"`
	OpenUtc      string `json:"openUtc"`
	Ts           string `json:"ts"`
	ChangeUtc24H string `json:"changeUtc24h"`
	Change24H    string `json:"change24h"`
}

type TickersResp

type TickersResp struct {
	Code        string        `json:"code"`
	Msg         string        `json:"msg"` //success
	RequestTime int64         `json:"requestTime"`
	Data        []TickersData `json:"data"`
}

type UnfilledOrdersData

type UnfilledOrdersData struct {
	UserId           string      `json:"userId"`
	Symbol           string      `json:"symbol"`
	OrderId          string      `json:"orderId"`
	ClientOid        string      `json:"clientOid"`
	PriceAvg         string      `json:"priceAvg"`
	Size             string      `json:"size"`
	OrderType        string      `json:"orderType"`
	Side             string      `json:"side"`
	Status           string      `json:"status"`
	BasePrice        string      `json:"basePrice"`
	BaseVolume       string      `json:"baseVolume"`
	QuoteVolume      string      `json:"quoteVolume"`
	EnterPointSource string      `json:"enterPointSource"`
	TriggerPrice     interface{} `json:"triggerPrice"`
	TpslType         string      `json:"tpslType"`
	CTime            string      `json:"cTime"`
}

type UnfilledOrdersResp

type UnfilledOrdersResp struct {
	Code        string               `json:"code"`
	Message     string               `json:"message"`
	RequestTime int64                `json:"requestTime"`
	Data        []UnfilledOrdersData `json:"data"`
}

Jump to

Keyboard shortcuts

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