tickerflow
Async OHLCV for crypto, stocks and forex behind one fetch() call.
Crypto needs no API keys and falls back across Binance, CoinGecko (4h only), Kraken, KuCoin and Yahoo Finance.
Stocks and forex come from yfinance; Tiingo (stocks) and Finnhub are fallbacks once you add a key.
import asyncio
from tickerflow import fetch
async def main():
btc = await fetch("BTCUSDT") # crypto → Binance → CoinGecko → Kraken → KuCoin → yfinance
aapl = await fetch("AAPL") # stocks → yfinance → Tiingo → Finnhub
eur = await fetch("EURUSD") # forex → yfinance → Finnhub
print(btc[-1].close, aapl[-1].close, eur[-1].close)
asyncio.run(main())
Real output of the CLI, run on 2026-11-25 (times are Unix seconds, bar open):
$ tickerflow fetch BTCUSDT 1d 5
time open high low close volume
1795219200 58951.5100 60996.0000 55130.0000 60215.7700 48558.10
1795305600 60215.7800 61669.9900 58768.5100 61271.0800 20137.13
1795392000 61271.0900 64603.1200 60386.0000 61270.9300 27493.88
1795478400 61270.9200 61682.0100 59260.0000 59832.0000 19707.40
1795564800 59832.0000 59950.0000 57300.3800 59674.4400 21870.02
$ tickerflow chart BTCUSDT 1d 30 --no-color
BTCUSDT · 1d · 30 candles
83,313
███ ││
█│█ ██
████████
76,366 ││ ██│████│
││ █████
││││█
██
█
67,682 ██
███│
█████│ │
││ │███ │││
60,735 │█████│
██│ ██
││ │
│
53,788
┼──────────────────────────────
vol █
█ ██
██ ██ █████████████
███████████ ██████████████████
27/10 10/11 25/11
Limitations
- Without API keys, stocks and forex have a single source (yfinance).
4hbars are available for crypto only.- Crypto pairs quoted in fiat, such as
BTCEUR, are read as forex and return no data. - Binance turns some regions away with HTTP 451, GitHub's hosted runners among them; there the next provider in the chain serves the bars.
- Date ranges come from Binance, KuCoin and yfinance; Kraken keeps only its last 720 bars, and CoinGecko, Tiingo and Finnhub serve no ranges. On Yahoo,
1mreaches 7 days back,5mand15m59 days,1h729 days. - On exchanges the last bar is the current, unfinished one, and cached results are reused for the interval's TTL (4 hours for
1d). - CoinGecko serves
4hbars only (up to 180), without volume, and prices stablecoin pairs in USD.
Install
pip install tickerflow
Extras for power users:
pip install "tickerflow[pandas]" # DataFrame output
pip install "tickerflow[serve]" # self-hosted API server
pip install "tickerflow[ai]" # Pydantic AI integration
pip install "tickerflow[all]" # everything
Quick Start
import asyncio
from tickerflow import fetch, fetch_df
async def main():
# Fetch 10 daily candles — provider is auto-selected
candles = await fetch("BTCUSDT", interval="1d", limit=10)
for c in candles[-3:]:
print(f"{c.time} O:{c.open:.2f} H:{c.high:.2f} L:{c.low:.2f} C:{c.close:.2f}")
# Want a DataFrame instead?
df = await fetch_df("AAPL", interval="1d", limit=30)
print(df.describe())
asyncio.run(main())
The result is a list of candles, oldest first, and candles.provider names the provider that served it.
Date Ranges
import asyncio
from datetime import UTC, datetime
from tickerflow import fetch
async def main():
candles = await fetch(
"ETHBTC", "1d", start=datetime(2020, 1, 1, tzinfo=UTC), end=datetime(2026, 1, 1, tzinfo=UTC)
)
print(len(candles), candles.provider) # 2192 binance
asyncio.run(main())
With start, fetch returns every bar that opens from start up to end (default: now), so leave limit out. Binance and KuCoin page back from the newest bar, also when limit asks for more bars than one request holds. start and end are timezone-aware datetimes or Unix seconds.
Errors
fetch returns bars or raises. When no provider serves them, NoDataError says why for each one, in its message and in .reasons:
import asyncio
from datetime import UTC, datetime
from tickerflow import NoDataError, fetch
async def main():
try:
await fetch("ETHBTC", "1d", start=datetime(2020, 1, 1, tzinfo=UTC), providers=["kraken"])
except NoDataError as e:
print(e) # no data for ETHBTC 1d: kraken: serves only its last 720 1d bars, from 2024-12-06 00:00 UTC
asyncio.run(main())
An unknown interval or provider, a limit below 1 or an empty range raise ValueError before any request. providers= tries the named providers in that order instead of the chain for the symbol, and timeout= (30 seconds by default) bounds the whole chain, yfinance included.
CLI
# Auto-routes to the best provider
tickerflow fetch BTCUSDT 1d 10
# Force a provider
tickerflow fetch EURUSD 1d 20 --provider yfinance
# Output formats
tickerflow fetch AAPL 1d 10 --csv
tickerflow fetch AAPL 1d 10 --json
# Terminal chart — screenshot-worthy
tickerflow chart BTCUSDT 1d 30
# Self-hosted market data API
tickerflow serve --port 8000
Terminal Chart
Render OHLCV data directly in your terminal with tickerflow chart:
tickerflow chart BTCUSDT 1d 30
Renders Unicode candlestick charts with ANSI green/red coloring and a volume pane — pure stdlib, zero dependencies. Supports --no-color and respects NO_COLOR.
No extra install needed — included in the base package.
Self-Hosted API
One command starts a FastAPI server with live market data endpoints:
tickerflow serve --port 8000
Then:
curl localhost:8000/ohlcv/BTCUSDT?interval=1d&limit=5
curl localhost:8000/providers/BTCUSDT
curl localhost:8000/health
Returns structured JSON, with the provider that served the candles — plug it into any frontend, dashboard, or automation. No vendor lock-in, runs on your machine; the upstream providers keep their own rate limits.
By default the server listens on 127.0.0.1 only and allows any CORS origin; pass --host 0.0.0.0 to open it to your network.
Requires: pip install "tickerflow[serve]"
DataFrame Output
Prefer a DataFrame? fetch_df takes the same arguments as fetch:
df = await fetch_df("BTCUSDT", interval="1d", limit=30)
print(df.describe())
Returns a pandas.DataFrame with columns time (UTC datetime), open, high, low, close, volume; df.attrs["provider"] names the provider that served it.
Requires: pip install "tickerflow[pandas]"
Provider Routing
The router automatically detects asset class from the symbol and tries providers in order. If one fails, the next picks up.
BTCUSDT → Binance → CoinGecko → Kraken → KuCoin → yfinance
AAPL → yfinance → Tiingo (daily/weekly) → Finnhub
RY.TO → yfinance → Finnhub
EURUSD → yfinance → Finnhub
| Provider | Key required | Asset classes | Date ranges |
|---|---|---|---|
| Binance | No | Crypto | Yes |
| KuCoin | No | Crypto | Yes |
| Kraken | No | Crypto | Last 720 bars |
| CoinGecko | No | Crypto (4h only) |
No |
| yfinance | No | Stocks, Forex, Crypto | Yes |
| Tiingo | Yes (free) | Stocks, ETFs | No |
| Finnhub | Yes (paid) | Stocks, Forex | No |
Supported Intervals
1m · 5m · 15m · 1h · 4h · 1d · 1w. Binance, KuCoin, Kraken and Finnhub also serve 30m, and Binance 3m, 2h, 6h, 8h, 12h, 3d and 1M; tickerflow.INTERVALS lists every interval fetch accepts.
Caching
Responses are cached in memory with interval-aware TTLs:
| Interval | TTL |
|---|---|
1m |
30s |
5m |
2 min |
15m |
5 min |
1h |
30 min |
4h |
2h |
1d |
4h |
1w |
24h |
Disable: OHLCV_CACHE_ENABLED=false
Pydantic AI Integration
Use tickerflow as a tool in your Pydantic AI agents:
from pydantic_ai import Agent
from tickerflow import NoDataError, fetch
agent = Agent("openai:gpt-4o", instructions="You are a market analyst.")
@agent.tool
async def fetch_market_data(ctx, symbol: str, interval: str = "1d", limit: int = 30) -> str:
try:
candles = await fetch(symbol, interval=interval, limit=limit)
except (NoDataError, ValueError) as e:
return f"No data for {symbol}: {e}"
last = candles[-1]
return f"{symbol}: O={last.open:.2f} H={last.high:.2f} L={last.low:.2f} C={last.close:.2f}"
See examples/pydantic_ai_agent.py for a complete working agent.
Requires: pip install "tickerflow[ai]"
Why This Exists
I built tickerflow because I was tired of wiring up different API clients for crypto vs stocks vs forex. I wanted one async fetch() call that handles everything — and falls back automatically when a provider is down.
It is meant for scripts, AI agents and small trading tools that need multi-asset OHLCV data without setting up one client per provider.
Examples
See examples/ for runnable scripts:
- basic_fetch.py — fetch candles for crypto, stock, and forex
- multi_provider.py — inspect provider chains and observe fallback
- pandas_output.py — DataFrame output for quick analysis
- pydantic_ai_agent.py — AI agent with market data tools
Roadmap
Shipped in v0.2
- pandas DataFrame output
tickerflow serve— self-hosted FastAPI market data APItickerflow chart— terminal candlestick charts- Pydantic AI integration example
Shipped in v0.3
- Date ranges with pagination where the exchange allows it
- Errors that give each provider's reason, and results that name the provider
Planned
- OKX and Bybit providers
- WebSocket streaming
- Batch fetching of many symbols within each provider's rate limits
Contributing
See CONTRIBUTING.md for development setup, how to add providers, and PR guidelines.
License
MIT
Metadata
Release files for tickerflow 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tickerflow-0.3.0.tar.gz | 48.0 kB | With provenance | Details for tickerflow-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tickerflow-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for tickerflow-0.3.0-py3-none-any.whl |
Total release size: 83.1 kB
Release files / tickerflow-0.3.0.tar.gz
| Download URL | tickerflow-0.3.0.tar.gz |
|---|---|
| Size | 48.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
31694e9a9eda782bb990fbcb66d8adeb441bcee4a25924ab73cfaedb252e4b61
|
|
BLAKE2b-256 checksum How to use checksums |
65c7325c5ac4bd743ec1ea7f619933452a284f35551cd4da373118f59b5c1dd8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logRelease files / tickerflow-0.3.0-py3-none-any.whl
| Download URL | tickerflow-0.3.0-py3-none-any.whl |
|---|---|
| Size | 35.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ab47f2204b0cdeae997468518714010a1dea905c17b67fccb35ddfc60615351d
|
|
BLAKE2b-256 checksum How to use checksums |
78bb27e780bb0e58dbed3a3f125decbb6afb1c36cea5a06d0000825b57c4c561
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logSecurity for tickerflow 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for tickerflow-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.