Utilities

Module for rest and websocket utilities

class Operation[source]

An enumeration.

create_cid()[source]

Create a new Client order id. Based on timestamp multiplied to 10k to make it improbable that two actions are assigned the same cid.

Returns:A integer number equal to the current timestamp * 10 thousend.
Return type:int
cid_to_date(cid)[source]

Converts a cid to date string YYYY-MM-DD

Parameters:cid (int) – A cid as it is generated by the function utils.create_cid()
Returns:A string formated date (e.g. YYYY-MM-DD, 2018-10-01)
Return type:str
get_nonce(multiplier)[source]

Returns a nonce used in authentication. Nonce must be an increasing number. If other frameworks have used higher numbers you might need to increase the nonce_multiplier.

TRADE_SYMBOL_MISSING = re.compile('^[a-zA-Z]{6}$')

Regular expression used to match trade symbols without a leading t (e.g. BTCUSD)

FUNDING_SYMBOL_MISSING = re.compile('^[a-zA-Z]{3}$')

Regular expression used to match financing symbols without a leading f (e.g. BTC)

order_symbol(symbol, capital=True)[source]

Convinience function for skipping t or f before symbols for trade and funding orders.

Parameters:
  • symbol (str) – Symbol as a string. For example BTCUSD for trades or BTC for funding.
  • capital (bool) – Boolean to capitalize trading and funding symbols. Capilat symbols are required in v2 of the Bitfinex API. Default: True
get_bitfinex_logger(name)[source]

Utility method for class specific logging