Contents
Brokerages
Coinbase Pro
Introduction
QuantConnect enables you to run your algorithms in live mode with real-time market data. We have successfully hosted more than 200,000 live algorithms and have had more than $15B in volume traded on our servers since 2015. Brokerages supply a connection to the exchanges so that you can automate orders using LEAN. You can use multiple data feeds in live trading algorithms.
Coinbase was founded by Brian Armstrong and Fred Ehrsam in 2012 with the goal to "increase economic freedom in the world". Coinbase Pro provides access to trading Crypto for clients in over 100 countries with no minimum deposit. Coinbase Pro also provides a self-hosted Crypto wallet, a Visa debit rewards card, and Bitcoin collateral-backed lines of credit.
Account Types
Coinbase Pro supports cash accounts.
SetBrokerageModel(BrokerageName.GDAX, AccountType.Cash);
self.SetBrokerageModel(BrokerageName.GDAX, AccountType.Cash)
Create an Account
Follow the How to open a Coinbase Pro account tutorial on the Coinbase Pro website to create a Coinbase Pro account.
You will need API credentials to deploy live algorithms. After you have an account, create API credentials and store them somewhere safe. As you create credentials, enable View and Trade permissions.
Paper Trading
Coinbase Pro supports paper trading through the Coinbase Sandbox. You need a Coinbase Pro account to paper trade in the Sandbox.
To create API credentials, log in to your Sandbox account and then follow the instructions for creating credentials for Coinbase Pro. As you create credentials, enable View and Trade permissions.
After you create API credentials for your Sandbox account, follow these steps to add capital to your account:
- In the top navigation bar of the Sandbox, click .
- On the Portfolios page, click .
- In the Deposit window, click the asset that you want to deposit into your account.
- Click .
- In the Amount field, enter the quantity of the asset to deposit.
- Click .
- Click .
Asset Classes
Coinbase Pro supports trading Crypto.
AddCrypto("BTCUSD", Resolution.Minute, Market.CoinbasePro);
self.AddCrypto("BTCUSD", Resolution.Minute, Market.CoinbasePro)
If you call the SetBrokerageModel
method with the correct BrokerageName
, then you don't need to pass a Market
argument to the AddCrypto
method because the brokerage model automatically selects the correct market.
Assets Available
Refer to the Coinbase Pro Crypto Price Data dataset to see the assets available.
Orders
We model the Coinbase Pro API by supporting several order types, supporting order properties, and not supporting order updates. When you deploy live algorithms, you can place manual orders through the IDE.
Order Types
Coinbase Pro supports the following order types:
MarketOrder
LimitOrder
StopMarketOrder
(Supported after 3/23/2019 in backtests. For reference, see the Coinbase Pro Market Structure Update on the Coinbase website.)StopLimitOrder
MarketOrder(_symbol, quantity); LimitOrder(_symbol, quantity, limitPrice); StopMarketOrder(_symbol, quantity, stopPrice); StopLimitOrder(_symbol, quantity, stopPrice, limitPrice);
self.MarketOrder(self.symbol, quantity) self.LimitOrder(self.symbol, quantity, limit_price) self.StopMarketOrder(self.symbol, quantity, stop_price) self.StopLimitOrder(self.symbol, quantity, stop_price, limit_price)
Order Properties
We model custom order properties from the Coinbase Pro API. The following table describes the members of the CoinbaseProOrderProperties
object that you can set to customize order execution:
Property | Description |
---|---|
TimeInForce | A TimeInForce instruction to apply to the order. The GoodTilCanceled TimeInForce is supported. |
PostOnly | A flag that signals the order must only add liquidity to the order book and not take liquidity from the order book. If part of the order results in taking liquidity rather than providing liquidity, the order is rejected without any part of it being filled. |
public override void Initialize() { // Set the default order properties DefaultOrderProperties = new CoinbaseProOrderProperties { TimeInForce = TimeInForce.GoodTilCanceled, PostOnly = false }; } public override void OnData(Slice slice) { // Use default order order properties LimitOrder(_symbol, quantity, limitPrice); // Override the default order properties LimitOrder(_symbol, quantity, limitPrice, orderProperties: new CoinbaseProOrderProperties { TimeInForce = TimeInForce.GoodTilCanceled, PostOnly = true }); }
def Initialize(self) -> None: # Set the default order properties self.DefaultOrderProperties = CoinbaseProOrderProperties() self.DefaultOrderProperties.TimeInForce = TimeInForce.GoodTilCanceled self.DefaultOrderProperties.PostOnly = False def OnData(self, slice: Slice) -> None: # Use default order order properties self.LimitOrder(self.symbol, quantity, limit_price) # Override the default order properties order_properties = CoinbaseProOrderProperties() order_properties.TimeInForce = TimeInForce.GoodTilCanceled order_properties.PostOnly = True self.LimitOrder(self.symbol, quantity, limit_price, orderProperties=order_properties)
Updates
We model the Coinbase Pro API by not supporting order updates, but you can cancel an existing order and then create a new order with the desired arguments.
var ticket = LimitOrder(_symbol, quantity, limitPrice); ticket.Cancel(); ticket = LimitOrder(_symbol, newQuantity, newLimitPrice);
ticket = self.LimitOrder(self.symbol, quantity, limit_price) ticket.Cancel() ticket = self.LimitOrder(self.symbol, new_quantity, new_limit_price)
Fees
We model the order fees of Coinbase Pro at the $50K-100K pricing tier for all Crypto pairs, which is a 0.5% maker and taker fee for most pairs. The following table shows the Coinbase Pro Stable Pairs, which charge a 0% maker fee and a 0.1% taker fee:
Stable Pairs | |||
---|---|---|---|
DAIUSDC | DAIUSD | GYENUSD | PAXUSD |
PAXUSDT | MUSDUSD | USDCEUR | USDCGBP |
USDTEUR | USDTGBP | USDTUSD | USDTUSDC |
USTEUR | USTUSD | USTUSDT | WBTCBTC |
If you add liquidity to the order book by placing a limit order that doesn't cross the spread, you pay maker fees. If you remove liquidity from the order book by placing an order that crosses the spread, you pay taker fees. Coinbase Pro adjusts your fees based on your 30-day trading volume, but we don't currently model trading volume to adjust fees.
We model the adjustments Coinbase Pro has made to their fees over time. The following table shows the fees for each time period:
Time Period (UTC) | Maker Fee (%) | Taker Fee (%) |
---|---|---|
Time < 3/23/2019 1:30AM | 0 | 0.3 |
3/23/2019 1:30AM <= Time < 10/8/2019 12:30AM | 0.15 | 0.25 |
10/8/2019 12:30AM <= Time | 0.5 | 0.5 |
To check the latest fees at all the fee levels, see the What are the fees on Coinbase Pro? page on the Coinbase Pro website.
Security and Stability
Note the following security and stability aspects of our Coinbase Pro integration.
Account Credentials
When you deploy live algorithms with Coinbase Pro, we don't save your brokerage account credentials.
API Outages
We call the Coinbase Pro API to place live trades. Sometimes the API may be down. Check the Coinbase Pro status page to see if the API is currently working.
Deploy Live Algorithms
You must have an available live trading node for each live trading algorithm you deploy.
Follow these steps to deploy a live algorithm:
- Open the project you want to deploy.
- Click the
Deploy Live icon.
- On the Deploy Live page, click the Brokerage field and then click from the drop-down menu.
- Enter your Coinbase Pro API key, API secret, and passphrase.
- Click on the Environment field and then click one of the environments.
- Click the Node field and then click the live trading node that you want to use from the drop-down menu.
- (Optional) Set up notifications.
- Configure the Automatically restart algorithm setting.
- Click .
To generate your API credentials, see Account Types. Your account details are not saved on QuantConnect.
The following table shows the supported environments:
Environment | Description |
---|---|
Live | Trade with real money |
Paper | Trade with paper money |
By enabling automatic restarts, the algorithm will use best efforts to restart the algorithm if it fails due to a runtime error. This can help improve the algorithm's resilience to temporary outages such as a brokerage API disconnection.
The deployment process can take up to 5 minutes. When the algorithm deploys, the live results page displays. If you know your brokerage positions before you deployed, you can verify they have been loaded properly by checking your equity value in the runtime statistics, your cashbook holdings, and your position holdings.