Quoine API¶
client module¶
-
class
quoine.client.
Quoine
(api_token_id, api_secret, vendor_id=None, language=None)[source]¶ Bases:
object
-
API_URL
= 'https://api.quoine.com'¶
-
API_VERSION
= '2'¶
-
SIDE_BUY
= 'buy'¶
-
SIDE_SELL
= 'sell'¶
-
STATUS_FILLED
= 'filled'¶
-
STATUS_LIVE
= 'live'¶
-
STATUS_PARTIAL
= 'partially_filled'¶
-
STATUS_CANCELLED
= 'cancelled'¶
-
ORDER_TYPE_LIMIT
= 'limit'¶
-
ORDER_TYPE_MARKET
= 'market'¶
-
ORDER_TYPE_MARKET_RANGE
= 'market_with_range'¶
-
LEVERAGE_LEVEL_2
= 2¶
-
LEVERAGE_LEVEL_4
= 4¶
-
LEVERAGE_LEVEL_5
= 5¶
-
LEVERAGE_LEVEL_10
= 10¶
-
LEVERAGE_LEVEL_25
= 25¶
-
MARGIN_ORDER_DIRECTION_ONE
= 'one_direction'¶
-
MARGIN_ORDER_DIRECTION_TWO
= 'two_direction'¶
-
MARGIN_ORDER_DIRECTION_NET
= 'netout'¶
-
__init__
(api_token_id, api_secret, vendor_id=None, language=None)[source]¶ Quoine API Client constructor
Parameters: - api_token_id (str.) – Api Token Id
- api_secret (str.) – Api Secret
- vendor_id (str.) – Vendor ID optional
- language (str.) – Langague optional
-
VENDOR_ID
= None¶
-
LANGUAGE
= 'en'¶
-
get_products
()[source]¶ Get the list of all available products
https://developers.quoine.com/#products
products = client.get_products()
Returns: list - List of product dictionaries [ { "id": 5, "product_type": "CurrencyPair", "code": "CASH", "name": "CASH Trading", "market_ask": "48203.05", "market_bid": "48188.15", "indicator": -1, "currency": "JPY", "currency_pair_code": "BTCJPY", "symbol": "¥", "fiat_minimum_withdraw": "1500.0", "pusher_channel": "product_cash_btcjpy_5", "taker_fee": "0.0", "maker_fee": "0.0", "low_market_bid": "47630.99", "high_market_ask": "48396.71", "volume_24h": "2915.627366519999999998", "last_price_24h": "48217.2", "last_traded_price": "48203.05", "last_traded_quantity": "1.0", "quoted_currency": "JPY", "base_currency": "BTC", "exchange_rate": "0.009398151671149725" }, #... ]
Raises: QuoineResponseException, QuoineAPIException
-
get_product
(product_id)[source]¶ Get product details
https://developers.quoine.com/#get-a-product
Parameters: product_id (int) – required product = client.get_product(1)
Returns: list - List of product dictionaries { "id": 5, "product_type": "CurrencyPair", "code": "CASH", "name": "CASH Trading", "market_ask": "48203.05", "market_bid": "48188.15", "indicator": -1, "currency": "JPY", "currency_pair_code": "BTCJPY", "symbol": "¥", "fiat_minimum_withdraw": "1500.0", "pusher_channel": "product_cash_btcjpy_5", "taker_fee": "0.0", "maker_fee": "0.0", "low_market_bid": "47630.99", "high_market_ask": "48396.71", "volume_24h": "2915.62736652", "last_price_24h": "48217.2", "last_traded_price": "48203.05", "last_traded_quantity": "1.0", "quoted_currency": "JPY", "base_currency": "BTC", "exchange_rate": "0.009398151671149725" }
Raises: QuoineResponseException, QuoineAPIException
-
get_order_book
(product_id, full=False)[source]¶ Get order book for a product
https://developers.quoine.com/#get-order-book
Parameters: - product_id (int) – required
- full (bool) – default False, optional
order_book = client.get_order_book(1, full=False)
Returns: API response { "buy_price_levels": [ [ "416.23000", # price "1.75000" # amount ], #... ], "sell_price_levels": [ [ "416.47000", # price "0.28675" # amount ], #... ] }
Raises: QuoineResponseException, QuoineAPIException
-
get_executions
(product_id, limit=None, page=None)[source]¶ Get a list of recent executions from a product (Executions are sorted in DESCENDING order - Latest first)
https://developers.quoine.com/#executions
Parameters: - product_id (int) – required
- limit (int) – How many executions should be returned. Must be <= 1000. Default is 20
- page (int) – From what page the executions should be returned, e.g if limit=20 and page=2, the response would start from the 21st execution. Default is 1
executions = client.get_executions( product_id=1, limit=200)
Returns: API response { "models": [ { "id": 1011880, "quantity": "6.118954", "price": "409.78", "taker_side": "sell", "created_at": 1457370745 }, { "id": 1011791, "quantity": "1.15", "price": "409.12", "taker_side": "sell", "created_at": 1457365585 } ], "current_page": 2, "total_pages": 1686 }
Raises: QuoineResponseException, QuoineAPIException
-
get_executions_since_time
(product_id, timestamp, limit=None)[source]¶ Get a list of executions after a particular time (Executions are sorted in ASCENDING order)
Note this call has an optional limit parameter but no paging.
https://developers.quoine.com/#get-executions-by-timestamp
Parameters: - product_id (int) – required
- timestamp (int (Unix timestamps in seconds)) – Only show executions at or after this timestamp
- limit (int) – How many executions should be returned. Must be <= 1000. Default is 20
import time since = int(time.time()) executions = client.get_executions_since_time( product_id=1, timestamp=since, limit=50)
Returns: API response [ { "id": 960598, "quantity": "5.6", "price": "431.89", "taker_side": "buy", "created_at": 1456705487 }, { "id": 960603, "quantity": "0.06", "price": "431.74", "taker_side": "buy", "created_at": 1456705564 } ]
Raises: QuoineResponseException, QuoineAPIException
-
get_interest_rate_ladder
(currency)[source]¶ Get a list of executions after a particular time (Executions are sorted in ASCENDING order)
https://developers.quoine.com/#interest-rates
Parameters: currency (string) – required (i.e. USD) ladder = client.get_interest_rate_ladder(currency='USD')
Returns: API response { "bids": [ [ "0.00020", "23617.81698" ], [ "0.00040", "50050.42000" ], [ "0.00050", "100000.00000" ] ], "asks": [ ] }
Raises: QuoineResponseException, QuoineAPIException
-
create_order
(order_type, product_id, side, quantity, price=None, price_range=None)[source]¶ Create a limit, market or market with range spot order. This function gives full flexibility for spot orders.
https://developers.quoine.com/#orders
Parameters: - order_type (string) – required - limit, market or market_with_range
- product_id (int) – required
- side (string) – required - buy or sell
- quantity (string) – required quantity to buy or sell
- price (string) – required price per unit of cryptocurrency
- price_range (string) – optional For order_type of market_with_range only, slippage of the order.
order = client.create_order( type=Quoinex.ORDER_TYPE_LIMIT product_id=1, side=Quoinex.SIDE_BUY, quantity='100', price='0.00001')
Returns: API response { "id": 2157474, "order_type": "limit", "quantity": "0.01", "disc_quantity": "0.0", "iceberg_total_quantity": "0.0", "side": "sell", "filled_quantity": "0.0", "price": "500.0", "created_at": 1462123639, "updated_at": 1462123639, "status": "live", "leverage_level": 1, "source_exchange": "QUOINE", "product_id": 1, "product_code": "CASH", "funding_currency": "USD", "currency_pair_code": "BTCUSD", "order_fee": "0.0", "margin_used": "0.0", "margin_interest": "0.0", "unwound_trade_leverage_level": null, }
Raises: QuoineResponseException, QuoineAPIException
-
create_limit_buy
(product_id, quantity, price)[source]¶ Create a limit spot buy order
https://developers.quoine.com/#orders
Parameters: - product_id (int) – required
- quantity (string) – required quantity to buy or sell
- price (string) – required price per unit of cryptocurrency
order = client.create_limit_buy( product_id=1, quantity='100', price='0.00001')
Returns: API response { "id": 2157474, "order_type": "limit", "quantity": "0.01", "disc_quantity": "0.0", "iceberg_total_quantity": "0.0", "side": "sell", "filled_quantity": "0.0", "price": "500.0", "created_at": 1462123639, "updated_at": 1462123639, "status": "live", "leverage_level": 1, "source_exchange": "QUOINE", "product_id": 1, "product_code": "CASH", "funding_currency": "USD", "currency_pair_code": "BTCUSD", "order_fee": "0.0", "margin_used": "0.0", "margin_interest": "0.0", "unwound_trade_leverage_level": null, }
Raises: QuoineResponseException, QuoineAPIException
-
create_limit_sell
(product_id, quantity, price)[source]¶ Create a limit spot sell order
https://developers.quoine.com/#orders
Parameters: - product_id (int) – required
- quantity (string) – required quantity to buy or sell
- price (string) – required price per unit of cryptocurrency
order = client.create_limit_sell( product_id=1, quantity='100', price='0.00001')
Returns: API response { "id": 2157474, "order_type": "limit", "quantity": "0.01", "disc_quantity": "0.0", "iceberg_total_quantity": "0.0", "side": "sell", "filled_quantity": "0.0", "price": "500.0", "created_at": 1462123639, "updated_at": 1462123639, "status": "live", "leverage_level": 1, "source_exchange": "QUOINE", "product_id": 1, "product_code": "CASH", "funding_currency": "USD", "currency_pair_code": "BTCUSD", "order_fee": "0.0", "margin_used": "0.0", "margin_interest": "0.0", "unwound_trade_leverage_level": null, }
Raises: QuoineResponseException, QuoineAPIException
-
create_market_buy
(product_id, quantity, price_range=None)[source]¶ Create a market spot buy order
https://developers.quoine.com/#orders
Parameters: - product_id (int) – required
- quantity (string) – required quantity to buy or sell
- price_range (string) – optional - slippage of the order.
order = client.create_market_buy( product_id=1, quantity='100') # place a market buy with range for slippage order = client.create_market_buy( product_id=1, quantity='100', price_range='0.001')
Returns: API response { "id": 2157474, "order_type": "limit", "quantity": "0.01", "disc_quantity": "0.0", "iceberg_total_quantity": "0.0", "side": "sell", "filled_quantity": "0.0", "price": "500.0", "created_at": 1462123639, "updated_at": 1462123639, "status": "live", "leverage_level": 1, "source_exchange": "QUOINE", "product_id": 1, "product_code": "CASH", "funding_currency": "USD", "currency_pair_code": "BTCUSD", "order_fee": "0.0", "margin_used": "0.0", "margin_interest": "0.0", "unwound_trade_leverage_level": null, }
Raises: QuoineResponseException, QuoineAPIException
-
create_market_sell
(product_id, quantity, price_range=None)[source]¶ Create a market spot sell order
https://developers.quoine.com/#orders
Parameters: - product_id (int) – required
- quantity (string) – required quantity to buy or sell
- price_range (string) – optional - slippage of the order.
order = client.create_market_sell( product_id=1, quantity='100') # place a market sell with range for slippage order = client.create_market_sell( product_id=1, quantity='100', price_range='0.001')
Returns: API response { "id": 2157474, "order_type": "limit", "quantity": "0.01", "disc_quantity": "0.0", "iceberg_total_quantity": "0.0", "side": "sell", "filled_quantity": "0.0", "price": "500.0", "created_at": 1462123639, "updated_at": 1462123639, "status": "live", "leverage_level": 1, "source_exchange": "QUOINE", "product_id": 1, "product_code": "CASH", "funding_currency": "USD", "currency_pair_code": "BTCUSD", "order_fee": "0.0", "margin_used": "0.0", "margin_interest": "0.0", "unwound_trade_leverage_level": null, }
Raises: QuoineResponseException, QuoineAPIException
-
create_margin_order
(order_type, product_id, side, quantity, price, leverage_level=2, price_range=None, funding_currency=None, order_direction=None)[source]¶ Create a leveraged margin order of type limit, market, or market with range
Only available on Quoinex
To trade at any specific leverage level, you will first need to go to margin trading dashboard, click on that leverage level and then confirm to get authorized. Or you can do it using the update_leverage_level function
https://developers.quoine.com/#orders
Parameters: - order_type (string) – required - limit, market or market_with_range
- product_id (int) – required
- side (string) – required - buy or sell
- quantity (string) – required quantity to buy or sell
- price (string) – required price per unit of cryptocurrency
- leverage_level (int) – optional - 2, 4, 5, 10 or 25 (default 2)
- price_range (string) – optional - For order_type of market_with_range only, slippage of the order.
- funding_currency (string) – optional - Currency used to fund the trade with. Default is quoted currency
order = client.create_order( type=Quoinex.ORDER_TYPE_LIMIT product_id=1, side=Quoinex.SIDE_BUY, quantity='100', price='0.00001')
Returns: API response { "id": 2157474, "order_type": "limit", "quantity": "0.01", "disc_quantity": "0.0", "iceberg_total_quantity": "0.0", "side": "sell", "filled_quantity": "0.0", "price": "500.0", "created_at": 1462123639, "updated_at": 1462123639, "status": "live", "leverage_level": 1, "source_exchange": "QUOINE", "product_id": 1, "product_code": "CASH", "funding_currency": "USD", "currency_pair_code": "BTCUSD", "order_fee": "0.0", "margin_used": "0.0", "margin_interest": "0.0", "unwound_trade_leverage_level": null, }
Raises: QuoineResponseException, QuoineAPIException
-
get_order
(order_id)[source]¶ Get an order
https://developers.quoine.com/#get-an-order
Parameters: order_id (int) – required order = client.get_order(order_id=2157479)
Returns: API response { "id": 2157479, "order_type": "limit", "quantity": "0.01", "disc_quantity": "0.0", "iceberg_total_quantity": "0.0", "side": "sell", "filled_quantity": "0.01", "price": "500.0", "created_at": 1462123639, "updated_at": 1462123639, "status": "filled", "leverage_level": 2, "source_exchange": "QUOINE", "product_id": 1, "product_code": "CASH", "funding_currency": "USD", "currency_pair_code": "BTCUSD", "order_fee": "0.0", "margin_used": "0.0", "margin_interest": "0.0", "unwound_trade_leverage_level": null, "executions": [ { "id": 4566133, "quantity": "0.01", "price": "500.0", "taker_side": "buy", "my_side": "sell", "created_at": 1465396785 } ] }
Raises: QuoineResponseException, QuoineAPIException
-
get_orders
(funding_currency=None, product_id=None, status=None, with_details=False, limit=None, page=None)[source]¶ Get a list of orders using filters with pagination
https://developers.quoine.com/#get-orders
Parameters: - funding_currency (string) – optional - filter orders based on funding currency
- product_id (int) – optional - filter orders based on product
- status (string) – optional - filter orders based on status
- with_details (bool) – optional - return full order details (attributes between *) including executions
- limit (int) – optional - page limit
- page (int) – optional - page number
orders = client.get_orders(product_id=1, limit=10)
Returns: API response { "models": [ { "id": 2157474, "order_type": "limit", "quantity": "0.01", "disc_quantity": "0.0", "iceberg_total_quantity": "0.0", "side": "sell", "filled_quantity": "0.0", "price": "500.0", "created_at": 1462123639, "updated_at": 1462123639, "status": "live", "leverage_level": 1, "source_exchange": "QUOINE", "product_id": 1, "product_code": "CASH", "funding_currency": "USD", "currency_pair_code": "BTCUSD", "unwound_trade_leverage_level": null, "order_fee": "0.0", "margin_used": "0.0", "margin_interest": "0.0", "executions": [] } ], "current_page": 1, "total_pages": 1 }
Raises: QuoineResponseException, QuoineAPIException
-
cancel_order
(order_id)[source]¶ Cancel an order
https://developers.quoine.com/#cancel-an-order
Parameters: order_id (int) – required result = client.cancel_order(order_id=2157479)
Returns: API response { "id": 2157474, "order_type": "limit", "quantity": "0.01", "disc_quantity": "0.0", "iceberg_total_quantity": "0.0", "side": "sell", "filled_quantity": "0.0", "price": "500.0", "created_at": 1462123639, "updated_at": 1462123639, "status": "cancelled", "leverage_level": 1, "source_exchange": "QUOINE", "product_id": 1, "product_code": "CASH", "funding_currency": "USD", "currency_pair_code": "BTCUSD" }
Raises: QuoineResponseException, QuoineAPIException
-
update_live_order
(order_id, quantity=None, price=None)[source]¶ Update a live order
https://developers.quoine.com/#edit-a-live-order
Parameters: - order_id (int) – required
- quantity (string) – optional - one or both of quantity or price should be set
- price (string) – optional - one or both of quantity or price should be set
order = client.update_live_order( order_id=2157479, quantity='101', price='0.001')
Returns: API response { "id": 2157474, "order_type": "limit", "quantity": "0.01", "disc_quantity": "0.0", "iceberg_total_quantity": "0.0", "side": "sell", "filled_quantity": "0.0", "price": "500.0", "created_at": 1462123639, "updated_at": 1462123639, "status": "cancelled", "leverage_level": 1, "source_exchange": "QUOINE", "product_id": 1, "product_code": "CASH", "funding_currency": "USD", "currency_pair_code": "BTCUSD" }
Raises: QuoineResponseException, QuoineAPIException
-
get_order_trades
(order_id)[source]¶ Get an orders trades
https://developers.quoine.com/#get-an-order’s-trades
Parameters: order_id (int) – required trades = client.get_order_trades(order_id=2157479)
Returns: API response [ { "id": 57896, "currency_pair_code": "BTCUSD", "status": "closed", "side": "short", "margin_used": "0.83588", "open_quantity": "0.01", "close_quantity": "0.0", "quantity": "0.01", "leverage_level": 5, "product_code": "CASH", "product_id": 1, "open_price": "417.65", "close_price": "417.0", "trader_id": 3020, "open_pnl": "0.0", "close_pnl": "0.0065", "pnl": "0.0065", "stop_loss": "0.0", "take_profit": "0.0", "funding_currency": "USD", "created_at": 1456250726, "updated_at": 1456251837, "close_fee": "0.0", "total_interest": "0.02", "daily_interest": "0.02" } ]
Raises: QuoineResponseException, QuoineAPIException
-
get_my_executions
(product_id, limit=None, page=None)[source]¶ Get list of your executions by product with pagination
https://developers.quoine.com/#get-your-executions
Parameters: - product_id (int) – required
- limit (int) – Limit execution per request
- page (int) – Page
executions = client.get_my_executions(product_id=1)
Returns: API response { "models": [ { "id": 1001232, "quantity": "0.37153179", "price": "390.0", "taker_side": "sell", "my_side": "sell", "created_at": 1457193798 } ], "current_page": 1, "total_pages": 2 }
Raises: QuoineResponseException, QuoineAPIException
-
get_fiat_accounts
()[source]¶ Get list of fiat accounts
https://developers.quoine.com/#get-fiat-accounts
accounts = client.get_fiat_accounts()
Returns: API response [ { "id": 4695, "currency": "USD", "currency_symbol": "$", "balance": "10000.1773", "pusher_channel": "user_3020_account_usd", "lowest_offer_interest_rate": "0.00020", "highest_offer_interest_rate": "0.00060", "exchange_rate": "1.0", "currency_type": "fiat", "margin": "0.0", "free_margin": "10000.1773" } ]
Raises: QuoineResponseException, QuoineAPIException
-
create_fiat_account
(currency)[source]¶ Create a fiat account for a currency
https://developers.quoine.com/#create-a-fiat-account
Parameters: currency (string) – required account = client.create_fiat_accounts(currency='USD')
Returns: API response { "id": 5595, "currency": "USD", "currency_symbol": "$", "balance": "0.0", "pusher_channel": "user_3122_account_usd", "lowest_offer_interest_rate": "0.00020", "highest_offer_interest_rate": "0.00060", "exchange_rate": "1.0", "currency_type": "fiat", "margin": "0.0", "free_margin": "0.0" }
Raises: QuoineResponseException, QuoineAPIException
-
get_crypto_accounts
()[source]¶ Get list of crypto accounts
https://developers.quoine.com/#get-crypto-accounts
accounts = client.get_crypto_accounts()
Returns: API response [ { "id": 4668, "balance": "4.99", "address": "1F25zWAQ1BAAmppNxLV3KtK6aTNhxNg5Hg", "currency": "BTC", "currency_symbol": "฿", "pusher_channel": "user_3020_account_btc", "minimum_withdraw": 0.02, "lowest_offer_interest_rate": "0.00049", "highest_offer_interest_rate": "0.05000", "currency_type": "crypto" } ]
Raises: QuoineResponseException, QuoineAPIException
-
get_account_balances
()[source]¶ Get all account balances
https://developers.quoine.com/#get-all-account-balances
account = client.get_account_balances()
Returns: API response [ { "currency": "BTC", "balance": "0.04925688" }, { "currency": "USD", "balance": "7.17696" }, { "currency": "JPY", "balance": "356.01377" } ]
Raises: QuoineResponseException, QuoineAPIException
-
get_main_asset
()[source]¶ Get name of your main asset with balance
Returns: API response Raises: QuoineResponseException, QuoineAPIException { "currency": "JPY", "total_amount": "23050.04" }
-
create_loan_bid
(rate, quantity, currency)[source]¶ Create a loan bid
https://developers.quoine.com/#create-a-loan-bid
Parameters: - rate (string) – daily interest rate, e.g 0.0002 (0.02%), must be <= 0.07%
- quantity (string) – amount to lend
- currency (string) – lending currency (all available in the system except JPY)
Returns: API response
Raises: QuoineResponseException, QuoineAPIException
{ "id": 3580, "bidask_type": "limit", "quantity": "50.0", "currency": "USD", "side": "bid", "filled_quantity": "0.0", "status": "live", "rate": "0.0002", "user_id": 3020 }
-
get_loan_bid
(currency, limit=None, page=None)[source]¶ Get loan bids
https://developers.quoine.com/#get-loan-bids
Parameters: - currency (string) – lending currency (all available in the system except JPY)
- limit (int) – Limit execution per request
- page (int) – Page
Returns: API response
Raises: QuoineResponseException, QuoineAPIException
{ "id": 3580, "bidask_type": "limit", "quantity": "50.0", "currency": "USD", "side": "bid", "filled_quantity": "0.0", "status": "live", "rate": "0.0002", "user_id": 3020 }
-
close_loan_bid
(loan_bid_id)[source]¶ Close loan bid
https://developers.quoine.com/#close-loan-bid
Parameters: loan_bid_id (int) – load bid Id Returns: API response Raises: QuoineResponseException, QuoineAPIException { "id": 3580, "bidask_type": "limit", "quantity": "50.0", "currency": "USD", "side": "bid", "filled_quantity": "0.0", "status": "closed", "rate": "0.0007", "user_id": 3020 }
-
get_loans
(currency, limit=None, page=None)[source]¶ Get loans
https://developers.quoine.com/#get-loans
Parameters: - currency (string) – lending currency (all available in the system except JPY)
- limit (int) – Limit execution per request
- page (int) – Page
Returns: API response
Raises: QuoineResponseException, QuoineAPIException
{ "models": [ { "id": 144825, "quantity": "495.1048", "rate": "0.0005", "created_at": 1464168246, "lender_id": 312, "borrower_id": 5712, "status": "open", "currency": "JPY", "fund_reloaned": true } ], "current_page": 1, "total_pages": 1 }
-
update_loan
(loan_id, fund_reloaned=None)[source]¶ Update a loan
https://developers.quoine.com/#update-a-loan
TODO: work out what else we can update
Parameters: - loan_id (int) – Loan Id
- fund_reloaned (bool) – optional
Returns: API response
Raises: QuoineResponseException, QuoineAPIException
{ "id": 144825, "quantity": "495.1048", "rate": "0.0005", "created_at": 1464168246, "lender_id": 312, "borrower_id": 5712, "status": "open", "currency": "JPY", "fund_reloaned": false }
-
get_trading_accounts
()[source]¶ Get Trading Accounts
https://developers.quoine.com/#get-trading-accounts
Returns: API response Raises: QuoineResponseException, QuoineAPIException [ { "id": 1759, "leverage_level": 10, "max_leverage_level": 10, "pnl": "0.0", "equity": "10000.1773", "margin": "4.2302", "free_margin": "9995.9471", "trader_id": 4807, "status": "active", "product_code": "CASH", "currency_pair_code": "BTCUSD", "position": "0.1", "balance": "10000.1773", "created_at": 1421992165, "updated_at": 1457242996, "pusher_channel": "trading_account_1759", "margin_percent": "0.1", "product_id": 1, "funding_currency": "USD", "base_open_price": 0, "long_summary": { "pnl": "0.0", "position": "0.0", "base_open_price": "0.0" }, "short_summary": { "pnl": "0.0", "position": "0.0", "base_open_price": "0.0" } }, #... ]
-
get_trading_account
(account_id)[source]¶ Get a Trading Account
https://developers.quoine.com/#get-a-trading-account
Parameters: account_id (int) – Trading Account Id Returns: API response Raises: QuoineResponseException, QuoineAPIException { "id": 1759, "leverage_level": 10, "max_leverage_level": 10, "pnl": "0.0", "equity": "10000.1773", "margin": "4.2302", "free_margin": "9995.9471", "trader_id": 4807, "status": "active", "product_code": "CASH", "currency_pair_code": "BTCUSD", "position": "0.1", "balance": "10000.1773", "created_at": 1421992165, "updated_at": 1457242996, "pusher_channel": "trading_account_1759", "margin_percent": "0.1", "product_id": 1, "funding_currency": "USD" }
-
update_leverage_level
(account_id, leverage_level)[source]¶ Update Trading account leverage level
Only available on Quoinex
https://developers.quoine.com/#update-leverage-level
Parameters: - account_id (int) – Trading Account Id
- leverage_level (int) – New leverage level
Returns: API response
Raises: QuoineResponseException, QuoineAPIException
{ "id": 1759, "leverage_level": 25, "max_leverage_level": 25, "pnl": "0.0", "equity": "10000.1773", "margin": "4.2302", "free_margin": "9995.9471", "trader_id": 4807, "status": "active", "product_code": "CASH", "currency_pair_code": "BTCUSD", "position": "0.1", "balance": "10000.1773", "created_at": 1421992165, "updated_at": 1457242996, "pusher_channel": "trading_account_1759", "margin_percent": "0.1", "product_id": 1, "funding_currency": "USD" }
-
get_trades
(funding_currency=None, status=None, limit=None, page=None)[source]¶ Get Trades
https://developers.quoine.com/#get-trades
Parameters: - funding_currency (string) – optional - get trades of a particular funding currency
- status (string) – optional - open or closed
- limit (int) – Limit trades per request
- page (int) – Page
Returns: API response
Raises: QuoineResponseException, QuoineAPIException
{ "models": [ { "id": 57896, "currency_pair_code": "BTCUSD", "status": "open", "side": "short", "margin_used": "0.83588", "open_quantity": "0.01", "close_quantity": "0.0", "quantity": "0.01", "leverage_level": 5, "product_code": "CASH", "product_id": 1, "open_price": "417.65", "close_price": "417.0", "trader_id": 3020, "open_pnl": "0.0", "close_pnl": "0.0", "pnl": "0.0065", "stop_loss": "0.0", "take_profit": "0.0", "funding_currency": "USD", "created_at": 1456250726, "updated_at": 1456251837, "close_fee": "0.0", "total_interest": "0.02", "daily_interest": "0.02" }, #... ], "current_page": 1, "total_pages": 1 }
-
close_trade
(trade_id, closed_quantity=None)[source]¶ Close a trade
https://developers.quoine.com/#close-a-trade
Parameters: - trade_id (int) – Trade Id
- closed_quantity (string) – optional - The quantity you want to close
Returns: API response
Raises: QuoineResponseException, QuoineAPIException
{ "id": 57896, "currency_pair_code": "BTCUSD", "status": "closed", "side": "short", "margin_used": "0.83588", "open_quantity": "0.01", "close_quantity": "0.0", "quantity": "0.01", "leverage_level": 5, "product_code": "CASH", "product_id": 1, "open_price": "417.65", "close_price": "417.0", "trader_id": 3020, "open_pnl": "0.0", "close_pnl": "0.0065", "pnl": "0.0065", "stop_loss": "0.0", "take_profit": "0.0", "funding_currency": "USD", "created_at": 1456250726, "updated_at": 1456251837, "close_fee": "0.0", "total_interest": "0.02", "daily_interest": "0.02" }
-
close_all_trades
(side=None)[source]¶ Close all trades
https://developers.quoine.com/#close-all-trade
Parameters: side (string) – optional - Close all trades of this side. Close trades of both side if left blank Returns: API response Raises: QuoineResponseException, QuoineAPIException [ { "id": 57896, "currency_pair_code": "BTCUSD", "status": "closed", "side": "short", "margin_used": "0.83588", "open_quantity": "0.01", "close_quantity": "0.0", "quantity": "0.01", "leverage_level": 5, "product_code": "CASH", "product_id": 1, "open_price": "417.65", "close_price": "417.0", "trader_id": 3020, "open_pnl": "0.0", "close_pnl": "0.0065", "pnl": "0.0065", "stop_loss": "0.0", "take_profit": "0.0", "funding_currency": "USD", "created_at": 1456250726, "updated_at": 1456251837, "close_fee": "0.0", "total_interest": "0.02", "daily_interest": "0.02" } ]
-
update_trade
(trade_id, stop_loss, take_profit)[source]¶ Update a trade
https://developers.quoine.com/#update-a-trade
Parameters: - trade_id (int) – Trade Id
- stop_loss (string) – Stop Loss price
- take_profit (string) – Take Profit price
Returns: API response
Raises: QuoineResponseException, QuoineAPIException
{ "id": 57897, "currency_pair_code": "BTCUSD", "status": "open", "side": "short", "margin_used": "0.83588", "open_quantity": "0.01", "close_quantity": "0.0", "quantity": "0.01", "leverage_level": 5, "product_code": "CASH", "product_id": 1, "open_price": "417.65", "close_price": "0", "trader_id": 3020, "open_pnl": "0.0", "close_pnl": "0.0065", "pnl": "0.0065", "stop_loss": "300.0", "take_profit": "600.0", "funding_currency": "USD", "created_at": 1456250726, "updated_at": 1456251837, "close_fee": "0.0", "total_interest": "0.02", "daily_interest": "0.02" }
-
get_trade_loans
(trade_id)[source]¶ Get a trade’s loans
https://developers.quoine.com/#get-a-trade’s-loans
Parameters: trade_id (int) – Trade Id Returns: API response Raises: QuoineResponseException, QuoineAPIException [ { "id": 103520, "quantity": "42.302", "rate": "0.0002", "created_at": 1461998432, "lender_id": 100, "borrower_id": 3020, "status": "open", "currency": "USD", "fund_reloaned": true } ]
-
-
class
quoine.client.
Quoinex
(api_token_id, api_secret, vendor_id=None, language=None)[source]¶ Bases:
quoine.client.Quoine
-
class
quoine.client.
Qryptos
(api_token_id, api_secret, vendor_id=None, language=None)[source]¶ Bases:
quoine.client.Quoinex
-
API_URL
= 'https://api.qryptos.com'¶
-
exceptions module¶
-
exception
quoine.exceptions.
QuoineAPIException
(response)[source]¶ Bases:
exceptions.Exception
Exception class to handle general API Exceptions
code values
- HTTP 400: Bad Request
- There was an error with the request. The body of the response will have more info
- HTTP 401: Unauthorized
- Token is invalid. If your API key is wrong a 401 will also be served, so check the response body, it might be that the API_KEY is invalid.
- HTTP 422: Unprocessable Entity
- There was an error with the request. The body of the response will have more info. Some possible reasons: - Missing params - The format of data is wrong
- HTTP 429: Too Many Requests
- This status indicates that the user has sent too many requests in a given amount of time
- HTTP 503: Service Unavailable
- Many reasons, body will include details - An internal error on Authy. - Your application is accessing an API call you don’t have access too. - API usage limit. If you reach API usage limits a 503 will be returned, please wait until you can do the call again.
message format
{ "user": ["not_enough_fund"] }