Skip to content

"Vibe-Trading: Your Personal Trading Agent"

fix(market-data): normalize UK LSE/ISE prices from GBp to GBP at the loader

cgycorey767cb0624e08
diff --git a/agent/backtest/loaders/base.py b/agent/backtest/loaders/base.py
index 5aab0f273..bf680bd49 100644
--- a/agent/backtest/loaders/base.py
+++ b/agent/backtest/loaders/base.py
@@ -20,10 +20,56 @@ from pathlib import Path
from typing import Callable, Protocol, TypeVar, runtime_checkable
import pandas as pd
+import re
logger = logging.getLogger(__name__)
+# Yahoo quotes LSE (.L) and GBp-quoted Irish (.IL) equities in pence, not
+# pounds: VOD.L is ~117p, HSBA.L ~1500p. `code_currency`/`_MARKET_CURRENCY`
+# declare GBP, so prices must be normalized ÷100 when a source reports the
+# pence marker (HKUDS/Vibe-Trading#1206). Anything else is left untouched.
+_GBP_PENCE_CURRENCY = "GBp"
+_PRICE_COLUMNS = ("open", "high", "low", "close")
+_UK_EQUITY_PATTERN = re.compile(r"^[A-Z0-9&.\-]+\.(L|IL)$", re.I)
+
+
+def is_gbp_pence_symbol(code: str) -> bool:
+ """Return whether a project symbol quotes in GBp (LSE/ISE UK names).
+
+ Both Yahoo sources (direct chart + yfinance) serve ``.L`` (always) and
+ ``.IL`` (for GBp-quoted Irish listings) in pence. The engine-side
+ ``code_currency`` resolves these to GBP, so any loader emitting them must
+ normalize ÷100 — callers with chart meta (Yahoo) pass the ``"GBp"``
+ currency directly; sources without per-symbol meta (yfinance) fall back to
+ this suffix rule (#1206).
+ """
+ return bool(_UK_EQUITY_PATTERN.match(str(code).strip()))
+
+
+def scale_pence_to_currency(
+ frame: pd.DataFrame, currency: str
+) -> tuple[pd.DataFrame, str]:
+ """Convert GBp-quoted OHLC prices to GBP (÷100) when the source says GBp.
+
+ Args:
+ frame: OHLCV frame with float price columns.
+ currency: Quote currency declared by the source (e.g. ``"GBp"`` for
+ LSE/ISE pence-quoted names; ``"USD"``/``"EUR"``/``"GBP"`` pass
+ through).
+
+ Returns:
+ ``(frame, applied)``: the (possibly scaled) frame, and the conversion
+ applied — ``"GBp→GBP (÷100)"`` when scaled, else ``"none"``.
+ """
+ if currency != _GBP_PENCE_CURRENCY or frame is None or frame.empty:
+ return frame, "none"
+ scaled = frame.copy()
+ for column in _PRICE_COLUMNS:
+ scaled[column] = scaled[column] / 100.0
+ return scaled, "GBp→GBP (÷100)"
+
+
class NoAvailableSourceError(Exception):
"""Raised when no data source is available for a given market."""
@@ -247,7 +293,9 @@ _LOADER_CACHE_TRUE_VALUES = {"1", "true", "yes", "on"}
# simply never matched (old files become unreachable garbage, safe to delete).
# v4: baostock volume normalized from shares to lots (#1062) — entries cached
# under the pre-normalization unit must never be served again.
-_LOADER_CACHE_VERSION = 4
+# v5: UK (.L/.IL) prices normalized from GBp to GBP (÷100) (#1206) — entries
+# cached under the pre-normalization pence values must never be served again.
+_LOADER_CACHE_VERSION = 5
def loader_cache_enabled() -> bool:
diff --git a/agent/backtest/loaders/yahoo_client.py b/agent/backtest/loaders/yahoo_client.py
index bfbc96d20..547d6de11 100644
--- a/agent/backtest/loaders/yahoo_client.py
+++ b/agent/backtest/loaders/yahoo_client.py
@@ -30,7 +30,7 @@ from __future__ import annotations
import logging
import threading
-from typing import Any, Dict, List, Optional
+from typing import Any, Dict, List, Optional, Tuple
import requests
@@ -179,9 +179,12 @@ def get_chart(
range_: Relative range string; takes precedence over period1/period2.
Returns:
- Ascending list of ``{trade_date, open, high, low, close, volume}`` dicts
- (``trade_date`` is the bar's epoch-second timestamp). Empty when Yahoo
- reports no data for the symbol/window.
+ ``(rows, currency)`` where ``rows`` is an ascending list of
+ ``{trade_date, open, high, low, close, volume}`` dicts (``trade_date``
+ is the bar's epoch-second timestamp) — empty when Yahoo reports no
+ data — and ``currency`` is the quote currency declared by the chart
+ meta (e.g. ``"USD"``, ``"GBP"``, ``"EUR"``, or the pence marker
+ ``"GBp"`` LSE/ISE names quote in). Rows-only callers unpack the tuple.
Raises:
requests.RequestException: On a network/HTTP failure.
@@ -207,8 +210,17 @@ def get_chart(
return _parse_chart(payload, yahoo_symbol)
-def _parse_chart(payload: Any, yahoo_symbol: str) -> List[Dict[str, Any]]:
- """Convert a v8 chart payload into ascending OHLCV row dicts."""
+_GBP_PENCE_CURRENCY = "GBp"
+
+
+def _parse_chart(payload: Any, yahoo_symbol: str) -> Tuple[List[Dict[str, Any]], str]:
+ """Convert a v8 chart payload into ascending OHLCV row dicts.
+
+ Returns:
+ ``(rows, currency)``: rows as in :func:`get_chart`, plus the quote
+ currency declared in the chart meta (``"GBp"`` when the venue quotes
+ UK names in pence — LSE always, ISE for GBp-quoted listings).
+ """
chart = (payload or {}).get("chart") or {}
error = chart.get("error")
if error:
@@ -217,8 +229,9 @@ def _parse_chart(payload: Any, yahoo_symbol: str) -> List[Dict[str, Any]]:
results = chart.get("result") or []
if not results:
- return []
+ return [], ""
result = results[0] or {}
+ currency = (result.get("meta") or {}).get("currency") or ""
timestamps = result.get("timestamp") or []
quotes = (((result.get("indicators") or {}).get("quote")) or [{}])[0] or {}
@@ -232,7 +245,7 @@ def _parse_chart(payload: Any, yahoo_symbol: str) -> List[Dict[str, Any]]:
row: Dict[str, Any] = {"trade_date": ts}
row.update({field: _to_float(values[field]) for field in _QUOTE_FIELDS})
rows.append(row)
- return rows
+ return rows, currency
def _at(series: Any, index: int) -> Any:
diff --git a/agent/backtest/loaders/yahoo_loader.py b/agent/backtest/loaders/yahoo_loader.py
index a3e3a29b8..0d8e88024 100644
--- a/agent/backtest/loaders/yahoo_loader.py
+++ b/agent/backtest/loaders/yahoo_loader.py
@@ -24,7 +24,11 @@ from typing import Dict, List, Optional
import pandas as pd
from backtest.loaders import yahoo_client
-from backtest.loaders.base import cached_loader_fetch, validate_date_range
+from backtest.loaders.base import (
+ cached_loader_fetch,
+ scale_pence_to_currency,
+ validate_date_range,
+)
from backtest.loaders.registry import register
logger = logging.getLogger(__name__)
@@ -47,14 +51,18 @@ _INTERVAL_MAP = {
def _is_supported(code: str) -> bool:
"""Return whether *code* is a symbol this loader handles.
- Covers US/HK/India/Korea/Canada/Vietnam equities plus Yahoo's own futures
- (``GC=F``) and forex (``EURUSD=X``) suffix conventions, which the public
- chart endpoint serves verbatim (the code is used as-is in the request URL,
- no conversion) (#718).
+ Covers US/HK/India/Korea/Canada/Vietnam/UK equities plus Yahoo's own
+ futures (``GC=F``) and forex (``EURUSD=X``) suffix conventions, which the
+ public chart endpoint serves verbatim (the code is used as-is in the
+ request URL, no conversion) (#718). UK ``.L``/``.IL`` comes in GBp and is
+ normalized to GBP at fetch time (#1206).
"""
upper = code.strip().upper()
return upper.endswith(
- (".US", ".HK", ".NS", ".BO", ".KS", ".KQ", ".TO", ".V", ".VN", "=F", "=X")
+ (
+ ".US", ".HK", ".NS", ".BO", ".KS", ".KQ", ".TO", ".V", ".VN",
+ ".L", ".IL", "=F", "=X",
+ )
)
@@ -180,12 +188,15 @@ class DataLoader:
name = "yahoo"
markets = {
"us_equity", "hk_equity", "india_equity", "kr_equity", "ca_equity",
- "vietnam_equity",
+ "vietnam_equity", "uk_equity",
}
# Yahoo chart volume is single shares for US/HK equities
# (HKUDS/Vibe-Trading#1062; HK verified 2026-08-11, 00700.HK ratio 1.00
# vs tencent/eastmoney). Other equity markets stay undeclared.
volume_units = {"us_equity": "shares", "hk_equity": "shares", "uk_equity": "shares"}
+ # Post-fetch price unit per market. UK names arrive GBp-quoted (pence) and
+ # are normalized to GBP (÷100) at fetch time (#1206); US/HK are native.
+ price_units = {"uk_equity": "GBP"}
requires_auth = False
def is_available(self) -> bool:
@@ -268,11 +279,12 @@ class DataLoader:
period1 = _epoch_seconds(start_date)
period2 = _epoch_seconds(end_date) + 86400
- rows = yahoo_client.get_chart(
+ rows, currency = yahoo_client.get_chart(
code,
interval=_to_yahoo_interval(interval),
period1=period1,
period2=period2,
)
frame = _rows_to_frame(rows, start_date, end_date, interval)
+ frame, _ = scale_pence_to_currency(frame, currency)
return frame if not frame.empty else None
diff --git a/agent/backtest/loaders/yfinance_loader.py b/agent/backtest/loaders/yfinance_loader.py
index 6c215ddf7..64849d4f1 100644
--- a/agent/backtest/loaders/yfinance_loader.py
+++ b/agent/backtest/loaders/yfinance_loader.py
@@ -12,8 +12,10 @@ import yfinance as yf
logger = logging.getLogger(__name__)
from backtest.loaders.base import (
+ is_gbp_pence_symbol,
loader_cache_get,
loader_cache_put,
+ scale_pence_to_currency,
validate_date_range,
validate_ohlc,
)
@@ -233,7 +235,7 @@ class DataLoader:
name = "yfinance"
markets = {
"us_equity", "hk_equity", "india_equity", "kr_equity", "ca_equity",
- "vietnam_equity", "crypto",
+ "vietnam_equity", "uk_equity", "crypto",
}
# yfinance volume is single shares for US/HK equities
# (HKUDS/Vibe-Trading#1062; HK verified 2026-08-11, 00700.HK ratio 1.00
@@ -328,6 +330,11 @@ class DataLoader:
logger.warning("yfinance returned no usable data for %s", symbol)
continue
+ # Yahoo-family data: .L/.IL UK names quote in GBp (pence).
+ # Normalize ÷100 so code_currency's GBP matches the values.
+ if is_gbp_pence_symbol(symbol):
+ normalized, _ = scale_pence_to_currency(normalized, "GBp")
+
loader_cache_put(
source=self.name,
symbol=symbol,
diff --git a/agent/src/market_data.py b/agent/src/market_data.py
index 76d8f8b8c..4b35afeb4 100644
--- a/agent/src/market_data.py
+++ b/agent/src/market_data.py
@@ -289,12 +289,19 @@ def fetch_market_data(
results[symbol] = cap_rows(records, max_rows)
if include_provenance:
volume_units = getattr(provider_cls, "volume_units", None) or {}
+ price_units = getattr(provider_cls, "price_units", None) or {}
+ if price_units.get(market):
+ # Loader normalizes GBp-quoted UK prices to GBP at fetch
+ # (#1206); declare the applied conversion explicitly.
+ currency_conversion = f"GBp→{price_units[market]} (÷100)"
+ else:
+ currency_conversion = "none"
entry: dict[str, Any] = {
"source": used_source or src,
"requested_source": source,
"detected_source": src,
"fallback_used": bool(used_source and used_source != src),
- "currency_conversion": "none",
+ "currency_conversion": currency_conversion,
"volume_unit": volume_units.get(market),
}
if extra_provenance:
diff --git a/agent/tests/test_market_data_tool.py b/agent/tests/test_market_data_tool.py
index bb5d5afa3..0bf2257a6 100644
--- a/agent/tests/test_market_data_tool.py
+++ b/agent/tests/test_market_data_tool.py
@@ -133,6 +133,45 @@ def test_market_data_provenance_exposes_declared_volume_unit():
assert payload["_provenance"]["0700.HK"]["volume_unit"] == "shares"
+def test_market_data_provenance_declares_gbp_conversion_for_uk():
+ """UK-serving loaders declare the GBp->GBP price normalization (#1206)."""
+ idx = pd.date_range("2026-01-01", periods=1, freq="D")
+ idx.name = "trade_date"
+ df = pd.DataFrame(
+ {
+ "open": [1.17],
+ "high": [1.18],
+ "low": [1.16],
+ "close": [1.175],
+ "volume": [100],
+ },
+ index=idx,
+ )
+
+ class _UKAwareLoader:
+ volume_units = {"uk_equity": "shares"}
+ price_units = {"uk_equity": "GBP"}
+
+ def fetch(self, codes, start, end, interval="1D"):
+ return {code: df for code in codes}
+
+ payload = json.loads(
+ fetch_market_data_json(
+ codes=["VOD.L", "AAPL.US"],
+ start_date="2026-01-01",
+ end_date="2026-01-02",
+ source="yahoo",
+ loader_resolver=lambda source: _UKAwareLoader,
+ include_provenance=True,
+ )
+ )
+
+ assert payload["_provenance"]["VOD.L"]["currency_conversion"] == "GBp→GBP (÷100)"
+ assert payload["_provenance"]["VOD.L"]["volume_unit"] == "shares"
+ # Non-UK symbols served by the same loader keep "none".
+ assert payload["_provenance"]["AAPL.US"]["currency_conversion"] == "none"
+
+
def test_market_data_provenance_volume_unit_follows_serving_loader():
"""After fallback, the unit comes from the loader that actually served."""
idx = pd.date_range("2026-01-01", periods=1, freq="D")
diff --git a/agent/tests/test_uk_equity_support.py b/agent/tests/test_uk_equity_support.py
index 00c32c28f..b0cba784a 100644
--- a/agent/tests/test_uk_equity_support.py
+++ b/agent/tests/test_uk_equity_support.py
@@ -12,6 +12,7 @@ from __future__ import annotations
from backtest.engines.global_equity import GlobalEquityEngine
from backtest.engines._market_hooks import _detect_market, _detect_submarket, code_currency
+from backtest.loaders.base import is_gbp_pence_symbol, scale_pence_to_currency
from backtest.loaders.registry import FALLBACK_CHAINS
from backtest.runner import _create_market_engine, _MARKET_TO_SOURCE
from src.market_data import detect_source
@@ -97,3 +98,52 @@ class TestUKBacktestRouting:
engine = _create_market_engine("auto", {"initial_cash": 100_000}, ["DCC.IL"])
assert isinstance(engine, GlobalEquityEngine)
assert engine.market == "uk"
+
+
+class TestGbpPenceNormalization:
+ """GBp-quoted UK prices must normalize to GBP (÷100) at the loader."""
+
+ def test_scale_scales_pence_when_currency_is_gbp(self) -> None:
+ import pandas as pd
+
+ frame = pd.DataFrame(
+ {
+ "open": [117.0],
+ "high": [118.5],
+ "low": [116.0],
+ "close": [117.5],
+ "volume": [1000],
+ }
+ )
+ scaled, applied = scale_pence_to_currency(frame, "GBp")
+ assert applied == "GBp→GBP (÷100)"
+ assert scaled["close"].iloc[0] == 117.5 / 100
+ # Volume is never part of the price normalization.
+ assert scaled["volume"].iloc[0] == 1000
+
+ def test_scale_leaves_other_currencies_untouched(self) -> None:
+ import pandas as pd
+
+ frame = pd.DataFrame(
+ {"open": [10.0], "high": [11.0], "low": [9.0], "close": [10.5], "volume": [1]}
+ )
+ for currency in ("USD", "GBP", "EUR", "HKD", ""):
+ scaled, applied = scale_pence_to_currency(frame, currency)
+ assert applied == "none"
+ assert scaled["close"].iloc[0] == 10.5
+
+ def test_scale_empty_frame_is_noop(self) -> None:
+ import pandas as pd
+
+ empty = pd.DataFrame()
+ scaled, applied = scale_pence_to_currency(empty, "GBp")
+ assert applied == "none"
+ assert scaled.empty
+
+ def test_pence_symbol_detection(self) -> None:
+ assert is_gbp_pence_symbol("VOD.L")
+ assert is_gbp_pence_symbol("DCC.IL")
+ assert is_gbp_pence_symbol("vod.l")
+ assert not is_gbp_pence_symbol("AAPL.US")
+ assert not is_gbp_pence_symbol("0700.HK")
+ assert not is_gbp_pence_symbol("GC=F")
diff --git a/agent/tests/test_vietnam_equity.py b/agent/tests/test_vietnam_equity.py
index fc552af10..0f241a09a 100644
--- a/agent/tests/test_vietnam_equity.py
+++ b/agent/tests/test_vietnam_equity.py
@@ -67,7 +67,7 @@ class TestFetch:
def test_fetch_returns_ohlcv_frame(self) -> None:
with patch(
"backtest.loaders.yahoo_loader.yahoo_client.get_chart",
- return_value=self._chart_rows(),
+ return_value=(self._chart_rows(), "VND"),
) as chart:
result = DataLoader().fetch(
["VIC.VN"], "2024-01-01", "2024-01-31", interval="1D"
@@ -86,7 +86,7 @@ class TestFetch:
# HNX/UPCOM are unsupported on Yahoo: no rows, no exception.
with patch(
"backtest.loaders.yahoo_loader.yahoo_client.get_chart",
- return_value=[],
+ return_value=([], ""),
):
result = DataLoader().fetch(
["PVS.VN"], "2024-01-01", "2024-01-31", interval="1D"
diff --git a/agent/tests/test_yahoo_client.py b/agent/tests/test_yahoo_client.py
index 28e2f64ce..07857514a 100644
--- a/agent/tests/test_yahoo_client.py
+++ b/agent/tests/test_yahoo_client.py
@@ -109,10 +109,12 @@ class TestGetChart:
monkeypatch.setattr(yahoo_client, "throttled_get_json", fake_get_json)
- rows = yahoo_client.get_chart("AAPL.US", interval="1d", range_="5d")
+ rows, currency = yahoo_client.get_chart("AAPL.US", interval="1d", range_="5d")
assert captured["url"].endswith("/AAPL")
assert captured["params"] == {"interval": "1d", "range": "5d"}
+ # No meta in this payload -> no declared currency.
+ assert currency == ""
# Third bar has null OHLC and must be dropped.
assert len(rows) == 2
assert rows[0] == {
@@ -134,9 +136,10 @@ class TestGetChart:
monkeypatch.setattr(yahoo_client, "throttled_get_json", fake_get_json)
- rows = yahoo_client.get_chart("0700.HK", period1=100, period2=200)
+ rows, currency = yahoo_client.get_chart("0700.HK", period1=100, period2=200)
assert rows == []
+ assert currency == ""
assert captured["params"] == {"interval": "1d", "period1": 100, "period2": 200}
def test_chart_error_raises(self, monkeypatch):
diff --git a/agent/tests/test_yahoo_loader.py b/agent/tests/test_yahoo_loader.py
index 862ecc932..fac2097bf 100644
--- a/agent/tests/test_yahoo_loader.py
+++ b/agent/tests/test_yahoo_loader.py
@@ -236,7 +236,7 @@ class TestFetch:
]
with patch(
"backtest.loaders.yahoo_loader.yahoo_client.get_chart",
- return_value=rows,
+ return_value=(rows, "USD"),
) as mock_chart:
out = DataLoader().fetch(["AAPL.US"], "2024-01-01", "2024-01-31")
assert "AAPL.US" in out
@@ -256,7 +256,7 @@ class TestFetch:
]
with patch(
"backtest.loaders.yahoo_loader.yahoo_client.get_chart",
- return_value=rows,
+ return_value=(rows, "INR"),
) as mock_chart:
out = DataLoader().fetch(["RELIANCE.NS"], "2024-01-01", "2024-01-31")
assert "RELIANCE.NS" in out
@@ -272,13 +272,48 @@ class TestFetch:
assert out == {}
mock_chart.assert_not_called()
- def test_one_failure_does_not_abort_batch(self):
+ def test_gbp_pence_meta_scales_ohlc_to_gbp(self):
+ # LSE prices arrive in pence ("GBp") from Yahoo's chart meta; the
+ # loader must normalize ÷100 so 117p becomes £1.17.
+ rows = [
+ _row("2024-01-02", 11700, 11800, 11600, 11750, 1000),
+ ]
+ with patch(
+ "backtest.loaders.yahoo_loader.yahoo_client.get_chart",
+ return_value=(rows, "GBp"),
+ ) as mock_chart:
+ out = DataLoader().fetch(["VOD.L"], "2024-01-01", "2024-01-31")
+ assert "VOD.L" in out
+ frame = out["VOD.L"]
+ assert frame["open"].iloc[0] == 117.0
+ assert frame["high"].iloc[0] == 118.0
+ assert frame["low"].iloc[0] == 116.0
+ assert frame["close"].iloc[0] == 117.5
+ # Volume is untouched.
+ assert frame["volume"].iloc[0] == 1000
+ assert mock_chart.call_args.args[0] == "VOD.L"
+
+ def test_non_gbp_currency_meta_left_untouched(self):
+ rows = [
+ _row("2024-01-02", 10, 11, 9, 10.5, 1000),
+ ]
+ with patch(
+ "backtest.loaders.yahoo_loader.yahoo_client.get_chart",
+ return_value=(rows, "USD"),
+ ):
+ out = DataLoader().fetch(["AAPL.US"], "2024-01-01", "2024-01-31")
+ assert out["AAPL.US"]["close"].iloc[0] == 10.5
+
+ def test_uk_symbols_are_supported(self):
+ assert _is_supported("VOD.L")
+ assert _is_supported("DCC.IL")
+ assert not _is_supported("601398.SH")
good_rows = [_row("2024-01-02", 10, 11, 9, 10.5, 1000)]
def fake_chart(symbol, **_kwargs):
if symbol == "BAD.US":
raise ValueError("yahoo chart error")
- return good_rows
+ return good_rows, "USD"
with patch(
"backtest.loaders.yahoo_loader.yahoo_client.get_chart",
@@ -300,7 +335,7 @@ class TestFetch:
def test_no_data_symbol_omitted(self):
with patch(
"backtest.loaders.yahoo_loader.yahoo_client.get_chart",
- return_value=[],
+ return_value=([], ""),
):
out = DataLoader().fetch(["AAPL.US"], "2024-01-01", "2024-01-31")
assert out == {}
@@ -314,7 +349,7 @@ class TestLoaderMetadata:
assert loader.name == "yahoo"
assert loader.markets == {
"us_equity", "hk_equity", "india_equity", "kr_equity", "ca_equity",
- "vietnam_equity",
+ "vietnam_equity", "uk_equity",
}
assert loader.requires_auth is False
assert loader.is_available() is True
diff --git a/agent/tests/test_yfinance_uk_scale.py b/agent/tests/test_yfinance_uk_scale.py
new file mode 100644
index 000000000..b59b969b2
--- /dev/null
+++ b/agent/tests/test_yfinance_uk_scale.py
@@ -0,0 +1,72 @@
+"""yfinance loader scales GBp-quoted UK (.L/.IL) prices to GBP.
+
+Yahoo-family data serves LSE/ISE UK names in pence (VOD.L ~117p); the loader
+must normalize ÷100 so ``code_currency``'s GBP matches the values (#1206).
+"""
+from __future__ import annotations
+
+import pandas as pd
+import pytest
+
+import backtest.loaders.yfinance_loader as yfl
+
+
+def _download_frame() -> pd.DataFrame:
+ # Penny-scale LSE close: 117.5p.
+ return pd.DataFrame(
+ {
+ "Open": [117.0, 118.0],
+ "High": [118.5, 119.0],
+ "Low": [116.0, 117.0],
+ "Close": [117.5, 118.5],
+ "Volume": [100, 200],
+ },
+ index=pd.DatetimeIndex(["2025-01-02", "2025-01-03"], name="Date"),
+ )
+
+
+def test_fetch_scales_lse_pence_to_gbp(monkeypatch: pytest.MonkeyPatch) -> None:
+ monkeypatch.delenv("VIBE_TRADING_DATA_CACHE", raising=False)
+
+ def fake_download(tickers, start_date, end_date, interval):
+ assert tickers == ["VOD.L"]
+ return _download_frame()
+
+ monkeypatch.setattr(yfl, "_download_history", fake_download)
+
+ result = yfl.DataLoader().fetch(["VOD.L"], "2025-01-01", "2025-01-03")
+
+ frame = result["VOD.L"]
+ # 117.5p -> £1.175; volume untouched.
+ assert frame["close"].iloc[0] == pytest.approx(1.175)
+ assert frame["high"].iloc[1] == pytest.approx(1.19)
+ assert frame["low"].iloc[0] == pytest.approx(1.16)
+ assert frame["volume"].iloc[0] == 100
+
+
+def test_fetch_scales_irish_gbp_names(monkeypatch: pytest.MonkeyPatch) -> None:
+ monkeypatch.delenv("VIBE_TRADING_DATA_CACHE", raising=False)
+
+ def fake_download(tickers, start_date, end_date, interval):
+ assert tickers == ["DCC.IL"]
+ return _download_frame()
+
+ monkeypatch.setattr(yfl, "_download_history", fake_download)
+
+ result = yfl.DataLoader().fetch(["DCC.IL"], "2025-01-01", "2025-01-03")
+
+ assert result["DCC.IL"]["close"].iloc[0] == pytest.approx(1.175)
+
+
+def test_fetch_leaves_us_prices_untouched(monkeypatch: pytest.MonkeyPatch) -> None:
+ monkeypatch.delenv("VIBE_TRADING_DATA_CACHE", raising=False)
+
+ def fake_download(tickers, start_date, end_date, interval):
+ assert tickers == ["AAPL"]
+ return _download_frame()
+
+ monkeypatch.setattr(yfl, "_download_history", fake_download)
+
+ result = yfl.DataLoader().fetch(["AAPL.US"], "2025-01-01", "2025-01-03")
+
+ assert result["AAPL.US"]["close"].iloc[0] == pytest.approx(117.5)