"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
revert(loaders): remove feitu / FTShare data source
Haozhe Wuac9889a5ba63
diff --git a/README.md b/README.mdindex 35616c139..161fed0ae 100644--- a/README.md+++ b/README.md@@ -305,7 +305,7 @@ Most runs follow the same evidence path: route the request, load the right marke## 📡 Data Sources & Smart Fallback-One `get_market_data` call, **20 free market-data sources** (plus the optional **QVeris** premium marketplace). Set `source: "auto"` — the loader picks by symbol, then walks a per-market chain ordered by **IP-ban risk**: never-banned public sources first, throttled / key-gated ones last. Zero config, no single point of failure.+One `get_market_data` call, **19 free market-data sources** (plus the optional **QVeris** premium marketplace). Set `source: "auto"` — the loader picks by symbol, then walks a per-market chain ordered by **IP-ban risk**: never-banned public sources first, throttled / key-gated ones last. Zero config, no single point of failure.| Source | Markets | Auth | Role ||--------|---------|------|------|@@ -317,7 +317,6 @@ One `get_market_data` call, **20 free market-data sources** (plus the optional *| `yfinance` | US / HK | none | wrapper || `longbridge` | US / HK | App Key + App Secret + Access Token | optional historical OHLCV source; install the optional SDK || `finnhub` · `alphavantage` · `tiingo` · `fmp` | US | key | optional providers |-| `feitu` | A / HK | none | optional [FTShare SDK](https://github.com/FTShare-Lab/FTShare-python-sdk) (`pip install "ftshare @ git+https://github.com/FTShare-Lab/[email protected]"`) || `qveris` | global multi-asset | key · credits | **premium marketplace** — 63+ providers via one key (explicit-only, never in auto fallback) || `okx` · `ccxt` | crypto | none | OKX + 100+ exchanges || `futu` | HK / A | OpenD | optional local FutuOpenD |@@ -326,9 +325,9 @@ One `get_market_data` call, **20 free market-data sources** (plus the optional ***Fallback chains (by IP-ban risk):**-- **A-share** → `tencent` · `mootdx` · `eastmoney` · `baostock` · `feitu` · `akshare` · `tushare` · `local`+- **A-share** → `tencent` · `mootdx` · `eastmoney` · `baostock` · `akshare` · `tushare` · `local`- **US** → `yahoo` · `stooq` · `sina` · `eastmoney` · `yfinance` · `tiingo` · `fmp` · `finnhub` · `alphavantage` · `longbridge` · `akshare` · `local`-- **HK** → `eastmoney` · `yahoo` · `feitu` · `futu` · `yfinance` · `akshare` · `longbridge` · `local`+- **HK** → `eastmoney` · `yahoo` · `futu` · `yfinance` · `akshare` · `longbridge` · `local`- **India (NSE/BSE)** → `yahoo` · `yfinance` · `india_broker` · `local`- **Crypto** → `okx` · `ccxt` · `yfinance` · `local` · *(futures / fund / macro / forex → `tushare`/`akshare` → `local`)*@@ -369,7 +368,7 @@ Beyond OHLCV, **18 read-only data tools** reach into fundamentals & flow — fun<img src="https://www.qveris.com/logo-color.png" alt="QVeris" height="36">-**Data: free routing or premium, your choice.** Free stays the default: 20 built-in sources with ban-risk fallback, no key, no cost. Premium via QVeris adds 10,000+ capabilities (per QVeris) across 63+ providers for options Greeks, premium fundamentals, China/HK/global data, macro, crypto, news, and filings; failed calls are not charged. Enable it in Settings -> QVeris or `vibe-trading data mode paid`.+**Data: free routing or premium, your choice.** Free stays the default: 19 built-in sources with ban-risk fallback, no key, no cost. Premium via QVeris adds 10,000+ capabilities (per QVeris) across 63+ providers for options Greeks, premium fundamentals, China/HK/global data, macro, crypto, news, and filings; failed calls are not charged. Enable it in Settings -> QVeris or `vibe-trading data mode paid`.*QVeris disclosure: [signing up through the Vibe-Trading referral link](https://qveris.ai/?ref=Vyjjo5G_1cAHJA) gets you **+1,000 bonus credits** and supports the project.*<!-- QVERIS-END -->diff --git a/agent/SKILL.md b/agent/SKILL.mdindex c2f09f719..bfe39de61 100644--- a/agent/SKILL.md+++ b/agent/SKILL.md@@ -1,7 +1,7 @@---name: vibe-tradingversion: 0.1.11-description: Professional finance research toolkit — backtesting (8 engines + benchmark comparison panel), factor analysis, Alpha Zoo (461 pre-built alphas across qlib158/alpha101/gtja191/academic/fundamental), options pricing, 88 finance skills, 30 multi-agent swarm teams, Trade Journal analyzer, and Shadow Account (extract → backtest → render) across 22 market-data sources (tushare, yfinance, okx, akshare, baostock, tencent, mootdx, ccxt, futu, local, eastmoney, sina, stooq, yahoo, india_broker, qveris, longbridge, feitu, plus optional-key finnhub/alphavantage/tiingo/fmp).+description: Professional finance research toolkit — backtesting (8 engines + benchmark comparison panel), factor analysis, Alpha Zoo (461 pre-built alphas across qlib158/alpha101/gtja191/academic/fundamental), options pricing, 88 finance skills, 30 multi-agent swarm teams, Trade Journal analyzer, and Shadow Account (extract → backtest → render) across 21 market-data sources (tushare, yfinance, okx, akshare, baostock, tencent, mootdx, ccxt, futu, local, eastmoney, sina, stooq, yahoo, india_broker, qveris, longbridge, plus optional-key finnhub/alphavantage/tiingo/fmp).dependencies:python: ">=3.11"pip:@@ -74,7 +74,7 @@ Feed a CSV broker export (同花顺 / 东财 / 富途 / generic), and the agent5. `scan_shadow_signals` — list today's symbols that match your shadow's entry cadence (research only).### Backtesting-Create and run quantitative strategies across 8 engines (ChinaA, GlobalEquity, IndiaEquity, Crypto, ChinaFutures, GlobalFutures, Forex + options) with 22 market-data sources (auto-detect + ordered fallback):+Create and run quantitative strategies across 8 engines (ChinaA, GlobalEquity, IndiaEquity, Crypto, ChinaFutures, GlobalFutures, Forex + options) with 21 market-data sources (auto-detect + ordered fallback):- **HK/US equities** via yfinance / stooq / yahoo (free, no API key); optionally via **Longbridge** historical OHLCV (`longbridge`, requires the optional SDK and `LONGBRIDGE_APP_KEY` / `LONGBRIDGE_APP_SECRET` / `LONGBRIDGE_ACCESS_TOKEN`). To force it for a run, set `"source": "longbridge"` in `config.json`.- **India equities (NSE/BSE)** via yahoo / yfinance using `<SYMBOL>.NS` (NSE, e.g. `RELIANCE.NS`) or `<SCRIP>.BO` (BSE, e.g. `500325.BO`) — free, no API key. The `IndiaEquityEngine` models T+1 delivery, no overnight shorts (set `allow_short` for intraday), configurable circuit bands, 1-share lots, and the STT/stamp-duty/exchange/GST cost stack. Optionally back-fill from your live broker via the `india_broker` source (Shoonya/Dhan; requires broker login).- **Cryptocurrency** via OKX or CCXT/100+ exchanges (free, no API key)@@ -143,7 +143,7 @@ Use `load_skill(name)` to access full methodology docs with code templates.| `factor_analysis` | IC/IR analysis + layered backtest | None* || `analyze_options` | Black-Scholes price + Greeks | None || `pattern_recognition` | Detect chart patterns (H&S, double top, etc.) | None |-| `get_market_data` | Fetch OHLCV data (auto-detect + ordered fallback across 22 sources) | None* |+| `get_market_data` | Fetch OHLCV data (auto-detect + ordered fallback across 21 sources) | None* || `get_fund_flow` | Capital fund-flow (main/retail net inflow) | None* || `get_dragon_tiger` | Dragon-tiger list (龙虎榜) top buyer/seller seats | None* || `get_northbound_flow` | Northbound (Stock Connect) net flow | None* |diff --git a/agent/backtest/loaders/feitu_loader.py b/agent/backtest/loaders/feitu_loader.pydeleted file mode 100644index 254e2a6f2..000000000--- a/agent/backtest/loaders/feitu_loader.py+++ /dev/null@@ -1,298 +0,0 @@-"""FTShare SDK-backed A-share and Hong Kong equity OHLCV loader.--FTShare is an optional dependency distributed from its upstream GitHub-repository. Importing this module never imports the SDK, so installations-that do not opt into FTShare keep the normal loader fallback behavior.--SDK: https://github.com/FTShare-Lab/FTShare-python-sdk (MIT)-"""--from __future__ import annotations--import logging-import re-from typing import Any, List, Optional--import pandas as pd--from backtest.loaders.base import (- NoAvailableSourceError,- cached_loader_fetch,- validate_date_range,-)-from backtest.loaders.registry import register--logger = logging.getLogger(__name__)--_OHLCV_COLUMNS = ["open", "high", "low", "close", "volume"]-_REQUEST_TIMEOUT_S = 20-_INSTALL_COMMAND = (- 'pip install "ftshare @ '- 'git+https://github.com/FTShare-Lab/[email protected]"'-)--_A_SHARE_RE = re.compile(- r"^(?P<code>\d{6})\.(?P<exchange>SH|XSHG|SZ|XSHE|BJ|BJSE)$",- re.IGNORECASE,-)-_HK_RE = re.compile(r"^(?P<code>\d{1,5})\.HK$", re.IGNORECASE)--_A_SHARE_INTERVALS = {- "1D": "Day",- "1W": "Week",- "1M": "Month",-}-_HK_INTERVALS = {- "1D": "day",- "1M": "month",-}---class FTShareDependencyError(RuntimeError):- """Raised when the optional FTShare SDK is not installed."""---def _require_ftshare() -> Any:- """Import and return the optional ``ftshare`` SDK module.-- Returns:- Imported ``ftshare`` module.-- Raises:- FTShareDependencyError: If the SDK is not installed.- """- try:- import ftshare # noqa: PLC0415- except ImportError as exc:- raise FTShareDependencyError(- f"The 'ftshare' SDK is not installed. Run: {_INSTALL_COMMAND}"- ) from exc- return ftshare---def _normalize_symbol(code: str) -> tuple[str, str] | None:- """Convert a project symbol to the FTShare SDK format.-- Args:- code: Project symbol such as ``600000.SH`` or ``700.HK``.-- Returns:- ``(market, sdk_symbol)`` or ``None`` for an unsupported symbol.- """- value = code.strip().upper()- a_share = _A_SHARE_RE.fullmatch(value)- if a_share:- exchange = a_share.group("exchange")- suffix = {- "SH": "XSHG",- "XSHG": "XSHG",- "SZ": "XSHE",- "XSHE": "XSHE",- "BJ": "BJSE",- "BJSE": "BJSE",- }[exchange]- return "a_share", f"{a_share.group('code')}.{suffix}"-- hk = _HK_RE.fullmatch(value)- if hk:- return "hk_equity", f"{int(hk.group('code')):05d}.HK"- return None---def _normalize_frame(frame: pd.DataFrame, *, market: str) -> pd.DataFrame:- """Normalize an FTShare response to the repository OHLCV contract.-- Args:- frame: DataFrame returned by the FTShare SDK.- market: ``a_share`` or ``hk_equity``.-- Returns:- Timezone-naive, ascending OHLCV frame indexed by ``trade_date``.- """- if frame is None or frame.empty:- return pd.DataFrame(columns=_OHLCV_COLUMNS)-- result = frame.copy()- if market == "a_share":- timestamp_column = next(- (name for name in ("open_ts_ms", "close_ts_ms") if name in result),- None,- )- if timestamp_column is None:- return pd.DataFrame(columns=_OHLCV_COLUMNS)- trade_dates = (- pd.to_datetime(- result[timestamp_column], unit="ms", errors="coerce", utc=True- )- .dt.tz_convert("Asia/Shanghai")- .dt.tz_localize(None)- .dt.normalize()- )- else:- if "date" not in result:- return pd.DataFrame(columns=_OHLCV_COLUMNS)- trade_dates = pd.to_datetime(result["date"], errors="coerce")-- missing = [column for column in _OHLCV_COLUMNS if column not in result]- if missing:- logger.warning("FTShare response missing OHLCV columns: %s", missing)- return pd.DataFrame(columns=_OHLCV_COLUMNS)-- normalized = result[_OHLCV_COLUMNS].copy()- for column in _OHLCV_COLUMNS:- normalized[column] = pd.to_numeric(normalized[column], errors="coerce")- normalized.index = pd.DatetimeIndex(trade_dates, name="trade_date")- normalized = normalized[~normalized.index.isna()]- normalized = normalized.dropna(subset=["open", "high", "low", "close"])- normalized["volume"] = normalized["volume"].fillna(0.0)- return normalized[~normalized.index.duplicated(keep="last")].sort_index()---def _a_share_interval(interval: str) -> str:- token = interval.strip()- if token not in _A_SHARE_INTERVALS:- raise NoAvailableSourceError(- f"unsupported FTShare A-share interval: {interval!r}; "- f"supported intervals: {sorted(_A_SHARE_INTERVALS)}"- )- return _A_SHARE_INTERVALS[token]---def _hk_interval(interval: str) -> str:- token = interval.strip()- if token not in _HK_INTERVALS:- raise NoAvailableSourceError(- f"unsupported FTShare HK interval: {interval!r}; "- f"supported intervals: {sorted(_HK_INTERVALS)}"- )- return _HK_INTERVALS[token]---@register-class DataLoader:- """Fetch A-share and Hong Kong equity bars through the FTShare SDK."""-- name = "feitu"- markets = {"a_share", "hk_equity"}- requires_auth = False-- def is_available(self) -> bool:- """Return whether the optional SDK is importable without network I/O."""- try:- _require_ftshare()- return True- except FTShareDependencyError:- return False-- def fetch(- self,- codes: List[str],- start_date: str,- end_date: str,- *,- interval: str = "1D",- fields: Optional[List[str]] = None,- ) -> dict[str, pd.DataFrame]:- """Fetch normalized OHLCV history through FTShare.-- Args:- codes: A-share or HK symbols in project format.- start_date: Inclusive start date in ``YYYY-MM-DD`` format.- end_date: Inclusive end date in ``YYYY-MM-DD`` format.- interval: ``1D``, ``1W`` or ``1M`` for A-shares; ``1D`` or- ``1M`` for Hong Kong equities.- fields: Ignored; included for loader protocol compatibility.-- Returns:- Mapping of the original input symbol to normalized OHLCV data.- """- del fields- if not codes:- return {}- validate_date_range(start_date, end_date)-- supported = [(code, _normalize_symbol(code)) for code in codes]- pending = [(code, symbol) for code, symbol in supported if symbol]- for code, symbol in supported:- if symbol is None:- logger.warning("FTShare does not support symbol %s", code)- if not pending:- return {}-- client: Any | None = None-- def get_client() -> Any:- nonlocal client- if client is None:- ftshare = _require_ftshare()- try:- client = ftshare.market_api(timeout=_REQUEST_TIMEOUT_S)- except Exception as exc:- raise NoAvailableSourceError(- f"Cannot initialise FTShare SDK client: {exc}"- ) from exc- return client-- results: dict[str, pd.DataFrame] = {}- try:- for code, normalized_symbol in pending:- assert normalized_symbol is not None- market, sdk_symbol = normalized_symbol- try:- frame = cached_loader_fetch(- source=self.name,- symbol=code,- timeframe=interval,- start_date=start_date,- end_date=end_date,- fields=None,- fetch=lambda market=market, sdk_symbol=sdk_symbol: self._fetch_one(- get_client(),- market=market,- symbol=sdk_symbol,- start_date=start_date,- end_date=end_date,- interval=interval,- ),- )- except Exception as exc:- logger.warning("FTShare failed for %s: %s", code, exc)- continue- if frame is not None and not frame.empty:- results[code] = frame- finally:- if client is not None:- close = getattr(client, "close", None)- if callable(close):- close()- return results-- @staticmethod- def _fetch_one(- client: Any,- *,- market: str,- symbol: str,- start_date: str,- end_date: str,- interval: str,- ) -> pd.DataFrame:- """Fetch and normalize one FTShare symbol."""- if market == "a_share":- frame = client.stock_ohlcs(- symbol=symbol,- since=pd.Timestamp(start_date).strftime("%Y%m%d"),- until=pd.Timestamp(end_date).strftime("%Y%m%d"),- interval=_a_share_interval(interval),- adjust="Forward",- )- else:- frame = client.hk_candlesticks(- trade_code=symbol,- interval_unit=_hk_interval(interval),- since_date=pd.Timestamp(start_date).strftime("%Y-%m-%d"),- until_date=pd.Timestamp(end_date).strftime("%Y-%m-%d"),- interval_value=1,- adjust_kind="forward",- )- return _normalize_frame(frame, market=market)diff --git a/agent/backtest/loaders/registry.py b/agent/backtest/loaders/registry.pyindex ac65da1f0..03f0f33fc 100644--- a/agent/backtest/loaders/registry.py+++ b/agent/backtest/loaders/registry.py@@ -48,7 +48,6 @@ VALID_SOURCES: set[str] = {"alphavantage","tiingo","fmp",- "feitu","qveris", # QVERIS-INTEGRATION"india_broker","longbridge",@@ -96,7 +95,6 @@ def _ensure_registered() -> None:"backtest.loaders.alphavantage_loader","backtest.loaders.tiingo_loader","backtest.loaders.fmp_loader",- "backtest.loaders.feitu_loader","backtest.loaders.qveris_loader", # QVERIS-INTEGRATION"backtest.loaders.india_broker_loader","backtest.loaders.longbridge",@@ -130,9 +128,9 @@ _NO_NETWORK_FALLBACK_SOURCES: frozenset[str] = frozenset({"local", "qveris"}) ## that must be politely throttled; Finnhub/AlphaVantage/Tiingo/FMP are key-gated# REST fallbacks placed deeper in the chain.FALLBACK_CHAINS: dict[str, list[str]] = {- "a_share": ["tencent", "mootdx", "eastmoney", "baostock", "feitu", "akshare", "tushare", "local"],+ "a_share": ["tencent", "mootdx", "eastmoney", "baostock", "akshare", "tushare", "local"],"us_equity": ["yahoo", "stooq", "sina", "eastmoney", "yfinance", "tiingo", "fmp", "finnhub", "alphavantage", "longbridge", "akshare", "local"],- "hk_equity": ["eastmoney", "yahoo", "feitu", "futu", "yfinance", "akshare", "longbridge", "local"],+ "hk_equity": ["eastmoney", "yahoo", "futu", "yfinance", "akshare", "longbridge", "local"],"india_equity": ["yahoo", "yfinance", "india_broker", "local"],"crypto": ["okx", "ccxt", "yfinance", "local"],"futures": ["tushare", "akshare", "local"],diff --git a/agent/src/skills/data-routing/SKILL.md b/agent/src/skills/data-routing/SKILL.mdindex c9a78c81c..6505e257b 100644--- a/agent/src/skills/data-routing/SKILL.md+++ b/agent/src/skills/data-routing/SKILL.md@@ -37,7 +37,6 @@ per-source skill.| alphavantage | US equities | Yes (`ALPHAVANTAGE_API_KEY`) | Unrestricted | data-routing || tiingo | US equities | Yes (`TIINGO_API_KEY`) | Unrestricted | data-routing || fmp | US equities | Yes (`FMP_API_KEY`) | Unrestricted | data-routing |-| feitu | A-shares, HK equities | No (optional `ftshare` SDK) | FTShare API | data-routing || qveris | Global multi-asset (paid, credits) | Yes (`QVERIS_API_KEY` / Settings) | QVeris API | qveris <!-- QVERIS-INTEGRATION --> |## Capability → Tool Routingdiff --git a/agent/src/skills/qveris/references/coverage.md b/agent/src/skills/qveris/references/coverage.mdindex aa569b37d..afe12f504 100644--- a/agent/src/skills/qveris/references/coverage.md+++ b/agent/src/skills/qveris/references/coverage.md@@ -37,7 +37,7 @@ results from `qveris_search`.|----------|--------------------------------|--------------------|----------------------|---------------------------------------|| US/global equities OHLCV | FMP, AlphaVantage, TwelveData, EODHD, Yahoo | 1-24.2 credits/call | The user asks for a paid provider, global breadth, or a source not covered by free loaders. | Routine OHLCV can use `source:"auto"` with yahoo/stooq/sina/eastmoney/yfinance/free fallbacks. || A-share and China market data | cn_financial_pro, cninfo, caidazi | 1-24.2 credits/call | Premium China fields, document-style data, or provider-specific coverage are needed. | A-share OHLCV and common flow/fundamental tools are covered by tencent/mootdx/eastmoney/akshare/tushare. |-| Hong Kong market data | hangseng_polysource, HKMA, Yahoo/FMP-style providers | 1-24.2 credits/call | HK-specific premium breadth or monetary data is required. | Routine HK OHLCV can use eastmoney/yahoo/feitu/futu/yfinance/akshare/local. |+| Hong Kong market data | hangseng_polysource, HKMA, Yahoo/FMP-style providers | 1-24.2 credits/call | HK-specific premium breadth or monetary data is required. | Routine HK OHLCV can use eastmoney/yahoo/futu/yfinance/akshare/local. || Fundamentals and financial statements | FMP, Finnhub, AlphaVantage, SEC, cn_financial_pro | 1-24.2 credits/call | Cross-provider comparison, premium vendor ratios, or non-US/non-China/HK coverage is needed. | US SEC facts and A/HK Eastmoney statements are available through built-in read-only tools. || SEC filings and institutional data | SEC, Finnhub, FMP | 1-24.2 credits/call | Marketplace convenience or 13F/filing enrichment is needed. | Official SEC filings/companyfacts should stay on built-in SEC tools when sufficient. || News and sentiment | Finnhub, FMP, AlphaVantage, web-search providers | 1-24.2 credits/call | Paid sentiment/news feeds or broad provider comparison are needed. | Basic stock news and web context can use built-in `get_stock_news` / `web_search`. |diff --git a/agent/tests/test_feitu_loader.py b/agent/tests/test_feitu_loader.pydeleted file mode 100644index 968e7e094..000000000--- a/agent/tests/test_feitu_loader.py+++ /dev/null@@ -1,222 +0,0 @@-"""Contract tests for the optional FTShare market-data loader."""--from __future__ import annotations--from types import SimpleNamespace--import pandas as pd-import pytest--from backtest.loaders import feitu_loader as loader_mod-from backtest.loaders.base import NoAvailableSourceError--- ("raw", "expected"),- [- ("600000.SH", ("a_share", "600000.XSHG")),- ("000001.XSHE", ("a_share", "000001.XSHE")),- ("920163.BJ", ("a_share", "920163.BJSE")),- ("700.HK", ("hk_equity", "00700.HK")),- ("00700.hk", ("hk_equity", "00700.HK")),- ("AAPL.US", None),- ("BTC-USDT", None),- ],-)-def test_normalize_symbol(raw: str, expected: tuple[str, str] | None) -> None:- assert loader_mod._normalize_symbol(raw) == expected---def test_normalize_a_share_frame_uses_shanghai_trade_date() -> None:- frame = pd.DataFrame(- [- {- "open_ts_ms": 1782869400000,- "open": "8.58",- "high": "8.75",- "low": "8.54",- "close": "8.65",- "volume": 53_417_711,- }- ]- )-- result = loader_mod._normalize_frame(frame, market="a_share")-- assert result.index.name == "trade_date"- assert result.index.tz is None- assert result.index[0] == pd.Timestamp("2026-07-01")- assert result.loc[pd.Timestamp("2026-07-01"), "close"] == pytest.approx(8.65)- assert list(result.columns) == ["open", "high", "low", "close", "volume"]---def test_normalize_hk_frame_sorts_dates_and_deduplicates() -> None:- frame = pd.DataFrame(- [- {- "date": "2026-07-08",- "open": "461.2",- "high": "482.8",- "low": "460.6",- "close": "478.8",- "volume": 10,- },- {- "date": "2026-07-07",- "open": "459",- "high": "479.8",- "low": "457",- "close": "461.2",- "volume": 20,- },- {- "date": "2026-07-08",- "open": "462",- "high": "483",- "low": "461",- "close": "479",- "volume": 30,- },- ]- )-- result = loader_mod._normalize_frame(frame, market="hk_equity")-- assert list(result.index) == [- pd.Timestamp("2026-07-07"),- pd.Timestamp("2026-07-08"),- ]- assert result.loc[pd.Timestamp("2026-07-08"), "close"] == pytest.approx(479)--[email protected]("interval", ["1m", "1H", "2D"])-def test_unsupported_a_share_intervals_fail(interval: str) -> None:- with pytest.raises(- NoAvailableSourceError, match="unsupported FTShare A-share interval"- ):- loader_mod._a_share_interval(interval)---def test_hk_weekly_interval_fails_instead_of_changing_fidelity() -> None:- with pytest.raises(NoAvailableSourceError, match="unsupported FTShare HK interval"):- loader_mod._hk_interval("1W")---def test_is_available_is_import_only(monkeypatch: pytest.MonkeyPatch) -> None:- fake_sdk = SimpleNamespace(- market_api=lambda **kwargs: (_ for _ in ()).throw(- AssertionError("availability must not create a client")- )- )- monkeypatch.setattr(loader_mod, "_require_ftshare", lambda: fake_sdk)-- assert loader_mod.DataLoader().is_available() is True---def test_fetch_routes_a_share_and_hk_and_closes_client(- monkeypatch: pytest.MonkeyPatch,-) -> None:- calls: list[tuple[str, dict[str, object]]] = []-- class FakeClient:- closed = False-- def stock_ohlcs(self, **kwargs: object) -> pd.DataFrame:- calls.append(("a_share", kwargs))- return pd.DataFrame(- [- {- "open_ts_ms": 1782869400000,- "open": "8.58",- "high": "8.75",- "low": "8.54",- "close": "8.65",- "volume": 100,- }- ]- )-- def hk_candlesticks(self, **kwargs: object) -> pd.DataFrame:- calls.append(("hk", kwargs))- return pd.DataFrame(- [- {- "date": "2026-07-01",- "open": "460",- "high": "480",- "low": "455",- "close": "475",- "volume": 200,- }- ]- )-- def close(self) -> None:- self.closed = True-- client = FakeClient()- fake_sdk = SimpleNamespace(market_api=lambda **kwargs: client)- monkeypatch.setattr(loader_mod, "_require_ftshare", lambda: fake_sdk)- monkeypatch.setattr(- loader_mod,- "cached_loader_fetch",- lambda **kwargs: kwargs["fetch"](),- )-- result = loader_mod.DataLoader().fetch(- ["600000.SH", "700.HK"],- "2026-07-01",- "2026-07-10",- )-- assert set(result) == {"600000.SH", "700.HK"}- assert calls == [- (- "a_share",- {- "symbol": "600000.XSHG",- "since": "20260701",- "until": "20260710",- "interval": "Day",- "adjust": "Forward",- },- ),- (- "hk",- {- "trade_code": "00700.HK",- "interval_unit": "day",- "since_date": "2026-07-01",- "until_date": "2026-07-10",- "interval_value": 1,- "adjust_kind": "forward",- },- ),- ]- assert client.closed is True---def test_fetch_failure_returns_empty_map_for_runtime_fallback(- monkeypatch: pytest.MonkeyPatch,-) -> None:- class BrokenClient:- def stock_ohlcs(self, **kwargs: object) -> pd.DataFrame:- raise RuntimeError("upstream unavailable")-- def close(self) -> None:- pass-- monkeypatch.setattr(- loader_mod,- "_require_ftshare",- lambda: SimpleNamespace(market_api=lambda **kwargs: BrokenClient()),- )- monkeypatch.setattr(- loader_mod,- "cached_loader_fetch",- lambda **kwargs: kwargs["fetch"](),- )-- assert (- loader_mod.DataLoader().fetch(["600000.SH"], "2026-07-01", "2026-07-10") == {}- )diff --git a/agent/tests/test_registry.py b/agent/tests/test_registry.pyindex fb9b7a1ed..0269bc003 100644--- a/agent/tests/test_registry.py+++ b/agent/tests/test_registry.py@@ -149,14 +149,14 @@ class TestFallbackChains:"""Equity chains lead with throttle-tolerant public sources and trailwith key-gated REST fallbacks, in the exact reviewed order."""assert FALLBACK_CHAINS["a_share"] == [- "tencent", "mootdx", "eastmoney", "baostock", "feitu", "akshare", "tushare", "local",+ "tencent", "mootdx", "eastmoney", "baostock", "akshare", "tushare", "local",]assert FALLBACK_CHAINS["us_equity"] == ["yahoo", "stooq", "sina", "eastmoney", "yfinance", "tiingo", "fmp","finnhub", "alphavantage", "longbridge", "akshare", "local",]assert FALLBACK_CHAINS["hk_equity"] == [- "eastmoney", "yahoo", "feitu", "futu", "yfinance", "akshare", "longbridge", "local",+ "eastmoney", "yahoo", "futu", "yfinance", "akshare", "longbridge", "local",]def test_us_equity_includes_sina_fallback(self) -> None: