Factor Research logo

Factor Research

OrganizationPopular
HKUDS
factor-research

Factor research framework with IC/IR analysis, quantile backtesting, and factor combination. Suitable for cross-sectional factor evaluation across multiple instruments.

Overview

PublisherHKUDS
RepositoryVibe-Trading
Skill namefactor-research
Stars
33.6K
Forks
5.5K
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by HKUDS on GitHub. Read the source before you install it.

Installation

Install the Factor Research AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/HKUDS/Vibe-Trading.git /tmp/Vibe-Trading
mkdir -p .claude/skills
cp -r /tmp/Vibe-Trading/agent/src/skills/factor-research .claude/skills/factor-research
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Factor Research in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Factor Research on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Factor Research is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Factor Research Framework

Purpose

Systematically evaluates the predictive power of single or multiple factors. Uses IC/IR statistical tests and quantile backtests to determine whether a factor has stock-selection power, and to guide factor screening and combination.

Applicable scenarios:

  • Single-factor validity testing (momentum, value, quality, volatility, and more)
  • Determining weights for multi-factor combination
  • Factor decay analysis (IC changes across different holding periods)
  • Comparing factor differences across industries and markets

Workflow

  1. Calculate factor values: compute factor exposures for each instrument on the cross-section, and output a factor CSV (index=date, columns=codes)
  2. Calculate returns: compute each instrument's forward N-day return, and output a return CSV (same structure)
  3. Call the factor_analysis tool: pass in the factor CSV, return CSV, and output directory
  4. Interpret the results: judge factor validity based on IC/IR criteria and quantile backtest results
  5. Factor screening / combination: keep effective factors and combine them with equal weights or IC-based weights

Key point: the rows (dates) and columns (instrument codes) of the factor CSV and return CSV must align exactly. Returns must be forward returns after the factor-observation date (to avoid look-ahead bias).

factor_analysis Tool Parameters

ParameterTypeRequiredDefaultDescription
factor_csvstringYes-Path to the factor-value CSV
return_csvstringYes-Path to the return CSV
output_dirstringYes-Output directory for results
n_groupsintegerNo5Number of quantile groups

Output Files

FileContents
ic_series.csvDaily IC series
ic_summary.jsonIC mean, IC standard deviation, IR, proportion of IC > 0
group_equity.csvCumulative equity curves for each quantile group

IC/IR Interpretation Standards

MetricThresholdInterpretation
IC mean> 0.03Factor has basic predictive power
IC mean> 0.05Factor has strong predictive power
IC mean> 0.10Unusually high; check for look-ahead bias
IR (IC mean / IC std)> 0.5Factor is stably effective
IR> 1.0Extremely strong, very rare
Proportion of IC > 0> 55%Factor direction is stable
Proportion of IC > 0< 50%Factor direction is unstable and unusable

Note: negative IC can also be useful (reverse factors). Judge by absolute value, and reverse the signal direction in actual use.

Quantile Backtest Interpretation

Quantile backtesting sorts instruments into N groups by factor value from low to high (default 5 groups), with equal-weight holding inside each group.

Criteria:

  • Monotonicity: the final net values from Group_1 to Group_N should show a monotonic rising (or falling) pattern. Better monotonicity means stronger factor discrimination
  • Long-short spread: the net-value difference between the highest and lowest group (long_short_spread). A larger spread means stronger selection power
  • Nonlinearity: if only the top and bottom groups differ materially while the middle groups are similar, the factor may only be effective in the tails
  • Stability: group equity curves should be smooth; sharp swings indicate an unstable factor

Warning signs:

  • No meaningful difference across group equity curves → the factor is ineffective
  • Non-monotonic pattern (such as V-shape or inverted V-shape) → the factor may have a nonlinear relationship and requires further analysis
  • One group's net value falls persistently → the factor may be usable in reverse

Factor Combination Methods

When multiple single factors pass validity tests, they should be combined into a composite factor:

Equal-Weight Combination

The simplest method: standardize each factor and sum them with equal weights. Suitable when the factor count is small and IC differences are minor.

Composite factor = Z(factor1) + Z(factor2) + ... + Z(factorN)
where Z() is cross-sectional Z-score standardization

