Lean  $LEAN_TAG$
IndexOptionSymbolProperties.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 
17 using QuantConnect.Data;
19 
21 {
22  /// <summary>
23  /// Index Option Symbol Properties
24  /// </summary>
26  {
27  private BaseData _lastData;
28 
29  /// <summary>
30  /// Minimum price variation, subject to variability due to contract price
31  /// </summary>
32  public override decimal MinimumPriceVariation => MinimumPriceVariationForPrice(_lastData?.Symbol, _lastData?.Price);
33 
34  /// <summary>
35  /// Creates an instance of index symbol properties
36  /// </summary>
37  /// <param name="description">Description of the Symbol</param>
38  /// <param name="quoteCurrency">Currency the price is quoted in</param>
39  /// <param name="contractMultiplier">Contract multiplier of the index option</param>
40  /// <param name="pipSize">Minimum price variation</param>
41  /// <param name="lotSize">Minimum order lot size</param>
43  string description,
44  string quoteCurrency,
45  decimal contractMultiplier,
46  decimal pipSize,
47  decimal lotSize
48  )
49  : base(description, quoteCurrency, contractMultiplier, pipSize, lotSize)
50  {
51  }
52 
53  /// <summary>
54  /// Creates instance of index symbol properties
55  /// </summary>
56  /// <param name="properties"></param>
58  : base(properties)
59  {
60  }
61 
62  /// <summary>
63  /// Updates the last data received, required for calculating some
64  /// index options contracts that have a variable step size for their premium's quotes
65  /// </summary>
66  /// <param name="marketData">Data to update with</param>
67  internal void UpdateMarketPrice(BaseData marketData)
68  {
69  _lastData = marketData;
70  }
71 
72  /// <summary>
73  /// Minimum price variation, subject to variability due to contract price
74  /// </summary>
75  /// <remarks>https://www.cboe.com/tradable_products/vix/vix_options/specifications/
76  /// https://www.cboe.com/tradable_products/sp_500/spx_options/specifications/
77  /// https://www.nasdaq.com/docs/2022/08/24/1926-Q22_NDX%20Fact%20Sheet_NAM_v3.pdf</remarks>
78  public static decimal MinimumPriceVariationForPrice(Symbol symbol, decimal? referencePrice)
79  {
80  if(symbol == null || !referencePrice.HasValue)
81  {
82  return 0.05m;
83  }
84 
85  var aboveThree = 0.1m;
86  var belowThree = 0.05m;
87  if(symbol.ID.Symbol == "VIXW")
88  {
89  aboveThree = belowThree = 0.01m;
90  }
91  else if (symbol.ID.Symbol == "VIX")
92  {
93  belowThree = 0.01m;
94  aboveThree = 0.05m;
95  }
96 
97  return referencePrice.HasValue && referencePrice >= 3m ? aboveThree : belowThree;
98  }
99  }
100 }