Write signal_engine.py for portfolios spanning multiple markets (A-shares + crypto, equity + forex, etc.)
56
65%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Fix and improve this skill with Tessl
tessl review fix ./agent/src/skills/cross-market-strategy/SKILL.mdWhen the user requests a backtest with codes from different markets — e.g. ["000001.SZ", "BTC-USDT"] 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.
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 signalsDifferent 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% |
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{
"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)| Pattern | Market |
|---|---|
000001.SZ, 600519.SH | A-share |
AAPL.US | US equity |
700.HK | HK equity |
BTC-USDT | Crypto |
IF2406.CFFEX | China futures |
ESZ4 | Global futures |
EUR/USD | Forex |
8643fcd
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.