Kucoin API

client module

class kucoin.client.Client(api_key=None, api_secret=None, passphrase=None, sandbox=False, requests_params=None)[source]

Bases: BaseClient

__init__(api_key=None, api_secret=None, passphrase=None, sandbox=False, requests_params=None)[source]

Kucoin API Client constructor

https://docs.kucoin.com/

Parameters:
  • api_key (string) – Api Token Id

  • api_secret (string) – Api Secret

  • passphrase (string) – Api Passphrase used to create API

  • sandbox (bool) – (optional) Use the sandbox endpoint or not (default False)

  • requests_params (dict.) – (optional) Dictionary of requests params to use for all calls

client = Client(api_key, api_secret, api_passphrase)
get_timestamp(**params)[source]

Get the server timestamp

https://www.kucoin.com/docs/rest/spot-trading/market-data/get-server-time

Returns:

response timestamp in ms

futures_get_timestamp(**params)[source]

Get the futures server timestamp

https://www.kucoin.com/docs/rest/futures-trading/market-data/get-server-time

Returns:

response timestamp in ms

get_status(**params)[source]

Get the service status

https://www.kucoin.com/docs/rest/spot-trading/market-data/get-service-status

currencies = client.get_status()
Returns:

API Response

futures_get_status(**params)[source]

Get the futures service status

https://www.kucoin.com/docs/rest/futures-trading/market-data/get-service-status

currencies = client.futures_get_status()
Returns:

API Response

get_announcements(page=None, limit=None, ann_type=None, lang=None, start=None, end=None, **params)[source]

Get a list of the latest news announcements

https://www.kucoin.com/docs/rest/spot-trading/market-data/get-announcements

Parameters:
  • page (int) – (optional) Current page

  • limit (int) – (optional) Number of results to return

  • ann_type (string) – (optional) Announcement type: latest-announcements, activities, new-listings, product-updates, vip, maintenance-updates, product-updates, delistings, others, api-campaigns (default latest-announcements)

  • lang (string) – (optional) Language (default is en_US): zh_HK - Chinese (Hong Kong), ja_JP - Japanese (Japan), ko_KR - Korean (Korea), en_US - English, pl_PL - Polish (Poland), es_ES - Spanish (Spain), fr_FR - French (France), ar_AE - Arabic (Egypt), it_IT - Italian (Italy), id_ID - Indonesian (Indonesia), nl_NL - Dutch (Netherlands), pt_PT - Portuguese (Brazil), vi_VN - Vietnamese (Vietnam), de_DE - German (Germany), tr_TR - Turkish (Turkey), ms_MY - Malay (Malaysia), ru_RU - Russian (Russia), th_TH - Thai (Thailand), hi_IN - Hindi (India), bn_BD - Bengali (Bangladesh), fil_PH - Filipino (Philippines), ur_PK - Urdu (Pakistan).

  • start (string) – (optional) Start time as unix timestamp

  • end (string) – (optional) End time as unix timestamp

accounts = client.get_announcements()
accounts = client.get_announcements(page=2, lang='ja_JP')
Returns:

API Response

{
    "code": "200000",
    "data": {
        "totalNum": 198,
        "items": [
            {
                "annId": 131185,
                "annTitle": "Announcement of KuCoin Futures System Upgrade",
                "annType": [
                    "latest-announcements",
                    "futures-announcements"
                ],
                "annDesc": "Announcement of KuCoin Futures System Upgrade",
                "cTime": 1730798882000,
                "language": "en_US",
                "annUrl": "https://www.kucoin.com/announcement/announcement-of-kucoin-futures-system-upgrade-2024-11-11?lang=en_US"
            }
        ],
        "currentPage": 2,
        "pageSize": 1,
        "totalPage": 198
    }
}
Raises:

KucoinResponseException, KucoinAPIException

get_currencies()[source]

List known currencies

https://www.kucoin.com/docs/rest/spot-trading/market-data/get-currency-list

currencies = client.get_currencies()
Returns:

API Response

{
    "code": "200000",
    "data": [
        {
            "currency": "BTC",
            "name": "BTC",
            "fullName": "Bitcoin",
            "precision": 8,
            "confirms": null,
            "contractAddress": null,
            "isMarginEnabled": true,
            "isDebitEnabled": true,
            "chains": [
                {
                    "chainName" : "BTC",
                    "withdrawalMinFee" : "0.001",
                    "withdrawalMinSize" : "0.0012",
                    "withdrawFeeRate" : "0",
                    "depositMinSize" : "0.0002",
                    "isWithdrawEnabled" : true,
                    "isDepositEnabled" : true,
                    "preConfirms" : 1,
                    "contractAddress" : "",
                    "chainId" : "btc",
                    "confirms" : 3
                },
                {
                    "chainName" : "KCC",
                    "withdrawalMinFee" : "0.00002",
                    "withdrawalMinSize" : "0.0008",
                    "withdrawFeeRate" : "0",
                    "depositMinSize" : null,
                    "isWithdrawEnabled" : true,
                    "isDepositEnabled" : true,
                    "preConfirms" : 20,
                    "contractAddress" : "0xfa93c12cd345c658bc4644d1d4e1b9615952258c",
                    "chainId" : "kcc",
                    "confirms" : 20
                },
                {
                    "chainName" : "BTC-Segwit",
                    "withdrawalMinFee" : "0.0005",
                    "withdrawalMinSize" : "0.0008",
                    "withdrawFeeRate" : "0",
                    "depositMinSize" : "0.0002",
                    "isWithdrawEnabled" : false,
                    "isDepositEnabled" : true,
                    "preConfirms" : 2,
                    "contractAddress" : "",
                    "chainId" : "bech32",
                    "confirms" : 2
                }
            ]
        }
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

get_currency(currency, chain=None, **params)[source]

Get single currency detail

https://www.kucoin.com/docs/rest/spot-trading/market-data/get-currency-detail

Parameters:
  • currency (string) – Currency code

  • chain (string) – (optional) Chain name. The available value for USDT are OMNI, ERC20, TRC20.

# call with no coins
currency = client.get_currency('BTC')
currency = client.get_currency('BTC', 'ERC20')
Returns:

API Response

{
    "data" : {
        "isMarginEnabled" : true,
        "chains" : [
            {
                "chainName" : "BTC",
                "withdrawalMinFee" : "0.001",
                "withdrawalMinSize" : "0.0012",
                "withdrawFeeRate" : "0",
                "depositMinSize" : "0.0002",
                "isWithdrawEnabled" : true,
                "isDepositEnabled" : true,
                "preConfirms" : 1,
                "contractAddress" : "",
                "chainId" : "btc",
                "confirms" : 3
            },
            {
                "chainName" : "KCC",
                "withdrawalMinFee" : "0.00002",
                "withdrawalMinSize" : "0.0008",
                "withdrawFeeRate" : "0",
                "depositMinSize" : null,
                "isWithdrawEnabled" : true,
                "isDepositEnabled" : true,
                "preConfirms" : 20,
                "contractAddress" : "0xfa93c12cd345c658bc4644d1d4e1b9615952258c",
                "chainId" : "kcc",
                "confirms" : 20
            },
            {
                "chainName" : "BTC-Segwit",
                "withdrawalMinFee" : "0.0005",
                "withdrawalMinSize" : "0.0008",
                "withdrawFeeRate" : "0",
                "depositMinSize" : "0.0002",
                "isWithdrawEnabled" : false,
                "isDepositEnabled" : true,
                "preConfirms" : 2,
                "contractAddress" : "",
                "chainId" : "bech32",
                "confirms" : 2
            }
        ],
        "contractAddress" : null,
        "isDebitEnabled" : true,
        "fullName" : "Bitcoin",
        "precision" : 8,
        "currency" : "BTC",
        "name" : "BTC",
        "confirms" : null
    },
    "code" : "200000"
}
Raises:

KucoinResponseException, KucoinAPIException

get_symbols(market=None, **params)[source]

Get a list of available currency pairs for trading.

https://www.kucoin.com/docs/rest/spot-trading/market-data/get-symbols-list

Parameters:

market (string) – (optional) Name of market e.g. BTC

symbols = client.get_symbols()
symbols = client.get_symbols('USDS')
Returns:

ApiResponse

[
    {
        "symbol": "XLM-USDT",
        "name": "XLM-USDT",
        "baseCurrency": "XLM",
        "quoteCurrency": "USDT",
        "feeCurrency": "USDT",
        "market": "USDS",
        "baseMinSize": "0.1",
        "quoteMinSize": "0.01",
        "baseMaxSize": "10000000000",
        "quoteMaxSize": "99999999",
        "baseIncrement": "0.0001",
        "quoteIncrement": "0.000001",
        "priceIncrement": "0.000001",
        "priceLimitRate": "0.1",
        "minFunds": "0.1",
        "isMarginEnabled": true,
        "enableTrading": true
    },
    {
        "symbol": "VET-USDT",
        "name": "VET-USDT",
        "baseCurrency": "VET",
        "quoteCurrency": "USDT",
        "feeCurrency": "USDT",
        "market": "USDS",
        "baseMinSize": "10",
        "quoteMinSize": "0.01",
        "baseMaxSize": "10000000000",
        "quoteMaxSize": "99999999",
        "baseIncrement": "0.0001",
        "quoteIncrement": "0.000001",
        "priceIncrement": "0.0000001",
        "priceLimitRate": "0.1",
        "minFunds": "0.1",
        "isMarginEnabled": true,
        "enableTrading": true
    }
]
Raises:

KucoinResponseException, KucoinAPIException

get_symbol(symbol=None, **params)[source]

Get a symbol details for trading.

https://www.kucoin.com/docs/rest/spot-trading/market-data/get-symbol-detail

Parameters:

symbol (string) – (optional) Name of symbol e.g. KCS-BTC

symbol = client.get_symbol('XLM-USDT')
Returns:

ApiResponse

{
    "data" : {
        "quoteMinSize" : "0.1",
        "quoteCurrency" : "USDT",
        "feeCurrency" : "USDT",
        "symbol" : "BTC-USDT",
        "market" : "USDS",
        "baseMaxSize" : "10000000000",
        "baseIncrement" : "0.00000001",
        "quoteIncrement" : "0.000001",
        "priceIncrement" : "0.1",
        "priceLimitRate" : "0.1",
        "minFunds" : "0.1",
        "isMarginEnabled" : true,
        "enableTrading" : true,
        "baseCurrency" : "BTC",
        "baseMinSize" : "0.00001",
        "name" : "BTC-USDT",
        "quoteMaxSize" : "99999999"
    },
    "code" : "200000"
}
Raises:

KucoinResponseException, KucoinAPIException

get_ticker(symbol, **params)[source]

Get symbol ticker

https://www.kucoin.com/docs/rest/spot-trading/market-data/get-ticker

Parameters:

symbol (string) – Name of symbol e.g. KCS-BTC

ticker = client.get_ticker('ETH-BTC')
Returns:

ApiResponse

{
    "sequence": "1550467636704",
    "price": "0.03715005",
    "size": "0.17",
    "bestAsk": "0.03715004",
    "bestAskSize": "1.788",
    "bestBid": "0.03710768",
    "bestBidSize": "3.803",
    "time": 1550653727731
}
Raises:

KucoinResponseException, KucoinAPIException

get_tickers()[source]

Get symbol tickers

https://www.kucoin.com/docs/rest/spot-trading/market-data/get-all-tickers

tickers = client.get_tickers()
Returns:

ApiResponse

{
    "time": 1602832092060,
    "ticker": [
        {
        "symbol": "BTC-USDT", // symbol
        "symbolName": "BTC-USDT", // Name of trading pairs, it would change after renaming
        "buy": "11328.9", // bestAsk
        "sell": "11329", // bestBid
        "bestBidSize": "0.1",
        "bestAskSize": "1",
        "changeRate": "-0.0055", // 24h change rate
        "changePrice": "-63.6", // 24h change price
        "high": "11610", // 24h highest price
        "low": "11200", // 24h lowest price
        "vol": "2282.70993217", // 24h volumethe aggregated trading volume in BTC
        "volValue": "25984946.157790431", // 24h total, the trading volume in quote currency of last 24 hours
        "last": "11328.9", // last price
        "averagePrice": "11360.66065903", // 24h average transaction price yesterday
        "takerFeeRate": "0.001", // Basic Taker Fee
        "makerFeeRate": "0.001", // Basic Maker Fee
        "takerCoefficient": "1", // Taker Fee Coefficient
        "makerCoefficient": "1" // Maker Fee Coefficient
        }
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

get_24hr_stats(symbol, **params)[source]

Get 24hr stats for a symbol. Volume is in base currency units. open, high, low are in quote currency units.

https://www.kucoin.com/docs/rest/spot-trading/market-data/get-24hr-stats

Parameters:

symbol (string) – Name of symbol e.g. KCS-BTC

stats = client.get_24hr_stats('ETH-BTC')
Returns:

ApiResponse

{
    "time": 1602832092060, // time
    "symbol": "BTC-USDT", // symbol
    "buy": "11328.9", // bestAsk
    "sell": "11329", // bestBid
    "changeRate": "-0.0055", // 24h change rate
    "changePrice": "-63.6", // 24h change price
    "high": "11610", // 24h highest price
    "low": "11200", // 24h lowest price
    "vol": "2282.70993217", // 24h volume the aggregated trading volume in BTC
    "volValue": "25984946.157790431", // 24h total, the trading volume in quote currency of last 24 hours
    "last": "11328.9", // last price
    "averagePrice": "11360.66065903", // 24h average transaction price yesterday
    "takerFeeRate": "0.001", // Basic Taker Fee
    "makerFeeRate": "0.001", // Basic Maker Fee
    "takerCoefficient": "1", // Taker Fee Coefficient
    "makerCoefficient": "1" // Maker Fee Coefficient
}
Raises:

KucoinResponseException, KucoinAPIException

get_markets()[source]

Get supported market list

https://www.kucoin.com/docs/rest/spot-trading/market-data/get-market-list

markets = client.get_markets()
Returns:

ApiResponse

{
    "data": [
        "USDS", //SC has been changed to USDS
        "BTC",
        "KCS",
        "ALTS", //ALTS market includes ETH, NEO, TRX
        "NFT-ETF",
        "FIAT",
        "DeFi",
        "NFT",
        "Metaverse",
        "Polkadot",
        "ETF"
    ],
    "code": "200000"
}
Raises:

KucoinResponseException, KucoinAPIException

get_order_book(symbol, depth_20=False, **params)[source]

Get a list of bids and asks aggregated by price for a symbol.

Returns up to 20 or 100 depth each side. Fastest Order book API

https://www.kucoin.com/docs/rest/spot-trading/market-data/get-part-order-book-aggregated-

Parameters:
  • symbol (string) – Name of symbol e.g. KCS-BTC

  • depth_20 (bool) – If to return only 20 depth

orders = client.get_order_book('KCS-BTC')
Returns:

ApiResponse

{
    "sequence": "3262786978",
    "time": 1550653727731,
    "bids": [
        ["6500.12", "0.45054140"],
        ["6500.11", "0.45054140"]
    ],
    "asks": [
        ["6500.16", "0.57753524"],
        ["6500.15", "0.57753524"]
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

get_full_order_book(symbol, **params)[source]

Get a list of all bids and asks aggregated by price for a symbol.

This call is generally used by professional traders because it uses more server resources and traffic, and Kucoin has strict access frequency control.

https://www.kucoin.com/docs/rest/spot-trading/market-data/get-full-order-book-aggregated-

Parameters:

symbol (string) – Name of symbol e.g. KCS-BTC

orders = client.get_order_book('KCS-BTC')
Returns:

ApiResponse

{
    "sequence": "3262786978",
    "bids": [
        ["6500.12", "0.45054140"],  # [price size]
        ["6500.11", "0.45054140"]
    ],
    "asks": [
        ["6500.16", "0.57753524"],
        ["6500.15", "0.57753524"]
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

get_trade_histories(symbol, **params)[source]

List the latest trades for a symbol

https://www.kucoin.com/docs/rest/spot-trading/market-data/get-trade-histories

Parameters:

symbol (string) – Name of symbol e.g. KCS-BTC

orders = client.get_trade_histories('KCS-BTC')
Returns:

ApiResponse

[
    {
        "sequence": "1545896668571",
        "price": "0.07",                # Filled price
        "size": "0.004",                # Filled amount
        "side": "buy",                  # Filled side. The filled side is set to the taker by default.
        "time": 1545904567062140823     # Transaction time
    },
    {
        "sequence": "1545896668578",
        "price": "0.054",
        "size": "0.066",
        "side": "buy",
        "time": 1545904581619888405
    }
]
Raises:

KucoinResponseException, KucoinAPIException

get_kline_data(symbol, kline_type='5min', start=None, end=None, **params)[source]

Get kline data

https://www.kucoin.com/docs/rest/spot-trading/market-data/get-klines

For each query, the system would return at most 1500 pieces of data. To obtain more data, please page the data by time.

Parameters:
  • symbol (string) – Name of symbol e.g. KCS-BTC

  • kline_type (string) – type of symbol, type of candlestick patterns: 1min, 3min, 5min, 15min, 30min, 1hour, 2hour, 4hour, 6hour, 8hour, 12hour, 1day, 1week

  • start (int) – Start time as unix timestamp (optional) default start of day in UTC

  • end (int) – End time as unix timestamp (optional) default now in UTC

klines = client.get_kline_data('KCS-BTC', '5min', 1507479171, 1510278278)
Returns:

ApiResponse

[
    [
        "1545904980",             //Start time of the candle cycle
        "0.058",                  //opening price
        "0.049",                  //closing price
        "0.058",                  //highest price
        "0.049",                  //lowest price
        "0.018",                  //Transaction amount
        "0.000945"                //Transaction volume
    ],
    [
        "1545904920",
        "0.058",
        "0.072",
        "0.072",
        "0.058",
        "0.103",
        "0.006986"
    ]
]
Raises:

KucoinResponseException, KucoinAPIException

get_fiat_prices(base=None, currencies=None, **params)[source]

Get fiat price for currency

https://www.kucoin.com/docs/rest/spot-trading/market-data/get-fiat-price

Parameters:
  • base (string) – (optional) Fiat,eg.USD,EUR, default is USD.

  • currencies (string) – (optional) Cryptocurrencies.For multiple cyrptocurrencies, please separate them with comma one by one. default is all

prices = client.get_fiat_prices()
Returns:

ApiResponse

{
    "BTC": "3911.28000000",
    "ETH": "144.55492453",
    "LTC": "48.45888179",
    "KCS": "0.45546856"
}
Raises:

KucoinResponseException, KucoinAPIException

futures_get_symbols(**params)[source]

Get a list of available currency pairs for trading.

https://www.kucoin.com/docs/rest/futures-trading/market-data/get-symbols-list

symbols = client.futures_get_symbols()
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "symbol": "XBTUSDTM",
        "rootSymbol": "USDT",
        "type": "FFWCSX",
        "firstOpenDate": 1585555200000,
        "expireDate": null,
        "settleDate": null,
        "baseCurrency": "XBT",
        "quoteCurrency": "USDT",
        "settleCurrency": "USDT",
        "maxOrderQty": 1000000,
        "maxPrice": 1000000.0,
        "lotSize": 1,
        "tickSize": 0.1,
        "indexPriceTickSize": 0.01,
        "multiplier": 0.001,
        "initialMargin": 0.008,
        "maintainMargin": 0.004,
        "maxRiskLimit": 100000,
        "minRiskLimit": 100000,
        "riskStep": 50000,
        "makerFeeRate": 2.0E-4,
        "takerFeeRate": 6.0E-4,
        "takerFixFee": 0.0,
        "makerFixFee": 0.0,
        "settlementFee": null,
        "isDeleverage": true,
        "isQuanto": true,
        "isInverse": false,
        "markMethod": "FairPrice",
        "fairMethod": "FundingRate",
        "fundingBaseSymbol": ".XBTINT8H",
        "fundingQuoteSymbol": ".USDTINT8H",
        "fundingRateSymbol": ".XBTUSDTMFPI8H",
        "indexSymbol": ".KXBTUSDT",
        "settlementSymbol": "",
        "status": "Open",
        "fundingFeeRate": 6.41E-4,
        "predictedFundingFeeRate": 5.5E-5,
        "fundingRateGranularity": 28800000,
        "openInterest": "6273644",
        "turnoverOf24h": 1.9110000807101517E9,
        "volumeOf24h": 21807.101,
        "markPrice": 87351.75,
        "indexPrice": 87357.57,
        "lastTradePrice": 87319.4,
        "nextFundingRateTime": 1816952,
        "maxLeverage": 125,
        "sourceExchanges": [
            "okex",
            "binance",
            "kucoin",
            "bybit",
            "bitmart",
            "gateio"
        ],
        "premiumsSymbol1M": ".XBTUSDTMPI",
        "premiumsSymbol8H": ".XBTUSDTMPI8H",
        "fundingBaseSymbol1M": ".XBTINT",
        "fundingQuoteSymbol1M": ".USDTINT",
        "lowPrice": 85201.8,
        "highPrice": 90000.0,
        "priceChgPct": -0.0033,
        "priceChg": -291.0,
        "k": 490.0,
        "m": 300.0,
        "f": 1.3,
        "mmrLimit": 0.3,
        "mmrLevConstant": 125.0,
        "supportCross": true,
        "buyLimit": 91717.92,
        "sellLimit": 82982.88
    }
}
Raises:

KucoinResponseException, KucoinAPIException

futures_get_symbol(symbol, **params)[source]

Get a symbol details for trading.

https://www.kucoin.com/docs/rest/futures-trading/market-data/get-symbol-detail

Parameters:

symbol (string) – Name of symbol e.g. XBTUSDTM

symbol = client.futures_get_symbol('XBTUSDTM')
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "symbol": "XBTUSDTM",
        "rootSymbol": "USDT",
        "type": "FFWCSX",
        "firstOpenDate": 1585555200000,
        "expireDate": null,
        "settleDate": null,
        "baseCurrency": "XBT",
        "quoteCurrency": "USDT",
        "settleCurrency": "USDT",
        "maxOrderQty": 1000000,
        "maxPrice": 1000000.0,
        "lotSize": 1,
        "tickSize": 0.1,
        "indexPriceTickSize": 0.01,
        "multiplier": 0.001,
        "initialMargin": 0.008,
        "maintainMargin": 0.004,
        "maxRiskLimit": 100000,
        "minRiskLimit": 100000,
        "riskStep": 50000,
        "makerFeeRate": 2.0E-4,
        "takerFeeRate": 6.0E-4,
        "takerFixFee": 0.0,
        "makerFixFee": 0.0,
        "settlementFee": null,
        "isDeleverage": true,
        "isQuanto": true,
        "isInverse": false,
        "markMethod": "FairPrice",
        "fairMethod": "FundingRate",
        "fundingBaseSymbol": ".XBTINT8H",
        "fundingQuoteSymbol": ".USDTINT8H",
        "fundingRateSymbol": ".XBTUSDTMFPI8H",
        "indexSymbol": ".KXBTUSDT",
        "settlementSymbol": "",
        "status": "Open",
        "fundingFeeRate": 6.41E-4,
        "predictedFundingFeeRate": 5.5E-5,
        "fundingRateGranularity": 28800000,
        "openInterest": "6273644",
        "turnoverOf24h": 1.9110000807101517E9,
        "volumeOf24h": 21807.101,
        "markPrice": 87351.75,
        "indexPrice": 87357.57,
        "lastTradePrice": 87319.4,
        "nextFundingRateTime": 1816952,
        "maxLeverage": 125,
        "sourceExchanges": [
            "okex",
            "binance",
            "kucoin",
            "bybit",
            "bitmart",
            "gateio"
        ],
        "premiumsSymbol1M": ".XBTUSDTMPI",
        "premiumsSymbol8H": ".XBTUSDTMPI8H",
        "fundingBaseSymbol1M": ".XBTINT",
        "fundingQuoteSymbol1M": ".USDTINT",
        "lowPrice": 85201.8,
        "highPrice": 90000.0,
        "priceChgPct": -0.0033,
        "priceChg": -291.0,
        "k": 490.0,
        "m": 300.0,
        "f": 1.3,
        "mmrLimit": 0.3,
        "mmrLevConstant": 125.0,
        "supportCross": true,
        "buyLimit": 91717.92,
        "sellLimit": 82982.88
    }
}
Raises:

KucoinResponseException, KucoinAPIException

futures_get_ticker(symbol, **params)[source]

Get symbol ticker

https://www.kucoin.com/docs/rest/futures-trading/market-data/get-ticker

Parameters:

symbol – Name of symbol e.g. XBTUSDTM

ticker = client.futures_get_ticker('XBTUSDTM')
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "sequence": 1001,
        "symbol":
        "side": "buy",
        "size": 10,
        "price": "7000.0",
        "bestBidSize": 20,
        "bestBidPrice": "7000.0",
        "bestAskSize": 30,
        "bestAskPrice": "7001.0",
        "tradeId": "5cbd7377a6ffab0c7ba98b26",
        "ts": 1550653727731
    }
}
Raises:

KucoinResponseException, KucoinAPIException

futures_get_tickers(**params)[source]

Get symbol tickers

https://www.kucoin.com/docs/rest/futures-trading/market-data/get-latest-ticker-for-all-contracts

tickers = client.futures_get_tickers()
Returns:

ApiResponse

{
    "success": true,
    "code": "200",
    "msg": "success",
    "retry": false,
    "data": [
        {
            "sequence": 1721456489271,
            "symbol": "THETAUSDTM",
            "side": "buy",
            "size": 728,
            "tradeId": "1721456489263",
            "price": "1.479",
            "bestBidPrice": "1.536",
            "bestBidSize": 272,
            "bestAskPrice": "1.54",
            "bestAskSize": 1000,
            "ts": 1722237164196000000
        }
        ...
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

futures_get_order_book(symbol, depth_20=False, **params)[source]

Get a list of bids and asks aggregated by price for a symbol.

Returns up to 20 or 100 depth each side. Fastest Order book API

https://www.kucoin.com/docs/rest/futures-trading/market-data/get-part-order-book-level-2

Parameters:

symbol – Name of symbol e.g. XBTUSDTM

orders = client.futures_get_order_book('XBTUSDTM')
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "symbol": "XBTUSDM",
        "sequence": 100,
        "asks": [
            ["5000.0", 1000],
            ["6000.0", 1983]
        ],
        "bids": [
            ["3200.0", 800],
            ["3100.0", 100]
        ],
        "ts": 1604643655040584408
    }
}
Raises:

KucoinResponseException, KucoinAPIException

futures_get_full_order_book(symbol, **params)[source]

Get a list of all bids and asks aggregated by price for a symbol.

This call is generally used by professional traders because it uses more server resources and traffic,

https://www.kucoin.com/docs/rest/futures-trading/market-data/get-full-order-book-level-2

Parameters:

symbol – Name of symbol e.g. XBTUSDTM

orders = client.futures_get_full_order_book('XBTUSDTM')
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "symbol": "XBTUSDM",
        "sequence": 100,
        "asks": [
            ["5000.0", 1000],
            ["6000.0", 1983]
        ],
        "bids": [
            ["3200.0", 800],
            ["3100.0", 100]
        ],
        "ts": 1604643655040584408
    }
}
Raises:

