# What Types of Stock Data Does the Daily‑Stock‑Analysis Repository Analyze?

> Explore the ZhuLinsen/daily_stock_analysis repository and discover its analysis of historical OHLCV bars, real-time quotes, market indices, and financial metrics via a unified Python interface.

- Repository: [mumu/daily_stock_analysis](https://github.com/ZhuLinsen/daily_stock_analysis)
- Tags: deep-dive
- Published: 2026-04-30

---

**The ZhuLinsen/daily_stock_analysis engine normalizes four distinct categories of equity information—historical daily OHLCV bars, real‑time price quotes, broad market indices, and fundamental financial metrics—behind a unified Python interface regardless of whether the underlying source is Yahoo Finance, Akshare, or Tushare.**

The repository provides a multi‑source aggregation layer that standardizes disparate financial feeds into consistent `pandas` DataFrames and named‑tuples. By abstracting vendor‑specific quirks through the **`BaseFetcher`** class defined in [`data_provider/base.py`](https://github.com/ZhuLinsen/daily_stock_analysis/blob/main/data_provider/base.py), the system guarantees that downstream **stock data** workflows receive identical column schemas whether they are back‑testing on five years of history or querying live market snapshots.

## Historical Daily K‑Line Data (OHLCV)

The foundation of the analysis pipeline is end‑of‑day price history adjusted for splits and dividends. All fetchers inherit from **`BaseFetcher`** and must normalize raw payloads into a DataFrame containing the columns `['date', 'open', 'high', 'low', 'close', 'volume', 'amount', 'pct_chg']`.

Concrete implementations include:

- **`YfinanceFetcher`** – Global equities via Yahoo Finance ([`data_provider/yfinance_fetcher.py`](https://github.com/ZhuLinsen/daily_stock_analysis/blob/main/data_provider/yfinance_fetcher.py))
- **`AkshareFetcher`** – Chinese A‑share and Hong Kong markets ([`data_provider/akshare_fetcher.py`](https://github.com/ZhuLinsen/daily_stock_analysis/blob/main/data_provider/akshare_fetcher.py))
- **`TushareFetcher`** – Pro‑API tier for institutional‑grade history
- **`PytdxFetcher`** and **`BaostockFetcher`** – Direct exchange protocols and free fundamental‑enhanced histories

To retrieve data, instantiate **`DataFetcherManager`** and call `get_daily_data()`:

```python
from data_provider.base import DataFetcherManager

manager = DataFetcherManager()
df, source = manager.get_daily_data('600519', days=60)
print(f"Fetched {len(df)} rows from {source}")
print(df.head())  # Columns: date, open, high, low, close, volume, amount, pct_chg

```

The manager implements a cascading priority chain—`EfinanceFetcher` → `AkshareFetcher` → `PytdxFetcher` → `TushareFetcher` → `BaostockFetcher` → `YfinanceFetcher` → `LongbridgeFetcher`—automatically failing over to the next provider if the primary source is rate‑limited or unavailable.

## Real‑Time Price Quotes

Beyond historical bars, the system captures live market snapshots through **`DataFetcherManager.get_realtime_quote()`**. This method returns a **`UnifiedRealtimeQuote`** named‑tuple containing the latest price, change percentage, volume, turnover rate, PE/PB ratios, and market capitalization, normalized across US, A‑share, and Hong Kong exchanges.

Primary real‑time fetchers include:

- **`AkshareFetcher`** – Aggregates East Money, Sina, and Tencent channels, applying a **20‑minute TTL cache** for bulk A‑share and ETF quotes (`_realtime_cache` and `_etf_realtime_cache` in [`data_provider/akshare_fetcher.py`](https://github.com/ZhuLinsen/daily_stock_analysis/blob/main/data_provider/akshare_fetcher.py))
- **`YfinanceFetcher`** – US equities and major indices
- **`LongbridgeFetcher`** – Authenticated fallback for US/HK securities when free sources exceed limits

```python
manager = DataFetcherManager()

# US equity

quote = manager.get_realtime_quote('AAPL')

# Chinese A‑share (prefix auto‑converted)

quote = manager.get_realtime_quote('sh600519')

# Hong Kong

quote = manager.get_realtime_quote('hk00700')

print(f"{quote.name}: {quote.price} ({quote.change_pct:.2f}%)")

```

## Market‑Wide Statistics and Index Levels

The repository aggregates macro‑level indicators through dedicated methods in `DataFetcherManager`:

- **`get_main_indices(region)`** – Current price, change, and volume for benchmarks such as S&P 500, CSI 300, and Hang Seng
- **`get_market_stats()`** – Exchange‑wide up/down/flat security counts
- **`get_sector_rankings(n)`** – Top‑performing industry groups by momentum

These methods normalize disparate vendor formats into plain dictionaries with keys such as `code`, `name`, `current`, `change_pct`, and `amplitude`, enabling consistent dashboard rendering regardless of whether the underlying feed originates from [`yfinance_fetcher.py`](https://github.com/ZhuLinsen/daily_stock_analysis/blob/main/yfinance_fetcher.py) or [`akshare_fetcher.py`](https://github.com/ZhuLinsen/daily_stock_analysis/blob/main/akshare_fetcher.py).

## Fundamental and Company‑Level Data

For valuation and earnings analysis, the **`AkshareFundamentalAdapter`** ([`data_provider/fundamental_adapter.py`](https://github.com/ZhuLinsen/daily_stock_analysis/blob/main/data_provider/fundamental_adapter.py)) extracts periodic report data including balance sheets, income statements, cash‑flow statements, and chip‑structure metrics. The adapter is exposed internally via `DataFetcherManager._fundamental_adapter` and returns dictionaries containing ratios such as `pe_ratio` and `pb_ratio`.

```python
from data_provider.fundamental_adapter import AkshareFundamentalAdapter

adapter = AkshareFundamentalAdapter()
fundamentals = adapter.get_fundamental('600519')
print(f"PE: {fundamentals['pe_ratio']}, PB: {fundamentals['pb_ratio']}")

```

## Summary

- **Historical daily data**: Standardized OHLCV DataFrames with split/dividend‑adjusted prices, sourced from six distinct fetchers and unified by the `BaseFetcher` interface in [`data_provider/base.py`](https://github.com/ZhuLinsen/daily_stock_analysis/blob/main/data_provider/base.py).
- **Real‑time quotes**: Snapshot prices and market metrics returned as `UnifiedRealtimeQuote` named‑tuples, with 20‑minute caching for A‑share bulk queries.
- **Market statistics**: Index levels, sector rankings, and broad market breadth indicators accessible through region‑specific `DataFetcherManager` methods.
- **Fundamental data**: Quarterly and annual financial statements plus valuation ratios via `AkshareFundamentalAdapter`.

The architecture guarantees that analysis scripts never handle vendor‑specific column naming or API quirks directly; the manager orchestrates failover, caching, and normalization transparently.

## Frequently Asked Questions

### Does the repository support real‑time intraday tick data?

No. The real‑time capabilities are limited to snapshot quotes (last price, volume, daily high/low) rather than full Level‑2 order books or tick‑by‑tick time‑and‑sales streams. For historical granularity, the fetchers provide daily‑bar resolution only; sub‑day data is not currently normalized in the `BaseFetcher` interface.

### How does the system handle data provider outages?

`DataFetcherManager` implements a cascading priority list defined in `_init_default_fetchers` ([`data_provider/base.py`](https://github.com/ZhuLinsen/daily_stock_analysis/blob/main/data_provider/base.py)). If `EfinanceFetcher` fails, it automatically retries with `AkshareFetcher`, then `PytdxFetcher`, continuing down the chain to `LongbridgeFetcher`. Each fetcher handles its own rate‑limiting and exponential back‑off, while the manager logs the successful source for debugging.

### What markets and exchanges are covered?

The codebase explicitly supports **US equities** (NYSE/NASDAQ via Yahoo Finance and Longbridge), **Chinese A‑shares** (SSE/SZSE via Akshare, Tushare, Pytdx, and Efinance), and **Hong Kong** (HKEX via Akshare and Longbridge). The `get_main_indices()` method distinguishes regions using the `region` parameter (`'us'`, `'cn'`, `'hk'`) to return localized benchmark indices.

### Is the historical data adjusted for corporate actions?

Yes. The standard column `pct_chg` and the adjusted `close` prices returned by `get_daily_data()` reflect splits and dividends, not raw nominal prices. This is ensured by the underlying provider libraries (e.g., Akshare and Baostock) and verified through the test suite, which asserts that the standardized DataFrame schema remains consistent across all fetchers.