Get real-time market data from Yahoo! Finance via WebSockets. Lightweight, efficient, and easy to use.
pip install yliveticker
brew tap yahoofinancelive/yliveticker
brew install yliveticker
To get the interactive dashboard and pandas support:
pip install yliveticker[cli,pandas]
The easiest way to watch stocks. It provides a real-time, color-coded dashboard with sparklines and live status updates.
# Watch multiple symbols and export to CSV
yliveticker watch AAPL MSFT TSLA BTC-USD --export my_data.csv
How it looks:
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ Yahoo! Finance Live Dashboard | 01:50:56 โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โโโโโโโโโโโโณโโโโโโโโโโโโณโโโโโโโโโโโโโโโโโโโณโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Symbol โ Price โ Day Change โ Trend โ
โกโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉ
โ AAPL โ 234.12 โ +1.45 (+0.62%) โ โโโ
โโ โ
โ BTC-USD โ 98,450.00โ -120.50 (-0.12%) โ โโโโ
โโ โ
โ NVDA โ 177.62 โ +2.42 (+1.38%) โ โโ โ
โโโโโโโโโโโโดโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ Status: โ Connected | Updates: 18 | Tickers: 3 | Press Ctrl+C to Quit โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
This is the simplest way to print live updates to the console.
import yliveticker
# this function is called on each ticker update
def on_new_msg(ws, msg):
print(msg)
yliveticker.YLiveTicker(on_ticker=on_new_msg, ticker_names=["BTC-USD", "AAPL", "EURUSD=X"])
Use YTimeSeries to collect data into a structured format for analysis.
import yliveticker
from yliveticker import YTimeSeries
ts = YTimeSeries()
# Collect data (press Ctrl+C to stop and see results)
try:
yliveticker.YLiveTicker(on_ticker=ts.on_ticker, ticker_names=["BTC-USD"])
except KeyboardInterrupt:
pass
# Get raw collected data as a pandas DataFrame
df = ts.get_dataframe()
print(df.head())
# Get 1-minute OHLCV candles
ohlcv = ts.get_ohlcv(interval='1Min')
for symbol, data in ohlcv.items():
print(f"\n--- {symbol} ---")
print(data)
Store and visualize live ticker data using high-performance time-series databases and Grafana.
Install the necessary drivers for your chosen database:
# For all supported databases
pip install yliveticker[all]
# Or individually
pip install yliveticker[influxdb]
pip install yliveticker[timescaledb]
pip install yliveticker[clickhouse]
pip install yliveticker[questdb]
pip install yliveticker[timestream]
We provide a pre-configured environment with InfluxDB and Grafana.
cd docker
docker-compose up -d
python examples/tsdb_example.py
http://localhost:3000 (User: admin, Pass: admin) to see the live "Yahoo Finance Live Ticker" dashboard.The YLiveTicker constructor accepts several parameters for fine-tuning:
| Parameter | Default | Description |
|---|---|---|
on_ticker |
None |
Callback function f(ws, msg) called on each update. |
ticker_names |
["AMZN"] |
List of Yahoo Finance symbols to subscribe to. |
reconnect |
5 |
Delay in seconds before attempting to reconnect on failure. |
ping_interval |
15 |
Interval in seconds to send WebSocket pings. |
ping_timeout |
10 |
Timeout in seconds to wait for a pong response. |
enable_socket_trace |
False |
Set to True to see raw WebSocket frames. |
If you don't observe any live metrics, please check the trading hours for your specific market. Many traditional stock symbols will only provide updates during market hours. Crypto symbols (like BTC-USD) usually stream 24/7.
Distributed under the MIT License. See LICENSE for more information.