KucoinResponseException, KucoinAPIException

futures_get_trade_histories(symbol, **params)[source]

List the latest trades for a symbol

https://www.kucoin.com/docs/rest/futures-trading/market-data/get-transaction-history

Parameters:

symbol – Name of symbol e.g. XBTUSDTM

orders = client.futures_get_trade_histories('XBTUSDTM')
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "sequence": 102,
        "tradeId": "5cbd7377a6ffab0c7ba98b26",
        "takerOrderId": "5cbd7377a6ffab0c7ba98b27",
        "makerOrderId": "5cbd7377a6ffab0c7ba98b28",
        "price": "7000.0",
        "size": 1,
        "side": "buy",
        "ts": 1545904567062140823
    }
}
Raises:

KucoinResponseException, KucoinAPIException

futures_get_klines(symbol, kline_type='5min', start=None, end=None, **params)[source]

Get kline data

https://www.kucoin.com/docs/rest/futures-trading/market-data/get-klines

For each query, the system would return at most 1500 pieces of data.

Parameters:
  • symbol (string) – Name of symbol e.g. XBTUSDTM

  • kline_type (string) – type of symbol, type of candlestick patterns: 1min, 3min, 5min, 15min, 30min, 1hour, 2hour, 4hour, 6hour, 8hour, 12hour, 1day, 1week

  • start (int) – Start time as unix timestamp (optional) default start of day in UTC

  • end (int) – End time as unix timestamp (optional) default now in UTC

klines = client.futures_get_klines('XBTUSDTM', '5min', 1507479171, 1510278278)
Returns:

ApiResponse

