# Transaction Cost Analysis

> A Claude skill from brainbytes-dev/everything-claude-trading.

- **Type:** Skill
- **Install:** `agentstack add skill-brainbytes-dev-everything-claude-trading-transaction-cost-analysis`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [brainbytes-dev](https://agentstack.voostack.com/s/brainbytes-dev)
- **Installs:** 0
- **Category:** [Finance & Payments](https://agentstack.voostack.com/c/finance-and-payments)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [brainbytes-dev](https://github.com/brainbytes-dev)
- **Source:** https://github.com/brainbytes-dev/everything-claude-trading/tree/main/skills/execution/transaction-cost-analysis

## Install

```sh
agentstack add skill-brainbytes-dev-everything-claude-trading-transaction-cost-analysis
```

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

## About

# Transaction Cost Analysis

> Transaction cost analysis (TCA) — slippage, market impact, benchmarks for measuring execution quality.

## When to Activate

- User needs to measure and decompose execution costs
- Evaluating broker or algorithm performance
- Building market impact models (Almgren-Chriss, square-root model)
- Comparing execution against benchmarks (VWAP, arrival price, close)
- Conducting pre-trade cost estimation for portfolio rebalancing

## Core Concepts

### What TCA Measures

TCA quantifies the total cost of transforming an investment decision into executed trades. This includes everything from the moment a portfolio manager decides to trade until the last share is filled.

### Cost Taxonomy

**Explicit Costs** (directly observable):
- Commissions: $0.001-0.005/share for institutional equity (declining toward zero)
- Exchange fees: $0.0003-0.003/share (varies by venue, maker/taker)
- Stamp duty / FTT: 0.5% UK, 0.1% HK, varies by jurisdiction
- Clearing fees: negligible for equities, meaningful for derivatives

**Implicit Costs** (estimated from market data):
- Bid-ask spread cost: half-spread on average for market orders
- Market impact: permanent price movement caused by the trade
- Timing cost: price drift between decision and execution
- Opportunity cost: cost of not executing (unexecuted portion)

### Implementation Shortfall Decomposition

Perold (1988) defined implementation shortfall as the difference between paper portfolio return and actual portfolio return:

```
IS = Paper Return - Actual Return

Decomposed into:
IS = Delay Cost + Market Impact + Spread Cost + Opportunity Cost + Commissions

Where:
- Delay Cost = price move from decision to order release
- Market Impact = price move from order release to execution (attributable to our trading)
- Spread Cost = half the bid-ask spread at execution
- Opportunity Cost = return on unexecuted shares (for partial fills)
- Commissions = explicit fees
```

## Methodology

### Step 1: Single-Order TCA

```python
import pandas as pd
import numpy as np

def implementation_shortfall(decision_price, arrival_price, exec_price,
                              close_price, exec_qty, order_qty,
                              side, commission_per_share=0.003):
    """
    Full IS decomposition for a single order.

    decision_price: price when PM made the decision
    arrival_price: price when order reached the trading desk
    exec_price: volume-weighted average execution price
    close_price: closing price on the day
    """
    direction = 1 if side == 'BUY' else -1
    fill_rate = exec_qty / order_qty

    # Component costs (in bps of notional)
    delay_cost = direction * (arrival_price - decision_price) / decision_price * 10000
    market_impact = direction * (exec_price - arrival_price) / arrival_price * 10000
    spread_cost = abs(exec_price - arrival_price) / arrival_price * 10000  # approximate
    commissions = commission_per_share / exec_price * 10000

    # Opportunity cost: return on unfilled shares
    if fill_rate 30 orders per group)
- [ ] Outlier orders investigated individually (extreme slippage may indicate information leakage)
- [ ] Portfolio-level TCA links costs to alpha — are we paying more to trade than we earn?

## Source & license

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

- **Author:** [brainbytes-dev](https://github.com/brainbytes-dev)
- **Source:** [brainbytes-dev/everything-claude-trading](https://github.com/brainbytes-dev/everything-claude-trading)
- **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-brainbytes-dev-everything-claude-trading-transaction-cost-analysis
- Seller: https://agentstack.voostack.com/s/brainbytes-dev
- 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%.
