Pure Clojure Yahoo Finance client using Java HttpClient. No Python dependency, no API key required.
Provides access to:
All of the above use Yahoo's public chart endpoint. Fundamentals, financial statements, analyst data and options chains live in the clj-yfinance.experimental.* namespaces (authenticated endpoints).
Pure Clojure Yahoo Finance client using Java HttpClient. No Python dependency, no API key required. Provides access to: - Current prices (single and parallel fetch) - Historical OHLCV data with full customization - Dividends and stock splits - Basic ticker information and metadata All of the above use Yahoo's public chart endpoint. Fundamentals, financial statements, analyst data and options chains live in the clj-yfinance.experimental.* namespaces (authenticated endpoints).
(cumulative-split-factor splits since)(cumulative-split-factor splits since until)Compute the cumulative split factor for a position entered at since.
splits is the :splits map as returned by fetch-dividends-splits, i.e.
{:1778160600 {:date 1778160600 :numerator 5.0 :denominator 1.0 :splitRatio "5:1"} ...}.
since (and optional until) are epoch seconds or java.time.Instant.
Multiplies numerator/denominator over all splits with :date strictly after
since (and at or before until, when given). A position entered before a
5:1 split yields 5.0: the share count has been multiplied by 5, and the
per-share entry price divided by 5, relative to today's (split-adjusted)
quotes. Returns 1.0 when no splits apply.
Note: split :date timestamps mark the market open of the effective date, so
trades executed ON the effective date (already in post-split units) are
correctly excluded as long as since is at or after that timestamp — when
working with date-granularity trade data, pass the END of the trade day.
Compute the cumulative split factor for a position entered at `since`.
`splits` is the :splits map as returned by fetch-dividends-splits, i.e.
{:1778160600 {:date 1778160600 :numerator 5.0 :denominator 1.0 :splitRatio "5:1"} ...}.
`since` (and optional `until`) are epoch seconds or java.time.Instant.
Multiplies numerator/denominator over all splits with :date strictly after
`since` (and at or before `until`, when given). A position entered before a
5:1 split yields 5.0: the share count has been multiplied by 5, and the
per-share entry price divided by 5, relative to today's (split-adjusted)
quotes. Returns 1.0 when no splits apply.
Note: split :date timestamps mark the market open of the effective date, so
trades executed ON the effective date (already in post-split units) are
correctly excluded as long as `since` is at or after that timestamp — when
working with date-granularity trade data, pass the END of the trade day.(fetch-dividends-splits ticker & {:keys [period start end] :or {period "5y"}})Fetch dividend and split events for a ticker. Returns {:dividends ... :splits ...} or empty maps on failure.
Options: :period - 1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, 10y, ytd, max (default 5y) :start - Epoch seconds (integer) or Instant (overrides :period) :end - Epoch seconds (integer) or Instant (requires :start; defaults to now)
Fetch dividend and split events for a ticker. Returns {:dividends ... :splits ...} or empty maps on failure.
Options:
:period - 1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, 10y, ytd, max (default 5y)
:start - Epoch seconds (integer) or Instant (overrides :period)
:end - Epoch seconds (integer) or Instant (requires :start; defaults to now)(fetch-dividends-splits* ticker & {:keys [period start end] :or {period "5y"}})Fetch dividend and split events for a ticker. Returns structured result {:ok? true :data {:dividends ... :splits ...}} or {:ok? false :error {...}}.
Options: :period - 1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, 10y, ytd, max (default 5y) :start - Epoch seconds (integer) or Instant (overrides :period) :end - Epoch seconds (integer) or Instant (requires :start; defaults to now)
Fetch dividend and split events for a ticker. Returns structured result {:ok? true :data {:dividends ... :splits ...}} or {:ok? false :error {...}}.
Options:
:period - 1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, 10y, ytd, max (default 5y)
:start - Epoch seconds (integer) or Instant (overrides :period)
:end - Epoch seconds (integer) or Instant (requires :start; defaults to now)(fetch-historical
ticker
&
{:keys [period interval start end auto-adjust prepost]
:or {period "1y" interval "1d" auto-adjust true prepost false}})Fetch historical OHLCV data for a ticker. Returns vector of maps, empty on failure. Options as for fetch-historical*.
Fetch historical OHLCV data for a ticker. Returns vector of maps, empty on failure. Options as for fetch-historical*.
(fetch-historical*
ticker
&
{:keys [period interval start end auto-adjust prepost]
:or {period "1y" interval "1d" auto-adjust true prepost false}})Fetch historical OHLCV data for a ticker. Returns structured result {:ok? true :data [...] :request {...} :warnings [...]} or {:ok? false :error {...}}.
Options: :period - 1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, 10y, ytd, max (default 1y) :interval - 1m, 2m, 5m, 15m, 30m, 60m, 90m, 1h, 1d, 5d, 1wk, 1mo, 3mo (default 1d) :start - Epoch seconds (integer) or Instant (overrides :period) :end - Epoch seconds (integer) or Instant (requires :start; defaults to now) :auto-adjust - Back-adjust :open/:high/:low/:close by the adjclose/close ratio, like python-yfinance's auto_adjust=True, so the whole OHLC series is adjusted for dividends as well as splits (default true). Rows missing adjclose are left unadjusted. :prepost - Include pre/post market data (default false)
Each row is {:timestamp :open :high :low :close :volume :adj-close}. :adj-close is Yahoo's dividend- and split-adjusted close and is always included when Yahoo provides it; with :auto-adjust true it equals :close by construction. Pass :auto-adjust false to get Yahoo's raw (split-adjusted only) OHLC alongside it.
Validation behavior:
Note: For dividend/split events, use fetch-dividends-splits* instead.
Fetch historical OHLCV data for a ticker. Returns structured result {:ok? true :data [...] :request {...} :warnings [...]} or {:ok? false :error {...}}.
Options:
:period - 1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, 10y, ytd, max (default 1y)
:interval - 1m, 2m, 5m, 15m, 30m, 60m, 90m, 1h, 1d, 5d, 1wk, 1mo, 3mo (default 1d)
:start - Epoch seconds (integer) or Instant (overrides :period)
:end - Epoch seconds (integer) or Instant (requires :start; defaults to now)
:auto-adjust - Back-adjust :open/:high/:low/:close by the adjclose/close ratio,
like python-yfinance's auto_adjust=True, so the whole OHLC series
is adjusted for dividends as well as splits (default true).
Rows missing adjclose are left unadjusted.
:prepost - Include pre/post market data (default false)
Each row is {:timestamp :open :high :low :close :volume :adj-close}. :adj-close
is Yahoo's dividend- and split-adjusted close and is always included when Yahoo
provides it; with :auto-adjust true it equals :close by construction. Pass
:auto-adjust false to get Yahoo's raw (split-adjusted only) OHLC alongside it.
Validation behavior:
- Invalid values (period/interval not in allowed sets, :end without :start, start > end)
are rejected immediately with :invalid-opts error
- Valid but incompatible combinations (e.g., 1m interval with 1mo period exceeding 7-day limit)
generate warnings in :warnings key but don't fail—Yahoo's API will reject truly invalid requests
Note: For dividend/split events, use fetch-dividends-splits* instead.(fetch-info ticker)Fetch basic ticker information and metadata. Returns map or nil on failure. See fetch-info* for the returned keys.
Fetch basic ticker information and metadata. Returns map or nil on failure. See fetch-info* for the returned keys.
(fetch-info* ticker)Fetch basic ticker information and metadata. Returns structured result {:ok? true :data {...}} or {:ok? false :error {...}}.
Returns a map with available company info including:
This is basic info from the chart endpoint. For richer company data (sector, description, officers, P/E) see clj-yfinance.experimental.fundamentals.
Fetch basic ticker information and metadata. Returns structured result {:ok? true :data {...}} or {:ok? false :error {...}}.
Returns a map with available company info including:
- :symbol, :long-name, :short-name
- :currency, :exchange-name, :instrument-type
- :regular-market-price, :regular-market-volume
- :regular-market-day-high, :regular-market-day-low
- :fifty-two-week-high, :fifty-two-week-low
- :timezone, :gmt-offset
This is basic info from the chart endpoint. For richer company data (sector,
description, officers, P/E) see clj-yfinance.experimental.fundamentals.(fetch-price ticker)Fetch current price for a single ticker. Returns price number or nil on failure.
Fetch current price for a single ticker. Returns price number or nil on failure.
(fetch-price* ticker)Fetch current price for a single ticker. Returns structured result {:ok? true :data price} or {:ok? false :error {...}}.
Fetch current price for a single ticker. Returns structured result {:ok? true :data price} or {:ok? false :error {...}}.
(fetch-prices tickers & {:keys [concurrency] :or {concurrency 8}})Fetch prices for multiple tickers in parallel. Returns {ticker price} map, omitting failures.
Options: :concurrency - Maximum number of concurrent requests (default 8)
Fetch prices for multiple tickers in parallel. Returns {ticker price} map, omitting failures.
Options:
:concurrency - Maximum number of concurrent requests (default 8)(fetch-prices* tickers & {:keys [concurrency] :or {concurrency 8}})Fetch prices for multiple tickers in parallel with bounded concurrency. Returns {ticker {:ok? ... :data/:error ...}} map.
Options: :concurrency - Maximum number of concurrent requests (default 8)
Fetch prices for multiple tickers in parallel with bounded concurrency.
Returns {ticker {:ok? ... :data/:error ...}} map.
Options:
:concurrency - Maximum number of concurrent requests (default 8)(fetch-split-factor ticker since & {:keys [period] :or {period "max"}})Fetch split events for ticker and return the cumulative split factor for a
position entered at since (epoch seconds or java.time.Instant). See
cumulative-split-factor for the exact semantics. Returns 1.0 when no splits
apply or when the fetch fails.
Options: :period - lookback window for split events (default "max")
Fetch split events for `ticker` and return the cumulative split factor for a position entered at `since` (epoch seconds or java.time.Instant). See cumulative-split-factor for the exact semantics. Returns 1.0 when no splits apply or when the fetch fails. Options: :period - lookback window for split events (default "max")
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 |