{
    "code": "200000",
    "data": [
        [
            1575331200000,
            7495.01,
            8309.67,
            7250,
            7463.55,
            0
        ],
        [
            1575374400000,
            7464.37,
            8297.85,
            7273.02,
            7491.44,
            0
        ]
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

futures_get_interest_rate(symbol, start=None, end=None, reverse=True, offset=None, forward=False, max_count=None, **params)[source]

Get interest rate

https://www.kucoin.com/docs/rest/futures-trading/market-data/get-interest-rate-list

Parameters:
  • symbol (string) – Name of symbol e.g. XBTUSDTM

  • start (int) – Start time as unix timestamp (optional) default start of day in UTC

  • end (int) – End time as unix timestamp (optional) default now in UTC

  • reverse (bool) – (optional) True means “yes”. False means no. This parameter is set as True by default.

  • offset (int) – (optional) Start offset. The unique attribute of the last returned result of the last request. The data of the first page will be returned by default.

  • forward (bool) – (optional) True means “yes”. False means no. This parameter is set as False by default.

  • max_count (int) – (optional) Maximum number of data to return. The default value is 100.

interest_rate = client.futures_get_interest_rate('XBTUSDTM')
Returns:

ApiResponse

{
    "dataList": [
        {
            "symbol": ".XBTINT",
            "granularity": 60000,
            "timePoint": 1557996300000,
            "value": 0.0003
        },
        {
            "symbol": ".XBTINT",
            "granularity": 60000,
            "timePoint": 1557996240000,
            "value": 0.0003
        },
        {
            "symbol": ".XBTINT",
            "granularity": 60000,
            "timePoint": 1557996180000,
            "value": 0.0003
        }
    ],
    "hasMore": true
}
Raises:

KucoinResponseException, KucoinAPIException

futures_get_index(symbol, start=None, end=None, reverse=True, offset=None, forward=False, max_count=None, **params)[source]

Get index

https://www.kucoin.com/docs/rest/futures-trading/market-data/get-index-list

Parameters:
  • symbol (string) – Name of symbol e.g. XBTUSDTM

  • start (int) – Start time as unix timestamp (optional) default start of day in UTC

  • end (int) – End time as unix timestamp (optional) default now in UTC

  • reverse (bool) – (optional) True means “yes”. False means no. This parameter is set as True by default.

  • offset (int) – (optional) Start offset. The unique attribute of the last returned result of the last request. The data of the first page will be returned by default.

  • forward (bool) – (optional) True means “yes”. False means no. This parameter is set as False by default.

  • max_count (int) – (optional) Maximum number of data to return. The default value is 100.

  • symbol – Name of symbol e.g. XBTUSDTM

index = client.futures_get_index('XBTUSDTM')
Returns:

ApiResponse

{
    "dataList": [
        {
            "symbol": ".KXBT",
            "granularity": 1000,
            "timePoint": 1557998570000,
            "value": 8016.24,
            "decomposionList": [
                {
                    "exchange": "gemini",
                    "price": 8016.24,
                    "weight": 0.08042611
                },
                {
                    "exchange": "kraken",
                    "price": 8016.24,
                    "weight": 0.02666502
                },
                {
                    "exchange": "coinbase",
                    "price": 8016.24,
                    "weight": 0.03847059
                },
                {
                    "exchange": "liquid",
                    "price": 8016.24,
                    "weight": 0.20419723
                },
                {
                    "exchange": "bittrex",
                    "price": 8016.24,
                    "weight": 0.29848962
                },
                {
                    "exchange": "bitstamp",
                    "price": 8016.24,
                    "weight": 0.35175143
                }
            ]
        }
    ],
    "hasMore": true
}
Raises:

KucoinResponseException, KucoinAPIException

futures_get_mark_price(symbol, **params)[source]

Get mark price

https://www.kucoin.com/docs/rest/futures-trading/market-data/get-current-mark-price

Parameters:

symbol (string) – Name of symbol e.g. XBTUSDTM

mark_price = client.futures_get_mark_price('XBTUSDTM')
Returns:

ApiResponse

{
    "symbol": "XBTUSDM",
    "granularity": 1000,
    "timePoint": 1557999585000,
    "value": 8052.51,
    "indexPrice": 8041.95
}
Raises:

KucoinResponseException, KucoinAPIException

futures_get_premium_index(symbol, start=None, end=None, reverse=True, offset=None, forward=False, max_count=None, **params)[source]

Get premium index

https://www.kucoin.com/docs/rest/futures-trading/market-data/get-premium-index

Parameters:
  • symbol (string) – Name of symbol e.g. XBTUSDTM

  • start (int) – Start time as unix timestamp (optional) default start of day in UTC

  • end (int) – End time as unix timestamp (optional) default now in UTC

  • reverse (bool) – (optional) True means “yes”. False means no. This parameter is set as True by default.

  • offset (int) – (optional) Start offset. The unique attribute of the last returned result of the last request. The data of the first page will be returned by default.

  • forward (bool) – (optional) True means “yes”. False means no. This parameter is set as False by default.

  • max_count (int) – (optional) Maximum number of data to return. The default value is 100.

premium_index = client.futures_get_premium_index('XBTUSDTM')
Returns:

ApiResponse

{
    "dataList": [
        {
            "symbol": ".XBTUSDMPI",
            "granularity": 60000,
            "timePoint": 1558000320000,
            "value": 0.022585
        },
        {
            "symbol": ".XBTUSDMPI",
            "granularity": 60000,
            "timePoint": 1558000260000,
            "value": 0.022611
        },
        {
            "symbol": ".XBTUSDMPI",
            "granularity": 60000,
            "timePoint": 1558000200000,
            "value": 0.021421
        }
    ],
    "hasMore": true
}
Raises:

KucoinResponseException, KucoinAPIException

futures_get_24hr_transaction_volume(**params)[source]

Get 24hr stats

https://www.kucoin.com/docs/rest/futures-trading/market-data/get-24hour-futures-transaction-volume

stats = client.futures_get_24hr_transaction_volume()
Returns:

ApiResponse

{
    "success": true,
    "code": "200",
    "msg": "success",
    "retry": false,
    "data": {
        "turnoverOf24h": 619
    }
}
Raises:

KucoinResponseException, KucoinAPIException

get_accounts(currency=None, account_type=None, **params)[source]

Get a list of accounts

https://www.kucoin.com/docs/rest/account/basic-info/get-account-list-spot-margin-trade_hf

Parameters:
  • currency (string) – optional Currency code

  • account_type (string) – optional Account type - main, trade, margin or pool

accounts = client.get_accounts()
accounts = client.get_accounts('BTC')
accounts = client.get_accounts('BTC', 'trade)
Returns:

API Response

[
    {
        "id": "5bd6e9286d99522a52e458de",
        "currency": "BTC",
        "type": "main",
        "balance": "237582.04299",
        "available": "237582.032",
        "holds": "0.01099"
    },
    {
        "id": "5bd6e9216d99522a52e458d6",
        "currency": "BTC",
        "type": "trade",
        "balance": "1234356",
        "available": "1234356",
        "holds": "0"
    }
]
Raises:

KucoinResponseException, KucoinAPIException

get_subaccounts(**params)[source]

Get a list of subaccounts

https://www.kucoin.com/docs/rest/account/sub-account/get-all-sub-accounts-info-v1-

accounts = client.get_subaccounts()
Returns:

API Response

[
    {
        "userId": "5cbd31ab9c93e9280cd36a0a", //subUserId
        "uid": "1789234",
        "subName": "kucoin1",
        "type": 0, //type:0-nomal
        "remarks": "kucoin1",
        "access": "All"
    },
    {
        "userId": "5cbd31b89c93e9280cd36a0d",
        "uid": "1789431",
        "subName": "kucoin2",
        "type": 1, //type:1-rebot
        "remarks": "kucoin2",
        "access": "All"
    }
]
Raises:

KucoinResponseException, KucoinAPIException

get_subaccounts_v2(page=None, limit=None, **params)[source]

Get a list of subaccounts

https://www.kucoin.com/docs/rest/account/sub-account/get-all-sub-accounts-info-v2-

Parameters:
  • page (int) – (optional) Current page - default 1

  • limit (int) – (optional) Number of results to return - default 10

accounts = client.get_subaccounts()
accounts = client.get_subaccounts(page=2, limit=5)
Returns:

API Response

{
    "code": "200000",
    "data": {
        "currentPage": 1,
        "pageSize": 100,
        "totalNum": 1,
        "totalPage": 1,
        "items": [
            {
                "userId": "635002438793b80001dcc8b3",
                "uid": 62356,
                "subName": "margin01",
                "status": 2,
                "type": 4,
                "access": "Margin",
                "createdAt": 1666187844000,
                "remarks": null
            }
        ]
    }
}
Raises:

KucoinResponseException, KucoinAPIException

margin_get_account_detail(**params)[source]

Get account detail

https://www.kucoin.com/docs/rest/funding/funding-overview/get-account-detail-margin

account = client.margin_get_account_detail()
Returns:

API Response

{
    "code": "200000",
    "data": {
        "debtRatio": "0",
        "accounts": [
            {
                "currency": "KCS",
                "totalBalance": "0.01",
                "availableBalance": "0.01",
                "holdBalance": "0",
                "liability": "0",
                "maxBorrowSize": "0"
            },
            {
                "currency": "USDT",
                "totalBalance": "0",
                "availableBalance": "0",
                "holdBalance": "0",
                "liability": "0",
                "maxBorrowSize": "0"
            },
            ...
        ]
    }
}
Raises:

KucoinResponseException, KucoinAPIException

margin_get_cross_account_detail(quote_currency=None, query_type=None, **params)[source]

Get cross account detail

https://www.kucoin.com/docs/rest/funding/funding-overview/get-account-detail-cross-margin

Parameters:
  • quote_currency (string) – (optional) quote currency

  • query_type (string) – (optional) query type

account = client.margin_get_cross_account_detail()
Returns:

API Response

{
    "success": true,
    "code": "200",
    "msg": "success",
    "retry": false,
    "data": {
        "timestamp": 1669708513820,
        "currentPage": 1,
        "pageSize": 100,
        "totalNum": 1,
        "totalPage": 1,
        "items": [
            {
                "totalLiabilityOfQuoteCurrency": "0.976",
                "totalAssetOfQuoteCurrency": "1.00",
                "debtRatio": "0.976",
                "status": "LIQUIDATION",
                "assets": [
                    {
                        "currency": "BTC",
                        "borrowEnabled": true,
                        "repayEnabled": true,
                        "transferEnabled": false,
                        "borrowed": "0.976",
                        "totalAsset": "1.00",
                        "available": "0.024",
                        "hold": "0",
                        "maxBorrowSize": "0"
                    }
                ]
            }
        ]
    }
}
Raises:

KucoinResponseException, KucoinAPIException

margin_get_isolated_account_detail(symbol=None, quote_currency=None, query_type=None, **params)[source]

Get isolated account detail

https://www.kucoin.com/docs/rest/funding/funding-overview/get-account-detail-isolated-margin

Parameters:
  • symbol (string) – (optional) symbol

  • quote_currency (string) – (optional) quote currency

  • query_type (string) – (optional) query type

account = client.margin_get_isolated_account_detail()
Returns:

API Response

{
    "code": "200000",
    "data": [
        {
            "totalAssetOfQuoteCurrency": "3.4939947",
            "totalLiabilityOfQuoteCurrency": "0.00239066",
            "timestamp": 1668062174000,
            "assets": [
                {
                    "symbol": "MANA-USDT",
                    "debtRatio": "0",
                    "status": "BORROW",
                    "baseAsset": {
                        "currency": "MANA",
                        "borrowEnabled": true,
                        "repayEnabled": true,
                        "transferEnabled": true,
                        "borrowed": "0",
                        "totalAsset": "0",
                        "available": "0",
                        "hold": "0",
                        "maxBorrowSize": "1000"
                    },
                    "quoteAsset": {
                        "currency": "USDT",
                        "borrowEnabled": true,
                        "repayEnabled": true,
                        "transferEnabled": true,
                        "borrowed": "0",
                        "totalAsset": "0",
                        "available": "0",
                        "hold": "0",
                        "maxBorrowSize": "50000"
                    }
                }
            ]
        }
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

futures_get_account_detail(currency=None, **params)[source]

Get futures account detail

https://www.kucoin.com/docs/rest/funding/funding-overview/get-account-detail-futures

Parameters:

currency (string) – (optional) currency

account = client.futures_get_account_detail()
Returns:

API Response

{
    "code": "200000",
    "data": {
        "accountEquity": 99.8999305281,
        "unrealisedPNL": 0,
        "marginBalance": 99.8999305281,
        "positionMargin": 0,
        "orderMargin": 0,
        "frozenFunds": 0,
        "availableBalance":
        "currency": "XBT" ,
        "riskRatio": 0
    }
}
Raises:

KucoinResponseException, KucoinAPIException

get_subaccount_balance(sub_user_id, include_base_ammount, **params)[source]

Get the account info of a sub-user specified by the subUserId

https://www.kucoin.com/docs/rest/account/sub-account/get-a-sub-account-balance

Parameters:
  • sub_user_id (string) – Sub account user id

  • include_base_ammount (bool) – Include base amount or not

accounts = client.get_subaccount_balance('5cbd31ab9c93e9280cd36a0a', True)
Returns:

API Response

{
    "subUserId": "5caefba7d9575a0688f83c45",
    "subName": "sdfgsdfgsfd",
    "mainAccounts": [
        {
            "currency": "BTC",
            "balance": "8",
            "available": "8",
            "holds": "0",
            "baseCurrency": "BTC",
            "baseCurrencyPrice": "1",
            "baseAmount": "1.1"
        }
    ],
    "tradeAccounts": [
        {
            "currency": "BTC",
            "balance": "1000",
            "available": "1000",
            "holds": "0",
            "baseCurrency": "BTC",
            "baseCurrencyPrice": "1",
            "baseAmount": "1.1"
        }
    ],
    "marginAccounts": [
        {
            "currency": "BTC",
            "balance": "1.1",
            "available": "1.1",
            "holds": "0",
            "baseCurrency": "BTC",
            "baseCurrencyPrice": "1",
            "baseAmount": "1.1"
        }
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

get_all_subaccounts_balance()[source]

Get the account info of all sub-users

https://www.kucoin.com/docs/rest/account/sub-account/get-all-sub-accounts-balance-v1-

accounts = client.get_all_subaccounts_balance()
Returns:

API Response

[
    {
        "subUserId": "5caefba7d9575a0688f83c45",
        "subName": "kucoin1",
        "mainAccounts": [
            {
                "currency": "BTC",
                "balance": "6",
                "available": "6",
                "holds": "0",
                "baseCurrency": "BTC",
                "baseCurrencyPrice": "1",
                "baseAmount": "1.1"
            }
        ],
        "tradeAccounts": [
            {
                "currency": "BTC",
                "balance": "1000",
                "available": "1000",
                "holds": "0",
                "baseCurrency": "BTC",
                "baseCurrencyPrice": "1",
                "baseAmount": "1.1"
            }
        ],
        "marginAccounts": [
            {
                "currency": "BTC",
                "balance": "1.1",
                "available": "1.1",
                "holds": "0",
                "baseCurrency": "BTC",
                "baseCurrencyPrice": "1",
                "baseAmount": "1.1"
            }
        ]
    }
]
Raises:

KucoinResponseException, KucoinAPIException

get_all_subaccounts_balance_v2(page=None, limit=None, **params)[source]

Get the account info of all sub-users

https://www.kucoin.com/docs/rest/account/sub-account/get-all-sub-accounts-balance-v2-

Parameters:
  • page (int) – (optional) Current page - default 1

  • limit (int) – (optional) Number of results to return - default 10

accounts = client.get_all_subaccounts_balance_v2()
accounts = client.get_all_subaccounts_balance_v2(page=2, limit=5)
Returns:

API Response

{
    "code": "200000",
    "data": {
        "currentPage": 1,
        "pageSize": 10,
        "totalNum": 14,
        "totalPage": 2,
        "items": [
            {
                "subUserId": "635002438793b80001dcc8b3",
                "subName": "margin03",
                "mainAccounts": [
                    {
                        "currency": "00",
                        "balance": "0",
                        "available": "0",
                        "holds": "0",
                        "baseCurrency": "BTC",
                        "baseCurrencyPrice": "125.63",
                        "baseAmount": "0"
                    }
                ]
            }
        ]
    }
}
Raises:

KucoinResponseException, KucoinAPIException

futures_get_all_subaccounts_balance(currency=None, **params)[source]

Get the account info of all sub-users

https://www.kucoin.com/docs/rest/funding/funding-overview/get-all-sub-accounts-balance-futures

Parameters:

currency (string) – (optional) currency

accounts = client.futures_get_all_subaccounts_balance()
Returns:

API Response

{
    "success": true,
    "code": "200",
    "msg": "success",
    "retry": false,
    "data": {
        "summary": {
            "accountEquityTotal": 9.99,
            "unrealisedPNLTotal": 0,
            "marginBalanceTotal": 9.99,
            "positionMarginTotal": 0,
            "orderMarginTotal": 0,
            "frozenFundsTotal": 0,
            "availableBalanceTotal": 9.99,
            "currency": "USDT"
        },
        "accounts": [
            {
                "accountName": "main",
                "accountEquity": 9.99,
                "unrealisedPNL": 0,
                "marginBalance": 9.99,
                "positionMargin": 0,
                "orderMargin": 0,
                "frozenFunds": 0,
                "availableBalance": 9.99,
                "currency": "USDT"
            },
            {
                "accountName": "subacct",
                "accountEquity": 0,
                "unrealisedPNL": 0,
                "marginBalance": 0,
                "positionMargin": 0,
                "orderMargin": 0,
                "frozenFunds": 0,
                "availableBalance": 0,
                "currency": "USDT"
            }
        ]
    }
}
Raises:

KucoinResponseException, KucoinAPIException

get_subaccount_api_list(sub_name, api_key=None, **params)[source]

Get the API key list of a sub-user

https://www.kucoin.com/docs/rest/account/sub-account-api/get-sub-account-api-list

Parameters:
  • api_key (string) – (optional) API key

  • sub_name (string) – Sub account name

accounts = client.get_subaccount_api_list('kucoin1')
accounts = client.get_subaccount_api_list('kucoin1', '5cbd31ab9c93e9280cd36a0a')
Returns:

API Response

{
    "code": "200000",
    "data": [
        {
            "subName": "AAAAAAAAAAAAA0022",
            "remark": "hytest01-01",
            "apiKey": "63032453e75087000182982b",
            "permission": "General",
            "ipWhitelist": "",
            "createdAt": 1661150291000,
            "apiVersion" : 3
        }
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

create_subaccount_api(sub_name, passphrase, remark, permission=None, ip_whitelist=None, expire=None, **params)[source]

Create Spot APIs for sub-accounts

https://www.kucoin.com/docs/rest/account/sub-account-api/create-sub-account-api

Parameters:
  • sub_name (string) – Sub account name

  • passphrase (string) – Sub account passphrase

  • remark (string) – API key remark

  • permission (string) – (optional) API key permission - General, Tradable, Withdraw

  • ip_whitelist (string) – (optional) IP whitelist

  • expire (string) – (optional) API key expiration time in seconds

accounts = client.create_subaccount_api('kucoin1', 'mypassword', 'myApiKey')

returns: API Response

{
    "code": "200000",
    "data": {
        "subName": "AAAAAAAAAA0007",
        "remark": "remark",
        "apiKey": "630325e0e750870001829864",
        "apiSecret": "110f31fc-61c5-4baf-a29f-3f19a62bbf5d",
        "passphrase": "passphrase",
        "permission": "General",
        "ipWhitelist": "",
        "createdAt": 1661150688000
    }
}
Raises:

KucoinResponseException, KucoinAPIException

modify_subaccount_api(sub_name, api_key, passphrase, permission=None, ip_whitelist=None, expire=None, **params)[source]

Modify Spot APIs for sub-accounts

https://www.kucoin.com/docs/rest/account/sub-account-api/modify-sub-account-api

Parameters:
  • sub_name (string) – Sub account name

  • api_key (string) – API key

  • passphrase (string) – Sub account passphrase

  • permission (string) – (optional) API key permission - General, Tradable, Withdraw

  • ip_whitelist (string) – (optional) IP whitelist

  • expire (string) – (optional) API key expiration time in seconds

accounts = client.modify_subaccount_api('kucoin1', 'myApiKey', 'mypassword')

returns: API Response

{
    "code": "200000",
    "data": {
        "subName": "AAAAAAAAAA0007",
        "apiKey": "630329b4e7508700018298c5",
        "permission": "General",
        "ipWhitelist": "127.0.0.1"
    }
}
Raises:

KucoinResponseException, KucoinAPIException

delete_subaccount_api(api_key, passphrase, sub_name, **params)[source]

Delete Spot APIs for sub-accounts

https://www.kucoin.com/docs/rest/account/sub-account-api/delete-sub-account-api

Parameters:
  • api_key (string) – API key

  • passphrase (string) – Sub account passphrase

  • sub_name (string) – Sub account name

accounts = client.delete_subaccount_api('myApiKey', 'mypassword', 'kucoin1')

returns: API Response

{
    "code": "200000",
    "data": {
        "subName": "AAAAAAAAAA0007",
        "apiKey": "630325e0e750870001829864"
    }
}
Raises:

KucoinResponseException, KucoinAPIException

get_account(account_id, **params)[source]

Get an individual account

https://www.kucoin.com/docs/rest/account/basic-info/get-account-detail-spot-margin-trade_hf

Parameters:

account_id (string) – ID for account - from list_accounts()

account = client.get_account('5bd6e9216d99522a52e458d6')
Returns:

API Response

{
    "currency": "KCS",
    "balance": "1000000060.6299",
    "available": "1000000060.6299",
    "holds": "0"
}
Raises:

KucoinResponseException, KucoinAPIException

create_account(account_type, currency)[source]

Create an account

https://docs.kucoin.com/#create-an-account

Parameters:
  • account_type (string) – Account type - main, trade, margin

  • currency (string) – Currency code

account = client.create_account('trade', 'BTC')
Returns:

API Response

{
    "id": "5bd6e9286d99522a52e458de"
}
Raises:

KucoinResponseException, KucoinAPIException

create_subaccount(password, sub_name, access, remarks=None, **params)[source]

Create a subaccount

https://www.kucoin.com/docs/rest/account/sub-account/create-sub-account

Parameters:
  • password (string) – Password(7-24 characters, must contain letters and numbers, cannot only contain numbers or include special characters).

  • sub_name (string) – Sub-account name(must contain 7-32 characters, at least one number and one letter. Cannot contain any spaces.)

  • access (string) – Permission (Spot, Futures, Margin permissions, which can be used alone or in combination).

  • remarks (string) – optional Remarks(1~24 characters).

account = client.create_subaccount('mypassword', 'mySubAccount', 'Spot')
account = client.create_subaccount('mypassword', 'mySubAccount', 'Spot, Margin', 'My Sub Account')
Returns:

API Response

{
    "id": "5bd6e9286d99522a52e458de"
}
Raises:

KucoinResponseException, KucoinAPIException

get_account_activity(currency=None, direction=None, biz_type=None, start=None, end=None, page=None, limit=None, **params)[source]

Get list of account activity

https://www.kucoin.com/docs/rest/account/basic-info/get-account-ledgers-spot-margin

Parameters:
  • currency (string) – (optional) currency name

  • direction (string) – (optional) Side: in - Receive, out - Send

  • biz_type (string) – (optional) Business type: DEPOSIT, WITHDRAW, TRANSFER, SUB_TRANSFER,TRADE_EXCHANGE, MARGIN_EXCHANGE, KUCOIN_BONUS.

  • start (string) – (optional) Start time as unix timestamp

  • end (string) – (optional) End time as unix timestamp

  • page (int) – (optional) Current page - default 1

  • limit (int) – (optional) Number of results to return - default 50

history = client.get_account_activity()

history = client.get_account_activity('ETH', start='1540296039000')

history = client.get_account_activity('ETH', page=2, page_size=10)
Returns:

API Response

{
    "currentPage": 1,
    "pageSize": 10,
    "totalNum": 2,
    "totalPage": 1,
    "items": [
        {
            "currency": "KCS",
            "amount": "0.0998",
            "fee": "0",
            "balance": "1994.040596",
            "bizType": "withdraw",
            "direction": "in",
            "createdAt": 1540296039000,
            "context": {
                 "orderId": "5bc7f080b39c5c03286eef8a",
                 "currency": "BTC"
             }
        },
        {
            "currency": "KCS",
            "amount": "0.0998",
            "fee": "0",
            "balance": "1994.140396",
            "bizType": "trade exchange",
            "direction": "in",
            "createdAt": 1540296039000,
            "context": {
                 "orderId": "5bc7f080b39c5c03286eef8e",
                 "tradeId": "5bc7f080b3949c03286eef8a",
                 "symbol": "BTC-USD"
            }
        }
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

hf_get_account_activity(currency=None, direction=None, biz_type=None, start=None, end=None, limit=None, last_id=None, margin=False, **params)[source]

Get list of hf account activity

https://www.kucoin.com/docs/rest/account/basic-info/get-account-ledgers-trade_hf https://www.kucoin.com/docs/rest/account/basic-info/get-account-ledgers-margin_hf

Parameters:
  • currency (string) – (optional) currency name

  • direction (string) – (optional) Side: in - Receive, out - Send

  • biz_type (string) – (optional) Business type: DEPOSIT, WITHDRAW, TRANSFER, SUB_TRANSFER,TRADE_EXCHANGE, MARGIN_EXCHANGE, KUCOIN_BONUS.

  • start (string) – (optional) Start time as unix timestamp

  • end (string) – (optional) End time as unix timestamp

  • limit (int) – (optional) Number of results to return - default 100

  • last_id (int) – (optional) The id of the last set of data from the previous batch of data. By default, the latest information is given.

  • margin (bool) – (optional) If True, get margin account activity - default False

history = client.hf_get_account_activity()

history = client.hf_get_account_activity('ETH', start='1540296039000')

history = client.hf_get_account_activity('ETH', margin=True, limit=10)
Returns:

API Response

{
    "code": "200000",
    "data": [
        {
            "id": "981449530900577",
            "currency": "ETH",
            "amount": "0.00617410",
            "fee": "0.00000000",
            "tax": "0",
            "balance": "0.00617410",
            "accountType": "TRADE_HF",
            "bizType": "TRADE_EXCHANGE",
            "direction": "in",
            "createdAt": "1730545211517",
            "context": "{"symbol": "ETH-USDT","orderId": "6726063b4d742800076e0273","tradeId": "10330457609226241"}"
        }
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

futures_get_account_activity(currency=None, type=None, start=None, end=None, limit=None, offset=None, forward=True, **params)[source]

Get list of futures account activity

https://www.kucoin.com/docs/rest/account/basic-info/get-account-ledgers-futures

Parameters:
  • currency (string) – (optional) currency name

  • type (string) – (optional) Type: RealisedPNL, Deposit, Withdrawal, Transferin, TransferOut.

  • start (string) – (optional) Start time as unix timestamp

  • end (string) – (optional) End time as unix timestamp

  • limit (int) – (optional) Number of results to return - default 50

  • offset (int) – (optional) Start offset. Generally, the only attribute of the last returned result of the previous request is used, and the first page is returned by default

  • forward (bool) – (optional) This parameter functions to judge whether the lookup is forward or not. True means “yes” and False means “no” - default True

history = client.get_futures_account_activity()

history = client.get_account_activity('ETH', start='1540296039000')

history = client.get_account_activity('ETH', forward=TRUE, page_size=10)
Returns:

API Response

Raises:

KucoinResponseException, KucoinAPIException

get_transferable_balance(currency, type, tag=None, **params)[source]

Get transferable balance

https://www.kucoin.com/docs/rest/funding/transfer/get-the-transferable

Parameters:
  • currency (string) – currency name

  • type (string) – Account type: MAIN、TRADE、MARGIN、ISOLATED

  • tag (string) – (optional) Trading pair, required when the account type is ISOLATED; other types are not passed, e.g.: BTC-USDT

transfer = client.get_transferable_balance('BTC', 'MAIN')
Returns:

API Response

{
    "currency": "KCS",
    "balance": "0",
    "available": "0",
    "holds": "0",
    "transferable": "0"
}
Raises:

KucoinResponseException, KucoinAPIException

create_universal_transfer(client_oid, amount, from_account_type, type, to_account_type, currency=None, from_user_id=None, from_account_tag=None, to_user_id=None, to_account_tag=None, **params)[source]

Transfer fund among accounts on the platform

https://www.kucoin.com/docs/rest/funding/transfer/flextransfer

Parameters:
  • client_oid (string) – Unique order id created by users to identify their orders, e.g. UUID, with a maximum length of 128 bits

  • amount (string) – Transfer amount, the amount is a positive integer multiple of the currency precision.

  • from_account_type (string) – Account type:MAIN、TRADE、CONTRACT、MARGIN、ISOLATED、MARGIN_V2、ISOLATED_V2

  • type (string) – Transfer type: Transfer type:INTERNAL(Transfer within account)、PARENT_TO_SUB(Transfer from master-account to sub-account),SUB_TO_PARENT(Transfer from sub-account to master-account)

  • to_account_type (string) – Account type:MAIN、TRADE、CONTRACT、MARGIN、ISOLATED、MARGIN_V2、ISOLATED_V2

  • currency (string) – (optional) currency name

  • from_user_id (string) – (optional) Transfer out UserId, This is required when transferring sub-account to master-account. It is optional for internal transfers.

  • from_account_tag (string) – (optional) Symbol, required when the account type is ISOLATED or ISOLATED_V2, for example: BTC-USDT

  • to_user_id (string) – (optional) Transfer in UserId, This is required when transferring master-account to sub-account. It is optional for internal transfers.

  • to_account_tag (string) – (optional) Symbol, required when the account type is ISOLATED or ISOLATED_V2, for example: BTC-USDT

transfer = client.create_universal_transfer('6d539dc614db3', 1, 'MAIN', 'INTERNAL', 'TRADE')
Returns:

API Response

{
    "clientOid": "64ccc0f164781800010d8c09",
    "type": "INTERNAL",
    "currency": "BTC",
    "amount": 1,
    "fromAccountType": "TRADE",
    "toAccountType": "CONTRACT"
}
Raises:

KucoinResponseException, KucoinAPIException

create_subaccount_transfer(client_oid, currency, amount, direction, sub_user_id, account_type=None, sub_account_type=None, **params)[source]

Transfer fund from master account to sub-account or from sub-account to master account

https://www.kucoin.com/docs/rest/funding/transfer/transfer-between-master-account-and-sub-account

Parameters:
  • client_oid (string) – Unique order id created by users to identify their orders, e.g. UUID, with a maximum length of 128 bits

  • currency (string) – currency name

  • amount (string) – Transfer amount, the amount is a positive integer multiple of the currency precision.

  • direction (string) – Transfer direction. OUT — the master user to sub user. IN — the sub user to the master user.

  • sub_user_id (string) – Sub account user id

  • account_type (string) – (optional) The account type of the master user: MAIN, TRADE, MARGIN or CONTRACT, default is MAIN.

  • sub_account_type (string) – (optional) The account type of the sub user: MAIN, TRADE, MARGIN or CONTRACT, default is MAIN.

transfer = client.create_subaccount_transfer('6d539dc614db3', 'BTC', 1, 'OUT', '5cbd31ab9c93e9280cd36a0a')
Returns:

API Response

{
    "orderId": "5cbd870fd9575a18e4438b9a"
}
Raises:

KucoinResponseException, KucoinAPIException

create_inner_transfer(client_oid, currency, from_type, to_type, amount, from_tag=None, to_tag=None, **params)[source]

Transfer fund among accounts on the platform

https://www.kucoin.com/docs/rest/funding/transfer/inner-transfer

Parameters:
  • client_oid (string) – Unique order id created by users to identify their orders, e.g. UUID, with a maximum length of 128 bits

  • currency (str) – currency name

  • from_type (str) – Payment Account Type: main, trade, margin, isolated, margin_v2, isolated_v2

  • to_type (str) – Receiving Account Type: main, trade, margin, isolated, margin_v2, isolated_v2, contract

  • amount (int) – Amount to transfer

  • from_tag (str) – (optional) Symbol, required when the account type is ISOLATED or ISOLATED_V2, for example: BTC-USDT

  • to_tag (str) – (optional) Symbol, required when the account type is ISOLATED or ISOLATED_V2, for example: BTC-USDT

transfer = client.create_inner_transfer('6d539dc614db3', 'BTC', 'main', 'trade', 1)
Returns:

API Response

{
    "orderId": "5bd6e9286d99522a52e458de"
}
Raises:

KucoinResponseException, KucoinAPIException

create_transfer_out(amount, currency, rec_account_type, **params)[source]

Transfer to Main or TRADE Account

https://www.kucoin.com/docs/rest/funding/transfer/transfer-to-main-or-trade-account

Parameters:
  • amount (string) – Transfer amount

  • currency (string) – Currency

  • rec_account_type (string) – Receive account type, including MAIN,TRADE

transfer = client.create_transfer_out('1', 'BTC', 'TRADE')
Returns:

API Response

{
    "applyId": "620a0bbefeaa6a000110e833",
    "bizNo": "620a0bbefeaa6a000110e832",
    "payAccountType": "CONTRACT",
    "payTag": "DEFAULT",
    "remark": "",
    "recAccountType": "MAIN",
    "recTag": "DEFAULT",
    "recRemark": "",
    "recSystem": "KUCOIN",
    "status": "PROCESSING",
    "currency": "USDT",
    "amount": "0.001",
    "fee": "0",
    "sn": 889048787670001,
    "reason": "",
    "createdAt": 1644825534000,
    "updatedAt": 1644825534000
}
Raises:

KucoinResponseException, KucoinAPIException

create_transfer_in(amount, currency, pay_account_type, **params)[source]

Transfer to Futures Account

https://www.kucoin.com/docs/rest/funding/transfer/transfer-to-futures-account

Parameters:
  • amount (string) – Transfer amount

  • currency (string) – Currency

  • pay_account_type (string) – Pay account type, including MAIN,TRADE

transfer = client.create_transfer_in('1', 'BTC', 'TRADE')
Returns:

API Response

{
    "code": "200",
    "msg": "",
    "retry": true,
    "success": true
}
Raises:

KucoinResponseException, KucoinAPIException

get_transfer_list(start=None, end=None, status=None, query_status=None, currency=None, page=None, limit=None, **params)[source]

Get Futures Transfer-Out Request Records

https://www.kucoin.com/docs/rest/funding/transfer/get-futures-transfer-out-request-records

Parameters:
  • start (int) – (optional) Start time (milisecond)

  • end (int) – (optional) End time (milisecond)

  • status (string) – (optional) Transfer status: PROCESSING, SUCCESS, FAILURE

  • query_status (string) – (optional) Transfer status: PROCESSING, SUCCESS, FAILURE

  • currency (string) – (optional) currency name

  • page (int) – (optional) Current page - default 1

  • limit (int) – (optional) Number of results to return - default 50

transfer = client.get_transfer_list()
transfer = client.get_transfer_list('1540296039000')
transfer = client.get_transfer_list('1540296039000', '1540296039000')
transfer = client.get_transfer_list('1540296039000', '1540296039000', 'PROCESSING')
transfer = client.get_transfer_list('1540296039000', '1540296039000', 'PROCESSING', 'PROCESSING')
transfer = client.get_transfer_list('1540296039000', '1540296039000', 'PROCESSING', 'PROCESSING', 'BTC')
transfer = client.get_transfer_list('1540296039000', '1540296039000', 'PROCESSING', 'PROCESSING', 'BTC', 1, 10)
Returns:

API Response

{
    "currentPage": 1,
    "pageSize": 50,
    "totalNum": 1,
    "totalPage": 1,
    "items": [
        {
        "applyId": "620a0bbefeaa6a000110e833", //Transfer-out request ID
        "currency": "USDT", //Currency
        "recRemark": "", //Receive account tx remark
        "recSystem": "KUCOIN", //Receive system
        "status": "SUCCESS", //Status  PROCESSING, SUCCESS, FAILURE
        "amount": "0.001", //Transaction amount
        "reason": "", //Reason caused the failure
        "offset": 889048787670001, //Offset
        "createdAt": 1644825534000, //Request application time
        "remark": "" //User remark
        }
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

create_deposit_address(currency, chain=None, to=None, amount=None, **params)[source]

Create deposit address for a currency you intend to deposit

https://www.kucoin.com/docs/rest/funding/deposit/create-deposit-address-v3-

Parameters:
  • currency (string) – Name of currency

  • chain (string) – (optional) The chain name of currency

  • to (string) – (optional) The address that the currency will be sent to

  • amount (string) – (optional) The amount of currency to be deposited

address = client.create_deposit_address_v3('USDT')
address = client.create_deposit_address_v3('USDT', 'ERC20')
address = client.create_deposit_address_v3('USDT', 'ERC20', '0x0a2586d5a901c8e7e68f6b0dc83bfd8bd8600ff5')
address = client.create_deposit_address_v3('USDT', 'ERC20', '0x0a2586d5a901c8e7e68f6b0dc83bfd8bd8600ff5', 100)
Returns:

ApiResponse

{
    "data" : {
        "memo" : null,
        "chain" : "ERC20",
        "chainId" : "eth",
        "to" : "MAIN",
        "currency" : "USDT",
        "address" : "0x0a2586d5a901c8e7e68f6b0dc83bfd8bd8600ff5"
    },
    "code" : "200000"
}
Raises:

KucoinResponseException, KucoinAPIException

get_deposit_addresses(currency, amount=None, chain=None, **params)[source]

Get all deposit addresses for the currency you intend to deposit.

https://www.kucoin.com/docs/rest/funding/deposit/get-deposit-addresses-v3-

Parameters:
  • currency (string) – Name of currency

  • amount (string) – (optional) The amount of currency to be deposited

  • chain (string) – (optional) The chain name of currency

address = client.get_deposit_addresses('USDT')
address = client.get_deposit_addresses('USDT', '100')
address = client.get_deposit_addresses('USDT', '100', 'ERC20')
Returns:

ApiResponse

{
    "data" : [
        {
            "address" : "bc1qwyuvmx53d*****gdg47kqxfwqy",
            "chain" : "BTC-Segwit",
            "memo" : "",
            "contractAddress" : "",
            "to" : "MAIN",
            "chainId" : "bech32",
            "currency" : "BTC"
        },
        {
            "address" : "3K7X9Vjnd*****TGaTAWoJ7H",
            "chain" : "BTC",
            "memo" : "",
            "contractAddress" : "",
            "to" : "MAIN",
            "chainId" : "btc",
            "currency" : "BTC"
        },
        {
            "address" : "0x637da22b860*****ac0c2433",
            "chain" : "KCC",
            "memo" : "",
            "contractAddress" : "0xfa93c12cd345c658bc4644d1d4e1b9615952258c",
            "to" : "MAIN",
            "chainId" : "kcc",
            "currency" : "BTC"
        }
    ],
    "code" : "200000"
}
Raises:

KucoinResponseException, KucoinAPIException

get_deposits(currency=None, status=None, start=None, end=None, page=None, limit=None, **params)[source]

Get deposit records for a currency

https://www.kucoin.com/docs/rest/funding/deposit/get-deposit-list

Parameters:
  • currency (string) – Name of currency (optional)

  • status (string) – optional - Status of deposit (PROCESSING, SUCCESS, FAILURE)

  • start (int) – (optional) Start time as unix timestamp

  • end (int) – (optional) End time as unix timestamp

  • page (int) – (optional) Page to fetch

  • limit (int) – (optional) Number of transactions

deposits = client.get_deposits('NEO')
deposits = client.get_deposits('NEO', 'SUCCESS')
deposits = client.get_deposits('NEO', 'SUCCESS', 1540296039000, 1540296039000)
deposits = client.get_deposits('NEO', 'SUCCESS', 1540296039000, 1540296039000, 1, 5)
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "currentPage": 1,
        "pageSize": 50,
        "totalNum": 1,
        "totalPage": 1,
        "items": [
            {
                "currency": "XRP",
                "chain": "xrp",
                "status": "SUCCESS",
                "address": "rNFugeoj3ZN8Wv6xhuLegUBBPXKCyWLRkB",
                "memo": "1919537769",
                "isInner": false,
                "amount": "20.50000000",
                "fee": "0.00000000",
                "walletTxId": "2C24A6D5B3E7D5B6AA6534025B9B107AC910309A98825BF5581E25BEC94AD83B",
                "createdAt": 1666600519000,
                "updatedAt": 1666600549000,
                "remark": "Deposit"
            }
        ]
    }
}
Raises:

KucoinResponseException, KucoinAPIException

get_deposit_history(currency=None, status=None, start=None, end=None, page=None, limit=None, **params)[source]

Get deposit history

https://www.kucoin.com/docs/rest/funding/deposit/get-v1-historical-deposits-list

Parameters:
  • currency (string) – Name of currency (optional)

  • status (string) – optional - Status of deposit (PROCESSING, SUCCESS, FAILURE)

  • start (string) – (optional) Start time as unix timestamp

  • end (string) – (optional) End time as unix timestamp

  • page (int) – (optional) Page to fetch

  • limit (int) – (optional) Number of transactions

deposits = client.get_deposit_history('NEO')
deposits = client.get_deposit_history('NEO', 'SUCCESS')
deposits = client.get_deposit_history('NEO', 'SUCCESS', 1540296039000, 1540296039000)
deposits = client.get_deposit_history('NEO', 'SUCCESS', 1540296039000, 1540296039000, 1, 5)
Returns:

ApiResponse

{
    "currentPage": 1,
    "pageSize": 1,
    "totalNum": 9,
    "totalPage": 9,
    "items": [
        {
            "currency": "BTC",
            "createAt": 1528536998,
            "amount": "0.03266638",
            "walletTxId": "55c643bc2c68d6f17266383ac1be9e454038864b929ae7cee0bc408cc5c869e8",
            "isInner": false,
            "status": "SUCCESS"
        }
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

get_user_type(**params)[source]

Get user type (the current user is a spot high-frequency user or a spot low-frequency user)

https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/get-user-type

deposits = client.get_user_type()
Returns:

ApiResponse

{
    "code": "200000",
    "data": true // true: high-frequency user, false: low-frequency user
}
Raises:

KucoinResponseException, KucoinAPIException

get_withdrawals(currency=None, status=None, start=None, end=None, page=None, limit=None, **params)[source]

Get deposit records for a currency

https://www.kucoin.com/docs/rest/funding/withdrawals/get-withdrawals-list

Parameters:
  • currency (string) – Name of currency (optional)

  • status (string) – optional - Status of deposit (PROCESSING, SUCCESS, FAILURE)

  • start (string) – (optional) Start time as unix timestamp

  • end (string) – (optional) End time as unix timestamp

  • page (int) – (optional) Page to fetch

  • limit (int) – (optional) Number of transactions

withdrawals = client.get_withdrawals('NEO')
withdrawals = client.get_withdrawals('NEO', 'SUCCESS')
withdrawals = client.get_withdrawals('NEO', 'SUCCESS', 1540296039000, 1540296039000)
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "currentPage": 1,
        "pageSize": 50,
        "totalNum": 1,
        "totalPage": 1,
        "items": [
            {
                "id": "63564dbbd17bef00019371fb",
                "currency": "XRP",
                "chain": "xrp",
                "status": "SUCCESS",
                "address": "rNFugeoj3ZN8Wv6xhuLegUBBPXKCyWLRkB",
                "memo": "1919537769",
                "isInner": false,
                "amount": "20.50000000",
                "fee": "0.50000000",
                "walletTxId": "2C24A6D5B3E7D5B6AA6534025B9B107AC910309A98825BF5581E25BEC94AD83B",
                "createdAt": 1666600379000,
                "updatedAt": 1666600511000,
                "remark": "test"
            }
        ]
    }
}
Raises:

KucoinResponseException, KucoinAPIException

get_historical_withdrawals(currency=None, status=None, start=None, end=None, page=None, limit=None, **params)[source]

Get historical withdrawals

https://www.kucoin.com/docs/rest/funding/withdrawals/get-v1-historical-withdrawals-list

Parameters:
  • currency (string) – Name of currency (optional)

  • status (string) – optional - Status of deposit (PROCESSING, SUCCESS, FAILURE)

  • start (string) – (optional) Start time as unix timestamp

  • end (string) – (optional) End time as unix timestamp

  • page (int) – (optional) Page to fetch

  • limit (int) – (optional) Number of transactions

withdrawals = client.get_historical_withdrawals('NEO')
withdrawals = client.get_historical_withdrawals('NEO', 'SUCCESS')
withdrawals = client.get_historical_withdrawals('NEO', 'SUCCESS', 1540296039000, 1540296039000)
Returns:

ApiResponse

{
    "currentPage": 1,
    "pageSize": 1,
    "totalNum": 2,
    "totalPage": 2,
    "items": [
        {
            "currency": "BTC",
            "createAt": 1526723468,
            "amount": "0.534",
            "address": "33xW37ZSW4tQvg443Pc7NLCAs167Yc2XUV",
            "walletTxId": "aeacea864c020acf58e51606169240e96774838dcd4f7ce48acf38e3651323f4",
            "isInner": false,
            "status": "SUCCESS"
        }
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

get_withdrawal_quotas(currency, chain=None, **params)[source]

Get withdrawal quotas for a currency

https://www.kucoin.com/docs/rest/funding/withdrawals/get-withdrawal-quotas

Parameters:
  • currency (string) – Name of currency

  • chain (string) – (optional) The chain name of currency

quotas = client.get_withdrawal_quotas('ETH')
Returns:

ApiResponse

{
    "data": {
        "limitBTCAmount": "37.83993375",
        "quotaCurrency": "USDT",
        "chain": "BTC",
        "remainAmount": "37.83993375",
        "innerWithdrawMinFee": "0",
        "usedBTCAmount": "0.00000000",
        "limitQuotaCurrencyAmount": "1000000.00000000",
        "withdrawMinSize": "0.0008",
        "withdrawMinFee": "0.0005",
        "precision": 8,
        "reason": null,
        "usedQuotaCurrencyAmount": "0",
        "currency": "BTC",
        "availableAmount": "0",
        "isWithdrawEnabled": true
    },
    "code": "200000"
}
Raises:

KucoinResponseException, KucoinAPIException

create_withdrawal(currency, amount, address, withdraw_type, memo=None, is_inner=False, remark=None, chain=None, fee_deduct_type=None, **params)[source]

Process a withdrawal

https://www.kucoin.com/docs/rest/funding/withdrawals/apply-withdraw-v3-

Parameters:
  • currency (string) – Name of currency

  • amount (number) – Amount to withdraw

  • address (string) – Address to withdraw to

  • withdraw_type (string) – Withdrawal type (ADDRESS (withdrawal address), UID, MAIL (email), PHONE (mobile phone number))

  • memo (string) – (optional) Remark to the withdrawal address

  • is_inner (bool) – (optional) Remark to the withdrawal address

  • remark (string) – (optional) Remark

  • chain (string) – (optional) The chain name of currency

  • fee_deduct_type (string) – (optional) Fee deduct type (INTERNAL or EXTERNAL)

withdrawal = client.create_withdrawal('NEO', 20, '598aeb627da3355fa3e851', 'ADDRESS')
Returns:

ApiResponse

# todo add response
Raises:

KucoinResponseException, KucoinAPIException

cancel_withdrawal(withdrawal_id, **params)[source]

Cancel a withdrawal

https://www.kucoin.com/docs/rest/funding/withdrawals/cancel-withdrawal

Parameters:

withdrawal_id (string) – ID of withdrawal

client.cancel_withdrawal('5bffb63303aa675e8bbe18f9')
Returns:

ApiResponse

{
    "withdrawalId": "5bffb63303aa675e8bbe18f9"
}
Raises:

KucoinResponseException, KucoinAPIException

get_base_fee(currency_type=None, **params)[source]

Get base fee

https://www.kucoin.com/docs/rest/funding/trade-fee/basic-user-fee-spot-margin-trade_hf

Parameters:

currency_type (string) – (optional) Currency type: 0-crypto currency, 1-fiat currency. default is 0-crypto currency

fee = client.get_base_fee()
fee = client.get_base_fee(1)
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "takerFeeRate": "0.001",
        "makerFeeRate": "0.001"
    }
}
Raises:

KucoinResponseException, KucoinAPIException

get_trading_pair_fee(symbols, **params)[source]

Trading pair actual fee - Spot/Margin/trade_hf

https://www.kucoin.com/docs/rest/funding/trade-fee/trading-pair-actual-fee-spot-margin-trade_hf

Parameters:

symbols (string) – Trading pair (optional, you can inquire fee rates of 10 trading pairs each time at most)

fee = client.get_trading_pair_fee()
fee = client.get_trading_pair_fee('BTC-USDT')
Returns:

ApiResponse

{
    "code": "200000",
    "data": [
        {
            "symbol": "BTC-USDT",
            "takerFeeRate": "0.001",
            "makerFeeRate": "0.001"
        },
        {
            "symbol": "KCS-USDT",
            "takerFeeRate": "0.002",
            "makerFeeRate": "0.0005"
        }
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

futures_get_trading_pair_fee(symbol, **params)[source]

Trading pair actual fee - Futures

https://www.kucoin.com/docs/rest/funding/trade-fee/trading-pair-actual-fee-futures

Parameters:

symbol (string) – Trading pair

fee = client.futures_get_trading_pair_fee('ETHUSDTM')
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "symbol": "XBTUSDTM",
        "takerFeeRate": "0.0006",
        "makerFeeRate": "0.0002"
    }
}
Raises:

KucoinResponseException, KucoinAPIException

create_order(symbol, type, side, size=None, price=None, funds=None, client_oid=None, stp=None, remark=None, time_in_force=None, cancel_after=None, post_only=None, hidden=None, iceberg=None, visible_size=None, **params)[source]

Create a spot order

https://www.kucoin.com/docs/rest/spot-trading/orders/place-order

Parameters:
  • symbol (string) – Name of symbol e.g. KCS-BTC

  • type (string) – order type (limit or market)

  • side (string) – buy or sell

  • size (string) – (optional) Desired amount in base currency (required for limit order)

  • price (string) – (optional) Price (required for limit order)

  • funds (string) – (optional) Desired amount of quote currency to use (for market order only)

  • client_oid (string) – (optional) Unique order id (default flat_uuid())

  • stp (string) – (optional) self trade protection CN, CO, CB or DC (default is None)

  • remark (string) – (optional) remark for the order, max 100 utf8 characters

  • time_in_force (string) – (optional) GTC, GTT, IOC, or FOK - default is GTC (for limit order only)

  • cancel_after (string) – (optional) time in ms to cancel after (for limit order only)

  • post_only (bool) – (optional) Post only flag (for limit order only)

  • hidden (bool) – (optional) Hidden order flag (for limit order only)

  • iceberg (bool) – (optional) Iceberg order flag (for limit order only)

  • visible_size (string) – (optional) The maximum visible size of an iceberg order (for limit orders only)

order = client.create_order('ETH-USDT', Client.ORDER_LIMIT, Client.SIDE_BUY, size=20, price=2000)
order = client.create_order('ETH-USDT', Client.ORDER_MARKET, Client.SIDE_BUY, funds=20)
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "orderId": "672a249054d62a0007ae04b8",
        "clientOid": "988a99edda5e496e95eb6e050c444994"
    }
}
Raises:

KucoinResponseException, KucoinAPIException, MarketOrderException, LimitOrderException, KucoinRequestException

create_market_order(symbol, side, size=None, funds=None, client_oid=None, remark=None, stp=None, **params)[source]

Create a spot market order

One of size or funds must be set

https://www.kucoin.com/docs/rest/spot-trading/orders/place-order

Parameters:
  • symbol (string) – Name of symbol e.g. KCS-BTC

  • side (string) – buy or sell

  • size (string) – (optional) Desired amount in base currency

  • funds (string) – (optional) Desired amount of quote currency to use

  • client_oid (string) – (optional) Unique order id (default flat_uuid())

  • remark (string) – (optional) remark for the order, max 100 utf8 characters

  • stp (string) – (optional) self trade protection CN, CO, CB or DC (default is None)

order = client.create_market_order('ETH-USDT', Client.SIDE_BUY, size=20)
Returns:

ApiResponse

{
    "orderOid": "596186ad07015679730ffa02"
}
Raises:

KucoinResponseException, KucoinAPIException, MarketOrderException

create_limit_order(symbol, side, price, size, client_oid=None, remark=None, time_in_force=None, stop=None, stop_price=None, stp=None, trade_type=None, cancel_after=None, post_only=None, hidden=None, iceberg=None, visible_size=None, **params)[source]

Create a spot limit order

https://docs.kucoin.com/#place-a-new-order

Parameters:
  • symbol (string) – Name of symbol e.g. KCS-BTC

  • side (string) – buy or sell

  • price (string) – Name of coin

  • size (string) – Amount of base currency to buy or sell

  • client_oid (string) – (optional) Unique order_id default flat_uuid()

  • remark (string) – (optional) remark for the order, max 100 utf8 characters

  • stp (string) – (optional) self trade protection CN, CO, CB or DC (default is None)

  • trade_type (string) – (optional) - deprecated - TRADE (spot) is supported only (default is TRADE)

  • time_in_force (string) – (optional) GTC, GTT, IOC, or FOK (default is GTC)

  • stop – (deprecated) not supported

  • stop_price – (deprecated) not supported

  • cancel_after (string) – (optional) number of seconds to cancel the order if not filled required time_in_force to be GTT

  • post_only (bool) – (optional) indicates that the order should only make liquidity. If any part of the order results in taking liquidity, the order will be rejected and no part of it will execute.

  • hidden (bool) – (optional) Orders not displayed in order book

  • iceberg (bool) – (optional) Only visible portion of the order is displayed in the order book

  • visible_size (string) – (optional) The maximum visible size of an iceberg order

order = client.create_limit_order('KCS-BTC', Client.SIDE_BUY, '0.01', '1000')
Returns:

ApiResponse

{
    "orderOid": "596186ad07015679730ffa02"
}
Raises:

KucoinResponseException, KucoinAPIException, LimitOrderException

create_test_order(symbol, type, side, size=None, price=None, funds=None, client_oid=None, stp=None, remark=None, time_in_force=None, cancel_after=None, post_only=None, hidden=None, iceberg=None, visible_size=None, **params)[source]

Create a test spot order

https://www.kucoin.com/docs/rest/spot-trading/orders/place-order-test

Parameters:
  • symbol (string) – Name of symbol e.g. KCS-BTC

  • type (string) – order type (limit or market)

  • side (string) – buy or sell

  • size (string) – (optional) Desired amount in base currency (required for limit order)

  • price (string) – (optional) Price (required for limit order)

  • funds (string) – (optional) Desired amount of quote currency to use (for market order only)

  • client_oid (string) – (optional) Unique order id (default flat_uuid())

  • stp (string) – (optional) self trade protection CN, CO, CB or DC (default is None)

  • remark (string) – (optional) remark for the order, max 100 utf8 characters

  • time_in_force (string) – (optional) GTC, GTT, IOC, or FOK - default is GTC (for limit order only)

  • cancel_after (string) – (optional) time in ms to cancel after (for limit order only)

  • post_only (bool) – (optional) Post only flag (for limit order only)

  • hidden (bool) – (optional) Hidden order flag (for limit order only)

  • iceberg (bool) – (optional) Iceberg order flag (for limit order only)

  • visible_size (string) – (optional) The maximum visible size of an iceberg order (for limit orders only)

order = client.create_test_order('ETH-USDT', Client.ORDER_LIMIT, Client.SIDE_BUY, size=20, price=2000)
order = client.create_test_order('ETH-USDT', Client.ORDER_MARKET, Client.SIDE_BUY, funds=20)
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "orderId": "672cf15bb2cdb8000708765c"
    }
}
Raises:

KucoinResponseException, KucoinAPIException, MarketOrderException, LimitOrderException, KucoinRequestException

create_orders(symbol, order_list, **params)[source]

Create multiple spot limit orders

Maximum of 5 orders can be created at once Only limit orders are supported

https://www.kucoin.com/docs/rest/spot-trading/orders/place-multiple-orders

Parameters:
  • symbol (string) – Name of symbol e.g. KCS-BTC

  • order_list – List of orders to create

order_list = [
    {
        "side": "buy",
        "price": "3000",
        "size": "0.1",
        "client_oid": "my_order_id_1"
    },
    {
        "side": "sell",
        "type": "limit",
        "price": "3500",
        "size": "0.1",
    }
]
orders = client.create_orders('ETH-USDT', order_list)
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "data": [
            {
                "symbol": "ETH-USDT",
                "type": "limit",
                "side": "buy",
                "price": "100",
                "size": "0.01",
                "funds": null,
                "stp": "",
                "stop": "loss",
                "stopPrice": "90",
                "timeInForce": "GTC",
                "cancelAfter": 0,
                "postOnly": false,
                "hidden": false,
                "iceberge": false,
                "iceberg": false,
                "visibleSize": null,
                "channel": "API",
                "id": "672e023a54d62a0007a60f73",
                "status": "success",
                "failMsg": null,
                "clientOid": "test_create_orders"
            }
        ]
    }
}
Raises:

KucoinResponseException, KucoinAPIException, KucoinRequestException, LimitOrderException

cancel_order(order_id, **params)[source]

Cancel a spot order

https://www.kucoin.com/docs/rest/spot-trading/orders/cancel-order-by-orderid

Parameters:

order_id (string) – Order id

res = client.cancel_order('5bd6e9286d99522a52e458de')
Returns:

ApiResponse

{
    "cancelledOrderIds": [
        "5bd6e9286d99522a52e458de"
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

KucoinAPIException If order_id is not found

cancel_order_by_client_oid(client_oid, **params)[source]

Cancel a spot order by the clientOid

https://www.kucoin.com/docs/rest/spot-trading/orders/cancel-order-by-clientoid

Parameters:

client_oid (string) – ClientOid

res = client.cancel_order_by_client_oid('6d539dc614db3')
Returns:

ApiResponse

{
    "cancelledOrderId": "5f311183c9b6d539dc614db3",
    "clientOid": "6d539dc614db3"
}
Raises:

KucoinResponseException, KucoinAPIException

KucoinAPIException If order_id is not found

cancel_all_orders(symbol=None, trade_type=None, **params)[source]

Cancel all orders

https://www.kucoin.com/docs/rest/spot-trading/orders/cancel-all-orders

Parameters:
  • symbol (string) – (optional) Name of symbol e.g. ETH-USDT

  • trade_type (string) – (optional) The type of trading: TRADE - spot trading, MARGIN_TRADE - cross margin trading, MARGIN_ISOLATED_TRADE - isolated margin trading default is TRADE

res = client.cancel_all_orders()
Returns:

ApiResponse

{
    "cancelledOrderIds": [
        "5bd6e9286d99522a52e458de"
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

get_orders(symbol=None, status=None, side=None, order_type=None, start=None, end=None, page=None, limit=None, trade_type=None, **params)[source]

Get list of orders

https://www.kucoin.com/docs/rest/spot-trading/orders/get-order-list

Parameters:
  • symbol (string) – (optional) Name of symbol e.g. KCS-BTC

  • status (string) – (optional) Specify status active or done (default done)

  • side (string) – (optional) buy or sell

  • order_type (string) – (optional) limit, market, limit_stop or market_stop

  • trade_type (string) – (optional) The type of trading : TRADE - spot trading, MARGIN_TRADE - cross margin trading, MARGIN_ISOLATED_TRADE - isolated margin trading default is TRADE

  • start (string) – (optional) Start time as unix timestamp

  • end (string) – (optional) End time as unix timestamp

  • page (int) – (optional) Page to fetch

  • limit (int) – (optional) Number of orders

orders = client.get_orders(symbol='KCS-BTC', status='active')
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "currentPage": 1,
        "pageSize": 50,
        "totalNum": 1,
        "totalPage": 1,
        "items": [
            {
                "id": "67320d92429d8b0007a962d0",
                "symbol": "ETH-USDT",
                "opType": "DEAL",
                "type": "limit",
                "side": "buy",
                "price": "100",
                "size": "0.01",
                "funds": "0",
                "dealFunds": "0",
                "dealSize": "0",
                "fee": "0",
                "feeCurrency": "USDT",
                "stp": null,
                "stop": null,
                "stopTriggered": false,
                "stopPrice": "0",
                "timeInForce": "GTC",
                "postOnly": false,
                "hidden": false,
                "iceberg": false,
                "visibleSize": "0",
                "cancelAfter": 0,
                "channel": "API",
                "clientOid": null,
                "remark": null,
                "tags": "partner:ccxt",
                "isActive": true,
                "cancelExist": false,
                "createdAt": 1731333522333,
                "tradeType": "TRADE"
            }
        ]
    }
}
Raises:

KucoinResponseException, KucoinAPIException

get_historical_orders(symbol=None, side=None, start=None, end=None, page=None, limit=None)[source]

Deprecated

get_recent_orders(page=None, limit=None, **params)[source]

Get up to 1000 last orders in the last 24 hours.

https://www.kucoin.com/docs/rest/spot-trading/orders/get-recent-orders-list

Parameters:
  • page (int) – (optional) Page to fetch

  • limit (int) – (optional) Number of orders

orders = client.get_recent_orders()
Returns:

ApiResponse

todo add the response example

Raises:

KucoinResponseException, KucoinAPIException

get_order(order_id, **params)[source]

Get order details

https://www.kucoin.com/docs/rest/spot-trading/orders/get-order-details-by-orderid

Parameters:

order_id (str) – orderOid value

order = client.get_order('5c35c02703aa673ceec2a168')
Returns:

ApiResponse

{
    "id": "5c35c02703aa673ceec2a168",
    "symbol": "BTC-USDT",
    "opType": "DEAL",
    "type": "limit",
    "side": "buy",
    "price": "10",
    "size": "2",
    "funds": "0",
    "dealFunds": "0.166",
    "dealSize": "2",
    "fee": "0",
    "feeCurrency": "USDT",
    "stp": "",
    "stop": "",
    "stopTriggered": false,
    "stopPrice": "0",
    "timeInForce": "GTC",
    "postOnly": false,
    "hidden": false,
    "iceberge": false,
    "visibleSize": "0",
    "cancelAfter": 0,
    "channel": "IOS",
    "clientOid": null,
    "remark": null,
    "tags": null,
    "isActive": false,
    "cancelExist": false,
    "createdAt": 1547026471000
}
Raises:

KucoinResponseException, KucoinAPIException

get_order_by_client_oid(client_oid, **params)[source]

Get order details by clientOid

https://www.kucoin.com/docs/rest/spot-trading/orders/get-order-details-by-clientoid

Parameters:

client_oid (str) – clientOid value

order = client.get_order_by_client_oid('6d539dc614db312')
Returns:

ApiResponse

{
    "id": "5f3113a1c9b6d539dc614dc6",
    "symbol": "KCS-BTC",
    "opType": "DEAL",
    "type": "limit",
    "side": "buy",
    "price": "0.00001",
    "size": "1",
    "funds": "0",
    "dealFunds": "0",
    "dealSize": "0",
    "fee": "0",
    "feeCurrency": "BTC",
    "stp": "",
    "stop": "",
    "stopTriggered": false,
    "stopPrice": "0",
    "timeInForce": "GTC",
    "postOnly": false,
    "hidden": false,
    "iceberg": false,
    "visibleSize": "0",
    "cancelAfter": 0,
    "channel": "API",
    "clientOid": "6d539dc614db312",
    "remark": "",
    "tags": "",
    "isActive": true,
    "cancelExist": false,
    "createdAt": 1597051810000,
    "tradeType": "TRADE"
}
Raises:

KucoinResponseException, KucoinAPIException

hf_create_order(symbol, type, side, size=None, price=None, funds=None, client_oid=None, stp=None, remark=None, time_in_force=None, cancel_after=None, post_only=None, hidden=None, iceberg=None, visible_size=None, tags=None, **params)[source]

Create a hf spot order

https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/place-hf-order

Parameters:
  • symbol (string) – Name of symbol e.g. KCS-BTC

  • type (string) – order type (limit or market)

  • side (string) – buy or sell

  • size (string) – (optional) Desired amount in base currency (required for limit order)

  • price (string) – (optional) Price (required for limit order)

  • funds (string) – (optional) Desired amount of quote currency to use (for market order only)

  • client_oid (string) – (optional) Unique order id (default flat_uuid())

  • stp (string) – (optional) self trade protection CN, CO, CB or DC (default is None)

  • remark (string) – (optional) remark for the order, max 100 utf8 characters

  • time_in_force (string) – (optional) GTC, GTT, IOC, or FOK - default is GTC (for limit order only)

  • cancel_after (string) – (optional) time in ms to cancel after (for limit order only)

  • post_only (bool) – (optional) Post only flag (for limit order only)

  • hidden (bool) – (optional) Hidden order flag (for limit order only)

  • iceberg (bool) – (optional) Iceberg order flag (for limit order only)

  • visible_size (string) – (optional) The maximum visible size of an iceberg order (for limit orders only)

  • tags (string) – (optional) order tag, length cannot exceed 20 characters (ASCII)

order = client.hf_create_order('ETH-USDT', Client.ORDER_LIMIT, Client.SIDE_BUY, size=20, price=2000)
order = client.hf_create_order('ETH-USDT', Client.ORDER_MARKET, Client.SIDE_BUY, funds=20)
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "orderId": "672a249054d62a0007ae04b8",
        "clientOid": "988a99edda5e496e95eb6e050c444994"
    }
}
Raises:

KucoinResponseException, KucoinAPIException, MarketOrderException, LimitOrderException, KucoinRequestException

hf_create_market_order(symbol, side, size=None, funds=None, client_oid=None, stp=None, remark=None, tags=None, **params)[source]

Create a hf spot market order

One of size or funds must be set

https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/place-hf-order

Parameters:
  • symbol (string) – Name of symbol e.g. KCS-BTC

  • side (string) – buy or sell

  • size (string) – (optional) Desired amount in base currency

  • funds (string) – (optional) Desired amount of quote currency to use

  • client_oid (string) – (optional) Unique order id (default flat_uuid())

  • stp (string) – (optional) self trade protection CN, CO, CB or DC (default is None)

  • remark (string) – (optional) remark for the order, max 100 utf8 characters

  • tags (string) – (optional) order tag, length cannot exceed 20 characters (ASCII)

order = client.hf_create_market_order('ETH-USDT', Client.SIDE_BUY, size=20)
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "orderId": "5bd6e9286d99522a52e458de",
        "clientOid": "11223344"
    }
}
Raises:

KucoinResponseException, KucoinAPIException, MarketOrderException

hf_create_limit_order(symbol, side, price, size, client_oid=None, stp=None, remark=None, time_in_force=None, cancel_after=None, post_only=None, hidden=None, iceberg=None, visible_size=None, tags=None, **params)[source]

Create a hf spot limit order

https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/place-hf-order

Parameters:
  • symbol (string) – Name of symbol e.g. KCS-BTC

  • side (string) – buy or sell

  • price (string) – Name of coin

  • size (string) – Amount of base currency to buy or sell

  • client_oid (string) – (optional) Unique order_id default flat_uuid()

  • stp (string) – (optional) self trade protection CN, CO, CB or DC (default is None)

  • remark (string) – (optional) remark for the order, max 100 utf8 characters

  • time_in_force (string) – (optional) GTC, GTT, IOC, or FOK (default is GTC)

  • cancel_after (string) – (optional) number of seconds to cancel the order if not filled required time_in_force to be GTT

  • post_only (bool) – (optional) indicates that the order should only make liquidity. If any part of the order results in taking liquidity, the order will be rejected and no part of it will execute.

  • hidden (bool) – (optional) Orders not displayed in order book

  • iceberg (bool) – (optional) Only visible portion of the order is displayed in the order book

  • visible_size (bool) – (optional) The maximum visible size of an iceberg order

  • tags (string) – (optional) order tag, length cannot exceed 20 characters (ASCII)

order = client.hf_create_limit_order('KCS-BTC', Client.SIDE_BUY, '0.01', '1000')
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "orderId": "5bd6e9286d99522a52e458de",
        "clientOid": "11223344"
    }
}
Raises:

KucoinResponseException, KucoinAPIException, LimitOrderException

hf_create_test_order(symbol, type, side, size=None, price=None, funds=None, client_oid=None, stp=None, remark=None, time_in_force=None, cancel_after=None, post_only=None, hidden=None, iceberg=None, visible_size=None, tags=None, **params)[source]

Create a hf test spot order

https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/place-hf-order-test

Parameters:
  • symbol (string) – Name of symbol e.g. KCS-BTC

  • type (string) – order type (limit or market)

  • side (string) – buy or sell

  • size (string) – (optional) Desired amount in base currency (required for limit order)

  • price (string) – (optional) Price (required for limit order)

  • funds (string) – (optional) Desired amount of quote currency to use (for market order only)

  • client_oid (string) – (optional) Unique order id (default flat_uuid())

  • stp (string) – (optional) self trade protection CN, CO, CB or DC (default is None)

  • remark (string) – (optional) remark for the order, max 100 utf8 characters

  • time_in_force (string) – (optional) GTC, GTT, IOC, or FOK - default is GTC (for limit order only)

  • cancel_after (string) – (optional) time in ms to cancel after (for limit order only)

  • post_only (bool) – (optional) Post only flag (for limit order only)

  • hidden (bool) – (optional) Hidden order flag (for limit order only)

  • iceberg (bool) – (optional) Iceberg order flag (for limit order only)

  • visible_size (string) – (optional) The maximum visible size of an iceberg order (for limit orders only)

  • tags (string) – (optional) order tag, length cannot exceed 20 characters (ASCII)

order = client.hf_create_test_order('ETH-USDT', Client.ORDER_LIMIT, Client.SIDE_BUY, size=20, price=2000)
order = client.hf_create_test_order('ETH-USDT', Client.ORDER_MARKET, Client.SIDE_BUY, funds=20)
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "orderId": "672a249054d62a0007ae04b8",
        "clientOid": "988a99edda5e496e95eb6e050c444994"
    }
}
Raises:

KucoinResponseException, KucoinAPIException, MarketOrderException, LimitOrderException, KucoinRequestException

sync_hf_create_order(symbol, type, side, size=None, price=None, funds=None, client_oid=None, stp=None, remark=None, time_in_force=None, cancel_after=None, post_only=None, hidden=None, iceberg=None, visible_size=None, tags=None, **params)[source]

Create a hf spot order The difference between this interface and hf_create_order is that this interface will synchronously return the order information after the order matching is completed

https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/sync-place-hf-order

Parameters:
  • symbol (string) – Name of symbol e.g. KCS-BTC

  • type (string) – order type (limit or market)

  • side (string) – buy or sell

  • size (string) – (optional) Desired amount in base currency (required for limit order)

  • price (string) – (optional) Price (required for limit order)

  • funds (string) – (optional) Desired amount of quote currency to use (for market order only)

  • client_oid (string) – (optional) Unique order id (default flat_uuid())

  • stp (string) – (optional) self trade protection CN, CO, CB or DC (default is None)

  • remark (string) – (optional) remark for the order, max 100 utf8 characters

  • time_in_force (string) – (optional) GTC, GTT, IOC, or FOK - default is GTC (for limit order only)

  • cancel_after (string) – (optional) time in ms to cancel after (for limit order only)

  • post_only (bool) – (optional) Post only flag (for limit order only)

  • hidden (bool) – (optional) Hidden order flag (for limit order only)

  • iceberg (bool) – (optional) Iceberg order flag (for limit order only)

  • visible_size (string) – (optional) The maximum visible size of an iceberg order (for limit orders only)

  • tags (string) – (optional) order tag, length cannot exceed 20 characters (ASCII)

order = client.sync_hf_create_order('ETH-USDT', Client.ORDER_LIMIT, Client.SIDE_BUY, size=20, price=2000)
order = client.sync_hf_create_order('ETH-USDT', Client.ORDER_MARKET, Client.SIDE_BUY, funds=20)
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "orderId": "673219d13cda6500071f613d",
        "orderTime": 1731336657616,
        "originSize": "0",
        "dealSize": "0.0003158",
        "remainSize": "0",
        "canceledSize": "0",
        "originFunds": "1",
        "dealFunds": "0.999709112",
        "remainFunds": "0",
        "canceledFunds": "0.000290888",
        "status": "done",
        "matchTime": 1731336657641
    }
}
Raises:

