# Portfolio Rebalancing Engine MCP

> Portfolio Rebalancing Engine identifies when your current holdings drift from their target asset weights and generates precise buy/sell orders to fix it. This MCP helps you maintain consistent risk profiles across automated or manual trading workflows.

## Overview
- **Category:** finance
- **Price:** Free
- **Tags:** portfolio, rebalancing, trading, asset-management, finance-tools

## Description

This connection lets your agent keep your investments aligned with your original strategy. When market movements cause one asset class to become too large or too small, the engine detects that drift immediately. You can use a tool to analyze how far off your current portfolio is from its ideal setup. Next, it generates exact instructions—the specific buy and sell orders needed to get everything back on track. It even calculates the total cost of these trades, letting you know the true net impact. Because this MCP handles complex financial calculations, Vinkius hosts it as part of a comprehensive catalog of tools for advanced portfolio management.

## Tools

### analyze_portfolio_drift
Checks if your current asset weights have moved beyond their intended target percentages.

### estimate_rebalancing_costs
Calculates the total transaction fees and net value impact of a proposed set of trades.

### compute_rebalancing_orders
Generates specific, quantified buy or sell instructions to restore your portfolio to its target balance.

## Prompt Examples

**Prompt:** 
```
My tech stock weight has drifted to 15% from a target of 10%. How much do I need to sell?
```

**Response:** 
```
To return your tech stock to the 10% target, you should execute a SELL order for the excess value relative to your total portfolio size.
```

**Prompt:** 
```
Check if my current holdings are drifting from my target allocation.
```

**Response:** 
```
The analysis shows that your 'Equities' asset is currently at 65% weight, while the target is 60%, indicating a drift of 5%.
```

**Prompt:** 
```
What will be my total transaction cost if I execute these rebalancing orders with a 0.1% fee?
```

**Response:** 
```
Based on the provided orders, the estimated total transaction cost is $45.50, leaving you with a net portfolio value of $99,954.50.
```

## Capabilities

### Detecting Portfolio Drift
The system analyzes your current asset weights against predefined targets to pinpoint exactly where the drift has occurred.

### Generating Trade Instructions
It computes precise buy and sell orders needed to return asset allocations to their intended weights.

### Calculating Transaction Costs
The engine estimates all associated transaction fees and the resulting net change in your overall portfolio value.

## Use Cases

### Catching a sudden tech bubble spike
A portfolio manager notices the tech sector has spiked, causing their overall allocation to drift significantly. They use analyze_portfolio_drift to confirm the percentage deviation and then run compute_rebalancing_orders to sell enough excess stock to bring the weight back down.

### Preparing for automated quarterly adjustments
A quant trader needs to prep trades before a market window closes. They first use analyze_portfolio_drift, then pass the results to compute_rebalancing_orders, and finally run estimate_rebalance_costs on the resulting list to ensure they know the net impact.

### Verifying compliance after a large trade
A wealth manager executes several manual trades. Before submitting the final report, they use analyze_portfolio_drift and compute_rebalancing_orders to prove that even with the recent activity, their assets are still within compliant weight limits.

### Stress-testing a new investment model
An analyst feeds historical volatility data into your agent. They use analyze_portfolio_drift repeatedly across different market scenarios and then estimate_rebalance_costs to see which models create the fewest unnecessary transaction fees.

## Benefits

- Stops guesswork. Instead of manually checking if your stocks are too high, the analyze_portfolio_drift tool flags exactly which assets have drifted past a set threshold.
- Saves time and capital. By using compute_rebalancing_orders first, you get precise buy/sell instructions right away, eliminating wasted research on manual trade calculations.
- Know your true cost. The estimate_rebalance_costs tool calculates transaction fees and net impact upfront, so nothing surprises your bottom line when the trades execute.
- Maintains risk parity. It ensures that even during volatile market swings, your overall portfolio structure stays within its designed risk parameters.
- Accelerates compliance workflows. You can build automated checks into your agent to verify adherence to regulatory asset weight limits instantly.

## How It Works

The bottom line is that this MCP takes complex financial data and outputs clear, actionable trade lists with calculated costs.

1. First, you prompt your agent to analyze your current holdings against your target allocation using the drift analysis tool.
2. Second, the system uses the results from the drift analysis to compute a set of specific buy and sell instructions needed for correction.
3. Third, it runs these proposed orders through the cost estimation tool, giving you the final transaction fees and net portfolio value before execution.

## Frequently Asked Questions

**How does the Portfolio Rebalancing Engine handle multiple asset classes?**
It treats all assets together, calculating drift across the entire portfolio. It doesn't just look at one stock; it analyzes how all your holdings relate to each other and their defined targets.

**Does compute_rebalancing_orders only give me buy orders?**
No, it generates both BUY and SELL instructions. It figures out the full mix of trades required—the ones you need to buy and the excess ones you must sell.

**What is the difference between analyze_portfolio_drift and compute_rebalancing_orders?**
Drift analysis *tells* you a problem exists (e.g., 'too much tech stock'). Compute rebalancing orders provide the solution—the exact trades needed to fix that specific imbalance.

**Can I use estimate_rebalance_costs for multiple transactions?**
Yes. You feed it a list of proposed orders, and it aggregates all associated fees (like commissions) to give you one total cost figure.

**Is this MCP suitable for non-traditional assets like crypto?**
The engine is designed for asset weight management. As long as your client has defined target weights and the necessary data feeds, it can compute rebalancing orders for those assets.