convez.ai
MCP ServerFinanceiroAvançado
Keshetti-Nikhil

Assessor de Rebalanceamento de Portfólio MCP

Keshetti-Nikhil/portfolio-rebalancing-advisor-mcp-server

Rebalanceamento de portfólio otimizado para impostos com benchmarks de 400 cenários

Ver no GitHub
InicialPluginScore · de 0 a 100

Servidor MCP em Python que fornece ferramentas de rebalanceamento de portfólio com análise comparativa de 400 cenários de mercado, mostrando que estratégias conscientes de impostos superam o rebalanceamento calendário em riqueza líquida após impostos. Integra simulações determinísticas offline com métricas de risco e impacto fiscal.

Instalação

$npx convez-ai Keshetti-Nikhil/portfolio-rebalancing-advisor-mcp-server

1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.

Métricas

Estrelas
0
Forks
0
Acompanhando
0
Saúde
42%
Último commit
há 5 meses
Versão
—
Issues abertas
0
Contribuidores
1

Casos de uso

  • Análise comparativa de estratégias de rebalanceamento (calendário, threshold, tax-aware)
  • Estimativa de impacto fiscal em operações de portfólio antes da execução
  • Decisões de política de rebalanceamento baseadas em riqueza líquida, não tracking error
  • Monitoramento de drift de ativos e detecção de violação de bandas de tolerância

Veredito

MCP bem construído que desafia sabedoria convencional com evidência quantitativa: rebalanceamento calendário (mais apertado) prejudica riqueza líquida por custo de impostos, enquanto estratégias conscientes de impostos com bandas ganham em Sharpe ajustado. Altamente relevante para assessores financeiros e construtores de sistemas de investimento que usem Claude.

README

A tradução para o português deste README ainda está na fila.

portfolio-rebalancing-advisor-mcp-server

python mcp tests mypy scale license

A Model Context Protocol server, in Python, that gives an LLM five portfolio rebalancing tools, plus a multi-period market benchmark that scores four rebalancing strategies on the metric that actually matters to an investor: after-tax terminal wealth. 400 market scenarios x 120 monthly periods x 6 assets. Deterministic, offline, JSON-RPC over stdio.

The challenge

The textbook advice is "rebalance to your target so you do not drift". But every rebalance sells appreciated assets, which realises capital gains, which are taxed, which permanently leaves the portfolio. So the strategy that tracks the target most tightly, calendar rebalancing, is also the one that bleeds the most tax. The question this bench answers is whether tight tracking is worth its tax cost, and the answer is no.

Use case

Use it to reason about rebalancing policy and as a worked MCP server: the tools let an LLM inspect drift, propose trades under a chosen policy, and estimate the tax impact before recommending an action.

MCP tools

ToolDescription
get_portfolioHoldings, target weights, and cost basis
compute_driftPer-asset deviation from target and band breach
propose_rebalanceTrades to rebalance under a chosen strategy
tax_impactEstimated realised-gains tax of a full rebalance
risk_metricsConcentration (max weight, Herfindahl, effective assets)

Headline result

400 scenarios · 120 months · 6 assets · 4% band · 20% gains tax · 10 bps cost.

StrategyNet wealthTracking errorAnnual turnoverTax dragNet SharpeMax weight
no_rebalance2.1960.1600.0000.0000.8950.388
calendar1.8900.0200.2220.1420.8780.197
threshold1.9780.0400.0710.0830.9300.223
tax_aware2.0100.0470.0440.0660.9420.225
  • Calendar rebalancing minimises tracking error (0.020) and is the worst for after-tax wealth (1.890). Its 0.142 tax drag, the highest of any strategy, costs more than the tracking precision is worth. Tight tracking is not the goal.
  • No-rebalance has the highest raw wealth (2.196) but at a real cost: it lets the high-return asset balloon to 0.39, nearly double its 0.167 target weight, which is concentration risk an investor did not choose.
  • Tax-aware banding wins on a risk-adjusted, after-tax basis (Sharpe 0.942, net wealth 2.010) by rebalancing only to the edge of the tolerance band, which cuts turnover and the gains it realises roughly in half versus calendar.
  • The ranking flips depending on the metric: calendar wins tracking error, no-rebalance wins raw wealth, tax-aware wins Sharpe. Choosing the strategy means choosing the metric, and tracking error is the wrong one.

Run it as an MCP server

make install
make serve     # or: uv run pra-mcp

Claude Desktop (claude_desktop_config.json):

{
  "mcpServers": {
    "portfolio-rebalancing-advisor": {
      "command": "uv",
      "args": ["--project", "/abs/path/to/portfolio-rebalancing-advisor-mcp-server", "run", "pra-mcp"]
    }
  }
}

Smoke test:

printf '%s\n' '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | uv run pra-mcp

Chart gallery

Test pyramid

            /\        end-to-end + strategy orderings (test_runner)
           /  \
          /----\      MCP protocol: init/list/call/errors (test_mcp)
         /      \
        /--------\    market generation + portfolio sim (test_market, test_portfolio)
       /__________\   16 tests total

Quickstart

make test          # 16 tests
make bench-fast    # 100 scenarios
make bench         # full 400-scenario run

What is in the repo

src/pra/
  data/market.py      deterministic multi-asset return simulator (the fixture)
  models/portfolio.py simulation with realised-gain taxes + transaction costs
  bench/ + runner.py  net wealth, tracking error, turnover, tax drag, Sharpe
  mcp/server.py       JSON-RPC MCP protocol
  mcp/tools.py        the five advisor tools
  viz/charts.py       six charts incl. wealth-vs-tracking-error trade-off
  cli/main.py         `pra info | bench | serve`

References

  1. Anthropic (2024). Model Context Protocol Specification.
  2. Markowitz, H. (1952). Portfolio Selection. Journal of Finance.
  3. Jaconetti, C., Kinniry, F. & Zilbering, Y. (2010). Best Practices for Portfolio Rebalancing. Vanguard.
  4. Arnott, R. & Lovell, R. (1993). Rebalancing: Why? When? How Often? Journal of Investing.
  5. Daryanani, G. (2008). Opportunistic Rebalancing. Journal of Financial Planning.

License

MIT.

Ver o original no GitHub

Bom para

Relacionados