Coinbase Advanced SDK¶
- class src.boatwright.External_Interfaces.Coinbase.Coinbase_Advanced_API.CoinbaseAdvancedAuth(api_key, secret_key)¶
python requests authenitification class for Coinbase api v3 https://docs.cloud.coinbase.com/advanced-trade-api/docs/rest-api-auth
- class src.boatwright.External_Interfaces.Coinbase.Coinbase_Advanced_API.CoinbaseAdvanced(api_key, api_secret, debug=False)¶
HTTP/REST Client for Coinbase api v3
- cancel_orders(order_ids)¶
https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_cancelorders
Initiate cancel requests for one or more orders.
- Parameters:
order_ids (list) – list of order_ids as strings
- create_limit_limit_gtc(product_id, side, base_size, limit_price, post_only=True, client_order_id='b00264be-fd15-11ef-bdfa-6045bd0028d4')¶
Create a limit order, good till canceled (never expires)
- Parameters:
product_id (str) – e.g. ‘BTC-USD’
side (str) – possible values - “UNKNOWN_ORDER_SIDE”, “BUY”, “SELL”
base_size (float) – Amount of base currency to spend on order
limit_price (float) – Ceiling price for which the order should get filled
post_only (bool) – The Post-Only Limit order option ensures that the limit order will be added to the order book and not match a pre-existing order. If your order would cause a match with a pre-existing order, your post-only limit order will be canceled
client_order_id (str) – unique uuid for the order
- create_limit_limit_gtd(product_id, side, base_size, limit_price, end_time, post_only=True, client_order_id='b00264bf-fd15-11ef-bdfa-6045bd0028d4')¶
Create a limit order, good till date
- Parameters:
product_id (str) – e.g. ‘BTC-USD’
side (str) – possible values - “UNKNOWN_ORDER_SIDE”, “BUY”, “SELL”
base_size (float) – Amount of base currency to spend on order
limit_price (float) – Ceiling price for which the order should get filled
end_time (date) – Time at which the order should be cancelled if it’s not filled
post_only (bool) – The Post-Only Limit order option ensures that the limit order will be added to the order book and not match a pre-existing order. If your order would cause a match with a pre-existing order, your post-only limit order will be canceled
client_order_id (str) – unique uuid for the order
- create_market_market_ioc(product_id, side, quote_size, base_size, client_order_id='b00264bd-fd15-11ef-bdfa-6045bd0028d4')¶
Create a market order
- Parameters:
product_id (str) – e.g. ‘BTC-USD’
side (str) – possible values - “UNKNOWN_ORDER_SIDE”, “BUY”, “SELL”
quote_size (float) – Amount of quote currency to spend on order. Required for BUY orders.
base_size (float) – Amount of base currency to spend on order. Required for SELL orders.
client_order_id (str) – unique uuid for the order
- create_order(product_id, side, order_configuration, client_order_id='b00264bc-fd15-11ef-bdfa-6045bd0028d4')¶
- Parameters:
product_id (str) – e.g. ‘BTC-USD’
side (str) – possible values - “UNKNOWN_ORDER_SIDE”, “BUY”, “SELL”
client_order_id (str) – unique uuid for the order
order_configuration (dict) – specification of order type and info
https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_postorder
parent function for all “create_order” requests -
market_market_ioc
limit_limit_gtc
limit_limit_gtd
stop_limit_stop_limit_gtc
stop_limit_stop_limit_gtd
- format_date(date)¶
convert datetime objects to the Coinbase accepted date format: utc isoformat timestamps
- get(path_url, params=None)¶
“generic post request structure
- get_account(account_uuid)¶
https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getaccount
Get a list of information about an account, given an account UUID.
- get_market_trades(product_id, limit)¶
https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getmarkettrades
- get_order(order_id)¶
https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_gethistoricalorder
get a single order by order ID
- get_product(product_id)¶
https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getproduct
Get information on a single product by product ID.
- get_product_account(product)¶
gets account for a single product :param product: e.g. “BTC”
- Parameters:
product (str)
- get_product_candles(product_id, start, end, granularity='UNKNOWN_GRANULARITY')¶
https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getcandles
- get_transactions_summary(start_date=None, end_date=None, user_native_currency=None, product_type=None)¶
- list_accounts()¶
lists your coinbase accounts, wallets etc
- list_fills(order_id=None, product_id=None, start_sequence_timestamp=None, end_sequence_timestamp=None, limit=None, cursor=None)¶
https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getfills
Get a list of fills filtered by optional query parameters (product_id, order_id, etc).
- list_orders(product_id=None, order_status=None, limit=None, start_date=None, end_date=None, user_native_currency=None, order_type=None, order_side=None, cursor=None, product_type=None, order_placement_source=None, debug=False)¶
https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_gethistoricalorders
Get a list of orders filtered by optional query parameters (product_id, order_status, etc)
- list_products(limit=None, offset=None, product_type=None)¶
https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getproducts
Get a list of the available currency pairs for trading.
- post(path_url, data)¶
“generic post request structure
- stop_limit_stop_limit_gtc(product_id, side, base_size, limit_price, stop_price, stop_direction, client_order_id='b00264c0-fd15-11ef-bdfa-6045bd0028d4')¶
Create a stop limit order, good till cancelled
- Parameters:
product_id (str) – e.g. ‘BTC-USD’
side (str) – possible values - “UNKNOWN_ORDER_SIDE”, “BUY”, “SELL”
base_size (float) – Amount of base currency to spend on order
limit_price (float) – Ceiling price for which the order should get filled
stop_price (float) – Price at which the order should trigger - if stop direction is Up, then the order will trigger when the last trade price goes above this, otherwise order will trigger when last trade price goes below this price.
stop_direction (str) – possible values - “UNKNOWN_STOP_DIRECTION”, “STOP_DIRECTION_STOP_UP”, “STOP_DIRECTION_STOP_DOWN”
client_order_id (str) – unique uuid for the order
- stop_limit_stop_limit_gtd(product_id, side, base_size, limit_price, stop_price, stop_direction, end_time, client_order_id='b00264c1-fd15-11ef-bdfa-6045bd0028d4')¶
Create a stop limit order, good till date
- Parameters:
product_id (str) – e.g. ‘BTC-USD’
side (str) – possible values - “UNKNOWN_ORDER_SIDE”, “BUY”, “SELL”
base_size (float) – Amount of base currency to spend on order
limit_price (float) – Ceiling price for which the order should get filled
stop_price (float) – Price at which the order should trigger - if stop direction is Up, then the order will trigger when the last trade price goes above this, otherwise order will trigger when last trade price goes below this price.
stop_direction (str) – possible values - “UNKNOWN_STOP_DIRECTION”, “STOP_DIRECTION_STOP_UP”, “STOP_DIRECTION_STOP_DOWN”
end_time (date) – Time at which the order should be cancelled if it’s not filled
client_order_id (str) – unique uuid for the order