Kucoin
CryptoExchangeAPIs.Kucoin.KucoinClient
— TypeKucoinClient <: AbstractAPIsClient
Client info.
Required fields
base_url::String
: Base URL for the client.
Optional fields
public_key::String
: Public key for authentication.secret_key::String
: Secret key for authentication.interface::String
: Interface for the client.proxy::String
: Proxy information for the client.account_name::String
: Account name associated with the client.description::String
: Description of the client.
CryptoExchangeAPIs.Kucoin.KucoinAPIError
— TypeKucoinAPIError{T} <: AbstractAPIsError
Exception thrown when an API method fails with code T
.
Required fields
code::Int64
: Error code.msg::String
: Error message.
CryptoExchangeAPIs.Kucoin.Data
— TypeData{D} <: AbstractAPIsData
Required fields
code::Int64
: Result code.data::D
: Result data.
CryptoExchangeAPIs.Kucoin.Page
— TypePage{D} <: AbstractAPIsData
Required fields
pageSize::Int64
: Number of results per request.totalNum::Int64
: Total number of results.currentPage::Int64
: Current request page.totalPage::Int64
: Total request page.items::Vector{D}
: Result data.
Spot
CryptoExchangeAPIs.Kucoin.Spot.public_client
— Constantpublic_client = KucoinClient(; base_url = "https://api.kucoin.com")
CryptoExchangeAPIs.Kucoin.Spot.Candle.candle
— Functioncandle(client::KucoinClient, query::CandleQuery)
candle(client::KucoinClient = Kucoin.Spot.public_client; kw...)
Request via this endpoint to get the kline of the specified symbol.
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
symbol | String | true | |
type | TimeInterval | true | m1 m3 m5 m15 m30 h1 h2 h4 h6 h8 h12 d1 w1 |
endAt | DateTime | false | |
startAt | DateTime | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Kucoin
result = Kucoin.Spot.candle(;
symbol = "BTC-USDT",
type = Kucoin.Spot.Candle.m1,
)
to_pretty_json(result.result)
Result:
{
"code":200000,
"data":[
{
"time":"2024-05-14T10:37:00",
"open":61665.9,
"close":61676.4,
"high":61676.4,
"low":61660.3,
"volume":0.61931855,
"turnover":38189.806617378
},
...
]
}
CryptoExchangeAPIs.Kucoin.Spot.Deposit.deposit
— Functiondeposit(client::KucoinClient, query::DepositQuery)
deposit(client::KucoinClient; kw...)
Request via this endpoint to get the V1 historical deposits list on KuCoin.
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
currency | String | false | |
endAt | DateTime | false | |
startAt | DateTime | false | |
status | Status | false | PROCESSING, SUCCESS, FAILURE |
passphrase | String | false | |
signature | String | false | |
timestamp | DateTime | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Kucoin
kucoin_client = KucoinClient(;
base_url = "https://api.kucoin.com",
public_key = ENV["KUCOIN_PUBLIC_KEY"],
secret_key = ENV["KUCOIN_SECRET_KEY"],
passphrase = ENV["KUCOIN_PASSPHRASE"],
)
result = Kucoin.Spot.deposit(
kucoin_client;
currency = "BTC",
)
to_pretty_json(result.result)
Result:
{
"pageSize":1,
"totalNum":9,
"currentPage":1,
"totalPage":9,
"items":[
{
"amount":0.03266638,
"createAt":"1970-01-18T16:35:36.998",
"currency":"BTC",
"isInner":false,
"status":"SUCCESS",
"walletTxId":"55c643bc2c68d6f17266383ac1be9e454038864b929ae7cee0bc408cc5c869e8"
}
]
}
CryptoExchangeAPIs.Kucoin.Spot.SymbolInfo.symbol_info
— Functionsymbol_info(client::KucoinClient, query::SymbolInfoQuery)
symbol_info(client::KucoinClient = Kucoin.Spot.public_client; kw...)
Request via this endpoint to get detail currency pairs for trading.
Parameter | Type | Required | Description |
---|---|---|---|
symbol | String | true |
Code samples:
using Serde
using CryptoExchangeAPIs.Kucoin
result = Kucoin.Spot.symbol_info(;
symbol = "BTC-USDT"
)
to_pretty_json(result.result)
Result:
{
"symbol":"BTC-USDT",
"baseCurrency":"BTC",
"quoteCurrency":"USDT",
"feeCurrency":"USDT",
"market":"USDS",
"baseMaxSize":1.0e10,
"baseIncrement":1.0e-8,
"quoteMinSize":0.1,
"quoteIncrement":1.0e-6,
"priceIncrement":0.1,
"priceLimitRate":0.1,
"minFunds":0.1,
"isMarginEnabled":true,
"enableTrading":true,
"baseMinSize":1.0e-5,
"name":"BTC-USDT",
"quoteMaxSize":9.9999999e7
}
CryptoExchangeAPIs.Kucoin.Spot.SymbolInfo.symbols_info
— Functionsymbols_info(client::KucoinClient, query::SymbolsInfoQuery)
symbols_info(client::KucoinClient = Kucoin.Spot.public_client; kw...)
Request via this endpoint to get detail currency pairs for trading.
Code samples:
using Serde
using CryptoExchangeAPIs.Kucoin
result = Kucoin.Spot.symbols_info()
to_pretty_json(result.result)
Result:
[
{
"symbol":"AVA-USDT",
"baseCurrency":"AVA",
"quoteCurrency":"USDT",
"feeCurrency":"USDT",
"market":"USDS",
"baseMaxSize":1.0e10,
"baseIncrement":0.01,
"quoteMinSize":0.1,
"quoteIncrement":0.0001,
"priceIncrement":0.0001,
"priceLimitRate":0.1,
"minFunds":0.1,
"isMarginEnabled":false,
"enableTrading":true,
"baseMinSize":0.1,
"name":"AVA-USDT",
"quoteMaxSize":9.9999999e7
},
...
]
CryptoExchangeAPIs.Kucoin.Spot.Ticker.ticker
— Functionticker(client::KucoinClient, query::TickerQuery)
ticker(client::KucoinClient = Kucoin.Spot.public_client; kw...)
Request via this endpoint to get the statistics of the specified ticker in the last 24 hours.
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
symbol | String | true |
Code samples:
using Serde
using CryptoExchangeAPIs.Kucoin
result = Kucoin.Spot.ticker(; symbol = "BTC")
to_pretty_json(result.result)
Result:
{
"code":200000,
"data":{
"symbol":"BTC",
"averagePrice":null,
"buy":null,
"changePrice":null,
"changeRate":null,
"high":null,
"last":null,
"low":null,
"makerCoefficient":null,
"makerFeeRate":null,
"sell":null,
"takerCoefficient":null,
"takerFeeRate":null,
"time":"2024-09-23T15:48:26.456999936",
"vol":null,
"volValue":null
}
}
CryptoExchangeAPIs.Kucoin.Spot.Ticker.ticker_all
— Functionticker_all(client::KucoinClient, query::TickerQuery)
ticker_all(client::KucoinClient = Kucoin.Spot.public_client; kw...)
Request market tickers for all the trading pairs in the market (including 24h volume).
Code samples:
using Serde
using CryptoExchangeAPIs.Kucoin
result = Kucoin.Spot.ticker_all()
to_pretty_json(result.result)
Result:
{
"code":200000,
"data":{
"time":"2024-09-23T15:54:48.020999936",
"ticker":[
{
"symbol":"HLG-USDT",
"averagePrice":0.0015635,
"buy":0.00156,
"changePrice":3.0e-5,
"changeRate":0.0194,
"high":0.00161,
"last":0.00157,
"low":0.00152,
"makerCoefficient":2.0,
"makerFeeRate":0.001,
"sell":0.00158,
"takerCoefficient":2.0,
"takerFeeRate":0.001,
"time":null,
"vol":1.6744577e6,
"volValue":2626.113078
},
...
]
}
}
Futures
CryptoExchangeAPIs.Kucoin.Futures.public_client
— Constantpublic_client = KucoinClient(; base_url = "https://api-futures.kucoin.com")
CryptoExchangeAPIs.Kucoin.Futures.Candle.candle
— Functioncandle(client::KucoinClient, query::CandleQuery)
candle(client::KucoinClient = Kucoin.Futures.public_client; kw...)
Request via this endpoint to get the kline of the specified symbol.
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
symbol | String | true | |
granularity | TimeInterval | true | m1 m5 m15 m30 h1 h2 h4 h8 h12 d1 w1 |
from | NanoDate | false | |
to | NanoDate | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Kucoin
result = Kucoin.Futures.candle(;
symbol = ".KXBT",
granularity = Kucoin.Futures.Candle.m1,
)
to_pretty_json(result.result)
Result:
{
"code":200000,
"data":[
{
"time":"2024-05-14T20:37:00",
"open":61593.03,
"close":61593.82,
"high":61593.02,
"low":61593.82,
"volume":0.0
},
...
]
}
CryptoExchangeAPIs.Kucoin.Futures.Contract.contract
— Functioncontract(client::KucoinClient, query::ContractQuery)
contract(client::KucoinClient = Kucoin.Futures.public_client; kw...)
Submit request to get the info of all open contracts.
Code samples:
using Serde
using CryptoExchangeAPIs.Kucoin
result = Kucoin.Futures.contract()
to_pretty_json(result.result)
Result:
{
"code":200000,
"data":[
{
"symbol":"XEMUSDTM",
"rootSymbol":"USDT",
"type":"FFWCSX",
"firstOpenDate":"2021-04-09T08:00:00",
"expireDate":null,
"settleDate":null,
"baseCurrency":"XEM",
"quoteCurrency":"USDT",
"settleCurrency":"USDT",
"maxOrderQty":1000000,
"maxPrice":1.0e6,
"lotSize":1,
"tickSize":1.0e-5,
"indexPriceTickSize":1.0e-5,
"multiplier":1.0,
"initialMargin":0.034,
"maintainMargin":0.017,
"maxRiskLimit":10000,
"minRiskLimit":10000,
"riskStep":5000,
"makerFeeRate":0.0002,
"takerFeeRate":0.0006,
"takerFixFee":0.0,
"makerFixFee":0.0,
"settlementFee":null,
"isDeleverage":true,
"isQuanto":false,
"isInverse":false,
"markMethod":"FairPrice",
"fairMethod":"FundingRate",
"fundingBaseSymbol":".XEMINT8H",
"fundingQuoteSymbol":".USDTINT8H",
"fundingRateSymbol":".XEMUSDTMFPI8H",
"indexSymbol":".KXEMUSDT",
"settlementSymbol":"",
"status":"Open",
"fundingFeeRate":7.2e-5,
"predictedFundingFeeRate":-1.5e-5,
"openInterest":"14240708",
"turnoverOf24h":39512.89870461,
"volumeOf24h":1.114053e6,
"markPrice":0.03541,
"indexPrice":0.03541,
"lastTradePrice":0.03535,
"nextFundingRateTime":12755619,
"maxLeverage":30,
"sourceExchanges":[
"binance",
"okex",
"kucoin",
"bitget",
"gateio"
],
"premiumsSymbol1M":".XEMUSDTMPI",
"premiumsSymbol8H":".XEMUSDTMPI8H",
"fundingBaseSymbol1M":".XEMINT",
"fundingQuoteSymbol1M":".USDTINT",
"lowPrice":0.03469,
"highPrice":0.03585,
"priceChgPct":-0.0106,
"priceChg":-0.00038
},
...
]
}
CryptoExchangeAPIs.Kucoin.Futures.PrivateFundingHistory.private_funding_history
— Functionprivate_funding_history(client::KucoinClient, query::PrivateFundingHistoryQuery)
private_funding_history(client::KucoinClient; kw...)
Submit request to get the funding history.
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
symbol | String | true | |
startAt | NanoDate | false | |
endAt | NanoDate | false | |
reverse | Bool | false | |
offset | Int64 | false | |
forward | Bool | false | |
maxCount | Int64 | false | |
passphrase | String | false | |
signature | String | false | |
timestamp | DateTime | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Kucoin
kucoin_client = KucoinClient(;
base_url = "https://api-futures.kucoin.com",
public_key = ENV["KUCOIN_PUBLIC_KEY"],
secret_key = ENV["KUCOIN_SECRET_KEY"],
passphrase = ENV["KUCOIN_PASSPHRASE"],
)
result = Kucoin.Futures.private_funding_history(
kucoin_client;
symbol = "XBTUSDM",
)
to_pretty_json(result.result)
Result:
{
"dataList":[
{
"id":36275152660006,
"symbol":"XBTUSDM",
"timePoint":"2019-05-15T11:00:00",
"fundingRate":13e-5,
"markPrice":8058.27,
"positionQty":10,
"positionCost":-0.001241,
"funding":-464e-6,
"settleCurrency":"XBT"
},
...
],
"hasMore":true
}
CryptoExchangeAPIs.Kucoin.Futures.PublicFundingHistory.public_funding_history
— Functionpublic_funding_history(client::KucoinClient, query::PublicFundingHistoryQuery)
public_funding_history(client::KucoinClient = Kucoin.Futures.public_client; kw...)
Query the funding rate at each settlement time point within a certain time range of the corresponding contract.
GET api/v1/contract/funding-rates
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
symbol | String | true | |
from | NanoDate | false | |
to | NanoDate | false |
Code samples:
using Serde
using NanoDates
using CryptoExchangeAPIs.Kucoin
result = Kucoin.Futures.public_funding_history(;
symbol = "IDUSDTM",
from = NanoDate("2023-11-18T12:31:40"),
to = NanoDate("2023-12-11T16:05:00"),
)
to_pretty_json(result.result)
Result:
{
"code":200000,
"data":[
{
"symbol":"IDUSDTM",
"timepoint":"2023-12-11T12:00:00",
"fundingRate":0.000226
},
...
]
}