QuantConnect / Lean

Lean Algorithmic Trading Engine by QuantConnect (Python, C#)
https://lean.io
Apache License 2.0
9.5k stars 3.22k forks source link

Adds OnOrderEvent Method to Execution Models #3834

Open AlexCatarino opened 4 years ago

AlexCatarino commented 4 years ago

Expected Behavior

ExecutionModel has OnOrderEvent method that can be used to manage the orders placed by ExecutionModel.Execute

Actual Behavior

ExecutionModel doesn't have OnOrderEvent method. If the algorithm needs to create complex order combinations, like OCO, it has to be managed by QCAlgorithm.OnOderEvent.

Potential Solution

Implement IExecutionModel.OnOderEvent(QCAlgorithm algorithm, OrderEvent orderEvent)

Checklist

ramonne69 commented 4 years ago

`/*

using QuantConnect.Algorithm.Framework.Portfolio; using QuantConnect.Orders;

namespace QuantConnect.Algorithm.Framework.Execution { ///

/// Algorithm framework model that executes portfolio targets /// public interface IExecutionModel : INotifiedSecurityChanges { /// /// Submit orders for the specified portfolio targets. /// This model is free to delay or spread out these orders as it sees fit /// /// The algorithm instance /// The portfolio targets just emitted by the portfolio construction model. /// These are always just the new/updated targets and not a complete set of targets void Execute(QCAlgorithm algorithm, IPortfolioTarget[] targets);

    /// <summary>
    /// Permit to access to OrderEvent method. (In order to use for example OCO)
    /// </summary>
    /// <param name="algorithm">The algorithm instance</param>
    /// <param name="orderEvent">
    /// These are always just the new/updated targets and not a complete set of targets</param>
    void OnOrderEvent(QCAlgorithm algorithm, OrderEvent orderEvent);
}

} `

ramonne69 commented 4 years ago

Hi, I Am Gmamuze Cht on the Forum, if you want, tell me what files to modify, then send you once the work is done. Best

stefanstoeckigt commented 2 years ago

Has this been implemented yet? Trying to use order events in an Execution Model.