1313 * limitations under the License.
1414*/
1515
16+ using Python . Runtime ;
1617using QuantConnect . Data . Market ;
1718using System ;
1819
@@ -28,16 +29,13 @@ public class OptionPriceModelResult
2829 /// </summary>
2930 public static OptionPriceModelResult None { get ; } = new ( 0 , NullGreeks . Instance ) ;
3031
31- private readonly Lazy < Greeks > _greeks ;
32- private readonly Lazy < decimal > _impliedVolatility ;
32+ private Lazy < Greeks > _greeks ;
33+ private Lazy < decimal > _impliedVolatility ;
3334
3435 /// <summary>
3536 /// Gets the theoretical price as computed by the <see cref="IOptionPriceModel"/>
3637 /// </summary>
37- public decimal TheoreticalPrice
38- {
39- get ; private set ;
40- }
38+ public decimal TheoreticalPrice { get ; set ; }
4139
4240 /// <summary>
4341 /// Gets the implied volatility of the option contract
@@ -48,6 +46,10 @@ public decimal ImpliedVolatility
4846 {
4947 return _impliedVolatility . Value ;
5048 }
49+ set
50+ {
51+ _impliedVolatility = new Lazy < decimal > ( ( ) => value , isThreadSafe : false ) ;
52+ }
5153 }
5254
5355 /// <summary>
@@ -59,6 +61,17 @@ public Greeks Greeks
5961 {
6062 return _greeks . Value ;
6163 }
64+ set
65+ {
66+ _greeks = new Lazy < Greeks > ( ( ) => value , isThreadSafe : false ) ;
67+ }
68+ }
69+
70+ /// <summary>
71+ /// Initializes a new instance of the <see cref="OptionPriceModelResult"/> class
72+ /// </summary>
73+ public OptionPriceModelResult ( )
74+ {
6275 }
6376
6477 /// <summary>
@@ -73,6 +86,17 @@ public OptionPriceModelResult(decimal theoreticalPrice, Greeks greeks)
7386 _greeks = new Lazy < Greeks > ( ( ) => greeks , isThreadSafe : false ) ;
7487 }
7588
89+ /// <summary>
90+ /// Initializes a new instance of the <see cref="OptionPriceModelResult"/> class
91+ /// </summary>
92+ /// <param name="theoreticalPrice">The theoretical price computed by the price model</param>
93+ /// <param name="impliedVolatility">The calculated implied volatility</param>
94+ /// <param name="greeks">The sensitivities (greeks) computed by the price model</param>
95+ public OptionPriceModelResult ( decimal theoreticalPrice , decimal impliedVolatility , Greeks greeks )
96+ : this ( theoreticalPrice , ( ) => impliedVolatility , ( ) => greeks )
97+ {
98+ }
99+
76100 /// <summary>
77101 /// Initializes a new instance of the <see cref="OptionPriceModelResult"/> class with lazy calculations of implied volatility and greeks
78102 /// </summary>
@@ -85,5 +109,16 @@ public OptionPriceModelResult(decimal theoreticalPrice, Func<decimal> impliedVol
85109 _impliedVolatility = new Lazy < decimal > ( impliedVolatility , isThreadSafe : false ) ;
86110 _greeks = new Lazy < Greeks > ( greeks , isThreadSafe : false ) ;
87111 }
112+
113+ /// <summary>
114+ /// Initializes a new instance of the <see cref="OptionPriceModelResult"/> class with lazy calculations of implied volatility and greeks
115+ /// </summary>
116+ /// <param name="theoreticalPrice">The theoretical price computed by the price model</param>
117+ /// <param name="impliedVolatility">The calculated implied volatility</param>
118+ /// <param name="greeks">The sensitivities (greeks) computed by the price model</param>
119+ public OptionPriceModelResult ( decimal theoreticalPrice , PyObject impliedVolatility , PyObject greeks )
120+ : this ( theoreticalPrice , impliedVolatility . SafeAs < Func < decimal > > ( ) , greeks . SafeAs < Func < Greeks > > ( ) )
121+ {
122+ }
88123 }
89124}
0 commit comments