agent-instructions
Use when writing project instructions for a coding agent (CLAUDE.md, AGENTS.md, or equivalent). Covers what belongs in them, what does not, structure, and…
Use when applying statistical methods to financial data. Covers return distributions, stationarity, correlation versus causation, the multiple-testing problem, and the statistical traps specific to financial time series.
$ npx -y skills add nimadorostkar/Claude-Skills-collection --skill quantitative-analysis --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/quantitative-analysisContext preview
The summary Claude sees to decide when to auto-load this skill.
Use when applying statistical methods to financial data. Covers return distributions, stationarity, correlation versus causation, the multiple-testing problem, and the statistical traps specific to financial time series.
name: quantitative-analysis description: Use when applying statistical methods to financial data. Covers return distributions, stationarity, correlation versus causation, the multiple-testing problem, and the statistical traps specific to financial time series. metadata: category: finance version: 1.0.0 tags: [quant, statistics, time-series, significance, modeling]
Apply statistics to financial data without being fooled by it. Financial time series violate nearly every assumption of standard statistical methods, and the tools will produce confident, well-formatted, wrong answers without complaint.
1. **Look at the distribution before assuming one** — Financial returns are not normal. They have fat tails and skew, and every method that assumes normality will underestimate the probability of a large move — which is the only probability that matters for survival. 2. **Test for stationarity** — Regressing one non-stationary series on another produces a high R-squared and a significant t-statistic between two entirely unrelated things. This is spurious regression, and it is the most common error in financial statistics. 3. **Work in returns, not prices** — Prices are non-stationary by construction. Returns are approximately stationary. Almost every meaningful analysis operates on returns. 4. **Count the hypotheses you have tested** — If you tried a hundred signals and one has a p-value of 0.01, you have found exactly what pure chance predicts. A p-value not adjusted for the search is not evidence. 5. **Distinguish correlation from causation, and both from coincidence** — With enough series, something will correlate with anything. A mechanism stated in advance is what separates a finding from a coincidence. 6. **Validate out of sample** — On data that was not available when the hypothesis was formed. Everything else is description.
**Spurious regression — the error that produces the most confident wrong answers:**
import numpy as np, statsmodels.api as sm
# Two independent random walks. There is no relationship whatsoever.
np.random.seed(1)
a = np.cumsum(np.random.randn(500))
b = np.cumsum(np.random.randn(500))
model = sm.OLS(a, sm.add_constant(b)).fit()
print(f"R-squared: {model.rsquared:.3f} t-stat: {model.tvalues[1]:.2f}")
# R-squared: 0.681 t-stat: 32.71
#
# An R-squared of 0.68 and a t-statistic of 33 between two series with NO
# relationship at all. This is not a fluke of the seed; it happens most of the
# time with non-stationary series. Any conclusion drawn from this is fiction.
# The correct procedure: test for stationarity, and work in returns.
from statsmodels.tsa.stattools import adfuller
for name, series in [("a", a), ("b", b)]:
p = adfuller(series)[1]
print(f"{name}: ADF p={p:.3f} -> {'non-stationary' if p > 0.05 else 'stationary'}")
# a: ADF p=0.712 -> non-stationary
# b: ADF p=0.884 -> non-stationary
#
# Differencing to returns removes the spurious relationship entirely.
model_returns = sm.OLS(np.diff(a), sm.add_constant(np.diff(b))).fit()
print(f"R-squared: {model_returns.rsquared:.4f} t-stat: {model_returns.tvalues[1]:.2f}")
# R-squared: 0.0004 t-stat: -0.44 <- the truth: no relationship**Multiple testing — why most published anomalies are not real:**
def corrected_significance(p_values: list[float], n_tested: int) -> Report:
"""A p-value of 0.01 means nothing if you tested 100 hypotheses."""
best_p = min(p_values)
# Bonferroni: the family-wise error rate.
bonferroni = min(1.0, best_p * n_tested)
# The probability that the best of n random signals looks this good by chance.
prob_by_chance = 1 - (1 - best_p) ** n_tested
return Report(
raw_p=best_p,
bonferroni_p=bonferroni,
prob_at_least_one_by_chance=prob_by_chance,
verdict=(
"Not distinguishable from chance."
if bonferroni > 0.05
else "Survives correction. Now validate out of sample."
),
)A curated library of 137 production-grade skills for Claude and other AI coding agents. Every skill follows one structure, speaks with one voice, and earns its place by changing what the agent does.
Repo: nimadorostkar/Claude-Skills-collection
Use when writing project instructions for a coding agent (CLAUDE.md, AGENTS.md, or equivalent). Covers what belongs in them, what does not, structure, and…
Use when an agent needs state that survives a session or a context compaction. Covers what to persist, file-based memory, structuring notes for retrieval, and…
Use when automating agent behavior with lifecycle hooks. Covers hook events, deterministic enforcement of rules the model should not be trusted to remember,…
Use when packaging skills, commands, hooks, and MCP servers into a distributable plugin. Covers manifest structure, bundling, versioning, testing, and…
Use when writing a new skill for an AI agent. Covers scoping, description writing for reliable triggering, progressive disclosure, and the difference between a…
Use when reviewing or improving an existing agent skill. Covers triggering accuracy, content quality, redundancy with the base model, and measuring whether the…