/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using QuantConnect.Python;
namespace QuantConnect.Data.Market
{
///
/// Defines the greeks
///
public class Greeks
{
///
/// Gets the delta.
///
/// Delta measures the rate of change of the option value with respect to changes in
/// the underlying asset'sprice. (∂V/∂S)
///
///
public virtual decimal Delta { get; set; }
///
/// Gets the gamma.
///
/// Gamma measures the rate of change of Delta with respect to changes in
/// the underlying asset'sprice. (∂²V/∂S²)
///
///
public virtual decimal Gamma { get; set; }
///
/// Gets the vega.
///
/// Vega measures the rate of change of the option value with respect to changes in
/// the underlying's volatility. (∂V/∂σ)
///
///
public virtual decimal Vega { get; set; }
///
/// Gets the theta.
///
/// Theta measures the rate of change of the option value with respect to changes in
/// time. This is commonly known as the 'time decay.' (∂V/∂τ)
///
///
public virtual decimal Theta { get; set; }
///
/// Gets the rho.
///
/// Rho measures the rate of change of the option value with respect to changes in
/// the risk free interest rate. (∂V/∂r)
///
///
public virtual decimal Rho { get; set; }
///
/// Gets the lambda.
///
/// Lambda is the percentage change in option value per percentage change in the
/// underlying's price, a measure of leverage. Sometimes referred to as gearing.
/// (∂V/∂S ✕ S/V)
///
///
[PandasIgnore]
public virtual decimal Lambda { get; set; }
///
/// Gets the lambda.
///
/// Lambda is the percentage change in option value per percentage change in the
/// underlying's price, a measure of leverage. Sometimes referred to as gearing.
/// (∂V/∂S ✕ S/V)
///
///
///
/// Alias for required for compatibility with Python when
/// PEP8 API is used (lambda is a reserved keyword in Python).
///
[PandasIgnore]
public virtual decimal Lambda_
{
get { return Lambda; }
set { Lambda = value; }
}
///
/// Gets the theta per day.
///
/// Theta measures the rate of change of the option value with respect to changes in
/// time. This is commonly known as the 'time decay.' (∂V/∂τ)
///
///
[PandasIgnore]
public virtual decimal ThetaPerDay
{
get { return Theta / 365m; }
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.
///
public Greeks()
{
}
///
/// Initializes a new instance of the class with specified values.
///
public Greeks(decimal delta, decimal gamma, decimal vega, decimal theta, decimal rho, decimal lambda)
{
Delta = delta;
Gamma = gamma;
Vega = vega;
Theta = theta;
Rho = rho;
Lambda = lambda;
}
}
}