feat(data): weekly and monthly bars, built from daily ones (#1479)

get_market_data and backtests accept 1W and 1M. A monthly review over
21 months used to mean 440 daily rows that microcompaction cleared
faster than the agent could aggregate them, until the no-progress
budget killed the run; one call now returns 21 bars.

Every loader is still asked for daily bars, and loaders.base.resample_bars
builds the period bar at the three fetch boundaries (runner.fetch_data_map,
market_data.fetch_market_data, the benchmark fetch). Few sources serve
weekly or monthly bars and those that do disagree on where a week ends
and how its bar is adjusted, so one resample keeps a weekly bar the same
thing whichever source served the days, at the daily caliber. A week runs
Monday to Sunday, a month is a calendar month, and each bar is stamped
with the last trading day inside it, when its close is known: first open,
highest high, lowest low, last close, summed volume and amount, vwap
weighted by volume, mean funding rate, last value of any other column.

The places that read an interval token learned the two new ones, and
1M is matched before any case fold, which would read it as a minute:
- calc_bars_per_year: 52 and 12 whatever the market's trading days;
- the runner's spacing check: a weekly or monthly file declared 1D now
  matches 1W / 1M; the calendar branch is left for quarterly files;
- _interval_span_hours: 168h and a mean month of 730.5h, so a weekly
  perpetual bar settles 21 funding periods instead of falling back to one;
- strict 100x compared the lower-cased token, so 1M would have passed as
  one minute; attribution lower-cased too and would annualise a monthly
  run at 98,280 bars a year;
- get_market_data serves 1W / 1M and the 1wk / 1mo spellings; the #1480
  guard that refused them is gone, and the case fold no longer maps 1m and
  1M onto one key;
- the technical-indicator tool documented 1wk / 1mo but handed them to the
  loaders verbatim, and fetched two days per bar whatever the interval, so
  200 weekly bars came back as 57.
READMEs x7, the MCP docstring and the strategy-generate skill list them.
This commit is contained in:
Haozhe Wu committed 2026-09-22 11:35:26 +08:00
1 parent dcf811369d
commit 6ca364f757
23 files changed
+466 -112

No files matched your search

+1 -1
View File
@@ -658,7 +658,7 @@ Ejecuta `vibe-trading alpha list` para explorar, `vibe-trading alpha show <id>`
| **Composite** | cross-market | un único pool de capital compartido entre mercados (`source="auto"`) |
| **options_portfolio** | opciones | multi-leg, greeks, payoff/escenario |
Barras intradía: 1m / 5m / 15m / 30m / 1H / 4H / 1D. 15 métricas + comparación con benchmark, **5 optimizadores de cartera** (volatilidad-igual / risk-parity / media-varianza / máxima diversificación / con conciencia de turnover), y 3 herramientas de validación (Monte Carlo / Bootstrap / Walk-Forward).
Barras: 1m / 5m / 15m / 30m / 1H / 4H / 1D, más semanales / mensuales (1W / 1M, construidas a partir de barras diarias). 15 métricas + comparación con benchmark, **5 optimizadores de cartera** (volatilidad-igual / risk-parity / media-varianza / máxima diversificación / con conciencia de turnover), y 3 herramientas de validación (Monte Carlo / Bootstrap / Walk-Forward).
</details>