/* * 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.Collections.Concurrent; using System.Collections.Generic; using System.ComponentModel.Composition; using QuantConnect.Interfaces; using QuantConnect.Lean.Engine.Results; using QuantConnect.Orders; using QuantConnect.Securities; namespace QuantConnect.Lean.Engine.TransactionHandlers { /// /// Transaction handlers define how the transactions are processed and set the order fill information. /// The pass this information back to the algorithm portfolio and ensure the cash and portfolio are synchronized. /// [InheritedExport(typeof(ITransactionHandler))] public interface ITransactionHandler : IOrderProcessor, IOrderEventProvider { /// /// Boolean flag indicating the thread is busy. /// False indicates it is completely finished processing and ready to be terminated. /// bool IsActive { get; } /// /// Gets the permanent storage for all orders /// ConcurrentDictionary Orders { get; } /// /// Gets all order events /// IEnumerable OrderEvents { get; } /// /// Gets the permanent storage for all order tickets /// ConcurrentDictionary OrderTickets { get; } /// /// Initializes the transaction handler for the specified algorithm using the specified brokerage implementation /// void Initialize(IAlgorithm algorithm, IBrokerage brokerage, IResultHandler resultHandler); /// /// Signal a end of thread request to stop montioring the transactions. /// void Exit(); /// /// Process any synchronous events from the primary algorithm thread. /// void ProcessSynchronousEvents(); /// /// Register an already open Order /// void AddOpenOrder(Order order, IAlgorithm algorithm); } }