Framework Reference
WEALTHLAB FRAMEWORK / CLASS REFERENCE

OptionsHelper

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

Search the framework

Find classes, members, and documentation.

NamespaceWealthLab.Data
Parent
Object

OptionsHelper is a static utility class that provides methods for recognizing, parsing, building, and converting option symbols in the formats used by WealthLab and various data and brokerage Providers. It also provides a method for estimating the underlying price corresponding to a specified option delta.

Static Members

19

BuildOptionSymbol

public static string BuildOptionSymbol(string underlyingSymbol, string right, double strike, DateTime expiryDate, OptionSymbolFormat format = OptionSymbolFormat.Compact)

Builds and returns an option symbol from the specified underlying symbol, option right, strike, and expiryDate. Use format to specify the desired OptionSymbolFormat. If omitted, OptionSymbolFormat.Compact is used.

C2Symbol

public static string C2Symbol(string root, OptionType optionType, double strike, DateTime expiry)
public static string C2Symbol(string optionSymbol)

Returns an option symbol in the Collective2 format, which is also the format used by IQFeed. The first overload builds the symbol from its individual components. The second converts an existing recognized option symbol into the Collective2 format.

callMonths

public static string[] callMonths

Contains the month codes used for call options in the legacy Collective2/IQFeed option symbol format:

A, B, C, D, E, F, G, H, I, J, K, L

These correspond to January through December.

ConvertSymbol

public static string ConvertSymbol(string optionSymbol, OptionSymbolFormat optSymFormat)
public static string ConvertSymbol(string optionSymbol, OptionSymbolFormat optSymFormat, OptionType resultType)
public static string ConvertSymbol(string optionSymbol, int format)
public static string ConvertSymbol(string optionSymbol, int format, OptionType resultType)

Converts optionSymbol from a recognized option symbol format to the specified format. The overloads that accept resultType also let you change the option type to OptionType.Call or OptionType.Put, which is useful for converting a call symbol to the corresponding put symbol, or vice versa. If the symbol cannot be parsed, the original symbol is returned.

IsOption

public static bool IsOption(string symbol)

Returns true if symbol matches one of the recognized option symbol formats, otherwise false.

IsOptionFormat

public static bool IsOptionFormat(string symbol, OptionSymbolFormat format)

Returns true if symbol matches the specified OptionSymbolFormat, otherwise false.

IsOptionFormat1

public static bool IsOptionFormat1(string symbol)

Returns true if symbol uses the Compact format employed by WealthLab synthetic options and Interactive Brokers. For example:

ABC230818C90.5

IsOptionFormat2

public static bool IsOptionFormat2(string symbol)

Returns true if symbol uses the OCC-style option format employed by Providers such as Tradier, Alpaca, and EODHD. For example:

TTD230721C00075000

IsOptionFormat3

public static bool IsOptionFormat3(string symbol)

Returns true if symbol uses the legacy month-code option format employed by Collective2 and IQFeed. For example:

TTD2321G75

IsOptionFormat4

public static bool IsOptionFormat4(string symbol)

Returns true if symbol uses the former TD Ameritrade option format. For example:

TTD_072123C75

IsOptionFormat5

public static bool IsOptionFormat5(string symbol)

Returns true if symbol uses the legacy padded exchange format associated with Schwab. The underlying symbol occupies six characters and is padded on the right with spaces when necessary. For example:

TTD   230721C00075000

ParseSymbol

public static (string, OptionType, double, DateTime) ParseSymbol(string symbol)

Parses a recognized option symbol and returns a tuple containing:

  1. The underlying symbol.
  2. The OptionType, either OptionType.Call or OptionType.Put.
  3. The strike price.
  4. The expiration date. If symbol cannot be recognized or parsed, the method returns:
(String.Empty, OptionType.Call, 0, DateTime.MinValue)

PriceAtDelta

public static double PriceAtDelta(OptionType optionType, double delta, double underlyingPrice, double iv, DateTime expiry)
public static double PriceAtDelta(OptionType optionType, double delta, double underlyingPrice, double iv, DateTime expiry, DateTime currentDate)

Estimates the underlying price corresponding to the specified option delta, optionType, implied volatility iv, and expiration date. Use the overload containing currentDate when performing historical calculations or backtests. The overload without currentDate uses the current date and is intended for future expirations. The delta value is treated as a positive value. For puts, the method internally accounts for the normally negative put delta. If iv is zero or Double.NaN, the method uses 0.20 as the implied volatility. The calculation uses a Black-Scholes-based estimate and incorporates the three-month U.S. Treasury yield as the risk-free rate.

putMonths

public static string[] putMonths

Contains the month codes used for put options in the legacy Collective2/IQFeed option symbol format:

M, N, O, P, Q, R, S, T, U, V, W, X

These correspond to January through December.

SymbolExpiry

public static DateTime SymbolExpiry(string optionSymbol)

Parses optionSymbol and returns its expiration date. Returns DateTime.MinValue if the supplied string is null or empty.

SymbolOptionType

public static OptionType SymbolOptionType(string optionSymbol)

Parses optionSymbol and returns its OptionType, either OptionType.Call or OptionType.Put. Returns OptionType.Call if the supplied string is null or empty.

SymbolStrike

public static double SymbolStrike(string optionSymbol)

Parses optionSymbol and returns its strike price. Returns zero if the supplied string is null or empty.

SymbolUnderlier

public static string SymbolUnderlier(string optionSymbol)

Parses optionSymbol and returns its underlying symbol. The returned symbol can differ from the actual underlier when an option-specific root is used. For example, weekly SPX options can use SPXW. Returns String.Empty if the supplied string is null or empty.

ToOptionSymbolFormat

public static OptionSymbolFormat ToOptionSymbolFormat(this int value, OptionSymbolFormat fallback = OptionSymbolFormat.Compact)

Converts a legacy integer option format value to the corresponding OptionSymbolFormat enumeration value. If value does not correspond to a defined OptionSymbolFormat, the specified fallback is returned. The default fallback is OptionSymbolFormat.Compact.

Need help with this API?

Ask the community or explore custom development services.