Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions Indicators/GreeksIndicators.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using QuantConnect.Data;
using QuantConnect.Data.Market;
using QuantConnect.Securities.Option;
using System;

namespace QuantConnect.Indicators
{
Expand Down Expand Up @@ -51,9 +52,9 @@ public class GreeksIndicators
public Vega Vega { get; }

/// <summary>
/// Gets the theta indicator
/// Gets the daily theta indicator
/// </summary>
public Theta Theta { get; }
public Theta ThetaPerDay { get; }

/// <summary>
/// Gets the rho indicator
Expand All @@ -73,7 +74,24 @@ public class GreeksIndicators
/// <summary>
/// Gets the current greeks values
/// </summary>
public Greeks Greeks => new Greeks(Delta, Gamma, Vega, Theta * 365m, Rho, 0m);
public Greeks Greeks
{
get
{
var theta = 0m;
var thetaPerDay = ThetaPerDay.Current.Value;
try
{
theta = thetaPerDay * 365m;
}
catch (OverflowException)
{
theta = thetaPerDay < 0 ? decimal.MinValue : decimal.MaxValue;
}

return new Greeks(Delta, Gamma, Vega, theta, Rho, 0m);
}
}

/// <summary>
/// Whether the mirror option is set and will be used in the calculations.
Expand All @@ -99,7 +117,7 @@ public static IDividendYieldModel GetDividendYieldModel(Symbol optionSymbol)
/// Creates a new instance of the <see cref="GreeksIndicators"/> class
/// </summary>
public GreeksIndicators(Symbol optionSymbol, Symbol mirrorOptionSymbol, OptionPricingModelType? optionModel = null,
OptionPricingModelType? ivModel = null, IDividendYieldModel dividendYieldModel = null,
OptionPricingModelType? ivModel = null, IDividendYieldModel dividendYieldModel = null,
IRiskFreeInterestRateModel riskFreeInterestRateModel = null)
{
_optionSymbol = optionSymbol;
Expand All @@ -112,13 +130,13 @@ public GreeksIndicators(Symbol optionSymbol, Symbol mirrorOptionSymbol, OptionPr
Delta = new Delta(_optionSymbol, riskFreeInterestRateModel, dividendYieldModel, _mirrorOptionSymbol, optionModel, ivModel);
Gamma = new Gamma(_optionSymbol, riskFreeInterestRateModel, dividendYieldModel, _mirrorOptionSymbol, optionModel, ivModel);
Vega = new Vega(_optionSymbol, riskFreeInterestRateModel, dividendYieldModel, _mirrorOptionSymbol, optionModel, ivModel);
Theta = new Theta(_optionSymbol, riskFreeInterestRateModel, dividendYieldModel, _mirrorOptionSymbol, optionModel, ivModel);
ThetaPerDay = new Theta(_optionSymbol, riskFreeInterestRateModel, dividendYieldModel, _mirrorOptionSymbol, optionModel, ivModel);
Rho = new Rho(_optionSymbol, riskFreeInterestRateModel, dividendYieldModel, _mirrorOptionSymbol, optionModel, ivModel);

Delta.ImpliedVolatility = ImpliedVolatility;
Gamma.ImpliedVolatility = ImpliedVolatility;
Vega.ImpliedVolatility = ImpliedVolatility;
Theta.ImpliedVolatility = ImpliedVolatility;
ThetaPerDay.ImpliedVolatility = ImpliedVolatility;
Rho.ImpliedVolatility = ImpliedVolatility;
}

Expand All @@ -131,7 +149,7 @@ public void Update(IBaseData data)
Delta.Update(data);
Gamma.Update(data);
Vega.Update(data);
Theta.Update(data);
ThetaPerDay.Update(data);
Rho.Update(data);
}

Expand All @@ -144,7 +162,7 @@ public void Reset()
Delta.Reset();
Gamma.Reset();
Vega.Reset();
Theta.Reset();
ThetaPerDay.Reset();
Rho.Reset();
}
}
Expand Down
Loading