JoinQuant Strategy Backtest Code Generator for Openclaw

A JoinQuant-focused Openclaw skill that generates ready-to-run quantitative strategy backtest code for multifactor stock selection and technical signal timing.

chenxyzcyxpp
v0.5.1
Aug 10, 2026
0
281
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install joinquant-strategy-backtest

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install joinquant-strategy-backtest using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is JoinQuant Strategy Backtest Code Generator?

The JoinQuant Strategy Backtest Code Generator provides a standardized six-stage Python framework for building and backtesting quantitative investment strategies on the JoinQuant platform. It supports both cross-sectional multifactor stock selection and time-series technical indicator timing strategies, producing code that can be copied directly into JoinQuant for testing.

The skill uses JoinQuant native APIs, including get_fundamentals, attribute_history, get_price, and get_index_stocks, without relying on the removed jqfactor dependency. Openclaw Skills users can define factors, benchmarks, rebalance periods, technical parameters, and portfolio sizing while retaining explicit factor cleaning, IC-direction weighting, order sequencing, and API compatibility safeguards.

JoinQuant Strategy Backtest Code Generator Use Cases

  • Generate a pure cross-sectional multifactor stock-picking strategy from index constituents.
  • Build valuation, quality, profitability, growth, liquidity, volatility, or momentum factor combinations.
  • Create technical timing strategies using EMA crossover buy and sell signals.
  • Convert a user-defined strategy idea into a complete JoinQuant backtest script.
  • Select factors by reviewing IC averages and quantile returns in the JoinQuant factor library.
  • Look up JoinQuant API usage, data tables, fields, order functions, scheduling functions, and security-code formats.
  • Produce a clean baseline strategy before explicitly adding stop-loss, ST filtering, industry neutralization, market-cap neutralization, or risk controls.
  • Troubleshoot common issues involving missing fundamentals, inverse valuation factors, get_price column names, commission settings, and historical-data performance.

How JoinQuant Strategy Backtest Code Generator Works

  1. Collect the user’s strategy requirements, including strategy type, securities or index universe, benchmark, holdings count, rebalance cycle, factors, and technical parameters.
  2. Select the appropriate template: cross-sectional multifactor selection or time-series technical timing.
  3. Build the standardized six-stage script: file header, initialize, optional before_trading_start, signal module, handle_data, and optional after_trading_end.
  4. For multifactor strategies, retrieve index constituents with get_index_stocks, query fundamental fields with get_fundamentals, and calculate market-data factors with attribute_history or batch get_price calls.
  5. Protect factor calculations with missing-value handling and zero-division safeguards, then apply MAD outlier clipping and Z-score standardization.
  6. Combine factors using IC direction: positive-IC factors receive positive weight, while negative-IC factors receive negative weight; the default combination is equal-weighted.
  7. Rank securities by the composite score and select the top N candidates.
  8. For timing strategies, calculate EMA values from historical prices and generate buy signals on golden crosses and sell signals on death crosses.
  9. Execute portfolio changes with order_target_value, selling unwanted positions before opening or resizing buy positions.
  10. Validate the generated code against the implementation checklist, including benchmark configuration, rebalance controls, API selection, signal direction, and JoinQuant compatibility.

JoinQuant Strategy Backtest Code Generator Setup

This skill is intended to run inside an AI coding-agent environment that supports Openclaw Skills. It does not require the jqfactor package; generated multifactor strategies use JoinQuant native data APIs instead.

  1. Install or register the skill in the agent’s skills directory according to your Openclaw Skills runtime.
  2. Provide the agent with the strategy type, benchmark, security universe or index pool, target holdings, rebalance period, selected factors, and any requested modules.
  3. Review factor IC statistics in the JoinQuant factor library when factor direction is not already known: https://www.joinquant.com/view/factorlib/list.
  4. Ask the agent to generate a standalone Python strategy file, then copy the output into the JoinQuant research or backtest platform.
  5. For local testing, install optional analysis dependencies such as NumPy, pandas, and TA-Lib as required by the generated strategy:
python -m pip install numpy pandas TA-Lib
  1. The JoinQuant platform generally provides talib and its proprietary strategy APIs; local installation is only needed when reproducing calculations outside JoinQuant.
  2. Run a backtest and verify transaction costs, slippage, minimum order units, data availability, and historical-date behavior before using results for research decisions.
  3. Before publishing the skill or generated artifacts, replace any IP addresses, passwords, tokens, or credentials with placeholders such as <YOUR_PLACEHOLDER>.

JoinQuant Strategy Backtest Code Generator Data Schema & Taxonomy

The skill produces a standalone JoinQuant-compatible Python strategy rather than a database or persistent storage schema.

Generated strategy structure

Section Contents
File header Strategy title, author information, and imports
initialize Benchmark, real-price option, global g.* parameters, holdings, and signal settings
before_trading_start Optional slippage and commission configuration
Signal module get_buy_list for multifactor selection, or buy/sell signal functions for technical timing
handle_data Rebalance or signal scheduling, sell-first execution, and target-value orders
after_trading_end Optional post-market logging or reporting

Multifactor data taxonomy

  • Universe data: index constituents from get_index_stocks.
  • Valuation data: valuation.code, market_cap, pe_ratio, pb_ratio, ps_ratio, and turnover_ratio.
  • Financial quality data: indicator.roe, roa, gross_profit_margin, net_profit_margin, and earnings or revenue growth fields.
  • Derived valuation factors: BP = 1 / pb_ratio, EP = 1 / pe_ratio, SP = 1 / ps_ratio, and PEG = pe_ratio / earnings_growth.
  • Market-data factors: volume, turnover proxies, volatility, and momentum derived from attribute_history or get_price.
  • Factor-processing metadata: missing-value status, MAD clipping, Z-score normalization, IC sign, composite score, rank, and selected Top N membership.
  • Portfolio state: benchmark, available cash, total portfolio value, positions, sellable amount, target capital per position, and rebalance day counter.

The implementation uses context.previous_date for historical factor dates to reduce look-ahead bias. When get_price(panel=False) is used for multiple securities, returned columns are security codes rather than field names, so consumers must access the correct code column or use attribute_history for unambiguous single-security series.

JoinQuant Strategy Backtest Code Generator Advanced Features

  • Native JoinQuant API generation without the jqfactor license dependency.
  • Two strategy modes: cross-sectional multifactor ranking and time-series EMA crossover timing.
  • IC-aware factor-sign handling, including inverse valuation factors such as BP, EP, and SP.
  • Equal-weight composite scoring with configurable factor lists and extensible weights.
  • MAD-based outlier removal and Z-score standardization for robust cross-sectional processing.
  • Optional factor discovery workflow using JoinQuant factor-library IC averages, quantile returns, and IC win rates.
  • Rebalance-period gating for periodic portfolio turnover rather than unnecessary daily trading.
  • Sell-before-buy execution using order_target_value for target allocation management.
  • Historical-data safeguards using context.previous_date, dropna, and zero-value replacement before reciprocal calculations.
  • Performance guidance for replacing repeated per-security attribute_history calls with batch get_price retrieval.
  • Technical implementation checklist covering initialization, scheduling, order APIs, factor direction, data access, and optional lifecycle hooks.
  • Extensible architecture for user-requested stop-loss rules, ST or new-stock filters, industry neutralization, market-cap neutralization, and risk controls.
  • JoinQuant API quick reference covering scheduling, order management, fundamentals, historical prices, portfolio context, and security-code formats.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*