/tradecraft:market-impact-modelfrom tradecraft
Estimates market impact of orders using the Almgren-Chriss model and generates optimal execution schedules (TWAP/VWAP). Useful for large account trading and transaction cost analysis.
Ships in tradecraft. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
import numpy as np
from dataclasses import dataclass
@dataclass
class MarketParams:
daily_volume: float # average daily volume in lots
avg_spread_pips: float
volatility_daily_pips: float
symbol: str = ""
class MarketImpactModel:
@staticmethod
def almgren_chriss_impact(order_size_lots: float, market: MarketParams,
urgency: float = 0.5) -> dict:
"""
Almgren-Chriss market impact model.
Estimates permanent and temporary impact of an order.
urgency: 0 (patient) to 1 (aggressive)
"""
participation_rate = order_size_lots / max(market.daily_volume, 1)
# Temporary impact (goes away after execution)
temp_impact = market.avg_spread_pips * 0.5 + market.volatility_daily_pips * participation_rate * urgency * 2
# Permanent impact (stays)
perm_impact = market.volatility_daily_pips * np.sqrt(participation_rate) * 0.1
total_impact = temp_impact + perm_impact
return {
"order_size_lots": order_size_lots,
"participation_rate": round(participation_rate * 100, 2),
"temporary_impact_pips": round(temp_impact, 2),
"permanent_impact_pips": round(perm_impact, 2),
"total_estimated_impact_pips": round(total_impact, 2),
"cost_in_spread_multiples": round(total_impact / market.avg_spread_pips, 1),
"recommendation": MarketImpactModel._execution_recommendation(participation_rate, urgency),
}
@staticmethod
def optimal_execution_schedule(order_size_lots: float, market: MarketParams,
execution_hours: float = 4) -> list[dict]:
"""TWAP-style execution schedule to minimize impact."""
n_slices = max(int(execution_hours * 4), 1) # One slice per 15 min
base_size = order_size_lots / n_slices
schedule = []
for i in range(n_slices):
# Vary size: slightly larger at open/close (more liquidity)
hour = i / 4
liquidity_factor = 1.2 if hour < 1 or hour > execution_hours - 1 else 0.9
size = round(base_size * liquidity_factor, 2)
schedule.append({"slice": i + 1, "lots": max(size, 0.01),
"minutes_from_start": i * 15})
return schedule
@staticmethod
def _execution_recommendation(participation: float, urgency: float) -> str:
if participation < 0.01:
return "SMALL ORDER — execute immediately, impact negligible"
if participation < 0.05:
return "MODERATE — consider splitting into 3-5 slices over 1 hour"
if participation < 0.15:
return "LARGE — use TWAP over 2-4 hours, consider limit orders"
return "VERY LARGE — use TWAP over full session, consider iceberg orders"
@staticmethod
def transaction_cost_analysis(trades: list[dict], market: MarketParams) -> dict:
"""Post-trade TCA: measure actual vs expected costs."""
slippages = [t.get("slippage_pips", 0) for t in trades]
return {
"avg_slippage_pips": round(np.mean(slippages), 2),
"max_slippage_pips": round(max(slippages), 2),
"total_cost_pips": round(sum(slippages) + len(trades) * market.avg_spread_pips, 2),
"cost_vs_benchmark": round(np.mean(slippages) / market.avg_spread_pips, 2),
}
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub mahmoud20138/tradecraft --plugin tradecraft169 skills in this plugin
/agent-developmentThis skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins./agentic-storageAgentic storage architecture — persistent memory for AI agents using MCP, immutable versioning, sandboxing, and intent validation. Covers the stateless problem in LLM agents, RAG limitations (read-only), MCP protocol (JSON-RPC, resources, tools), storage safety layers, and agent file system design. Source: IBM Technology (Martin Keen), March 2026. Use this skill for "agentic storage", "agent memory", "persistent agent state", "MCP storage", "agent file system", "agent hard drive", "stateless agent problem", "agent work product", "immutable versioning", "agent sandboxing", "intent validation", "agent safety layers", "agent context window limits", "storage for AI agents", "agent persistence", "autonomous agent storage", "agent audit trail". Works with mcp-integration, trading-brain, agents, trade-psychology-coach.
Other plugins' skills for the same job