Lean  $LEAN_TAG$
ITradeBuilder.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.Collections.Generic;
18 using QuantConnect.Orders;
21 
23 {
24  /// <summary>
25  /// Generates trades from executions and market price updates
26  /// </summary>
27  public interface ITradeBuilder
28  {
29  /// <summary>
30  /// Sets the security manager instance
31  /// </summary>
32  /// <param name="securities">The security manager</param>
33  void SetSecurityManager(SecurityManager securities);
34 
35  /// <summary>
36  /// Sets the live mode flag
37  /// </summary>
38  /// <param name="live">The live mode flag</param>
39  void SetLiveMode(bool live);
40 
41  /// <summary>
42  /// The list of closed trades
43  /// </summary>
44  List<Trade> ClosedTrades { get; }
45 
46  /// <summary>
47  /// Returns true if there is an open position for the symbol
48  /// </summary>
49  /// <param name="symbol">The symbol</param>
50  /// <returns>true if there is an open position for the symbol</returns>
51  bool HasOpenPosition(Symbol symbol);
52 
53  /// <summary>
54  /// Sets the current market price for the symbol
55  /// </summary>
56  /// <param name="symbol"></param>
57  /// <param name="price"></param>
58  void SetMarketPrice(Symbol symbol, decimal price);
59 
60  /// <summary>
61  /// Applies a split to the trade builder
62  /// </summary>
63  /// <param name="split">The split to be applied</param>
64  /// <param name="liveMode">True if live mode, false for backtest</param>
65  /// <param name="dataNormalizationMode">The <see cref="DataNormalizationMode"/> for this security</param>
66  void ApplySplit(Split split, bool liveMode, DataNormalizationMode dataNormalizationMode);
67 
68  /// <summary>
69  /// Processes a new fill, eventually creating new trades
70  /// </summary>
71  /// <param name="fill">The new fill order event</param>
72  /// <param name="securityConversionRate">The current security market conversion rate into the account currency</param>
73  /// <param name="feeInAccountCurrency">The current order fee in the account currency</param>
74  /// <param name="multiplier">The contract multiplier</param>
75  void ProcessFill(OrderEvent fill,
76  decimal securityConversionRate,
77  decimal feeInAccountCurrency,
78  decimal multiplier = 1.0m);
79  }
80 }