Agent skill

Signal Classification

by agiprolabs in agiprolabs/claude-trading-skills

ML trading signal classifiers using XGBoost and LightGBM with walk-forward validation, SHAP feature importance, and threshold optimization

MITAuto-check passedData & Analytics

Install Signal Classification

skills CLI
$ npx skills add agiprolabs/claude-trading-skills --skill signal-classification -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install agiprolabs/claude-trading-skills signal-classification --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/agiprolabs/claude-trading-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/signal-classification .claude/skills/signal-classification && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
signal-classification
GitHub stars
410
Token cost
~2.8k tokens
SKILL.md length
911 words
Files
5 (incl. scripts, references)
Skills in repo
68
Repo updated
First seen
Licence
MIT

At a glance

ML trading signal classifiers using XGBoost and LightGBM with walk-forward validation, SHAP feature importance, and threshold optimization

  • Works in 5 steps: Train on past N bars → Skip a gap (embargo) equal to the… → Predict on next M bars → …
  • Tasks that involve Machine learning
  • SKILL.md covers Why Tree-Based Models Dominate…, Classification Types, Walk-Forward Validation and Model Training Pipeline, plus 6 more sections
  • Runs Python scripts from its folder; calls uv

What it does

Signal Classification is an agent skill from agiprolabs/claude-trading-skills. ML trading signal classifiers using XGBoost and LightGBM with walk-forward validation, SHAP feature importance, and threshold optimization

Its SKILL.md is about 2.8k tokens, which your agent loads only when the skill is triggered. The skill folder holds 6 other files, including scripts and reference files (for example `references/model_guide.md`, `references/validation_methods.md` and `scripts/train_classifier.py`).

It sits in Data & Analytics, covering Machine learning and Trading and backtesting. The repository describes itself as: 68 trading, DeFi, and quantitative finance Agent Skills. Works with Claude Code, Cursor, Codex, Gemini CLI, and 30+ other tools. The licence is MIT.

When your agent uses it

  • Tasks that involve Machine learning
  • Tasks that involve Trading and backtesting

Example prompts

  • “/signal-classification”

Requirements

  • Python 3

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  1. Train on past N bars
  2. Skip a gap (embargo) equal to the forward return horizon
  3. Predict on next M bars
  4. Record out-of-sample predictions
  5. Slide forward and repeat

What it can do on your machine

