Framework Reference
WEALTHLAB FRAMEWORK / CLASS REFERENCE

OptionChain

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

Search the framework

Find classes, members, and documentation.

NamespaceWealthLab.Data
Parent
Object

OptionChain organizes the option expirations and strikes available for a single underlying symbol. Each expiration is represented by an OptionSymExp instance, which contains the option symbol root and available strikes for that expiration.

Constructors

1

OptionChain

public OptionChain(string underlier, bool isIndex = false)

Creates a new OptionChain for the underlying symbol specified in underlier. Set isIndex to true for index options. This information can be used when generating historical expiration dates for expired contracts.

Members

13

Add

public void Add(OptionSymExp optionSymExp)

Adds the OptionSymExp specified in optionSymExp to the chain. The item is added only if the chain does not already contain an OptionSymExp with the same option symbol root and expiration.

ClosestStrike

public double ClosestStrike(double price, DateTime expiration, bool useWeekly)

Returns the available strike closest to price for the specified expiration. Set useWeekly to false to search regular expirations or true to search weekly/non-regular expirations. If no matching OptionSymExp is available, WL9 generates a fictitious strike based on the supplied price. For generated historical strikes, WL9 uses progressively larger strike intervals as the underlying price increases.

ContainsOptionRoot

public bool ContainsOptionRoot(string optionSymbolRoot)

Returns true if the chain contains an OptionSymExp whose option symbol root matches optionSymbolRoot, otherwise returns false.

Expirations

public List<DateTime> Expirations(bool weeklies = false)

Returns a sorted List of unique expiration dates contained in the option chain. If weeklies is false, regular expirations are returned. If true, weekly or other non-regular expirations are returned. Returns null if an error occurs while obtaining the expirations.

GetOptionSymExp

public OptionSymExp GetOptionSymExp(DateTime expiration, bool useWeekly)

Returns the OptionSymExp instance for the specified expiration. Set useWeekly to false to search regular expirations or true to search weekly/non-regular expirations. Returns null if no matching OptionSymExp exists.

IsIndex

public bool IsIndex

Indicates whether this OptionChain represents index options.

KeyToOptionSymExp

public string KeyToOptionSymExp(string optionSymbolRoot, DateTime expiration)

Returns a string key that uniquely identifies an OptionSymExp using the specified optionSymbolRoot and expiration. The key is formatted as the option symbol root followed by @ and the expiration date in yyMMdd format.

NextExpiry

public DateTime NextExpiry(DateTime dte, int calendarDaysAhead = 0, bool allowExpired = false, bool weeklies = false)

Returns the next option expiration on or after dte, advanced by the number of calendar days specified in calendarDaysAhead. Set weeklies to false to use regular expirations, or true to use weekly/non-regular expirations. Set allowExpired to true when working with historical options during a backtest. If expired contracts are not present in the option chain, WL9 generates an appropriate historical expiration date. For regular historical expirations, WL9 accounts for US stock market holidays. If RegularExpirationOnThursday is true, the generated regular expiration is moved from Friday to Thursday.

NextStrike

public double NextStrike(double price, DateTime expiration, bool useWeekly)

Returns the next available strike greater than price for the specified expiration. Set useWeekly to false to search regular expirations or true to search weekly/non-regular expirations. If price is higher than every available strike, the highest strike in the chain is returned. If no matching OptionSymExp is available, such as when backtesting historical options without a historical option chain, WL9 generates a fictitious strike based on the supplied price.

OptionSymExpirations

public List<OptionSymExp> OptionSymExpirations

Returns the List of OptionSymExp instances contained in the chain. Each OptionSymExp represents an option symbol root and expiration, along with the strikes available for that expiration.

PreviousStrike

public double PreviousStrike(double price, DateTime expiration, bool useWeekly)

Returns the next available strike below price for the specified expiration. Set useWeekly to false to search regular expirations or true to search weekly/non-regular expirations. If no lower strike is available, the lowest strike in the chain is returned. If no matching OptionSymExp is available, WL9 generates a fictitious strike based on the supplied price.

RegularExpirationOnThursday

public bool RegularExpirationOnThursday

Indicates that regular expirations should occur on Thursday rather than Friday when WL9 generates historical expiration dates for expired contracts.

Underlier

public string Underlier

Returns the underlying symbol associated with the option chain, such as AAPL, IBM, or SPX.

Need help with this API?

Ask the community or explore custom development services.