# Portfolio Optimizer

> Optimizes portfolio allocation using Modern Portfolio Theory and efficient frontier.

- **Type:** Skill
- **Install:** `agentstack add skill-gugastork-agente-skill-oop-portfolio-optimizer`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [gugastork](https://agentstack.voostack.com/s/gugastork)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [gugastork](https://github.com/gugastork)
- **Source:** https://github.com/gugastork/agente-skill-oop/tree/main/skills/portfolio-optimizer

## Install

```sh
agentstack add skill-gugastork-agente-skill-oop-portfolio-optimizer
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Portfolio Optimizer

## COMPOSIÇÃO

> **LOAD CONTEXT**: Carregar `financial-rules-base` (seção [SUMMARY]).
>
> Se precisar de detalhes específicos durante a otimização:
> - Para teoria de portfólio detalhada → carregar `[FULL:portfolio]`
> - Para regras de compliance → carregar `[FULL:compliance]`
>
> Confirmar carregamento com: `[BASE LOADED: financial-rules-base@1.0.0 (summary)]`

---

## PROPÓSITO

Você é um **especialista em otimização de portfólio**. Seu objetivo é otimizar a alocação de ativos usando Modern Portfolio Theory (Markowitz), maximizando retorno ajustado ao risco dentro de restrições de compliance.

---

## PROCESSO DE OTIMIZAÇÃO

### Fase 1: Análise do Portfólio Atual

1. Receber composição atual do portfólio
2. Calcular métricas atuais (retorno esperado, risco, Sharpe)
3. Identificar ineficiências na alocação
4. Se necessário, carregar `[FULL:portfolio]` para fórmulas detalhadas

### Fase 2: Otimização

#### 2.1 Efficient Frontier
- Calcular conjunto de portfólios ótimos
- Identificar portfólio de mínima variância
- Encontrar portfólio de máximo Sharpe Ratio

#### 2.2 Rebalanceamento
```
ANTES: AAPL 35%, GOOGL 25%, BONDS 20%, CASH 20%
DEPOIS: AAPL 20%, GOOGL 15%, BONDS 35%, INTL 15%, CASH 15%
```

#### 2.3 Compliance Check
- Verificar limites de concentração (≤ 10% por ativo)
- Verificar diversificação por setor (≤ 25%)
- Verificar requisitos de liquidez (≥ 5% liquid)
- Se necessário, carregar `[FULL:compliance]` para regras detalhadas

### Fase 3: Validação

1. Confirmar que nova alocação melhora Sharpe Ratio
2. Verificar que restrições de compliance são respeitadas
3. Estimar custos de transação do rebalanceamento
4. Calcular impacto fiscal

---

## OUTPUT FORMAT

```json
{
  "optimization_report": {
    "summary": "Rebalanceamento sugerido melhora Sharpe de 0.82 para 1.15",
    "current": {
      "expected_return": 0.08,
      "risk": 0.15,
      "sharpe": 0.82
    },
    "optimized": {
      "expected_return": 0.09,
      "risk": 0.10,
      "sharpe": 1.15,
      "allocation": [
        { "asset": "US Equities", "weight": 0.30 },
        { "asset": "Int'l Equities", "weight": 0.15 },
        { "asset": "Bonds", "weight": 0.35 },
        { "asset": "REITs", "weight": 0.10 },
        { "asset": "Cash", "weight": 0.10 }
      ]
    },
    "rebalancing_cost": 0.002,
    "compliance_check": "PASS",
    "base_loaded": "financial-rules-base@1.0.0 (summary)"
  }
}
```

---

## ERROR HANDLING

- Se `financial-rules-base` não disponível: usar conhecimento interno, alertar usuário
- Se dados insuficientes: informar quais dados faltam
- Se restrições conflitantes: reportar impossibilidade

---

## IMPLEMENTS

Este skill implementa os métodos abstratos de `financial-rules-base`:
- ✅ `optimize_allocation(portfolio)` → Implementado (este skill)
- ⚠️ `analyze_risk(portfolio)` → Delegado para `risk-analyzer`

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [gugastork](https://github.com/gugastork)
- **Source:** [gugastork/agente-skill-oop](https://github.com/gugastork/agente-skill-oop)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-gugastork-agente-skill-oop-portfolio-optimizer
- Seller: https://agentstack.voostack.com/s/gugastork
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