KucoinResponseException, KucoinAPIException, MarketOrderException, LimitOrderException, KucoinRequestException

hf_create_orders(order_list, **params)[source]

Create multiple hf spot orders

Maximum of 5 orders can be created at once

https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/place-multiple-orders

Parameters:

order_list – List of orders to create

order_list = [
    {
        "symbol": "ETH-USDT",
        "side": "buy",
        'type': 'market',
        "size": "0.1",
        "client_oid": "my_order_id_1"
    },
    {
        "symbol": "ETH-USDT",
        "side": "sell",
        "type": "limit",
        "price": "3500",
        "size": "0.1",
    }
]
orders = client.hf_create_orders(order_list)
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException, KucoinRequestException, LimitOrderException

sync_hf_create_orders(order_list, **params)[source]

Create multiple hf spot orders

The difference between this interface and hf_create_orders is that this interface will synchronously return the order information after the order matching is completed Maximum of 20 orders can be created at once

https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/sync-place-multiple-hf-orders

Parameters:

order_list – List of orders to create

order_list = [
    {
        {
        "symbol": "ETH-USDT",
        "side": "buy",
        'type': 'market',
        "size": "0.1",
        "client_oid": "my_order_id_1"
    },
    {
        "symbol": "ETH-USDT",
        "side": "sell",
        "type": "limit",
        "price": "3500",
        "size": "0.1",
    }
]
orders = client.sync_hf_create_orders(order_list)
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException, KucoinRequestException, LimitOrderException

hf_modify_order(symbol, order_id=None, client_oid=None, new_size=None, new_price=None, **params)[source]

Modify an existing hf order

https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/modify-hf-order

Parameters:
  • symbol (string) – Name of symbol e.g. KCS-BTC

  • order_id (string) – OrderId

  • client_oid (string) – ClientOid

  • new_size (string) – (optional) Desired amount in base currency

  • new_price (string) – (optional) Price

order = client.hf_modify_order('ETH-USDT', order_id='5c35c02703aa673ceec2a168', new_size='0.2')
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

hf_cancel_order(order_id, symbol, **params)[source]

Cancel an hf order by the orderId

https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/cancel-hf-order-by-orderid

Parameters:
  • order_id (string) – OrderId

  • symbol (string) – Name of symbol e.g. KCS-BTC

res = client.hf_cancel_order('5bd6e9286d99522a52e458de', 'KCS-BTC')
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

KucoinAPIException If order_id is not found

sync_hf_cancel_order(order_id, symbol, **params)[source]

Cancel an hf order by the orderId The difference between this interface and hf_cancel_order is that this interface will synchronously return the order information after the order canceling is completed.

https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/sync-cancel-hf-order-by-orderid

Parameters:
  • order_id (string) – OrderId

  • symbol (string) – Name of symbol e.g. KCS-BTC

res = client.sync_hf_cancel_order('5bd6e9286d99522a52e458de', 'KCS-BTC')
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

KucoinAPIException If order_id is not found

hf_cancel_order_by_client_oid(client_oid, symbol, **params)[source]

Cancel a hf order by the clientOid

https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/cancel-hf-order-by-clientoid

Parameters:
  • client_oid (string) – ClientOid

  • symbol (string) – Name of symbol e.g. KCS-BTC

res = client.hf_cancel_order_by_client_oid('6d539dc614db3', 'KCS-BTC')
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

KucoinAPIException If order_id is not found

sync_hf_cancel_order_by_client_oid(client_oid, symbol, **params)[source]

Cancel a hf order by the clientOid The difference between this interface and hf_cancel_order is that this interface will synchronously return the order information after the order canceling is completed.

https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/sync-cancel-hf-order-by-orderid

Parameters:
  • client_oid (string) – ClientOid

  • symbol (string) – Name of symbol e.g. ETH-USDT

res = client.sync_hf_cancel_order_by_client_oid('6d539dc614db3', 'ETH-USDT')
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

KucoinAPIException If order_id is not found

hf_cancel_specified_quantity_of_order(order_id, symbol, cancel_size, **params)[source]

Cancel a specified quantity of an hf order by the orderId

https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/cancel-specified-number-hf-orders-by-orderid

Parameters:
  • order_id (string) – OrderId

  • symbol (string) – Name of symbol e.g. KCS-BTC

  • cancel_size (string) – The quantity to cancel

res = client.hf_cancel_specified_quantity_of_order('5bd6e9286d99522a52e458de', 'ETH-USDT, '0.1')
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

KucoinAPIException

hf_cancel_orders_by_symbol(symbol, **params)[source]

Cancel all hf orders by symbol

https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/cancel-all-hf-orders-by-symbol

Parameters:

symbol (string) – Name of symbol e.g. ETH-USDT

res = client.hf_cancel_orders_by_symbol('ETH-USDT')
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

hf_cancel_all_orders(**params)[source]

Cancel all hf orders

https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/cancel-all-hf-orders

res = client.hf_cancel_all_orders()
Returns:

ApiResponse

{
    "succeedSymbols": [
        "ETH-USDT"
    ],
    "failedSymbols": [
        {
            "symbol": "BTC-USDT",
            "error": "can't cancel, system timeout"
        }
    ],
}
Raises:

KucoinResponseException, KucoinAPIException

hf_get_active_orders(symbol, **params)[source]

Get a list of active hf orders

https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/get-active-hf-orders-list

Parameters:

symbol (string) – Name of symbol e.g. KCS-BTC

orders = client.hf_get_active_orders('ETH-USDT')
Returns:

ApiResponse

{
    "code" : "200000",
    "data" : [
        "id": "5c35c02703aa673ceec2a168",
        "symbol": "BTC-USDT",
        "opType": "DEAL",
        "type": "limit",
        "side": "buy",
        "price": "10",
        "size": "2",
        "funds": "0",
        "dealFunds": "0.166",
        "dealSize": "2",
        "fee": "0",
        "feeCurrency": "USDT",
        "stp": "",
        "timeInForce": "GTC",
        "postOnly": false,
        "hidden": false,
        "iceberg": false,
        "visibleSize": "0",
        "cancelAfter": 0,
        "channel": "IOS",
        "clientOid": "",
        "remark": "",
        "tags": "",
        "active": true,
        "inOrderBook": true,
        "cancelExist": false,
        "createdAt": 1547026471000,
        "lastUpdatedAt": 1547026471001,
        "tradeType": "TRADE",
        "cancelledSize": "0",
        "cancelledFunds": "0",
        "remainSize": "0",
        "remainFunds": "0"
        }
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

hf_get_symbol_with_active_orders(**params)[source]

Get a list of symbols with active hf orders

https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/get-symbol-with-active-hf-orders-list

orders = client.hf_get_symbol_with_active_orders()
Returns:

ApiResponse

{
    "success": true,
    "code": "200",
    "msg": "success",
    "retry": false,
    "data": {
        "symbols": ["BTC-USDT"]
    }
}
Raises:

KucoinResponseException, KucoinAPIException

hf_get_completed_orders(symbol, side=None, type=None, start=None, end=None, last_id=None, limit=None, **params)[source]

Get a list of completed hf orders

https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/get-hf-completed-order-list

Parameters:
  • symbol (string) – Name of symbol e.g. KCS-BTC

  • side (string) – (optional) buy or sell

  • type (string) – (optional) limit, market, limit_stop or market_stop

  • start (int) – (optional) Start time as unix timestamp

  • end (int) – (optional) End time as unix timestamp

  • last_id (int) – (optional) The last orderId of the last page

  • limit (int) – (optional) Number of orders

orders = client.hf_get_completed_orders('ETH-USDT')
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "lastId": 2682265600,
        "items": [
        {
            "id": "63074a5a27ecbe0001e1f3ba",
            "symbol": "CSP-USDT",
            "opType": "DEAL",
            "type": "limit",
            "side": "sell",
            "price": "0.1",
            "size": "0.1",
            "funds": "0.01",
            "dealSize": "0",
            "dealFunds": "0",
            "fee": "0",
            "feeCurrency": "USDT",
            "stp": "",
            "timeInForce": "GTC",
            "postOnly": false,
            "hidden": false,
            "iceberg": false,
            "visibleSize": "0",
            "cancelAfter": 0,
            "channel": "API",
            "clientOid": "",
            "remark": "",
            "tags": "",
            "cancelExist": true,
            "createdAt": 1661422170924,
            "lastUpdatedAt": 1661422196926,
            "tradeType": "TRADE",
            "inOrderBook": false,
            "active": false,
            "cancelledSize": "0",
            "cancelledFunds": "0",
            "remainSize": "0",
            "remainFunds": "0"
        }
        ]
    }
}
Raises:

KucoinResponseException, KucoinAPIException

hf_get_order(order_id, symbol, **params)[source]

Get an hf order details by the orderId

https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/get-hf-order-details-by-orderid

Parameters:
  • order_id (string) – OrderId

  • symbol (string) – Name of symbol e.g. KCS-BTC

order = client.hf_get_order('5bd6e9286d99522a52e458de', 'KCS-BTC')
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "id": "5f3113a1c9b6d539dc614dc6",
        "symbol": "KCS-BTC",
        "opType": "DEAL",
        "type": "limit",
        "side": "buy",
        "price": "0.00001",
        "size": "1",
        "funds": "0",
        "dealFunds": "0",
        "dealSize": "0",
        "fee": "0",
        "feeCurrency": "BTC",
        "stp": "",
        "timeInForce": "GTC",
        "postOnly": false,
        "hidden": false,
        "iceberg": false,
        "visibleSize": "0",
        "cancelAfter": 0,
        "channel": "API",
        "clientOid": "6d539dc614db312",
        "remark": "",
        "tags": "",
        "active": true,
        "inOrderBook": false,
        "cancelExist": false,
        "createdAt": 1547026471000,
        "lastUpdatedAt": 1547026471001,
        "tradeType": "TRADE",
        "cancelledSize": "0",
        "cancelledFunds": "0",
        "remainSize": "0",
        "remainFunds": "0"
    }
}
Raises:

