API Specification

QuadrigaClient

class quadriga.client.QuadrigaClient(api_key=None, api_secret=None, client_id=None, timeout=None, session=None, logger=None)

Python client for QuadrigaCX’s REST API v2.

Parameters:
  • api_key (str | unicode) – QuadrigaCX API key.
  • api_secret (str | unicode) – QuadrigaCX API secret.
  • client_id (str | unicode | int) – QuadrigaCX client ID (number used for user login).
  • timeout (int | float) – Number of seconds to wait for QuadrigaCX to respond to an API request.
  • session (requests.Session) – User-defined requests.Session object. If not set, requests.Session() is used by default.
  • logger (logging.Logger) – Logger to record debug messages with. If not set, logging.getLogger('quadriga') is used by default.
Variables:
  • version (str | unicode) – Client version.
  • url (str | unicode) – QuadrigaCX API base URL.
  • order_books ([str | unicode]) – Order books supported.
  • major_currencies (dict) – Major currencies supported.

Note

Parameters api_key, api_secret and client_id are optional. See Public API for details.

book(name)

Return an API wrapper for the given order book.

Parameters:name (str | unicode) – Order book name (e.g. “btc_cad”).
Returns:Order book API wrapper.
Return type:quadriga.book.OrderBook
Raises:InvalidOrderBookError – If an invalid order book is given.

Example:

>>> from quadriga import QuadrigaClient
>>>
>>> client = QuadrigaClient()
>>>
>>> eth = client.book('eth_cad').get_ticker()  
>>> btc = client.book('btc_cad').get_ticker()  
cancel_order(order_id)

Cancel an open order by ID (64 hexadecmial characters).

Parameters:order_id (str | unicode) – Order ID.
Returns:True if the order was cancelled successfully.
Return type:bool
get_balance()

Return user’s account balance.

Returns:User’s account balance.
Return type:dict
get_deposit_address(currency)

Return the deposit address for the given major currency.

Parameters:currency (str | unicode) – Major currency name in lowercase (e.g. “btc”, “eth”).
Returns:Deposit address.
Return type:str | unicode
lookup_order(order_id)

Look up one or more orders by ID (64 hexadecmial characters).

Parameters:order_id (str | unicode | [str | unicode]) – Order ID or list of order IDs.
Returns:Order details.
Return type:[dict]
withdraw(currency, amount, address)

Withdraw a major currency from QuadrigaCX to the given wallet.

Parameters:
  • currency (str | unicode) – Major currency name in lowercase (e.g. “btc”, “eth”).
  • amount (int | float | str | unicode | decimal.Decimal) – Withdrawal amount.
  • address (str | unicode) – Wallet address.

Warning

Specifying incorrect major currency or wallet address could result in permanent loss of your coins. Please be careful when using this method!

OrderBook

class quadriga.book.OrderBook(name, rest_client, logger)

API wrapper for an order book on QuadrigaCX.

This class is not meant to be imported or instantiated directly. Use method quadriga.client.QuadrigaClient.book() instead.

buy_limit_order(amount, price)

Place a buy order at the given limit price.

Parameters:
  • amount (int | float | str | unicode | decimal.Decimal) – Amount of major currency to buy at limit price.
  • price (int | float | str | unicode | decimal.Decimal) – Limit price.
Returns:

Order details.

Return type:

dict

buy_market_order(amount)

Place a buy order at market price.

Parameters:amount (int | float | str | unicode | decimal.Decimal) – Amount of major currency to buy at market price.
Returns:Order details.
Return type:dict
get_public_orders(group=False)

Return public orders that are currently open.

Parameters:group (bool) – If set to True (default: False), orders with the same price are grouped.
Returns:Public orders currently open.
Return type:dict
get_public_trades(time_frame=u'hour')

Return public trades that were completed recently.

Parameters:time_frame (str | unicode) – Time frame. Allowed values are “minute” for trades in the last minute, or “hour” for trades in the last hour (default: “hour”).
Returns:Public trades completed recently.
Return type:[dict]
get_ticker()

Return the latest ticker information.

Returns:Latest ticker information.
Return type:dict
get_user_orders()

Return user’s orders that are currently open.

Returns:User’s orders currently open.
Return type:[dict]
get_user_trades(limit=0, offset=0, sort=u'desc')

Return user’s trade history.

Parameters:
  • limit (int) – Maximum number of trades to return. If set to 0 or lower, all trades are returned (default: 0).
  • offset (int) – Number of trades to skip.
  • sort (str | unicode) – Method used to sort the results by date and time. Allowed values are “desc” for descending order, and “asc” for ascending order (default: “desc”).
Returns:

User’s trade history.

Return type:

[dict]

sell_limit_order(amount, price)

Place a sell order at the given limit price.

Parameters:
  • amount (int | float | str | unicode | decimal.Decimal) – Amount of major currency to sell at limit price.
  • price (int | float | str | unicode | decimal.Decimal) – Limit price.
Returns:

Order details.

Return type:

dict

sell_market_order(amount)

Place a sell order at market price.

Parameters:amount (int | float | str | unicode | decimal.Decimal) – Amount of major currency to sell at market price.
Returns:Order details.
Return type:dict