mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-18 23:16:49 +00:00
OKEX/OKCoin fix unauthenticated endpoints
This commit is contained in:
@@ -81,7 +81,8 @@ func (o *OKEX) SetDefaults() {
|
||||
exchange.WebsocketOrderbookSupported
|
||||
}
|
||||
|
||||
// GetFuturesPostions Get the information of all holding positions in futures trading.Due to high energy consumption, you are advised to capture data with the "Futures Account of a Currency" API instead.
|
||||
// GetFuturesPostions Get the information of all holding positions in futures trading.
|
||||
// Due to high energy consumption, you are advised to capture data with the "Futures Account of a Currency" API instead.
|
||||
func (o *OKEX) GetFuturesPostions() (resp okgroup.GetFuturesPositionsResponse, _ error) {
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupFuturesSubsection, okGroupFuturePosition, nil, &resp, true)
|
||||
}
|
||||
@@ -346,60 +347,60 @@ func (o *OKEX) GetSwapTransactionDetails(request okgroup.GetSwapTransactionDetai
|
||||
|
||||
// GetSwapContractInformation Get market data.
|
||||
func (o *OKEX) GetSwapContractInformation() (resp []okgroup.GetSwapContractInformationResponse, _ error) {
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupSwapSubsection, okgroup.OKGroupInstruments, nil, &resp, true)
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupSwapSubsection, okgroup.OKGroupInstruments, nil, &resp, false)
|
||||
}
|
||||
|
||||
// GetSwapOrderBook Get the charts of the trading pairs.
|
||||
func (o *OKEX) GetSwapOrderBook(request okgroup.GetSwapOrderBookRequest) (resp okgroup.GetSwapOrderBookResponse, _ error) {
|
||||
requestURL := fmt.Sprintf("%v/%v/%v%v", okgroup.OKGroupInstruments, request.InstrumentID, okGroupDepth, okgroup.FormatParameters(request))
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupSwapSubsection, requestURL, nil, &resp, true)
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupSwapSubsection, requestURL, nil, &resp, false)
|
||||
}
|
||||
|
||||
// GetAllSwapTokensInformation Get the last traded price, best bid/ask price, 24 hour trading volume and more info of all contracts.
|
||||
func (o *OKEX) GetAllSwapTokensInformation() (resp []okgroup.GetAllSwapTokensInformationResponse, _ error) {
|
||||
requestURL := fmt.Sprintf("%v/%v", okgroup.OKGroupInstruments, okgroup.OKGroupTicker)
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupSwapSubsection, requestURL, nil, &resp, true)
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupSwapSubsection, requestURL, nil, &resp, false)
|
||||
}
|
||||
|
||||
// GetSwapTokensInformationForCurrency Get the last traded price, best bid/ask price, 24 hour trading volume and more info of all contracts.
|
||||
func (o *OKEX) GetSwapTokensInformationForCurrency(instrumentID string) (resp okgroup.GetAllSwapTokensInformationResponse, _ error) {
|
||||
requestURL := fmt.Sprintf("%v/%v/%v", okgroup.OKGroupInstruments, instrumentID, okgroup.OKGroupTicker)
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupSwapSubsection, requestURL, nil, &resp, true)
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupSwapSubsection, requestURL, nil, &resp, false)
|
||||
}
|
||||
|
||||
// GetSwapFilledOrdersData Get details of the recent filled orders
|
||||
func (o *OKEX) GetSwapFilledOrdersData(request *okgroup.GetSwapFilledOrdersDataRequest) (resp []okgroup.GetSwapFilledOrdersDataResponse, _ error) {
|
||||
requestURL := fmt.Sprintf("%v/%v/%v%v", okgroup.OKGroupInstruments, request.InstrumentID, okgroup.OKGroupTrades, okgroup.FormatParameters(request))
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupSwapSubsection, requestURL, nil, &resp, true)
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupSwapSubsection, requestURL, nil, &resp, false)
|
||||
}
|
||||
|
||||
// GetSwapMarketData Get the charts of the trading pairs.
|
||||
func (o *OKEX) GetSwapMarketData(request okgroup.GetSwapMarketDataRequest) (resp []okgroup.GetSwapMarketDataResponse, _ error) {
|
||||
requestURL := fmt.Sprintf("%v/%v/%v%v", okgroup.OKGroupInstruments, request.InstrumentID, okgroup.OKGroupGetSpotMarketData, okgroup.FormatParameters(request))
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupSwapSubsection, requestURL, nil, &resp, true)
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupSwapSubsection, requestURL, nil, &resp, false)
|
||||
}
|
||||
|
||||
// GetSwapIndeces Get Indices of tokens.
|
||||
func (o *OKEX) GetSwapIndeces(instrumentID string) (resp okgroup.GetSwapIndecesResponse, _ error) {
|
||||
// GetSwapIndices Get Indices of tokens.
|
||||
func (o *OKEX) GetSwapIndices(instrumentID string) (resp okgroup.GetSwapIndecesResponse, _ error) {
|
||||
requestURL := fmt.Sprintf("%v/%v/%v", okgroup.OKGroupInstruments, instrumentID, okGroupIndices)
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupSwapSubsection, requestURL, nil, &resp, true)
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupSwapSubsection, requestURL, nil, &resp, false)
|
||||
}
|
||||
|
||||
// GetSwapExchangeRates Get the fiat exchange rates.
|
||||
func (o *OKEX) GetSwapExchangeRates() (resp okgroup.GetSwapExchangeRatesResponse, _ error) {
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupSwapSubsection, okGroupRate, nil, &resp, true)
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupSwapSubsection, okGroupRate, nil, &resp, false)
|
||||
}
|
||||
|
||||
// GetSwapOpenInterest Get the open interest of a contract.
|
||||
func (o *OKEX) GetSwapOpenInterest(instrumentID string) (resp okgroup.GetSwapExchangeRatesResponse, _ error) {
|
||||
requestURL := fmt.Sprintf("%v/%v/%v", okgroup.OKGroupInstruments, instrumentID, okGroupOpenInterest)
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupSwapSubsection, requestURL, nil, &resp, true)
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupSwapSubsection, requestURL, nil, &resp, false)
|
||||
}
|
||||
|
||||
// GetSwapCurrentPriceLimits Get the open interest of a contract.
|
||||
func (o *OKEX) GetSwapCurrentPriceLimits(instrumentID string) (resp okgroup.GetSwapCurrentPriceLimitsResponse, _ error) {
|
||||
requestURL := fmt.Sprintf("%v/%v/%v", okgroup.OKGroupInstruments, instrumentID, okgroup.OKGroupPriceLimit)
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupSwapSubsection, requestURL, nil, &resp, true)
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupSwapSubsection, requestURL, nil, &resp, false)
|
||||
}
|
||||
|
||||
// GetSwapForceLiquidatedOrders Get force liquidated orders.
|
||||
@@ -417,13 +418,13 @@ func (o *OKEX) GetSwapOnHoldAmountForOpenOrders(instrumentID string) (resp okgro
|
||||
// GetSwapNextSettlementTime Get the time of next settlement.
|
||||
func (o *OKEX) GetSwapNextSettlementTime(instrumentID string) (resp okgroup.GetSwapNextSettlementTimeResponse, _ error) {
|
||||
requestURL := fmt.Sprintf("%v/%v/%v", okgroup.OKGroupInstruments, instrumentID, okGroupFundingTime)
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupSwapSubsection, requestURL, nil, &resp, true)
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupSwapSubsection, requestURL, nil, &resp, false)
|
||||
}
|
||||
|
||||
// GetSwapMarkPrice Get the time of next settlement.
|
||||
func (o *OKEX) GetSwapMarkPrice(instrumentID string) (resp okgroup.GetSwapMarkPriceResponse, _ error) {
|
||||
requestURL := fmt.Sprintf("%v/%v/%v", okgroup.OKGroupInstruments, instrumentID, okgroup.OKGroupMarkPrice)
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupSwapSubsection, requestURL, nil, &resp, true)
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupSwapSubsection, requestURL, nil, &resp, false)
|
||||
}
|
||||
|
||||
// GetSwapFundingRateHistory Get Funding Rate History.
|
||||
|
||||
@@ -1389,7 +1389,7 @@ func TestGetSwapMarketData(t *testing.T) {
|
||||
func TestGetSwapIndeces(t *testing.T) {
|
||||
TestSetDefaults(t)
|
||||
t.Parallel()
|
||||
_, err := o.GetSwapIndeces(fmt.Sprintf("%v-%v-SWAP", symbol.BTC, symbol.USD))
|
||||
_, err := o.GetSwapIndices(fmt.Sprintf("%v-%v-SWAP", symbol.BTC, symbol.USD))
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ func (o *OKGroup) Setup(exch config.ExchangeConfig) {
|
||||
|
||||
// GetAccountCurrencies returns a list of tradable spot instruments and their properties
|
||||
func (o *OKGroup) GetAccountCurrencies() (resp []GetAccountCurrenciesResponse, _ error) {
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupAccountSubsection, okGroupGetAccountCurrencies, nil, &resp, true)
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupAccountSubsection, okGroupGetAccountCurrencies, nil, &resp, false)
|
||||
}
|
||||
|
||||
// GetAccountWalletInformation returns a list of wallets and their properties
|
||||
@@ -349,45 +349,45 @@ func (o *OKGroup) GetSpotOrder(request GetSpotOrderRequest) (resp GetSpotOrderRe
|
||||
// All paginated requests return the latest information (newest) as the first page sorted by newest (in chronological time) first.
|
||||
func (o *OKGroup) GetSpotTransactionDetails(request GetSpotTransactionDetailsRequest) (resp []GetSpotTransactionDetailsResponse, _ error) {
|
||||
requestURL := fmt.Sprintf("%v%v", OKGroupGetSpotTransactionDetails, FormatParameters(request))
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupTokenSubsection, requestURL, nil, &resp, true)
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupTokenSubsection, requestURL, nil, &resp, false)
|
||||
}
|
||||
|
||||
// GetSpotTokenPairDetails Get market data. This endpoint provides the snapshots of market data and can be used without verifications.
|
||||
// List trading pairs and get the trading limit, price, and more information of different trading pairs.
|
||||
func (o *OKGroup) GetSpotTokenPairDetails() (resp []GetSpotTokenPairDetailsResponse, _ error) {
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupTokenSubsection, OKGroupInstruments, nil, &resp, true)
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupTokenSubsection, OKGroupInstruments, nil, &resp, false)
|
||||
}
|
||||
|
||||
// GetSpotOrderBook Getting the order book of a trading pair. Pagination is not supported here.
|
||||
// The whole book will be returned for one request. WebSocket is recommended here.
|
||||
func (o *OKGroup) GetSpotOrderBook(request GetSpotOrderBookRequest) (resp GetSpotOrderBookResponse, _ error) {
|
||||
requestURL := fmt.Sprintf("%v/%v/%v%v", OKGroupInstruments, request.InstrumentID, OKGroupGetSpotOrderBook, FormatParameters(request))
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupTokenSubsection, requestURL, nil, &resp, true)
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupTokenSubsection, requestURL, nil, &resp, false)
|
||||
}
|
||||
|
||||
// GetSpotAllTokenPairsInformation Get the last traded price, best bid/ask price, 24 hour trading volume and more info of all trading pairs.
|
||||
func (o *OKGroup) GetSpotAllTokenPairsInformation() (resp []GetSpotTokenPairsInformationResponse, _ error) {
|
||||
requestURL := fmt.Sprintf("%v/%v", OKGroupInstruments, OKGroupTicker)
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupTokenSubsection, requestURL, nil, &resp, true)
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupTokenSubsection, requestURL, nil, &resp, false)
|
||||
}
|
||||
|
||||
// GetSpotAllTokenPairsInformationForCurrency Get the last traded price, best bid/ask price, 24 hour trading volume and more info of a currency
|
||||
func (o *OKGroup) GetSpotAllTokenPairsInformationForCurrency(currency string) (resp GetSpotTokenPairsInformationResponse, _ error) {
|
||||
requestURL := fmt.Sprintf("%v/%v/%v", OKGroupInstruments, currency, OKGroupTicker)
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupTokenSubsection, requestURL, nil, &resp, true)
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupTokenSubsection, requestURL, nil, &resp, false)
|
||||
}
|
||||
|
||||
// GetSpotFilledOrdersInformation Get the recent 60 transactions of all trading pairs.
|
||||
// Cursor pagination is used. All paginated requests return the latest information (newest) as the first page sorted by newest (in chronological time) first.
|
||||
func (o *OKGroup) GetSpotFilledOrdersInformation(request GetSpotFilledOrdersInformationRequest) (resp []GetSpotFilledOrdersInformationResponse, _ error) {
|
||||
requestURL := fmt.Sprintf("%v/%v/%v%v", OKGroupInstruments, request.InstrumentID, OKGroupTrades, FormatParameters(request))
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupTokenSubsection, requestURL, nil, &resp, true)
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupTokenSubsection, requestURL, nil, &resp, false)
|
||||
}
|
||||
|
||||
// GetSpotMarketData Get the charts of the trading pairs. Charts are returned in grouped buckets based on requested granularity.
|
||||
func (o *OKGroup) GetSpotMarketData(request GetSpotMarketDataRequest) (resp GetSpotMarketDataResponse, _ error) {
|
||||
requestURL := fmt.Sprintf("%v/%v/%v%v", OKGroupInstruments, request.InstrumentID, OKGroupGetSpotMarketData, FormatParameters(request))
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupTokenSubsection, requestURL, nil, &resp, true)
|
||||
return resp, o.SendHTTPRequest(http.MethodGet, okGroupTokenSubsection, requestURL, nil, &resp, false)
|
||||
}
|
||||
|
||||
// GetMarginTradingAccounts List all assets under token margin trading account, including information such as balance, amount on hold and more.
|
||||
|
||||
@@ -1369,7 +1369,7 @@ type WebsocketEstimatedPriceResponse struct {
|
||||
SettlementPrice float64 `json:"settlement_price,string,omitempty"`
|
||||
}
|
||||
|
||||
// WebsocketMarkPriceResponse contains formatted data for mark prices
|
||||
// WebsocketPriceRangeResponse contains formatted data for mark prices
|
||||
type WebsocketPriceRangeResponse struct {
|
||||
Highest float64 `json:"highest,omitempty"`
|
||||
Lowest float64 `json:"lowest,omitempty"`
|
||||
@@ -1382,12 +1382,12 @@ type WebsocketOrderBooksData struct {
|
||||
Checksum int32 `json:"checksum,omitempty"`
|
||||
}
|
||||
|
||||
// WebsocketUserPositionResponse contains formatted data for user position data
|
||||
// WebsocketUserSwapPositionResponse contains formatted data for user position data
|
||||
type WebsocketUserSwapPositionResponse struct {
|
||||
Holding []WebsocketUserSwapPositionHoldingData `json:"holding,omitempty"`
|
||||
}
|
||||
|
||||
// WebsocketUserPositionResponse contains formatted data for user position holding data
|
||||
// WebsocketUserSwapPositionHoldingData contains formatted data for user position holding data
|
||||
type WebsocketUserSwapPositionHoldingData struct {
|
||||
AvailablePosition float64 `json:"avail_position,string,omitempty"`
|
||||
AverageCost float64 `json:"avg_cost,string,omitempty"`
|
||||
@@ -1401,7 +1401,7 @@ type WebsocketUserSwapPositionHoldingData struct {
|
||||
Timestamp time.Time `json:"timestamp,omitempty"`
|
||||
}
|
||||
|
||||
// WebsocketUserAccountResponse contains formatted data for user account data
|
||||
// WebsocketUserSwapFutureAccountResponse contains formatted data for user account data
|
||||
type WebsocketUserSwapFutureAccountResponse struct {
|
||||
Equity float64 `json:"equity,string,omitempty"`
|
||||
FixedBalance float64 `json:"fixed_balance,string,omitempty"`
|
||||
@@ -1441,6 +1441,7 @@ type WebsocketSpotMarginOrderResponse struct {
|
||||
// WebsocketUserFutureFixedMarginAccountResponse contains formatted data for user account data
|
||||
type WebsocketUserFutureFixedMarginAccountResponse map[string]WebsocketUserFutureFixedMarginAccountData
|
||||
|
||||
// WebsocketUserFutureFixedMarginAccountData contains the user fixed margin account data
|
||||
type WebsocketUserFutureFixedMarginAccountData struct {
|
||||
Contracts []WebsocketUserSwapFutureAccountResponse `json:"contracts"`
|
||||
Equity string `json:"equity"`
|
||||
@@ -1448,7 +1449,7 @@ type WebsocketUserFutureFixedMarginAccountData struct {
|
||||
TotalAvailBalance string `json:"total_avail_balance"`
|
||||
}
|
||||
|
||||
// WebsocketUserOrdersResponse contains formatted data for user order data
|
||||
// WebsocketUserSwapOrdersResponse contains formatted data for user order data
|
||||
type WebsocketUserSwapOrdersResponse struct {
|
||||
FilledQuantity float64 `json:"filled_qty,string,omitempty"`
|
||||
ClientOID string `json:"client_oid,omitempty"`
|
||||
|
||||
@@ -450,7 +450,7 @@ func (o *OKGroup) WsHandleDataResponse(response *WebsocketDataResponse) {
|
||||
}
|
||||
}
|
||||
|
||||
// resubscribeToChannel will attempt to unsubscribe and resubscribe to a channel
|
||||
// ResubscribeToChannel will attempt to unsubscribe and resubscribe to a channel
|
||||
func (o *OKGroup) ResubscribeToChannel(channel string) {
|
||||
if okGroupWsResubscribeFailureLimit > 0 {
|
||||
var successfulUnsubscribe bool
|
||||
|
||||
@@ -72,7 +72,6 @@ func (o *OKGroup) UpdateTicker(p pair.CurrencyPair, assetType string) (tickerDat
|
||||
}
|
||||
|
||||
ticker.ProcessTicker(o.Name, p, tickerData, assetType)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user