KucoinResponseException, KucoinAPIException

hf_get_order_by_client_oid(client_oid, symbol, **params)[source]

Get hf order details by clientOid

https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/get-hf-order-details-by-clientoid

Parameters:
  • client_oid (str) – clientOid value

  • symbol (string) – Name of symbol e.g. KCS-BTC

order = client.hf_get_order_by_client_oid('6d539dc614db312', 'KCS-BTC')
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

hf_auto_cancel_order(timeout, symbol=None, **params)[source]

Auto cancel a hf order

https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/auto-cancel-hf-order-setting

Parameters:
  • timeout (int) – The timeout period in ms

  • symbol (string) – (optional) Name of symbol e.g. KCS-BTC

res = client.hf_auto_cancel_order(60000)
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "currentTime": 1682010526,
        "triggerTime": 1682010531
    }
}
Raises:

KucoinResponseException, KucoinAPIException

hf_get_auto_cancel_order(**params)[source]

Get auto cancel setting

https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/auto-cancel-hf-order-setting-query

res = client.hf_get_auto_cancel_order()
Returns:

ApiResponse

{
    "timeout": 5,
    "symbols": "BTC-USDT",
    "currentTime": 1682010526,
    "triggerTime": 1682010531
}
Raises:

KucoinResponseException, KucoinAPIException

create_stop_order(symbol, type, side, stop_price, size=None, price=None, funds=None, client_oid=None, stp=None, remark=None, time_in_force=None, cancel_after=None, post_only=None, hidden=None, iceberg=None, visible_size=None, stop=None, trade_type=None, **params)[source]

Create a stop order

https://www.kucoin.com/docs/rest/spot-trading/stop-order/place-order

Parameters:
  • symbol (string) – Name of symbol e.g. KCS-BTC

  • type (string) – order type (limit or market)

  • side (string) – buy or sell

  • stop_price (string) – Stop price

  • size (string) – (optional) Desired amount in base currency (required for limit order)

  • price (string) – (optional) Price (required for limit order)

  • funds (string) – (optional) Desired amount of quote currency to use (for market order only)

  • client_oid (string) – (optional) Unique order id (default flat_uuid())

  • stp (string) – (optional) self trade protection CN, CO, CB or DC (default is None)

  • remark (string) – (optional) remark for the order, max 100 utf8 characters

  • time_in_force (string) – (optional) GTC, GTT, IOC, or FOK - default is GTC (for limit order only)

  • cancel_after (string) – (optional) time in ms to cancel after (for limit order only)

  • post_only (bool) – (optional) Post only flag (for limit order only)

  • hidden (bool) – (optional) Hidden order flag (for limit order only)

  • iceberg (bool) – (optional) Iceberg order flag (for limit order only)

  • visible_size (string) – (optional) The maximum visible size of an iceberg order (for limit orders only)

  • stop (string) – (optional) stop type - loss or entry (default is loss)

  • trade_type (string) – (optional) TRADE (Spot Trading), MARGIN_TRADE (Margin Trading), MARGIN_ISOLATED_TRADE (Isolated Margin Trading), default is TRADE.

order = client.create_stop_order('ETH-USDT', Client.ORDER_LIMIT, Client.SIDE_BUY, stop_price=2100, size=20, price=2000)
order = client.create_order('ETH-USDT', Client.ORDER_MARKET, Client.SIDE_BUY, stop_price=2100, funds=20)
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "orderId": "672a249054d62a0007ae04b8",
        "clientOid": "988a99edda5e496e95eb6e050c444994"
    }
}
Raises:

KucoinResponseException, KucoinAPIException, MarketOrderException, LimitOrderException, KucoinRequestException

cancel_stop_order(order_id, **params)[source]

Cancel a stop order

https://www.kucoin.com/docs/rest/spot-trading/stop-order/cancel-order-by-orderid

Parameters:

order_id (string) – Order id

res = client.cancel_stop_order('5bd6e9286d99522a52e458de')
Returns:

ApiResponse

