Websocket Example Code (Python)
Here you can see an example for Kucoin Websocket SDK for Future.
π Position change In Future Websocket
# Future API keys
api_key=""
api_secret=""
api_passphrase=""
import asyncio
from kucoin_futures.client import WsToken
from kucoin_futures.ws_client import KucoinFuturesWsClient
async def main():
async def deal_msg(msg):
if msg['topic'] == '/contract/position:XBTUSDM':
print(f'Position Change:{msg["data"]}')
elif msg['topic'] == '/contractMarket/tradeOrders':
print({msg["data"]})
# is private
client = WsToken(key=api_key, secret=api_secret, passphrase=api_passphrase, is_sandbox=False, url="https://api-futures.kucoin.com")
ws_client = await KucoinFuturesWsClient.create(loop, client, deal_msg, private=False)
await ws_client.subscribe('/contract/position:XBTUSDM')
while True:
await asyncio.sleep(60)
KuCoin Learning Center
Here you can see an example for Kucoin Websocket SDK for Future.
π Position change In Future Websocket
# Future API keys
api_key=""
api_secret=""
api_passphrase=""
import asyncio
from kucoin_futures.client import WsToken
from kucoin_futures.ws_client import KucoinFuturesWsClient
async def main():
async def deal_msg(msg):
if msg['topic'] == '/contract/position:XBTUSDM':
print(f'Position Change:{msg["data"]}')
elif msg['topic'] == '/contractMarket/tradeOrders':
print({msg["data"]})
# is private
client = WsToken(key=api_key, secret=api_secret, passphrase=api_passphrase, is_sandbox=False, url="https://api-futures.kucoin.com")
ws_client = await KucoinFuturesWsClient.create(loop, client, deal_msg, private=False)
await ws_client.subscribe('/contract/position:XBTUSDM')
while True:
await asyncio.sleep(60)
KuCoin Learning Center
β
We need your feedback about new API FUTURE Help Document.
We have recently released the new API HELP Document. It is an updated version to old help document. The new API FUTURE interface will be ready soon. It is currently in testing phase.
But before that, we like to hear your feedback/suggestions about new help document to improve the quality and readability of our new FUTURE help document.
So in case you were willing to help us or engage in providing useful feedback to us, please kindly check new FURUE API HELP and then send your feedback to our API Community manager, Hed.
Thanks for your active participation.
KuCoin Learning Center
We have recently released the new API HELP Document. It is an updated version to old help document. The new API FUTURE interface will be ready soon. It is currently in testing phase.
But before that, we like to hear your feedback/suggestions about new help document to improve the quality and readability of our new FUTURE help document.
So in case you were willing to help us or engage in providing useful feedback to us, please kindly check new FURUE API HELP and then send your feedback to our API Community manager, Hed.
Thanks for your active participation.
KuCoin Learning Center
FAQ Book V 3.0.pdf
547.5 KB
FAQ V 3.0
π₯ FAQ book of API questions has been updated.
Please study for most asked API questions.
KuCoin Learning Center
π₯ FAQ book of API questions has been updated.
Please study for most asked API questions.
KuCoin Learning Center
KuCoin Launches an Exclusive VIP Service Channel
Dear Valued KuCoin Client,
To provide better services for our VIP clients, KuCoin is launching an Exclusive VIP Service Channel for faster and more effective trading solutions.
At the moment, we are inviting VIPs from Level 5 and above to join the Exclusive VIP Service Channel. And we will expand the services to broaden the clientsβ scope in the future.
How to apply for the KuCoin Exclusive VIP Service:
1. Please make sure your KuCoin VIP Level is 5 and above.
2. Please send your KuCoin UID, current VIP Level, and your Telegram account to vip@kucoin.com.
3. A KuCoin Exclusive VIP Service group will be set up for you.
For more information, please contact vip@kucoin.com
KuCoin Learning Center
Dear Valued KuCoin Client,
To provide better services for our VIP clients, KuCoin is launching an Exclusive VIP Service Channel for faster and more effective trading solutions.
At the moment, we are inviting VIPs from Level 5 and above to join the Exclusive VIP Service Channel. And we will expand the services to broaden the clientsβ scope in the future.
How to apply for the KuCoin Exclusive VIP Service:
1. Please make sure your KuCoin VIP Level is 5 and above.
2. Please send your KuCoin UID, current VIP Level, and your Telegram account to vip@kucoin.com.
3. A KuCoin Exclusive VIP Service group will be set up for you.
For more information, please contact vip@kucoin.com
KuCoin Learning Center
π₯ KuCoin VIP Invitation: Trade To Share 200,000 USDT!π°π°
KuCoin will be launching special promotions to thank you for your continued support. We sincerely invite you to join our trading campaign to share a 200,000 USDT prize pool!
Promotion Period: 08:00 on June 17, 2022 - 08:00 on June 30, 2022 (All times UTC)
β Phase I: 08:00 on June 17, 2022 - 08:00 on June 23, 2022 (UTC)
β Phase II: 08:00 on June 23, 2022 - 08:00 on June 30, 2022 (UTC)
Who Can Participate?
Users will have chance to share 200,000 USDT by completing the following tasks:
Β· 7-Day Spot trading volume from June 10, 2022 to 16:00 on June 16, 2022 (UTC) exceed 100,000 USDT.
OR
Β· 7-Day Futures trading volume from June 10, 2022 to 16:00 on June 16, 2022 (UTC) exceed 200,000 USDT.
The prize pool for this campaign is 200,000 USDT. Rewards will be distributed within 15 working days of the campaign ending. During the campaign, we will calculate the total trading volume and increase rate from the previous day.
More ...
KuCoin Learning Center
KuCoin will be launching special promotions to thank you for your continued support. We sincerely invite you to join our trading campaign to share a 200,000 USDT prize pool!
Promotion Period: 08:00 on June 17, 2022 - 08:00 on June 30, 2022 (All times UTC)
β Phase I: 08:00 on June 17, 2022 - 08:00 on June 23, 2022 (UTC)
β Phase II: 08:00 on June 23, 2022 - 08:00 on June 30, 2022 (UTC)
Who Can Participate?
Users will have chance to share 200,000 USDT by completing the following tasks:
Β· 7-Day Spot trading volume from June 10, 2022 to 16:00 on June 16, 2022 (UTC) exceed 100,000 USDT.
OR
Β· 7-Day Futures trading volume from June 10, 2022 to 16:00 on June 16, 2022 (UTC) exceed 200,000 USDT.
The prize pool for this campaign is 200,000 USDT. Rewards will be distributed within 15 working days of the campaign ending. During the campaign, we will calculate the total trading volume and increase rate from the previous day.
More ...
KuCoin Learning Center
π― API Quiz of the Week with Prize (Fifth Week)π
π’ To test our API knowledge and also have some fun, every week we will have a simple quiz with small prizes for three winners. You can find the answer in the Learning Center posts or in Help Document contents.
π Open this Online Quiz and take the quiz.
π Prize: 5 USDT for three random winners.
π Answer Source: Help Document and Learning Center
β° You can answer the quiz from today till tomorrow noon.
Good luck and Enjoy using API ππ
KuCoin Learning Center
π’ To test our API knowledge and also have some fun, every week we will have a simple quiz with small prizes for three winners. You can find the answer in the Learning Center posts or in Help Document contents.
π Open this Online Quiz and take the quiz.
π Prize: 5 USDT for three random winners.
π Answer Source: Help Document and Learning Center
β° You can answer the quiz from today till tomorrow noon.
Good luck and Enjoy using API ππ
KuCoin Learning Center
KuCoin Learning Center
π― API Quiz of the Week with Prize (Fifth Week)π π’ To test our API knowledge and also have some fun, every week we will have a simple quiz with small prizes for three winners. You can find the answer in the Learning Center posts or in Help Document contents.β¦
π API Quiz Winners
π Congrats to this week API Quiz Winners.
π Every Thursday or Friday, we will have a simple API quiz to test our knowledge and have some API fun together. For each Quiz there will be 3 random winners by lucky draw.
π Here is the winners list for this week Quiz
1. UID: 69931712
2. UID: 154713554
3. UID: 90013778
π₯Congrats to all winners. We will give you each 5 USDT as reward.
Don't miss the next one...
KuCoin Learning Center
π Congrats to this week API Quiz Winners.
π Every Thursday or Friday, we will have a simple API quiz to test our knowledge and have some API fun together. For each Quiz there will be 3 random winners by lucky draw.
π Here is the winners list for this week Quiz
1. UID: 69931712
2. UID: 154713554
3. UID: 90013778
π₯Congrats to all winners. We will give you each 5 USDT as reward.
Don't miss the next one...
KuCoin Learning Center
β
Long Order Example in Future
In below example we have tried to clarify the details of placing a Long Order via KuCoin API.
π‘ The complete process requires 3 orders:
1. First order to open a position.
2. Second is the TP order.
3. Third one is SL order.
π Example
Symbol: XBTUSDTM
1. The opening price/entry Price is: 21000
side: BUY/LONG
Position quantity: 10
SL price: 20000
TP price: 22000
Then you need to place 2 orders:
2. For TP orderοΌthe important parameters set are as follows:
side: sell
stop: up
stopPriceType: TP, IP or MP (TP for trade price, MP for mark price, and IP for index price)
stopPrice: 21900 (Recommended between 21000 and 22000)
price: 22000
3. For SL orderοΌthe important parameters set are as follows:
side: sell
stop: down
stopPriceType: TP, IP or MP (TP for trade price, MP for mark price, and IP for index price)
stopPrice: 20100 (Recommended between 20000 and 21000)
price: 20000
KuCoin Learning Center
In below example we have tried to clarify the details of placing a Long Order via KuCoin API.
π‘ The complete process requires 3 orders:
1. First order to open a position.
2. Second is the TP order.
3. Third one is SL order.
π Example
Symbol: XBTUSDTM
1. The opening price/entry Price is: 21000
side: BUY/LONG
Position quantity: 10
SL price: 20000
TP price: 22000
Then you need to place 2 orders:
2. For TP orderοΌthe important parameters set are as follows:
side: sell
stop: up
stopPriceType: TP, IP or MP (TP for trade price, MP for mark price, and IP for index price)
stopPrice: 21900 (Recommended between 21000 and 22000)
price: 22000
3. For SL orderοΌthe important parameters set are as follows:
side: sell
stop: down
stopPriceType: TP, IP or MP (TP for trade price, MP for mark price, and IP for index price)
stopPrice: 20100 (Recommended between 20000 and 21000)
price: 20000
KuCoin Learning Center
π₯π₯π₯ Third AMA is coming...
π This week we don't have weekly quiz, but instead, we are preparing for our Third API AMA on Wednesday, 29th of June.
Get ready for exciting event ππ
KuCoin Learning Center
π This week we don't have weekly quiz, but instead, we are preparing for our Third API AMA on Wednesday, 29th of June.
Get ready for exciting event ππ
KuCoin Learning Center
π KuCoin Adds OCO Order Type π
KuCoin has enabled OCO order types (One Cancels the Other) to the WEB trading interface. App clients will have the OCO order type enabled at a later date.
What is an OCO order?
A One-Cancels-the-Other (OCO) is a pair of orders combining a stop-limit order and a limit maker order on the same side, with the same quantity. When either one of the orders is executed (the stop price is triggered for stop limit order), the other one is automatically canceled. And when canceling either one of the orders, the entire OCO pair is canceled.
For further information on how to use or execute OCO orders, refer to our guideοΌ
Everything you Need to Know About OCO Orders: KuCoin Tutorial
KuCoin Learning Center
KuCoin has enabled OCO order types (One Cancels the Other) to the WEB trading interface. App clients will have the OCO order type enabled at a later date.
What is an OCO order?
A One-Cancels-the-Other (OCO) is a pair of orders combining a stop-limit order and a limit maker order on the same side, with the same quantity. When either one of the orders is executed (the stop price is triggered for stop limit order), the other one is automatically canceled. And when canceling either one of the orders, the entire OCO pair is canceled.
For further information on how to use or execute OCO orders, refer to our guideοΌ
Everything you Need to Know About OCO Orders: KuCoin Tutorial
KuCoin Learning Center
π₯Third KuCoin API AMA with Prizes π₯
π₯We are pleased to announce our Third API AMA on KuCoin API Learning Center Channelπ₯βοΈ
πΈπ΅In this AMA, thereβs a big prize pool waiting for users who ask the best API related questions from the AMA Questionnaire form or free asking in AMA, first served!π
β° Time: Wednesday June 29th, 2022 at 12 P.M (UTC)
βοΈ Duration: 30 to 40 minutes
π΅ Where: Learning Center Channel (Voice AMA)
β You need to be a member of our main API Telegram Group
β You should be a KuCoin user. If not, register HERE
β You can submit your questions to be answered during AMA via this Question Form
π₯Good Questions will have rewardsπ₯
We can't wait to meet you thereπ·
π€Agenda
Part 1οΈβ£ A brief talk about KuCoin API Team and new releases. Short talk with volunteers.
Part 2οΈβ£ An overview on recent changes and upgrades
Part 3οΈβ£ AMA and Free Talk
KuCoin Learning Center channel
π₯We are pleased to announce our Third API AMA on KuCoin API Learning Center Channelπ₯βοΈ
πΈπ΅In this AMA, thereβs a big prize pool waiting for users who ask the best API related questions from the AMA Questionnaire form or free asking in AMA, first served!π
β° Time: Wednesday June 29th, 2022 at 12 P.M (UTC)
βοΈ Duration: 30 to 40 minutes
π΅ Where: Learning Center Channel (Voice AMA)
β You need to be a member of our main API Telegram Group
β You should be a KuCoin user. If not, register HERE
β You can submit your questions to be answered during AMA via this Question Form
π₯Good Questions will have rewardsπ₯
We can't wait to meet you thereπ·
π€Agenda
Part 1οΈβ£ A brief talk about KuCoin API Team and new releases. Short talk with volunteers.
Part 2οΈβ£ An overview on recent changes and upgrades
Part 3οΈβ£ AMA and Free Talk
KuCoin Learning Center channel
π Less than 2 hours left to AMA...
π₯ Third API AMA π₯
π It will happen HERE in Learning Center
KuCoin Learning Center channel
π₯ Third API AMA π₯
π It will happen HERE in Learning Center
KuCoin Learning Center channel
π₯π₯π₯
Less than one hour has left to our AMA...
Get ready for the awesome AMA.
Where : Voice AMA in KuCoin Learning Center
See you soonπ
KuCoin Learning Center channel
Less than one hour has left to our AMA...
Get ready for the awesome AMA.
Where : Voice AMA in KuCoin Learning Center
See you soonπ
KuCoin Learning Center channel
π₯π₯π₯AMA will start in 10 minutes here.
It is in Voice mode
π€Agenda
Part 1οΈβ£ A brief talk about KuCoin API Team and new releases. Short talk with volunteers.
Part 2οΈβ£ An overview on recent changes and upgrades
Part 3οΈβ£ AMA and Free Talk
KuCoin Learning Center channel
It is in Voice mode
π€Agenda
Part 1οΈβ£ A brief talk about KuCoin API Team and new releases. Short talk with volunteers.
Part 2οΈβ£ An overview on recent changes and upgrades
Part 3οΈβ£ AMA and Free Talk
KuCoin Learning Center channel
Telegram
KuCoin Learning Center
Kucoin Learning Center (API Knowledge)
Discussion Group: https://t.me/KuCoin_API
API Notification Channel: https://t.me/KuCoin_API_Notify
Discussion Group: https://t.me/KuCoin_API
API Notification Channel: https://t.me/KuCoin_API_Notify
π How to make API keys in Sub-account?
Sub-account has their own API keys. We have explained the steps in above Image. Those steps are:
1. Go to sub-account menu under main menu.
2. Make a sub-account.
3. In sub-account list, find the sub-account name you just created.
4. When you found it, on items in front of it, look for view
5. Click on view
6. On new page that opens, you can make API keys
KuCoin Learning Center channel
Sub-account has their own API keys. We have explained the steps in above Image. Those steps are:
1. Go to sub-account menu under main menu.
2. Make a sub-account.
3. In sub-account list, find the sub-account name you just created.
4. When you found it, on items in front of it, look for view
5. Click on view
6. On new page that opens, you can make API keys
KuCoin Learning Center channel
Media is too big
VIEW IN TELEGRAM
π₯π₯ Recorded Video of Third KuCoin API AMAπ₯π₯
β For those who might miss our Third API AMA, here is a high quality recorded video of it.
π In this AMA, we talked about recent upgrades in API version of Futures and Spot and mostly we covered new features of new API Futures which has been released recently.
π Our Third AMA was announced HERE. Don't miss the next AMA
KuCoin Learning Center channel
β For those who might miss our Third API AMA, here is a high quality recorded video of it.
π In this AMA, we talked about recent upgrades in API version of Futures and Spot and mostly we covered new features of new API Futures which has been released recently.
π Our Third AMA was announced HERE. Don't miss the next AMA
KuCoin Learning Center channel
KuCoin Learning Center
π₯π₯ Recorded Video of Third KuCoin API AMAπ₯π₯ β
For those who might miss our Third API AMA, here is a high quality recorded video of it. π In this AMA, we talked about recent upgrades in API version of Futures and Spot and mostly we covered new features ofβ¦
Third AMA Powerpoint.pdf
2.3 MB
KuCoin Learning Center
π₯Third KuCoin API AMA with Prizes π₯ π₯We are pleased to announce our Third API AMA on KuCoin API Learning Center Channelπ₯βοΈ πΈπ΅In this AMA, thereβs a big prize pool waiting for users who ask the best API related questions from the AMA Questionnaire form orβ¦
π Third KuCoin API AMA Winnersπ
π Here is the winner list of the third AMA on June 29th.
πCongratulations to the winners. The rewards will be distributed within 7 business days.
π Don't miss the next one
KuCoin Learning Center channel
π Here is the winner list of the third AMA on June 29th.
πCongratulations to the winners. The rewards will be distributed within 7 business days.
π Don't miss the next one
KuCoin Learning Center channel