Versions in this module Expand all Collapse all v1 v1.0.2 Dec 4, 2023 v1.0.1 Dec 4, 2023 Changes in this version + const AckMessage + const ApiKeyVersionV1 + const ApiKeyVersionV2 + const ApiSuccess + const Command + const ErrorMessage + const Message + const Notice + const PingMessage + const PongMessage + const ProductionApiBaseURI + const SubscribeMessage + const UnsubscribeMessage + const WelcomeMessage + var DebugMode = os.Getenv("API_DEBUG_MODE") == "1" + var Version = "1.0.5" + func IntToString(i int64) string + func SetLoggerDirectory(directory string) + func ToJsonString(v interface{}) string + type AccountModel struct + AccountEquity float64 + AvailableBalance float64 + Currency string + FrozenFunds float64 + MarginBalance float64 + OrderMargin float64 + PositionMargin float64 + UnrealisedPNL float64 + type AccountsModel []*AccountModel + type ApiResponse struct + Code string + Message string + RawData jsoniter.RawMessage + func (ar *ApiResponse) ApiSuccessful() bool + func (ar *ApiResponse) HttpSuccessful() bool + func (ar *ApiResponse) ReadData(v interface{}) error + func (ar *ApiResponse) ReadPaginationData(v interface{}) (*PaginationModel, error) + type ApiService struct + func NewApiService(opts ...ApiServiceOption) *ApiService + func NewApiServiceFromEnv() *ApiService + func (as *ApiService) AccountOverview(params map[string]string) (*ApiResponse, error) + func (as *ApiService) ActiveContracts() (*ApiResponse, error) + func (as *ApiService) ApplyWithdrawal(currency, address, amount string, options map[string]string) (*ApiResponse, error) + func (as *ApiService) AutoDepositStatus(params map[string]string) (*ApiResponse, error) + func (as *ApiService) Call(request *Request) (*ApiResponse, error) + func (as *ApiService) CancelOrder(orderId string) (*ApiResponse, error) + func (as *ApiService) CancelOrders(symbol string) (*ApiResponse, error) + func (as *ApiService) CancelTransfer(applyId string) (*ApiResponse, error) + func (as *ApiService) CancelWithdrawal(withdrawalId string) (*ApiResponse, error) + func (as *ApiService) ChangeRiskLimitLevel(params map[string]string) (*ApiResponse, error) + func (as *ApiService) Contracts(symbol string) (*ApiResponse, error) + func (as *ApiService) ContractsRiskLimitLevel(symbol string) (*ApiResponse, error) + func (as *ApiService) CreateOrder(params map[string]string) (*ApiResponse, error) + func (as *ApiService) CreateSubApiKey(p map[string]string) (*ApiResponse, error) + func (as *ApiService) DeleteSubApiKey(apiKey, passphrase, subName string) (*ApiResponse, error) + func (as *ApiService) DepositAddresses(currency string) (*ApiResponse, error) + func (as *ApiService) DepositMargin(params map[string]string) (*ApiResponse, error) + func (as *ApiService) Deposits(params map[string]string, pagination *PaginationParam) (*ApiResponse, error) + func (as *ApiService) Fills(params map[string]string, pagination *PaginationParam) (*ApiResponse, error) + func (as *ApiService) FundingHistory(params map[string]string) (*ApiResponse, error) + func (as *ApiService) FundingRate(Symbol string) (*ApiResponse, error) + func (as *ApiService) IndexQuery(params map[string]string, pagination *PaginationParam) (*ApiResponse, error) + func (as *ApiService) InterestQuery(params map[string]string, pagination *PaginationParam) (*ApiResponse, error) + func (as *ApiService) KLines(symbol, granularity string, startAt, endAt int64) (*ApiResponse, error) + func (as *ApiService) Level2MessageQuery(symbol string, start, end int64) (*ApiResponse, error) + func (as *ApiService) Level2Snapshot(symbol string) (*ApiResponse, error) + func (as *ApiService) Level3MessageQuery(symbol string, start, end int64) (*ApiResponse, error) + func (as *ApiService) Level3Snapshot(symbol string) (*ApiResponse, error) + func (as *ApiService) Level3SnapshotV2(symbol string) (*ApiResponse, error) + func (as *ApiService) MarkPrice(Symbol string) (*ApiResponse, error) + func (as *ApiService) ModifySubApiKey(p map[string]string) (*ApiResponse, error) + func (as *ApiService) NewWebSocketClient(token *WebSocketTokenModel) *WebSocketClient + func (as *ApiService) ObtainStopOrders(symbol string, page *PaginationParam) (*ApiResponse, error) + func (as *ApiService) OpenOrderStatistics(symbol string) (*ApiResponse, error) + func (as *ApiService) Order(orderId string) (*ApiResponse, error) + func (as *ApiService) OrderByClientOid(clientOid string) (*ApiResponse, error) + func (as *ApiService) Orders(params map[string]string, pagination *PaginationParam) (*ApiResponse, error) + func (as *ApiService) Position(symbol string) (*ApiResponse, error) + func (as *ApiService) Positions(currency string) (*ApiResponse, error) + func (as *ApiService) PremiumQuery(params map[string]string, pagination *PaginationParam) (*ApiResponse, error) + func (as *ApiService) RecentDoneOrders(symbol string) (*ApiResponse, error) + func (as *ApiService) RecentFills() (*ApiResponse, error) + func (as *ApiService) ServerTime() (*ApiResponse, error) + func (as *ApiService) ServiceStatus() (*ApiResponse, error) + func (as *ApiService) StopOrders(symbol string) (*ApiResponse, error) + func (as *ApiService) SubAccountsBalance(currency string) (*ApiResponse, error) + func (as *ApiService) SubApiKeys(apiKey, subName string) (*ApiResponse, error) + func (as *ApiService) Ticker(symbol string) (*ApiResponse, error) + func (as *ApiService) TradeHistory(symbol string) (*ApiResponse, error) + func (as *ApiService) TransactionHistory(params map[string]string, pagination *PaginationParam) (*ApiResponse, error) + func (as *ApiService) TransferIn(currency, payAccountType, amount string) (*ApiResponse, error) + func (as *ApiService) TransferList(params map[string]string, pagination *PaginationParam) (*ApiResponse, error) + func (as *ApiService) TransferOut(bizNo, amount string) (*ApiResponse, error) + func (as *ApiService) TransferOutV2(bizNo, amount, currency string) (*ApiResponse, error) + func (as *ApiService) TransferOutV3(currency, recAccountType, amount string) (*ApiResponse, error) + func (as *ApiService) WebSocketPrivateToken() (*ApiResponse, error) + func (as *ApiService) WebSocketPublicToken() (*ApiResponse, error) + func (as *ApiService) WithdrawalQuotas(currency string) (*ApiResponse, error) + func (as *ApiService) Withdrawals(params map[string]string, pagination *PaginationParam) (*ApiResponse, error) + type ApiServiceOption func(service *ApiService) + func ApiBaseURIOption(uri string) ApiServiceOption + func ApiKeyOption(key string) ApiServiceOption + func ApiKeyVersionOption(apiKeyVersion string) ApiServiceOption + func ApiPassPhraseOption(passPhrase string) ApiServiceOption + func ApiSecretOption(secret string) ApiServiceOption + func ApiSkipVerifyTlsOption(skipVerifyTls bool) ApiServiceOption + type ApplyWithdrawalResultModel struct + WithdrawalId string + type BasicRequester struct + func (br *BasicRequester) Request(request *Request, timeout time.Duration) (*Response, error) + type CancelOrderResultModel struct + CancelledOrderIds []string + type CancelTransferModel struct + ApplyId string + type CancelWithdrawalResultModel struct + CancelledWithdrawIds []string + type ContractsModel struct + BaseCurrency string + FairMethod string + FundingBaseSymbol string + FundingQuoteSymbol string + FundingRateSymbol string + IndexSymbol string + InitialMargin float32 + IsDeleverage bool + IsInverse bool + IsQuanto bool + LotSize float32 + MaintainMargin float32 + MakerFeeRate float32 + MakerFixFee float32 + MarkMethod string + MaxLeverage float32 + MaxOrderQty float32 + MaxPrice float32 + MaxRiskLimit float32 + MinRiskLimit float32 + Multiplier float32 + OpenInterest string + QuoteCurrency string + RiskStep int + RootSymbol string + Status string + Symbol string + TakerFeeRate float32 + TakerFixFee float32 + TickSize float32 + TurnoverOf24h float64 + Type string + VolumeOf24h float64 + type ContractsModels []*ContractsModel + type ContractsRiskLimitLevelModel []*RiskLimitLevelModel + type CreateOrderResultModel struct + OrderId string + type CreateSubApiKeyRes struct + ApiKey string + ApiSecret string + CreatedAt json.Number + IpWhitelist string + Passphrase string + Permission string + Remark string + SubName string + type DeleteSubApiKeyRes struct + ApiKey string + SubName string + type DepositAddressModel struct + Address string + Memo string + type DepositAddressesModel []*DepositAddressModel + type DepositModel struct + Address string + Amount string + CreatedAt int64 + Currency string + Fee string + IsInner bool + Status string + WalletTxId string + type DepositsModel []*DepositModel + type FillModel struct + CloseFeePay string + CreatedAt int64 + Fee string + FeeCurrency string + FeeRate string + FixFee string + Liquidity string + OpenFeePay string + OrderId string + OrderType string + Price string + SettleCurrency string + Side string + Size float64 + Stop string + Symbol string + TradeId string + TradeTime int64 + TradeType string + Value string + type FillsModel []*FillModel + type FundingListModel struct + DataList []*FundingModel + HasMore bool + type FundingModel struct + Funding float64 + FundingRate float64 + Id int64 + MarkPrice float64 + PositionCost float64 + PositionQty float32 + SettleCurrency string + Symbol string + TimePoint int64 + type FundingRateModel struct + Granularity int64 + PredictedValue float32 + Symbol string + TimePoint int64 + Value float32 + type IndexModel struct + DecomposionList [][]interface{} + Granularity int + Symbol string + TimePoint int64 + Value float32 + type IndexQueryModel struct + DataList []*IndexModel + HasMore bool + type InterestModel struct + Granularity int + Symbol string + TimePoint int64 + Value float32 + type InterestsModel struct + DataList []*InterestModel + HasMore bool + type KLineModel []interface + type KLinesModel []*KLineModel + type KcSigner struct + func NewKcSigner(key, secret, passPhrase string) *KcSigner + func NewKcSignerV2(key, secret, passPhrase string) *KcSigner + func (ks *KcSigner) Headers(plain string) map[string]string + func (ks *KcSigner) Sign(plain []byte) []byte + type Level2MessageQueryListModel []*Level2MessageQueryModel + type Level2MessageQueryModel struct + Change string + Sequence int + Symbol string + type Level2SnapshotModel struct + Asks [][]float32 + Bids [][]float32 + Sequence int + Symbol string + type Level3MessageQueryListModel []*Level3MessageQueryModel + type Level3MessageQueryModel struct + ClientOid string + OrderId string + OrderTime int64 + Price string + Sequence int + Side string + Size int + Symbol string + Ts int64 + Type string + type Level3SnapshotModel struct + Asks [][]interface{} + Bids [][]interface{} + Sequence int + Symbol string + type Level3SnapshotV2Model struct + Asks [][]interface{} + Bids [][]interface{} + Sequence int + Symbol string + Ts int64 + type MarkPriceModel struct + Granularity float32 + IndexPrice float32 + Symbol string + TimePoint int64 + Value float32 + type ModifySubApiKeyRes struct + ApiKey string + IpWhitelist string + Permission string + SubName string + type OpenOrderStatisticsModel struct + OpenOrderBuyCost string + OpenOrderBuySize int32 + OpenOrderSellCost string + OpenOrderSellSize int32 + SettleCurrency string + type OrderModel struct + CancelExist bool + ClientOid string + CloseOnly bool + CloseOrder bool + CreatedAt int64 + DealSize int64 + DealValue string + ForceHold bool + Hidden bool + IceBerg bool + Id string + IsActive bool + Leverage string + PostOnly bool + Price string + Remark string + SettleCurrency string + Side string + Size int64 + Status string + Stop string + StopPrice string + StopPriceType string + StopTriggered bool + Stp string + Symbol string + TimeInForce string + Type string + UpdatedAt int64 + Value string + VisibleSize string + type OrdersModel []*OrderModel + type PaginationModel struct + CurrentPage int64 + PageSize int64 + RawItems json.RawMessage + TotalNum int64 + TotalPage int64 + func (p *PaginationModel) ReadItems(v interface{}) error + type PaginationParam struct + CurrentPage int64 + PageSize int64 + func (p *PaginationParam) ReadParam(params map[string]string) + type PositionModel struct + AutoDeposit bool + AvgEntryPrice string + BankruptPrice string + CrossMode bool + CurrentComm string + CurrentCost string + CurrentQty string + CurrentTimestamp string + DelevPercentage string + Id string + IsOpen bool + LiquidationPrice string + MaintMargin string + MaintMarginReq string + MaintainMargin string + MarkPrice string + MarkValue string + OpeningTimestamp string + PosComm string + PosCost string + PosCross string + PosInit string + PosLoss string + PosMaint string + PosMargin string + RealLeverage string + RealisedCost string + RealisedGrossCost string + RealisedGrossPnl string + RealisedPnl string + RiskLimit string + RiskLimitLevel string + SettleCurrency string + Symbol string + UnrealisedCost string + UnrealisedPnl string + UnrealisedPnlPcnt string + UnrealisedRoePcnt string + UserId string + type PositionsModel []*PositionModel + type PremiumModel struct + Granularity string + Symbol string + TimePoint string + Value string + type PremiumsModel struct + DataList []*PremiumModel + HasMore bool + type Request struct + BaseURI string + Body []byte + Header http.Header + Method string + Path string + Query url.Values + SkipVerifyTls bool + Timeout time.Duration + func NewRequest(method, path string, params map[string]string) *Request + func (r *Request) FullURL() string + func (r *Request) HttpRequest() (*http.Request, error) + func (r *Request) RequestURI() string + type Requester interface + Request func(request *Request, timeout time.Duration) (*Response, error) + type Response struct + func (r *Response) ReadBody() ([]byte, error) + func (r *Response) ReadJsonBody(v interface{}) error + type RiskLimitLevelModel struct + InitialMargin float64 + Level int64 + MaintainMargin float64 + MaxLeverage int64 + MaxRiskLimit int64 + MinRiskLimit int64 + Symbol string + type ServiceStatusModel struct + Msg string + Status string + type Sha256Signer struct + func (ss *Sha256Signer) Sign(plain []byte) []byte + type Signer interface + Sign func(plain []byte) []byte + type SubAccountBalanceModel struct + Accounts []struct{ ... } + Summary struct{ ... } + type SubApiKeyModel struct + ApiKey string + CreatedAt json.Number + IpWhitelist string + Permission string + Remark string + SubName string + type SubApiKeysModel []*SubApiKeyModel + type TickerLevel1Model struct + BestAskPrice string + BestAskSize int + BestBidPrice string + BestBidSize int + Price string + Sequence int + Side string + Size int + Symbol string + TradeId string + Ts int64 + type TickerV2Model struct + BestAskPrice string + BestAskSize int + BestBidPrice string + BestBidSize int + Symbol string + Ts int64 + type TradeHistoryModel struct + MakerOrderId string + Price string + Sequence int + Side string + Size int + TakerOrderId string + Time int64 + TradeId string + type TradesHistoryModel []*TradeHistoryModel + type TransactionHistoryListModel []*TransactionHistoryModel + type TransactionHistoryModel struct + AccountEquity string + Amount string + Currency string + Fee string + Offset string + Remarks string + Status string + Time string + Type string + type TransferModel struct + Amount string + ApplyId string + CreatedAt int64 + Currency string + Offset int64 + Reason string + Status string + type TransferOutModel struct + ApplyId string + type TransferOutV2Model struct + ApplyId string + type TransferOutV3Res struct + Amount string + ApplyId string + BizNo string + CreatedAt json.Number + Currency string + Fee string + PayAccountType string + PayTag string + Reason string + RecAccountType string + RecRemark string + RecSystem string + RecTag string + Remark string + Sn big.Int + Status string + UpdatedAt json.Number + type TransfersModel []*TransferModel + type WebSocketClient struct + func (wc *WebSocketClient) Connect() (<-chan *WebSocketDownstreamMessage, <-chan error, error) + func (wc *WebSocketClient) Stop() + func (wc *WebSocketClient) Subscribe(channels ...*WebSocketSubscribeMessage) error + func (wc *WebSocketClient) Unsubscribe(channels ...*WebSocketUnsubscribeMessage) error + type WebSocketDownstreamMessage struct + RawData json.RawMessage + Subject string + Topic string + func (m *WebSocketDownstreamMessage) ReadData(v interface{}) error + type WebSocketMessage struct + Id string + Type string + func NewPingMessage() *WebSocketMessage + type WebSocketServerModel struct + Encrypt bool + Endpoint string + PingInterval int64 + PingTimeout int64 + Protocol string + type WebSocketServersModel []*WebSocketServerModel + func (s WebSocketServersModel) RandomServer() (*WebSocketServerModel, error) + type WebSocketSubscribeMessage struct + PrivateChannel bool + Response bool + Topic string + func NewSubscribeMessage(topic string, privateChannel bool) *WebSocketSubscribeMessage + type WebSocketTokenModel struct + AcceptUserMessage bool + Servers WebSocketServersModel + Token string + type WebSocketUnsubscribeMessage WebSocketSubscribeMessage + func NewUnsubscribeMessage(topic string, privateChannel bool) *WebSocketUnsubscribeMessage + type WithdrawalModel struct + Address string + Amount string + CreatedAt int64 + Currency string + Fee string + IsInner bool + Memo string + Reason string + Remark string + Status string + WalletTxId string + WithdrawalId string + type WithdrawalQuotasModel struct + AvailableAmount float32 + Currency string + InnerWithdrawMinFee float32 + IsWithdrawEnabled bool + LimitAmount float32 + Precision uint8 + RemainAmount float32 + UsedAmount float32 + WithdrawMinFee float32 + WithdrawMinSize float32 + type WithdrawalsModel []*WithdrawalModel