Skip to content
Lucrum Quant Loop

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.

5 stepsdescription to listing
S/A/B/C/Dfive-tier rating
vnpygenerated code stack

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.

Lucrum Strategy Loop
graph TB
  NL[自然语言] --> GEN[AI 策略生成]
  GEN --> CODE[vnpy 代码]
  CODE --> BT[历史数据回测]
  BT --> SCORE{评分}
  SCORE -->|未达 A| OPT[AI 优化建议]
  OPT --> BT
  SCORE -->|达 A 级| MKT[策略市场上架]

Full Workflow ​

  1. 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%.

  2. AI generates vnpy code

    python
    from 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)
  3. 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 (收益良好,风控合格)
  4. AI optimization — Lucrum offers improvement suggestions:

    The current RSI filter threshold (70) is fairly loose — the backtest had 8 false breakouts. Suggestions:

    1. Tighten the RSI threshold to 65
    2. Add a 5-day volume moving average filter
    3. 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 (收益优秀,风控良好)
  5. Strategy marketplace listing — open the strategy detail page → List button → fill in pricing:

    FieldExample
    Strategy nameMA_RSI_A股趋势 v2
    Revenue splitAuthor 70% / Platform 30%
    Trial period7 days
    Suggested subscription price99 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 ​

Sharpe RatioSharpe RatioExcess return earned per unit of risk taken. Above 1.0 is good; above 2.0 is excellent.

Excess return per unit of risk.

Max DrawdownMax DrawdownThe maximum percentage drop from a historical peak to a subsequent trough. Below 20% is acceptable; below 10% is excellent.

The decline from the historical peak to the lowest trough.

CtaTemplateCtaTemplatevnpy's base strategy template, which defines standard lifecycle hooks such as on_bar, on_tick, and on_trade.

vnpy's strategy base class.

Next Steps ​

Next steps

Powered by Lurus Technologies