EXPERIMENTAL: Fetch options chain data from Yahoo Finance.
This namespace provides access to options chains via Yahoo's authenticated v7 options endpoint. Authentication is handled automatically via the shared session in clj-yfinance.experimental.auth.
WARNING: This is experimental and may break at any time. Yahoo can change or block authentication without notice.
For production use, consider stable alternatives:
Implementation notes:
EXPERIMENTAL: Fetch options chain data from Yahoo Finance. This namespace provides access to options chains via Yahoo's authenticated v7 options endpoint. Authentication is handled automatically via the shared session in clj-yfinance.experimental.auth. WARNING: This is experimental and may break at any time. Yahoo can change or block authentication without notice. For production use, consider stable alternatives: - AlphaVantage (free tier, options data available) - Polygon.io (professional-grade, comprehensive options) - Tradier (options-focused API) Implementation notes: - Uses /v7/finance/options endpoint (different from quoteSummary) - Without :expiration returns nearest expiry + full list of available dates - With :expiration (epoch seconds) returns full calls/puts chain for that date - Each contract map includes: strike, bid, ask, lastPrice, impliedVolatility, openInterest, volume, inTheMoney, contractSymbol, expiration, lastTradeDate - Session auto-refreshes every hour - MAX 1 retry on authentication failure
(fetch-options ticker & {:keys [expiration]})Fetch options chain for a ticker (simple API).
Returns the options data map or nil on failure. Options: :expiration - epoch seconds for a specific expiry date. For error details, use fetch-options* instead.
Example: (fetch-options "AAPL") => {:underlying-symbol "AAPL" :expiration-dates [1771372800 ...] :strikes [195.0 200.0 ...] :expiration-date 1771372800 :calls [{:strike 210.0 :bid 44.6 :ask 47.6 ...} ...] :puts [{:strike 195.0 :bid 0.01 :ask 0.08 ...} ...]}
(fetch-options "AAPL" :expiration 1771372800) => {:calls [<31 contracts>] :puts [<32 contracts>] ...}
Fetch options chain for a ticker (simple API).
Returns the options data map or nil on failure.
Options: :expiration - epoch seconds for a specific expiry date.
For error details, use fetch-options* instead.
Example:
(fetch-options "AAPL")
=> {:underlying-symbol "AAPL"
:expiration-dates [1771372800 ...]
:strikes [195.0 200.0 ...]
:expiration-date 1771372800
:calls [{:strike 210.0 :bid 44.6 :ask 47.6 ...} ...]
:puts [{:strike 195.0 :bid 0.01 :ask 0.08 ...} ...]}
(fetch-options "AAPL" :expiration 1771372800)
=> {:calls [<31 contracts>] :puts [<32 contracts>] ...}(fetch-options* ticker & {:keys [expiration]})Fetch options chain for a ticker (verbose API).
Parameters:
Returns {:ok? true :data {...}} or {:ok? false :error {:}}.
:data map keys:
Each contract map includes:
Error types: :auth-failed, :session-failed, :api-error, :http-error, :rate-limited, :parse-error, :missing-data, :request-failed, :exception
Example - nearest expiry: (fetch-options* "AAPL") => {:ok? true :data {:underlying-symbol "AAPL" :expiration-dates [1771372800 1771545600 ...] ; 23 dates :strikes [195.0 200.0 ... 335.0] ; 41 strikes :expiration-date 1771372800 :calls [{:contractSymbol "AAPL260218C00210000" :strike 210.0 :bid 44.6 :ask 47.6 :impliedVolatility 1.447 :inTheMoney true ...} ...] :puts [{:contractSymbol "AAPL260218P00195000" :strike 195.0 :bid 0.01 :ask 0.08 :impliedVolatility 1.453 :inTheMoney false ...} ...]}}
Example - specific expiry: (fetch-options* "AAPL" :expiration 1771372800) => {:ok? true :data {:calls [<31 contracts>] :puts [<32 contracts>] ...}}
Fetch options chain for a ticker (verbose API).
Parameters:
- ticker - Ticker symbol string (e.g. "AAPL")
- :expiration - Epoch seconds (integer) for a specific expiry date.
Omit to get the nearest expiry + list of all available dates.
Returns {:ok? true :data {...}} or {:ok? false :error {:}}.
:data map keys:
- :underlying-symbol - Ticker symbol
- :expiration-dates - Vector of all available expiry dates (epoch seconds)
- :strikes - Vector of all available strike prices
- :expiration-date - Epoch seconds of the returned chain's expiry
- :calls - Vector of call contract maps
- :puts - Vector of put contract maps
- :quote - Current quote data for the underlying
Each contract map includes:
- :contractSymbol - e.g. "AAPL260218C00210000"
- :strike - Strike price (number)
- :bid, :ask - Current bid/ask (number)
- :lastPrice - Last traded price (number)
- :impliedVolatility - IV (number, e.g. 0.35 = 35%)
- :openInterest - Open interest (integer)
- :volume - Volume (integer)
- :inTheMoney - Boolean
- :expiration - Contract expiry (epoch seconds)
- :lastTradeDate - Last trade timestamp (epoch seconds)
- :percentChange, :change - Price change fields
Error types: :auth-failed, :session-failed, :api-error, :http-error,
:rate-limited, :parse-error, :missing-data, :request-failed,
:exception
Example - nearest expiry:
(fetch-options* "AAPL")
=> {:ok? true
:data {:underlying-symbol "AAPL"
:expiration-dates [1771372800 1771545600 ...] ; 23 dates
:strikes [195.0 200.0 ... 335.0] ; 41 strikes
:expiration-date 1771372800
:calls [{:contractSymbol "AAPL260218C00210000"
:strike 210.0 :bid 44.6 :ask 47.6
:impliedVolatility 1.447 :inTheMoney true ...} ...]
:puts [{:contractSymbol "AAPL260218P00195000"
:strike 195.0 :bid 0.01 :ask 0.08
:impliedVolatility 1.453 :inTheMoney false ...} ...]}}
Example - specific expiry:
(fetch-options* "AAPL" :expiration 1771372800)
=> {:ok? true
:data {:calls [<31 contracts>] :puts [<32 contracts>] ...}}cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |