compute_attribution
Analyze trade attribution and rotation effectiveness by matching round-trips, computing swap alpha and benchmark-relative returns, and providing pattern analysis with calibration recommendations.
Instructions
Analyze trade attribution and rotation effectiveness.
Matches BUY/SELL trades into round-trips, computes swap alpha (what the replaced stock did), benchmark-relative returns, and pattern analysis with calibration recommendations.
Args: trades_json: JSON array of trades, e.g. '[{"date": "2025-01-15", "action": "BUY", "ticker": "NVDA", "shares": 50, "price": 120.00, "score": 75, "replaced": "INTC"}, ...]'. prices_json: JSON of price data from fetch_prices (the "prices" array). benchmark: Benchmark ticker (default "SPY").
Returns: JSON with round_trips (per-trade attribution, swap alpha) and patterns (win rate, avg return, score-return correlation, recommendations).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| trades_json | Yes | ||
| prices_json | Yes | ||
| benchmark | No | SPY |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |