Supported Models
Bitfinex
Introduction
This page explains the BitfinexBrokerageModel
, including the asset classes it supports, its default security-level models, and it's 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)
To view the implementation of this model, see the LEAN GitHub repository.
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 | |
Limit if touched | |
Stop market | |
Stop limit | |
Market on open | |
Market on close |
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 |
---|---|---|---|
TimeInForce time_in_force | TimeInForce |
A TimeInForce instruction to apply to the order. The following instructions are supported:
| TimeInForce.GoodTilCanceled TimeInForce.GOOD_TIL_CANCELED |
Hidden hidden | 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. | |
PostOnly post_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.