/* * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals. * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System; using System.Collections.Generic; using QuantConnect.Brokerages; using QuantConnect.Data; using QuantConnect.Orders; using QuantConnect.Securities; namespace QuantConnect.Interfaces { /// /// Brokerage interface that defines the operations all brokerages must implement. The IBrokerage implementation /// must have a matching IBrokerageFactory implementation. /// public interface IBrokerage : IBrokerageCashSynchronizer, IDisposable { /// /// Event that fires each time the brokerage order id changes /// event EventHandler OrderIdChanged; /// /// Event that fires each time the status for a list of orders change /// event EventHandler> OrdersStatusChanged; /// /// 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 /// event EventHandler OrderUpdated; /// /// Event that fires each time a short option position is assigned /// event EventHandler OptionPositionAssigned; /// /// Event that fires each time an option position has changed /// event EventHandler OptionNotification; /// /// Event that fires each time there's a brokerage side generated order /// event EventHandler NewBrokerageOrderNotification; /// /// Event that fires each time a delisting occurs /// /// TODO: Wire brokerages to call this event to process delistings event EventHandler DelistingNotification; /// /// Event that fires each time a user's brokerage account is changed /// event EventHandler AccountChanged; /// /// Event that fires when a message is received from the brokerage /// event EventHandler Message; /// /// Gets the name of the brokerage /// string Name { get; } /// /// Returns true if we're currently connected to the broker /// bool IsConnected { get; } /// /// Gets all open orders on the account /// /// The open orders returned from IB List GetOpenOrders(); /// /// Gets all holdings for the account /// /// The current holdings from the account List GetAccountHoldings(); /// /// Gets the current cash balance for each currency held in the brokerage account /// /// The current cash balance for each currency available for trading List GetCashBalance(); /// /// Places a new order and assigns a new broker ID to the order /// /// The order to be placed /// True if the request for a new order has been placed, false otherwise bool PlaceOrder(Order order); /// /// Updates the order with the same id /// /// The new order information /// True if the request was made for the order to be updated, false otherwise bool UpdateOrder(Order order); /// /// Cancels the order with the specified ID /// /// The order to cancel /// True if the request was made for the order to be canceled, false otherwise bool CancelOrder(Order order); /// /// Connects the client to the broker's remote servers /// void Connect(); /// /// Disconnects the client from the broker's remote servers /// void Disconnect(); /// /// Specifies whether the brokerage will instantly update account balances /// bool AccountInstantlyUpdated { get; } /// /// Returns the brokerage account's base currency /// string AccountBaseCurrency { get; } /// /// Gets the history for the requested security /// /// The historical data request /// An enumerable of bars covering the span specified in the request IEnumerable GetHistory(HistoryRequest request); /// /// Enables or disables concurrent processing of messages to and from the brokerage. /// bool ConcurrencyEnabled { get; set; } } }