fox-strategy
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFOX v0.1 — Autonomous Multi-Strategy Trading
FOX v0.1 — 自主多策略交易系统
The FOX hunts for its human. It scans, enters, exits, and rotates positions autonomously — no permission needed. When criteria are met, it acts. Speed is edge.
Forked from Wolf v7 + v7.1 data-driven optimizations. Independent strategies, state files, scripts, and cron jobs. Runs in parallel with Wolf without interference.
FOX系统如同猎手般自主运作。它会自主扫描行情、开仓、平仓、轮换仓位——无需人工许可。当满足条件时立即行动,速度就是优势。
基于Wolf v7 + v7.1分叉并进行数据驱动优化。拥有独立的策略、状态文件、脚本和Cron任务,可与Wolf系统并行运行且互不干扰。
Quick Start
快速开始
- Ensure Senpi MCP is connected (should show
mcporter list)senpi - Create a custom strategy wallet: use via mcporter
strategy_create_custom_strategy - Fund the wallet via with your budget
strategy_top_up - Run setup:
python3 scripts/fox-setup.py --wallet 0x... --strategy-id UUID --budget 6500 --chat-id 12345 - Create the 8 OpenClaw crons using templates from
references/cron-templates.md - The FOX is hunting
To add a second strategy, run again with a different wallet/budget. It adds to the registry.
fox-setup.py- 确保已连接Senpi MCP(执行应显示
mcporter list)senpi - 创建自定义策略钱包:通过mcporter执行
strategy_create_custom_strategy - 通过为钱包注入资金
strategy_top_up - 运行设置脚本:
python3 scripts/fox-setup.py --wallet 0x... --strategy-id UUID --budget 6500 --chat-id 12345 - 使用中的模板创建8个OpenClaw Cron任务
references/cron-templates.md - FOX系统开始自主运作
若要添加第二个策略,再次运行并指定不同的钱包/预算即可,新策略会被添加到注册表中。
fox-setup.pyReference Files
参考文件
| File | Contents |
|---|---|
| references/learnings.md | Proven results, key learnings, known bugs, trading discipline |
| references/cron-setup.md | Cron config, race condition prevention, time-aware scheduling |
| references/cron-templates.md | Ready-to-use cron mandates with proper systemEvent/agentTurn format |
| references/state-schema.md | JSON state file schemas (registry, trade counter, DSL state, scanner config) |
| references/api-tools.md | Senpi API tool quick reference |
| references/senpi-skill-guide.md | Senpi Skill Development Guide (conformance reference) |
| 文件 | 内容 |
|---|---|
| references/learnings.md | 已验证结果、关键经验、已知问题、交易纪律 |
| references/cron-setup.md | Cron配置、竞态条件预防、时段感知调度 |
| references/cron-templates.md | 可直接使用的Cron任务模板,包含正确的systemEvent/agentTurn格式 |
| references/state-schema.md | JSON状态文件 schema(注册表、交易计数器、DSL状态、扫描器配置) |
| references/api-tools.md | Senpi API工具速查手册 |
| references/senpi-skill-guide.md | Senpi Skill开发指南(合规参考) |
Multi-Strategy Architecture
多策略架构
Strategy Registry (fox-strategies.json
)
fox-strategies.json策略注册表(fox-strategies.json
)
fox-strategies.jsonCentral config holding all strategies. Created/updated by .
fox-setup.pyfox-strategies.json
├── strategies
│ ├── fox-abc123 (Aggressive Momentum, 3 slots, 10x)
│ └── fox-xyz789 (Conservative XYZ, 2 slots, 7x)
└── global (telegram, workspace)存储所有策略的中央配置文件,由创建和更新。
fox-setup.pyfox-strategies.json
├── strategies
│ ├── fox-abc123 (激进动量策略,3个仓位,10倍杠杆)
│ └── fox-xyz789 (保守型XYZ策略,2个仓位,7倍杠杆)
└── global (Telegram、工作区配置)Per-Strategy State
单策略独立状态
Each strategy gets its own state directory:
state/
├── fox-abc123/
│ ├── dsl-HYPE.json
│ └── dsl-SOL.json
└── fox-xyz789/
├── dsl-HYPE.json # Same asset, different strategy, no collision
└── dsl-GOLD.json每个策略拥有独立的状态目录:
state/
├── fox-abc123/
│ ├── dsl-HYPE.json
│ └── dsl-SOL.json
└── fox-xyz789/
├── dsl-HYPE.json # 同一资产,不同策略,无冲突
└── dsl-GOLD.jsonSignal Routing
信号路由
When a signal fires, it's routed to the best-fit strategy:
- Which strategies have empty slots?
- Does any strategy already hold this asset? (skip within strategy, allow cross-strategy)
- Which strategy's risk profile matches? (aggressive gets FIRST_JUMPs, conservative gets DEEP_CLIMBERs)
- Route to best-fit → open on that wallet → create DSL state in that strategy's dir
当交易信号触发时,会被路由至最匹配的策略:
- 哪些策略有空余仓位?
- 是否有策略已持有该资产?(同策略内跳过,允许跨策略持有)
- 哪个策略的风险偏好匹配?(激进策略接收FIRST_JUMP信号,保守策略接收DEEP_CLIMBER信号)
- 路由至最佳匹配策略→在对应钱包开仓→在该策略目录下创建DSL状态
Adding a Strategy
添加策略
bash
python3 scripts/fox-setup.py --wallet 0x... --strategy-id UUID --budget 6500 \
--chat-id 12345 --name "Aggressive Momentum" --dsl-preset aggressiveThis adds to the registry without disrupting running strategies. Disable with in the registry.
enabled: falsebash
python3 scripts/fox-setup.py --wallet 0x... --strategy-id UUID --budget 6500 \
--chat-id 12345 --name "Aggressive Momentum" --dsl-preset aggressive该操作会将策略添加到注册表中,且不会影响正在运行的策略。可通过在注册表中设置来禁用策略。
enabled: falseFOX v7 Changes Summary (from Wolf v7)
FOX v7 相较于Wolf v7的变更总结
1. Market Regime Refresh (4h)
1. 市场行情刷新(每4小时)
- New cron job runs every 4 hours
fox-market-regime.py - Saves output to
market-regime-last.json - Provides fresh BEARISH/BULLISH/NEUTRAL classification
- 新增Cron任务,每4小时运行
fox-market-regime.py - 将输出保存至
market-regime-last.json - 提供最新的熊市/牛市/中性行情分类
2. NEUTRAL Regime Support
2. 支持中性行情
- BEARISH: SHORT only (unchanged)
- BULLISH: LONG only (unchanged)
- NEUTRAL: Both LONG and SHORT allowed if signal score ≥ 8 (higher bar)
- NEUTRAL definition: market_bull < 60 AND market_bear < 60, OR overall confidence < 50
- 熊市:仅允许做空(无变更)
- 牛市:仅允许做多(无变更)
- 中性:若信号评分≥8分(更高门槛),则允许做多和做空
- 中性定义:market_bull < 60 且 market_bear < 60,或整体置信度 < 50
3. Scoring System (replaces "min 4 reasons")
3. 评分系统(替代“至少4个理由”规则)
- FIRST_JUMP: +3 pts (still mandatory)
- IMMEDIATE_MOVER: +2 pts
- contribVelocity > 10: +2 pts
- CONTRIB_EXPLOSION: +2 pts
- DEEP_CLIMBER: +1 pt
- Other reasons (RANK_UP, CLIMBING, ACCEL, STREAK): +1 pt each
- BTC 1h bias alignment: +1 bonus pt
- v0.1 TIME BONUS (04:00–14:00 UTC): +1 pt
- v0.1 TIME PENALTY (18:00–02:00 UTC): -2 pts
- Minimum 6 points to enter (8+ for NEUTRAL regime)
- FIRST_JUMP:+3分(仍为必填项)
- IMMEDIATE_MOVER:+2分
- contribVelocity > 10:+2分
- CONTRIB_EXPLOSION:+2分
- DEEP_CLIMBER:+1分
- 其他理由(RANK_UP、CLIMBING、ACCEL、STREAK):每项+1分
- BTC 1小时趋势对齐:额外+1分
- v0.1时段奖励(UTC 04:00–14:00):+1分
- v0.1时段惩罚(UTC 18:00–02:00):-2分
- 开仓最低要求6分(中性行情下需8分以上)
4. Tiered Margin System
4. 分层保证金系统
- Max entries: 6 (flat, no dynamic slots)
- Entries 1-2: $1450 margin, $1500 budget
- Entries 3-4: $950 margin, $1000 budget
- Entries 5-6: $450 margin, $500 budget
- Scanner reads tier based on current entry count from
fox-trade-counter.json
- 最大持仓数:6笔(固定值,无动态仓位)
- 第1-2笔持仓:1450美元保证金,1500美元预算
- 第3-4笔持仓:950美元保证金,1000美元预算
- 第5-6笔持仓:450美元保证金,500美元预算
- 扫描器从读取当前持仓数以匹配对应层级
fox-trade-counter.json
5. BTC 1h Bias Alignment
5. BTC 1小时趋势对齐
- Check BTC hourly trend from regime data before entry
- Aligned signals: +1 bonus point (BTC 1h BULLISH + signal LONG, or BTC 1h BEARISH + signal SHORT)
- Conflicting signals: no penalty, no bonus (regime filter handles hard blocks)
- 开仓前根据行情数据检查BTC小时级趋势
- 趋势对齐信号:额外+1分(BTC 1小时牛市+做多信号,或BTC 1小时熊市+做空信号)
- 趋势冲突信号:无惩罚也无奖励(行情过滤器会处理硬性限制)
v0.1 Optimizations (Data-Driven from 14 Live Trades: 2W/12L)
v0.1 数据驱动优化(基于14笔实盘交易:2胜12负)
These changes are derived from analyzing Wolf v7's live trading results. Every optimization has evidence from real trades.
这些变更均来自对Wolf v7实盘交易结果的分析,每一项优化都有真实交易数据支撑。
1. Tighter Absolute Floor (0.02/leverage → ~20% max ROE loss)
1. 更严格的绝对止损线(0.02/杠杆 → 最大ROE损失约20%)
| Old (v7) | New (v0.1) | |
|---|---|---|
| Formula (LONG) | | |
| Formula (SHORT) | | |
| Max ROE loss | ~30% | ~20% |
Evidence: NEAR lost 23.7% ROE, FARTCOIN 18.4% — both would have been capped earlier at 20%.
Config field: (default: )
phase1.retraceThreshold0.02| 旧版(v7) | 新版(v0.1) | |
|---|---|---|
| 做多公式 | | |
| 做空公式 | | |
| 最大ROE损失 | ~30% | ~20% |
数据支撑:NEAR代币损失了23.7%的ROE,FARTCOIN损失了18.4%——若使用新版规则,两者都会在损失20%时被止损。
配置字段:(默认值:)
phase1.retraceThreshold0.022. Aggressive Phase 1 Timing
2. 激进的第一阶段时间控制
| Rule | Old (v7) | New (v0.1) |
|---|---|---|
| Hard timeout (never hits Tier 1) | 90 min | 30 min |
| Weak peak cut (peak ROE < 3%, declining) | 45 min | 15 min |
| Dead weight (never positive ROE) | 30 min | 10 min |
Evidence: 100% of winners went positive within minutes. 100% of losers that started negative stayed negative.
Config fields: (default: ), (default: ), (default: )
phase1.hardTimeoutMin30phase1.weakPeakCutMin15phase1.deadWeightCutMin10Enforcement: These timing rules are checked by the DSL cron mandate (agent-level), NOT by the dsl-v5.py script. The agent reads from the DSL state file and applies timing logic after parsing dsl-v5.py output.
createdAt| 规则 | 旧版(v7) | 新版(v0.1) |
|---|---|---|
| 强制超时(未达到Tier 1) | 90分钟 | 30分钟 |
| 弱势峰值止损(峰值ROE <3%且持续下跌) | 45分钟 | 15分钟 |
| 无效仓位止损(从未实现正ROE) | 30分钟 | 10分钟 |
数据支撑:100%的盈利仓位在数分钟内就实现了正收益,100%的亏损仓位从一开始就处于负收益状态且持续恶化。
配置字段:(默认值:)、(默认值:)、(默认值:)
phase1.hardTimeoutMin30phase1.weakPeakCutMin15phase1.deadWeightCutMin10执行逻辑:这些时间规则由DSL Cron任务(Agent层面)检查,而非dsl-v5.py脚本。Agent会从DSL状态文件读取字段,并在解析dsl-v5.py输出后应用时间逻辑。
createdAt3. Green-in-10 Rule
3. 10分钟未盈利规则
New field in DSL state: (default: )
greenIn10falseIf a position never shows positive ROE within the first 10 minutes → tighten to 50% of original distance from entry. This is a "tighten, don't close" rule — the 10min dead weight cut handles the actual close if it stays negative.
absoluteFloorFor positions that briefly went green then reversed, this rule does NOT apply.
Config field: (default: — tighten floor to 50% of original distance)
phase1.greenIn10TightenPct50DSL状态新增字段:(默认值:)
greenIn10false若仓位在前10分钟内从未实现正ROE,则将(绝对止损线)收紧至距开仓价原始距离的50%。这是一条“收紧止损而非平仓”的规则——若仓位持续亏损,10分钟无效仓位止损规则会触发平仓。
absoluteFloor若仓位曾短暂盈利后回落,则不适用本规则。
配置字段:(默认值:——将止损线收紧至原始距离的50%)
phase1.greenIn10TightenPct504. Time-of-Day Scoring
4. 时段评分机制
| Time Window (UTC) | Modifier | Rationale |
|---|---|---|
| 04:00–14:00 | +1 pt | Historically where winners occur |
| 14:00–18:00 | 0 pts | Neutral window |
| 18:00–02:00 | -2 pts | 0% win rate across 6 evening trades |
| 02:00–04:00 | 0 pts | Neutral window |
Effect: Evening entries effectively need score ≥ 8 to pass the 6-point threshold.
Config fields: (default: ), (default: ), (default: ), (default: )
scoring.timeBonusHoursUTC[4,14]scoring.timePenaltyHoursUTC[18,2]scoring.timeBonusPts1scoring.timePenaltyPts-2| UTC时段 | 评分调整 | 依据 |
|---|---|---|
| 04:00–14:00 | +1分 | 历史数据显示盈利交易多发生在此时段 |
| 14:00–18:00 | 0分 | 中性时段 |
| 18:00–02:00 | -2分 | 6笔晚间交易胜率为0% |
| 02:00–04:00 | 0分 | 中性时段 |
影响:晚间开仓需达到8分以上才能满足6分的最低门槛。
配置字段:(默认值:)、(默认值:)、(默认值:)、(默认值:)
scoring.timeBonusHoursUTC[4,14]scoring.timePenaltyHoursUTC[18,2]scoring.timeBonusPts1scoring.timePenaltyPts-25. Rank Jump Minimum
5. 最小排名跃升阈值
New filter: OR
rankJumpThisScan ≥ 15contribVelocity > 15Old rule: just needed (any 10+ rank jump from #25+). Now requires either a massive jump (≥15 ranks) or strong velocity (>15).
isFirstJump=trueEvidence: Both winners had massive jumps. Small jumps (#30→#20, #35→#21) all lost.
Config fields: (default: ), (default: )
filters.minRankJump15filters.minVelocityOverride15新增过滤器: 或
rankJumpThisScan ≥ 15contribVelocity > 15旧规则:仅需(排名从25名之后跃升10名以上)。现在要求要么是大幅跃升(≥15名),要么是高速度(>15)。
isFirstJump=true数据支撑:两笔盈利交易均为大幅跃升,小幅跃升(如30→20、35→21)的交易全部亏损。
配置字段:(默认值:)、(默认值:)
filters.minRankJump15filters.minVelocityOverride156. Conviction-Scaled Phase 1 Tolerance (v7.2)
6. 基于信心度的第一阶段容忍度(v7.2)
Finding: Direction was right 85% of the time (11/13 trades) but we still lost $785 on correct-direction trades and left $8,000+ on the table. The problem is timing/stops, not signal quality.
Solution: Score at entry determines how much room Phase 1 gets. High-conviction trades survive initial volatility; low-conviction trades get cut fast.
| Score | Absolute Floor | Hard Timeout | Weak Peak | Dead Weight |
|---|---|---|---|---|
| 6-7 | 0.02/lev (~20%) | 30 min | 15 min | 10 min |
| 8-9 | 0.025/lev (~25%) | 45 min | 20 min | 15 min |
| 10+ | 0.03/lev (~30%) | 60 min | 30 min | 20 min |
Implementation: Entry score is stored in DSL state ( field). The DSL cron mandate reads the score and selects the matching tolerance tier from config. If no score is present, defaults to the 6-7 tier (tightest).
scorephase1.convictionTiersConfig field: (array of )
phase1.convictionTiers{minScore, retraceThreshold, hardTimeoutMin, weakPeakCutMin, deadWeightCutMin}发现:85%的交易方向判断正确(13笔交易中有11笔),但我们仍在方向正确的交易中亏损了785美元,且错失了8000美元以上的盈利机会。问题出在止损时机而非信号质量。
解决方案:开仓时的评分决定第一阶段的容忍空间。高信心度交易可承受初始波动,低信心度交易则会被快速止损。
| 评分 | 绝对止损线 | 强制超时 | 弱势峰值止损 | 无效仓位止损 |
|---|---|---|---|---|
| 6-7 | 0.02/杠杆(约20%) | 30分钟 | 15分钟 | 10分钟 |
| 8-9 | 0.025/杠杆(约25%) | 45分钟 | 20分钟 | 15分钟 |
| 10+ | 0.03/杠杆(约30%) | 60分钟 | 30分钟 | 20分钟 |
实现逻辑:开仓评分会被存储在DSL状态的字段中。DSL Cron任务会读取该评分,并从配置中选择对应的容忍层级。若未存储评分,则默认使用6-7分的最严格层级。
scorephase1.convictionTiers配置字段:(包含的数组)
phase1.convictionTiers{minScore, retraceThreshold, hardTimeoutMin, weakPeakCutMin, deadWeightCutMin}7. Re-Entry Rule (v7.2)
7. 重新开仓规则(v7.2)
When we exit a Phase 1 trade and the asset continues in our original direction, we can re-enter with guardrails.
Re-entry checklist (ALL must pass):
- Asset still in top 20 with same direction
- (momentum continuing)
contribVelocity > 5 - Price has moved FURTHER in our original direction since exit
- Within 2 hours of original exit
- First attempt did NOT lose > 15% ROE (too volatile = skip)
- Score minimum: 5 pts (relaxed from 6 — direction already validated)
- NOT required (it already jumped once)
isFirstJump
Sizing: 75% of normal margin tier (reduced risk on 2nd attempt)
State tracking: DSL state gets and . Trade counter logs .
isReentry: truereentryOf: "<original_trade_id>"isReentry: trueConfig fields: (default: ), (default: ), (default: ), (default: ), (default: ), (default: )
reentry.enabledtruereentry.marginPct75reentry.minScore5reentry.maxOriginalLossROE15reentry.windowMin120reentry.minContribVelocity5当我们在第一阶段平仓后,若资产仍沿原方向运行,可在防护规则下重新开仓。
重新开仓检查清单(全部需满足):
- 资产仍处于前20名且方向不变
- (动量持续)
contribVelocity > 5 - 平仓后价格沿原方向进一步变动
- 距原平仓时间不超过2小时
- 首次开仓未损失超过15%的ROE(波动过大则跳过)
- 最低评分:5分(较6分放宽——方向已被验证)
- 无需满足条件(已发生过一次跃升)
isFirstJump
仓位规模:为正常保证金层级的75%(降低第二次尝试的风险)
状态跟踪:DSL状态会添加和字段。交易计数器会记录。
isReentry: truereentryOf: "<original_trade_id>"isReentry: true配置字段:(默认值:)、(默认值:)、(默认值:)、(默认值:)、(默认值:)、(默认值:)
reentry.enabledtruereentry.marginPct75reentry.minScore5reentry.maxOriginalLossROE15reentry.windowMin120reentry.minContribVelocity5Entry Philosophy — THE Most Important Section
开仓理念 — 最重要的部分
Enter before the peak, not at the top.
Leaderboard rank confirmation LAGS price. When an asset jumps from #31→#16 in one scan, the price is moving NOW. By the time it reaches #7 with clean history, the move is over. Speed is edge.
Core principle: 2 reasons at rank #25 with a big jump = ENTER. 4+ reasons at rank #5 = SKIP (already peaked).
在峰值前开仓,而非在顶部开仓。
排行榜排名确认滞后于价格变动。当某资产在一次扫描中从31名跃升至16名时,价格正在实时变动。当它以清晰的历史记录升至第7名时,行情已经结束。速度就是优势。
核心原则:排名25名时拥有2个理由+大幅跃升=开仓。排名5名时拥有4个以上理由=跳过(已达峰值)。
Entry Signals — Priority Order
开仓信号 — 优先级顺序
1. FIRST_JUMP (Highest Priority)
1. FIRST_JUMP(最高优先级)
What: Asset jumps 10+ ranks from #25+ in ONE scan AND was not in previous scan's top 50 (or was at rank >= #30).
Action: Enter IMMEDIATELY. This is the money signal. Route to best-fit strategy with available slots.
Checklist:
- in scanner output
isFirstJump: true - v0.1 Rank jump minimum: OR
rankJumpThisScan ≥ 15(small jumps like #30→#20 all lost)contribVelocity > 15 - 2+ reasons is enough (don't require 4+)
- vel > 0 is sufficient (velocity hasn't had time to build on a first jump)
- Max leverage >= 7x (check )
max-leverage.json - Slot available in target strategy (or rotation justified)
-
= 10 SM traders (crypto); for XYZ equities, ignore trader count
What to ignore:
- Erratic rank history — the scanner excludes the current jump from erratic checks
- Low velocity — first jumps haven't had time to build velocity
If CONTRIB_EXPLOSION accompanies it: Double confirmation. Even stronger entry.
定义:资产在一次扫描中从25名之后跃升10名以上,且在上一次扫描中未进入前50名(或排名≥30名)。
操作:立即开仓。这是核心盈利信号。路由至有空余仓位的最佳匹配策略。
检查清单:
- 扫描器输出中
isFirstJump: true - v0.1最小排名跃升阈值:或
rankJumpThisScan ≥15(如30→20的小幅跃升全部亏损)contribVelocity >15 - 2个理由即可(无需4个以上)
- vel>0即可(首次跃升还未积累足够速度)
- 最大杠杆≥7倍(查看)
max-leverage.json - 目标策略有空余仓位(或有理由进行仓位轮换)
- 至少10名SM交易者(加密货币;对于XYZ股票,忽略交易者数量)
可忽略项:
- 不稳定的排名历史——扫描器会在不稳定检查中排除当前跃升
- 低速度——首次跃升还未积累足够速度
若伴随CONTRIB_EXPLOSION信号:双重确认,开仓信号更强。
2. CONTRIB_EXPLOSION
2. CONTRIB_EXPLOSION
What: 3x+ contribution increase in one scan from asset at rank #20+.
Action: Enter even if rank history looks "erratic." The contrib spike IS the signal regardless of prior rank bouncing.
Never downgraded for erratic history. Often accompanies FIRST_JUMP for double confirmation.
定义:排名20名之后的资产在一次扫描中贡献度增长3倍以上。
操作:即使排名历史“不稳定”也要开仓。贡献度飙升本身就是信号,与之前的排名波动无关。
永远不会因不稳定的排名历史被降级。常与FIRST_JUMP信号同时出现,形成双重确认。
3. DEEP_CLIMBER
3. DEEP_CLIMBER
What: Steady climb from #30+, positive velocity (>= 0.03), 3+ reasons, clean rank history.
Action: Enter when it crosses into top 20. Route to conservative strategy if available.
定义:从30名之后稳步攀升,速度为正(≥0.03),拥有3个以上理由,排名历史清晰。
操作:当进入前20名时开仓。若保守策略有空余仓位,则路由至保守策略。
4. NEW_ENTRY_DEEP
4. NEW_ENTRY_DEEP
What: Appears in top 20 from nowhere (wasn't in top 50 last scan).
Action: Instant entry.
定义:从上一次扫描的前50名之外直接进入前20名。
操作:立即开仓。
5. Opportunity Scanner (Score 175+)
5. 机会扫描器(评分175+)
Runs every 15min. v6 scanner with BTC macro context, hourly trend classification, and hard disqualifiers. Complements Emerging Movers as a secondary signal source for deeper technical analysis.
每15分钟运行一次。v6版本扫描器,包含BTC宏观环境、小时级趋势分类和硬性 disqualifier。作为新兴行情扫描器的补充,提供更深入的技术分析信号。
Anti-Patterns — When NOT to Enter
反模式 — 禁止开仓的情况
- NEVER enter assets already at #1-10. That's the top, not the entry. Rank = what already happened.
- NEVER wait for a signal to "clean up." By the time rank history is smooth and velocity is high, the move is priced in.
- 4+ reasons at rank #5 = SKIP. The asset already peaked.
- 2 reasons at rank #25 with a big jump = ENTER. The move is just starting.
- Leaderboard rank != future price direction. Rank reflects past trader concentration. Price moves first, rank follows.
- Negative velocity + no jump = skip. Slow bleeders going nowhere.
- Oversold shorts (RSI < 30 + extended 24h move) = skip.
- 绝对不要在资产已处于1-10名时开仓。那是顶部,不是开仓点。排名反映的是过去的情况。
- 绝对不要等待信号“变得清晰”。当排名历史平滑、速度高时,行情已经被定价。
- 排名5名时拥有4个以上理由=跳过。资产已达峰值。
- 排名25名时拥有2个理由+大幅跃升=开仓。行情才刚刚开始。
- 排行榜排名≠未来价格方向。排名反映的是过去的交易者集中度。价格先变动,排名随后跟进。
- 负速度+无跃升=跳过。缓慢下跌的资产毫无机会。
- 超卖做空(RSI<30+24小时持续变动)=跳过。
Late Entry Anti-Pattern
延迟开仓反模式
The pattern: Scanner fires FIRST_JUMP for ASSET at #25→#14. You hesitate. Next scan it's #10. Next scan #7 with 5 reasons. NOW it looks "safe." You enter. It reverses from #5.
The fix: Enter on the FIRST signal or don't enter at all. If you missed it, wait for the next asset. There's always another FIRST_JUMP coming.
Rule: If an asset has been in the top 10 for 2+ scans already, it's too late. Move on.
模式:扫描器为ASSET触发FIRST_JUMP信号(25→14名)。你犹豫了。下一次扫描它到了10名。再下一次到了7名,拥有5个理由。现在看起来“安全”了,你开仓了。它从5名开始反转。
解决方法:要么在第一个信号出现时开仓,要么完全放弃。如果错过了,等待下一个资产。总会有下一个FIRST_JUMP信号。
规则:若资产已连续2次扫描处于前10名,就太晚了。继续等待下一个机会。
Architecture — 8 Cron Jobs
架构 — 8个Cron任务
| # | Job | Interval | Session | Script | Purpose |
|---|---|---|---|---|---|
| 1 | Emerging Movers | 3min | main | | Hunt FIRST_JUMP signals with v7 scoring |
| 2 | DSL v5.3.1 | 3min | isolated | | Trailing stop exits, HL SL sync |
| 3 | SM Flip Detector | 5min | isolated | | Conviction collapse cuts |
| 4 | Watchdog | 5min | isolated | | Per-strategy margin buffer, liq distances |
| 5 | Portfolio Update | 15min | isolated | (agent-driven) | Per-strategy PnL reporting |
| 6 | Opportunity Scanner | 15min | main | | 4-pillar scoring, BTC macro, hourly trend |
| 7 | Market Regime | 4h | isolated | | Regime classification |
| 8 | Health Check | 10min | isolated | | Orphan DSL, state validation |
All scripts read and iterate all enabled Fox strategies.
fox-strategies.jsonSee references/cron-setup.md for detailed cron configuration, race condition prevention, and time-aware scheduling.
| 序号 | 任务 | 执行间隔 | 会话类型 | 脚本 | 用途 |
|---|---|---|---|---|---|
| 1 | 新兴行情扫描 | 3分钟 | main | | 基于v7评分机制捕捉FIRST_JUMP信号 |
| 2 | DSL v5.3.1 | 3分钟 | 独立 | | 追踪止损平仓、同步HL止损线 |
| 3 | SM反转检测器 | 5分钟 | 独立 | | 信心度崩溃时止损 |
| 4 | 监控守护进程 | 5分钟 | 独立 | | 单策略保证金缓冲、清算距离检查 |
| 5 | 投资组合更新 | 15分钟 | 独立 | (Agent驱动) | 单策略PnL报告 |
| 6 | 机会扫描器 | 15分钟 | main | | 4支柱评分、BTC宏观环境、小时级趋势 |
| 7 | 市场行情检测 | 4小时 | 独立 | | 行情分类 |
| 8 | 健康检查 | 10分钟 | 独立 | | 孤立DSL检查、状态验证 |
所有脚本都会读取并遍历所有启用的Fox策略。
fox-strategies.json详细的Cron配置、竞态条件预防和时段感知调度请参考references/cron-setup.md。
Model Selection Per Cron — 3-Tier Approach
基于Cron的模型选择 — 3层级方法
| Tier | Role | Crons | Example Model IDs |
|---|---|---|---|
| Primary | Complex judgment, multi-strategy routing | Emerging Movers, Opportunity Scanner | Your configured model (runs on main session) |
| Mid | Structured tasks, script output parsing | DSL v5.3.1, Portfolio Update, Health Check, Market Regime | model configured in OpenClaw |
| Budget | Simple threshold checks, binary decisions | SM Flip, Watchdog | model configured in OpenClaw |
Do NOT create crons yet — the main agent will set these up when activating the strategy.
| 层级 | 角色 | 对应Cron任务 | 示例模型ID |
|---|---|---|---|
| Primary | 复杂判断、多策略路由 | 新兴行情扫描、机会扫描器 | 你配置的模型(运行在main会话) |
| Mid | 结构化任务、脚本输出解析 | DSL v5.3.1、投资组合更新、健康检查、市场行情检测 | OpenClaw中配置的模型 |
| Budget | 简单阈值检查、二元决策 | SM反转检测、监控守护进程 | OpenClaw中配置的模型 |
暂时不要创建Cron任务——主Agent会在激活策略时自动设置。
Cron Setup
Cron设置
Critical: Crons are OpenClaw crons, NOT senpi crons. FOX uses two session types:
- Main session (): Emerging Movers + Opportunity Scanner. These share the primary session context for accumulated routing knowledge.
systemEvent - Isolated session (): All others. Each runs in its own session — no context pollution, enables cheaper model tiers.
agentTurn
Key rules (per Senpi Skill Guide §7):
- uses
systemEventkey;"text"usesagentTurnkey — wrong key = silent failure"message" - Budget/Mid mandates have explicit per output field — never "apply rules from SKILL.md"
if/then - Slot guard pattern: check BEFORE any entry
anySlotsAvailable - One set of crons — scripts iterate all strategies internally
See references/cron-templates.md for exact payloads.
关键提示:Cron任务是OpenClaw Cron,而非senpi Cron。FOX使用两种会话类型:
- Main会话():新兴行情扫描 + 机会扫描器。这些任务共享主会话上下文,以积累路由知识。
systemEvent - 独立会话():其他所有任务。每个任务运行在独立会话中——无上下文污染,可使用更便宜的模型层级。
agentTurn
核心规则(来自Senpi Skill Guide §7):
- 使用
systemEvent字段;"text"使用agentTurn字段——字段错误会导致静默失败"message" - Budget/Mid层级任务需为每个输出字段设置明确的逻辑——绝不要使用“应用SKILL.md中的规则”
if/then - 仓位防护模式:开仓前先检查
anySlotsAvailable - 仅需一组Cron任务——脚本会在内部遍历所有策略
具体的请求体请参考references/cron-templates.md。
Autonomy Rules
自主运行规则
The FOX operates autonomously by default. The agent does NOT ask permission to:
- Open a position when entry checklist passes
- Close a position when DSL triggers or conviction collapses
- Rotate out of weak positions into stronger signals
- Cut dead weight (SM conv 0, negative ROE, 10+ min)
The agent DOES notify the user (via Telegram) after every action — but ONLY actions.
FOX默认以自主模式运行。Agent无需请求许可即可执行以下操作:
- 当开仓检查清单满足时开仓
- 当DSL触发或信心度崩溃时平仓
- 从弱势仓位轮换至更强信号的仓位
- 清理无效仓位(SM信心度0、负ROE、持仓10分钟以上)
Agent会在每次操作后(仅操作完成后)通过Telegram通知用户。
Notification Policy (Strict)
通知策略(严格执行)
ONLY send Telegram when:
- Position OPENED (asset, direction, leverage, margin, score, reasons)
- Position CLOSED (asset, direction, PnL, close reason, hold time)
- Risk guardian triggered (gate closed, cooldown started, force close)
- Copy trading alert (-20% drawdown, strategy inactive, auto-rotate fired)
- Critical error (3+ consecutive DSL failures, MCP auth expired)
NEVER send Telegram for:
- Scanner ran and found nothing (HEARTBEAT_OK silently)
- Scanner found signals but all were filtered out
- DSL checked positions and nothing changed
- Health check passed
- Watchdog checked margins and everything is fine
- SM flip check found no flips
- Any reasoning, thinking, or narration about what the agent considered
Rule: If you didn't open, close, or force-close a position, and nothing is broken, the user should not hear from you. Silence = everything is working.
仅在以下情况发送Telegram通知:
- 仓位开仓(资产、方向、杠杆、保证金、评分、理由)
- 仓位平仓(资产、方向、PnL、平仓理由、持仓时间)
- 风险守护进程触发(关闭仓位、启动冷却期、强制平仓)
- 复制交易警报(回撤20%、策略停用、自动轮换触发)
- 严重错误(连续3次以上DSL失败、MCP授权过期)
绝对不要在以下情况发送Telegram通知:
- 扫描器运行但未发现任何信号(静默输出HEARTBEAT_OK)
- 扫描器发现信号但全部被过滤
- DSL检查仓位但未发生任何变化
- 健康检查通过
- 监控守护进程检查保证金一切正常
- SM反转检查未发现反转
- 任何关于Agent思考过程的推理、叙述
规则:如果没有开仓、平仓或强制平仓操作,且系统无故障,用户不应收到通知。静默意味着一切正常。
Phase 1 Auto-Cut (v0.1 — Conviction-Scaled Timing)
第一阶段自动止损(v0.1 — 基于信心度的时间缩放)
Positions that never gain momentum get cut automatically. Timing is scaled by entry score (v7.2): high-conviction trades get more room, low-conviction trades get cut fast.
Default rules (score 6-7, configurable via fields in DSL state):
phase1- 30-minute hard timeout (). If ROE never hits Tier 1 (5%) in 30 min, close.
hardTimeoutMin: 30 - 15-minute weak peak cut (). If peak ROE was < 3% and declining → close after 15 min.
weakPeakCutMin: 15 Dead weight cut(REMOVED v1.1). Was cutting positions that would have worked. Hard timeout handles real duds.- Green-in-10 floor tightening (). If never green in 10 min but not yet cut → tighten absoluteFloor to 50% of original distance from entry.
greenIn10TightenPct: 50
Conviction scaling (v7.2):
| Score | Floor | Hard Timeout | Weak Peak | Dead Weight |
|---|---|---|---|---|
| 6-7 | 0.02/lev | 30 min | 15 min | 10 min |
| 8-9 | 0.025/lev | 45 min | 20 min | 15 min |
| 10+ | 0.03/lev | 60 min | 30 min | 20 min |
The DSL cron mandate reads from the DSL state file and applies the matching tier. No score = defaults to 6-7 tier.
scoreEnforcement: These timing rules are applied by the DSL cron mandate (agent reads and from state file), NOT by dsl-v5.py itself.
createdAtscoreWhy: Direction was right 85% of the time. We lost money because stops were too tight on high-conviction trades. Score-scaling gives good trades room to breathe while still cutting bad ones fast.
从未获得动量的仓位会被自动止损。时间控制基于开仓评分进行缩放(v7.2):高信心度交易拥有更多空间,低信心度交易则被快速止损。
默认规则(评分6-7,可通过DSL状态中的字段配置):
phase1- 30分钟强制超时()。若30分钟内ROE从未达到Tier 1(5%),则平仓。
hardTimeoutMin: 30 - 15分钟弱势峰值止损()。若峰值ROE<3%且持续下跌→15分钟后平仓。
weakPeakCutMin: 15 无效仓位止损(v1.1已移除)。曾错误平仓了原本盈利的仓位。强制超时规则会处理真正的无效仓位。- 10分钟未盈利则收紧止损线()。若10分钟内从未盈利但尚未被平仓→将absoluteFloor收紧至距开仓价原始距离的50%。
greenIn10TightenPct: 50
基于信心度的缩放(v7.2):
| 评分 | 止损线 | 强制超时 | 弱势峰值止损 | 无效仓位止损 |
|---|---|---|---|---|
| 6-7 | 0.02/杠杆 | 30分钟 | 15分钟 | 10分钟 |
| 8-9 | 0.025/杠杆 | 45分钟 | 20分钟 | 15分钟 |
| 10+ | 0.03/杠杆 | 60分钟 | 30分钟 | 20分钟 |
DSL Cron任务会从DSL状态文件读取字段,并应用匹配的层级。若无评分,则默认使用6-7分的最严格层级。
score执行逻辑:这些时间规则由DSL Cron任务(Agent从状态文件读取和字段)应用,而非dsl-v5.py脚本本身。
createdAtscore原因:85%的交易方向判断正确。我们亏损是因为高信心度交易的止损线过紧。评分缩放机制让优质交易有足够的波动空间,同时仍能快速止损劣质交易。
Exit Rules
平仓规则
1. DSL v5.3.1 Mechanical Exit (Trailing Stops)
1. DSL v5.3.1 机械平仓(追踪止损)
All trailing stops handled automatically by DSL v5.3.1 per-strategy crons. SL synced to Hyperliquid for instant execution.
所有追踪止损由DSL v5.3.1单策略Cron任务自动处理。止损线同步至Hyperliquid以实现即时执行。
2. SM Conviction Collapse
2. SM信心度崩溃
Conv drops to 0 or 4→1 with mass trader exodus → instant cut.
信心度降至0或从4→1且大量交易者离场→立即平仓。
3. Dead Weight
3. 无效仓位
Conv 0, negative ROE, 10+ min → instant cut (v0.1: tightened from 30min).
信心度0、负ROE、持仓10分钟以上→立即平仓(v0.1:从30分钟收紧至10分钟)。
4. SM Flip
4. SM反转
Conviction 4+ in the OPPOSITE direction with 100+ traders → cut immediately.
信心度4+且方向相反,同时有100+交易者→立即平仓。
5. Race Condition Prevention
5. 竞态条件预防
When ANY job closes a position → immediately:
- Set DSL state in
active: false(or DSL v5.3.1 auto-reconciles via clearinghouse)dsl/{strategyId}/{ASSET}.json - Alert user
- Evaluate: empty slot in that strategy for next signal?
当任何任务平仓后→立即执行:
- 在中设置DSL状态
dsl/{strategyId}/{ASSET}.json(或DSL v5.3.1通过清算所自动协调)active: false - 通知用户
- 评估:该策略是否有空余仓位用于下一个信号?
DSL v5.3.1 — Trailing Stop System
DSL v5.3.1 — 追踪止损系统
Uses the official DSL v5.3.1 skill at . See that skill's SKILL.md for full details.
/data/workspace/skills/dsl-dynamic-stop-loss/使用位于的官方DSL v5.3.1 skill。详细信息请参考该skill的SKILL.md。
/data/workspace/skills/dsl-dynamic-stop-loss/Phase 1 (Pre-Tier 1): Absolute floor (v0.1 tightened)
第一阶段(未达Tier 1):绝对止损线(v0.1收紧)
- LONG floor = — caps max loss at ~20% ROE (v0.1: was 0.03/~30%)
entry × (1 - 0.02/leverage) - SHORT floor =
entry × (1 + 0.02/leverage) - 2% retrace threshold, 3 consecutive breaches → close
- Max duration: 30 minutes (v0.1: was 90min — see Phase 1 Auto-Cut above)
- Green-in-10: If never positive ROE in 10min → floor tightens to 50% of original distance
- 做多止损线 = — 最大损失限制在约20% ROE(v0.1:原0.03/~30%)
entry × (1 - 0.02/leverage) - 做空止损线 =
entry × (1 + 0.02/leverage) - 2%回撤阈值,连续3次触发→平仓
- 最长持续时间:30分钟(v0.1:原90分钟——见上文第一阶段自动止损)
- 10分钟未盈利:若10分钟内从未实现正ROE→止损线收紧至原始距离的50%
Phase 2 (Tier 1+): 9-Tier Aggressive Trailing
第二阶段(Tier 1+):9层级激进追踪止损
| Tier | ROE Trigger | Lock % | Breaches |
|---|---|---|---|
| 1 | 5% | 2% | 2 |
| 2 | 10% | 5% | 2 |
| 3 | 20% | 14% | 2 |
| 4 | 30% | 24% | 2 |
| 5 | 40% | 34% | 1 |
| 6 | 50% | 44% | 1 |
| 7 | 65% | 56% | 1 |
| 8 | 80% | 72% | 1 |
| 9 | 100% | 90% | 1 |
Phase 2: 1.5% retrace threshold, 2 consecutive breaches required.
| 层级 | ROE触发阈值 | 锁定比例 | 连续触发次数 |
|---|---|---|---|
| 1 | 5% | 2% | 2 |
| 2 | 10% | 5% | 2 |
| 3 | 20% | 14% | 2 |
| 4 | 30% | 24% | 2 |
| 5 | 40% | 34% | 1 |
| 6 | 50% | 44% | 1 |
| 7 | 65% | 56% | 1 |
| 8 | 80% | 72% | 1 |
| 9 | 100% | 90% | 1 |
第二阶段:1.5%回撤阈值,需连续2次触发。
DSL v5.3.1 State Creation (on position entry)
DSL v5.3.1 状态创建(开仓时)
Create directory if needed. Write state file with ALL required fields:
dsl/{strategyId}/json
{
"active": true,
"asset": "ASSET",
"direction": "SHORT",
"leverage": 10,
"entryPrice": "<entry>",
"size": "<size>",
"wallet": "<strategy_wallet>",
"strategyId": "<strategy_uuid>",
"phase": 1,
"phase1": {
"retraceThreshold": 0.02,
"consecutiveBreachesRequired": 3,
"absoluteFloor": "<calculated>",
"hardTimeoutMin": 30,
"weakPeakCutMin": 15,
"deadWeightCutMin": 10,
"greenIn10TightenPct": 50
},
"greenIn10": false,
"score": "<entry_score>",
"isReentry": false,
"reentryOf": null,
"phase2TriggerTier": 0,
"phase2": {
"retraceThreshold": 0.015,
"consecutiveBreachesRequired": 2
},
"tiers": [
{"triggerPct": 5, "lockPct": 2},
{"triggerPct": 10, "lockPct": 5},
{"triggerPct": 20, "lockPct": 14},
{"triggerPct": 30, "lockPct": 24},
{"triggerPct": 40, "lockPct": 34},
{"triggerPct": 50, "lockPct": 44},
{"triggerPct": 65, "lockPct": 56},
{"triggerPct": 80, "lockPct": 72},
{"triggerPct": 100, "lockPct": 90}
],
"currentTierIndex": -1,
"tierFloorPrice": null,
"highWaterPrice": "<entryPrice>",
"floorPrice": "<absoluteFloor>",
"currentBreachCount": 0,
"createdAt": "<ISO 8601>"
}absoluteFloor: LONG: , SHORT: . Caps max loss at ~20% ROE (v0.1: tightened from 0.03/~30%).
entry × (1 - 0.02/leverage)entry × (1 + 0.02/leverage)Filename: Main dex: . XYZ dex: (colon → double-dash).
{ASSET}.jsonxyz--SYMBOL.json若需要则创建目录。写入包含所有必填字段的状态文件:
dsl/{strategyId}/json
{
"active": true,
"asset": "ASSET",
"direction": "SHORT",
"leverage": 10,
"entryPrice": "<entry>",
"size": "<size>",
"wallet": "<strategy_wallet>",
"strategyId": "<strategy_uuid>",
"phase": 1,
"phase1": {
"retraceThreshold": 0.02,
"consecutiveBreachesRequired": 3,
"absoluteFloor": "<calculated>",
"hardTimeoutMin": 30,
"weakPeakCutMin": 15,
"deadWeightCutMin": 10,
"greenIn10TightenPct": 50
},
"greenIn10": false,
"score": "<entry_score>",
"isReentry": false,
"reentryOf": null,
"phase2TriggerTier": 0,
"phase2": {
"retraceThreshold": 0.015,
"consecutiveBreachesRequired": 2
},
"tiers": [
{"triggerPct": 5, "lockPct": 2},
{"triggerPct": 10, "lockPct": 5},
{"triggerPct": 20, "lockPct": 14},
{"triggerPct": 30, "lockPct": 24},
{"triggerPct": 40, "lockPct": 34},
{"triggerPct": 50, "lockPct": 44},
{"triggerPct": 65, "lockPct": 56},
{"triggerPct": 80, "lockPct": 72},
{"triggerPct": 100, "lockPct": 90}
],
"currentTierIndex": -1,
"tierFloorPrice": null,
"highWaterPrice": "<entryPrice>",
"floorPrice": "<absoluteFloor>",
"currentBreachCount": 0,
"createdAt": "<ISO 8601>"
}absoluteFloor:做多:,做空:。最大损失限制在约20% ROE(v0.1:从0.03/~30%收紧)。
entry × (1 - 0.02/leverage)entry × (1 + 0.02/leverage)文件名:主DEX:。XYZ DEX:(冒号替换为双连字符)。
{ASSET}.jsonxyz--SYMBOL.jsonDSL v5.3.1 Cron Management
DSL v5.3.1 Cron管理
One cron per strategy. Created when first position opens. Removed on .
strategy_inactiveDSL_STATE_DIR=/data/workspace/dsl DSL_STRATEGY_ID={strategyId} PYTHONUNBUFFERED=1 python3 /data/workspace/skills/dsl-dynamic-stop-loss/scripts/dsl-v5.pySchedule: (every 3 min), isolated session, mid-tier model.
*/3 * * * *每个策略对应一个Cron任务。首次开仓时创建,策略停用()时删除。
strategy_inactiveDSL_STATE_DIR=/data/workspace/dsl DSL_STRATEGY_ID={strategyId} PYTHONUNBUFFERED=1 python3 /data/workspace/skills/dsl-dynamic-stop-loss/scripts/dsl-v5.py调度设置:(每3分钟一次),独立会话,Mid层级模型。
*/3 * * * *Opportunity Scanner v6
机会扫描器v6
4-stage funnel with 6 hard disqualifiers:
- Counter-trend on hourly (the "$346 lesson")
- Extreme RSI (<20 shorts, >80 longs)
- Counter-trend on 4h with strength >50
- Volume dying (<0.5x on both timeframes)
- Heavy unfavorable funding (>50% annualized)
- BTC macro headwind >30 points
Disqualified assets appear in output with and for transparency.
reasonwouldHaveScored包含6个硬性 disqualifier的4阶段漏斗:
- 小时级逆势交易(“346美元教训”)
- 极端RSI(做空<20,做多>80)
- 4小时逆势且强度>50
- 成交量低迷(两个时间框架均<0.5倍)
- 不利资金费率过高(年化>50%)
- BTC宏观阻力>30点
被 disqualify的资产会在输出中显示和字段以保证透明度。
reasonwouldHaveScoredBudget Scaling v7 — Tiered Margin System
预算缩放v7 — 分层保证金系统
v7 uses tiered margin based on entry count (not budget-based slots):
| Entry Count | Margin per Trade | Budget per Strategy | Leverage | Notes |
|---|---|---|---|---|
| 1-2 | $1,450 | $1,500 | 10x | Higher margin for early entries |
| 3-4 | $950 | $1,000 | 10x | Medium margin for mid entries |
| 5-6 | $450 | $500 | 10x | Lower margin for final entries |
Max entries per day: 6 (flat limit, no dynamic slots)
How it works:
- Scanner reads current entry count from
fox-trade-counter.json - Finds matching tier from array
marginTiers - Uses that tier's margin/budget for position sizing
Minimum leverage: 7x. If max leverage for an asset is below 7x, skip it.
Auto-Delever: If a strategy's account drops below its → reduce max slots by 1, close weakest in that strategy.
autoDeleverThresholdv7基于持仓数使用分层保证金(而非基于预算的动态仓位):
| 持仓数 | 每笔交易保证金 | 单策略预算 | 杠杆 | 说明 |
|---|---|---|---|---|
| 1-2 | 1450美元 | 1500美元 | 10倍 | 早期持仓使用更高保证金 |
| 3-4 | 950美元 | 1000美元 | 10倍 | 中期持仓使用中等保证金 |
| 5-6 | 450美元 | 500美元 | 10倍 | 后期持仓使用更低保证金 |
每日最大持仓数:6笔(固定限制,无动态仓位)
工作原理:
- 扫描器从读取当前持仓数
fox-trade-counter.json - 从数组中匹配对应层级
marginTiers - 使用该层级的保证金/预算进行仓位 sizing
最低杠杆:7倍。若资产的最大杠杆低于7倍,则跳过该资产。
自动降杠杆:若策略账户余额低于→最大仓位数减少1,平仓该策略中最弱的仓位。
autoDeleverThresholdRotation Rules
仓位轮换规则
When slots are full in a strategy and a new FIRST_JUMP or IMMEDIATE fires:
- Rotate if: new signal is FIRST_JUMP or has 3+ reasons + positive velocity AND weakest position in that strategy is flat/negative ROE with SM conv 0-1
- Hold if: current position in Tier 2+ or trending up with SM conv 3+
- Cross-strategy: If one strategy is full but another has slots, route to the available strategy instead of rotating
当策略仓位已满且新的FIRST_JUMP或IMMEDIATE信号触发时:
- 轮换条件:新信号为FIRST_JUMP,或者拥有3个以上理由+正速度,且该策略中最弱的仓位为持平/负ROE且SM信心度0-1
- 持有条件:当前仓位处于Tier 2+或趋势向上且SM信心度3+
- 跨策略路由:若一个策略仓位已满但另一个策略有空余仓位,则将信号路由至有空余仓位的策略而非轮换
Position Lifecycle
仓位生命周期
Opening
开仓
- Signal fires → validate checklist → route to best-fit strategy
- on that strategy's wallet (use
create_positionfor XYZ assets)leverageType: "ISOLATED" - Create DSL v5.3.1 state file in
dsl/{strategyId}/{ASSET}.json - Ensure DSL v5.3.1 cron exists for this strategy (create if first position)
- Update
fox-trade-counter.json - Alert user
- 信号触发→验证检查清单→路由至最佳匹配策略
- 在该策略的钱包上执行(XYZ资产使用
create_position)leverageType: "ISOLATED" - 在中创建DSL v5.3.1状态文件
dsl/{strategyId}/{ASSET}.json - 确保该策略的DSL v5.3.1 Cron任务存在(首次开仓时创建)
- 更新
fox-trade-counter.json - 通知用户
Closing
平仓
- Close via (or DSL v5.3.1 auto-closes on breach/SL hit)
close_position - DSL v5.3.1 script auto-deletes state file and reconciles via clearinghouse
- Alert user with strategy name for context
- On output → remove the DSL v5.3.1 cron for that strategy
strategy_inactive - Evaluate: empty slot in that strategy for next signal?
- Re-entry evaluation (v7.2): If closed from Phase 1, log exit details (asset, direction, exit price, ROE, exit time) for re-entry window tracking
- 通过平仓(或DSL v5.3.1在触发止损/止损线命中时自动平仓)
close_position - DSL v5.3.1脚本自动删除状态文件并通过清算所协调
- 通知用户并附上策略名称以提供上下文
- 当输出时→删除该策略的DSL v5.3.1 Cron任务
strategy_inactive - 评估:该策略是否有空余仓位用于下一个信号?
- 重新开仓评估(v7.2):若在第一阶段平仓,则记录平仓详情(资产、方向、平仓价、ROE、平仓时间)以追踪重新开仓窗口
Re-Entry (v7.2)
重新开仓(v7.2)
- Emerging Movers detects asset still in top 20 with same direction,
contribVelocity > 5 - Validate: within 2h of original exit, original loss ≤ 15% ROE, price moved further in original direction
- Score ≥ 5 pts (relaxed threshold — direction already validated)
- Size at 75% of normal margin tier
- Create DSL state with ,
isReentry: truereentryOf: "<original_trade_id>" - Alert user: "RE-ENTRY: {ASSET} {DIR} — direction confirmed, 2nd attempt at 75% size"
- 新兴行情扫描器检测到资产仍处于前20名且方向不变,
contribVelocity >5 - 验证:距原平仓时间不超过2小时,原损失≤15% ROE,价格沿原方向进一步变动
- 评分≥5分(门槛放宽——方向已被验证)
- 仓位规模为正常保证金层级的75%
- 创建DSL状态,设置、
isReentry: truereentryOf: "<original_trade_id>" - 通知用户:“RE-ENTRY: {ASSET} {DIR} — 方向已确认,第二次尝试使用75%仓位规模”
Margin Types
保证金类型
- Cross-margin for crypto (BTC, ETH, SOL, etc.)
- Isolated margin for XYZ DEX (GOLD, SILVER, TSLA, etc.) — set and
leverageType: "ISOLATED"dex: "xyz" - Same wallet holds both cross crypto + isolated XYZ side by side
- 跨保证金:用于加密货币(BTC、ETH、SOL等)
- 逐仓保证金:用于XYZ DEX(GOLD、SILVER、TSLA等)——设置和
leverageType: "ISOLATED"dex: "xyz" - 同一钱包可同时持有跨保证金加密货币仓位和逐仓保证金XYZ仓位
XYZ Equities
XYZ股票
- Ignore trader count. XYZ equities often have low SM trader counts — this doesn't invalidate the signal.
- Use reason count + rank velocity as primary quality filter instead.
- Always use isolated margin (,
leverageType: "ISOLATED").dex: "xyz" - Check max leverage — many XYZ assets cap at 5x or 3x. If below 7x, skip.
- 忽略交易者数量。XYZ股票的SM交易者数量通常较低——这不会 invalidate 信号。
- 使用理由数量+排名速度作为主要质量过滤器。
- 始终使用逐仓保证金(,
leverageType: "ISOLATED")。dex: "xyz" - 检查最大杠杆——许多XYZ资产的杠杆上限为5倍或3倍。若低于7倍,则跳过。
Token Optimization & Context Management
令牌优化与上下文管理
Model tiers: See Architecture table. Primary for main-session crons, Mid/Budget for isolated.
Heartbeat policy: If script output contains no actionable signals, output HEARTBEAT_OK immediately. Do not reason about what wasn't found.
Context isolation (multi-signal runs): Read ONCE per cron run. Build complete action plan before executing. Send ONE consolidated Telegram per run.
fox-strategies.jsonSkip rules: Skip redundant checks when data < 3 min old. If all slots full and no FIRST_JUMPs → skip scanner processing.
模型层级:见架构表。Main会话Cron任务使用Primary层级,独立会话任务使用Mid/Budget层级。
心跳策略:若脚本输出无 actionable 信号,立即输出HEARTBEAT_OK。无需解释未发现的内容。
上下文隔离(多信号运行):每次Cron运行时仅读取一次。在执行前构建完整的行动计划。每次运行仅发送一条整合的Telegram通知。
fox-strategies.json跳过规则:若数据不足3分钟,则跳过重复检查。若所有仓位已满且无FIRST_JUMP信号→跳过扫描器处理。
API Dependencies
API依赖
All MCP calls go through — no direct subprocess invocations. See references/api-tools.md for the full tool reference.
fox_config.mcporter_call()| Action | Tool | Used By |
|---|---|---|
| Create strategy wallet | | Setup |
| Fund wallet | | Setup |
| Open position | | Emerging Movers, Opp Scanner |
| Close position | | DSL v5.3.1, SM Flip, Watchdog |
| Sync stop loss to HL | | DSL v5.3.1 |
| Check positions/PnL | | Watchdog, Portfolio, Health Check |
| Check strategy status | | DSL v5.3.1 |
| Check open orders | | DSL v5.3.1 |
| Smart money data | | Emerging Movers, SM Flip, Opp Scanner |
| Top traders | | Opp Scanner |
| Asset candles | | Opp Scanner, Market Regime |
| Market prices | | DSL v5.3.1 |
| All instruments | | Opp Scanner, Setup |
Never use: (actually executes), (closes entire strategy irreversibly).
dryRun: truestrategy_close_strategy所有MCP调用均通过执行——无直接子进程调用。完整工具参考请见references/api-tools.md。
fox_config.mcporter_call()| 操作 | 工具 | 使用方 |
|---|---|---|
| 创建策略钱包 | | 设置脚本 |
| 钱包充值 | | 设置脚本 |
| 开仓 | | 新兴行情扫描器、机会扫描器 |
| 平仓 | | DSL v5.3.1、SM反转检测器、监控守护进程 |
| 同步止损线至HL | | DSL v5.3.1 |
| 检查仓位/PnL | | 监控守护进程、投资组合更新、健康检查 |
| 检查策略状态 | | DSL v5.3.1 |
| 检查挂单 | | DSL v5.3.1 |
| 智能资金数据 | | 新兴行情扫描器、SM反转检测器、机会扫描器 |
| 顶级交易者 | | 机会扫描器 |
| 资产K线 | | 机会扫描器、市场行情检测 |
| 市场价格 | | DSL v5.3.1 |
| 所有交易品种 | | 机会扫描器、设置脚本 |
禁止使用:(会实际执行)、(会不可逆地关闭整个策略)。
dryRun: truestrategy_close_strategyScripts Reference
脚本参考
| Script | Purpose |
|---|---|
| Setup wizard — adds strategy to registry from budget |
| Shared config loader — all Fox scripts import this |
| Emerging Movers v4 scanner (FIRST_JUMP, IMMEDIATE, CONTRIB_EXPLOSION) |
| SM conviction flip detector (multi-strategy) |
| Watchdog — per-strategy margin buffer + position health |
| Opportunity Scanner v6 (BTC macro, hourly trend, disqualifiers) |
| Per-strategy orphan DSL / state validation |
| Market regime detector |
| 脚本 | 用途 |
|---|---|
| 设置向导——从预算创建并添加策略至注册表 |
| 共享配置加载器——所有Fox脚本都会导入该模块 |
| 新兴行情扫描器v4(捕捉FIRST_JUMP、IMMEDIATE、CONTRIB_EXPLOSION信号) |
| SM信心度反转检测器(多策略) |
| 监控守护进程——单策略保证金缓冲+仓位健康检查 |
| 机会扫描器v6(BTC宏观环境、小时级趋势、disqualifier) |
| 单策略孤立DSL检查、状态验证 |
| 市场行情检测器 |
State Files Reference
状态文件参考
| File | Purpose |
|---|---|
| Strategy registry (wallets, budgets, DSL config) |
| Daily trade counter with tiered margin |
| Emerging movers scan history |
| Latest market regime (shared, read-only) |
| Per-asset max leverage (shared) |
| DSL v5.3.1 per-position state |
| Cross-scan momentum tracking |
| Scanner threshold overrides |
See references/state-schema.md for complete schemas.
| 文件 | 用途 |
|---|---|
| 策略注册表(钱包、预算、DSL配置) |
| 每日交易计数器,包含分层保证金信息 |
| 新兴行情扫描历史 |
| 最新市场行情(共享、只读) |
| 单资产最大杠杆(共享) |
| DSL v5.3.1单仓位状态 |
| 跨扫描动量跟踪 |
| 扫描器阈值覆盖配置 |
完整schema请参考references/state-schema.md。
Known Limitations
已知限制
- Watchdog blind spot for XYZ isolated: Can't see isolated position liquidation distances. XYZ positions rely on DSL.
- Health check only sees crypto wallet: Total equity may differ from actual.
- Scanner needs history for momentum: Cross-scan momentum requires at least 2 scans. First scan produces scored results without momentum data.
- 监控守护进程对XYZ逐仓的盲区:无法查看逐仓仓位的清算距离。XYZ仓位依赖DSL进行止损。
- 健康检查仅能查看加密货币钱包:总权益可能与实际不符。
- 扫描器需要历史数据来计算动量:跨扫描动量需要至少2次扫描数据。首次扫描会生成评分结果,但无动量数据。