DerivativesHelper
Extension class for derivatives.
Methods
public static double D1(decimal assetPrice, decimal strike, decimal riskFree, decimal dividend, decimal deviation, double timeToExp)
result = DerivativesHelper.D1(assetPrice, strike, riskFree, dividend, deviation, timeToExp)
To calculate the d1 parameter of the option fulfilment probability estimating.
- assetPrice
- Underlying asset price.
- strike
- The strike price.
- riskFree
- The risk free interest rate.
- dividend
- The dividend amount on shares.
- deviation
- Standard deviation.
- timeToExp
- The option period before the expiration.
Returns: The d1 parameter of the option fulfilment probability estimating.
public static double D2(double d1, decimal deviation, double timeToExp)
result = DerivativesHelper.D2(d1, deviation, timeToExp)
To calculate the d2 parameter of the option fulfilment probability estimating.
- d1
- The d1 parameter of the option fulfilment probability estimating.
- deviation
- Standard deviation.
- timeToExp
- The option period before the expiration.
Returns: The d2 parameter of the option fulfilment probability estimating.
public static decimal Delta(OptionTypes optionType, decimal assetPrice, double d1)
result = DerivativesHelper.Delta(optionType, assetPrice, d1)
To calculate the option delta.
- optionType
- Option type.
- assetPrice
- Underlying asset price.
- d1
- The d1 parameter of the option fulfilment probability estimating.
Returns: Option delta.
public static double ExpRate(decimal riskFree, double timeToExp)
result = DerivativesHelper.ExpRate(riskFree, timeToExp)
To calculate the time exhibitor.
- riskFree
- The risk free interest rate.
- timeToExp
- The option period before the expiration.
Returns: The time exhibitor.
public static IEnumerable<Security> Filter(IEnumerable<Security> options, decimal strike)
result = DerivativesHelper.Filter(options, strike)
To filter options by the strike Strike.
- options
- Options to be filtered.
- strike
- The strike price.
Returns: Filtered options.
public static IEnumerable<Security> Filter(IEnumerable<Security> options, OptionTypes type)
result = DerivativesHelper.Filter(options, type)
To filter options by type OptionType.
- options
- Options to be filtered.
- type
- Option type.
Returns: Filtered options.
public static IEnumerable<Security> Filter(IEnumerable<Security> securities, DateTime? expirationDate)
result = DerivativesHelper.Filter(securities, expirationDate)
To filter instruments by the expiration date ExpiryDate.
- securities
- Instruments to be filtered.
- expirationDate
- The expiration date.
Returns: Instruments filtered.
public static IEnumerable<Security> FilterByUnderlying(IEnumerable<Security> securities, Security asset)
result = DerivativesHelper.FilterByUnderlying(securities, asset)
To filter instruments by the underlying asset.
- securities
- Instruments to be filtered.
- asset
- Underlying asset.
Returns: Instruments filtered.
public static decimal Gamma(decimal assetPrice, decimal deviation, double timeToExp, double d1)
result = DerivativesHelper.Gamma(assetPrice, deviation, timeToExp, d1)
To calculate the option gamma.
- assetPrice
- Underlying asset price.
- deviation
- Standard deviation.
- timeToExp
- The option period before the expiration.
- d1
- The d1 parameter of the option fulfilment probability estimating.
Returns: Option gamma.
public static Security GetAsset(Security derivative, ISecurityProvider provider)
result = DerivativesHelper.GetAsset(derivative, provider)
To get the underlying asset.
- derivative
- The derivative.
- provider
- The provider of information about instruments.
Returns: Underlying asset.
public static IEnumerable<Security> GetAtTheMoney(Security underlyingAsset, ISecurityProvider securityProvider, decimal assetPrice)
result = DerivativesHelper.GetAtTheMoney(underlyingAsset, securityProvider, assetPrice)
To get at the money options (ATM).
- underlyingAsset
- Underlying asset.
- securityProvider
- The provider of information about instruments.
- assetPrice
- The asset price.
Returns: At the money options.
public static IEnumerable<Security> GetAtTheMoney(Security underlyingAsset, IEnumerable<Security> allStrikes, decimal assetPrice)
result = DerivativesHelper.GetAtTheMoney(underlyingAsset, allStrikes, assetPrice)
To get at the money options (ATM).
- underlyingAsset
- Underlying asset.
- allStrikes
- All strikes.
- assetPrice
- The asset price.
Returns: At the money options.
public static Security GetCall(Security future, ISecurityProvider provider, decimal strike, DateTime expirationDate)
result = DerivativesHelper.GetCall(future, provider, strike, expirationDate)
To get Call for the underlying futures.
- future
- Underlying futures.
- provider
- The provider of information about instruments.
- strike
- Strike.
- expirationDate
- The date of the option expiration.
Returns: The Call option.
public static Security GetCentralStrike(Security underlyingAsset, ISecurityProvider securityProvider, DateTime expirationDate, OptionTypes optionType, decimal assetPrice)
result = DerivativesHelper.GetCentralStrike(underlyingAsset, securityProvider, expirationDate, optionType, assetPrice)
To get the main strike.
- underlyingAsset
- Underlying asset.
- securityProvider
- The provider of information about instruments.
- expirationDate
- The options expiration date.
- optionType
- Option type.
- assetPrice
- The current market price of the asset. It is used to calculate the main strike.
Returns: The main strike.
public static Security GetCentralStrike(IEnumerable<Security> allStrikes, decimal assetPrice)
result = DerivativesHelper.GetCentralStrike(allStrikes, assetPrice)
To get the main strike.
- allStrikes
- All strikes.
- assetPrice
- The current market price of the asset. It is used to calculate the main strike.
Returns: The main strike. If it is impossible to get the current market price of the asset then the will be returned.
public static IEnumerable<Security> GetDerivatives(Security asset, ISecurityProvider provider, DateTime? expirationDate)
result = DerivativesHelper.GetDerivatives(asset, provider, expirationDate)
To get derivatives by the underlying asset.
- asset
- Underlying asset.
- provider
- The provider of information about instruments.
- expirationDate
- The expiration date.
Returns: The list of derivatives.
public static double? GetExpirationTimeLine(DateTime expirationTime, DateTime currentTime, TimeSpan timeLine)
result = DerivativesHelper.GetExpirationTimeLine(expirationTime, currentTime, timeLine)
To get the option period before expiration.
- expirationTime
- The option expiration time.
- currentTime
- The current time.
- timeLine
- The length of the total period.
Returns: The option period before expiration. If the value is equal to , then the value calculation currently is impossible.
public static double? GetExpirationTimeLine(DateTime expirationTime, DateTime currentTime)
result = DerivativesHelper.GetExpirationTimeLine(expirationTime, currentTime)
To get the option period before expiration.
- expirationTime
- The option expiration time.
- currentTime
- The current time.
Returns: The option period before expiration. If the value is equal to , then the value calculation currently is impossible.
public static SecurityMessage GetFutureInfo(string futureName, string optionCode, ExchangeBoard board)
result = DerivativesHelper.GetFutureInfo(futureName, optionCode, board)
To get the information about the futures from its name (underlying asset, expiration date, etc.).
- futureName
- The futures name.
- optionCode
- The option code.
- board
- Board info.
Returns: Information about futures.
public static IEnumerable<Security> GetInTheMoney(Security underlyingAsset, ISecurityProvider securityProvider, decimal assetPrice)
result = DerivativesHelper.GetInTheMoney(underlyingAsset, securityProvider, assetPrice)
To get in the money options (ITM).
- underlyingAsset
- Underlying asset.
- securityProvider
- The provider of information about instruments.
- assetPrice
- The asset price.
Returns: In the money options.
public static IEnumerable<Security> GetInTheMoney(Security underlyingAsset, IEnumerable<Security> allStrikes, decimal assetPrice)
result = DerivativesHelper.GetInTheMoney(underlyingAsset, allStrikes, assetPrice)
To get in the money options (ITM).
- underlyingAsset
- Underlying asset.
- allStrikes
- All strikes.
- assetPrice
- The asset price.
Returns: In the money options.
public static decimal GetIntrinsicValue(Security option, decimal assetPrice)
result = DerivativesHelper.GetIntrinsicValue(option, assetPrice)
To get the internal option value.
- option
- Options contract.
- assetPrice
- The underlying asset price.
Returns: The internal value. If it is impossible to get the current market price of the asset then the will be returned.
public static Security GetOppositeOption(Security option, ISecurityProvider provider)
result = DerivativesHelper.GetOppositeOption(option, provider)
To get opposite option (for Call to get Put, for Put to get Call).
- option
- Options contract.
- provider
- The provider of information about instruments.
Returns: The opposite option.
public static Security GetOption(Security future, ISecurityProvider provider, decimal strike, DateTime expirationDate, OptionTypes optionType)
result = DerivativesHelper.GetOption(future, provider, strike, expirationDate, optionType)
To get an option for the underlying futures.
- future
- Underlying futures.
- provider
- The provider of information about instruments.
- strike
- Strike.
- expirationDate
- The options expiration date.
- optionType
- Option type.
Returns: Options contract.
public static Security GetOptionInfo(string optionName, ExchangeBoard board)
result = DerivativesHelper.GetOptionInfo(optionName, board)
To get the information about the option from its name (underlying asset, strike, expiration date, etc.).
- optionName
- The option name.
- board
- Board info.
Returns: Information about the option.
public static IEnumerable<Security> GetOutOfTheMoney(Security underlyingAsset, ISecurityProvider securityProvider, decimal assetPrice)
result = DerivativesHelper.GetOutOfTheMoney(underlyingAsset, securityProvider, assetPrice)
To get out of the money options (OTM).
- underlyingAsset
- Underlying asset.
- securityProvider
- The provider of information about instruments.
- assetPrice
- The asset price.
Returns: Out of the money options.
public static IEnumerable<Security> GetOutOfTheMoney(Security underlyingAsset, IEnumerable<Security> allStrikes, decimal assetPrice)
result = DerivativesHelper.GetOutOfTheMoney(underlyingAsset, allStrikes, assetPrice)
To get out of the money options (OTM).
- underlyingAsset
- Underlying asset.
- allStrikes
- All strikes.
- assetPrice
- The asset price.
Returns: Out of the money options.
public static Security GetPut(Security future, ISecurityProvider provider, decimal strike, DateTime expirationDate)
result = DerivativesHelper.GetPut(future, provider, strike, expirationDate)
To get Put for the underlying futures.
- future
- Underlying futures.
- provider
- The provider of information about instruments.
- strike
- Strike.
- expirationDate
- The date of the option expiration.
Returns: The Put option.
public static decimal GetStrikeStep(Security underlyingAsset, ISecurityProvider provider, DateTime? expirationDate)
result = DerivativesHelper.GetStrikeStep(underlyingAsset, provider, expirationDate)
To get the strike step size.
- provider
- The provider of information about instruments.
- underlyingAsset
- Underlying asset.
- expirationDate
- The options expiration date (to specify a particular series).
Returns: The strike step size.
public static decimal GetTimeValue(Security option, decimal currentPrice, decimal assetPrice)
result = DerivativesHelper.GetTimeValue(option, currentPrice, assetPrice)
To get the timed option value.
- option
- Options contract.
- currentPrice
- The contract price.
- assetPrice
- The underlying asset price.
Returns: The timed value.
public static Security GetUnderlyingAsset(Security derivative, ISecurityProvider provider)
result = DerivativesHelper.GetUnderlyingAsset(derivative, provider)
To get the underlying asset by the derivative.
- derivative
- The derivative.
- provider
- The provider of information about instruments.
Returns: Underlying asset.
public static QuoteChangeMessage ImpliedVolatility(IOrderBookMessage depth, ISecurityProvider securityProvider, IMarketDataProvider dataProvider, DateTime currentTime, decimal riskFree, decimal dividend)
result = DerivativesHelper.ImpliedVolatility(depth, securityProvider, dataProvider, currentTime, riskFree, dividend)
To create the volatility order book from usual order book.
- depth
- The order book quotes of which will be changed to volatility quotes.
- securityProvider
- The provider of information about instruments.
- dataProvider
- The market data provider.
- currentTime
- The current time.
- riskFree
- The risk free interest rate.
- dividend
- The dividend amount on shares.
Returns: The order book volatility.
public static QuoteChangeMessage ImpliedVolatility(IOrderBookMessage depth, IBlackScholes model, DateTime currentTime)
result = DerivativesHelper.ImpliedVolatility(depth, model, currentTime)
To create the volatility order book from usual order book.
- depth
- The order book quotes of which will be changed to volatility quotes.
- model
- The model for calculating Greeks values by the Black-Scholes formula.
- currentTime
- The current time.
Returns: The order book volatility.
public static decimal? ImpliedVolatility(decimal premium, Func<decimal, decimal?> getPremium)
result = DerivativesHelper.ImpliedVolatility(premium, getPremium)
To calculate the implied volatility.
- premium
- The option premium.
- getPremium
- To calculate the premium by volatility.
Returns: The implied volatility. If the value is equal to , then the value calculation currently is impossible.
public static OptionTypes Invert(OptionTypes type)
result = DerivativesHelper.Invert(type)
To change the option type for opposite.
- type
- The initial value.
Returns: The opposite value.
public static bool IsExpired(Security security, IExchangeInfoProvider exchangeInfoProvider, DateTime currentTime)
result = DerivativesHelper.IsExpired(security, exchangeInfoProvider, currentTime)
To check whether the instrument has finished the action.
- security
- Security.
- exchangeInfoProvider
- Exchanges and trading boards provider.
- currentTime
- The current time.
Returns: if the instrument has finished its action.
public static decimal Premium(OptionTypes optionType, decimal strike, decimal assetPrice, decimal riskFree, decimal dividend, decimal deviation, double timeToExp, double d1)
result = DerivativesHelper.Premium(optionType, strike, assetPrice, riskFree, dividend, deviation, timeToExp, d1)
To calculate the option premium.
- optionType
- Option type.
- strike
- The strike price.
- assetPrice
- Underlying asset price.
- riskFree
- The risk free interest rate.
- dividend
- The dividend amount on shares.
- deviation
- Standard deviation.
- timeToExp
- The option period before the expiration.
- d1
- The d1 parameter of the option fulfilment probability estimating.
Returns: The option premium.
public static decimal Rho(OptionTypes optionType, decimal strike, decimal assetPrice, decimal riskFree, decimal deviation, double timeToExp, double d1)
result = DerivativesHelper.Rho(optionType, strike, assetPrice, riskFree, deviation, timeToExp, d1)
To calculate the option rho.
- optionType
- Option type.
- strike
- The strike price.
- assetPrice
- Underlying asset price.
- riskFree
- The risk free interest rate.
- deviation
- Standard deviation.
- timeToExp
- The option period before the expiration.
- d1
- The d1 parameter of the option fulfilment probability estimating.
Returns: Option rho.
public static decimal Theta(OptionTypes optionType, decimal strike, decimal assetPrice, decimal riskFree, decimal deviation, double timeToExp, double d1, decimal daysInYear)
result = DerivativesHelper.Theta(optionType, strike, assetPrice, riskFree, deviation, timeToExp, d1, daysInYear)
To calculate the option theta.
- optionType
- Option type.
- strike
- The strike price.
- assetPrice
- Underlying asset price.
- riskFree
- The risk free interest rate.
- deviation
- Standard deviation.
- timeToExp
- The option period before the expiration.
- d1
- The d1 parameter of the option fulfilment probability estimating.
- daysInYear
- Days per year.
Returns: Option theta.
public static decimal Vega(decimal assetPrice, double timeToExp, double d1)
result = DerivativesHelper.Vega(assetPrice, timeToExp, d1)
To calculate the option vega.
- assetPrice
- Underlying asset price.
- timeToExp
- The option period before the expiration.
- d1
- The d1 parameter of the option fulfilment probability estimating.
Returns: Option vega.