Supported Models
Bitfinex
Introduction
This page explains the BitfinexBrokerageModel, including the asset classes it supports, its default security-level models, and its default markets.
SetBrokerageModel(BrokerageName.Bitfinex, AccountType.Cash); SetBrokerageModel(BrokerageName.Bitfinex, AccountType.Margin);
self.set_brokerage_model(BrokerageName.BITFINEX, AccountType.CASH) self.set_brokerage_model(BrokerageName.BITFINEX, AccountType.MARGIN)
For more information about this model, see the class reference and implementation.
For more information about this model, see the class reference and implementation.
Asset Classes
The BitfinexBrokerageModel supports trading Crypto.
Orders
The BitfinexBrokerageModel supports several order types, order properties, and order updates.
Order Types
The following table describes the available order types for each asset class that the BitfinexBrokerageModel supports:
| Order Type | Crypto |
|---|---|
| Market | ![]() |
| Limit | ![]() |
| Stop market | ![]() |
| Stop limit | ![]() |
Order Properties
The BitfinexBrokerageModel supports custom order properties. The following table describes the members of the BitfinexOrderProperties object that you can set to customize order execution:
| Property | Data Type | Description | Default Value |
|---|---|---|---|
TimeInForcetime_in_force | TimeInForce |
A TimeInForce instruction to apply to the order. The following instructions are supported:
| TimeInForce.GoodTilCanceledTimeInForce.GOOD_TIL_CANCELED |
Hiddenhidden | bool | A flag to signal that the order should be hidden. Hidden orders do not appear in the order book, so they do not influence other market participants. Hidden orders incur the taker fee. | |
PostOnlypost_only | bool | A flag to signal that 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 BitfinexOrderProperties
{
TimeInForce = TimeInForce.GoodTilCanceled,
Hidden = false,
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 BitfinexOrderProperties
{
TimeInForce = TimeInForce.Day,
Hidden = true,
PostOnly = false
});
LimitOrder(_symbol, quantity, limitPrice,
orderProperties: new BitfinexOrderProperties
{
TimeInForce = TimeInForce.GoodTilDate(new DateTime(year, month, day)),
Hidden = false,
PostOnly = true
});
} def initialize(self) -> None:
# Set the default order properties
self.default_order_properties = BitfinexOrderProperties()
self.default_order_properties.time_in_force = TimeInForce.GOOD_TIL_CANCELED
self.default_order_properties.hidden = False
self.default_order_properties.post_only = False
def on_data(self, slice: Slice) -> None:
# Use default order order properties
self.limit_order(self._symbol, quantity, limit_price)
# Override the default order properties
order_properties = BitfinexOrderProperties()
order_properties.time_in_force = TimeInForce.DAY
order_properties.hidden = True
order_properties.post_only = False
self.limit_order(self._symbol, quantity, limit_price, order_properties=order_properties)
order_properties.time_in_force = TimeInForce.good_til_date(datetime(year, month, day))
order_properties.hidden = False
order_properties.post_only = True
self.limit_order(self._symbol, quantity, limit_price, order_properties=order_properties)
Updates
The BitfinexBrokerageModel supports order updates.
Fills
The BitfinexBrokerageModel uses the ImmediateFillModel.
Slippage
The BitfinexBrokerageModel uses the NullSlippageModel.
Fees
The BitfinexBrokerageModel uses the BitfinexFeeModel with the default argument values that models the current Bitfinex fee schedule.
Settlement
The BitfinexBrokerageModel uses the ImmediateSettlementModel.
Margin Interest Rate
The BitfinexBrokerageModel uses the NullMarginInterestRateModel.
Account Currency
The BitfinexBrokerageModel doesn't set a default currency.
To change the algorithm's currency from USD to a different currency, see Set Account Currency.
