Lean  $LEAN_TAG$
QuantConnect.Interfaces.IBrokerage Interface Reference

Brokerage interface that defines the operations all brokerages must implement. The IBrokerage implementation must have a matching IBrokerageFactory implementation. More...

Inheritance diagram for QuantConnect.Interfaces.IBrokerage:
[legend]

Public Member Functions

List< OrderGetOpenOrders ()
 Gets all open orders on the account More...
 
List< HoldingGetAccountHoldings ()
 Gets all holdings for the account More...
 
List< CashAmountGetCashBalance ()
 Gets the current cash balance for each currency held in the brokerage account More...
 
bool PlaceOrder (Order order)
 Places a new order and assigns a new broker ID to the order More...
 
bool UpdateOrder (Order order)
 Updates the order with the same id More...
 
bool CancelOrder (Order order)
 Cancels the order with the specified ID More...
 
void Connect ()
 Connects the client to the broker's remote servers More...
 
void Disconnect ()
 Disconnects the client from the broker's remote servers More...
 
IEnumerable< BaseDataGetHistory (HistoryRequest request)
 Gets the history for the requested security More...
 
- Public Member Functions inherited from QuantConnect.Interfaces.IBrokerageCashSynchronizer
bool ShouldPerformCashSync (DateTime currentTimeUtc)
 Returns whether the brokerage should perform the cash synchronization More...
 
bool PerformCashSync (IAlgorithm algorithm, DateTime currentTimeUtc, Func< TimeSpan > getTimeSinceLastFill)
 Synchronizes the cashbook with the brokerage account More...
 

Properties

string Name [get]
 Gets the name of the brokerage More...
 
bool IsConnected [get]
 Returns true if we're currently connected to the broker More...
 
bool AccountInstantlyUpdated [get]
 Specifies whether the brokerage will instantly update account balances More...
 
string AccountBaseCurrency [get]
 Returns the brokerage account's base currency More...
 
- Properties inherited from QuantConnect.Interfaces.IBrokerageCashSynchronizer
DateTime LastSyncDateTimeUtc [get]
 Gets the datetime of the last sync (UTC) More...
 

Events

EventHandler< BrokerageOrderIdChangedEventOrderIdChanged
 Event that fires each time the brokerage order id changes More...
 
EventHandler< List< OrderEvent > > OrdersStatusChanged
 
EventHandler< OrderUpdateEventOrderUpdated
 Event that fires each time an order is updated in the brokerage side More...
 
EventHandler< OrderEventOptionPositionAssigned
 Event that fires each time a short option position is assigned More...
 
EventHandler< OptionNotificationEventArgsOptionNotification
 Event that fires each time an option position has changed More...
 
EventHandler< NewBrokerageOrderNotificationEventArgsNewBrokerageOrderNotification
 Event that fires each time there's a brokerage side generated order More...
 
EventHandler< DelistingNotificationEventArgsDelistingNotification
 Event that fires each time a delisting occurs More...
 
EventHandler< AccountEventAccountChanged
 Event that fires each time a user's brokerage account is changed More...
 
EventHandler< BrokerageMessageEventMessage
 Event that fires when a message is received from the brokerage More...
 

Detailed Description

Brokerage interface that defines the operations all brokerages must implement. The IBrokerage implementation must have a matching IBrokerageFactory implementation.

Definition at line 29 of file IBrokerage.cs.

Member Function Documentation

◆ GetOpenOrders()

List<Order> QuantConnect.Interfaces.IBrokerage.GetOpenOrders ( )

Gets all open orders on the account

Returns
The open orders returned from IB

Implemented in QuantConnect.Brokerages.Brokerage, and QuantConnect.Brokerages.Backtesting.BacktestingBrokerage.

Here is the caller graph for this function:

◆ GetAccountHoldings()

List<Holding> QuantConnect.Interfaces.IBrokerage.GetAccountHoldings ( )

Gets all holdings for the account

Returns
The current holdings from the account

Implemented in QuantConnect.Brokerages.Brokerage, QuantConnect.Brokerages.Backtesting.BacktestingBrokerage, and QuantConnect.Brokerages.Paper.PaperBrokerage.

◆ GetCashBalance()

List<CashAmount> QuantConnect.Interfaces.IBrokerage.GetCashBalance ( )

Gets the current cash balance for each currency held in the brokerage account

Returns
The current cash balance for each currency available for trading

Implemented in QuantConnect.Brokerages.Brokerage, QuantConnect.Brokerages.Backtesting.BacktestingBrokerage, and QuantConnect.Brokerages.Paper.PaperBrokerage.

◆ PlaceOrder()

bool QuantConnect.Interfaces.IBrokerage.PlaceOrder ( Order  order)

Places a new order and assigns a new broker ID to the order

Parameters
orderThe order to be placed
Returns
True if the request for a new order has been placed, false otherwise

Implemented in QuantConnect.Brokerages.Backtesting.BacktestingBrokerage, and QuantConnect.Brokerages.Brokerage.

