Table of Contents

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 ISecurityProvider

The provider of information about instruments.

dataProvider IMarketDataProvider

The market data provider.

exchangeInfoProvider IExchangeInfoProvider

Exchanges 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 Security

Underlying asset.

dataProvider IMarketDataProvider

The market data provider.

exchangeInfoProvider IExchangeInfoProvider

Exchanges 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 Security

Options contract.

securityProvider ISecurityProvider

The provider of information about instruments.

dataProvider IMarketDataProvider

The market data provider.

exchangeInfoProvider IExchangeInfoProvider

Exchanges 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 Security

Options contract.

underlyingAsset Security

Underlying asset.

dataProvider IMarketDataProvider

The market data provider.

exchangeInfoProvider IExchangeInfoProvider

Exchanges and trading boards provider.

Properties

DataProvider

The market data provider.

public virtual IMarketDataProvider DataProvider { get; }

Property Value

IMarketDataProvider

DefaultDeviation

The standard deviation by default.

public decimal DefaultDeviation { get; }

Property Value

decimal

Dividend

The dividend amount on shares.

public virtual decimal Dividend { get; set; }

Property Value

decimal

ExchangeInfoProvider

Exchanges and trading boards provider.

public IExchangeInfoProvider ExchangeInfoProvider { get; }

Property Value

IExchangeInfoProvider

Option

Options contract.

public virtual Security Option { get; }

Property Value

Security

OptionType

Option type.

protected OptionTypes OptionType { get; }

Property Value

OptionTypes

RiskFree

The risk free interest rate.

public decimal RiskFree { get; set; }

Property Value

decimal

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

int

SecurityProvider

The provider of information about instruments.

public ISecurityProvider SecurityProvider { get; }

Property Value

ISecurityProvider

UnderlyingAsset

Underlying asset.

public virtual Security UnderlyingAsset { get; set; }

Property Value

Security

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 decimal

Standard deviation.

assetPrice decimal

Underlying asset price.

timeToExp double

The 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 DateTimeOffset

The 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 DateTimeOffset

The 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 DateTimeOffset

The 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 DateTimeOffset

The current time.

premium decimal

The 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 DateTimeOffset

The 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 DateTimeOffset

The 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 DateTimeOffset

The 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 DateTimeOffset

The current time.

deviation decimal?

Standard deviation.

assetPrice decimal?

Underlying asset price.

Returns

decimal?

The option vega. If the value is equal to null, then the value calculation currently is impossible.