Skip to main content

Simple WebSocket adapter for CoinFLEX's WebSocket API

Project description

WebSocket Adapter

This is a simple CoinFLEX WebSocket adapter.


pip install coinflex-ws


All CoinFLEX WebSocket streams and requests are available in this package.

Import the CoinFLEX WebSocket library and initialise an instance of the client:

import coinflex_ws

ws = coinflex_ws.CoinFLEXWebSocket(
    url="wss://",	# Testnet endpoint; live endpoint is "wss://"
    market='BTC-USD-SWAP-LIN',				# Change markets here
    api_key='',					# API public key generated by
    api_secret=''					# API secret key generated by

API keys, api_key and api_secret, are required to access private streams and requests.

Streaming data and making requests

This wrapper supports all of the WebSocket channels on the docs (

When a get method, such as get_depth(), returns an empty string it indicates that no relevant data has been received by the client yet.

# Subscribe to WebSocket streams

# Public endpoints
# ws.subscribe_liquidation()
# ws.subscribe_trade()
# ws.subscribe_ticker()
# ws.subscribe_kline('60s')
# ws.subscribe_market()

# Private endpoints
# ws.subscribe_balance()
# ws.subscribe_position()
# ws.subscribe_order()

# Order Management
# ws.place_limit_order(1, 'BUY', 10,  0.001, 'GTC', 1)		# clientOrderId, side, price, quantity, time in force, tag
# ws.place_stop_order(1, 'BUY', 50000, 60000, 0.001, 'GTC', 2)  # clientOrderId, side, stopPrice, limitPrice, quantity, time in force, tag
# ws.place_market_order(1, 'BUY', 0.001, time.time())		# clientOrderId, side, quantity, tag
# ws.cancel_order('304397024272106384', 3)				# orderId, tag
# ws.modify_order('304397024272106383', 'BUY', 4000, 0.1, 'modify1')	# orderId, side, price, quantity, tag

# Get responses forever
while True:
    # print(ws.get_liquidation())
    # print(ws.get_trade())
    # print(ws.get_ticker())
    # print(ws.get_kline('60s'))
    # print(ws.get_market())

    # print(ws.get_balance())
    # print(ws.get_position())
    # print(ws.get_order())


See a full usage example in at

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

coinflex-ws-0.1.1.tar.gz (5.9 kB view hashes)

Uploaded source

Built Distribution

coinflex_ws-0.1.1-py3-none-any.whl (6.9 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page