Coinbase International
This 指南 will walk you through using Coinbase International with NautilusTrader for 数据 ingest and/or 实时交易.
The Coinbase International integration is currently in a beta 测试 phase. Exercise caution and report any issues on GitHub.
Coinbase International Exchange provides non-US institutional clients with access to cryptocurrency perpetual futures and spot markets. The exchange serves European and international traders by providing leveraged crypto derivatives, often restricted or unavailable in these regions.
Coinbase International brings a high standard of customer protection, a robust 风险管理 框架 and 高性能 trading technology, including:
- 实时 24/7/365 风险管理.
- Liquidity from external market makers (no proprietary trading).
- Dynamic margin 要求 and collateral assessments.
- Liquidation 框架 that meets rigorous compliance standards.
- Well-capitalized exchange to 支持 tail market events.
- Collaboration with top-tier global regulators.
See the Introducing Coinbase International Exchange blog article for more details.
安装
No additional coinbase_intx
安装 is required; the adapter’s core components, written in Rust, are automatically compiled and linked during the build.
示例
You can find live example scripts here. These 示例 demonstrate how to set up live market 数据 feeds and 执行 clients for trading on Coinbase International.
概览
The following products are supported on the Coinbase International exchange:
- Perpetual Futures contracts
- Spot cryptocurrencies
This 指南 assumes a trader is setting up for both live market 数据 feeds, and trade 执行. The Coinbase International adapter includes multiple components, which can be used together or separately depending on the use case. These components work together to connect to Coinbase International’s APIs for market 数据 and 执行.
CoinbaseIntxHttpClient
: REST API connectivity.CoinbaseIntxWebSocketClient
: WebSocket API connectivity.CoinbaseIntxInstrumentProvider
: Instrument parsing and loading functionality.CoinbaseIntxDataClient
: A market data feed manager.CoinbaseIntxExecutionClient
: An account management and trade execution gateway.CoinbaseIntxLiveDataClientFactory
: Factory for Coinbase International data clients.CoinbaseIntxLiveExecClientFactory
: Factory for Coinbase International execution clients.
Most users will simply define a 配置 for a 实时交易 节点 (described below), and won't necessarily need to work with the above components directly.
Coinbase 文档
Coinbase International provides extensive API documentation for users which can be found in the Coinbase Developer Platform. We recommend also referring to the Coinbase International 文档 in conjunction with this NautilusTrader integration 指南.
数据
金融工具
On startup, the adapter automatically loads all available 金融工具 from the Coinbase International REST API
and subscribes to the 金融工具
WebSocket channel for updates. This ensures that the 缓存 and clients requiring
up-to-date definitions for parsing always have the latest instrument 数据.
Available instrument types include:
CurrencyPair
(Spot cryptocurrencies)CryptoPerpetual
Index products have not yet been implemented.
The following 数据 types are available:
OrderBookDelta
(L2 market-by-price)QuoteTick
(L1 top-of-book best bid/ask)TradeTick
Bar
MarkPriceUpdate
IndexPriceUpdate
Historical 数据 requests have not yet been implemented.
WebSocket market 数据
The 数据 客户端 connects to Coinbase International's WebSocket feed to stream 实时 market 数据. The WebSocket 客户端 handles automatic reconnection and re-subscribes to active subscriptions upon reconnecting.
执行
The adapter is designed to trade one Coinbase International 投资组合 per 执行 客户端.
Selecting a 投资组合
To identify your available portfolios and their IDs, use the REST 客户端 by running the following script:
python nautilus_trader/adapters/coinbase_intx/scripts/list_portfolios.py
This will output a list of 投资组合 details, similar to the example below:
[{'borrow_disabled': False,
'cross_collateral_enabled': False,
'is_default': False,
'is_lsp': False,
'maker_fee_rate': '-0.00008',
'name': 'hrp5587988499',
'portfolio_id': '3mnk59ap-1-22', # Your portfolio ID
'portfolio_uuid': 'dd0958ad-0c9d-4445-a812-1870fe40d0e1',
'pre_launch_trading_enabled': False,
'taker_fee_rate': '0.00012',
'trading_lock': False,
'user_uuid': 'd4fbf7ea-9515-1068-8d60-4de91702c108'}]
Configuring the 投资组合
To specify a 投资组合 for trading, set the COINBASE_INTX_PORTFOLIO_ID
环境 variable to
the desired portfolio_id
. If you're using multiple 执行 clients, you can alternatively define
the portfolio_id
in the 执行 配置 for each 客户端.
Capability Matrix
Coinbase International offers market, limit, and stop order types, enabling a broad range of 策略.
Order Types
Order Type | Derivatives | Spot | Notes |
---|---|---|---|
MARKET | ✓ | ✓ | Must use IOC or FOK time-in-forc |
LIMIT | ✓ | ✓ | |
STOP_MARKET | ✓ | ✓ | |
STOP_LIMIT | ✓ | ✓ | |
MARKET_IF_TOUCHED | - | - | Not supported. |
LIMIT_IF_TOUCHED | - | - | Not supported. |
TRAILING_STOP_MARKET | - | - | Not supported. |
执行 Instructions
Instruction | Derivatives | Spot | Notes |
---|---|---|---|
post_only | ✓ | ✓ | Ensures 订单 only provide liquidity. |
reduce_only | ✓ | ✓ | Ensures 订单 only reduce existing 头寸. |
Time in force options
Time in force | Derivatives | Spot | Notes |
---|---|---|---|
GTC | ✓ | ✓ | Good Till Canceled. |
GTD | ✓ | ✓ | Good Till Date. |
FOK | ✓ | ✓ | Fill or Kill. |
IOC | ✓ | ✓ | Immediate or Cancel. |
Advanced Order Features
功能 | Derivatives | Spot | Notes |
---|---|---|---|
Order Modification | ✓ | ✓ | Price and quantity modification. |
Bracket/OCO 订单 | ? | ? | Requires further investigation. |
Iceberg 订单 | ✓ | ✓ | Available via FIX 协议. |
Batch operations
Operation | Derivatives | Spot | Notes |
---|---|---|---|
Batch Submit | - | - | Not supported. |
Batch Modify | - | - | Not supported. |
Batch Cancel | - | - | Not supported. |
Position management
功能 | Derivatives | Spot | Notes |
---|---|---|---|
Query 头寸 | ✓ | - | 实时 position updates for derivatives. |
Position mode | - | - | Single position mode only. |
Leverage control | ✓ | - | Per-投资组合 leverage settings. |
Margin mode | ✓ | - | Cross margin only. |
Order querying
功能 | Derivatives | Spot | Notes |
---|---|---|---|
Query open 订单 | ✓ | ✓ | List all active 订单. |
Query order history | ✓ | ✓ | Historical order 数据. |
Order status updates | ✓ | ✓ | 实时 updates via FIX drop copy. |
Trade history | ✓ | ✓ | 执行 and fill 报告. |
Contingent 订单
功能 | Derivatives | Spot | Notes |
---|---|---|---|
Order lists | - | - | Not supported. |
OCO 订单 | ? | ? | Requires further investigation. |
Bracket 订单 | ? | ? | Requires further investigation. |
Conditional 订单 | ✓ | ✓ | Stop and stop-limit 订单. |
配置 Options
The following 执行 客户端 配置 options are available:
Option | Default | Description |
---|---|---|
portfolio_id | None | Specifies the Coinbase International 投资组合 to trade. Required for 执行. |
http_timeout_secs | 60 | Default timeout for HTTP requests in seconds. |
FIX Drop Copy Integration
The Coinbase International adapter includes a FIX (Financial Information eXchange) drop copy client. This provides reliable, 低延迟 执行 updates directly from Coinbase's matching engine.
This approach is necessary because 执行 messages are not provided over the WebSocket feed, and delivers faster and more reliable order 执行 updates than polling the REST API.
The FIX 客户端:
- Establishes a secure TCP/TLS connection and logs on automatically when the trading 节点 starts.
- Handles connection 监控 and automatic reconnection and logon if the connection is interrupted.
- Properly logs out and closes the connection when the trading 节点 stops.
The 客户端 processes several types of 执行 messages:
- Order status 报告 (canceled, expired, triggered).
- Fill 报告 (partial and complete fills).
The FIX credentials are automatically managed using the same API credentials as the REST and WebSocket clients. No additional 配置 is required beyond providing valid API credentials.
The REST 客户端 handles processing REJECTED
and ACCEPTED
status 执行 messages on order submission.
Account and Position Management
On startup, the 执行 客户端 requests and loads your current account and 执行 state including:
- Available balances across all assets.
- Open 订单.
- Open 头寸.
This provides your trading 策略 with a complete picture of your account before placing new 订单.
配置
策略
Coinbase International has a strict specification for 客户端 order IDs.
Nautilus can meet the spec by using UUID4 values for 客户端 order IDs.
To comply, set the use_uuid_client_order_ids=True
config option in your strategy 配置 (otherwise, order submission will trigger an API error).
See the Coinbase International Create order REST API documentation for further details.
An example 配置 could be:
from nautilus_trader.adapters.coinbase_intx import COINBASE_INTX, CoinbaseIntxDataClientConfig, CoinbaseIntxExecClientConfig
from nautilus_trader.live.node import TradingNode
config = TradingNodeConfig(
..., # Further config omitted
data_clients={
COINBASE_INTX: CoinbaseIntxDataClientConfig(
instrument_provider=InstrumentProviderConfig(load_all=True),
),
},
exec_clients={
COINBASE_INTX: CoinbaseIntxExecClientConfig(
instrument_provider=InstrumentProviderConfig(load_all=True),
),
},
)
strat_config = TOBQuoterConfig(
use_uuid_client_order_ids=True, # <-- Necessary for Coinbase Intx
instrument_id=instrument_id,
external_order_claims=[instrument_id],
..., # Further config omitted
)
Then, create a TradingNode
and add the 客户端 factories:
from nautilus_trader.adapters.coinbase_intx import COINBASE_INTX, CoinbaseIntxLiveDataClientFactory, CoinbaseIntxLiveExecClientFactory
from nautilus_trader.live.node import TradingNode
# Instantiate the live trading node with a configuration
node = TradingNode(config=config)
# Register the client factories with the node
node.add_data_client_factory(COINBASE_INTX, CoinbaseIntxLiveDataClientFactory)
node.add_exec_client_factory(COINBASE_INTX, CoinbaseIntxLiveExecClientFactory)
# Finally build the node
node.build()
API Credentials
Provide credentials to the clients using one of the following methods.
Either pass values for the following 配置 options:
api_key
api_secret
api_passphrase
portfolio_id
Or, set the following 环境 variables:
COINBASE_INTX_API_KEY
COINBASE_INTX_API_SECRET
COINBASE_INTX_API_PASSPHRASE
COINBASE_INTX_PORTFOLIO_ID
We recommend using 环境 variables to manage your credentials.
When starting the trading 节点, you'll receive immediate confirmation of whether your credentials are valid and have trading permissions.
实现 notes
- Heartbeats: The adapter maintains heartbeats on both the WebSocket and FIX connections to ensure reliable connectivity.
- Rate Limits: The REST API client is configured to limit requests to the 40/second, as specified by Coinbase International.
- Graceful Shutdown: The adapter properly handles graceful shutdown, ensuring all pending messages are processed before disconnecting.
- Thread Safety: All adapter components are thread-safe, allowing them to be used from multiple threads concurrently.
- Execution Model: The adapter can be configured with a single Coinbase International portfolio per execution client. For trading multiple portfolios, you can create multiple execution clients.