Lean  $LEAN_TAG$
ModeledGreeks.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  /// Defines the greeks
22  /// </summary>
23  internal class ModeledGreeks : Greeks
24  {
25  private Lazy<decimal> _delta;
26  private Lazy<decimal> _gamma;
27  private Lazy<decimal> _vega;
28  private Lazy<decimal> _theta;
29  private Lazy<decimal> _rho;
30  private Lazy<decimal> _lambda;
31 
32  /// <summary>
33  /// Gets the delta
34  /// </summary>
35  public override decimal Delta => _delta.Value;
36 
37  /// <summary>
38  /// Gets the gamma
39  /// </summary>
40  public override decimal Gamma => _gamma.Value;
41 
42  /// <summary>
43  /// Gets the vega
44  /// </summary>
45  public override decimal Vega => _vega.Value;
46 
47  /// <summary>
48  /// Gets the theta
49  /// </summary>
50  public override decimal Theta => _theta.Value;
51 
52  /// <summary>
53  /// Gets the rho
54  /// </summary>
55  public override decimal Rho => _rho.Value;
56 
57  /// <summary>
58  /// Gets the lambda
59  /// </summary>
60  public override decimal Lambda => _lambda.Value;
61 
62  /// <summary>
63  /// Initializes a new instance of the <see cref="ModeledGreeks"/> class
64  /// </summary>
65  public ModeledGreeks(Func<decimal> delta, Func<decimal> gamma, Func<decimal> vega, Func<decimal> theta, Func<decimal> rho, Func<decimal> lambda)
66  {
67  _delta = new Lazy<decimal>(delta, isThreadSafe: false);
68  _gamma = new Lazy<decimal>(gamma, isThreadSafe: false);
69  _vega = new Lazy<decimal>(vega, isThreadSafe: false);
70  _theta = new Lazy<decimal>(theta, isThreadSafe: false);
71  _rho = new Lazy<decimal>(rho, isThreadSafe: false);
72  _lambda = new Lazy<decimal>(lambda, isThreadSafe: false);
73  }
74  }
75 }