Lean  $LEAN_TAG$
AddSecurityCommand.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 
18 
20 {
21  /// <summary>
22  /// Represents a command to add a security to the algorithm
23  /// </summary>
25  {
26  /// <summary>
27  /// The security type of the security
28  /// </summary>
29  public SecurityType SecurityType { get; set; }
30 
31  /// <summary>
32  /// The security's ticker symbol
33  /// </summary>
34  public string Symbol { get; set; }
35 
36  /// <summary>
37  /// The requested resolution, defaults to Resolution.Minute
38  /// </summary>
39  public Resolution Resolution { get; set; }
40 
41  /// <summary>
42  /// The security's market, defaults to <see cref="QuantConnect.Market.USA"/> except for Forex, defaults to <see cref="QuantConnect.Market.FXCM"/>
43  /// </summary>
44  public string Market { get; set; }
45 
46  /// <summary>
47  /// The fill forward behavior, true to fill forward, false otherwise - defaults to true
48  /// </summary>
49  public bool FillDataForward { get; set; }
50 
51  /// <summary>
52  /// The leverage for the security, defaults to 2 for equity, 50 for forex, and 1 for everything else
53  /// </summary>
54  public decimal Leverage { get; set; }
55 
56  /// <summary>
57  /// The extended market hours flag, true to allow pre/post market data, false for only in market data
58  /// </summary>
59  public bool ExtendedMarketHours { get; set; }
60 
61  /// <summary>
62  /// Default construct that applies default values
63  /// </summary>
65  {
66  Resolution = Resolution.Minute;
67  Market = null;
68  FillDataForward = true;
70  ExtendedMarketHours = false;
71  }
72 
73  /// <summary>
74  /// Runs this command against the specified algorithm instance
75  /// </summary>
76  /// <param name="algorithm">The algorithm to run this command against</param>
77  public override CommandResultPacket Run(IAlgorithm algorithm)
78  {
80  return new Result(this, true, security.Symbol);
81  }
82 
83  /// <summary>
84  /// Result packet type for the <see cref="AddSecurityCommand"/> command
85  /// </summary>
86  public class Result : CommandResultPacket
87  {
88  /// <summary>
89  /// The symbol result from the add security command
90  /// </summary>
91  public Symbol Symbol { get; set; }
92 
93  /// <summary>
94  /// Initializes a new instance of the <see cref="Result"/> class
95  /// </summary>
96  public Result(AddSecurityCommand command, bool success, Symbol symbol)
97  : base(command, success)
98  {
99  Symbol = symbol;
100  }
101  }
102  }
103 }