Skip to content

feat: CVM fund quote history and structure mapping on public MCP - #49

Merged
cursor[bot] merged 2 commits into
mainfrom
cursor/cvm-fund-quotes-structure-cf0b
Aug 30, 2026
Merged

feat: CVM fund quote history and structure mapping on public MCP#49
cursor[bot] merged 2 commits into
mainfrom
cursor/cvm-fund-quotes-structure-cf0b

Conversation

@robertoecf

@robertoecf robertoecf commented Aug 30, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-on to #47/#48. Public cvm_fund already had RCVM 175 cadastro, latest/multi-month INF_DIARIO (Worker capped at 3 months), and CDA periods/holdings. This PR closes the remaining Mais Retorno data gaps using CVM/official files only. Calc/analytics tools stay out.

Already on main (#48): catalog by CNPJ/name, daily (≤3 months on Worker), periods, holdings, CONFID=sigilo, stream ZIP scan, rate limits 60/60s + 20/10s.

This PR:

  • catalog q also matches classe and subclasse names.
  • daily accepts start/end (real calendar days) or months up to 12. CVM yearly HIST ZIPs exceed the Worker 32 MB cap; page longer windows.
  • Single-class RCVM 175 continuation stitches the sibling 555 fund CNPJ, uses the class as identity, and dedupes overlapping dates.
  • Multiple subclasses stay grouped (pick_required); id_subclasse is applied before the point limit.
  • served[].nicename / CVM / ANBIMA class for the series actually returned.
  • Worker tool description maps Mais Retorno data tools onto cvm_fund datasets.
Mais Retorno (data only) cvm_fund
search_assets / get_asset_info / get_fund_class_subclass dataset=catalog
list_fund_structure catalog.classes[].subclasses[]
get_quotes dataset=daily
get_available_wallets dataset=periods product=CDA
get_wallet_detail dataset=holdings

Not implemented (explicitly excluded): backtest_portfolio, compare_assets, get_asset_stats, get_drawdown, get_rolling_windows. No Mais Retorno API. No public code mode. Rate limits unchanged.

Validation

  • Worker: 23 node:test cases (class-name search, calendar start/end, 555→175 stitch, subclass-before-limit, pick_required).
  • Pre-push: ruff, mypy --strict, pytest 351 passed (15 integration deselected).
  • Adversarial CROSS_FAMILY (GPT vs Grok): ACTIONABLE=0 after CVQ-1/2/3.

MCP Trust

PASS (MCP_TOOL). Posted on this PR. Code mode still off on the public Worker.

Deploy (after merge)

  1. Public Worker: cd workers/mcp && npx wrangler deploy if Cloudflare auth is present.
  2. VPS FastAPI (/opt/openfindata, not Charlie): git pull --ff-only + gVisor compose up --build.
  3. Smoke catalog + search + daily history + holdings on 38.729.027/0001-92 and 21.494.444/0001-09.
Open in Web Open in Cursor 

Extend cvm_fund so agents can search by class/subclass name, pull up to
12 months of INF_DIARIO (start/end), stitch a single-class 555→175
continuation, and report the nicename actually served without picking a
FIDC série. Document the Mais Retorno data-tool mapping. No calc tools.
@coderabbitai

coderabbitai Bot commented Aug 30, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4f75847e-3aa4-4ec5-8ff5-a185d119ee12


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

start/end now keep only dt_comptc in the requested inclusive range and
reject impossible dates. id_subclasse is applied before the point limit.
Single-class 555→175 stitch uses the class CNPJ as identity and drops
duplicate dates, keeping the continuation class row.
@cursor

cursor Bot commented Aug 30, 2026

Copy link
Copy Markdown

MCP Trust Review

  • Classificação: MCP_TOOL
  • Base: origin/main (bcbc8ff)
  • Head: d8727df
  • Tools tocadas: cvm_fund (Worker + FastAPI MCP). Sem nova tool. Sem code mode.
  • Conclusão: PASS

Achados

NO_FINDINGS.

Over-engineering

Extendeu cvm_fund com dataset em vez de clonar os nomes Mais Retorno. Histórico anual CVM HIST (>32 MB) ficou de fora do isolate de propósito. Sem camada de Sharpe/deflator.

Eixos

  • A Curation: catálogo continua 1 tool; mapping MR→dataset nas descriptions e em docs/MCP_SURFACE.md.
  • B Code mode: off no Worker; findata_run_code não entra.
  • C Credenciais:dados.cvm.gov.br. Sem Mais Retorno API, sem secrets.
  • D Rede/testes: unitários com mock (respx / fetch); Worker stream ZIP inalterado.
  • E Rate limits: 60/60s + 20/10s intactos.

Adversarial CROSS_FAMILY (GPT vs Grok): ACTIONABLE=0 after CVQ-1/2/3 fixes (calendar start/end, subclass-before-limit, class identity + date dedupe).

@cursor
cursor Bot merged commit 191e865 into main Aug 30, 2026
7 of 8 checks passed
@cursor
cursor Bot deleted the cursor/cvm-fund-quotes-structure-cf0b branch August 30, 2026 21:16
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.

2 participants