ai-ide-strategy-writing

Generates and executes Qlib quantitative trading strategies in Docker containers via REST APIs.

1.5k|337|Updated Apr 15, 2026
One-click install
npx skills add https://github.com/qusong0627/QuantMind --skill ai-ide-strategy-writing-qusong0627
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ai-ide-strategy-writing
Source: https://github.com/qusong0627/QuantMind/tree/main/skills/ai-ide-strategy-writing
Command: npx skills add https://github.com/qusong0627/QuantMind --skill ai-ide-strategy-writing-qusong0627

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing and running quantitative trading strategies requires deep knowledge of the Qlib framework, correct stock code formats, backtest engine configuration, and containerized execution environments. This Skill lets an AI assistant generate valid Qlib strategy code from natural language, execute it in an isolated Docker container, stream backtest results, and persist strategies to the cloud. ## Core Features & Use Cases - AI Strategy Generation: Produces module-type strategies with STRATEGY_CONFIG or get_strategy_config() compatible with the backtest center, supporting 11 strategy classes such as TopK, weight-based, long-short, stop-loss, and sector rotation. - Containerized Execution & Streaming Logs: Starts strategy runs or backtests via /api/v1/ai-ide/execute endpoints, monitors SSE log streams for results like annual return and Sharpe ratio, and supports stop and syntax-check operations. - Cloud Strategy Persistence: Saves generated strategies with parameters and tags through the /api/v1/strategies API for later reuse and iteration. - Use Case: A user asks the AI to "write a low-valuation strategy selecting stocks with PE under 15 and ROE above 10, then backtest it on the CN market" — the Skill generates the config, saves it, runs the backtest with the default model, and streams the results. ## Quick Start Ask the AI to write a Qlib TopK strategy for the A-share market with your stock selection conditions, save it to the cloud, run the backtest, and show the annual return and Sharpe ratio.

Frequently Asked Questions about ai-ide-strategy-writing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate and run a Qlib trading strategy with AI?

Describe your selection conditions in natural language, and the Skill generates a STRATEGY_CONFIG module, saves it via the /api/v1/strategies endpoint, then starts execution through /api/v1/ai-ide/execute/start with a model_id and qlib_provider_uri. Results stream back over the SSE logs endpoint.

What strategy classes are available for Qlib backtests?

Eleven classes are supported, including RedisTopkStrategy for equal-weight Top-K selection, RedisWeightStrategy for score weighting, RedisLongShortTopkStrategy for long-short portfolios, plus stop-loss, momentum, sector rotation, and risk-guard variants defined in extended_strategies.py and recording_strategy.py.

Why does my Qlib backtest return empty universe data?

The most common cause is mixing stock code formats. Strategy Lab SDK uses prefix format like SH600036, while Qlib module strategies and QuantDB parquet files use suffix format like 600036.SH. Use StockCodeUtil.to_suffix or to_prefix to convert explicitly.

Can I run backtests on markets other than A-shares?

Yes. Pass the qlib_provider_uri and qlib_region parameters when starting execution. Supported regions include cn, us, hk, crypto, and futures, each with its own Qlib data directory, and you can set a custom benchmark index.

Why does my module-type strategy fail to execute?

Module-type strategies must define either a STRATEGY_CONFIG dictionary or a get_strategy_config() function containing the strategy class and kwargs such as signal, topk, n_drop, and rebalance_days. Missing these causes the executor to reject the code.

What happens if the backtest model has no prediction file?

Single models require an existing pred.pkl or pred.parquet generated by a prior inference run. Ensemble models with ensemble_config.json automatically fuse child model predictions into a pred.pkl, so no manual inference step is needed.