◆ UpdateOrder()

bool QuantConnect.Interfaces.IBrokerage.UpdateOrder ( Order  order)

Updates the order with the same id

Parameters
orderThe new order information
Returns
True if the request was made for the order to be updated, false otherwise

Implemented in QuantConnect.Brokerages.Backtesting.BacktestingBrokerage, and QuantConnect.Brokerages.Brokerage.

◆ CancelOrder()

bool QuantConnect.Interfaces.IBrokerage.CancelOrder ( Order  order)

Cancels the order with the specified ID

Parameters
orderThe order to cancel
Returns
True if the request was made for the order to be canceled, false otherwise

Implemented in QuantConnect.Brokerages.Backtesting.BacktestingBrokerage, and QuantConnect.Brokerages.Brokerage.

◆ Connect()

void QuantConnect.Interfaces.IBrokerage.Connect ( )

Connects the client to the broker's remote servers

Implemented in QuantConnect.Brokerages.Backtesting.BacktestingBrokerage, QuantConnect.Brokerages.Brokerage, and QuantConnect.Brokerages.BaseWebsocketsBrokerage.

Here is the caller graph for this function:

◆ Disconnect()

void QuantConnect.Interfaces.IBrokerage.Disconnect ( )

Disconnects the client from the broker's remote servers

Implemented in QuantConnect.Brokerages.Backtesting.BacktestingBrokerage, and QuantConnect.Brokerages.Brokerage.

Here is the caller graph for this function:

◆ GetHistory()

IEnumerable<BaseData> QuantConnect.Interfaces.IBrokerage.GetHistory ( HistoryRequest  request)

Gets the history for the requested security

Parameters
requestThe historical data request
Returns
An enumerable of bars covering the span specified in the request

Implemented in QuantConnect.Brokerages.Brokerage.

Here is the caller graph for this function:

Property Documentation

◆ Name

string QuantConnect.Interfaces.IBrokerage.Name
get

Gets the name of the brokerage

Definition at line 82 of file IBrokerage.cs.

◆ IsConnected

bool QuantConnect.Interfaces.IBrokerage.IsConnected
get

Returns true if we're currently connected to the broker

Definition at line 87 of file IBrokerage.cs.

◆ AccountInstantlyUpdated

bool QuantConnect.Interfaces.IBrokerage.AccountInstantlyUpdated
get

Specifies whether the brokerage will instantly update account balances

Definition at line 141 of file IBrokerage.cs.

◆ AccountBaseCurrency

string QuantConnect.Interfaces.IBrokerage.AccountBaseCurrency
get

Returns the brokerage account's base currency

Definition at line 146 of file IBrokerage.cs.

Event Documentation

◆ OrderIdChanged

EventHandler<BrokerageOrderIdChangedEvent> QuantConnect.Interfaces.IBrokerage.OrderIdChanged

Event that fires each time the brokerage order id changes

Definition at line 34 of file IBrokerage.cs.

◆ OrdersStatusChanged

EventHandler<List<OrderEvent> > QuantConnect.Interfaces.IBrokerage.OrdersStatusChanged

Event that fires each time the status for a list of orders change

Definition at line 38 of file IBrokerage.cs.

◆ OrderUpdated

EventHandler<OrderUpdateEvent> QuantConnect.Interfaces.IBrokerage.OrderUpdated

Event that fires each time an order is updated in the brokerage side

These are not status changes but mainly price changes, like the stop price of a trailing stop order

Definition at line 46 of file IBrokerage.cs.

◆ OptionPositionAssigned

EventHandler<OrderEvent> QuantConnect.Interfaces.IBrokerage.OptionPositionAssigned

Event that fires each time a short option position is assigned

Definition at line 51 of file IBrokerage.cs.

◆ OptionNotification

EventHandler<OptionNotificationEventArgs> QuantConnect.Interfaces.IBrokerage.OptionNotification

Event that fires each time an option position has changed

Definition at line 56 of file IBrokerage.cs.

◆ NewBrokerageOrderNotification

EventHandler<NewBrokerageOrderNotificationEventArgs> QuantConnect.Interfaces.IBrokerage.NewBrokerageOrderNotification

Event that fires each time there's a brokerage side generated order

Definition at line 61 of file IBrokerage.cs.

◆ DelistingNotification

EventHandler<DelistingNotificationEventArgs> QuantConnect.Interfaces.IBrokerage.DelistingNotification

Event that fires each time a delisting occurs

TODO: Wire brokerages to call this event to process delistings

Definition at line 67 of file IBrokerage.cs.

◆ AccountChanged

EventHandler<AccountEvent> QuantConnect.Interfaces.IBrokerage.AccountChanged

Event that fires each time a user's brokerage account is changed

Definition at line 72 of file IBrokerage.cs.

◆ Message

EventHandler<BrokerageMessageEvent> QuantConnect.Interfaces.IBrokerage.Message

Event that fires when a message is received from the brokerage

Definition at line 77 of file IBrokerage.cs.


The documentation for this interface was generated from the following file: