Class BlackScholes
- Namespace
- StockSharp.Algo.Derivatives
- Assembly
- StockSharp.Algo.dll
The model for calculating Greeks values by the Black-Scholes formula.
public class BlackScholes : IBlackScholes
- Inheritance
-
BlackScholes
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
BlackScholes(ISecurityProvider, IMarketDataProvider, IExchangeInfoProvider)
Initialize BlackScholes.
protected BlackScholes(ISecurityProvider securityProvider, IMarketDataProvider dataProvider, IExchangeInfoProvider exchangeInfoProvider)
Parameters
securityProvider
ISecurityProviderThe provider of information about instruments.
dataProvider
IMarketDataProviderThe market data provider.
exchangeInfoProvider
IExchangeInfoProviderExchanges and trading boards provider.
BlackScholes(Security, IMarketDataProvider, IExchangeInfoProvider)
Initializes a new instance of the BlackScholes.
protected BlackScholes(Security underlyingAsset, IMarketDataProvider dataProvider, IExchangeInfoProvider exchangeInfoProvider)
Parameters
underlyingAsset
SecurityUnderlying asset.
dataProvider
IMarketDataProviderThe market data provider.
exchangeInfoProvider
IExchangeInfoProviderExchanges and trading boards provider.
BlackScholes(Security, ISecurityProvider, IMarketDataProvider, IExchangeInfoProvider)
Initializes a new instance of the BlackScholes.
public BlackScholes(Security option, ISecurityProvider securityProvider, IMarketDataProvider dataProvider, IExchangeInfoProvider exchangeInfoProvider)
Parameters
option
SecurityOptions contract.
securityProvider
ISecurityProviderThe provider of information about instruments.
dataProvider
IMarketDataProviderThe market data provider.
exchangeInfoProvider
IExchangeInfoProviderExchanges and trading boards provider.
BlackScholes(Security, Security, IMarketDataProvider, IExchangeInfoProvider)
Initializes a new instance of the BlackScholes.
public BlackScholes(Security option, Security underlyingAsset, IMarketDataProvider dataProvider, IExchangeInfoProvider exchangeInfoProvider)
Parameters
option
SecurityOptions contract.
underlyingAsset
SecurityUnderlying asset.
dataProvider
IMarketDataProviderThe market data provider.
exchangeInfoProvider
IExchangeInfoProviderExchanges and trading boards provider.
Properties
DataProvider
The market data provider.
public virtual IMarketDataProvider DataProvider { get; }
Property Value
DefaultDeviation
The standard deviation by default.
public decimal DefaultDeviation { get; }
Property Value
Dividend
The dividend amount on shares.
public virtual decimal Dividend { get; set; }
Property Value
ExchangeInfoProvider
Exchanges and trading boards provider.
public IExchangeInfoProvider ExchangeInfoProvider { get; }
Property Value
Option
Options contract.
public virtual Security Option { get; }
Property Value
OptionType
Option type.
protected OptionTypes OptionType { get; }
Property Value
RiskFree
The risk free interest rate.
public decimal RiskFree { get; set; }
Property Value
RoundDecimals
The number of decimal places at calculated values. The default is -1, which means no values rounding.
public virtual int RoundDecimals { get; set; }
Property Value
SecurityProvider
The provider of information about instruments.
public ISecurityProvider SecurityProvider { get; }
Property Value
UnderlyingAsset
Underlying asset.
public virtual Security UnderlyingAsset { get; set; }
Property Value
Methods
D1(decimal, decimal, double)
To calculate the d1 parameter of the option fulfilment probability estimating.
protected virtual double D1(decimal deviation, decimal assetPrice, double timeToExp)
Parameters
deviation
decimalStandard deviation.
assetPrice
decimalUnderlying asset price.
timeToExp
doubleThe option period before the expiration.
Returns
- double
The d1 parameter.
Delta(DateTimeOffset, decimal?, decimal?)
To calculate the option delta.
public virtual decimal? Delta(DateTimeOffset currentTime, decimal? deviation = null, decimal? assetPrice = null)
Parameters
currentTime
DateTimeOffsetThe current time.
deviation
decimal?Standard deviation.
assetPrice
decimal?Underlying asset price.
Returns
- decimal?
The option delta. If the value is equal to null, then the value calculation currently is impossible.
Gamma(DateTimeOffset, decimal?, decimal?)
To calculate the option gamma.
public virtual decimal? Gamma(DateTimeOffset currentTime, decimal? deviation = null, decimal? assetPrice = null)
Parameters
currentTime
DateTimeOffsetThe current time.
deviation
decimal?Standard deviation.
assetPrice
decimal?Underlying asset price.
Returns
- decimal?
The option gamma. If the value is equal to null, then the value calculation currently is impossible.
GetAssetPrice(decimal?)
To get the price of the underlying asset.
public decimal? GetAssetPrice(decimal? assetPrice = null)
Parameters
assetPrice
decimal?The price of the underlying asset if it is specified.
Returns
- decimal?
The price of the underlying asset. If the value is equal to null, then the value calculation currently is impossible.
GetExpirationTimeLine(DateTimeOffset)
The time before expiration calculation.
public virtual double? GetExpirationTimeLine(DateTimeOffset currentTime)
Parameters
currentTime
DateTimeOffsetThe current time.
Returns
- double?
The time remaining until expiration. If the value is equal to null, then the value calculation currently is impossible.
ImpliedVolatility(DateTimeOffset, decimal)
To calculate the implied volatility.
public virtual decimal? ImpliedVolatility(DateTimeOffset currentTime, decimal premium)
Parameters
currentTime
DateTimeOffsetThe current time.
premium
decimalThe option premium.
Returns
- decimal?
The implied volatility. If the value is equal to null, then the value calculation currently is impossible.
Premium(DateTimeOffset, decimal?, decimal?)
To calculate the option premium.
public virtual decimal? Premium(DateTimeOffset currentTime, decimal? deviation = null, decimal? assetPrice = null)
Parameters
currentTime
DateTimeOffsetThe current time.
deviation
decimal?Standard deviation.
assetPrice
decimal?Underlying asset price.
Returns
- decimal?
The option premium. If the value is equal to null, then the value calculation currently is impossible.
Rho(DateTimeOffset, decimal?, decimal?)
To calculate the option rho.
public virtual decimal? Rho(DateTimeOffset currentTime, decimal? deviation = null, decimal? assetPrice = null)
Parameters
currentTime
DateTimeOffsetThe current time.
deviation
decimal?Standard deviation.
assetPrice
decimal?Underlying asset price.
Returns
- decimal?
The option rho. If the value is equal to null, then the value calculation currently is impossible.
Theta(DateTimeOffset, decimal?, decimal?)
To calculate the option theta.
public virtual decimal? Theta(DateTimeOffset currentTime, decimal? deviation = null, decimal? assetPrice = null)
Parameters
currentTime
DateTimeOffsetThe current time.
deviation
decimal?Standard deviation.
assetPrice
decimal?Underlying asset price.
Returns
- decimal?
The option theta. If the value is equal to null, then the value calculation currently is impossible.
TryRound(decimal?)
To round to RoundDecimals.
protected decimal? TryRound(decimal? value)
Parameters
value
decimal?The initial value.
Returns
- decimal?
The rounded value.
Vega(DateTimeOffset, decimal?, decimal?)
To calculate the option vega.
public virtual decimal? Vega(DateTimeOffset currentTime, decimal? deviation = null, decimal? assetPrice = null)
Parameters
currentTime
DateTimeOffsetThe current time.
deviation
decimal?Standard deviation.
assetPrice
decimal?Underlying asset price.