Lean  $LEAN_TAG$
SymbolProperties.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 
19 {
20  /// <summary>
21  /// Represents common properties for a specific security, uniquely identified by market, symbol and security type
22  /// </summary>
23  public class SymbolProperties
24  {
25  /// <summary>
26  /// The description of the security
27  /// </summary>
28  public string Description
29  {
30  get;
31  }
32 
33  /// <summary>
34  /// The quote currency of the security
35  /// </summary>
36  public string QuoteCurrency
37  {
38  get;
39  }
40 
41  /// <summary>
42  /// The contract multiplier for the security
43  /// </summary>
44  public decimal ContractMultiplier
45  {
46  get;
47  protected set;
48  }
49 
50  /// <summary>
51  /// The minimum price variation (tick size) for the security
52  /// </summary>
53  public virtual decimal MinimumPriceVariation
54  {
55  get;
56  protected set;
57  }
58 
59  /// <summary>
60  /// The lot size (lot size of the order) for the security
61  /// </summary>
62  public decimal LotSize
63  {
64  get;
65  }
66 
67  /// <summary>
68  /// The market ticker
69  /// </summary>
70  public string MarketTicker
71  {
72  get;
73  }
74 
75  /// <summary>
76  /// The minimum order size allowed
77  /// For crypto/forex pairs it's expected to be expressed in base or quote currency
78  /// i.e For BTC/USD the minimum order size allowed with Coinbase is 0.0001 BTC
79  /// while on Binance the minimum order size allowed is 10 USD
80  /// </summary>
81  public decimal? MinimumOrderSize
82  {
83  get;
84  }
85 
86  /// <summary>
87  /// Allows normalizing live asset prices to US Dollars for Lean consumption. In some exchanges,
88  /// for some securities, data is expressed in cents like for example for corn futures ('ZC').
89  /// </summary>
90  /// <remarks>Default value is 1 but for some futures in cents it's 100</remarks>
91  public decimal PriceMagnifier
92  {
93  get;
94  }
95 
96  /// <summary>
97  /// Scale factor for option's strike price. For some options, such as NQX, the strike price
98  /// is based on a fraction of the underlying, thus this paramater scales the strike price so
99  /// that it can be used in comparation with the underlying such as
100  /// in <see cref="OptionFilterUniverse.Strikes(int, int)"/>
101  /// </summary>
102  public decimal StrikeMultiplier
103  {
104  get;
105  }
106 
107  /// <summary>
108  /// Creates an instance of the <see cref="SymbolProperties"/> class
109  /// </summary>
110  public SymbolProperties(string description, string quoteCurrency, decimal contractMultiplier, decimal minimumPriceVariation, decimal lotSize, string marketTicker, decimal? minimumOrderSize = null, decimal priceMagnifier = 1, decimal strikeMultiplier = 1)
111  {
112  Description = description;
113  QuoteCurrency = quoteCurrency;
114  ContractMultiplier = contractMultiplier;
115  MinimumPriceVariation = minimumPriceVariation;
116  LotSize = lotSize;
117 
118  if (LotSize <= 0)
119  {
120  throw new ArgumentException(Messages.SymbolProperties.InvalidLotSize);
121  }
122 
123  MarketTicker = marketTicker;
124  MinimumOrderSize = minimumOrderSize;
125 
126  PriceMagnifier = priceMagnifier;
127  if (PriceMagnifier <= 0)
128  {
129  throw new ArgumentException(Messages.SymbolProperties.InvalidPriceMagnifier);
130  }
131 
132  StrikeMultiplier = strikeMultiplier;
133  if (strikeMultiplier <= 0)
134  {
135  throw new ArgumentException(Messages.SymbolProperties.InvalidStrikeMultiplier);
136  }
137  }
138 
139  /// <summary>
140  /// The string representation of these symbol properties
141  /// </summary>
142  public override string ToString()
143  {
144  return Messages.SymbolProperties.ToString(this);
145  }
146 
147  /// <summary>
148  /// Gets a default instance of the <see cref="SymbolProperties"/> class for the specified <paramref name="quoteCurrency"/>
149  /// </summary>
150  /// <param name="quoteCurrency">The quote currency of the symbol</param>
151  /// <returns>A default instance of the<see cref="SymbolProperties"/> class</returns>
152  public static SymbolProperties GetDefault(string quoteCurrency)
153  {
154  return new SymbolProperties(string.Empty, quoteCurrency.LazyToUpper(), 1, 0.01m, 1, string.Empty);
155  }
156  }
157 }