Lean  $LEAN_TAG$
FillModelParameters.cs
1 /*
2  * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
3  * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14 */
15 
16 using System;
17 using System.Collections.Generic;
18 using QuantConnect.Data;
21 
23 {
24  /// <summary>
25  /// Defines the parameters for the <see cref="IFillModel"/> method
26  /// </summary>
27  public class FillModelParameters
28  {
29  /// <summary>
30  /// Gets the <see cref="Security"/>
31  /// </summary>
32  public Security Security { get; }
33 
34  /// <summary>
35  /// Gets the <see cref="Order"/>
36  /// </summary>
37  public Order Order { get; }
38 
39  /// <summary>
40  /// Gets the <see cref="SubscriptionDataConfig"/> provider
41  /// </summary>
43 
44  /// <summary>
45  /// Gets the minimum time span elapsed to consider a market fill price as stale (defaults to one hour)
46  /// </summary>
47  public TimeSpan StalePriceTimeSpan { get; }
48 
49  /// <summary>
50  /// Gets the collection of securities by order
51  /// </summary>
52  /// <remarks>We need this so that combo limit orders can access the prices for each security to calculate the price for the fill</remarks>
53  public Dictionary<Order, Security> SecuritiesForOrders { get; }
54 
55  /// <summary>
56  /// Callback to notify when an order is updated by the fill model
57  /// </summary>
58  public Action<Order> OnOrderUpdated { get; }
59 
60  /// <summary>
61  /// Creates a new instance
62  /// </summary>
63  /// <param name="security">Security asset we're filling</param>
64  /// <param name="order">Order packet to model</param>
65  /// <param name="configProvider">The <see cref="ISubscriptionDataConfigProvider"/> to use</param>
66  /// <param name="stalePriceTimeSpan">The minimum time span elapsed to consider a fill price as stale</param>
67  /// <param name="securitiesForOrders">Collection of securities for each order</param>
69  Security security,
70  Order order,
71  ISubscriptionDataConfigProvider configProvider,
72  TimeSpan stalePriceTimeSpan,
73  Dictionary<Order, Security> securitiesForOrders,
74  Action<Order> onOrderUpdated = null)
75  {
76  Security = security;
77  Order = order;
78  ConfigProvider = configProvider;
79  StalePriceTimeSpan = stalePriceTimeSpan;
80  SecuritiesForOrders = securitiesForOrders;
81  OnOrderUpdated = onOrderUpdated ?? (o => { });
82  }
83  }
84 }