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 GDAX 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  /// Creates an instance of the <see cref="SymbolProperties"/> class
98  /// </summary>
99  public SymbolProperties(string description, string quoteCurrency, decimal contractMultiplier, decimal minimumPriceVariation, decimal lotSize, string marketTicker, decimal? minimumOrderSize = null, decimal priceMagnifier = 1)
100  {
101  Description = description;
102  QuoteCurrency = quoteCurrency;
103  ContractMultiplier = contractMultiplier;
104  MinimumPriceVariation = minimumPriceVariation;
105  LotSize = lotSize;
106 
107  if (LotSize <= 0)
108  {
109  throw new ArgumentException(Messages.SymbolProperties.InvalidLotSize);
110  }
111 
112  MarketTicker = marketTicker;
113  MinimumOrderSize = minimumOrderSize;
114 
115  PriceMagnifier = priceMagnifier;
116  if (PriceMagnifier <= 0)
117  {
118  throw new ArgumentException(Messages.SymbolProperties.InvalidPriceMagnifier);
119  }
120  }
121 
122  /// <summary>
123  /// The string representation of these symbol properties
124  /// </summary>
125  public override string ToString()
126  {
127  return Messages.SymbolProperties.ToString(this);
128  }
129 
130  /// <summary>
131  /// Gets a default instance of the <see cref="SymbolProperties"/> class for the specified <paramref name="quoteCurrency"/>
132  /// </summary>
133  /// <param name="quoteCurrency">The quote currency of the symbol</param>
134  /// <returns>A default instance of the<see cref="SymbolProperties"/> class</returns>
135  public static SymbolProperties GetDefault(string quoteCurrency)
136  {
137  return new SymbolProperties(string.Empty, quoteCurrency.LazyToUpper(), 1, 0.01m, 1, string.Empty);
138  }
139  }
140 }