Agent SkillsHKUDS/Vibe-Trading › cross-market-strategy

cross-market-strategy

GitHub

跨市场策略引擎,支持A股、加密货币、美股及外汇等多资产组合回测。自动处理日历对齐、资金共享、市场规则差异及波动率加权,实现信号生成与风险预算分配。

agent/src/skills/cross-market-strategy/SKILL.md HKUDS/Vibe-Trading

Trigger Scenarios

用户请求包含不同市场代码(如A股加加密货币)的回测任务 需要构建跨资产类别的投资组合策略

Install

npx skills add HKUDS/Vibe-Trading --skill cross-market-strategy -g -y
More Options

Non-standard path

npx skills add https://github.com/HKUDS/Vibe-Trading/tree/main/agent/src/skills/cross-market-strategy -g -y

Use without installing

npx skills use HKUDS/Vibe-Trading@cross-market-strategy

指定 Agent (Claude Code)

npx skills add HKUDS/Vibe-Trading --skill cross-market-strategy -a claude-code -g -y

安装 repo 全部 skill

npx skills add HKUDS/Vibe-Trading --all -g -y

预览 repo 内 skill

npx skills add HKUDS/Vibe-Trading --list

SKILL.md

Frontmatter
{
    "name": "cross-market-strategy",
    "category": "strategy",
    "description": "Write signal_engine.py for portfolios spanning multiple markets (A-shares + crypto, equity + forex, etc.)"
}

When to Use

When the user requests a backtest with codes from different markets — e.g. ["000001.SZ", "BTC-USDT"], ["TD.TO", "PNG.V"], or ["AAPL.US", "EUR/USD", "600519.SH"].

The CompositeEngine handles calendar alignment, shared capital, and market rules automatically. The strategy only needs to output per-symbol signals.

Key Concepts

1. Market Classification in generate()

Group symbols by market type and apply market-specific indicator parameters:

def generate(self, data_map):
    groups = {}
    for code, df in data_map.items():
        market = self._detect_market(code)
        groups.setdefault(market, {})[code] = df

    signals = {}
    for market, market_data in groups.items():
        params = MARKET_PARAMS[market]
        for code, df in market_data.items():
            signals[code] = self._market_signal(df, params)
    return signals

2. Per-Market Parameter Tables

Different markets have very different dynamics. Using the same parameters everywhere produces poor results.

Parameter A-Share Crypto US Equity Forex
MA fast 5 7 10 10
MA slow 20 25 50 30
RSI period 14 10 14 14
Vol lookback 20 14 20 20
Typical daily vol 1-2% 3-8% 1-2% 0.3-0.8%

3. Volatility-Adjusted Weights (Critical)

BTC daily vol ~ 5%, A-share daily vol ~ 1.5%. Without vol-adjustment, crypto eats the entire risk budget.

def _vol_adjust(self, signals, data_map):
    vols = {}
    for code, df in data_map.items():
        ret = df["close"].pct_change().dropna()
        vols[code] = ret.rolling(20).std().iloc[-1] if len(ret) > 20 else ret.std()

    inv_vols = {c: 1.0 / (v + 1e-10) for c, v in vols.items()}
    total_inv = sum(inv_vols.values())

    adjusted = {}
    for code, sig in signals.items():
        weight = inv_vols[code] / total_inv * len(signals)
        adjusted[code] = (sig * weight).clip(-1.0, 1.0)
    return adjusted

4. Cross-Market Signal Patterns

  1. Momentum spillover: BTC 7-day momentum as overlay for A-share tech sectors
  2. Risk-on/Risk-off: USD/CNH rate + VIX proxy to reduce equity exposure
  3. Hedging: Long A-shares + short crypto delta as tail hedge
  4. Correlation regime: When rolling correlation > 0.6, reduce to single-market exposure; when < 0.2, maximize diversification

