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.
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.
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.
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.
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.
Returns true if symbol matches one of the recognized option symbol formats, otherwise false.
Returns true if symbol matches the specified OptionSymbolFormat, otherwise false.
Returns true if symbol uses the Compact format employed by WealthLab synthetic options and Interactive Brokers. For example:
ABC230818C90.5
Returns true if symbol uses the OCC-style option format employed by Providers such as Tradier, Alpaca, and EODHD. For example:
TTD230721C00075000
Returns true if symbol uses the legacy month-code option format employed by Collective2 and IQFeed. For example:
TTD2321G75
Returns true if symbol uses the former TD Ameritrade option format. For example:
TTD_072123C75
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
Parses a recognized option symbol and returns a tuple containing:
- The underlying symbol.
- The OptionType, either OptionType.Call or OptionType.Put.
- The strike price.
- The expiration date. If symbol cannot be recognized or parsed, the method returns:
(String.Empty, OptionType.Call, 0, DateTime.MinValue)
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.
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.
Parses optionSymbol and returns its expiration date. Returns DateTime.MinValue if the supplied string is null or empty.
Parses optionSymbol and returns its OptionType, either OptionType.Call or OptionType.Put. Returns OptionType.Call if the supplied string is null or empty.
Parses optionSymbol and returns its strike price. Returns zero if the supplied string is null or empty.
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.
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.