{
    "cancelledOrderIds": [
        "5bd6e9286d99522a52e458de"
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

KucoinAPIException If order_id is not found

cancel_stop_order_by_client_oid(client_oid, symbol=None, **params)[source]

Cancel a spot order by the clientOid

https://www.kucoin.com/docs/rest/spot-trading/orders/cancel-order-by-clientoid

Parameters:
  • client_oid (string) – ClientOid

  • symbol (string) – (optional) Name of symbol e.g. ETH-USDT

res = client.cancel_order_by_client_oid('6d539dc614db3')
Returns:

ApiResponse

{
    "cancelledOrderId": "5f311183c9b6d539dc614db3",
    "clientOid": "6d539dc614db3"
}
Raises:

KucoinResponseException, KucoinAPIException

KucoinAPIException If order_id is not found

cancel_all_stop_orders(symbol=None, trade_type=None, order_ids=None, **params)[source]

Cancel all stop orders

https://www.kucoin.com/docs/rest/spot-trading/stop-order/cancel-stop-orders

Parameters:
  • symbol (string) – (optional) Name of symbol e.g. ETH-USDT

  • trade_type (string) – (optional) The type of trading: TRADE - spot trading, MARGIN_TRADE - cross margin trading, MARGIN_ISOLATED_TRADE - isolated margin trading default is TRADE

  • order_ids (string) – (optional) Comma seperated order IDs (e.g. ‘5bd6e9286d99522a52e458de,5bd6e9286d99522a52e458df’)

res = client.cancel_all_stop_orders()
Returns:

ApiResponse

{
    "cancelledOrderIds": [
        "5bd6e9286d99522a52e458de"
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

get_stop_orders(symbol=None, side=None, order_type=None, start=None, end=None, page=None, limit=None, trade_type=None, order_ids=None, stop=None, **params)[source]

Get list of stop orders

https://www.kucoin.com/docs/rest/spot-trading/stop-order/get-stop-orders-list

Parameters:
  • symbol (string) – (optional) Name of symbol e.g. KCS-BTC

  • side (string) – (optional) buy or sell

  • order_type (string) – (optional) limit, market, limit_stop or market_stop

  • trade_type (string) – (optional) The type of trading : TRADE - spot trading, MARGIN_TRADE - cross margin trading, MARGIN_ISOLATED_TRADE - isolated margin trading default is TRADE

  • start (string) – (optional) Start time as unix timestamp

  • end (string) – (optional) End time as unix timestamp

  • page (int) – (optional) Page to fetch

  • limit (int) – (optional) Number of orders

  • order_ids (string) – (optional) Comma seperated order IDs (e.g. ‘5bd6e9286d99522a52e458de,5bd6e9286d99522a52e458df’)

  • stop (string) – (optional) stop (stop loss order) or oco (oco order) todo check this parameter

orders = client.get_stop_orders(symbol='KCS-BTC', side='sell')
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

get_stop_order(order_id, **params)[source]

Get stop order details

https://www.kucoin.com/docs/rest/spot-trading/stop-order/get-order-details-by-orderid

Parameters:

order_id (str) – orderOid value

order = client.get_stop_order('5c35c02703aa673ceec2a168')
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

get_stop_order_by_client_oid(client_oid, symbol=None, **params)[source]

Get stop order details by clientOid

https://www.kucoin.com/docs/rest/spot-trading/stop-order/get-order-details-by-clientoid

Parameters:
  • client_oid (str) – clientOid value

  • symbol (string) – (optional) Name of symbol e.g. ETH-USDT

order = client.get_stop_order_by_client_oid('6d539dc614db312')
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

oco_create_order(symbol, side, size, price, stop_price, limit_price, client_oid=None, remark=None, **params)[source]

Create an OCO order

https://www.kucoin.com/docs/rest/spot-trading/oco-order/place-order

Parameters:
  • symbol (string) – Name of symbol e.g. ETH-USDT

  • side (string) – buy or sell

  • size (string) – Desired amount in base currency

  • price (string) – price

  • stop_price (string) – trigger price

  • limit_price (string) – limit order price after take-profit and stop-loss are triggered

  • client_oid (string) – (optional) Unique order id (default flat_uuid())

  • remark (string) – (optional) remark for the order, max 100 utf8 characters

order = client.oco_create_order('ETH-USDT', Client.SIDE_BUY, size=20, price=2000, stop_price=2100, limit_price=2200)
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

oco_cancel_order(order_id, **params)[source]

Cancel an oco order

https://www.kucoin.com/docs/rest/spot-trading/oco-order/cancel-order-by-orderid

Parameters:

order_id (string) – Order id

res = client.oco_cancel_order('5bd6e9286d99522a52e458de')
Returns:

ApiResponse

todo add the response example

Raises:

KucoinResponseException, KucoinAPIException

KucoinAPIException If order_id is not found

oco_cancel_order_by_client_oid(client_oid, **params)[source]

Cancel a spot order by the clientOid

https://www.kucoin.com/docs/rest/spot-trading/oco-order/cancel-order-by-clientoid

Parameters:

client_oid (string) – ClientOid

res = client.oco_cancel_order_by_client_oid('6d539dc614db3')
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

KucoinAPIException If order_id is not found

oco_cancel_all_orders(symbol=None, order_ids=None, **params)[source]

Cancel all oco orders

https://www.kucoin.com/docs/rest/spot-trading/oco-order/cancel-multiple-orders

Parameters:
  • symbol (string) – (optional) Name of symbol e.g. ETH-USDT

  • order_ids (string) – (optional) Comma seperated order IDs (e.g. ‘5bd6e9286d99522a52e458de,5bd6e9286d99522a52e458df’)

res = client.oco_cancel_all_orders()
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

oco_get_order_info(order_id, **params)[source]

Get oco order information for the order details use oco_get_order()

https://www.kucoin.com/docs/rest/spot-trading/oco-order/get-order-info-by-orderid

Parameters:

order_id (str) – orderOid value

order = client.oco_get_order_info('5c35c02703aa673ceec2a168')
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

oco_get_order(order_id, **params)[source]

Get oco order information

https://www.kucoin.com/docs/rest/spot-trading/oco-order/get-order-details-by-orderid

Parameters:

order_id (str) – orderOid value

order = client.oco_get_order('5c35c02703aa673ceec2a168')
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

oco_get_order_by_client_oid(client_oid, **params)[source]

Get oco order details by clientOid

https://www.kucoin.com/docs/rest/spot-trading/oco-order/get-order-info-by-clientoid

Parameters:

client_oid (string) – clientOid value

order = client.oco_get_order_by_client_oid('6d539dc614db312')
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

oco_get_orders(symbol=None, start=None, end=None, page=None, limit=None, order_ids=None, **params)[source]

Get list of oco orders

https://www.kucoin.com/docs/rest/spot-trading/oco-order/get-order-list

Parameters:
  • symbol (string) – (optional) Name of symbol e.g. KCS-BTC

  • start (string) – (optional) Start time as unix timestamp

  • end (string) – (optional) End time as unix timestamp

  • page (int) – (optional) Page to fetch

  • limit (int) – (optional) Number of orders

  • order_ids (string) – (optional) Comma seperated order IDs (e.g. ‘5bd6e9286d99522a52e458de,5bd6e9286d99522a52e458df’)

orders = client.oco_get_orders(symbol='KCS-BTC')
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

margin_create_order(symbol, type, side, size=None, price=None, funds=None, client_oid=None, stp=None, remark=None, time_in_force=None, cancel_after=None, post_only=None, hidden=None, iceberg=None, visible_size=None, margin_model=None, auto_borrow=None, auto_repay=None, **params)[source]

Create a margin order

https://www.kucoin.com/docs/rest/margin-trading/orders/place-margin-order

Parameters:
  • symbol (string) – Name of symbol e.g. KCS-BTC

  • type (string) – order type (limit or market)

  • side (string) – buy or sell

  • size (string) – (optional) Desired amount in base currency (required for limit order)

  • price (string) – (optional) Price (required for limit order)

  • funds (string) – (optional) Desired amount of quote currency to use (for market order only)

  • client_oid (string) – (optional) Unique order id (default flat_uuid())

  • stp (string) – (optional) self trade protection CN, CO, CB or DC (default is None)

  • remark (string) – (optional) remark for the order, max 100 utf8 characters

  • time_in_force (string) – (optional) GTC, GTT, IOC, or FOK - default is GTC (for limit order only)

  • cancel_after (string) – (optional) time in ms to cancel after (for limit order only)

  • post_only (bool) – (optional) Post only flag (for limit order only)

  • hidden (bool) – (optional) Hidden order flag (for limit order only)

  • iceberg (bool) – (optional) Iceberg order flag (for limit order only)

  • visible_size (string) – (optional) The maximum visible size of an iceberg order (for limit orders only)

  • margin_model (string) – (optional) cross or isolated (default is cross)

  • auto_borrow (bool) – (optional) auto borrow flag (default is False). If true the system will first borrow you funds at the optimal interest rate and then place an order for you. Currently autoBorrow parameter only supports cross mode, not isolated mode. When add this param, stop profit and stop loss are not supported, if it is a sell order, the size must be passed

  • auto_repay – (optional) auto repay flag (default is False). Automatically repay when placing an order, that is, the system automatically triggers repayment after the order is completed. The maximum currency repayment amount is the trade amount. The same order does not support the simultaneous use of autoBorrow and autoRepay.

order = client.margin_create_order('ETH-USDT', Client.ORDER_LIMIT, Client.SIDE_BUY, size=20, price=2000)
order = client.margin_create_order('ETH-USDT', Client.ORDER_MARKET, Client.SIDE_BUY, funds=20)
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException, MarketOrderException, LimitOrderException, KucoinRequestException

margin_create_test_order(symbol, type, side, size=None, price=None, funds=None, client_oid=None, stp=None, remark=None, time_in_force=None, cancel_after=None, post_only=None, hidden=None, iceberg=None, visible_size=None, margin_model=None, auto_borrow=None, auto_repay=None, **params)[source]

Create a margin test order

https://www.kucoin.com/docs/rest/margin-trading/orders/place-margin-order-test

Parameters:
  • symbol (string) – Name of symbol e.g. KCS-BTC

  • type (string) – order type (limit or market)

  • side (string) – buy or sell

  • size (string) – (optional) Desired amount in base currency (required for limit order)

  • price (string) – (optional) Price (required for limit order)

  • funds (string) – (optional) Desired amount of quote currency to use (for market order only)

  • client_oid (string) – (optional) Unique order id (default flat_uuid())

  • stp (string) – (optional) self trade protection CN, CO, CB or DC (default is None)

  • remark (string) – (optional) remark for the order, max 100 utf8 characters

  • time_in_force (string) – (optional) GTC, GTT, IOC, or FOK - default is GTC (for limit order only)

  • cancel_after (string) – (optional) time in ms to cancel after (for limit order only)

  • post_only (bool) – (optional) Post only flag (for limit order only)

  • hidden (bool) – (optional) Hidden order flag (for limit order only)

  • iceberg (bool) – (optional) Iceberg order flag (for limit order only)

  • visible_size (string) – (optional) The maximum visible size of an iceberg order (for limit orders only)

  • margin_model (string) – (optional) cross or isolated (default is cross)

  • auto_borrow (bool) – (optional) auto borrow flag (default is False). If true the system will first borrow you funds at the optimal interest rate and then place an order for you. Currently autoBorrow parameter only supports cross mode, not isolated mode. When add this param, stop profit and stop loss are not supported, if it is a sell order, the size must be passed

  • auto_repay – (optional) auto repay flag (default is False). Automatically repay when placing an order, that is, the system automatically triggers repayment after the order is completed. The maximum currency repayment amount is the trade amount. The same order does not support the simultaneous use of autoBorrow and autoRepay.

order = client.margin_create_test_order('ETH-USDT', Client.ORDER_LIMIT, Client.SIDE_BUY, size=20, price=2000)
order = client.margin_create_test_order('ETH-USDT', Client.ORDER_MARKET, Client.SIDE_BUY, funds=20)
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException, MarketOrderException, LimitOrderException, KucoinRequestException

hf_margin_create_order(symbol, type, side, size=None, price=None, funds=None, client_oid=None, stp=None, remark=None, time_in_force=None, cancel_after=None, post_only=None, hidden=None, iceberg=None, visible_size=None, is_isolated=None, auto_borrow=None, auto_repay=None, **params)[source]

Create an hf margin order

https://www.kucoin.com/docs/rest/margin-trading/margin-hf-trade/place-hf-order

Parameters:
  • symbol (string) – Name of symbol e.g. KCS-BTC

  • type (string) – order type (limit or market)

  • side (string) – buy or sell

  • size (string) – (optional) Desired amount in base currency (required for limit order)

  • price (string) – (optional) Price (required for limit order)

  • funds (string) – (optional) Desired amount of quote currency to use (for market order only)

  • client_oid (string) – (optional) Unique order id (default flat_uuid())

  • stp (string) – (optional) self trade protection CN, CO, CB or DC (default is None)

  • remark (string) – (optional) remark for the order, max 100 utf8 characters

  • time_in_force (string) – (optional) GTC, GTT, IOC, or FOK - default is GTC (for limit order only)

  • cancel_after (string) – (optional) time in ms to cancel after (for limit order only)

  • post_only (bool) – (optional) Post only flag (for limit order only)

  • hidden (bool) – (optional) Hidden order flag (for limit order only)

  • iceberg (bool) – (optional) Iceberg order flag (for limit order only)

  • visible_size (string) – (optional) The maximum visible size of an iceberg order (for limit orders only)

  • is_isolated – (optional) True for isolated margin, False for cross margin (default is False)

  • auto_borrow (bool) – (optional) auto borrow flag (default is False). When Margin HFTrading Account has inefficient balance, System autoborrows inefficient assets and opens positions according to the lowest market interest rate.

  • auto_repay – (optional) auto repay flag (default is False). AutoPay allows returning borrowed assets when you close a position. System automatically triggers the repayment and the maximum repayment amount equals to the filled-order amount.

order = client.hf_margin_create_order('ETH-USDT', Client.ORDER_LIMIT, Client.SIDE_BUY, size=20, price=2000)
order = client.hf_margin_create_order('ETH-USDT', Client.ORDER_MARKET, Client.SIDE_BUY, funds=20)
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException, MarketOrderException, LimitOrderException, KucoinRequestException

hf_margin_create_test_order(symbol, type, side, size=None, price=None, funds=None, client_oid=None, stp=None, remark=None, time_in_force=None, cancel_after=None, post_only=None, hidden=None, iceberg=None, visible_size=None, is_isolated=None, auto_borrow=None, auto_repay=None, **params)[source]

Create an hf margin test order

https://www.kucoin.com/docs/rest/margin-trading/margin-hf-trade/place-hf-order-test

Parameters:
  • symbol (string) – Name of symbol e.g. KCS-BTC

  • type (string) – order type (limit or market)

  • side (string) – buy or sell

  • size (string) – (optional) Desired amount in base currency (required for limit order)

  • price (string) – (optional) Price (required for limit order)

  • funds (string) – (optional) Desired amount of quote currency to use (for market order only)

  • client_oid (string) – (optional) Unique order id (default flat_uuid())

  • stp (string) – (optional) self trade protection CN, CO, CB or DC (default is None)

  • remark (string) – (optional) remark for the order, max 100 utf8 characters

  • time_in_force (string) – (optional) GTC, GTT, IOC, or FOK - default is GTC (for limit order only)

  • cancel_after (string) – (optional) time in ms to cancel after (for limit order only)

  • post_only (bool) – (optional) Post only flag (for limit order only)

  • hidden (bool) – (optional) Hidden order flag (for limit order only)

  • iceberg (bool) – (optional) Iceberg order flag (for limit order only)

  • visible_size (string) – (optional) The maximum visible size of an iceberg order (for limit orders only)

  • is_isolated – (optional) True for isolated margin, False for cross margin (default is False)

  • auto_borrow (bool) – (optional) auto borrow flag (default is False). When Margin HFTrading Account has inefficient balance, System autoborrows inefficient assets and opens positions according to the lowest market interest rate.

  • auto_repay – (optional) auto repay flag (default is False). AutoPay allows returning borrowed assets when you close a position. System automatically triggers the repayment and the maximum repayment amount equals to the filled-order amount.

order = client.hf_margin_create_test_order('ETH-USDT', Client.ORDER_LIMIT, Client.SIDE_BUY, size=20, price=2000)
order = client.hf_margin_create_test_order('ETH-USDT', Client.ORDER_MARKET, Client.SIDE_BUY, funds=20)
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException, MarketOrderException, LimitOrderException, KucoinRequestException

hf_margin_cancel_order(order_id, symbol, **params)[source]

Cancel an hf margin order by the orderId

https://www.kucoin.com/docs/rest/margin-trading/margin-hf-trade/cancel-hf-order-by-orderid

Parameters:
  • order_id (string) – OrderId

  • symbol (string) – Name of symbol e.g. KCS-BTC

res = client.hf_margin_cancel_order('5bd6e9286d99522a52e458de', 'KCS-BTC')
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

KucoinAPIException If order_id is not found

hf_margin_cancel_order_by_client_oid(client_oid, symbol, **params)[source]

Cancel a hf margin order by the clientOid

https://www.kucoin.com/docs/rest/margin-trading/margin-hf-trade/cancel-hf-order-by-clientoid

Parameters:
  • client_oid (string) – ClientOid

  • symbol (string) – Name of symbol e.g. KCS-BTC

res = client.hf_margin_cancel_order_by_client_oid('6d539dc614db3', 'KCS-BTC')
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

KucoinAPIException If order_id is not found

hf_margin_cancel_orders_by_symbol(symbol, trade_type, **params)[source]

Cancel all hf margin orders by symbol

https://www.kucoin.com/docs/rest/margin-trading/margin-hf-trade/cancel-all-hf-orders-by-symbol

Parameters:
  • symbol (string) – Name of symbol e.g. ETH-USDT

  • trade_type (string) – MARGIN_TRADE (Margin Trading) or MARGIN_ISOLATED_TRADE (Isolated Margin Trading)

res = client.hf_margin_cancel_orders_by_symbol('ETH-USDT')
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

hf_margin_get_active_orders(symbol, trade_type, **params)[source]

Get a list of active hf margin orders

https://www.kucoin.com/docs/rest/margin-trading/margin-hf-trade/get-active-hf-orders-list

Parameters:
  • symbol (string) – Name of symbol e.g. KCS-BTC

  • trade_type (string) – MARGIN_TRADE (Margin Trading) or MARGIN_ISOLATED_TRADE (Isolated Margin Trading)

orders = client.hf_margin_get_active_orders('ETH-USDT')
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

hf_margin_get_completed_orders(symbol, trade_type, side=None, type=None, start=None, end=None, last_id=None, limit=None, **params)[source]

Get a list of completed hf margin orders

https://www.kucoin.com/docs/rest/margin-trading/margin-hf-trade/get-hf-filled-list

Parameters:
  • symbol (string) – Name of symbol e.g. KCS-BTC

  • trade_type (string) – MARGIN_TRADE (Margin Trading) or MARGIN_ISOLATED_TRADE (Isolated Margin Trading)

  • side (string) – (optional) buy or sell

  • type (string) – (optional) limit, market, limit_stop or market_stop

  • start (int) – (optional) Start time as unix timestamp

  • end (int) – (optional) End time as unix timestamp

  • last_id (int) – (optional) The last orderId of the last page

  • limit (int) – (optional) Number of orders

orders = client.hf_margin_get_completed_orders('ETH-USDT', 'MARGIN_ISOLATED_TRADE')
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

hf_margin_get_order(order_id, symbol, **params)[source]

Get an hf margin order details by the orderId

https://www.kucoin.com/docs/rest/margin-trading/margin-hf-trade/get-hf-order-details-by-orderid

Parameters:
  • order_id (string) – OrderId

  • symbol (string) – Name of symbol e.g. KCS-BTC

order = client.hf_get_order('5bd6e9286d99522a52e458de', 'KCS-BTC')
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

hf_get_margin_order_by_client_oid(client_oid, symbol, **params)[source]

Get hf margin order details by clientOid

https://www.kucoin.com/docs/rest/margin-trading/margin-hf-trade/get-hf-order-details-by-clientoid

Parameters:
  • client_oid (str) – clientOid value

  • symbol (string) – Name of symbol e.g. KCS-BTC

order = client.hf_get_order_by_client_oid('6d539dc614db312', 'KCS-BTC')
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

hf_margin_get_symbol_with_active_orders(trade_type, **params)[source]

Get a list of symbols with active hf margin orders

https://www.kucoin.com/docs/rest/margin-trading/margin-hf-trade/get-active-hf-order-symbols

Parameters:

trade_type (string) – MARGIN_TRADE (Margin Trading) or MARGIN_ISOLATED_TRADE (Isolated Margin Trading)

orders = client.hf_margin_get_symbol_with_active_orders('MARGIN_TRADE')
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "symbolSize": 1,
        "symbols": ["ADA-USDT"]
    }
}
Raises:

KucoinResponseException, KucoinAPIException

futures_create_order(symbol, type=None, side=None, size=None, price=None, funds=None, client_oid=None, stp=None, remark=None, time_in_force=None, post_only=None, hidden=None, iceberg=None, visible_size=None, value_qty=None, leverage=None, stop=None, stop_price_type=None, stop_price=None, reduce_only=None, close_order=None, force_hold=None, margin_mode=None, **params)[source]

Create a futures order

https://www.kucoin.com/docs/rest/futures-trading/orders/place-order

Parameters:
  • symbol (string) – Name of symbol e.g. ETHUSDTM

  • type (string) – (optional)order type - limit or market (default is limit) Is mandatory if close_order!=True

  • side (string) – (optional) buy or sell Is mandatory if close_order!=True

  • size (string) – (optional) Desired amount in base currency Is mandatory if funds and value_qty are not passed and close_order!=True

  • price (string) – (optional) Price per base currency Is mandatory for limit order

  • funds (string) – (optional) Desired amount of quote currency to use Is mandatory if size and value_qty are not passed and close_order!=True

  • client_oid (string) – (optional) Unique order id (default flat_uuid())

  • stp (string) – (optional) self trade protection CN, CO or CB (default is None). DC is not supported

  • remark (string) – (optional) remark for the order, max 100 utf8 characters

  • time_in_force (string) – (optional) GTC or IOC - default is GTC

  • post_only (bool) – (optional) Post only flag (default is False)

  • hidden (bool) – (optional) Hidden order flag (default is False)

  • iceberg (bool) – (optional) Iceberg order flag (default is False)

  • visible_size (string) – (optional) The maximum visible size of an iceberg order

  • value_qty (string) – (optional) Order size (Value), USDS-Swap correspond to USDT or USDC. The unit of the quantity of coin-swap is size(lot), which is not supported Is mandatory if size and funds are not passed and close_order!=True

  • leverage (string) – (optional) Leverage of the order is mandatory if close_order!=True

  • stop (string) – (optional) down (triggers when the price reaches or goes below the stopPrice) or up (triggers when the price reaches or goes above the stopPrice). Requires stopPrice and stopPriceType to be defined

  • stop_price_type (string) – (optional) Either TP (trade price), IP (index price) or MP (mark price) Is mandatory if stop is defined

  • stop_price (string) – (optional) The trigger price of the order Is mandatory if stop is defined

  • reduce_only (bool) – (optional) Reduce only flag (default is False)

  • close_order (bool) – (optional) A flag to close the position. Set to false by default. If closeOrder is set to True, the system will close the position and the position size will become 0. Side, Size and Leverage fields can be left empty and the system will determine the side and size automatically.

  • force_hold (bool) – (optional) A flag to forcely hold the funds for an order, even though it’s an order to reduce the position size. This helps the order stay on the order book and not get canceled when the position size changes. Set to false by default. The system will forcely freeze certain amount of funds for this order, including orders whose direction is opposite to the current positions. This feature is to ensure that the order would not be canceled by the matching engine in such a circumstance that not enough funds are frozen for the order.

  • margin_mode (string) – (optional) ISOLATED or CROSS (default is ISOLATED)

order = client.futures_create_order('ETHUSDTM', type=Client.ORDER_LIMIT, side=Client.SIDE_BUY, size=20, price=2000)
order = client.futures_create_order('ETHUSDTM', type=Client.ORDER_MARKET, side=Client.SIDE_BUY, funds=20)
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException, MarketOrderException, LimitOrderException, KucoinRequestException

futures_create_test_order(symbol, type=None, side=None, size=None, price=None, funds=None, client_oid=None, stp=None, remark=None, time_in_force=None, post_only=None, hidden=None, iceberg=None, visible_size=None, value_qty=None, leverage=None, stop=None, stop_price_type=None, stop_price=None, reduce_only=None, close_order=None, force_hold=None, margin_mode=None, **params)[source]

Create a futures test order

https://www.kucoin.com/docs/rest/futures-trading/orders/place-order-test

Parameters:
  • symbol (string) – Name of symbol e.g. ETHUSDTM

  • type (string) – (optional)order type - limit or market (default is limit) Is mandatory if close_order!=True

  • side (string) – (optional) buy or sell Is mandatory if close_order!=True

  • size (string) – (optional) Desired amount in base currency Is mandatory if funds and value_qty are not passed and close_order!=True

  • price (string) – (optional) Price per base currency Is mandatory for limit order

  • funds (string) – (optional) Desired amount of quote currency to use Is mandatory if size and value_qty are not passed and close_order!=True

  • client_oid (string) – (optional) Unique order id (default flat_uuid())

  • stp (string) – (optional) self trade protection CN, CO or CB (default is None). DC is not supported

  • remark (string) – (optional) remark for the order, max 100 utf8 characters

  • time_in_force (string) – (optional) GTC or IOC - default is GTC

  • post_only (bool) – (optional) Post only flag (default is False)

  • hidden (bool) – (optional) Hidden order flag (default is False)

  • iceberg (bool) – (optional) Iceberg order flag (default is False)

  • visible_size (string) – (optional) The maximum visible size of an iceberg order

  • value_qty (string) – (optional) Order size (Value), USDS-Swap correspond to USDT or USDC. The unit of the quantity of coin-swap is size(lot), which is not supported Is mandatory if size and funds are not passed and close_order!=True

  • leverage (string) – (optional) Leverage of the order is mandatory if close_order!=True

  • stop (string) – (optional) down (triggers when the price reaches or goes below the stopPrice) or up (triggers when the price reaches or goes above the stopPrice). Requires stopPrice and stopPriceType to be defined

  • stop_price_type (string) – (optional) Either TP (trade price), IP (index price) or MP (mark price) Is mandatory if stop is defined

  • stop_price (string) – (optional) The trigger price of the order Is mandatory if stop is defined

  • reduce_only (bool) – (optional) Reduce only flag (default is False)

  • close_order (bool) – (optional) A flag to close the position. Set to false by default. If closeOrder is set to True, the system will close the position and the position size will become 0. Side, Size and Leverage fields can be left empty and the system will determine the side and size automatically.

  • force_hold (bool) – (optional) A flag to forcely hold the funds for an order, even though it’s an order to reduce the position size. This helps the order stay on the order book and not get canceled when the position size changes. Set to false by default. The system will forcely freeze certain amount of funds for this order, including orders whose direction is opposite to the current positions. This feature is to ensure that the order would not be canceled by the matching engine in such a circumstance that not enough funds are frozen for the order.

  • margin_mode (string) – (optional) ISOLATED or CROSS (default is ISOLATED)

order = client.futures_create_test_order('ETHUSDTM', type=Client.ORDER_LIMIT, side=Client.SIDE_BUY, size=20, price=2000)
order = client.futures_create_test_order('ETHUSDTM', type=Client.ORDER_MARKET, side=Client.SIDE_BUY, funds=20)
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException, MarketOrderException, LimitOrderException, KucoinRequestException

futures_create_stop_order(symbol, type=None, side=None, size=None, price=None, funds=None, client_oid=None, stp=None, remark=None, time_in_force=None, post_only=None, hidden=None, iceberg=None, visible_size=None, value_qty=None, leverage=None, trigger_stop_up_price=None, stop_price_type=None, trigger_stop_down_price=None, reduce_only=None, close_order=None, force_hold=None, margin_mode=None, **params)[source]

Create a futures take profit and/or stop loss order

https://www.kucoin.com/docs/rest/futures-trading/orders/place-take-profit-and-stop-loss-order

Parameters:
  • symbol (string) – Name of symbol e.g. ETHUSDTM

  • type (string) – (optional)order type - limit or market (default is limit) Is mandatory if close_order!=True

  • side (string) – (optional) buy or sell Is mandatory if close_order!=True

  • size (string) – (optional) Desired amount in base currency Is mandatory if funds and value_qty are not passed and close_order!=True

  • price (string) – (optional) Price per base currency Is mandatory for limit order

  • funds (string) – (optional) Desired amount of quote currency to use Is mandatory if size and value_qty are not passed and close_order!=True

  • client_oid (string) – (optional) Unique order id (default flat_uuid())

  • stp (string) – (optional) self trade protection CN, CO or CB (default is None). DC is not supported

  • remark (string) – (optional) remark for the order, max 100 utf8 characters

  • time_in_force (string) – (optional) GTC or IOC - default is GTC

  • post_only (bool) – (optional) Post only flag (default is False)

  • hidden (bool) – (optional) Hidden order flag (default is False)

  • iceberg (bool) – (optional) Iceberg order flag (default is False)

  • visible_size (string) – (optional) The maximum visible size of an iceberg order

  • value_qty (string) – (optional) Order size (Value), USDS-Swap correspond to USDT or USDC. The unit of the quantity of coin-swap is size(lot), which is not supported Is mandatory if size and funds are not passed and close_order!=True

  • leverage (string) – (optional) Leverage of the order is mandatory if close_order!=True

  • trigger_stop_up_price (string) – (optional) The trigger price of the take profit order

  • stop_price_type (string) – (optional) Either TP (trade price), IP (index price) or MP (mark price)

  • trigger_stop_down_price (string) – (optional) The trigger price of the stop loss order

  • reduce_only (bool) – (optional) Reduce only flag (default is False)

  • close_order (bool) – (optional) A flag to close the position. Set to false by default. If closeOrder is set to True, the system will close the position and the position size will become 0. Side, Size and Leverage fields can be left empty and the system will determine the side and size automatically.

  • force_hold (bool) – (optional) A flag to forcely hold the funds for an order, even though it’s an order to reduce the position size. This helps the order stay on the order book and not get canceled when the position size changes. Set to false by default. The system will forcely freeze certain amount of funds for this order, including orders whose direction is opposite to the current positions. This feature is to ensure that the order would not be canceled by the matching engine in such a circumstance that not enough funds are frozen for the order.

  • margin_mode (string) – (optional) ISOLATED or CROSS (default is ISOLATED)

order = client.futures_create_stop_order('ETHUSDTM', type=Client.ORDER_LIMIT, side=Client.SIDE_BUY, size=20, price=2000)
order = client.futures_create_stop_order('ETHUSDTM', type=Client.ORDER_MARKET, side=Client.SIDE_BUY, funds=20)
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException, MarketOrderException, LimitOrderException, KucoinRequestException

futures_create_orders(orders_data)[source]

Create multiple futures orders You can place up to 20 orders at one time, including limit orders, market orders, and stop orders

https://www.kucoin.com/docs/rest/futures-trading/orders/place-multiple-orders

Parameters:

orders_data (list Every order data is a dict with the same parameters as futures_create_order) – List of orders data

orders = [
    {
        'symbol': 'ETHUSDTM',
        'type': Client.ORDER_LIMIT,
        'side': Client.SIDE_BUY,
        'size': 20,
        'price': 2000
    },
    {
        'symbol': 'ETHUSDTM',
        'type': Client.ORDER_MARKET,
        'side': Client.SIDE_BUY,
        'funds': 20
    }
]
order = client.futures_create_orders(orders)
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException, MarketOrderException, LimitOrderException, KucoinRequestException

futures_cancel_order(order_id, **params)[source]

Cancel a futures order by order id

https://www.kucoin.com/docs/rest/futures-trading/orders/cancel-order-by-orderid

Parameters:

order_id (string) – Order id

res = client.futures_cancel_order('5bd6e9286d99522a52e458de')
Returns:

ApiResponse

{
    "cancelledOrderIds": [
        "5bd6e9286d99522a52e458de"
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

KucoinAPIException If order_id is not found

futures_cancel_order_by_client_oid(client_oid, symbol, **params)[source]

Cancel a futures order by the clientOid

https://www.kucoin.com/docs/rest/futures-trading/orders/cancel-order-by-clientoid

Parameters:
  • client_oid (string) – ClientOid

  • symbol (string) – Name of symbol e.g. KCS-BTC

res = client.futures_cancel_order_by_client_oid('6d539dc614db3', 'KCS-BTC')
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

KucoinAPIException If order_id is not found

futures_cancel_orders(symbol=None, order_ids=None, client_oids=None, **params)[source]

Cancel multiple futures orders by order ids or clientOids Either order_ids or client_oids and symbol are mandatory

https://www.kucoin.com/docs/rest/futures-trading/orders/batch-cancel-orders

Parameters:
  • symbol (string) – (optional) Name of symbol e.g. ETHUSDTM Is mandatory if order_ids are not passed

  • order_ids (list) – (optional) List of order ids Is mandatory if client_oids is not passed

  • client_oids (list) – (optional) List of clientOids Is mandatory if order_ids are not passed

res = client.futures_cancel_orders(['5bd6e9286d99522a52e458de', '5bd6e9286d99522a52e458df'])
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

KucoinAPIException If order_id is not found

futures_cancel_all_orders(symbol=None, **params)[source]

Cancel all futures orders

https://www.kucoin.com/docs/rest/futures-trading/orders/cancel-multiple-futures-limit-orders

Parameters:

symbol (string) – (optional) Name of symbol e.g. ETHUSDTM

res = client.futures_cancel_all_orders()
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

futures_cancel_all_stop_orders(symbol=None, **params)[source]

Cancel all futures stop orders

https://www.kucoin.com/docs/rest/futures-trading/orders/cancel-multiple-futures-stop-orders

Parameters:

symbol (string) – (optional) Name of symbol e.g. ETHUSDTM

res = client.futures_cancel_all_stop_orders()
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

futures_get_orders(symbol=None, status=None, side=None, order_type=None, start=None, end=None, page=None, limit=None, **params)[source]

Get list of futures orders

https://www.kucoin.com/docs/rest/futures-trading/orders/get-order-list

Parameters:
  • symbol (string) – (optional) Name of symbol e.g. KCS-BTC

  • status (string) – (optional) Specify status active or done (default done)

  • side (string) – (optional) buy or sell

  • order_type (string) – (optional) limit, market, limit_stop or market_stop

  • start (string) – (optional) Start time as unix timestamp

  • end (string) – (optional) End time as unix timestamp

  • page (int) – (optional) Page to fetch

  • limit (int) – (optional) Number of orders (default 50, max 1000)

orders = client.futures_get_orders(symbol='ETHUSDTM', status='active')
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

futures_get_stop_orders(symbol=None, side=None, order_type=None, start=None, end=None, page=None, limit=None, **params)[source]

Get list of untriggered futures stop orders

https://www.kucoin.com/docs/rest/futures-trading/orders/get-untriggered-stop-order-list

Parameters:
  • symbol (string) – (optional) Name of symbol e.g. KCS-BTC

  • side (string) – (optional) buy or sell

  • order_type (string) – (optional) limit, market, limit_stop or market_stop

  • start (string) – (optional) Start time as unix timestamp

  • end (string) – (optional) End time as unix timestamp

  • page (int) – (optional) Page to fetch

  • limit (int) – (optional) Number of orders (default 50, max 1000)

orders = client.futures_get_stop_orders(symbol='ETHUSDTM')
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

futures_get_recent_orders(symbol=None, **params)[source]

Get up to 1000 last futures done orders in the last 24 hours.

https://www.kucoin.com/docs/rest/futures-trading/orders/get-list-of-orders-completed-in-24h

Parameters:

symbol (string) – (optional) Name of symbol e.g. ETHUSDTM

orders = client.futures_get_recent_orders()
Returns:

ApiResponse

todo add the response example

Raises:

KucoinResponseException, KucoinAPIException

futures_get_order(order_id, **params)[source]

Get futures order details by order id

https://www.kucoin.com/docs/rest/futures-trading/orders/get-order-details-by-orderid-clientoid

Parameters:

order_id (str) – orderOid value

order = client.futures_get_order('5c35c02703aa673ceec2a168')
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

futures_get_order_by_client_oid(client_oid, **params)[source]

Get futures order details by clientOid

https://www.kucoin.com/docs/rest/futures-trading/orders/get-order-details-by-orderid-clientoid

Parameters:

client_oid (string) – clientOid value

order = client.futures_get_order_by_client_oid('6d539dc614db312')
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

get_fills(trade_type, order_id=None, symbol=None, side=None, type=None, start=None, end=None, page=None, limit=None, **params)[source]

Get a list of recent fills.

https://www.kucoin.com/docs/rest/spot-trading/fills/get-filled-list

Parameters:
  • trade_type (string) – TRADE (Spot Trading), MARGIN_TRADE (Margin Trading), MARGIN_ISOLATED_TRADE (Isolated Margin Trading), TRADE as default.

  • order_id (string) – (optional) OrderId

  • symbol (string) – (optional) Name of symbol e.g. KCS-BTC

  • side (string) – (optional) buy or sell

  • type (string) – (optional) limit, market, limit_stop or market_stop

  • start (int) – (optional) Start time as unix timestamp

  • end (int) – (optional) End time as unix timestamp

  • page (int) – (optional) Page number

  • limit (int) – (optional) Number of orders

fills = client.get_fills('TRADE')
Returns:

ApiResponse

{
    "currentPage": 1,
    "pageSize": 1,
    "totalNum": 251915,
    "totalPage": 251915,
    "items": [
        {
        "symbol": "BTC-USDT",
        "tradeId": "5c35c02709e4f67d5266954e",
        "orderId": "5c35c02703aa673ceec2a168",
        "counterOrderId": "5c1ab46003aa676e487fa8e3",
        "side": "buy",
        "liquidity": "taker",
        "forceTaker": true,
        "price": "0.083",
        "size": "0.8424304",
        "funds": "0.0699217232",
        "fee": "0",
        "feeRate": "0",
        "feeCurrency": "USDT",
        "stop": "",
        "type": "limit",
        "createdAt": 1547026472000,
        "tradeType": "TRADE"
        }
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

get_recent_fills(**params)[source]

Get a list of recent fills.

https://www.kucoin.com/docs/rest/spot-trading/fills/get-recent-filled-list

fills = client.get_recent_fills()
Returns:

ApiResponse

{
    "code": "200000",
    "data": [
        {
            "counterOrderId": "5db7ee769797cf0008e3beea",
            "createdAt": 1572335233000,
            "fee": "0.946357371456",
            "feeCurrency": "USDT",
            "feeRate": "0.001",
            "forceTaker": true,
            "funds": "946.357371456",
            "liquidity": "taker",
            "orderId": "5db7ee805d53620008dce1ba",
            "price": "9466.8",
            "side": "buy",
            "size": "0.09996592",
            "stop": "",
            "symbol": "BTC-USDT",
            "tradeId": "5db7ee8054c05c0008069e21",
            "tradeType": "MARGIN_TRADE",
            "type": "market"
        }
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

hf_get_fills(symbol, order_id=None, side=None, type=None, start=None, end=None, last_id=None, limit=None, **params)[source]

Get a list of hf fills

https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/get-hf-filled-list

Parameters:
  • symbol (string) – Name of symbol e.g. KCS-BTC

  • order_id (string) – (optional) OrderId

  • side (string) – (optional) buy or sell

  • type (string) – (optional) limit, market, limit_stop or market_stop

  • start (int) – (optional) Start time as unix timestamp

  • end (int) – (optional) End time as unix timestamp

  • last_id (int) – (optional) The last orderId of the last page

  • limit (int) – (optional) Number of orders

fills = client.hf_get_fills('ETH-USDT')
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "items": [
        {
            "id": 2678765568,
            "symbol": "BTC-ETC",
            "tradeId": 616179312641,
            "orderId": "6306cf6e27ecbe0001e1e03a",
            "counterOrderId": "6306cf4027ecbe0001e1df4d",
            "side": "buy",
            "liquidity": "taker",
            "forceTaker": false,
            "price": "1",
            "size": "1",
            "funds": "1",
            "fee": "0.00021",
            "feeRate": "0.00021",
            "feeCurrency": "USDT",
            "stop": "",
            "tradeType": "TRADE",
            "type": "limit",
            "createdAt": 1661390702919
        }
        ],
        "lastId": 2678765568
    }
}
Raises:

KucoinResponseException, KucoinAPIException

hf_margin_get_fills(symbol, trade_type, order_id=None, side=None, type=None, start=None, end=None, last_id=None, limit=None, **params)[source]

Get a list of hf fills

https://www.kucoin.com/docs/rest/margin-trading/margin-hf-trade/get-hf-transaction-records

Parameters:
  • symbol (string) – Name of symbol e.g. KCS-BTC

  • trade_type (string) – MARGIN_TRADE (Margin Trading) or MARGIN_ISOLATED_TRADE (Isolated Margin Trading)

  • order_id (string) – (optional) OrderId

  • side (string) – (optional) buy or sell

  • type (string) – (optional) limit, market, limit_stop or market_stop

  • start (int) – (optional) Start time as unix timestamp

  • end (int) – (optional) End time as unix timestamp

  • last_id (int) – (optional) The last orderId of the last page

  • limit (int) – (optional) Number of orders

fills = client.hf_get_fills('ETH-USDT')
Returns:

ApiResponse

todo add the response example
Raises:

KucoinResponseException, KucoinAPIException

futures_get_fills(order_id=None, symbol=None, side=None, type=None, start=None, end=None, page=None, limit=None, **params)[source]

Get a list of recent futures fills.

https://www.kucoin.com/docs/rest/futures-trading/fills/get-filled-list

Parameters:
  • order_id (string) – (optional) OrderId

  • symbol (string) – (optional) Name of symbol e.g. KCS-BTC

  • side (string) – (optional) buy or sell

  • type (string) – (optional) limit, market, limit_stop or market_stop

  • start (int) – (optional) Start time as unix timestamp

  • end (int) – (optional) End time as unix timestamp

  • page (int) – (optional) Page number

  • limit (int) – (optional) Number of orders

fills = client.futures_get_fills()
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "currentPage": 1,
        "pageSize": 1,
        "totalNum": 251915,
        "totalPage": 251915,
        "items": [
            {
                "symbol": "XBTUSDM",
                "tradeId": "5ce24c1f0c19fc3c58edc47c",
                "orderId": "5ce24c16b210233c36ee321d",
                "side": "sell",
                "liquidity": "taker",
                "forceTaker": true,
                "price": "8302",
                "size": 10,
                "value": "0.001204529",
                "feeRate": "0.0005",
                "fixFee": "0.00000006",
                "feeCurrency": "XBT",
                "stop": "",
                "fee": "0.0000012022",
                "orderType": "limit",
                "tradeType": "trade",
                "createdAt": 1558334496000,
                "settleCurrency": "XBT",
                "openFeePay": "0.002",
                "closeFeePay": "0.002",
                "tradeTime": 1558334496000000000,
                "marginMode": "ISOLATED"
            }
        ]
    }
}
Raises:

KucoinResponseException, KucoinAPIException

futures_get_recent_fills(symbol=None, **params)[source]

Get a list of recent futures fills.

https://www.kucoin.com/docs/rest/futures-trading/fills/get-recent-filled-list

fills = client.futures_get_recent_fills()
Returns:

ApiResponse

{
    "code": "200000",
    "data": [
        {
            "symbol": "XBTUSDM",
            "tradeId": "5ce24c1f0c19fc3c58edc47c",
            "orderId": "5ce24c16b210233c36ee321d",
            "side": "sell",
            "liquidity": "taker",
            "forceTaker": true,
            "price": "8302",
            "size": 10,
            "value": "0.001204529",
            "feeRate": "0.0005",
            "fixFee": "0.00000006",
            "feeCurrency": "XBT",
            "stop": "",
            "fee": "0.0000012022",
            "orderType": "limit",
            "tradeType": "trade",
            "createdAt": 1558334496000,
            "settleCurrency": "XBT",
            "openFeePay": "0.002",
            "closeFeePay": "0.002",
            "tradeTime": 1558334496000000000,
            "marginMode": "ISOLATED"
        }
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

futures_get_active_order_value(symbol, **params)[source]

Get the active order value of a symbol

https://www.kucoin.com/docs/rest/futures-trading/fills/get-active-order-value-calculation

Parameters:

symbol (string) – Name of symbol e.g. XBTUSDM

active_order_value = client.futures_get_active_order_value('XBTUSDM')
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "openOrderBuySize": 20,
        "openOrderSellSize": 0,
        "openOrderBuyCost": "0.0025252525",
        "openOrderSellCost": "0",
        "settleCurrency": "XBT"
    }
}
Raises:

KucoinResponseException, KucoinAPIException

margin_get_leverage_token_info(currency=None, **params)[source]

Get a list of leverage token info

https://www.kucoin.com/docs/rest/margin-trading/margin-info/get-leveraged-token-info

Parameters:

currency (string) – (optional) Currency, if empty query all currencies

leverage_token_info = client.get_leverage_token_info()
Returns:

ApiResponse

{
    "success": true,
    "code": "200",
    "msg": "success",
    "retry": false,
    "data": [
        {
            "currency": "BTCUP",
            "netAsset": 0.001,
            "targetLeverage": "2-4",
            "actualLeverage": "2.33",
            "assetsUnderManagement": "766834.764756714775 USDT"
            "basket": "-78.671762 XBTUSDTM"
        }
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

margin_get_all_trading_pairs_mark_prices(**params)[source]

Get a list of trading pairs and their mark prices

https://www.kucoin.com/docs/rest/margin-trading/margin-info/get-all-trading-pairs-mark-price

trading_pairs_mark_prices = client.get_all_trading_pairs_mark_prices()
Returns:

ApiResponse

{
    "code": "200000",
    "data": [
        {
            "symbol": "POND-BTC",
            "timePoint": 1721027167000,
            "value": 2.96603125E-7
        },
        {
            "symbol": "REN-BTC",
            "timePoint": 1721027217000,
            "value": 7.36068750E-7
        }
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

margin_get_mark_price(symbol, **params)[source]

Get the mark price of a symbol

https://www.kucoin.com/docs/rest/margin-trading/margin-info/get-mark-price

Parameters:

symbol (string) – Name of symbol e.g. KCS-BTC

mark_price = client.get_mark_price('ETH-USDT')
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "symbol": "USDT-BTC",
        "timePoint": 1659930234000,
        "value": 0.0000429
    }
}
Raises:

KucoinResponseException, KucoinAPIException

margin_get_config(**params)[source]

Get the margin configuration

https://www.kucoin.com/docs/rest/margin-trading/margin-info/get-margin-configuration-info

margin_config = client.get_config()
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "currencyList": [
            "XEM",
            "MATIC",
            "VRA",
            ...
        ],
        "maxLeverage": 5,
        "warningDebtRatio": "0.95",
        "liqDebtRatio": "0.97"
    }
}
Raises:

KucoinResponseException, KucoinAPIException

margin_get_cross_isolated_risk_limit_config(isolated, symbol=None, currency=None, **params)[source]

Get the cross or isolated margin risk limit configuration

https://www.kucoin.com/docs/rest/margin-trading/margin-info/get-cross-isolated-margin-risk-limit-currency-config

Parameters:
  • isolated (bool) – True for isolated margin, False for cross margin

  • symbol (string) – (optional) Name of symbol e.g. KCS-BTC

  • currency (string) – (optional) Currency

risk_limit_config = client.get_cross_isolated_risk_limit_config(False)
Returns:

ApiResponse

CROSS MARGIN RESPONSES
{
    "success": true,
    "code": "200",
    "msg": "success",
    "retry": false,
    "data": [
        {
            "timestamp": 1697783812257,
            "currency": "XMR",
            "borrowMaxAmount": "999999999999999999",
            "buyMaxAmount": "999999999999999999",
            "holdMaxAmount": "999999999999999999",
            "borrowCoefficient": "0.5",
            "marginCoefficient": "1",
            "precision": 8,
            "borrowMinAmount": "0.001",
            "borrowMinUnit": "0.001",
            "borrowEnabled": true
        }
    ]
}
ISOLATED MARGIN RESPONSES

{
    "success": true,
    "code": "200",
    "msg": "success",
    "retry": false,
    "data": [
        {
            "timestamp": 1697782543851,
            "symbol": "LUNC-USDT",
            "baseMaxBorrowAmount": "999999999999999999",
            "quoteMaxBorrowAmount": "999999999999999999",
            "baseMaxBuyAmount": "999999999999999999",
            "quoteMaxBuyAmount": "999999999999999999",
            "baseMaxHoldAmount": "999999999999999999",
            "quoteMaxHoldAmount": "999999999999999999",
            "basePrecision": 8,
            "quotePrecision": 8,
            "baseBorrowCoefficient": "1",
            "quoteBorrowCoefficient": "1",
            "baseMarginCoefficient": "1",
            "quoteMarginCoefficient": "1",
            "baseBorrowMinAmount": null,
            "baseBorrowMinUnit": null,
            "quoteBorrowMinAmount": "0.001",
            "quoteBorrowMinUnit": "0.001",
            "baseBorrowEnabled": false,
            "quoteBorrowEnabled": true
        }
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

margin_get_isolated_synbols_config(**params)[source]

Get the isolated margin symbol configuration

https://www.kucoin.com/docs/rest/margin-trading/isolated-margin/get-isolated-margin-symbols-configuration

isolated_symbols_config = client.get_isolated_synbols_config()
Returns:

ApiResponse

{
    "code": "200000",
    "data": [
        {
            "symbol": "EOS-USDC",
            "symbolName": "EOS-USDC",
            "baseCurrency": "EOS",
            "quoteCurrency": "USDC",
            "maxLeverage": 10,
            "flDebtRatio": "0.97",
            "tradeEnable": true,
            "autoRenewMaxDebtRatio": "0.96",
            "baseBorrowEnable": true,
            "quoteBorrowEnable": true,
            "baseTransferInEnable": true,
            "quoteTransferInEnable": true
        },
        {
            "symbol": "MANA-USDT",
            "symbolName": "MANA-USDT",
            "baseCurrency": "MANA",
            "quoteCurrency": "USDT",
            "maxLeverage": 10,
            "flDebtRatio": "0.9",
            "tradeEnable": true,
            "autoRenewMaxDebtRatio": "0.96",
            "baseBorrowEnable": true,
            "quoteBorrowEnable": true,
            "baseTransferInEnable": true,
            "quoteTransferInEnable": true
        }
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

margin_get_isolated_account_info(balance_currency=None, **params)[source]

Get the isolated margin account info

https://www.kucoin.com/docs/rest/margin-trading/isolated-margin/get-isolated-margin-account-info

Parameters:

balance_currency (string) – (optional) The pricing coin, currently only supports USDT, KCS, and BTC. Defaults to BTC if no value is passed.

isolated_account_info = client.get_isolated_account_info()
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "totalConversionBalance": "3.4939947",
        "liabilityConversionBalance": "0.00239066",
        "assets": [
            {
                "symbol": "MANA-USDT",
                "status": "CLEAR",
                "debtRatio": "0",
                "baseAsset": {
                "currency": "MANA",
                "totalBalance": "0",
                "holdBalance": "0",
                "availableBalance": "0",
                "liability": "0",
                "interest": "0",
                "borrowableAmount": "0"
            },
                "quoteAsset": {
                    "currency": "USDT",
                    "totalBalance": "0",
                    "holdBalance": "0",
                    "availableBalance": "0",
                    "liability": "0",
                    "interest": "0",
                    "borrowableAmount": "0"
                }
            },
            {
                "symbol": "EOS-USDC",
                "status": "CLEAR",
                "debtRatio": "0",
                "baseAsset": {
                    "currency": "EOS",
                    "totalBalance": "0",
                    "holdBalance": "0",
                    "availableBalance": "0",
                    "liability": "0",
                    "interest": "0",
                    "borrowableAmount": "0"
                },
                "quoteAsset": {
                    "currency": "USDC",
                    "totalBalance": "0",
                    "holdBalance": "0",
                    "availableBalance": "0",
                    "liability": "0",
                    "interest": "0",
                    "borrowableAmount": "0"
                }
            }
        ]
    }
}
Raises:

KucoinResponseException, KucoinAPIException

margin_get_single_isolated_account_info(symbol, **params)[source]

Get the isolated margin account info for a single symbol

https://www.kucoin.com/docs/rest/margin-trading/isolated-margin/get-single-isolated-margin-account-info

Parameters:

symbol (string) – Name of symbol e.g. KCS-BTC

isolated_account_info = client.get_single_isolated_account_info('EOS-USDC')
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "symbol": "MANA-USDT",
        "status": "CLEAR",
        "debtRatio": "0",
        "baseAsset": {
            "currency": "MANA",
            "totalBalance": "0",
            "holdBalance": "0",
            "availableBalance": "0",
            "liability": "0",
            "interest": "0",
            "borrowableAmount": "0"
        },
        "quoteAsset": {
            "currency": "USDT",
            "totalBalance": "0",
            "holdBalance": "0",
            "availableBalance": "0",
            "liability": "0",
            "interest": "0",
            "borrowableAmount": "0"
        }
    }
}
Raises:

KucoinResponseException, KucoinAPIException

margin_borrow(currency, size, time_in_force, isolated=False, symbol=None, is_hf=False, **params)[source]

Borrow funds for margin trading

https://www.kucoin.com/docs/rest/margin-trading/margin-trading-v3-/margin-borrowing

Parameters:
  • currency (string) – Currency

  • size (string) – Amount to borrow

  • time_in_force (string) – GTC (Good till cancelled) or GTT (Good till time)

  • isolated (bool) – (optional) True for isolated margin, False for cross margin

  • symbol (string) – (optional) Name of symbol e.g. KCS-BTC

  • is_hf (bool) – (optional) true: high frequency borrowing, false: low frequency borrowing; default false

borrow = client.margin_borrow('USDT', '100', 'GTC')
Returns:

ApiResponse

{
    "success": true,
    "code": "200",
    "msg": "success",
    "retry": false,
    "data": {
        "orderNo": "5da6dba0f943c0c81f5d5db5",
        "actualSize": 10
    }
}
Raises:

KucoinResponseException, KucoinAPIException

margin_repay(currency, size, isolated=False, symbol=None, is_hf=False, **params)[source]

Repay borrowed funds for margin trading

https://www.kucoin.com/docs/rest/margin-trading/margin-trading-v3-/repayment

Parameters:
  • currency (string) – Currency

  • size (string) – Amount to repay

  • isolated (bool) – (optional) True for isolated margin, False for cross margin

  • symbol (string) – (optional) Name of symbol e.g. KCS-BTC

  • is_hf (bool) – (optional) true: high frequency borrowing, false: low frequency borrowing; default false

repay = client.margin_repay('USDT', '100')
Returns:

ApiResponse

{
    "success": true,
    "code": "200",
    "msg": "success",
    "retry": false,
    "data": {
        "orderNo": "5da6dba0f943c0c81f5d5db5",
        "actualSize": 10
    }
}
Raises:

KucoinResponseException, KucoinAPIException

margin_get_borrow_history(currency, isolated=False, symbol=None, order_no=None, start=None, end=None, page=None, limit=None, **params)[source]

Get the borrow history for margin trading

https://www.kucoin.com/docs/rest/margin-trading/margin-trading-v3-/get-margin-borrowing-history

Parameters:
  • currency (string) – Currency

  • isolated (bool) – (optional) True for isolated margin, False for cross margin

  • symbol (string) – (optional) Name of symbol e.g. KCS-BTC

  • order_no (string) – (optional) OrderNo

  • start (int) – (optional) Start time as unix timestamp

  • end (int) – (optional) End time as unix timestamp

  • page (int) – (optional) Page number

  • limit (int) – (optional) Number of orders

borrow_history = client.margin_get_borrow_history('USDT')
Returns:

ApiResponse

{
    "currentPage": 1,
    "pageSize": 50,
    "totalNum": 1,
    "totalPage": 1,
    "items": [
        {
            "orderNo": "5da6dba0f943c0c81f5d5db5",
            "symbol": "BTC-USDT",
            "currency": "USDT",
            "size": 10,
            "actualSize": 10,
            "status": "DONE",
            "createdTime": 1555056425000
        }
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

margin_get_repay_history(currency, isolated=False, symbol=None, order_no=None, start=None, end=None, page=None, limit=None, **params)[source]

Get the repay history for margin trading

https://www.kucoin.com/docs/rest/margin-trading/margin-trading-v3-/get-repayment-history

Parameters:
  • currency (string) – Currency

  • isolated (bool) – (optional) True for isolated margin, False for cross margin

  • symbol (string) – (optional) Name of symbol e.g. KCS-BTC

  • order_no (string) – (optional) OrderNo

  • start (int) – (optional) Start time as unix timestamp

  • end (int) – (optional) End time as unix timestamp

  • page (int) – (optional) Page number

  • limit (int) – (optional) Number of orders

repay_history = client.margin_get_repay_history('USDT')
Returns:

ApiResponse

{
    "currentPage": 1,
    "pageSize": 50,
    "totalNum": 1,
    "totalPage": 1,
    "items": {
        "orderNo": "5da6dba0f943c0c81f5d5db5",
        "symbol": "BTC-USDT",
        "currency": "USDT",
        "size": 10,
        "actualSize": 10,
        "status": "DONE",
        "createdTime": 1555056425000
    }
}
Raises:

KucoinResponseException, KucoinAPIException

margin_get_cross_isolated_interest_records(isolated=False, symbol=None, currency=None, start=None, end=None, page=None, limit=None, **params)[source]

Get the cross or isolated margin interest records

https://www.kucoin.com/docs/rest/margin-trading/margin-trading-v3-/get-cross-isolated-margin-interest-records

Parameters:
  • isolated (bool) – (optional) True for isolated margin, False for cross margin

  • symbol (string) – (optional) Name of symbol e.g. KCS-BTC

  • currency (string) – (optional) Currency

  • start (int) – (optional) Start time as unix timestamp

  • end (int) – (optional) End time as unix timestamp

  • page (int) – (optional) Page number

  • limit (int) – (optional) Number of orders

interest_records = client.margin_get_cross_isolated_interest_records()
Returns:

ApiResponse

{
    "currentPage": 1,
    "pageSize": 50,
    "totalNum": 1,
    "totalPage": 1,
    "items": [
        {
            "createdAt": 1697783812257,
            "currency": "XMR",
            "interestAmount": "0.1",
            "dayRatio": "0.001"
        }
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

margin_get_cross_trading_pairs_config(symbol=None, **params)[source]

Get the cross margin trading pairs configuration

https://www.kucoin.com/docs/rest/margin-trading/margin-trading-v3-/get-cross-margin-trading-pairs-configuration

Parameters:

symbol (string) – (optional) Name of symbol e.g. KCS-BTC

trading_pairs_config = client.margin_get_cross_trading_pairs_config()
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "timestamp": 1718779915377,
        "items": [{
            "symbol": "ATOM-USDT",
            "name": "ATOM-USDT",
            "enableTrading": true,
            "market": "USDS",
            "baseCurrency": "ATOM",
            "quoteCurrency": "USDT",
            "baseIncrement": 0.0001,
            "baseMinSize": 0.1,
            "quoteIncrement": 0.0001,
            "quoteMinSize": 0.1,
            "baseMaxSize": 10000000000,
            "quoteMaxSize": 99999999,
            "priceIncrement": 0.0001,
            "feeCurrency": "USDT",
            "priceLimitRate": 0.1,
            "minFunds": 0.1
        }]
    }
}
Raises:

KucoinResponseException, KucoinAPIException

margin_modify_leverage_multiplier(leverage, symbol=None, isolated=False, **params)[source]

Modify the leverage multiplier

https://www.kucoin.com/docs/rest/margin-trading/margin-trading-v3-/modify-leverage-multiplier

Parameters:
  • leverage (int) – Must be greater than 1 and up to two decimal places, and cannot be less than the user’s current debt leverage or greater than the system’s maximum leverage

  • symbol (string) – (optional) Name of symbol e.g. KCS-BTC

  • isolated (bool) – (optional) True for isolated margin, False for cross margin

leverage_multiplier = client.margin_modify_leverage_multiplier(5)
Returns:

ApiResponse

{
    "code": "200000",
    "data": None
}
Raises:

KucoinResponseException, KucoinAPIException

margin_lending_get_currency_info(currency=None, **params)[source]

Get the lending currency info

https://www.kucoin.com/docs/rest/margin-trading/lending-market-v3-/get-currency-information

Parameters:

currency (string) – (optional) Currency

currency_info = client.lending_get_currency_info()
Returns:

ApiResponse

{
    "success": true,
    "code": "200",
    "msg": "success",
    "retry": false,
    "data": [
        {
            "currency": "BTC",
            "purchaseEnable": true,
            "redeemEnable": true,
            "increment": "1",
            "minPurchaseSize": "10",
            "minInterestRate": "0.004",
            "maxInterestRate": "0.02",
            "interestIncrement": "0.0001",
            "maxPurchaseSize": "20000",
            "marketInterestRate": "0.009",
            "autoPurchaseEnable": true
        }
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

margin_lending_get_interest_rate(currency, **params)[source]

Get the interest rate for a currency

https://www.kucoin.com/docs/rest/margin-trading/lending-market-v3-/get-interest-rates

Parameters:

currency (string) – Currency

interest_rate = client.lending_get_interest_rate('BTC')
Returns:

ApiResponse

{
    "success": true,
    "code": "200",
    "msg": "success",
    "retry": false,
    "data": [
        {
            "time": "202303261200",
            "marketInterestRate": "0.003"
        },
        {
            "time": "202303261300",
            "marketInterestRate": "0.004"
        }
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

margin_lending_subscribtion(currency, size, interest_rate, **params)[source]

Subscribe to a lending product

https://www.kucoin.com/docs/rest/margin-trading/lending-market-v3-/subscription

Parameters:
  • currency (string) – Currency

  • size (string) – Amount to subscribe

  • interest_rate (string) – Interest rate

subscription = client.lending_subscribtion('BTC', '10', '0.004')
Returns:

ApiResponse

{
    "success": true,
    "code": "200",
    "msg": "success",
    "retry": false,
    "data": {
        "orderNo": "5da6dba0f943c0c81f5d5db5"
    }
}
Raises:

KucoinResponseException, KucoinAPIException

margin_lending_redemption(currency, size, purchase_order_no, **params)[source]

Redeem a lending product

https://www.kucoin.com/docs/rest/margin-trading/lending-market-v3-/redemption

Parameters:
  • currency (string) – Currency

  • size (string) – Amount to redeem

  • purchase_order_no (string) – OrderNo

redemption = client.lending_redemption('BTC', '10', '5da6dba0f943c0c81f5d5db5')
Returns:

ApiResponse

{
    "success": true,
    "code": "200",
    "msg": "success",
    "retry": false,
    "data": {
        "orderNo": "5da6dba0f943c0c81f5d5db5"
    }
}
Raises:

KucoinResponseException, KucoinAPIException

margin_lending_modify_subscription_orders(currency, purchase_order_no, interest_rate, **params)[source]

Modify subscription orders

https://www.kucoin.com/docs/rest/margin-trading/lending-market-v3-/modify-subscription-orders

Parameters:
  • currency (string) – Currency

  • purchase_order_no (string) – OrderNo

  • interest_rate (string) – Interest rate

modify_subscription = client.lending_modify_subscription_orders('BTC', '5da6dba0f943c0c81f5d5db5', '0.004')
Returns:

ApiResponse

{
    "success": true,
    "code": "200",
    "msg": "success",
    "retry": false
}
Raises:

KucoinResponseException, KucoinAPIException

margin_lending_get_redemtion_orders(currency, status, redeem_order_no=None, page=None, limit=None, **params)[source]

Get redemption orders

https://www.kucoin.com/docs/rest/margin-trading/lending-market-v3-/get-redemption-orders

Parameters:
  • currency (string) – Currency

  • status (string) – Status

  • redeem_order_no (string) – (optional) OrderNo

  • page (int) – (optional) Page number

  • limit (int) – (optional) Number of orders

redemption_orders = client.lending_get_redemtion_orders('BTC', 'DONE')
Returns:

ApiResponse

{
    "currentPage": 1,
    "pageSize": 100,
    "totalNum": 1,
    "totalPage": 1,
    "items": [
        {
            "currency": "BTC",
            "purchaseOrderNo": "5da6dba0f943c0c81f5d5db5",
            "redeemOrderNo": "5da6dbasdffga1f5d5dfsb5",
            "redeemAmount": "300000",
            "receiptAmount": "250000",
            "applyTime": 1669508513820,
            "status": "PENDING"
        }
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

margin_lending_get_subscription_orders(currency, status, purchase_order_no=None, page=None, limit=None, **params)[source]

Get subscription orders

https://www.kucoin.com/docs/rest/margin-trading/lending-market-v3-/get-subscription-orders

Parameters:
  • currency (string) – Currency

  • status (string) – Status

  • purchase_order_no (string) – (optional) OrderNo

  • page (int) – (optional) Page number

  • limit (int) – (optional) Number of orders

subscription_orders = client.lending_get_subscription_orders('BTC', 'DONE')
Returns:

ApiResponse

{
    "currentPage": 1,
    "pageSize": 100,
    "totalNum": 1,
    "totalPage": 1,
    "items": [
        {
            "currency": "BTC",
            "purchaseOrderNo": "5da6dba0f943c0c81f5d5db5",
            "purchaseAmount": "300000",
            "lendAmount": "0",
            "redeemAmount": "300000",
            "interestRate": "0.0003",
            "incomeAmount": "200",
            "applyTime": 1669508513820,
            "status": "DONE"
        }
    ]
}
Raises:

KucoinResponseException, KucoinAPIException

futures_get_max_open_position_size(symbol, price, leverage, **params)[source]

Get the maximum open position size for a symbol

https://www.kucoin.com/docs/rest/futures-trading/positions/get-maximum-open-position-size

Parameters:
  • symbol (string) – Name of symbol e.g. XBTUSDM

  • price (int) – Price

  • leverage (int) – Leverage

max_open_position_size = client.futures_get_max_open_position_size('XBTUSDM', 10000, 10)
Returns:

ApiResponse

# todo: example response
Raises:

KucoinResponseException, KucoinAPIException

futures_get_position(symbol, **params)[source]

Get the position for a symbol

https://www.kucoin.com/docs/rest/futures-trading/positions/get-position-details

Parameters:

symbol – Name of symbol e.g. XBTUSDM

position = client.get_position('XBTUSDM')
Returns:

ApiResponse

# todo: example response
Raises:

KucoinResponseException, KucoinAPIException

futures_get_positions(currency=None, **params)[source]

Get the positions

https://www.kucoin.com/docs/rest/futures-trading/positions/get-position-list

Parameters:

currency (string) – (optional) Currency

positions = client.get_positions()
Returns:

ApiResponse

# todo: example response
Raises:

KucoinResponseException, KucoinAPIException

futures_get_positions_history(symbol=None, start=None, end=None, page=None, limit=None, **params)[source]

Get the positions history

https://www.kucoin.com/docs/rest/futures-trading/positions/get-positions-history

Parameters:
  • symbol (string) – (optional) Name of symbol e.g. XBTUSDM

  • start (int) – (optional) Start time as unix timestamp

  • end (int) – (optional) End time as unix timestamp

  • page (int) – (optional) Page number

  • limit (int) – (optional) Number of requests per page, max 200, default 10

positions_history = client.get_positions_history()
Returns:

ApiResponse

# todo: example response
Raises:

KucoinResponseException, KucoinAPIException

futures_modify_auto_deposit_margin(symbol, status=True, **params)[source]

Modify the auto deposit margin status for a symbol

https://www.kucoin.com/docs/rest/futures-trading/positions/modify-auto-deposit-margin-status

Parameters:
  • symbol (string) – Name of symbol e.g. XBTUSDM

  • status (bool) – Status

auto_deposit_margin = client.modify_auto_deposit_margin('XBTUSDM', True)
Returns:

ApiResponse

# todo: example response
Raises:

KucoinResponseException, KucoinAPIException

futures_get_max_withdraw_margin(symbol, **params)[source]

Get the maximum withdraw margin for a symbol

https://www.kucoin.com/docs/rest/futures-trading/positions/get-max-withdraw-margin

Parameters:

symbol (string) – Name of symbol e.g. XBTUSDM

max_withdraw_margin = client.get_max_withdraw_margin('XBTUSDM')
Returns:

ApiResponse

# todo: example response
Raises:

KucoinResponseException, KucoinAPIException

futures_withdraw_margin(symbol, amount, **params)[source]

Withdraw margin for a symbol

https://www.kucoin.com/docs/rest/futures-trading/positions/remove-margin-manually

Parameters:
  • symbol (string) – Name of symbol e.g. XBTUSDM

  • amount (string) – Amount to withdraw

withdraw_margin = client.withdraw_margin('XBTUSDM', '100')
Returns:

ApiResponse

# todo: example response
Raises:

KucoinResponseException, KucoinAPIException

futures_deposit_margin(symbol, margin, biz_no, **params)[source]

Deposit margin for a symbol

https://www.kucoin.com/docs/rest/futures-trading/positions/add-margin-manually

Parameters:
  • symbol (string) – Name of symbol e.g. XBTUSDM

  • margin (int) – Margin

  • biz_no (string) – Business number

deposit_margin = client.deposit_margin('XBTUSDM', 100, '123456')
Returns:

ApiResponse

# todo: example response
Raises:

KucoinResponseException, KucoinAPIException

futures_get_margin_mode(symbol, **params)[source]

Get the margin mode for a symbol

https://www.kucoin.com/docs/rest/futures-trading/positions/get-margin-mode

Parameters:

symbol (string) – Name of symbol e.g. XBTUSDM

margin_mode = client.get_margin_mode('XBTUSDM')
Returns:

ApiResponse

# todo: example response
Raises:

KucoinResponseException, KucoinAPIException

futures_modify_margin_mode(symbol, mode, **params)[source]

Modify the margin mode for a symbol

https://www.kucoin.com/docs/rest/futures-trading/positions/modify-margin-mode

Parameters:
  • symbol (string) – Name of symbol e.g. XBTUSDM

  • mode (string) – Margin mode (CROSS or ISOLATED)

margin_mode = client.modify_margin_mode('XBTUSDM', 'CROSS')
Returns:

ApiResponse

# todo: example response
Raises:

KucoinResponseException, KucoinAPIException

futures_get_cross_margin_leverage(symbol, **params)[source]

Get the cross margin leverage for a symbol

https://www.kucoin.com/docs/rest/futures-trading/positions/get-cross-margin-leverage

Parameters:

symbol (string) – Name of symbol e.g. XBTUSDM

cross_margin_leverage = client.get_cross_margin_leverage('XBTUSDM')
Returns:

ApiResponse

# todo: example response
Raises:

KucoinResponseException, KucoinAPIException

futures_modify_cross_margin_leverage(symbol, leverage, **params)[source]

Modify the cross margin leverage for a symbol

https://www.kucoin.com/docs/rest/futures-trading/positions/modify-cross-margin-leverage

Parameters:
  • symbol (string) – Name of symbol e.g. XBTUSDM

  • leverage (string) – Leverage

cross_margin_leverage = client.modify_cross_margin_leverage('XBTUSDM', '10')
Returns:

ApiResponse

# todo: example response
Raises:

KucoinResponseException, KucoinAPIException

futures_get_risk_limit_level(symbol, **params)[source]

Get the risk limit level for a symbol

https://www.kucoin.com/docs/rest/futures-trading/risk-limit/get-futures-risk-limit-level

Parameters:

symbol (string) – Name of symbol e.g. XBTUSDM

risk_limit_level = client.futures_get_risk_limit_level('XBTUSDM')
Returns:

ApiResponse

{

“code”: “200000”, “data”: [

{

“symbol”: “ADAUSDTM”, “level”: 1, “maxRiskLimit”: 500, “minRiskLimit”: 0, “maxLeverage”: 20, “initialMargin”: 0.05, “maintainMargin”: 0.025

}, {

”symbol”: “ADAUSDTM”, “level”: 2, “maxRiskLimit”: 1000, “minRiskLimit”: 500, “maxLeverage”: 2, “initialMargin”: 0.5, “maintainMargin”: 0.25

}

]

}

Raises:

KucoinResponseException, KucoinAPIException

futures_modify_risk_limit_level(symbol, level, **params)[source]

Modify the risk limit level for a symbol

https://www.kucoin.com/docs/rest/futures-trading/risk-limit/modify-risk-limit-level

Parameters:
  • symbol (string) – Name of symbol e.g. XBTUSDM

  • level (int) – Risk limit level

risk_limit_level = client.futures_modify_risk_limit_level('XBTUSDM', 2)
Returns:

ApiResponse

{

“code”: “200000”, “data”: true

}

Raises:

KucoinResponseException, KucoinAPIException

futures_get_funding_rate(symbol, **params)[source]

Get the funding rate for a symbol

https://www.kucoin.com/docs/rest/futures-trading/funding-fees/get-current-funding-rate

Parameters:

symbol (string) – Name of symbol e.g. XBTUSDM

funding_rate = client.futures_get_funding_rate('XBTUSDM')
Returns:

ApiResponse

{

“code”: “200000”, “data”: {

”symbol”: “.XBTUSDTMFPI8H”, “granularity”: 28800000, “timePoint”: 1731441600000, “value”: 0.000641, “predictedValue”: 0.000052, “fundingRateCap”: 0.003, “fundingRateFloor”: -0.003

}

}

Raises:

KucoinResponseException, KucoinAPIException

futures_get_public_funding_history(symbol, start, end, **params)[source]

Get the public funding history for a symbol

https://www.kucoin.com/docs/rest/futures-trading/funding-fees/get-public-funding-history

Parameters:
  • symbol (string) – Name of symbol e.g. XBTUSDM

  • start (int) – Start time as unix timestamp

  • end (int) – End time as unix timestamp

funding_history = client.futures_get_public_funding_history('XBTUSDM', 1669508513820, 1669508513820)
Returns:

ApiResponse

{

“success”: true, “code”: “200”, “msg”: “success”, “retry”: false, “data”: [

{

“symbol”: “IDUSDTM”, “fundingRate”: 0.018750, “timepoint”: 1702310700000

}

]

}

Raises:

KucoinResponseException, KucoinAPIException

futures_get_private_funding_history(symbol, start=None, end=None, reverse=True, offset=None, forward=False, max_count=None, **params)[source]

Get the private funding history for a symbol

https://www.kucoin.com/docs/rest/futures-trading/funding-fees/get-private-funding-history

Parameters:
  • symbol (string) – Name of symbol e.g. XBTUSDM

  • start (int) – (optional) Start time as unix timestamp

  • end (int) – (optional) End time as unix timestamp

  • reverse (bool) – (optional) Reverse the results

  • offset (int) – (optional) Offset

  • forward (bool) – (optional) Forward the results

  • max_count (int) – (optional) Maximum number of results

funding_history = client.futures_get_private_funding_history('XBTUSDM')
Returns:

ApiResponse

{
“dataList”: [
{

“id”: 36275152660006, “symbol”: “XBTUSDM”, “timePoint”: 1557918000000, “fundingRate”: 0.000013, “markPrice”: 8058.27, “positionQty”: 10, “positionCost”: -0.001241, “funding”: -0.00000464, “settleCurrency”: “XBT”

}, {

”id”: 36275152660004, “symbol”: “XBTUSDM”, “timePoint”: 1557914400000, “fundingRate”: 0.00375, “markPrice”: 8079.65, “positionQty”: 10, “positionCost”: -0.0012377, “funding”: -0.00000465, “settleCurrency”: “XBT”

}, {

”id”: 36275152660002, “symbol”: “XBTUSDM”, “timePoint”: 1557910800000, “fundingRate”: 0.00375, “markPrice”: 7889.03, “positionQty”: 10, “positionCost”: -0.0012676, “funding”: -0.00000476, “settleCurrency”: “XBT”

}

], “hasMore”: true

}

Raises:

KucoinResponseException, KucoinAPIException

get_ws_endpoint(private=False)[source]

Get websocket channel details

Parameters:

private (bool) – (optional) True for private channel

https://www.kucoin.com/docs/websocket/basic-info/apply-connect-token/public-token-no-authentication-required- https://www.kucoin.com/docs/websocket/basic-info/apply-connect-token/private-channels-authentication-request-required-

ws_details = client.get_ws_endpoint(private=True)
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "token": "2neAiuYvAU737TOajb2U3uT8AEZqSWYe0fBD4LoHuXJDSC7gIzJiH4kNTWhCPISWo6nDpAe7aUYs6Y1N4x9p7wSsRU5m3-PcVsqeGGI9bNupipWRcVoGHnwZIngtMdMrjqPnP-biofFWbNaP1cl0X1pZc2SQ-33hDH1LgNP-yg89NEzuQg4KjtLDa9zSoVaC.rc5an2wAXOiNB42guxeKhQ==",
        "instanceServers": [
            {
                "endpoint": "wss://ws-api-spot.kucoin.com/",
                "encrypt": true,
                "protocol": "websocket",
                "pingInterval": 18000,
                "pingTimeout": 10000
            }
        ]
    }
}
Raises:

KucoinResponseException, KucoinAPIException

futures_get_ws_endpoint(private=False)[source]

Get websocket futures channel details

Parameters:

private (bool) – (optional) True for private channel

https://www.kucoin.com/docs/websocket/basic-info/apply-connect-token/public-token-no-authentication-required- https://www.kucoin.com/docs/websocket/basic-info/apply-connect-token/private-channels-authentication-request-required-

ws_details = client.futures_get_ws_endpoint(private=True)
Returns:

ApiResponse

{
    "code": "200000",
    "data": {
        "token": "2neAiuYvAU737TOajb2U3uT8AEZqSWYe0fBD4LoHuXJDSC7gIzJiH4kNTWhCPISWo6nDpAe7aUYs6Y1N4x9p7wSsRU5m3-PcVsqeGGI9bNupipWRcVoGHnwZIngtMdMrjqPnP-biofFWbNaP1cl0X1pZc2SQ-33hDH1LgNP-yg9a0FbYvs_Bct6QYKlTjDiL.uo5fqwmeBei2enyEh62Qvg==",
        "instanceServers": [
            {
                "endpoint": "wss://ws-api-futures.kucoin.com/",
                "encrypt": true,
                "protocol": "websocket",
                "pingInterval": 18000,
                "pingTimeout": 10000
            }
        ]
    }
}
Raises:

KucoinResponseException, KucoinAPIException

get_user_info()[source]

Get account summary info

https://www.kucoin.com/docs/rest/account/basic-info/get-account-summary-info

user_info = client.get_user_info()
Returns:

ApiResponse

{
    "level": 0,
    "subQuantity": 5,
    "maxDefaultSubQuantity": 5,
    "maxSubQuantity": 5,
    "spotSubQuantity": 5,
    "marginSubQuantity": 5,
    "futuresSubQuantity": 5,
    "maxSpotSubQuantity": 0,
    "maxMarginSubQuantity": 0,
    "maxFuturesSubQuantity": 0
}
Raises:

KucoinResponseException, KucoinAPIException

exceptions module

exception kucoin.exceptions.KucoinAPIException(response, status_code, text)[source]

Bases: Exception

Exception class to handle general API Exceptions

code values

message format

__init__(response, status_code, text)[source]
exception kucoin.exceptions.KucoinRequestException(message)[source]

Bases: Exception

__init__(message)[source]
exception kucoin.exceptions.MarketOrderException(message)[source]

Bases: Exception

__init__(message)[source]
exception kucoin.exceptions.LimitOrderException(message)[source]

Bases: Exception

__init__(message)[source]