IC-Weighted Combination

Assign weights according to historical IC mean. Factors with higher IC receive larger weights.

weight_i = |IC_mean_i| / sum(|IC_mean_j|)
Composite factor = sum(weight_i * Z(factor_i))

Orthogonalized Combination

First orthogonalize the factors with the Schmidt process to remove collinearity, then combine them with equal weights. Suitable when factors are highly correlated with one another.

1. Sort factors by IC from high to low
2. Keep the first factor unchanged
3. Regress each later factor on all previous factors and use the residual as the orthogonalized factor
4. Combine the orthogonalized factors with equal weights

Common Pitfalls

Look-Ahead Bias

  • Factor values must be computed using data from day T and earlier, while returns must use data from T+1 to T+N
  • Wrong example: calculate the factor with day T closing price and correlate it with day T return → artificially inflated IC
  • Correct approach: factor value at day T, return defined as the move from the T close to the T+1 close and beyond

Skewed Factor Distributions

  • Some factors (such as market cap and turnover) have heavily right-skewed distributions
  • Computing IC directly from raw values makes the result dominated by outliers
  • Solution: apply cross-sectional rank or Z-score standardization before computing IC

Industry Neutralization

  • Factor values can be highly similar within the same industry, causing stock selection to cluster in a few sectors
  • Solution: perform Z-score standardization within each industry (industry neutralization) to remove industry effects
  • For China A-shares, Shenwan Level-1 industries can be used

Insufficient Sample Size

  • Each cross-section should contain at least 5 valid instruments to compute meaningful IC
  • Quantile backtests require at least n_groups instruments
  • When the universe is too small, IC is noisy and IR becomes unreliable

Factor Crowding

  • Classic factors (momentum, value) may see diminished excess returns after becoming widely used
  • Regularly inspect the time-series evolution of factor IC to see whether decay is occurring
  • Consider factor innovation or factor timing

Survivorship Bias

  • Backtesting only on stocks that still survive today will overestimate factor performance
  • Use full-sample data including delisted stocks

Dependencies

bash
pip install pandas numpy scipy

Calling Zoo Factors

Rather than recompute factors from raw OHLCV every research iteration, prefer reusing the 450+ pre-built alphas in the Alpha Zoo registry. Each alpha is metadata-validated (AlphaMeta schema with theme, universe, columns_required, decay_horizon, min_warmup_bars), shape-checked against panel["close"], and rejected if it emits +/- inf or >95% NaN — so the factor CSV you feed to factor_analysis is already sanity-checked.

python
from src.factors.registry import Registry

registry = Registry()
ids = registry.list(theme="momentum", universe="equity_cn")  # filter the catalogue
factor_panel = registry.compute("alpha101_001", panel)        # wide DataFrame, same shape as panel["close"]
factor_panel.to_csv("factor_alpha101_001.csv")                # ready for factor_analysis tool

For combining several validated alphas into one composite signal, see the multi-factor skill's ZooSignalEngine (it z-scores, weights, and ranks alphas for you, with per-alpha skip isolation). For browsing the catalogue and inspecting individual __alpha_meta__ records, see the alpha-zoo skill.

Artifact Placement

When factor_analysis runs inside a backtest or swarm run, set output_dir to <run_dir>/artifacts/factor/<factor_name>/ so the Run Detail Factor tab can render the results. Use one subdirectory per factor (for example artifacts/factor/momentum_20d/), and keep the three standard output files (ic_series.csv, ic_summary.json, group_equity.csv) together inside it. Artifacts written elsewhere under artifacts/ are still discovered by the recursive scan, but the canonical layout keeps runs comparable.

Frequently asked questions

What does the Factor Research AI skill do?

Factor research framework with IC/IR analysis, quantile backtesting, and factor combination. Suitable for cross-sectional factor evaluation across multiple instruments.

Why use Factor Research on TypingMind?

Because you install it once and use it with any model. Factor Research is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Factor Research in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/HKUDS/Vibe-Trading/tree/main/agent/src/skills/factor-research. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Factor Research?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Factor Research?

As many as you like. As long as a model supports skills, you can use Factor Research with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Factor Research AI skill free?

Yes. It is published on GitHub by HKUDS under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