The Complete Lucrum Strategy Flow
Goal: take the "dual moving average + RSI filter" idea all the way from a natural-language description to a strategy marketplace listing.
Architecture
From natural language to listing, the rating is the routing gate: a rating ≥ A goes straight to listing, while anything below A runs through AI optimization and a re-backtest.
graph TB
NL[自然语言] --> GEN[AI 策略生成]
GEN --> CODE[vnpy 代码]
CODE --> BT[历史数据回测]
BT --> SCORE{评分}
SCORE -->|未达 A| OPT[AI 优化建议]
OPT --> BT
SCORE -->|达 A 级| MKT[策略市场上架]Full Workflow
Natural-language description — go to lucrum.lurus.cn → New Strategy → paste the description:
Dual moving average crossover strategy: buy when the 5-day MA crosses above the 20-day MA, and sell when it crosses below. Add an RSI(14) filter — do not buy when RSI > 70. Stop loss at 5%, take profit at 15%.
AI generates vnpy code
pythonfrom vnpy.app.cta_strategy import CtaTemplate import talib class MA_RSI_Strategy(CtaTemplate): fast_window = 5 slow_window = 20 rsi_window = 14 rsi_upper = 70 stop_loss_pct = 0.05 take_profit_pct = 0.15 def on_bar(self, bar): self.am.update_bar(bar) if not self.am.inited: return fast_ma = talib.SMA(self.am.close_array, self.fast_window)[-1] slow_ma = talib.SMA(self.am.close_array, self.slow_window)[-1] rsi = talib.RSI(self.am.close_array, self.rsi_window)[-1] if self.pos == 0 and fast_ma > slow_ma and rsi < self.rsi_upper: self.buy(bar.close_price, 1) elif self.pos > 0 and (fast_ma < slow_ma): self.sell(bar.close_price, self.pos)Backtest — pick a backtest window (defaults to the last 2 years) and click Run:
回测期间: 2024-01-01 ~ 2025-12-31 夏普比率: 1.15 最大回撤: 11.3% 胜率: 56% 年化收益: 18.4% 评级: B (收益良好,风控合格)AI optimization — Lucrum offers improvement suggestions:
The current RSI filter threshold (70) is fairly loose — the backtest had 8 false breakouts. Suggestions:
- Tighten the RSI threshold to 65
- Add a 5-day volume moving average filter
- Widen the stop loss from 5% to 7% (to avoid getting shaken out by noise)
Projected Sharpe → 1.42, drawdown → 9.2%
Accept the suggestions and re-run the backtest:
夏普比率: 1.44 最大回撤: 9.1% 胜率: 62% 评级: A (收益优秀,风控良好)Strategy marketplace listing — open the strategy detail page → List button → fill in pricing:
Field Example Strategy name MA_RSI_A股趋势 v2 Revenue split Author 70% / Platform 30% Trial period 7 days Suggested subscription price 99 Lubei/month Once it passes compliance review, it can be listed on the strategy marketplace.
The B → A jump comes from the optimization round
The first backtest rated B (Sharpe 1.15). After accepting the AI optimization suggestions and re-running the backtest, the Sharpe rose to 1.44 and the drawdown dropped to 9.1%, reaching A grade — and only then passing the listing gate.
Key Concepts
Excess return per unit of risk.
The decline from the historical peak to the lowest trough.
vnpy's strategy base class.