Supported Models

Coinbase

Introduction

This page explains GDAXBrokerageModel, including the asset classes it supports, its default security-level models, and it's default markets.

SetBrokerageModel(BrokerageName.GDAX, AccountType.Cash);
self.SetBrokerageModel(BrokerageName.GDAX, AccountType.Cash)

To view the implementation of this model, see the LEAN GitHub repository.

Asset Classes

The GDAXBrokerageModel supports trading Crypto.

Orders

The GDAXBrokerageModel supports several order types and order properties, but it doesn't support order updates.

Order Types

The following table describes the available order types for each asset class that the GDAXBrokerageModel supports:

Order TypeCrypto
MarketOrdergreen check
LimitOrdergreen check
StopMarketOrdergreen check
Supported after 2019-03-23 in backtests. For reference, see the Coinbase Market Structure Update on the Coinbase website.
StopLimitOrdergreen check

Order Properties

The GDAXBrokerageModel supports custom order properties. The following table describes the members of the GDAXOrderProperties object that you can set to customize order execution:

PropertyDescription
TimeInForceA TimeInForce instruction to apply to the order. The GoodTilCanceled TimeInForce is supported.
PostOnlyA 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 GDAXOrderProperties
    {
        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 GDAXOrderProperties
               { 
                   TimeInForce = TimeInForce.GoodTilCanceled,
                   PostOnly = true
               });
}
def Initialize(self) -> None:
    # Set the default order properties
    self.DefaultOrderProperties = GDAXOrderProperties()
    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 = GDAXOrderProperties()
    order_properties.TimeInForce = TimeInForce.GoodTilCanceled
    order_properties.PostOnly = True
    self.LimitOrder(self.symbol, quantity, limit_price, orderProperties=order_properties)

Updates

The GDAXBrokerageModel doesn't support order updates, but you can cancel an existing order and then create a new order with the desired arguments. For more information about this workaround, see the Workaround for Brokerages That Don’t Support Updates.

Fills

The GDAXBrokerageModel uses the ImmediateFillModel.

Slippage

The GDAXBrokerageModel uses the ConstantSlippageModel with zero slippage.

security.SetSlippageModel(new ConstantSlippageModel(0));
security.SetSlippageModel(ConstantSlippageModel(0))

Fees

The GDAXBrokerageModel uses the GDAXFeeModel.

Buying Power

The GDAXBrokerageModel uses the CashBuyingPowerModel. The brokerage model doesn't currently support margin trading.

Settlement

The GDAXBrokerageModel uses the ImmediateSettlementModel.

Margin Interest Rate

The GDAXBrokerageModel uses the NullMarginInterestRateModel.

Default Markets

The default market of the GDAXBrokerageModel is Market.GDAX.

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: