HitBTC Websocket API Client Code Reference¶
HitBTC WSS API V2.0 Client.
The Client Object¶
-
class
hitbtc.client.
HitBTC
(key=None, secret=None, raw=None, stdout_only=False, silent=False, url=None, **conn_ops)[source]¶ HitBTC Websocket API Client class.
Programmed using the official API documentation as a reference.
- Documentation can be found here:
- https://api.hitbtc.com/?python#socket-api-reference
-
cancel_order
(custom_id=None, **params)[source]¶ Cancel an order via Websocket.
- Offical Endpoint Documentation:
- https://api.hitbtc.com/?python#cancel-order
-
credentials_given
¶ Assert if credentials are complete.
-
login
(key=None, secret=None, basic=None, custom_nonce=None)[source]¶ Login using the WSS API.
- Offical Endpoint Documentation:
- https://api.hitbtc.com/?python#socket-session-authentication
-
place_order
(custom_id=None, **params)[source]¶ Place a new order via Websocket.
- Offical Endpoint Documentation:
- https://api.hitbtc.com/?python#place-new-order
-
replace_order
(custom_id=None, **params)[source]¶ Replace an existing order via Websocket.
- Offical Endpoint Documentation:
- https://api.hitbtc.com/?python#cancel-replace-orders
-
request_active_orders
(custom_id=None, **params)[source]¶ Request your account’s active orders.
This requires you to be logged-in! Call
login()
first!- Offical Endpoint Documentation:
- https://api.hitbtc.com/?python#get-active-orders-2
-
request_balance
(custom_id=None, **params)[source]¶ Request your account’s balance.
This requires you to be logged-in! Call
login()
first.- Offical Endpoint Documentation:
- https://api.hitbtc.com/?python#get-trading-balance
-
request_currencies
(custom_id=None, **params)[source]¶ Request currencies currently listed at HitBTC.
- Offical Endpoint Documentation:
- https://api.hitbtc.com/?python#get-currencies
-
request_symbols
(custom_id=None, **params)[source]¶ Request symbols currently traded at HitBTC.
- Offical Endpoint Documentation:
- https://api.hitbtc.com/?python#get-symbols
-
request_trades
(custom_id=None, **params)[source]¶ Request trades executed at HitBTC.
- Offical Endpoint Documentation:
- https://api.hitbtc.com/?python#get-trades
-
subscribe_book
(cancel=False, custom_id=None, **params)[source]¶ Request a stream for order book data.
- Offical Endpoint Documentation:
- https://api.hitbtc.com/?python#subscribe-to-orderbook
-
subscribe_candles
(cancel=False, custom_id=None, **params)[source]¶ Request a stream for candle data.
- Offical Endpoint Documentation:
- https://api.hitbtc.com/?python#subscribe-to-candles
-
subscribe_reports
(cancel=False, custom_id=None, **params)[source]¶ Request a stream of your account’s order activities.
This requires you to be logged-in! Call
HitBTC.login()
first!- Offical Endpoint Documentation:
- https://api.hitbtc.com/?python#subscribe-to-reports
-
subscribe_ticker
(cancel=False, custom_id=None, **params)[source]¶ Request a stream for ticker data.
- Offical Endpoint Documentation:
- https://api.hitbtc.com/?python#subscribe-to-ticker
-
subscribe_trades
(cancel=False, custom_id=None, **params)[source]¶ Request a stream for trade data.
- Offical Endpoint Documentation:
- https://api.hitbtc.com/?python#subscribe-to-trades
The Connector Object¶
-
class
hitbtc.connector.
HitBTCConnector
(url=None, raw=None, stdout_only=False, silent=False, **conn_ops)[source]¶ Class to pre-process HitBTC data, before putting it on the internal queue.
Data on the queue is available as a 3-item-tuple by default.
- Response items on the queue are formatted as:
- (‘Response’, ‘Success’ or ‘Failure’, (request, response))
‘Success’ indicates a successful response and ‘Failure’ a failed one.
request
is the original payload sent by the client andresponse
the related response object from the server.- Stream items on the queue are formatted as:
- (method, symbol, params)
You can disable extraction and handling by passing ‘raw=True’ on instantiation. Note that this will also turn off recording of sent requests, as well all logging activity.
The Websocket APP Object¶
-
class
hitbtc.wss.
WebSocketConnector
(url, timeout=None, q_maxsize=None, reconnect_interval=None, log_level=None)[source]¶ Websocket Connection Thread.
Inspired heavily by ekulyk’s PythonPusherClient Connection Class https://github.com/ekulyk/PythonPusherClient/blob/master/pusherclient/connection.py
Data received is available by calling WebSocketConnection.recv()
-
pass_up
(data, recv_at)[source]¶ Pass data up to the client via the internal Queue().
Parameters: - data – data to be passed up
- recv_at – float, time of reception
Returns:
-
recv
(block=True, timeout=None)[source]¶ Wrap for self.q.get().
Parameters: - block – Whether or not to make the call to this method block
- timeout – Value in seconds which determines a timeout for get()
Returns:
-