MarketData SDK

OptionChains extends ResponseBase
in package

Represents a collection of option chains with associated data.

Table of Contents

Properties

$_saved_filename  : string|null
$next_time  : Carbon|null
Time of the next quote if there is no data in the requested period, but there is data in a subsequent period.
$option_chains  : array<string, array<string|int, OptionQuote>>
Multidimensional array of OptionQuote objects organized by date.
$prev_time  : Carbon|null
Time of the previous quote if there is no data in the requested period, but there is data in a previous period.
$status  : string
Status of the option chains request. Will always be ok when there is the quote requested.
$csv  : string
$html  : string

Methods

__construct()  : mixed
Constructs a new OptionChains instance from the given response object.
__toString()  : string
Returns a string representation of the option chains collection.
count()  : int
Get the total count of option quotes across all expirations.
getAllQuotes()  : array<string|int, OptionQuote>
Get all option quotes as a flat array.
getByStrike()  : array<string|int, OptionQuote>
Get option quotes for a specific strike price.
getCalls()  : array<string|int, OptionQuote>
Get only call options from the chain.
getCsv()  : string
Get the CSV content of the response.
getExpirationDates()  : array<string|int, string>
Get all expiration dates in the chain.
getHtml()  : string
Get the HTML content of the response.
getPuts()  : array<string|int, OptionQuote>
Get only put options from the chain.
getQuotesByExpiration()  : array<string|int, OptionQuote>
Get option quotes for a specific expiration date.
getStrikes()  : array<string|int, float>
Get all unique strike prices in the chain, sorted ascending.
isCsv()  : bool
Check if the response is in CSV format.
isHtml()  : bool
Check if the response is in HTML format.
isJson()  : bool
Check if the response is in JSON format.
saveToFile()  : string
Save CSV/HTML content to a file.
toQuotes()  : Quotes
Convert the option chains to a flat Quotes object.

Properties

$_saved_filename

public string|null $_saved_filename = null

The filename where the response was saved (if filename parameter was used).

$next_time

Time of the next quote if there is no data in the requested period, but there is data in a subsequent period.

public Carbon|null $next_time = null

$option_chains

Multidimensional array of OptionQuote objects organized by date.

public array<string, array<string|int, OptionQuote>> $option_chains = []

$prev_time

Time of the previous quote if there is no data in the requested period, but there is data in a previous period.

public Carbon|null $prev_time = null

$status

Status of the option chains request. Will always be ok when there is the quote requested.

public string $status = 'no_data'

$csv

protected string $csv

The CSV content of the response.

$html

protected string $html

The HTML content of the response.

Methods

__construct()

Constructs a new OptionChains instance from the given response object.

public __construct(object $response) : mixed
Parameters
$response : object

The response object containing option chains data.

__toString()

Returns a string representation of the option chains collection.

public __toString() : string
Return values
string —

Human-readable option chains summary.

count()

Get the total count of option quotes across all expirations.

public count() : int
Return values
int —

The total number of option quotes.

getAllQuotes()

Get all option quotes as a flat array.

public getAllQuotes() : array<string|int, OptionQuote>
Return values
array<string|int, OptionQuote> —

All option quotes from all expiration dates.

getByStrike()

Get option quotes for a specific strike price.

public getByStrike(float $strike) : array<string|int, OptionQuote>
Parameters
$strike : float

The strike price to filter by.

Return values
array<string|int, OptionQuote> —

Array of option quotes with the given strike price.

getCalls()

Get only call options from the chain.

public getCalls() : array<string|int, OptionQuote>
Return values
array<string|int, OptionQuote> —

Array of call option quotes.

getCsv()

Get the CSV content of the response.

public getCsv() : string
Tags
throws
InvalidArgumentException

If the response is not in CSV format.

Return values
string —

The CSV content.

getExpirationDates()

Get all expiration dates in the chain.

public getExpirationDates() : array<string|int, string>
Return values
array<string|int, string> —

Array of expiration date strings (YYYY-MM-DD format).

getHtml()

Get the HTML content of the response.

public getHtml() : string
Tags
throws
InvalidArgumentException

If the response is not in HTML format.

Return values
string —

The HTML content.

getPuts()

Get only put options from the chain.

public getPuts() : array<string|int, OptionQuote>
Return values
array<string|int, OptionQuote> —

Array of put option quotes.

getQuotesByExpiration()

Get option quotes for a specific expiration date.

public getQuotesByExpiration(string $date) : array<string|int, OptionQuote>
Parameters
$date : string

The expiration date in YYYY-MM-DD format.

Return values
array<string|int, OptionQuote> —

Array of option quotes for the given date, or empty array if not found.

getStrikes()

Get all unique strike prices in the chain, sorted ascending.

public getStrikes() : array<string|int, float>
Return values
array<string|int, float> —

Array of unique strike prices.

isCsv()

Check if the response is in CSV format.

public isCsv() : bool
Return values
bool —

True if the response is in CSV format, false otherwise.

isHtml()

Check if the response is in HTML format.

public isHtml() : bool
Return values
bool —

True if the response is in HTML format, false otherwise.

isJson()

Check if the response is in JSON format.

public isJson() : bool
Return values
bool —

True if the response is in JSON format, false otherwise.

saveToFile()

Save CSV/HTML content to a file.

public saveToFile(string $filename) : string
Parameters
$filename : string

The file path to save to.

Tags
throws
InvalidArgumentException

If filename is invalid (wrong extension, etc.).

RuntimeException

If file writing fails.

Return values
string —

The absolute path of the saved file.

toQuotes()

Convert the option chains to a flat Quotes object.

public toQuotes() : Quotes

This flattens all option quotes from all expiration dates into a single Quotes container, useful when you want to treat a chain as a simple collection of quotes.

Return values
Quotes —

A Quotes object containing all option quotes from this chain.

On this page

Search results