/tradecraft:ai-signal-aggregatorfrom tradecraft
Combines signals from multiple trading strategies using weighted voting, random forest meta-learner, and confidence calibration. Use for aggregating strategy signals or getting a master recommendation.
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 pandas as pd, numpy as np
from sklearn.ensemble import RandomForestClassifier, GradientBoostingClassifier
from sklearn.calibration import CalibratedClassifierCV
class AISignalAggregator:
@staticmethod
def weighted_vote(signals: dict, weights: dict = None) -> dict:
"""Combine signals from multiple strategies using weighted voting."""
default_weights = {
"trend_following": 1.2, "mean_reversion": 0.8, "breakout": 1.0,
"price_action": 1.3, "divergence": 0.9, "momentum": 0.8,
"institutional": 1.5, "news": 0.7, "sentiment_contrarian": 0.6,
"fibonacci": 0.7, "harmonic": 0.6, "elliott_wave": 0.5,
"wyckoff": 1.2, "supply_demand": 1.1, "volume_profile": 1.0,
"market_structure": 1.3, "session_breakout": 0.9, "mtf_confluence": 1.4,
}
weights = weights or default_weights
total_score = 0
total_weight = 0
details = []
for strategy, signal in signals.items():
w = weights.get(strategy, 1.0)
# Normalize signal to -1 (sell) to +1 (buy)
if isinstance(signal, str):
s = signal.upper()
score = 1.0 if "BUY" in s or "BULL" in s or "LONG" in s else -1.0 if "SELL" in s or "BEAR" in s or "SHORT" in s else 0
elif isinstance(signal, (int, float)):
score = np.clip(signal, -1, 1)
elif isinstance(signal, dict):
score = signal.get("score", signal.get("signal_score", 0))
else:
continue
total_score += score * w
total_weight += abs(w)
details.append({"strategy": strategy, "signal_score": round(score, 2), "weight": w, "contribution": round(score * w, 3)})
normalized = total_score / max(total_weight, 1e-10)
agreement = sum(1 for d in details if np.sign(d["signal_score"]) == np.sign(normalized)) / max(len(details), 1)
return {
"composite_score": round(normalized, 4),
"direction": "STRONG BUY" if normalized > 0.5 else "BUY" if normalized > 0.2 else "STRONG SELL" if normalized < -0.5 else "SELL" if normalized < -0.2 else "NEUTRAL",
"confidence": round(min(abs(normalized) * agreement * 1.5, 0.95), 3),
"agreement_pct": round(agreement * 100, 1),
"n_strategies": len(details),
"bullish_count": sum(1 for d in details if d["signal_score"] > 0),
"bearish_count": sum(1 for d in details if d["signal_score"] < 0),
"neutral_count": sum(1 for d in details if d["signal_score"] == 0),
"top_contributors": sorted(details, key=lambda d: abs(d["contribution"]), reverse=True)[:5],
"conflicts": [d["strategy"] for d in details if np.sign(d["signal_score"]) != np.sign(normalized) and d["signal_score"] != 0],
"trade_decision": AISignalAggregator._make_decision(normalized, agreement, len(details)),
}
@staticmethod
def _make_decision(score: float, agreement: float, n_strategies: int) -> str:
if n_strategies < 3:
return "INSUFFICIENT DATA — need at least 3 strategy signals"
if abs(score) > 0.4 and agreement > 0.7:
return f"HIGH CONVICTION {'BUY' if score > 0 else 'SELL'} — full position size"
if abs(score) > 0.25 and agreement > 0.5:
return f"MODERATE {'BUY' if score > 0 else 'SELL'} — reduced position size"
if abs(score) > 0.15:
return f"LOW CONVICTION {'BUY' if score > 0 else 'SELL'} — test position only"
return "NO TRADE — insufficient consensus across strategies"
@staticmethod
def train_meta_model(historical_signals: pd.DataFrame, outcomes: pd.Series) -> dict:
"""Train an ML meta-model to learn optimal signal weights from history."""
X = historical_signals.dropna()
y = (outcomes.reindex(X.index) > 0).astype(int)
common = X.index.intersection(y.index)
X, y = X.loc[common], y.loc[common]
# Time-series split
split = int(len(X) * 0.7)
X_train, X_test = X.iloc[:split], X.iloc[split:]
y_train, y_test = y.iloc[:split], y.iloc[split:]
model = CalibratedClassifierCV(GradientBoostingClassifier(n_estimators=100, max_depth=3), cv=3)
model.fit(X_train, y_train)
accuracy = model.score(X_test, y_test)
# Extract learned weights (feature importance)
base_model = model.calibrated_classifiers_[0].estimator
importances = dict(zip(X.columns, base_model.feature_importances_))
top = sorted(importances.items(), key=lambda x: x[1], reverse=True)
return {
"oos_accuracy": round(accuracy, 4),
"learned_weights": {k: round(v, 4) for k, v in top[:10]},
"most_predictive": top[0][0],
"least_predictive": top[-1][0],
"WARNING": "Meta-model overfits easily. Re-train monthly with walk-forward.",
}
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