SuperAPI AI Directory

shadow-account

Data & analytics

View repository

Updated 10-15 22:13

About this skill

Shadow Account — Shadow Account

When to trigger

Load this skill when the user says "distill my strategy" / "train the shadow" / "backtest my playbook" / "how much more could I earn" / "my profit pattern".

Prerequisite: the user has already uploaded trade confirmations and analyze_trade_journal has already run. If not, run the Phase 4a tool first.

Workflow (four steps)

  1. extract_shadow_strategy(journal_path=...)
    • Return shadow_id + 3-5 plain-language rules
    • Confirm with the user: "Do these rules look like you?" If the user says "no", increase min_support and rerun
  2. run_shadow_backtest(shadow_id=..., journal_path=...)
    • Return per-market metrics + delta_pnl + attribution breakdown
    • Run four markets by default (china_a/hk/us/crypto)
  3. render_shadow_report(shadow_id=...)
    • Generate HTML + PDF (automatically degrade to HTML-only when weasyprint fails)
    • Return html_path / pdf_path / delta_pnl
  4. (optional)scan_shadow_signals(shadow_id=...) — list of symbols falling into the shadow entry window today (for research use)

Output interpretation

Rule card

Each rule contains:rule_id、human_text(≤30 characters),support_count、coverage_rate、holding_days_range. Rules are not a "sure-win formula", but a "common profile of when the user was profitable".

Backtest matrix

  • per_market: Sharpe/annualized/max drawdown for the four markets
  • combined: combined pool performance
  • equity_curve: net value time series (goes into PDF Section 3)

Difference attribution (PDF Section 5 — gut punch)

All values are signed; positive = shadow earns relatively more:

  • noise_trades_pnl: cumulative PnL of real trades that hit none of the rules (the user's emotional trades)
  • early_exit_pnl: winning trades but holding period < rule lower bound, opportunity cost prorated by the shortfall ratio
  • late_exit_pnl: losing trades but holding period > rule upper bound, amplified loss prorated by the excess ratio
  • overtrading_pnl: PnL of real trades exceeding the rule frequency
  • missed_signals_pnl: residual (shadow_pnl − real_pnl − sum of the four items above)

Counterfactual Top 5

Sorted by |impact| , list the 5 trades of "most should have done but didn't / most shouldn't have done but did", with specific dates and reasons.

Dialogue templates

Confirm rules:

From your {profitable_roundtrips} profitable roundtrips, these rules were distilled: {rules}. Do these look like your own playbook?

Show difference(Section 5):

Shadow PnL {shadow_pnl:+.0f} / your real {real_pnl:+.0f} / difference {delta_pnl:+.0f}. Of which {noise_trades_pnl:+.0f} comes from "emotional trades" that don't match any of your profit rules.

Today's scan(mandatory disclaimer attached):

Symbols falling into your shadow entry rhythm today: {symbols}.For research only, not a buy recommendation.

Rule translation Prompt template

When extract_shadow_strategy is called, a llm_translator callable can be injected to translate the structured entry_condition into Chinese natural language:

[上下文] 一位散户的盈利回合中,{N} 笔满足同一组条件:
  market = {market}
  entry_hour ∈ [{hour_min}, {hour_max}]
  持有 {hold_lo}-{hold_hi} 天
[任务] 用 ≤30 字的中文写一条规则,口吻像用户自述的交易习惯,不要堆术语。
[输出] 只返回一行规则文本,不要解释。

When not injected, use the f-string template (see extractor._translate_rule)。

Red lines

  • No order placement: these tools will never connect to any order channel, research output only
  • Do not copy others' strategies: Shadow Account is the "user's own" shadow, and does not extract rules from community/public strategies
  • Insufficient samples must raise an error: profitable roundtrips < 5 → directly raise, do not fabricate