diff --git a/Common/Data/Market/Greeks.cs b/Common/Data/Market/Greeks.cs
index 16d67ec61bd6..a054207b33fe 100644
--- a/Common/Data/Market/Greeks.cs
+++ b/Common/Data/Market/Greeks.cs
@@ -13,6 +13,7 @@
* limitations under the License.
*/
+using System;
using QuantConnect.Python;
namespace QuantConnect.Data.Market
@@ -111,6 +112,24 @@ public virtual decimal ThetaPerDay
set { Theta = value * 365m; }
}
+ ///
+ /// Calculates the annualized theta value based on a daily theta input.
+ ///
+ /// The theta value per day to be annualized.
+ /// The annualized theta value, calculated as the daily theta multiplied by 365. Returns decimal.MaxValue or
+ /// decimal.MinValue if the result overflows.
+ public static decimal GetSafeTheta(decimal thetaPerDay)
+ {
+ try
+ {
+ return thetaPerDay * 365m;
+ }
+ catch (OverflowException)
+ {
+ return thetaPerDay < 0 ? decimal.MinValue : decimal.MaxValue;
+ }
+ }
+
///
/// Initializes a new instance of the class.
///
diff --git a/Common/Data/UniverseSelection/OptionUniverse.cs b/Common/Data/UniverseSelection/OptionUniverse.cs
index b2c30b7412dd..b8909c81d705 100644
--- a/Common/Data/UniverseSelection/OptionUniverse.cs
+++ b/Common/Data/UniverseSelection/OptionUniverse.cs
@@ -257,7 +257,7 @@ private class PreCalculatedGreeks : Greeks
public override decimal Vega => _csvLine.GetDecimalFromCsv(StartingGreeksCsvIndex + 2);
- public override decimal Theta => _csvLine.GetDecimalFromCsv(StartingGreeksCsvIndex + 3) * 365m;
+ public override decimal Theta => GetSafeTheta(_csvLine.GetDecimalFromCsv(StartingGreeksCsvIndex + 3));
public override decimal Rho => _csvLine.GetDecimalFromCsv(StartingGreeksCsvIndex + 4);
diff --git a/Indicators/GreeksIndicators.cs b/Indicators/GreeksIndicators.cs
index 604c60a396d4..d51b1c7d178d 100644
--- a/Indicators/GreeksIndicators.cs
+++ b/Indicators/GreeksIndicators.cs
@@ -78,18 +78,7 @@ 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);
+ return new Greeks(Delta, Gamma, Vega, Greeks.GetSafeTheta(ThetaPerDay.Current.Value), Rho, 0m);
}
}