Read from SKILL.md and the folder at commit 981e1d7. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 2 files in scripts/ (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • uv

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use uv, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Signal Classification loads about 2.8k tokens when it runs, and up to ~6.6k if it reads all its reference files. Until then it costs about 40 tokens; SKILL.md has 911 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~40
When it runs · the whole SKILL.md, loaded when a task matches
~2.8k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~6.6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from agiprolabs/claude-trading-skills at commit 981e1d7, republished under its MIT licence (© agiprolabs). 911 words, ~2,849 tokens.

Download SKILL.mdSave it as .claude/skills/signal-classification/SKILL.md (or your agent's skills folder). This skill also uses 4 other files; get the full folder from GitHub.
name
signal-classification
description
ML trading signal classifiers using XGBoost and LightGBM with walk-forward validation, SHAP feature importance, and threshold optimization

Signal Classification

Predict whether an asset's price will move up or down over a forward horizon using supervised machine learning classifiers. This skill covers the full pipeline: label creation, model training, walk-forward validation, feature importance analysis, and threshold optimization for trading applications.

Why Tree-Based Models Dominate Trading ML

XGBoost and LightGBM are the workhorses of quantitative trading ML for good reason:

  • Non-linear relationships: Financial features interact in complex, non-linear ways that trees capture naturally
  • Robust to feature scale: No need to normalize or standardize inputs — trees split on rank order
  • Built-in feature importance: Understand which features drive predictions without separate analysis
  • Fast training and inference: Train on thousands of samples in seconds, predict in microseconds
  • Handle missing values: Native support for NaN without imputation hacks
  • Regularization built in: max_depth, min_child_weight, subsample all prevent overfitting

Linear models and deep learning have their place, but for tabular trading features with fewer than 100k samples, gradient-boosted trees consistently outperform alternatives.

Classification Types

Binary Classification

The simplest and most common setup. Predict whether forward returns exceed a threshold:

  • Up signal: forward return > +1%
  • Down signal: forward return < -1%
  • Neutral (excluded): -1% to +1% — drop these from training to create cleaner labels
python
import numpy as np

def create_binary_labels(
    prices: np.ndarray, horizon: int = 24, threshold: float = 0.01
) -> np.ndarray:
    """Create binary labels from forward returns.

    Args:
        prices: Array of prices.
        horizon: Forward return lookback in bars.
        threshold: Minimum return magnitude for a label.

    Returns:
        Array of labels: 1 (up), 0 (down), NaN (neutral).
    """
    fwd_returns = np.roll(prices, -horizon) / prices - 1
    fwd_returns[-horizon:] = np.nan
    labels = np.where(fwd_returns > threshold, 1,
             np.where(fwd_returns < -threshold, 0, np.nan))
    return labels
Multi-Class Classification

Three classes for finer signal granularity:

ClassConditionTypical threshold
Strong Upfwd_return > +2%High confidence long
Mild Up+0.5% to +2%Moderate confidence
Downfwd_return < -0.5%Avoid / short

Multi-class reduces per-class sample size. Use only with large datasets (1000+ samples per class).

Probability Calibration

Raw model probabilities from XGBoost/LightGBM are not well-calibrated. A predicted 0.7 probability does not mean 70% chance of being correct. Use calibration to fix this:

python
from sklearn.calibration import CalibratedClassifierCV

calibrated = CalibratedClassifierCV(base_model, cv=5, method="isotonic")
calibrated.fit(X_train, y_train)
probs = calibrated.predict_proba(X_test)[:, 1]

Isotonic calibration works better than Platt scaling for tree models.

Walk-Forward Validation

This is the single most important concept in trading ML. Standard cross-validation randomly shuffles data, which creates lookahead bias. Walk-forward validation respects time ordering.

How It Works
Window 1: [===TRAIN===][GAP][=TEST=]
Window 2:    [===TRAIN===][GAP][=TEST=]
Window 3:       [===TRAIN===][GAP][=TEST=]
Window 4:          [===TRAIN===][GAP][=TEST=]

Each window:

  1. Train on past N bars
  2. Skip a gap (embargo) equal to the forward return horizon
  3. Predict on next M bars
  4. Record out-of-sample predictions
  5. Slide forward and repeat
Typical Parameters
ParameterValueRationale
Train window30 days (720 hourly bars)Enough data to learn, recent enough to be relevant
Test window7 days (168 hourly bars)Enough predictions for statistical significance
Step size1 day (24 bars)Overlap test windows for more data points
Gap (embargo)Same as forward horizonPrevents label leakage
Walk-Forward Implementation
python
from typing import Iterator

def walk_forward_splits(
    n_samples: int,
    train_size: int = 720,
    test_size: int = 168,
    step_size: int = 24,
    gap: int = 24,
) -> Iterator[tuple[np.ndarray, np.ndarray]]:
    """Generate walk-forward train/test index splits.

    Args:
        n_samples: Total number of samples.
        train_size: Number of training samples per window.
        test_size: Number of test samples per window.
        step_size: Step between successive windows.
        gap: Gap between train end and test start.

    Yields:
        Tuples of (train_indices, test_indices).
    """
    start = 0
    while start + train_size + gap + test_size <= n_samples:
        train_idx = np.arange(start, start + train_size)
        test_start = start + train_size + gap
        test_idx = np.arange(test_start, test_start + test_size)
        yield train_idx, test_idx
        start += step_size

See references/validation_methods.md for purged CV, CPCV, and evaluation metrics.

Model Training Pipeline

Full Pipeline Overview
  1. Feature engineering — compute technical indicators, on-chain metrics, volume features (see feature-engineering skill)
  2. Label creation — forward returns with threshold, drop neutral zone
  3. Walk-forward split — time-ordered train/test windows with gap
  4. Train model — XGBoost or LightGBM on each training window
  5. Predict on test — generate out-of-sample probability predictions
  6. Aggregate predictions — concatenate all out-of-sample results
  7. Evaluate — accuracy, precision, recall, F1, AUC, profit factor
Quick Training Example
python
from xgboost import XGBClassifier

model = XGBClassifier(
    n_estimators=200,
    max_depth=4,
    learning_rate=0.05,
    subsample=0.8,
    colsample_bytree=0.8,
    eval_metric="logloss",
    use_label_encoder=False,
    random_state=42,
)

model.fit(
    X_train, y_train,
    eval_set=[(X_val, y_val)],
    verbose=False,
)

probabilities = model.predict_proba(X_test)[:, 1]

See references/model_guide.md for parameter recommendations and tuning.

SHAP Feature Importance

SHAP (SHapley Additive exPlanations) provides the gold standard for understanding model predictions.

Global Feature Importance

Which features matter most across all predictions:

python
import shap

explainer = shap.TreeExplainer(model)
shap_values = explainer.shap_values(X_test)

# Summary plot (top 15 features)
shap.summary_plot(shap_values, X_test, max_display=15)
Local Explanations

Why a specific prediction was made:

python
# Explain a single prediction
shap.force_plot(explainer.expected_value, shap_values[0], X_test.iloc[0])
Temporal Feature Importance

Track how feature importance drifts over walk-forward windows. If a feature's importance drops significantly, the market regime may have shifted.

Show full SKILL.md (366 more words)Show less

Threshold Optimization

The default 0.5 probability threshold is almost never optimal for trading.

Why Not 0.5?
  • Class imbalance: if 60% of labels are "up", a 0.5 threshold is too aggressive
  • Trading costs: marginal signals (0.51 probability) rarely cover transaction costs
  • Asymmetric payoffs: precision matters more than recall for trading
Optimize for Profit Factor
python
def optimize_threshold(
    probabilities: np.ndarray,
    returns: np.ndarray,
    thresholds: np.ndarray | None = None,
) -> tuple[float, float]:
    """Find threshold that maximizes profit factor.

    Args:
        probabilities: Model predicted probabilities.
        returns: Actual forward returns.
        thresholds: Thresholds to search over.

    Returns:
        Tuple of (best_threshold, best_profit_factor).
    """
    if thresholds is None:
        thresholds = np.arange(0.50, 0.85, 0.01)
    best_threshold, best_pf = 0.5, 0.0
    for t in thresholds:
        signals = probabilities >= t
        if signals.sum() < 10:
            continue
        signal_returns = returns[signals]
        wins = signal_returns[signal_returns > 0].sum()
        losses = abs(signal_returns[signal_returns < 0].sum())
        pf = wins / losses if losses > 0 else 0.0
        if pf > best_pf:
            best_pf = pf
            best_threshold = t
    return best_threshold, best_pf

Typical finding: optimal threshold is 0.60-0.75 for crypto trading signals.

Crypto-Specific Considerations

Short Training Windows

Crypto market regimes change fast. A model trained on 6 months of data may perform worse than one trained on 30 days. Use shorter training windows and retrain frequently.

Class Imbalance

Most time periods are "flat" (returns within the neutral zone). Strategies to handle this:

  • Drop neutral zone: only train on clear up/down labels
  • Undersample majority class: scale_pos_weight in XGBoost
  • SMOTE: synthetic minority oversampling (use cautiously — can introduce lookahead)
  • Adjust threshold: raise the probability threshold to compensate
Transaction Costs

A model with 55% accuracy sounds good, but after 0.5% round-trip costs (slippage + fees), many signals become unprofitable. Always evaluate signals net of costs:

python
net_return = gross_return - 0.005  # 50 bps round-trip
Feature Decay

Features lose predictive power over time as more participants discover and trade on them. Monitor rolling performance and retrain when metrics degrade.

Integration with Other Skills

SkillIntegration
feature-engineeringCompute input features for the classifier
vectorbtBacktest trading strategies from ML signals
regime-detectionTrain separate models per regime, or use regime as a feature
position-sizingSize positions based on classifier confidence
risk-managementApply portfolio-level risk limits to ML-generated signals

Files

References
  • references/model_guide.md — XGBoost and LightGBM parameter guide, tuning, and ensembling
  • references/validation_methods.md — Walk-forward, purged CV, CPCV, and evaluation metrics
Scripts
  • scripts/train_classifier.py — Train a signal classifier with walk-forward validation and feature importance
  • scripts/walk_forward_backtest.py — Backtest ML signals vs buy-and-hold with walk-forward validation

Dependencies

bash
# Core (required)
uv pip install pandas numpy scikit-learn

# Optional (recommended)
uv pip install xgboost lightgbm shap

Key Takeaways

  1. Walk-forward validation is non-negotiable — random CV will give you wildly inflated results
  2. Optimize threshold for profit factor, not accuracy — a high-precision, low-recall model beats a high-accuracy one
  3. Short training windows for crypto — 30 days beats 6 months in most regimes
  4. Monitor feature decay — retrain when rolling metrics drop below baseline
  5. Always evaluate net of costs — a 55% accurate model may be unprofitable after fees
  6. SHAP over raw feature importance — SHAP gives consistent, theoretically grounded explanations

© agiprolabs, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 4 other files (scripts, references) in skills/signal-classification of agiprolabs/claude-trading-skills.

  • SKILL.md
  • references/model_guide.md
  • references/validation_methods.md
  • scripts/train_classifier.py
  • scripts/walk_forward_backtest.py

Open the folder on GitHubat commit 981e1d7

Compare with similar skills

Signal Classification next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Signal Classification compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Signal Classification this skillagiprolabs/claude-trading-skills410—~2.8kAutomated safety check: PassMIT
QuantMind Training Config Generatorqusong0627/QuantMind1.7k—~1.5kAutomated safety check: PassAGPL-3.0
Longbridge Quanthelsome/folio2701 repos~1.6kAutomated safety check: PassMIT
Machine Learning Trading StrategyHKUDS/Vibe-Trading35k—~3.2kAutomated safety check: PassMIT
Scikit LearnzLanqing/codex-claude-academic-skills4.7k16 repos~3.9kAutomated safety check: PassBSD-3-Clause
Question2reportrefraction-ray/xalpha2.7k—~3.2kAutomated safety check: PassMIT

Similar skills

  • Turns a plain-language model training request into a validated QuantMind training config file that can be imported from the Model Training page.

    1.7k GitHub stars~1.5k tokensUpdated today
    Data & AnalyticsAuto-check passed
  • Longbridge Quant

    helsome/folio

    Quantitative strategy frameworks: pairs trading/cointegration, volatility regime strategies, seasonality/calendar effects, multi-factor models (IC/IR), factor research and screening, correlation…

    270 GitHub starsUsed in 1 repo~1.6k tokens
    Data & AnalyticsAuto-check passed
  • Trains scikit-learn models with walk-forward validation on features from OHLCV data to predict return direction and turn the predictions into trading signals.

    35k GitHub stars~3.2k tokensUpdated yesterday
    Data & AnalyticsAuto-check passed
  • Scikit Learn

    zLanqing/codex-claude-academic-skills

    Machine learning in Python with scikit-learn. An agent skill from zLanqing/codex-claude-academic-skills.

    4.7k GitHub starsUsed in 16 repos~3.9k tokens
    Data & AnalyticsAuto-check passed
  • Question2report

    refraction-ray/xalpha

    Turn a natural-language financial question into a polished, self-contained HTML report.

    2.7k GitHub stars~3.2k tokensUpdated 2 mo ago
    Data & AnalyticsAuto-check passed
  • Agentic Kaggle Workflow

    FrankS-IntelLab/agentic-kaggle-skill

    Takes a Kaggle competition from rules and validation design through baselines, ensembling and notebook architecture to a scored submission.

    188 GitHub stars~4k tokensUpdated 3 mo ago
    Data & AnalyticsAuto-check passed

More from agiprolabs/claude-trading-skills

All 68 skills in this repo
  • Backtrader

    agiprolabs/claude-trading-skills

    Event-driven backtesting with bar-by-bar execution, complex order types, multiple analyzers, and custom indicators

    410 GitHub stars~2.4k tokensUpdated 1 mo ago
    Auto-check passed
  • Birdeye API

    agiprolabs/claude-trading-skills

    Solana token market data via Birdeye — prices, OHLCV, trades, token metadata, security checks, and trader activity

    410 GitHub stars~1.8k tokensUpdated 1 mo ago
    Auto-check passed
  • Coingecko API

    agiprolabs/claude-trading-skills

    Broad crypto market data from CoinGecko covering 13,000+ tokens.

    410 GitHub stars~1.6k tokensUpdated 1 mo ago
    Auto-check passed
  • Cointegration Analysis

    agiprolabs/claude-trading-skills

    Cointegration testing for pairs trading using Engle-Granger, Johansen, and rolling stability analysis

    410 GitHub stars~2.1k tokensUpdated 1 mo ago
    Auto-check passed
  • Copy Trading

    agiprolabs/claude-trading-skills

    Wallet evaluation, monitoring, and copy-trade strategy design for Solana DEX trading

    410 GitHub stars~2.4k tokensUpdated 1 mo ago
    Auto-check passed
  • Correlation Analysis

    agiprolabs/claude-trading-skills

    Cross-asset correlation analysis including rolling correlation, hierarchical clustering, tail dependence, and regime-dependent correlation

    410 GitHub stars~2.4k tokensUpdated 1 mo ago
    Auto-check passed

Questions about Signal Classification

What does Signal Classification do?

ML trading signal classifiers using XGBoost and LightGBM with walk-forward validation, SHAP feature importance, and threshold optimization. Signal Classification is an agent skill from agiprolabs/claude-trading-skills.

When should I use Signal Classification?

Signal Classification fits situations like: tasks that involve Machine learning; tasks that involve Trading and backtesting.

How do I install Signal Classification in Claude Code?

Run `npx skills add agiprolabs/claude-trading-skills --skill signal-classification -a claude-code`. Or copy the skill folder (skills/signal-classification in agiprolabs/claude-trading-skills) into .claude/skills/signal-classification in your project. Claude Code loads it when a task matches its description.

How do I install Signal Classification in Codex?

Run `npx skills add agiprolabs/claude-trading-skills --skill signal-classification -a codex`. Or copy the skill folder (skills/signal-classification in agiprolabs/claude-trading-skills) into .agents/skills/signal-classification in your project. Codex loads it when a task matches its description.

Can I use Signal Classification in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add agiprolabs/claude-trading-skills --skill signal-classification -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/signal-classification, .gemini/skills/signal-classification, .github/skills/signal-classification and .opencode/skills/signal-classification in your project.

What does Signal Classification need to run?

Going by SKILL.md and its folder, Signal Classification needs Python for the scripts in its folder and the command-line tools its instructions call (uv). Our summary lists: Python 3.

Does Signal Classification access the network?

SKILL.md contains no URLs. Its commands use uv, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Signal Classification safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Signal Classification use?

Signal Classification is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Signal Classification use?

About 2.8k tokens (SKILL.md is roughly 11k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 3.8k tokens, read only when the agent opens those files.

What are the alternatives to Signal Classification?

Skills that share tags, products or a category with Signal Classification: QuantMind Training Config Generator (qusong0627/QuantMind, 1.7k stars), Longbridge Quant (helsome/folio, 270 stars), Machine Learning Trading Strategy (HKUDS/Vibe-Trading, 35k stars) and Scikit Learn (zLanqing/codex-claude-academic-skills, 4.7k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Signal Classification?

agiprolabs (a GitHub user) maintains it in agiprolabs/claude-trading-skills, which has 410 GitHub stars. The repository holds 68 skills in this directory. The repository was last updated on September 3, 2026.

Source: agiprolabs/claude-trading-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.