Framework Reference
WEALTHLAB FRAMEWORK / CLASS REFERENCE

OptionSynthetic

API documentation, members, signatures, and C# examples.

Search the framework

Find classes, members, and documentation.

NamespaceWealthLab.Data
Parent
Object

OptionSynthetic is a static utility class that generates synthetic option symbols and calculated option price histories. It also provides methods for calculating option prices and Greeks using the Black-Scholes model. Synthetic option calculations require an estimate of implied volatility (IV). The resulting prices and Greeks will only approximate actual option values to the extent that the supplied IV accurately represents the option's implied volatility. OptionSynthetic is particularly useful when developing and backtesting option trading strategies when historical option contracts or option chains are not available.

Methods

8

CalculateOptionPrice

public static double CalculateOptionPrice(string optionSymbol, double impliedVolatility, double priceUnderlying, DateTime dateTime)

Calculates a hypothetical option price using the Black-Scholes model. Pass the option contract symbol in optionSymbol, the estimated implied volatility in impliedVolatility, the hypothetical underlying price in priceUnderlying, and the date/time for which the calculation should be performed in dateTime. If dateTime is on or after the option's expiration, the method returns the option's intrinsic value instead of a Black-Scholes calculated value.

GetGreeks

public static OptionGreek GetGreeks(BarHistory underlier, int bar, OptionType optionType, double strike, DateTime expiration, double iv = 0.2)
public static OptionGreek GetGreeks(BarHistory underlier, int bar, string optionSymbol, double iv = 0.2)

Calculates option Greeks for the specified bar of the underlying BarHistory and returns the results in an OptionGreek instance. The calculated values include OptionPrice, Delta, Theta, Gamma, and Vega. The method uses the Black-Scholes model and the supplied iv as the option's implied volatility estimate.

GetHistory

public static BarHistory GetHistory(BarHistory underlier, OptionType optionType, double strike, DateTime expiration, double iv = 0.2)
public static BarHistory GetHistory(BarHistory underlier, OptionType optionType, double strike, DateTime expiration, TimeSeries iv)
public static BarHistory GetHistory(BarHistory underlier, string optionSymbol, double iv = 0.2)
public static BarHistory GetHistory(BarHistory underlier, string optionSymbol, TimeSeries iv)

Returns a calculated BarHistory representing a synthetic option contract. The synthetic option's OHLC values are calculated from the corresponding OHLC values of the underlier using the Black-Scholes model. You can supply either a constant implied volatility or a TimeSeries containing a varying implied volatility estimate. When using an optionSymbol overload, OptionSynthetic parses the option type, strike, and expiration from the supplied symbol. The resulting synthetic BarHistory is cached in the underlying BarHistory's Cache using the synthetic option symbol as the key.

GetOptionsSymbol

public static string GetOptionsSymbol(
BarHistory underlier,
OptionType optionType,
double price,
DateTime currentDate,
int minDaysAhead = 0,
bool useWeeklies = false,
bool allowExpired = false,
bool closestStrike = true,
bool priceIsStrike = false)

Generates a synthetic option contract symbol based on the supplied underlying BarHistory, option type, price, and expiration criteria. Pass OptionType.Call or OptionType.Put in optionType. The price parameter represents the price near the desired strike. Unless priceIsStrike is true, OptionSynthetic converts this value to an appropriate synthetic strike using the following increments: | Underlying Price | Strike Increment | | --- | --- | | Above $1,000 | $25 | | Above $200 | $10 | | Above $10 | $5 | | $10 or below | $1 | If closestStrike is true, the strike closest to price is selected. If false, the next higher strike is selected for calls and the next lower strike for puts. Set priceIsStrike to true to use price directly as the strike without adjustment. The expiration is determined from currentDate, minDaysAhead, and useWeeklies. Set allowExpired to true when backtesting synthetic options so historical expiration dates can be generated.

GetSymbolExpiry

[Obsolete("Use OptionsHelper.SymbolExpiry() for all option formats.")]
public static DateTime GetSymbolExpiry(string optionSymbol)

Parses optionSymbol and returns its expiration date. This method is obsolete. Use OptionsHelper.SymbolExpiry instead.

GetSymbolStrike

[Obsolete("Use OptionsHelper.SymbolStrike() for all option formats.")]
public static double GetSymbolStrike(string optionSymbol)

Parses optionSymbol and returns its strike price. This method is obsolete. Use OptionsHelper.SymbolStrike instead.

ImpliedVolatility

public static double ImpliedVolatility(BarHistory source, string optionSymbol, double atPrice, DateTime asOfDate)

Attempts to calculate implied volatility using an iterative Newton-Raphson calculation. The current implementation is marked in the source code as not yet accurate and needing further work. It should therefore not be relied upon for precise implied volatility calculations.

Symbol

public static string Symbol(BarHistory underlier, OptionType optionType, double strike, DateTime expiration)

Returns a synthetic option symbol for the specified underlying BarHistory, option type, strike, and expiration. Synthetic option symbols begin with ! and use the following format:

![underlier]yyMMdd[C/P][strike]

For example:

!SPY260918C650

The Symbol method lets you specify the strike and expiration exactly, whereas GetOptionsSymbol determines them according to its strike and expiration selection rules.

Need help with this API?

Ask the community or explore custom development services.