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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.