Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jhonabreul committed Dec 13, 2024
1 parent e2937a6 commit da392b1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
3 changes: 1 addition & 2 deletions Indicators/ImpliedVolatility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,7 @@ protected override decimal Calculate(IndicatorDataPoint input)
RiskFreeRate.Update(time, _riskFreeInterestRateModel.GetInterestRate(time));
DividendYield.Update(time, _dividendYieldModel.GetDividendYield(time, UnderlyingPrice.Current.Value));

var timeTillExpiry = Convert.ToDecimal(
OptionGreekIndicatorsHelper.TimeTillExpiry(Securities.Option.OptionSymbol.GetSettlementDateTime(OptionSymbol), time));
var timeTillExpiry = Convert.ToDecimal(OptionGreekIndicatorsHelper.TimeTillExpiry(Expiry, time));
_impliedVolatility = CalculateIV(timeTillExpiry);
}

Expand Down
3 changes: 1 addition & 2 deletions Indicators/OptionGreekIndicatorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,7 @@ protected override decimal Calculate(IndicatorDataPoint input)
RiskFreeRate.Update(time, _riskFreeInterestRateModel.GetInterestRate(time));
DividendYield.Update(time, _dividendYieldModel.GetDividendYield(time, UnderlyingPrice.Current.Value));

var timeTillExpiry = Convert.ToDecimal(
OptionGreekIndicatorsHelper.TimeTillExpiry(Securities.Option.OptionSymbol.GetSettlementDateTime(OptionSymbol), time));
var timeTillExpiry = Convert.ToDecimal(OptionGreekIndicatorsHelper.TimeTillExpiry(Expiry, time));
try
{
_greekValue = timeTillExpiry < 0 ? 0 : CalculateGreek(timeTillExpiry);
Expand Down
14 changes: 13 additions & 1 deletion Indicators/OptionIndicatorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ namespace QuantConnect.Indicators
/// </summary>
public abstract class OptionIndicatorBase : IndicatorBase<IndicatorDataPoint>, IIndicatorWarmUpPeriodProvider
{
private DateTime _expiry;

/// <summary>
/// Option's symbol object
/// </summary>
Expand Down Expand Up @@ -56,7 +58,17 @@ public abstract class OptionIndicatorBase : IndicatorBase<IndicatorDataPoint>, I
/// <summary>
/// Gets the expiration time of the option
/// </summary>
public DateTime Expiry => OptionSymbol.ID.Date;
public DateTime Expiry
{
get
{
if (_expiry == default)
{
_expiry = Securities.Option.OptionSymbol.GetSettlementDateTime(OptionSymbol);
}
return _expiry;
}
}

/// <summary>
/// Gets the option right (call/put) of the option
Expand Down

0 comments on commit da392b1

Please sign in to comment.