Skip to content

paidafy/kucoin-python-sdk

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

image image

Features

  • Implementation of REST endpoints
  • Simple handling of authentication
  • Response exception handling
  • Implement websockets (note only python3.6+)

update

  • 2024 04/14
  1. [NEW] POST /api/v3/accounts/universal-transfer: User.flex_transfer
  2. [DEPRECATED] Margin.create_borrow_order,use Margin.margin_borrowing instead
  3. [DEPRECATED] Margin.get_borrow_order,use Margin.get_margin_borrowing_history instead
  4. [DEPRECATED] Margin.get_repayment_record
  5. [DEPRECATED] Margin.click_to_repayment,use Margin.repayment instead
  6. [DEPRECATED] Margin.repay_single_order,use Margin.repayment instead
  7. [DEPRECATED] Margin.create_lend_order
  8. [DEPRECATED] Margin.cancel_lend_order
  9. [DEPRECATED] Margin.set_auto_lend
  10. [DEPRECATED] Margin.get_active_order
  11. [DEPRECATED] Margin.get_lent_history
  12. [DEPRECATED] Margin.get_active_list
  13. [DEPRECATED] Margin.get_settled_order
  14. [DEPRECATED] Margin.get_lend_record
  15. [DEPRECATED] Margin.get_lending_market
  16. [DEPRECATED] Margin.get_margin_data
  17. [DEPRECATED] Margin.create_isolated_margin_borrow_order,use Margin.margin_borrowing instead
  18. [DEPRECATED] Margin.quick_repayment,use Margin.repayment instead
  19. [DEPRECATED] Margin.single_repayment,use Margin.repayment instead
  20. [DEPRECATED] Margin.query_repayment_records
  21. [DEPRECATED] Margin.query_outstanding_repayment_records,use Margin.query_single_isolated_margin_account_info instead
  22. [DEPRECATED] Margin.get_repay_record,use Margin.get_margin_account instead
  • 2024 02/26
  1. add Api: margin.get_interest_rates:Get Interest Rates.
  • 2024 02/19
  1. trade.get_hf_filled_list: same to trade.get_hf_transaction_records Get HF Filled List

    • The trade.get_hf_transaction_records method will be removed at some time in the future
  2. trade.get_hf_completed_orders: same to trade.get_filled_hf_order Get HF Completed order list

    • The trade.get_filled_hf_order method will be removed at some time in the future
  • 2024 02/07
  1. margin.get_etf_info: Get Leveraged Token Info.
  2. margin.get_margin_account_Detail: Get Account Detail - Cross Margin.
  3. margin.get_isolated_margin_account_detail: Get Account Detail - Isolated Margin.
  4. margin.get_margin_currencies: Get Cross/Isolated Margin Risk Limit/Currency config.
  5. trade.create_oco_order: Place Order.
  6. trade.cancel_oco_order: Cancel Order by orderId.
  7. trade.cancel_oco_order_by_clientOid: Cancel Order by clientOid.
  8. trade.cancel_all_oco_orders: Cancel Multiple Orders.
  9. trade.get_oco_order_by_orderId: Get Order Info by orderId.
  10. trade.get_oco_order_by_client_oid: Get Order Info by clientOid.
  11. trade.get_oco_orders: Get Order List.
  12. trade.get_oco_order_details: Get Order Details by orderId.
  13. trade.cancel_all_hf_orders: Cancel all HF orders.
  14. customized websocket: ./kucoin/example_customized_ws_private.py | kucoin/example_customized_ws_public.py
  • sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
  1. set api TCP_NODELAY:After instantiating the client, you can cancel the Nagle algorithm through client.TCP_NODELAY=1 (default is 0)
  • kucoin/example_client_TCP_NODELAY.py

Quick Start

Register an account with KuCoin.

To test on the Sandbox with KuCoin Sandbox.

Generate an API Key or Generate an API Key in Sandbox and enable it.

pip install kucoin-python
#  MarketData
from kucoin.client import Market
client = Market(url='https://api.kucoin.com')
# client = Market()

# or connect to Sandbox
# client = Market(url='https://openapi-sandbox.kucoin.com')
# client = Market(is_sandbox=True)

# get symbol kline
klines = client.get_kline('BTC-USDT','1min')

# get symbol ticker
server_time = client.get_server_timestamp()

api_key = '<api_key>'
api_secret = '<api_secret>'
api_passphrase = '<api_passphrase>'

# Trade
from kucoin.client import Trade
client = Trade(key='', secret='', passphrase='', is_sandbox=False, url='')

# or connect to Sandbox
# client = Trade(api_key, api_secret, api_passphrase, is_sandbox=True)

# place a limit buy order
order_id = client.create_limit_order('BTC-USDT', 'buy', '1', '8000')

# place a market buy order   Use cautiously
order_id = client.create_market_order('BTC-USDT', 'buy', size='1')

# cancel limit order 
client.cancel_order('5bd6e9286d99522a52e458de')

# User
from kucoin.client import User
client = User(api_key, api_secret, api_passphrase)

# or connect to Sandbox
# client = User(api_key, api_secret, api_passphrase, is_sandbox=True)

address = client.get_withdrawal_quota('KCS')

Websockets

  • ./kucoin/example_customized_ws_private.py
  • ./kucoin/example_customized_ws_public.py
  • ./kucoin/example_default_ws_public.py

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%