Skip to content
All library documents

Connecting Coinbase Spot Crypto and Handling Historical Bars

Article Lumibot

Summary

The document describes Coinbase as a spot crypto venue available through Lumibot’s shared CCXT broker integration. It explains that current Coinbase Cloud Developer Platform credentials use a key name and private key, while a passphrase is generally relevant only to legacy HMAC credentials. It also notes that crypto markets run continuously, so a strategy should use a 24/7 market schedule and an appropriate polling interval.

For operational checks, it recommends starting with small paper or live quantities and verifying balances, orders, fills, and cancellations before increasing exposure. Its historical-data note explains that CCXT pagination advances the timestamp cursor by one full timeframe after the last candle, avoiding repeated boundary candles on exchanges with inclusive cursors. Requests either return the requested bar count or raise a short-history error. The document covers setup and data handling rather than a trading signal, and it provides no performance evidence or analysis of Coinbase execution quality.

Key ideas

  • Coinbase access through the shared CCXT broker uses a CDP key name and private key for current credentials.
  • Continuous crypto trading calls for a 24/7 market schedule.
  • Small test quantities can help check balances, orders, fills, and cancellation behavior.
  • Historical pagination advances beyond the last candle to avoid repeatedly fetching an inclusive boundary.
  • A history request may fail when the exchange returns fewer bars than requested.

Tags

Full text
# brokers.ccxt.coinbase


Coinbase Crypto Broker
======================

.. meta::
   :description: Coinbase is one of Lumibot's auto-detected CCXT credential paths. It is a good starting point for users who want regulated spot crypto access and relatively simple.

Coinbase is one of Lumibot's auto-detected CCXT credential paths. It is a good
starting point for users who want regulated spot crypto access and relatively
simple account setup.

Status
------

* **Live trading path:** auto-detected through the shared CCXT broker
* **Credential style:** Coinbase CDP key name plus private key
* **Backtesting:** use CCXT backtesting with an exchange id when appropriate
* **Asset class:** crypto

Credentials
-----------

Coinbase's current Cloud Developer Platform keys use a key ``name`` and a
multi-line private key. Create the key in the Coinbase CDP portal:

https://portal.cdp.coinbase.com/

Then set:

.. code-block:: bash

   COINBASE_API_KEY_NAME=organizations/<org-id>/apiKeys/<key-id>
   COINBASE_PRIVATE_KEY="-----BEGIN EC PRIVATE KEY-----\n...\n-----END EC PRIVATE KEY-----\n"

``COINBASE_API_PASSPHRASE`` is only for legacy HMAC keys and should usually be
omitted for new CDP keys.

Strategy Notes
--------------

Crypto markets trade continuously, so set the market in ``initialize()``:

.. code-block:: python

   def initialize(self):
       self.set_market("24/7")
       self.sleeptime = "1M"

Start with tiny paper or live test quantities, verify balances, open orders,
fills, and cancellation behavior, and only then increase size.

Live Historical Bars
--------------------

Live Coinbase history uses CCXT timestamp pagination. LumiBot advances the
``since`` cursor to one full timeframe after the last returned candle, which
prevents exchanges with inclusive cursors from returning the same boundary
candle indefinitely. A request either returns the requested number of bars or
raises a short-history error that includes the returned and requested counts.

Shown in full with attribution under the source's licence. Licence: GPL-3.0

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.