Skip to main content

Coinbase Advanced Trade API client library.

Project description

cb-advanced-trade

Coinbase Advanced Trade API client library.


Installation:

python -m pip install [--upgrade] cb-advanced-trade

Endpoints:

INFO:

Advanced Trade endpoints require authentication using an API Key authentication scheme. You can generate API keys here.

  • Accounts
  • Orders
  • Products
  • TransactionSummary

Required parameters:

  • key: str - The API key;
  • secret: str - The API secret.

Optional parameters:

  • cache: bool - Use caching (defaults to: True);
  • retries: int - Total number of retries to allow (defaults to: 3);
  • backoff: int - A backoff factor to apply between attempts after the second try (defaults to: 1);
  • timeout: int - How long to wait for the server to send data before giving up (defaults to: 30);
  • debug: bool - Set to True to log all requests/responses to/from server (defaults to: False);
  • logger: Logger - The handler to be used for logging (defaults to: None).

Any of the endpoints can be instantiated or used as a context-manager:

from cb_advanced_trade import Accounts

credentials: dict = {
    "key": "KEY",
    "secret": "SECRET",
}  # be careful where you keep your credentials!


if __name__ == '__main__':

    endpoint = Accounts(**credentials)
    account = endpoint.get_account("2ca72458-ade9-45fd-83f2-e1f468b70026")
    endpoint.close()

    # or

    with Accounts(**credentials) as endpoint:
        account = endpoint.get_account("2ca72458-ade9-45fd-83f2-e1f468b70026")

Resources:

For each mapped resource you must read the documentation. All the parameters these resources can take are described in the official documentation.

Accounts

  • get_accounts()

    Get a list of authenticated accounts for the current user.

  • get_account()

    Get a list of information about an account, given an account UUID.

Orders

  • create_order()

    Create an order with a specified product_id (asset-pair), side (buy/sell), etc.

    Maximum Open Orders Per Product

    The maximum number of OPEN orders you can have for a given product_id is 500. If you have 500 open orders for a product_id at submission, new orders placed for that product enter a failed state immediately.

  • del_order()

    Initiate cancel requests for one or more orders.

  • get_orders()

    Get a list of orders filtered by optional query parameters (product_id, order_status, etc).

    Maximum Open Orders Returned

    The maximum number of OPEN orders returned is 1000.

    CAUTION

    If you have more than 1000 open, is recommended the WebSocket User channel to retrieve all OPEN orders.

  • get_fills()

    Get a list of fills filtered by optional query parameters (product_id, order_id, etc).

  • get_order()

    Get a single order by order ID.

Products

  • get_products()

    Get a list of the available currency pairs for trading.

  • get_product()

    Get information on a single product by product ID.

  • get_product_candles()

    Get rates for a single product by product ID, grouped in buckets.

  • get_market_trades()

    Get snapshot information, by product ID, about the last trades (ticks), best bid/ask, and 24h volume.

TransactionSummary


Websocket client:

Required parameters:

  • key: The API key;
  • secret: The API secret;
  • channel: The channel to subscribe to;
  • product_ids: Product IDs as list of strings.

Optional parameters:

  • debug: Set to True to log all requests/responses to/from server (defaults to: False).
  • logger: The handler to be used for logging. If given, and level is above DEBUG, all debug messages will be ignored.

Note:

For information about Websocket feed channels visit the documentation.

Examples:

MarketData

from cb_advanced_trade import MarketData

credentials = {
"key": "YOUR KEY",
"secret": "YOUR SECRET",
}  # be careful where you keep this!


if __name__ == '__main__':

    client = MarketData(
        **credentials,
        channel="ticker",
        product_ids=["BTC-USD"],
        debug=True
    )

    client.listen()

    try:
        for tick in client.queue:
            print(tick)
    except KeyboardInterrupt:
        client.close()


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cb_advanced_trade-0.0.4.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

cb_advanced_trade-0.0.4-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file cb_advanced_trade-0.0.4.tar.gz.

File metadata

  • Download URL: cb_advanced_trade-0.0.4.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.5

File hashes

Hashes for cb_advanced_trade-0.0.4.tar.gz
Algorithm Hash digest
SHA256 3b27eb181b98d97c072d09e1db3fd8ae98bc997f255ff21e0f7283318c88e7bb
MD5 9fe14b5cddb8aef4da877dee36346084
BLAKE2b-256 03f5c6f1e7939752047644756b8f2f5a6ed8d38cd7bff061f606838cc798f15c

See more details on using hashes here.

File details

Details for the file cb_advanced_trade-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for cb_advanced_trade-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2b35e7ba7ec1423078d876cc8249bf729422c6b406aaba24163632379ac76ece
MD5 c55eb12c6fb0a3ab23aaafe340702f21
BLAKE2b-256 2cea4a26bf9a6db9bc18bc4485d6f8c787efe8b93767c6b1ac6b3d0dcdfca167

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page