close
Skip to content

fix(backtest): route yfinance crypto to CryptoEngine - #970

Merged
warren618 merged 1 commit into
HKUDS:mainfrom
he-yufeng:fix/yfinance-crypto-engine-routing
Aug 6, 2026
Merged

fix(backtest): route yfinance crypto to CryptoEngine#970
warren618 merged 1 commit into
HKUDS:mainfrom
he-yufeng:fix/yfinance-crypto-engine-routing

Conversation

@he-yufeng

@he-yufeng he-yufeng commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Fixes #965.

The yfinance branch of _create_market_engine routed on the loader name alone, so every symbol fetched from Yahoo went to GlobalEquityEngine. That engine reads slippage_us / slippage_hk / hk_commission, so a crypto config's taker_rate / maker_rate / slippage were never looked at, and nothing errored or warned. Two runs differing only in fees came out byte-identical, which is how the reporter caught it.

The fix routes that branch on the instrument market, the same way the fallback branch already does for local/stooq. Crypto pairs now get CryptoEngine and the fee keys actually reach it.

One adjacent gap had to come along for the fix to cover what Yahoo really serves: the market classifier only knew BTC-USDT / BTC/USDT, while Yahoo's native crypto spelling is BTC-USD. Without it, BTC-USD still missed the crypto branch, so ^[A-Z]+-USD$ is added next to the USDT patterns. Nothing else in the pattern list uses the dash-USD shape, so no existing classification moves.

Verification

New test_yfinance_crypto_routing.py: USDT and USD spellings route to CryptoEngine, AAPL.US still routes to GlobalEquityEngine, and an explicit fee config lands on the engine instance (taker_rate / maker_rate / slippage_rate). Routing/engine/composite subset: 769 passed, the only 2 failures (test_akshare_loader forex) reproduce on a clean main checkout without this change, so they are pre-existing and unrelated.

Scope and risk

In scope: engine routing for the yfinance branch and the -USD crypto spelling in the market classifier. Deliberately out of scope: composite-engine fee plumbing and any loader changes. No broker, MCP, network, or credential surface is touched; the change is backtest-local. Rollback is a single-commit revert; the pre-change behavior is reachable by reverting without side effects.

_create_market_engine's yfinance branch handed every symbol to
GlobalEquityEngine on the loader name alone, so crypto pairs fetched
from Yahoo ran under zero-commission equity rules while the
CryptoEngine fee keys (taker_rate/maker_rate/slippage) sat ignored in
config. Two runs differing only in fees produced byte-identical
metrics (HKUDS#965).

Route that branch on the instrument market like the fallback branch
already does, and teach the market classifier yfinance's native crypto
spelling (BTC-USD) next to the USDT forms so the routing actually
covers what Yahoo serves.

Fixes HKUDS#965

Signed-off-by: Yufeng He <40085740+he-yufeng@users.noreply.github.com>
@he-yufeng
he-yufeng force-pushed the fix/yfinance-crypto-engine-routing branch from 40eff7c to 672acca Compare August 4, 2026 08:27
@warren618
warren618 merged commit 8452a84 into HKUDS:main Aug 6, 2026
3 checks passed
p1927 pushed a commit to p1927/Vibe-Trading that referenced this pull request Aug 21, 2026
_create_market_engine's yfinance branch handed every symbol to
GlobalEquityEngine on the loader name alone, so crypto pairs fetched
from Yahoo ran under zero-commission equity rules while the
CryptoEngine fee keys (taker_rate/maker_rate/slippage) sat ignored in
config. Two runs differing only in fees produced byte-identical
metrics (HKUDS#965).

Route that branch on the instrument market like the fallback branch
already does, and teach the market classifier yfinance's native crypto
spelling (BTC-USD) next to the USDT forms so the routing actually
covers what Yahoo serves.

Fixes HKUDS#965

Signed-off-by: Yufeng He <40085740+he-yufeng@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crypto backtests with source: "yfinance" are routed to the equity engine, silently discarding all fee config

2 participants