5. What the Engine Handles (Don't Worry About)

  • Trading calendar alignment: signals are shifted on each symbol's own calendar, then ffill'd to unified dates
  • Market rules: T+1 for A-shares, funding fees for crypto, swap for forex — all per-symbol
  • Capital allocation: shared pool, strategy just sets target weights via signals
  • Commission/slippage: dispatched to correct sub-engine per symbol

config.json for Cross-Market

{
  "source": "auto",
  "codes": ["000001.SZ", "BTC-USDT"],
  "start_date": "2024-01-01",
  "end_date": "2025-03-31",
  "interval": "1D",
  "initial_cash": 1000000,
  "engine": "daily"
}
  • source must be "auto" for cross-market (routes each symbol to its loader)
  • extra_fields should be null (not all markets support fundamentals)
  • leverage defaults to 1.0 (CompositeEngine inherits from config)

Market Detection Heuristics

Pattern Market
000001.SZ, 600519.SH A-share
AAPL.US US equity
700.HK HK equity
TD.TO, PNG.V Canada equity (TSX / TSXV)
BTC-USDT Crypto
IF2406.CFFEX China futures
ESZ4 Global futures
EUR/USD Forex

Supporting Files

Version History

  • 9806936 Current 2026-08-16 09:06

    新增TSX和TSXV加拿大市场支持,完善符号路由、CAD环境回测、Yahoo数据源回退、基准选择及回归测试覆盖。

  • 0aa45a9 2026-07-24 17:45

Same Skill Collection

agent/src/skills/adr-hshare/SKILL.md
agent/src/skills/akshare/SKILL.md
agent/src/skills/alpha-zoo/SKILL.md
agent/src/skills/ashare-pre-st-filter/SKILL.md
agent/src/skills/asset-allocation/SKILL.md
agent/src/skills/backtest-diagnose/SKILL.md
agent/src/skills/behavioral-finance/SKILL.md
agent/src/skills/candlestick/SKILL.md
agent/src/skills/ccxt/SKILL.md
agent/src/skills/chanlun/SKILL.md
agent/src/skills/commodity-analysis/SKILL.md
agent/src/skills/corporate-events/SKILL.md
agent/src/skills/correlation-analysis/SKILL.md
agent/src/skills/correlation-regime/SKILL.md
agent/src/skills/crypto-derivatives/SKILL.md
agent/src/skills/data-routing/SKILL.md
agent/src/skills/defi-yield/SKILL.md
agent/src/skills/dividend-analysis/SKILL.md
agent/src/skills/doc-reader/SKILL.md
agent/src/skills/earnings-forecast/SKILL.md
agent/src/skills/earnings-revision/SKILL.md
agent/src/skills/eastmoney/SKILL.md
agent/src/skills/edgar-sec-filings/SKILL.md
agent/src/skills/elliott-wave/SKILL.md
agent/src/skills/event-driven/SKILL.md
agent/src/skills/execution-model/SKILL.md
agent/src/skills/factor-research/SKILL.md
agent/src/skills/fund-analysis/SKILL.md
agent/src/skills/fundamental-filter/SKILL.md
agent/src/skills/geopolitical-risk/SKILL.md
agent/src/skills/global-macro/SKILL.md
agent/src/skills/harmonic/SKILL.md
agent/src/skills/hedging-strategy/SKILL.md
agent/src/skills/hk-connect-flow/SKILL.md
agent/src/skills/ichimoku/SKILL.md
agent/src/skills/investor-lenses/SKILL.md
agent/src/skills/liquidation-heatmap/SKILL.md
agent/src/skills/macro-analysis/SKILL.md
agent/src/skills/market-microstructure/SKILL.md
agent/src/skills/minute-analysis/SKILL.md
agent/src/skills/ml-strategy/SKILL.md
agent/src/skills/mootdx/SKILL.md
agent/src/skills/multi-factor/SKILL.md
agent/src/skills/okx-market/SKILL.md
agent/src/skills/onchain-analysis/SKILL.md
agent/src/skills/options-advanced/SKILL.md
agent/src/skills/options-payoff/SKILL.md
agent/src/skills/options-strategy/SKILL.md
agent/src/skills/pair-trading/SKILL.md

Metadata

Files
0
Version
9806936
Hash
331e78d3
Indexed
2026-07-24 17:45

inicio - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-16 17:56
浙ICP备14020137号-1 $mapa de visitantes$