{"id":"d8802470-5fad-4f0c-b600-d28f29296fa9","entityType":"agent","slug":"clawhub-sopaco-money-never-sleep","name":"money-never-sleep","canonicalUrl":"https://www.xpersona.co/agent/clawhub-sopaco-money-never-sleep","canonicalPath":"/agent/clawhub-sopaco-money-never-sleep","generatedAt":"2026-10-10T21:53:18.845Z","source":"CLAWHUB","claimStatus":"UNCLAIMED","verificationTier":"NONE","summary":{"evidence":{"source":"editorial-content","verified":true,"confidence":"high","updatedAt":"2026-10-10T17:42:02.110Z","emptyReason":null},"description":"MNS (Money Never Sleeps) CLI operations manual for autonomous agents. Tracks an investment portfolio in a local ledger, reads market sentiment (CNN Fear & Greed Index), and generates target-weight rebalancing suggestions. Use when the user asks to view holdings, record a trade they already executed, Skill: money-never-sleep Owner: sopaco Summary: MNS (Money Never Sleeps) CLI operations manual for autonomous agents. Tracks an investment portfolio in a local ledger, reads market sentiment (CNN Fear & Greed Index), and generates target-weight rebalancing suggestions. Use when the user asks to view holdings, record a trade they already executed, Tags: latest:0.6.0 Version history: v0.6.0 | 2026-07-31T15:47:05.459Z |","descriptionLabel":"Technical summary","evidenceSummary":"Capability contract not published. No trust telemetry is available yet. 1.3K downloads reported by the source. Last updated 10/10/2026.","installCommand":"clawhub skill install s17a75kt8fank19t6971cm2bs583jz3w:money-never-sleep","sourceUrl":"https://clawhub.ai/sopaco/money-never-sleep","homepage":"https://clawhub.ai/sopaco/skills/money-never-sleep","primaryLinks":[{"label":"View on ClawHub","url":"https://clawhub.ai/sopaco/money-never-sleep","kind":"source"},{"label":"Homepage","url":"https://clawhub.ai/sopaco/skills/money-never-sleep","kind":"homepage"}],"safetyScore":84,"overallRank":62,"popularityScore":62,"trustScore":null,"claimedByName":null,"isOwner":false,"seoDescription":"MNS (Money Never Sleeps) CLI operations manual for autonomous agents. Tracks an investment portfolio in a local ledger, reads market sentiment (CNN Fear & Greed"},"coverage":{"evidence":{"source":"public-profile","verified":false,"confidence":"medium","updatedAt":"2026-10-10T17:42:02.110Z","emptyReason":null},"protocols":[{"protocol":"OPENCLEW","label":"OpenClaw","status":"self-declared","notes":"Declared in the public agent profile."}],"capabilities":[],"verifiedCount":0,"selfDeclaredCount":1,"capabilityMatrix":{"rows":[{"key":"OPENCLEW","type":"protocol","support":"unknown","confidenceSource":"profile","notes":"Listed on profile"}],"flattenedTokens":"protocol:OPENCLEW|unknown|profile"}},"adoption":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"medium","updatedAt":"2026-10-10T17:42:02.110Z","emptyReason":null},"stars":null,"forks":null,"downloads":1313,"packageName":null,"latestVersion":"0.6.0","tractionLabel":"1.3K downloads"},"release":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"medium","updatedAt":"2026-10-10T17:42:02.110Z","emptyReason":null},"lastUpdatedAt":"2026-10-10T17:42:02.110Z","lastCrawledAt":"2026-10-10T17:42:02.110Z","lastIndexedAt":null,"nextCrawlAt":"2026-10-11T17:42:02.110Z","lastVerifiedAt":null,"highlights":[{"version":"0.6.0","createdAt":"2026-07-31T15:47:05.459Z","changelog":"**Summary:** Major refactor with documentation overhaul, clarified positioning, and removed auxiliary reference files. - Fully rewrote documentation to prioritize correct usage, strict bookkeeping, and risk of silent data corruption. - Clearly distinguishes between trade recording (bookkeeping) and report suggestions. - Updated all command examples, usage flows, error cases, and troubleshooting to match rewritten skill and recent CLI refactoring. - Changed installation instructions to emphasize single static binary (Rust), with no runtime dependencies. - Removed auxiliary files: references/commands.md, references/strategy.md, and skill-card.md. All core usage is now in SKILL.md.","fileCount":3,"zipByteSize":8128},{"version":"0.5.10","createdAt":"2026-04-23T09:47:21.761Z","changelog":"- Removed example data files: assets/examples/portfolio-example.json and report-example.json. - Updated strategy documentation in SKILL.md, including new buy/sell matrix ranges, thresholds, and advanced agent workflow guidance. - Added sections on industry/portfolio risk analysis for agent workflows. - No breaking changes to core functionality; documentation and sample data cleanup only.","fileCount":5,"zipByteSize":17057},{"version":"0.5.8","createdAt":"2026-04-21T13:40:51.948Z","changelog":"money-never-sleep 0.5.8 - Version bump from 0.5.7 to 0.5.8. - No changes detected in source files or documentation content.","fileCount":6,"zipByteSize":16544},{"version":"0.5.7","createdAt":"2026-04-21T09:26:59.121Z","changelog":"Version 0.5.7 - Added strategy backtesting (回测策略) functionality, allowing users to test and compare configurations using historical data. - Enhanced price update capabilities: now supports both manual and automatic (online) price updates for assets. - Expanded configuration management and sell ratio matrix for more flexible portfolio strategies. - Updated documentation with new workflows, improved configuration parameter explanations, and detailed usage guidance. - Various clarifications and workflow improvements for daily operations and risk warning mechanisms.","fileCount":6,"zipByteSize":16544},{"version":"0.5.4","createdAt":"2026-04-20T07:45:46.137Z","changelog":"Version 0.5.4 Changelog - Updated compatibility: now requires Node.js 18+ or Bun. - Modernized Openclaw metadata format, specifying supported platforms and binaries. - Simplified security and compatibility notes. - Improved documentation structure; redundant and detailed content reduced for clarity. - No changes to program code or CLI functions—documentation and metadata only.","fileCount":6,"zipByteSize":15833},{"version":"0.5.3","createdAt":"2026-04-20T07:09:43.704Z","changelog":"- Now explicitly states that the CLI does not execute real trades or connect to broker APIs; all trading actions must be performed manually and recorded in the tool. - Clarified \"交易记录\" (trade recording) replaces \"交易执行\" (trade execution) in skill description and documentation. - Added \"ClawHub Security Verified\" certification, with details about safety, local data storage, and open-source transparency. - Expanded skill triggers and improved language around configuration/reset warnings for storage initialization. - Updated metadata: new version number, added security and source code fields.","fileCount":6,"zipByteSize":17317},{"version":"0.5.2","createdAt":"2026-04-20T06:48:42.117Z","changelog":"- Removed 5 files, including README.md, package.json, and all scripts in the scripts/ directory. - Updated installation and usage documentation to reflect the new unified CLI: now use npm install -g @never-sleeps/mns-cli and the mns command. - Removed references to platform-specific binaries and npx usage in documentation. - Documentation now highlights simplified setup and command usage. - Auxiliary script explanations were removed alongside the script files.","fileCount":6,"zipByteSize":16488},{"version":"0.5.1","createdAt":"2026-04-20T04:45:41.554Z","changelog":"- CLI 二进制包的 npm 包名由 `@mns/cli-*` 统一变更为 `@never-sleeps/cli-*`，影响了所有使用示例和初始化命令。 - 快速开始、操作示例和工作流说明中的所有 CLI 调用命令已同步替换为新包名（如 `npx @never-sleeps/cli-darwin-arm64 ...`）。 - 其余功能、策略说明和扩展建议内容保持不变。","fileCount":11,"zipByteSize":20918}]},"execution":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No published capability contract is available yet."},"installCommand":"clawhub skill install s17a75kt8fank19t6971cm2bs583jz3w:money-never-sleep","setupComplexity":"low","setupSteps":["Setup complexity is classified as HIGH. You must provision dedicated cloud infrastructure or an isolated VM. Do not run this directly on your local workstation.","Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data."],"contract":{"contractStatus":"missing","authModes":[],"requires":[],"forbidden":[],"supportsMcp":false,"supportsA2a":false,"supportsStreaming":false,"inputSchemaRef":null,"outputSchemaRef":null,"dataRegion":null,"contractUpdatedAt":null,"sourceUpdatedAt":null,"freshnessSeconds":null},"invocationGuide":{"preferredApi":{"snapshotUrl":"https://www.xpersona.co/api/v1/agents/clawhub-sopaco-money-never-sleep/snapshot","contractUrl":"https://www.xpersona.co/api/v1/agents/clawhub-sopaco-money-never-sleep/contract","trustUrl":"https://www.xpersona.co/api/v1/agents/clawhub-sopaco-money-never-sleep/trust"},"curlExamples":["curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-sopaco-money-never-sleep/snapshot\"","curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-sopaco-money-never-sleep/contract\"","curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-sopaco-money-never-sleep/trust\""],"jsonRequestTemplate":{"query":"summarize this repo","constraints":{"maxLatencyMs":2000,"protocolPreference":["OPENCLEW"]}},"jsonResponseTemplate":{"ok":true,"result":{"summary":"...","confidence":0.9},"meta":{"source":"CLAWHUB","generatedAt":"2026-10-10T21:53:18.842Z"}},"retryPolicy":{"maxAttempts":3,"backoffMs":[500,1500,3500],"retryableConditions":["HTTP_429","HTTP_503","NETWORK_TIMEOUT"]}},"endpoints":{"dossierUrl":"https://www.xpersona.co/api/v1/agents/clawhub-sopaco-money-never-sleep/dossier","snapshotUrl":"https://www.xpersona.co/api/v1/agents/clawhub-sopaco-money-never-sleep/snapshot","contractUrl":"https://www.xpersona.co/api/v1/agents/clawhub-sopaco-money-never-sleep/contract","trustUrl":"https://www.xpersona.co/api/v1/agents/clawhub-sopaco-money-never-sleep/trust"}},"reliability":{"evidence":{"source":"runtime-metrics","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No trust, reliability, or runtime telemetry is available."},"trust":{"status":"unavailable","handshakeStatus":"UNKNOWN","verificationFreshnessHours":null,"reputationScore":null,"p95LatencyMs":null,"successRate30d":null,"fallbackRate":null,"attempts30d":null,"trustUpdatedAt":null,"trustConfidence":"unknown","sourceUpdatedAt":null,"freshnessSeconds":null},"decisionGuardrails":{"doNotUseIf":["Contract metadata is missing or unavailable for deterministic execution."],"safeUseWhen":[],"riskFlags":["missing_or_unavailable_contract","trust_data_unavailable","schema_references_missing"],"operationalConfidence":"low"},"executionMetrics":{"observedLatencyMsP50":null,"observedLatencyMsP95":null,"estimatedCostUsd":null,"uptime30d":null,"rateLimitRpm":null,"rateLimitBurst":null,"lastVerifiedAt":null,"verificationSource":null},"runtimeMetrics":{"successRate":null,"avgLatencyMs":null,"avgCostUsd":null,"hallucinationRate":null,"retryRate":null,"disputeRate":null,"p50Latency":null,"p95Latency":null,"lastUpdated":null}},"benchmarks":{"evidence":{"source":"no-benchmark-data","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No benchmark suites or observed failure patterns are available."},"suites":[],"failurePatterns":[]},"artifacts":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"high","updatedAt":"2026-10-10T17:42:02.110Z","emptyReason":null},"readme":"Skill: money-never-sleep\n\nOwner: sopaco\n\nSummary: MNS (Money Never Sleeps) CLI operations manual for autonomous agents. Tracks an investment\nportfolio in a local ledger, reads market sentiment (CNN Fear & Greed Index), and generates\ntarget-weight rebalancing suggestions. Use when the user asks to view holdings, record a\ntrade they already executed,\n\nTags: latest:0.6.0\n\nVersion history:\n\nv0.6.0 | 2026-07-31T15:47:05.459Z | user\n\n**Summary:** Major refactor with documentation overhaul, clarified positioning, and removed auxiliary reference files.\n\n- Fully rewrote documentation to prioritize correct usage, strict bookkeeping, and risk of silent data corruption.\n- Clearly distinguishes between trade recording (bookkeeping) and report suggestions.\n- Updated all command examples, usage flows, error cases, and troubleshooting to match rewritten skill and recent CLI refactoring.\n- Changed installation instructions to emphasize single static binary (Rust), with no runtime dependencies.\n- Removed auxiliary files: references/commands.md, references/strategy.md, and skill-card.md. All core usage is now in SKILL.md.\n\nv0.5.10 | 2026-04-23T09:47:21.761Z | user\n\n- Removed example data files: assets/examples/portfolio-example.json and report-example.json.\n- Updated strategy documentation in SKILL.md, including new buy/sell matrix ranges, thresholds, and advanced agent workflow guidance.\n- Added sections on industry/portfolio risk analysis for agent workflows.\n- No breaking changes to core functionality; documentation and sample data cleanup only.\n\nv0.5.8 | 2026-04-21T13:40:51.948Z | user\n\nmoney-never-sleep 0.5.8\n\n- Version bump from 0.5.7 to 0.5.8.\n- No changes detected in source files or documentation content.\n\nv0.5.7 | 2026-04-21T09:26:59.121Z | user\n\nVersion 0.5.7\n\n- Added strategy backtesting (回测策略) functionality, allowing users to test and compare configurations using historical data.\n- Enhanced price update capabilities: now supports both manual and automatic (online) price updates for assets.\n- Expanded configuration management and sell ratio matrix for more flexible portfolio strategies.\n- Updated documentation with new workflows, improved configuration parameter explanations, and detailed usage guidance.\n- Various clarifications and workflow improvements for daily operations and risk warning mechanisms.\n\nv0.5.4 | 2026-04-20T07:45:46.137Z | user\n\nVersion 0.5.4 Changelog\n\n- Updated compatibility: now requires Node.js 18+ or Bun.\n- Modernized Openclaw metadata format, specifying supported platforms and binaries.\n- Simplified security and compatibility notes.\n- Improved documentation structure; redundant and detailed content reduced for clarity.\n- No changes to program code or CLI functions—documentation and metadata only.\n\nv0.5.3 | 2026-04-20T07:09:43.704Z | user\n\n- Now explicitly states that the CLI does not execute real trades or connect to broker APIs; all trading actions must be performed manually and recorded in the tool.\n- Clarified \"交易记录\" (trade recording) replaces \"交易执行\" (trade execution) in skill description and documentation.\n- Added \"ClawHub Security Verified\" certification, with details about safety, local data storage, and open-source transparency.\n- Expanded skill triggers and improved language around configuration/reset warnings for storage initialization.\n- Updated metadata: new version number, added security and source code fields.\n\nv0.5.2 | 2026-04-20T06:48:42.117Z | user\n\n- Removed 5 files, including README.md, package.json, and all scripts in the scripts/ directory.\n- Updated installation and usage documentation to reflect the new unified CLI: now use npm install -g @never-sleeps/mns-cli and the mns command.\n- Removed references to platform-specific binaries and npx usage in documentation.\n- Documentation now highlights simplified setup and command usage.\n- Auxiliary script explanations were removed alongside the script files.\n\nv0.5.1 | 2026-04-20T04:45:41.554Z | user\n\n- CLI 二进制包的 npm 包名由 `@mns/cli-*` 统一变更为 `@never-sleeps/cli-*`，影响了所有使用示例和初始化命令。\n- 快速开始、操作示例和工作流说明中的所有 CLI 调用命令已同步替换为新包名（如 `npx @never-sleeps/cli-darwin-arm64 ...`）。\n- 其余功能、策略说明和扩展建议内容保持不变。\n\nv0.5.0 | 2026-04-20T03:54:20.357Z | user\n\nInitial release of money-never-sleep skill:\n\n- Provides CLI tools for investment portfolio management and automated contrarian strategy execution.\n- Integrates CNN Fear & Greed Index for market sentiment analysis and buy/sell decision-making.\n- Supports daily report generation, trading record-keeping, and cash/position updates.\n- Offers configuration management for strategy parameters and detailed error handling advice.\n- Compatible with Node.js, available as prebuilt binaries for major platforms, and uses a local SQLite database for data storage.\n\nArchive index:\n\nArchive v0.6.0: 3 files, 8128 bytes\n\nFiles: skill-card.md (2533b), SKILL.md (12614b), _meta.json (136b)\n\nFile v0.6.0:SKILL.md\n\n---\nname: money-never-sleep\nversion: 0.6.0\ndescription: |\n  MNS (Money Never Sleeps) CLI operations manual for autonomous agents. Tracks an investment\n  portfolio in a local ledger, reads market sentiment (CNN Fear & Greed Index), and generates\n  target-weight rebalancing suggestions. Use when the user asks to view holdings, record a\n  trade they already executed, generate a daily strategy report, inspect or tune strategy\n  parameters, or run a backtest.\n\n  CRITICAL: MNS connects to NO broker and executes NO trades. `mns buy` / `mns sell` are\n  bookkeeping entries that record trades the human has ALREADY executed elsewhere. Never call\n  them to \"act on\" a suggestion — doing so silently corrupts every downstream number.\n\n  Triggers: \"查看持仓\", \"记录买入\", \"记录卖出\", \"生成策略报告\", \"调仓建议\", \"再平衡\",\n  \"恐贪指数\", \"更新价格\", \"现金余额\", \"交易历史\", \"回测策略\", \"调整策略参数\", \"MNS\"\nlicense: MIT\ncompatibility: Single static binary (Rust). No runtime dependencies.\nmetadata:\n  {\n    \"openclaw\":\n      {\n        \"source\": \"https://github.com/sopaco/money-never-sleep\",\n        \"homepage\": \"https://github.com/sopaco/money-never-sleep\",\n        \"author\": \"Sopaco\",\n        \"os\": [\"darwin\", \"linux\", \"win32\"]\n      }\n  }\n---\n\n# MNS 操作手册（面向 Agent）\n\n## 0. 先读这三条硬约束\n\n**① `mns buy` / `mns sell` 是记账，不是下单。**\nMNS 不连接任何券商。这两个命令的唯一用途是把**用户已经在券商完成的**交易登记进本地账本。\n\n- ✅ 用户说\"我刚买了 100 份 QQQ，成交价 450\" → `mns buy QQQ 100 450`\n- ❌ `mns report` 建议买入 ¥2000 → **不要**据此调用 `mns buy`\n\n记入一笔并未真实发生的交易，会同时污染现金余额、成本价、持有天数、收益率和后续所有调仓建议，且没有撤销命令。**不确定用户是否真的成交过，就先问。**\n\n**② 建议不是投资建议。**\n`mns report` 的输出是规则引擎的机械计算结果。向用户转述时要说明它来自什么规则，不要包装成推荐意见，也不要替用户做买卖决定。用户自己的判断和持牌顾问才是决策来源。\n\n**③ 数字只能来自命令输出。**\n不要凭记忆或推算填写价格、份额、收益率。拿不到数据就说拿不到——不要编。\n\n---\n\n## 1. 安装与可用性检查\n\n**执行任何操作前，先判断 `mns` 是否已安装可用，不要重复安装。**\n\n```bash\nmns --version\n```\n\n- 输出正常版本号 → 已安装，直接跳到第 2 节使用即可。\n- 报 `command not found` / 找不到命令 → 执行下方安装步骤。\n\n**通过 npm 安装**（会按当前系统自动拉取对应平台的预编译二进制，支持 macOS Apple Silicon / Linux x64 / Windows x64）：\n\n```bash\nnpm install -g @never-sleeps/mns-cli\n```\n\n安装完成后重新执行 `mns --version` 复核。若已执行过安装且 `mns --version` 仍失败，说明是 PATH 未生效或当前平台/架构暂无预编译包，直接向用户反馈原因即可，**不要**反复重跑安装命令。\n\n---\n\n## 2. 命令速查（语法已逐条实测）\n\n| 命令 | 作用 | 备注 |\n|---|---|---|\n| `mns init` | 初始化配置与数据库 | **会清空既有数据**，有确认提示；`--force` 跳过确认 |\n| `mns cash` | 查看现金余额 | |\n| `mns cash set <金额>` | 设为指定余额 | 覆盖式 |\n| `mns cash add <金额>` | 增加现金（注资） | 金额须为正 |\n| `mns portfolio` | 持仓概览（份额/成本/现价/市值/收益） | 只读，最常用 |\n| `mns add <代码> <名称> <类别>` | 把标的加入持仓池（份额为0） | 类别只能是 `us_stocks` / `cn_stocks` / `counter_cyclical` |\n| `mns buy <代码> <份额> <价格>` | **登记**已成交买入 | 现金不足会报错；须先 `add` |\n| `mns sell <代码> <份额> <价格>` | **登记**已成交卖出 | 份额超出持有量会报错 |\n| `mns price <代码> [价格]` | 省略价格=查看；带价格=手工更新 | |\n| `mns update-prices` | 自动抓取全部持仓现价 | 需要网络；单个失败会跳过并继续 |\n| `mns remove <代码>` | 从持仓池删除标的 | 不可逆，先与用户确认 |\n| `mns sentiment` | 当前恐贪指数 | 需要网络 |\n| `mns report` | 生成今日调仓报告并存盘 | 需要网络；同时写入 `reports/YYYY-MM-DD.txt` |\n| `mns history [条数]` | 交易历史，默认 20 条 | **位置参数**，不是 `--limit` |\n| `mns config` | 打印全部配置 | |\n| `mns config <键>` | 读单项 | 必须是完整叶子键 |\n| `mns config <键> <值>` | 改单项 | 校验不通过则拒绝写入，原配置不变 |\n| `mns backtest` | 四种策略对比回测 | 纯离线，不碰账本 |\n| `mns backtest validate` | 样本外验证 + 收益分布 | `--iterations` / `--block` 可调 |\n| `mns backtest params` | 列出可调参数及默认值 | 忘记键名时先跑这个 |\n| `mns market` / `mns market-indices` / `mns analyze <代码>` | 全球指数 / 个股报价 | 依赖 Yahoo，**部分网络环境不可用**，见 §7 |\n\n数据位置：配置 `~/.mns/config.toml`，账本 `~/.mns/mns.db`，报告 `./reports/`。\n\n---\n\n## 3. Agent 需要理解的最小策略模型\n\n不需要了解内部实现，只需理解这一句：**策略回答的是\"现在应该持有多少\"，而不是\"现在该花掉多少钱\"。**\n\n1. 恐贪指数落入某个情绪区间 → 得出**风险资产目标总权重**（越恐慌越高）\n2. 该权重按资产配置比例拆到三条腿（美股/A股/逆周期）\n3. 每条腿把**实际权重**与**目标权重**比较\n4. 偏离超过**偏离带**（默认 4 个百分点）才建议动作，且只补到目标为止\n5. 偏离在带内 → **不动作，这是正常状态**\n\n默认目标权重曲线（`mns config target_weight.*` 可调）：\n\n| 情绪 | 指数范围 | 风险资产目标权重 |\n|---|---|---|\n| 极度恐慌 | < 30 | 85% |\n| 恐慌 | 30–45 | 75% |\n| 中性 | 45–55 | 60% |\n| 贪婪 | 55–70 | 45% |\n| 极度贪婪 | ≥ 70 | 35% |\n\n两条 agent 容易误判的规则：\n\n- **\"今日无需调仓\"是健康输出，不是故障。** 中长线框架下多数月份都不该有动作。不要因为没有建议就反复重跑，也不要去调窄偏离带来\"制造\"建议。\n- **卖出有最短持有天数限制**（默认 30 天）。报告可能显示\"需减仓但持仓未满 N 天\"，这是刻意规避国内基金惩罚性赎回费，不是 bug。\n\n---\n\n## 4. 标准工作流\n\n### 4.1 每日/每周例行\n\n```bash\nmns update-prices   # 先刷新价格，否则报告基于过期价格\nmns report          # 生成调仓报告\n```\n\n向用户汇报时应包含：当前恐贪指数与区间、风险资产目标 vs 实际权重、每条腿的建议动作（或不动作的原因）、净操作方向。若某腿建议为\"不动作\"，把原因一并说明。\n\n### 4.2 用户已成交，登记入账\n\n```bash\n# 用户：\"我在券商买了 300 份 018966，成交价 1.52\"\nmns buy 018966 300 1.52\nmns portfolio            # 复核登记结果\n```\n\n登记前确认三件事：标的是否已 `add` 过、份额与价格是否为**实际成交值**（不是建议值）、现金余额是否够（不够会报错）。\n\n### 4.3 新增标的建仓\n\n```bash\nmns add 518880 \"黄金ETF华安\" counter_cyclical   # 先入池\nmns buy 518880 1000 8.38                        # 再登记已成交买入\n```\n\n### 4.4 参数调整\n\n```bash\nmns backtest params                    # 先查键名与默认值\nmns config rebalance.band_pp           # 读当前值\nmns config rebalance.band_pp 6         # 改（校验不通过会拒绝）\nmns backtest                           # 改完跑回测看影响\n```\n\n改参数前先告知用户当前值和预期影响；参数变化会直接改变后续所有建议。\n\n### 4.5 首次初始化（危险）\n\n```bash\nmns init            # 若已有数据会提示确认\nmns cash set 100000\n```\n\n`mns init` 会**删除既有数据库**。只在用户明确要求全新开始时调用，且**永远不要**加 `--force`，除非用户明确说了\"强制覆盖/不用问我\"。\n\n---\n\n## 5. 如何读 `mns report` 的输出\n\n报告固定含以下章节，可按 `【章节名】` 定位：\n\n| 章节 | 内容 | agent 用法 |\n|---|---|---|\n| `【市场情绪】` | 恐贪指数 + 前日/周/月/年同比 | 判断情绪所处区间与变化方向 |\n| `【账户概览】` | 现金、持仓市值、总资产、持仓明细表 | 核对账本状态 |\n| `【调仓计划】` | 目标/当前/偏离 + 每腿建议，含标的级分摊 | **核心结论来源** |\n| `【净操作指引】` | 净买入/净卖出/持仓不动 | 一句话总结 |\n| `【目标仓位预案】` | 各情绪区间下的目标权重与对应金额 | 回答\"如果继续跌该买多少\" |\n| `【信号口径】` | 当前由哪个信号驱动及其局限 | 转述结论时必须带上的限定 |\n\n报告已同时写入 `reports/YYYY-MM-DD.txt`，需要复述历史结论时读文件，不要重跑（重跑会得到不同时点的指数）。\n\n---\n\n## 6. 转述效果时必须带上的限定\n\n用户问\"这个策略行不行\"时，不要只报有利数字。仓库内经修正数据（真实全收益、计入交易成本与赎回费）的回测结论是：\n\n- **买入持有在收益上领先**（年化约 14.6% vs 12.8%）。本工具不能宣称提高收益。\n- 优势只在**风险调整后**成立：最大回撤约 10.9% vs 14.9%，Calmar 1.17 vs 0.98。\n- **恐贪指数的边际贡献接近于零**——加入趋势锚后，带情绪倾斜与不带几乎无差别。\n- **2000–2002、2008 等长期熊市未被数据覆盖**，而\"熊市回撤保护\"正是该策略的主要卖点，该卖点尚未经检验。\n- 回测区间是美股强牛市 + 长期低利率，结论不应外推到其他环境。\n\n跑 `mns backtest` / `mns backtest validate` 可复现上述数字。**不要**把回测年化当作对未来收益的预期转述给用户。\n\n---\n\n## 7. 故障模式与处理\n\n| 现象 | 原因 | 处理 |\n|---|---|---|\n| `mns report` / `sentiment` 失败 | CNN 接口需要网络，且可能反爬返回 418 | 内置重试；仍失败则告知用户拿不到实时情绪，**不要**用旧指数假装是今天的 |\n| `mns market` / `analyze` 全部失败，报 HTTP 403 | 部分网络环境完全拦截 Yahoo Finance | 属环境限制，非配置问题。告知用户需代理；`update-prices` 的**国内基金**部分仍可用 |\n| `update-prices` 个别标的被跳过 | 该代码在数据源无对应数据（如特殊 QDII） | 用 `mns price <代码> <价格>` 手工补 |\n| `Error: 现金余额不足` | 登记买入金额超过账面现金 | 多为漏记注资，先 `mns cash add`，或核对成交金额 |\n| `Error: 卖出份额超出持有量` | 份额记错，或漏记了此前买入 | 用 `mns portfolio` / `mns history` 核对 |\n| `Error: 未知的配置项: buy_ratio` | 只能读写完整叶子键 | 用 `mns config buy_ratio.extreme_fear`；或 `mns config` 看全量 |\n| `Error: 情绪阈值必须满足单调递增` / `target_weight 必须随情绪升高而单调不增` | 参数值违反策略内在约束 | 校验已拒绝写入，原配置完好。按提示改成合法值 |\n| 中文输出乱码（Windows） | PowerShell 默认 GBK | 切 UTF-8 终端，或重定向到文件再读 |\n| 数据库被锁 | 多进程并发写 SQLite | **串行调用**，不要并发跑多个 mns 命令 |\n\n错误一律以非零退出码 + `Error: <中文原因>` 形式返回，原因可直接转述给用户。\n\n---\n\n## 8. 常见错误用法（明确不要这么做）\n\n| ❌ 错误 | ✅ 正确 |\n|---|---|\n| `mns history --limit 50` | `mns history 50`（位置参数） |\n| `mns config buy_ratio` | `mns config buy_ratio.fear`（叶子键） |\n| 看到建议就 `mns buy` 落账 | 只登记用户**实际已成交**的交易 |\n| 报告无建议就反复重跑 | \"不动作\"是正常结论，直接如实汇报 |\n| 为了产出建议而调窄 `band_pp` | 参数调整需用户同意，且要说明影响 |\n| `mns init --force` 图省事 | 除用户明确授权外不加 `--force` |\n| 并发跑多个 mns 命令 | 串行执行 |\n| 把回测年化当预期收益转述 | 带上 §6 的全部限定 |\n\n---\n\n## 9. 快速自检\n\n不确定环境是否可用时，按序执行（全部只读，不改数据）：\n\n```bash\nmns --version        # 二进制可用\nmns config           # 配置可加载（旧配置缺新字段会自动取默认值）\nmns portfolio        # 账本可读\nmns sentiment        # 网络与 CNN 接口可用\nmns backtest params  # 参数键名参考\n```\n\nFile v0.6.0:_meta.json\n\n{\n  \"ownerId\": \"kn7a2vy7ys7aj3gzm2vvw7zc158311b2\",\n  \"slug\": \"money-never-sleep\",\n  \"version\": \"0.6.0\",\n  \"publishedAt\": 1785512825459\n}\n\nFile v0.6.0:skill-card.md\n\n## Description:\n\nMNS (Money Never Sleeps) is a CLI operations manual that guides agents through local portfolio ledger review, already-executed trade recording, market sentiment checks, target-weight rebalancing reports, strategy parameter inspection, and backtesting.\n\nThis skill is ready for commercial/non-commercial use.\n\n## Publisher:\n\n[sopaco](https://clawhub.ai/user/sopaco)\n\n### License/Terms of Use:\n\nMIT-0\n\n## Use Case:\n\nExternal users and agents use this skill to operate the MNS CLI for local portfolio bookkeeping, daily or weekly strategy reporting, manual price and configuration workflows, and backtest review. The skill is for recording user-confirmed transactions and explaining rule-based outputs, not for executing broker trades or making investment decisions.\n\n### Deployment Geography for Use:\n\nGlobal\n\n## Known Risks and Mitigations:\n\nRisk: The skill asks agents to install and run an unpinned third-party npm package.\n\nMitigation: Review the npm package and publisher before installation, prefer a pinned audited version, and run it in an isolated environment when possible.\n\nRisk: The CLI can mutate local financial ledger records, including recording trades and resetting data.\n\nMitigation: Only record trades or reset data after explicit user confirmation of the real-world transaction or destructive action.\n\nRisk: Rule-based rebalancing reports may be mistaken for investment advice.\n\nMitigation: Present reports as mechanical calculations, avoid making buy or sell decisions for the user, and preserve the skill's stated limitations.\n\n## Reference(s):\n\n- [ClawHub skill page](https://clawhub.ai/sopaco/skills/money-never-sleep)\n- [Project homepage](https://github.com/sopaco/money-never-sleep)\n- [OpenClaw source link](https://github.com/sopaco/money-never-sleep)\n\n## Skill Output:\n\n**Output Type(s):** [text, markdown, shell commands, configuration, guidance]\n\n**Output Format:** [Markdown guidance with inline shell commands and command-output summaries]\n\n**Output Parameters:** [1D]\n\n**Other Properties Related to Output:** [Outputs should distinguish bookkeeping from investment advice and use command output as the source for portfolio figures.]\n\n## Skill Version(s):\n\n0.6.0 (source: server release evidence and skill frontmatter)\n\n## Ethical Considerations:\n\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.\n\nArchive v0.5.10: 5 files, 17057 bytes\n\nFiles: references/commands.md (17197b), references/strategy.md (11692b), skill-card.md (2896b), SKILL.md (11458b), _meta.json (137b)\n\nFile v0.5.10:SKILL.md\n\n---\nname: money-never-sleep\nversion: 0.5.10\ndescription: |\n  MNS (Money Never Sleep, Market Neutral Strategist) CLI skill for autonomous agents. Provides investment\n  portfolio tracking, market sentiment analysis using CNN Fear & Greed Index, and strategy\n  suggestion report generation. Use when managing a contrarian investment portfolio,\n  generating buy/sell suggestions based on market sentiment thresholds, or producing\n  daily strategy reports.\n\n  NOTE: This tool provides strategy suggestions only - it does NOT connect to any broker APIs\n  or execute actual trades. All trades must be manually executed by users on their brokerage platforms\n  and then recorded via CLI commands.\n\n  Triggers include: \"管理投资组合\", \"生成策略建议\", \"获取市场报告\", \"查看持仓收益\",\n  \"更新现金余额\", \"记录买入卖出\", \"查看恐贪指数\", \"投资组合再平衡\", \"MNS 报告\", \"回测策略\"\nlicense: MIT\ncompatibility: Requires Node.js 18+ or Bun.\nmetadata:\n  {\n    \"openclaw\":\n      {\n        \"requires\": { \"anyBins\": [\"npx\", \"bunx\", \"npm\", \"bun\"] },\n        \"source\": \"https://github.com/sopaco/money-never-sleep\",\n        \"homepage\": \"https://github.com/sopaco/money-never-sleep\",\n        \"author\": \"Sopaco\",\n        \"os\": [\"darwin\", \"linux\", \"win32\"]\n      }\n  }\n  \n---\n\n# MNS CLI 投资管理 Skill\n\n## 概述\n\n本 skill 提供 MNS 逆向投资策略的 CLI 操作能力。MNS 是基于 CNN Fear & Greed Index 情绪指标的量化投资工具，通过 contrarian 策略在情绪极度恐慌时买入，极度贪婪时卖出，实现市场中性风格的长期投资。\n\n### 安全声明\n\n> - **源码公开**: 所有源码公开托管于 [GitHub](https://github.com/sopaco/money-never-sleep)\n> - **无网络交易**: 不连接任何券商 API，所有数据存储在本地 SQLite 数据库\n> - **无敏感权限**: 无需使用也不自动读取用户任何金融账户配置\n\n## 核心能力\n\n1. **投资组合管理**: 查看持仓、现金余额、资产配置、年化收益\n2. **交易记录**: 记录买入/卖出操作，更新资产当前价格（手动输入或自动获取）\n3. **策略建议**: 自动生成基于最新恐贪指数的买卖建议报告（仅建议，不执行交易）\n4. **配置管理**: 查看和调整策略参数（阈值、买入/卖出比例、止盈线）\n5. **历史查询**: 查看交易历史、价格更新记录\n6. **策略回测**: 基于历史数据验证策略参数表现\n\n> **重要说明**: 本工具仅提供策略建议和记录功能，不连接任何券商 API。\n> 用户需自行在券商平台执行交易后，通过 CLI 记录交易结果。\n\n## 快速开始\n\n### 安装\n\n```bash\n# 通过 npm 安装（推荐）\nnpm install -g @never-sleeps/mns-cli\n\n# 或通过 bun 安装\nbun install -g @never-sleeps/mns-cli\n\n# 或直接使用 npx（无需安装）\nnpx @never-sleeps/mns-cli --help\n```\n\n### 初始化\n\n```bash\n# 初始化配置文件和数据库\n# 如果已有数据，会提示确认后再覆盖\nmns init\n\n# 使用 --force 跳过确认直接覆盖\nmns init --force\n\n# 设置初始现金\nmns cash set 100000\n```\n\n### 添加资产到持仓池\n\n```bash\nmns add QQQ \"纳指100\" us_stocks\nmns add SH600000 \"浦发银行\" cn_stocks\nmns add GLD \"黄金ETF\" counter_cyclical\n```\n\n### 记录买入交易\n\n```bash\nmns buy QQQ 100 450.50\nmns buy SH600000 500 12.30\n```\n\n### 查看持仓和策略建议\n\n```bash\n# 查看当前持仓（含年化收益）\nmns portfolio\n\n# 获取今日策略报告（基于最新恐贪指数）\nmns report\n\n# 查看当前恐贪指数\nmns sentiment\n```\n\n### 更新价格和查看历史\n\n```bash\n# 手动更新单个资产价格\nmns price QQQ 460.00\n\n# 自动更新所有资产价格（需要网络）\nmns update-prices\n\n# 查看最近交易历史\nmns history --limit 50\n\n# 查看现金余额\nmns cash\n```\n\n### 配置管理\n\n```bash\n# 查看所有配置\nmns config\n\n# 查看特定配置项（支持 dot-path 语法）\nmns config thresholds.fear\nmns config buy_ratio.extreme_fear\n\n# 修改配置项（策略参数）\nmns config thresholds.greed 75\nmns config buy_ratio.fear 30.0\nmns config sell_ratio.extreme_greed_target_high 60.0\n```\n\n### 策略回测\n\n```bash\n# 查看可调参数列表\nmns backtest params\n\n# 运行默认配置回测\nmns backtest run\n\n# 使用自定义配置回测\nmns backtest run --config path/to/config.toml\n\n# 对比多个配置\nmns backtest run --compare config1.toml,config2.toml\n```\n\n## 数据存储\n\n- **配置文件**: `~/.mns/config.toml`\n- **数据库**: `~/.mns/mns.db`\n- **报告输出**: `./reports/`（可通过 `settings.report_output_dir` 配置）\n\n## 策略逻辑详解\n\n### 情绪驱动的买入决策\n\n买入比例基于恐贪指数区间：\n\n| 恐贪区间 | 指数范围 | 买入比例 | 逻辑 |\n|---------|---------|---------|------|\n| 极度恐慌 | FGI < 30 | 60% (默认) | 极度恐慌，适度买入 |\n| 恐慌 | 30 ≤ FGI < 45 | 35% (默认) | 恐慌，保守买入 |\n| 中性 | 45 ≤ FGI < 55 | 0% (默认) | 中性，暂停买入 |\n| 贪婪 | 55 ≤ FGI < 70 | 0% (默认) | 贪婪，不买入 |\n| 极度贪婪 | FGI ≥ 70 | 0% (默认) | 极度贪婪，不买入 |\n\n### 卖出决策（双准则）\n\n卖出建议综合考虑：\n1. **年化收益止盈**: 基于持有天数计算年化收益率，对照卖出矩阵\n2. **绝对收益线**: 绝对收益 ≥ 30% 且持仓 ≥ 90 天时也可考虑卖出\n\n卖出矩阵（按情绪区间和收益档位）：\n\n| 情绪区间 | target_high | target_low | below_target |\n|---------|-------------|------------|--------------|\n| 极度贪婪 | 50% | 30% | 20% |\n| 贪婪 | 40% | 25% | 0% |\n| 中性 | 15% | 0% | 0% |\n| 恐慌/极度恐慌 | 0% | 0% | 0% |\n\n> 注：target_high = 年化收益 ≥ annualized_target_high（默认15%），target_low = 年化收益 ≥ annualized_target_low（默认10%）\n\n### 买入资金分配：Contrarian 权重\n\n可用现金按 contrarian 权重分配到各资产：\n\n- **权重公式**: `weight = min(max_weight, max(1.0, cost_price / current_price))`\n- **解释**: 浮亏资产（当前价格 < 成本价）获得更高权重，符合逆向抄底逻辑\n- **上限控制**: `max_contrarian_weight`（默认 2.0）防止过度集中单一标的\n- **浮盈资产**: 权重为 1.0（基线）\n\n### 风险警告机制\n\n当持仓浮亏 ≥ 20% 时触发风险警告，建议根据市场情绪差异化处理：\n\n| 情绪环境 | 建议操作 |\n|---------|---------|\n| Extreme Fear/Fear | 可能是加仓机会 |\n| Neutral | 审视基本面 |\n| Greed/Extreme Greed | 紧急审视（别人赚钱你还在亏） |\n\n## 常见工作流\n\n### 日常报告（Agent 每日执行）\n\n```bash\n# 1. 自动更新所有资产价格\nmns update-prices\n\n# 2. 查看策略报告\nmns report\n\n# 3. 根据建议执行买入（如有）\nmns buy QQQ 50 445.00\n\n# 4. 记录卖出（如有）\nmns sell QQQ 100 455.00\n\n# 5. 查看最新持仓\nmns portfolio\n```\n\n### 策略参数调优\n\n```bash\n# 查看当前买入比例\nmns config buy_ratio\n\n# 调整极端恐慌买入比例到 60%\nmns config buy_ratio.extreme_fear 60.0\n\n# 降低中性区间买入到 10%\nmns config buy_ratio.neutral 10.0\n\n# 调整卖出矩阵\nmns config sell_ratio.extreme_greed_target_high 70.0\n\n# 调整止盈线\nmns config settings.annualized_target_low 12.0\nmns config settings.annualized_target_high 18.0\n\n# 调整逆向权重上限（防止单标的过度集中）\nmns config settings.max_contrarian_weight 1.5\n```\n\n### 新资产添加流程\n\n```bash\n# 1. 添加资产到池子\nmns add TSLA \"特斯拉\" us_stocks\n\n# 2. 初始建仓买入\nmns buy TSLA 50 250.00\n\n# 3. 更新当前价格\nmns price TSLA 255.00\n```\n\n## 高级分析指南\n\n以下分析功能由 Agent 组合使用基础命令完成，非单一 CLI 命令。\n\n### 行业分析 (Agent 执行)\n\n组合使用基础命令分析行业表现：\n\n```bash\n# 1. 查询行业 ETF 表现\nmns analyze XLK    # 科技\nmns analyze XLF    # 金融\nmns analyze XLE    # 能源\nmns analyze XLV    # 医疗\nmns analyze XLY    # 消费\nmns analyze XLP    # 消费必需品\nmns analyze XLB    # 材料\nmns analyze XLU    # 公用事业\nmns analyze XLI    # 工业\nmns analyze XLRE   # 房地产\n\n# 2. 分析各行业龙头股\nmns analyze AAPL   # 科技龙头\nmns analyze JPM    # 金融龙头\nmns analyze XOM    # 能源龙头\n\n# 3. 对比行业表现与大盘指数\nmns market-indices  # 获取大盘指数参考\nmns portfolio       # 查看当前持仓行业分布\n```\n\nAgent 分析要点：\n- 比较各行业 ETF 涨跌幅，识别强势/弱势行业\n- 对比行业与大盘（S&P 500）的相对表现\n- 结合恐贪指数判断行业轮动机会\n\n### 组合深度分析 (Agent 执行)\n\n基于已有数据进行组合分析：\n\n```bash\n# 1. 查看当前持仓\nmns portfolio\n\n# 2. 获取市场情绪\nmns sentiment\n\n# 3. 获取策略报告\nmns report\n\n# 4. 查看历史表现\nmns history --limit 100\n```\n\nAgent 分析要点：\n- **配置合理性**: 持仓集中度是否过高（单一标的 > 30% 需警惕）\n- **收益分布**: 各持仓年化收益率分布，识别拖累/贡献主力\n- **情绪偏离**: 当前恐贪指数与持仓策略是否匹配（恐慌时应持有更多权益）\n- **现金比例**: 现金占比是否符合理想配置（参考买入比例建议）\n\n### 风险评估 (Agent 执行)\n\n组合计算风险指标：\n\n```bash\n# 1. 获取持仓成本与当前价格\nmns portfolio\n\n# 2. 获取历史价格记录\nmns history --limit 365\n\n# 3. 结合市场波动率\nmns market  # 包含 VIX 指数\n```\n\nAgent 风险指标计算：\n- **最大回撤**: 基于历史快照计算峰值到谷值的最大跌幅\n- **Sharpe 比率**: `(年化收益 - 无风险利率) / 波动率`（需历史数据支持）\n- **持仓集中度**: 前三大持仓占比总和\n- **浮亏暴露**: 当前浮亏 > 20% 的持仓数量及金额\n\n风险等级判定：\n| 风险等级 | 条件 |\n|---------|------|\n| 低风险 | 单一持仓 < 20%，无浮亏 > 20% 标的，现金 > 20% |\n| 中风险 | 单一持仓 20-30%，或 1-2 个标的浮亏 10-20% |\n| 高风险 | 单一持仓 > 30%，或 3+ 标的浮亏 > 20%，或 VIX > 30 |\n\n## 配置参数\n\n完整的配置参数说明请参考 `references/strategy.md`，其中包含：\n- 所有配置项的默认值速查表\n- 策略参数的详细解释\n- 买入/卖出比例矩阵说明\n\n命令使用方法请参考 `references/commands.md`。\n\n## 注意事项\n\n- **价格更新**: 买入/卖出后建议调用 `price` 或 `update-prices` 命令更新价格，确保持仓收益数据准确\n- **时间敏感性**: `report` 和 `sentiment` 命令通过 HTTP 获取实时 CNN Fear & Greed Index，需要网络访问\n- **异步要求**: 这两个命令是异步的，agent 调用时需确保环境支持 async execution\n- **Windows 编码**: PowerShell 默认 GBK 编码可能导致中文乱码，建议使用 UTF-8 终端或重定向输出到文件\n- **年化收益计算**: 使用 `annualized = (current / cost) ^ (365 / holding_days) - 1`，持仓天数 < min_holding_days 时不显示\n- **绝对收益止盈**: 持仓绝对收益 ≥ 30% 且天数 ≥ min_absolute_profit_days 时，即使年化收益率未达阈值也可能触发卖出\n\n## 错误处理\n\n- **网络错误**: `sentiment` 和 `report` 可能因 API 不可用失败，建议重试或使用缓存数据\n- **数据库锁定**: 多进程并发操作 SQLite 会导致锁定，agent 应确保串行访问\n\n## 相关文件\n\n- `references/commands.md` - 完整命令参考\n- `references/strategy.md` - 策略参数详解\n\nFile v0.5.10:_meta.json\n\n{\n  \"ownerId\": \"kn7a2vy7ys7aj3gzm2vvw7zc158311b2\",\n  \"slug\": \"money-never-sleep\",\n  \"version\": \"0.5.10\",\n  \"publishedAt\": 1776937641761\n}\n\nFile v0.5.10:references/commands.md\n\n# MNS CLI 命令参考\n\n本文档详细描述 MNS CLI 的所有命令、参数和用法。\n\n## 命令概览\n\n| 命令 | 用途 | 异步 |\n|------|------|------|\n| `init` | 初始化配置文件和数据库 | 否 |\n| `config` | 查看/修改配置 | 否 |\n| `cash` | 现金余额管理 | 否 |\n| `portfolio` | 查看持仓概览 | 否 |\n| `add` | 新增资产到持仓池 | 否 |\n| `buy` | 记录买入交易 | 否 |\n| `sell` | 记录卖出交易 | 否 |\n| `price` | 更新资产当前价格 | 否 |\n| `sentiment` | 查看当前恐贪指数 | 是 |\n| `report` | 生成策略报告 | 是 |\n| `history` | 查看交易历史 | 否 |\n| `backtest` | 策略回测 | 否 |\n| `update-prices` | 自动更新所有资产价格 | 是 |\n\n---\n\n## `init`\n\n**语法**: `mns init [-f, --force]`\n\n**功能**: 初始化配置文件和数据库。\n\n**参数**:\n- `-f, --force`: 跳过确认提示，强制覆盖已有数据\n\n**行为说明**:\n- 如果检测到已有配置文件或数据库，会提示用户确认后再覆盖\n- 使用 `--force` 参数可跳过确认直接覆盖\n\n**示例**:\n```bash\n# 普通初始化（如有数据会提示确认）\nmns init\n\n# 强制初始化（跳过确认）\nmns init --force\n```\n\n**输出示例（已有数据时）**:\n```\n⚠️  检测到已有数据：\n\n继续将覆盖上述文件，数据将丢失。是否继续？[y/N]: y\n✓ 初始化完成\n  配置文件: ~/.mns/config.toml\n  数据库: ~/.mns/mns.db\n  报告目录: ./reports\n```\n\n**注意**: \n- 报告目录默认为当前目录下的 `reports/`，可通过配置修改\n- 输入 `y` 或 `yes` 确认覆盖，其他任何输入都会取消操作\n\n---\n\n## `config`\n\n**语法**: `mns config [KEY] [VALUE]`\n\n**功能**: 查看或修改配置项。支持 dot-path 语法访问嵌套配置。\n\n### 查看所有配置\n```bash\nmns config\n```\n\n输出 TOML 格式的完整配置。\n\n### 查看特定配置项\n```bash\nmns config thresholds.fear\nmns config buy_ratio.extreme_fear\nmns config sell_ratio.extreme_greed_target_high\n```\n\n输出:\n```\nthresholds.fear = 45\nbuy_ratio.extreme_fear = 60.0\nsell_ratio.extreme_greed_target_high = 50.0\n```\n\n### 修改配置项\n```bash\nmns config thresholds.greed 75\nmns config buy_ratio.fear 30.0\n```\n\n**支持的配置路径**:\n\n| 路径 | 说明 | 默认值 |\n|------|------|--------|\n| `settings.annualized_target_low` | 年化止盈下限(%) | 10.0 |\n| `settings.annualized_target_high` | 年化止盈上限(%) | 15.0 |\n| `settings.min_holding_days` | 最小持仓天数 | 45 |\n| `settings.min_absolute_profit_days` | 绝对收益最小天数 | 120 |\n| `settings.max_contrarian_weight` | 最大逆向权重 | 2.0 |\n| `settings.report_output_dir` | 报告输出目录 | ./reports |\n| `allocation.us_stocks` | 美股配置比例(%) | 55.0 |\n| `allocation.cn_stocks` | A股配置比例(%) | 25.0 |\n| `allocation.counter_cyclical` | 逆周期配置比例(%) | 20.0 |\n| `thresholds.extreme_fear` | 极度恐慌阈值 | 30.0 |\n| `thresholds.fear` | 恐慌阈值 | 45.0 |\n| `thresholds.neutral` | 中性阈值 | 55.0 |\n| `thresholds.greed` | 贪婪阈值 | 70.0 |\n| `buy_ratio.extreme_fear` | 极度恐慌买入比例(%) | 60.0 |\n| `buy_ratio.fear` | 恐慌买入比例(%) | 35.0 |\n| `buy_ratio.neutral` | 中性买入比例(%) | 0.0 |\n| `buy_ratio.greed` | 贪婪买入比例(%) | 0.0 |\n| `sell_ratio.extreme_greed_target_high` | 极度贪婪+高收益卖出(%) | 50.0 |\n| `sell_ratio.extreme_greed_target_low` | 极度贪婪+低收益卖出(%) | 30.0 |\n| `sell_ratio.extreme_greed_below_target` | 极度贪婪+未达标卖出(%) | 20.0 |\n| `sell_ratio.greed_target_high` | 贪婪+高收益卖出(%) | 40.0 |\n| `sell_ratio.greed_target_low` | 贪婪+低收益卖出(%) | 25.0 |\n| `sell_ratio.neutral_target_high` | 中性+高收益卖出(%) | 15.0 |\n\n**示例 - 完整参数调优**:\n```bash\n# 调整买入比例\nmns config buy_ratio.extreme_fear 60.0\nmns config buy_ratio.fear 25.0\nmns config buy_ratio.neutral 10.0\n\n# 调整卖出矩阵\nmns config sell_ratio.extreme_greed_target_high 60.0\nmns config sell_ratio.greed_target_high 50.0\n\n# 调整止盈线\nmns config settings.annualized_target_low 12.0\nmns config settings.annualized_target_high 18.0\n\n# 调整逆向权重上限\nmns config settings.max_contrarian_weight 1.5\n```\n\n---\n\n## `cash`\n\n**语法**: `mns cash [ACTION]`\n\n**功能**: 查看或设置现金余额。\n\n### 查看余额\n```bash\nmns cash\n```\n\n输出:\n```\n现金余额: ¥125430.50\n```\n\n### 设置现金余额\n```bash\nmns cash set 100000\n```\n\n### 增加现金\n```bash\nmns cash add 5000\n```\n\n**注意**:\n- `set` 会覆盖当前余额\n- `add` 在当前余额基础上增加\n- 金额不能为负数\n\n---\n\n## `portfolio`\n\n**语法**: `mns portfolio`\n\n**功能**: 显示当前持仓概览，包括：\n- 资产代码和名称\n- 持仓份额和成本价\n- 当前价格（需通过 `price` 命令更新）\n- 持仓市值和盈亏\n- 年化收益率（基于持有天数）\n\n**示例输出**:\n```\n┌───────┬────────────┬──────────┬──────────┬─────────────┬─────────────┬────────────┐\n│ 代码  │   名称     │  份额    │ 成本价   │ 当前价      │  市值       │ 年化收益   │\n├───────┼────────────┼──────────┼──────────┼─────────────┼─────────────┼────────────┤\n│ QQQ   │ 纳指100    │ 150.0    │ 450.00   │ 460.50      │ 69075.00    │  +8.2%     │\n│ SH600 │ 浦发银行   │ 500.0    │ 12.30    │ 12.80       │ 6400.00     │ +15.3%     │\n└───────┴────────────┴──────────┴──────────┴─────────────┴─────────────┴────────────┘\n\n总市值: ¥75475.00\n现金余额: ¥24685.50\n总资产: ¥100160.50\n```\n\n**注意事项**:\n- 年化收益计算公式: `(current / cost) ^ (365 / holding_days) - 1`\n- 如果持有天数小于配置的 `min_holding_days`，年化收益显示为 `N/A`\n- 当前价格需要定期通过 `price` 命令更新\n\n---\n\n## `add`\n\n**语法**: `mns add <CODE> <NAME> <CATEGORY>`\n\n**功能**: 新增资产到持仓池，后续可通过 `buy` 命令买入。\n\n**参数**:\n- `CODE`: 资产代码（如 `QQQ`, `SH600000`, `AAPL`）\n- `NAME`: 资产名称（任意描述性字符串）\n- `CATEGORY`: 类别，预设可选值：\n  - `us_stocks` - 美股\n  - `cn_stocks` - A股\n  - `counter_cyclical` - 逆周期资产\n\n**示例**:\n```bash\nmns add QQQ \"纳指100\" us_stocks\nmns add SH600000 \"浦发银行\" cn_stocks\nmns add GLD \"黄金ETF\" counter_cyclical\n```\n\n**注意**:\n- 资产代码在数据库中必须唯一\n- 添加后立即用 `buy` 记录初始买入\n\n---\n\n## `buy`\n\n**语法**: `mns buy <CODE> <SHARES> <PRICE>`\n\n**功能**: 记录买入交易，增加持仓份额。\n\n**参数**:\n- `CODE`: 资产代码（必须已通过 `add` 添加）\n- `SHARES`: 买入份额（支持小数，如股票可支持碎股）\n- `PRICE`: 买入单价（元/股）\n\n**示例**:\n```bash\n# 买入 100 股 QQQ，单价 450.50 元\nmns buy QQQ 100 450.50\n\n# 买入 50 份黄金 ETF，单价 180.00 元\nmns buy GLD 50 180.00\n```\n\n**行为**:\n- 现金余额相应减少\n- 持仓成本价重新计算（加权平均）\n- 交易记录存入 `transactions` 表\n\n---\n\n## `sell`\n\n**语法**: `mns sell <CODE> <SHARES> <PRICE>`\n\n**功能**: 记录卖出交易，减少持仓份额。\n\n**参数**:\n- `CODE`: 资产代码\n- `SHARES`: 卖出份额（不能超过当前持仓）\n- `PRICE`: 卖出单价\n\n**示例**:\n```bash\n# 卖出 30 股 QQQ，单价 455.00 元\nmns sell QQQ 30 455.00\n\n# 清仓某资产\nmns sell SH600000 500 13.20\n```\n\n**行为**:\n- 现金余额相应增加\n- 持仓份额减少，成本价保持不变（剩余份额）\n- 交易记录存入 `transactions` 表\n\n---\n\n## `price`\n\n**语法**: `mns price <CODE> [PRICE]`\n\n**功能**: 查看或更新单个资产的当前价格。\n\n### 查看当前价格\n```bash\nmns price QQQ\n```\n\n输出:\n```\nQQQ (纳指100): ¥460.50\n```\n\n### 更新当前价格\n```bash\nmns price QQQ 460.50\n```\n\n**注意**:\n- 每次更新价格会更新对应持仓的 `current_price` 和 `current_at` 字段\n- 不更新价格会导致 `portfolio` 和 `report` 显示的市值不准确\n- 如需批量更新所有资产价格，请使用 `update-prices` 命令\n\n---\n\n## `update-prices`\n\n**语法**: `mns update-prices`\n\n**功能**: 自动更新所有持仓资产的当前价格。\n\n**行为说明**:\n- 遍历所有有持仓的资产\n- 尝试从网络获取最新价格（需要网络连接）\n- 更新数据库中的 `current_price` 字段\n- 此命令为异步命令\n\n**示例**:\n```bash\nmns update-prices\n```\n\n**输出示例**:\n```\n正在更新所有资产价格...\n✓ QQQ: 460.50\n✓ SH600000: 12.80\n✓ GLD: 182.35\n已完成 3 个资产的价格更新\n```\n\n**注意**:\n- 需要网络连接\n- 部分资产可能无法获取价格（如 A 股需要特定数据源）\n- 建议在执行 `report` 前先运行此命令\n\n---\n\n## `sentiment`\n\n**语法**: `mns sentiment`\n\n**功能**: 从 CNN 官网获取最新的 Fear & Greed Index 数据。\n\n**示例**:\n```bash\nmns sentiment\n```\n\n输出:\n```\nCNN Fear & Greed Index: 42 (Fear)\nPrevious Close: 38\n1 Week Ago: 35\n1 Month Ago: 28\n```\n\n**注意**:\n- 此命令是异步的，需要网络访问\n- 如果 API 不可用，可能返回错误\n- 数据来自 CNN 官方 API 端点\n\n---\n\n## `report`\n\n**语法**: `mns report`\n\n**功能**: 生成今日策略报告，包含：\n1. 当前恐贪指数和情绪判断\n2. 买入建议（基于可用现金和 contrarian 分配）\n3. 卖出建议（基于年化收益和绝对收益）\n4. 持仓摘要和风险警告（浮亏过大）\n5. 现金预测（按建议执行后）\n\n**示例**:\n```bash\nmns report\n```\n\n**输出节选**:\n```\n╔═══════════════════════════════════════════════════════════════╗\n║           MNS 逆向投资策略报告 - 2026-04-21                     ║\n╚═══════════════════════════════════════════════════════════════╝\n\n📊 市场情绪 (CNN Fear & Greed)\n┌─────────────────────────────────────┐\n│ 当前指数: 42 (Fear)                  │\n│ 状态解读: 市场处于恐慌区间，建议逐步  │\n│         买入                          │\n└─────────────────────────────────────┘\n\n💰 买入建议 (可用现金: ¥25000)\n┌─────────────────────────────────────┐\n│ QQQ (Fear 区间权重: 1.2)             │\n│  建议买入: ¥12000 (50 股 @ ¥240)    │\n│                                     │\n│ SH600000 (Fear 区间权重: 1.5)        │\n│  建议买入: ¥13000 (1042 股 @ ¥12.5) │\n└─────────────────────────────────────┘\n\n⚠️  卖出建议\n┌─────────────────────────────────────┐\n│ 暂无满足卖出条件的持仓              │\n└─────────────────────────────────────┘\n\n🚨 风险警告\n┌─────────────────────────────────────┐\n│ [无]                                │\n└─────────────────────────────────────┘\n```\n\n**注意**:\n- 异步命令，需要网络获取恐贪指数\n- 报告同时保存到报告目录（默认 `./reports/`）\n- 买入/卖出建议仅供参考，agent 需根据实际执行顺序调整\n\n---\n\n## `history`\n\n**语法**: `mns history [--limit N]`\n\n**功能**: 查看最近的交易历史。\n\n**参数**:\n- `--limit N`: 显示条数，默认 20\n\n**示例**:\n```bash\n# 查看最近 20 条\nmns history\n\n# 查看最近 50 条\nmns history --limit 50\n```\n\n**输出**:\n```\n最近交易记录 (按时间倒序):\n┌─────────────────┬───────┬────────┬──────┬────────┬──────────┐\n│ 时间            │ 类型  │ 资产   │ 份额 │ 价格   │ 金额     │\n├─────────────────┼───────┼────────┼──────┼────────┼──────────┤\n│ 2025-06-15 10:30│ buy   │ QQQ    │ 50   │ 448.50 │ 22425.00 │\n│ 2025-06-14 14:20│ sell  │ SH600  │ 100  │ 13.00  │ 1300.00  │\n│ 2025-06-14 09:15│ price │ QQQ    │ -    │ 445.00 │ -        │\n└─────────────────┴───────┴────────┴──────┴────────┴──────────┘\n```\n\n**类型说明**:\n- `buy` - 买入交易\n- `sell` - 卖出交易\n- `price` - 价格更新记录\n\n---\n\n## `backtest`\n\n**语法**: `mns backtest [SUBCOMMAND]`\n\n**功能**: 策略回测相关命令，基于历史数据验证策略表现。\n\n### 子命令\n\n#### `backtest run`\n运行回测。\n\n**语法**: `mns backtest run [-c, --config <PATH>] [-C, --compare <PATHS>]`\n\n**参数**:\n- `-c, --config <PATH>`: 配置文件路径，省略则使用默认配置\n- `-C, --compare <PATHS>`: 对比多个配置文件，逗号分隔\n\n**示例**:\n```bash\n# 使用默认配置运行回测\nmns backtest run\n\n# 指定配置文件\nmns backtest run --config ./my_strategy.toml\n\n# 对比多个策略配置\nmns backtest run --compare config1.toml,config2.toml,config3.toml\n```\n\n#### `backtest params`\n查看可调参数列表。\n\n**语法**: `mns backtest params`\n\n**示例**:\n```bash\nmns backtest params\n```\n\n**输出示例**:\n```\n可调参数列表:\n┌─────────────────────────────┬────────────────┬─────────────────┐\n│ 参数名                       │ 默认值          │ 说明             │\n├─────────────────────────────┼────────────────┼─────────────────┤\n│ buy_ratio.extreme_fear      │ 50.0           │ 极度恐慌买入比例  │\n│ buy_ratio.fear             │ 30.0           │ 恐慌买入比例     │\n│ ...                        │ ...            │ ...             │\n└─────────────────────────────┴────────────────┴─────────────────┘\n```\n\n---\n\n## 通用 Exit Code\n\n| Code | 含义 |\n|------|------|\n| 0    | 成功 |\n| 1    | 通用错误（配置错误、参数错误、数据库错误等） |\n| 2    | 网络错误（仅影响 `sentiment`/`report`/`update-prices`） |\n\n---\n\n## 数据存储位置\n\nMNS 数据存储在用户主目录下的 `.mns` 文件夹：\n\n| 文件 | 路径 | 说明 |\n|------|------|------|\n| 配置文件 | `~/.mns/config.toml` | TOML 格式的策略配置 |\n| 数据库 | `~/.mns/mns.db` | SQLite 数据库 |\n| 报告目录 | `./reports/` | 默认报告输出目录（可配置） |\n\n---\n\n## 数据库 Schema 参考\n\n主要表结构：\n\n### `cash`\n- `id` INTEGER PRIMARY KEY\n- `balance` REAL NOT NULL\n- `updated_at` TIMESTAMP\n\n### `positions`\n- `id` INTEGER PRIMARY KEY\n- `code` TEXT NOT NULL UNIQUE\n- `name` TEXT NOT NULL\n- `category` TEXT NOT NULL\n- `shares` REAL NOT NULL\n- `cost_price` REAL NOT NULL\n- `current_price` REAL NOT NULL\n- `first_buy_date` TEXT NOT NULL\n- `updated_at` TIMESTAMP\n- `created_at` TIMESTAMP\n\n### `transactions`\n- `id` INTEGER PRIMARY KEY\n- `type` TEXT NOT NULL ('buy' | 'sell' | 'price')\n- `code` TEXT NOT NULL\n- `shares` REAL\n- `price` REAL\n- `amount` REAL\n- `created_at` TIMESTAMP\n\n---\n\n## 错误信息速查\n\n| 错误信息 | 原因 | 解决方案 |\n|----------|------|----------|\n| `未知的配置项` | 配置路径错误或不存在 | 用 `config` 查看有效的配置项 |\n| `现金余额不能为负数` | `cash set` 参数 < 0 | 检查金额参数 |\n| `资产代码不存在` | `buy`/`sell`/`price` 使用未添加的代码 | 先用 `add` 添加资产 |\n| `卖出份额超过持仓` | `sell` 参数 > 当前持仓 | 检查持仓数量 |\n| `API error: ...` | CNN API 不可用 | 稍后重试或检查网络 |\n| `Database is locked` | 并发访问数据库 | 确保同一时间只有一个进程操作 |\n\n---\n\n**最后更新**: 2026-04-21\n\nFile v0.5.10:references/strategy.md\n\n# MNS 策略参数参考\n\n本文档详细说明 MNS 逆向投资策略的核心参数，包括阈值定义、买入/卖出比例配置、止盈线设置等。这些参数通过 `mns config` 命令动态调整。\n\n---\n\n## 配置层级\n\nMNS 配置采用分层结构，存储于 `~/.mns/config.toml`：\n\n```toml\n[settings]\nannualized_target_low = 10.0      # 年化止盈线下限(%)\nannualized_target_high = 15.0     # 年化止盈线上限(%)\nmin_holding_days = 45             # 年化收益计算最小天数\nmin_absolute_profit_days = 120    # 绝对收益止盈最小天数\nmax_contrarian_weight = 2.0      # 逆向权重上限\nreport_output_dir = \"./reports\"   # 报告输出目录\n\n[allocation]\nus_stocks = 55.0          # 美股目标配置比例(%)\ncn_stocks = 25.0          # A股目标配置比例(%)\ncounter_cyclical = 20.0   # 逆周期资产配置比例(%)\n\n[thresholds]\nextreme_fear = 30.0       # 极度恐慌阈值\nfear = 45.0               # 恐慌阈值\nneutral = 55.0            # 中性阈值\ngreed = 70.0              # 贪婪阈值\n\n[buy_ratio]\nextreme_fear = 60.0       # 极度恐慌买入比例(%)\nfear = 35.0               # 恐慌买入比例(%)\nneutral = 0.0             # 中性买入比例(%)\ngreed = 0.0               # 贪婪买入比例(%)\n\n[sell_ratio]\nextreme_greed_target_high = 50.0    # 极度贪婪+高年化卖出(%)\nextreme_greed_target_low = 30.0     # 极度贪婪+低年化卖出(%)\nextreme_greed_below_target = 20.0  # 极度贪婪+未达标卖出(%)\ngreed_target_high = 40.0            # 贪婪+高年化卖出(%)\ngreed_target_low = 25.0             # 贪婪+低年化卖出(%)\nneutral_target_high = 15.0          # 中性+高年化卖出(%)\n\n[api]\nfear_greed_url = \"https://production.dataviz.cnn.io/index/fearandgreed/graphdata\"\n```\n\n---\n\n## 恐贪指数区间划分\n\nCNN Fear & Greed Index 是一个 0-100 的指数，0 表示极度恐慌（Extreme Fear），100 表示极度贪婪（Extreme Greed）。\n\n### 默认区间配置\n\n| 区间名称 | 指数范围 | 含义 | 买入比例 |\n|---------|---------|------|---------|\n| Extreme Fear | 0-30 | 市场极度恐慌，逆向买入信号强 | 60% |\n| Fear | 30-45 | 市场恐慌，适度买入 | 35% |\n| Neutral | 45-55 | 中性，观望不买入 | 0% |\n| Greed | 55-70 | 市场贪婪，谨慎持有 | 0% |\n| Extreme Greed | 70-100 | 市场极度贪婪，考虑减仓 | 0% |\n\n### 调整阈值\n\n通过修改 `thresholds` 可改变区间边界：\n\n```bash\n# 将贪婪阈值从 70 降至 65，使贪婪区间更早触发\nmns config thresholds.greed 65.0\n\n# 将极度恐慌阈值从 30 提升至 35，减少极端情况下的买入频率\nmns config thresholds.extreme_fear 35.0\n```\n\n**注意**: 区间必须保持连续性，建议:\n- `extreme_fear < fear < neutral < greed`\n- 阈值单位为百分比数值（如 25.0 表示 25）\n\n---\n\n## 买入比例矩阵 (`buy_ratio`)\n\n定义在不同情绪区间下，用多少比例的可用现金进行买入。\n\n### 参数说明\n\n- **可用现金**: `cash_balance + 卖出回笼资金`（买卖互感知）\n- **分配方式**: 按 contrarian 权重分配到各资产类别\n- **类别配置**: 按 `allocation` 比例分配到美股/A股/逆周期\n\n### 默认配置\n\n| 情绪区间 | 买入比例 | 适用场景 |\n|---------|---------|---------|\n| extreme_fear | 60.0% | 恐慌极致，重仓抄底 |\n| fear | 35.0% | 恐慌情绪，积极建仓 |\n| neutral | 0.0% | 中性市场，观望不买入 |\n| greed | 0.0% | 贪婪时暂停买入 |\n\n### 调优示例\n\n```bash\n# 策略1: 极度贪婪时也可能小幅买入（左侧布局）\nmns config buy_ratio.greed 10.0\n\n# 策略2: 中性区间也暂停买入，只在明确的恐慌区间出手\nmns config buy_ratio.neutral 0.0\n\n# 策略3: 极端恐慌时加大买入\nmns config buy_ratio.extreme_fear 70.0\n```\n\n---\n\n## 卖出比例矩阵 (`sell_ratio`)\n\n定义在特定情绪区间和年化收益档位下的卖出比例。卖出逻辑基于 **双准则**:\n\n1. **年化收益止盈**: 当持仓年化收益率达标且处于可卖出情绪区间\n2. **绝对收益止盈**: 当持仓绝对收益 ≥ 30% 且持有天数足够长\n\n### 收益档位定义\n\n- `target_high`: 年化收益 ≥ `annualized_target_high`（默认 15%）\n- `target_low`: 年化收益 ≥ `annualized_target_low`（默认 10%）但 < target_high\n- `below_target`: 年化收益 < target_low（仅在极度贪婪时考虑部分卖出）\n\n### 默认卖出矩阵\n\n| 情绪区间 | target_high | target_low | below_target |\n|---------|-------------|------------|--------------|\n| extreme_greed | 50% | 30% | 20% |\n| greed | 40% | 25% | 0% |\n| neutral | 15% | 0% | 0% |\n| fear/extreme_fear | 0% | 0% | 0% |\n\n### 配置路径\n\n```bash\n# 查看卖出配置\nmns config sell_ratio\n\n# 调整极度贪婪时的高收益卖出比例\nmns config sell_ratio.extreme_greed_target_high 70.0\n\n# 调整贪婪时的中等收益卖出比例\nmns config sell_ratio.greed_target_low 30.0\n\n# 启用中性区间的部分止盈\nmns config sell_ratio.neutral_target_high 20.0\n```\n\n---\n\n## 止盈线参数 (`settings`)\n\n### `annualized_target_low` (默认 10.0)\n\n年化收益率的下限阈值。当持仓年化收益 ≥ 此值且处于可卖出情绪区间时，触发部分卖出建议。\n\n### `annualized_target_high` (默认 15.0)\n\n年化收益率的上限阈值。当持仓年化收益 ≥ 此值时，卖出比例达到该情绪区间的最大值。\n\n**调优示例**:\n\n```bash\n# 保守止盈：年化 8% 就开始卖\nmns config settings.annualized_target_low 8.0\nmns config settings.annualized_target_high 12.0\n\n# 激进止盈：年化 20% 才开始卖\nmns config settings.annualized_target_low 15.0\nmns config settings.annualized_target_high 25.0\n```\n\n### `min_holding_days` (默认 45)\n\n最小持有天数。持仓天数小于此值时，不计算年化收益率（显示为 N/A），避免短期波动误导。\n\n### `min_absolute_profit_days` (默认 120)\n\n绝对收益止盈的最小天数。只有持仓天数 ≥ 此值且绝对收益 ≥ 30% 时，才触发绝对收益止盈。\n\n**目的**: 避免短期投机操作，确保长期持有才能享受\"坐过山车保护\"。\n\n---\n\n## 逆向权重参数 (`settings`)\n\n### `max_contrarian_weight` (默认 2.0)\n\n逆向权重的上限。防止浮亏过大的标的获得过多资金，导致过度集中风险。\n\n**权重公式**:\n```\nweight = min(max_contrarian_weight, max(1.0, cost_price / current_price))\n```\n\n**调优示例**:\n\n```bash\n# 降低权重上限，避免过度集中\nmns config settings.max_contrarian_weight 1.5\n\n# 提高权重上限，更激进抄底\nmns config settings.max_contrarian_weight 3.0\n```\n\n---\n\n## 资产配置参数 (`allocation`)\n\n定义买入资金在不同资产类别间的目标分配比例。\n\n### 默认配置\n\n| 类别 | 比例 | 说明 |\n|------|------|------|\n| us_stocks | 55% | 美股（如 QQQ, SPY） |\n| cn_stocks | 25% | A股（如沪深300成分股） |\n| counter_cyclical | 20% | 逆周期资产（如黄金ETF, 债券） |\n\n### 注意事项\n\n- 配置比例之和必须为 100%\n- 这是**目标参考比例**，非强制约束\n- 实际分配还会受 contrarian 权重影响\n\n### 调整示例\n\n```bash\n# 查看当前配置\nmns config allocation\n\n# 调整美股占比\nmns config allocation.us_stocks 60.0\nmns config allocation.cn_stocks 30.0\nmns config allocation.counter_cyclical 10.0\n```\n\n---\n\n## 买入资金分配: Contrarian 权重详解\n\nMNS 的买入资金不是平均分配，而是采用 **逆向权重**：\n\n```\nweight_i = min(max_contrarian_weight, max(1.0, cost_price_i / current_price_i))\n```\n\n### 权重计算示例\n\n假设 Fear 区间可用买入资金 30,000 元，有两个美股持仓：\n\n| 资产 | 成本价 | 当前价 | 浮亏/浮盈 | 权重计算 | 权重 |\n|------|--------|--------|----------|---------|------|\n| QQQ  | 450.00 | 460.50 | +2.3%    | min(2.0, max(1.0, 450/460.5)) = 1.0 | 1.0 |\n| AAPL | 180.00 | 150.00 | -16.7%   | min(2.0, max(1.0, 180/150)) = 1.2 | 1.2 |\n\n**分配结果**:\n- QQQ: `30000 × (1.0 / 2.2) = 13,636 元`\n- AAPL: `30000 × (1.2 / 2.2) = 16,364 元`\n\n浮亏资产获得更高权重，符合\"越跌越买\"的逆向逻辑，但权重上限防止过度集中。\n\n### 高浮亏排除机制\n\n当持仓浮亏 ≥ 30% 时，该标的会被**排除加仓列表**，避免\"越亏越买\"的基本面恶化风险。\n\n---\n\n## 卖出决策双准则详解\n\n### 准则1：年化收益 + 情绪区间\n\n当同时满足以下条件时触发：\n1. 当前情绪在可卖出区间（neutral 及以上）\n2. 持仓年化收益 ≥ `annualized_target_low`\n3. 持仓天数 ≥ `min_holding_days`\n\n卖出比例根据年化收益档位和情绪区间从 `sell_ratio` 矩阵查出。\n\n### 准则2：绝对收益止盈\n\n当满足以下条件时触发：\n- 绝对收益 = (当前价 - 成本价) / 成本价 ≥ 30%\n- 持仓天数 ≥ `min_absolute_profit_days`（默认 120 天）\n\n**目的**: 锁定长期盈利，即使年化收益率因持有时间较长而降低。\n\n---\n\n## 风险警告机制\n\n当持仓浮亏 ≥ 20% 时触发风险警告，建议根据市场情绪差异化处理：\n\n| 情绪环境 | 建议操作 |\n|---------|---------|\n| Extreme Fear/Fear | 可能是加仓机会 |\n| Neutral | 审视基本面 |\n| Greed/Extreme Greed | 紧急审视（别人赚钱你还在亏） |\n\n---\n\n## 完整参数调优工作流\n\n### 1. 查看当前配置\n\n```bash\nmns config\n\n# 查看特定分组\nmns config buy_ratio\nmns config sell_ratio\nmns config settings\n```\n\n### 2. 运行回测验证\n\n```bash\n# 查看可调参数\nmns backtest params\n\n# 运行默认配置回测\nmns backtest run\n\n# 测试新参数组合\nmns backtest run --config my_strategy.toml\n```\n\n### 3. 调整参数\n\n```bash\n# 每次只调整 1-2 个参数\nmns config buy_ratio.extreme_fear 60.0\n\n# 观察 report 变化\nmns report\n```\n\n### 4. 备份配置\n\n```bash\nmns config > config_backup_$(date +%Y%m%d).toml\n```\n\n---\n\n## 配置路径速查表\n\n| 配置路径 | 说明 | 默认值 |\n|---------|------|--------|\n| `settings.annualized_target_low` | 年化止盈下限(%) | 10.0 |\n| `settings.annualized_target_high` | 年化止盈上限(%) | 15.0 |\n| `settings.min_holding_days` | 年化收益最小天数 | 45 |\n| `settings.min_absolute_profit_days` | 绝对收益最小天数 | 120 |\n| `settings.max_contrarian_weight` | 逆向权重上限 | 2.0 |\n| `settings.report_output_dir` | 报告输出目录 | ./reports |\n| `allocation.us_stocks` | 美股目标比例(%) | 55.0 |\n| `allocation.cn_stocks` | A股目标比例(%) | 25.0 |\n| `allocation.counter_cyclical` | 逆周期比例(%) | 20.0 |\n| `thresholds.extreme_fear` | 极度恐慌阈值 | 30.0 |\n| `thresholds.fear` | 恐慌阈值 | 45.0 |\n| `thresholds.neutral` | 中性阈值 | 55.0 |\n| `thresholds.greed` | 贪婪阈值 | 70.0 |\n| `buy_ratio.extreme_fear` | 极度恐慌买入(%) | 60.0 |\n| `buy_ratio.fear` | 恐慌买入(%) | 35.0 |\n| `buy_ratio.neutral` | 中性买入(%) | 0.0 |\n| `buy_ratio.greed` | 贪婪买入(%) | 0.0 |\n| `sell_ratio.extreme_greed_target_high` | 极度贪婪高收益卖(%) | 50.0 |\n| `sell_ratio.extreme_greed_target_low` | 极度贪婪低收益卖(%) | 30.0 |\n| `sell_ratio.extreme_greed_below_target` | 极度贪婪未达标卖(%) | 20.0 |\n| `sell_ratio.greed_target_high` | 贪婪高收益卖(%) | 40.0 |\n| `sell_ratio.greed_target_low` | 贪婪低收益卖(%) | 25.0 |\n| `sell_ratio.neutral_target_high` | 中性高收益卖(%) | 15.0 |\n\n---\n\n## 风险提示\n\n- **参数调优需结合实际市场环境**: 回测结果是历史数据，不代表未来表现\n- **避免频繁调整**: 每次调整后至少观察 1-2 个月的实盘表现\n- **分散投资**: `max_contrarian_weight` 可防止单一标的过度集中\n\n---\n\n**文档版本**: v0.5.8 | **更新日期**: 2026-04-21\n\nFile v0.5.10:skill-card.md\n\n## Description: <br>\nMNS helps agents manage an investment portfolio with CLI-driven position tracking, CNN Fear & Greed sentiment checks, contrarian strategy suggestions, backtesting, and daily strategy reports. <br>\n\nThis skill is ready for commercial/non-commercial use. <br>\n\n## Publisher: <br>\n[sopaco](https://clawhub.ai/user/sopaco) <br>\n\n### License/Terms of Use: <br>\nMIT-0 <br>\n\n\n## Use Case: <br>\nExternal investors, developers, and agent operators use this skill to inspect portfolio state, record manual buy and sell activity, update prices, tune contrarian strategy parameters, run backtests, and generate market-sentiment-based strategy reports. It supports investment tracking and suggestions only, not broker connectivity or automated trading. <br>\n\n### Deployment Geography for Use: <br>\nGlobal <br>\n\n## Known Risks and Mitigations: <br>\nRisk: Generated strategy suggestions may be mistaken for financial advice or used to authorize real brokerage activity. <br>\nMitigation: Treat all reports as informational suggestions, keep broker execution manual, and do not grant an agent authority to place real trades from these outputs. <br>\nRisk: Portfolio records and strategy reports can expose sensitive personal financial information on disk. <br>\nMitigation: Review local data storage under ~/.mns and report output under ./reports, restrict workspace access, and remove generated reports when they are no longer needed. <br>\nRisk: Market sentiment and price-update flows depend on network data that may be delayed, unavailable, or inaccurate. <br>\nMitigation: Verify current market data from trusted sources before making decisions and retry or fall back to cached/manual data when network calls fail. <br>\n\n\n## Reference(s): <br>\n- [ClawHub Skill Page](https://clawhub.ai/sopaco/money-never-sleep) <br>\n- [GitHub Project Homepage](https://github.com/sopaco/money-never-sleep) <br>\n- [MNS CLI Command Reference](references/commands.md) <br>\n- [MNS Strategy Parameters Reference](references/strategy.md) <br>\n\n\n## Skill Output: <br>\n**Output Type(s):** [text, markdown, shell commands, configuration, guidance] <br>\n**Output Format:** [Markdown guidance with CLI command sequences, configuration examples, portfolio summaries, and strategy report text] <br>\n**Output Parameters:** [1D] <br>\n**Other Properties Related to Output:** [Commands can read and write local MNS configuration, SQLite portfolio data, and report files; sentiment and price-update flows may make network calls for market data.] <br>\n\n## Skill Version(s): <br>\n0.5.10 (source: SKILL.md frontmatter and server release evidence) <br>\n\n## Ethical Considerations: <br>\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment. <br>\n\nArchive v0.5.8: 6 files, 16544 bytes\n\nFiles: assets/examples/portfolio-example.json (1426b), assets/examples/report-example.json (2580b), references/commands.md (17197b), references/strategy.md (11692b), SKILL.md (9140b), _meta.json (136b)\n\nFile v0.5.8:SKILL.md\n\n---\nname: money-never-sleep\nversion: 0.5.8\ndescription: |\n  MNS (Money Never Sleep, Market Neutral Strategist) CLI skill for autonomous agents. Provides investment\n  portfolio tracking, market sentiment analysis using CNN Fear & Greed Index, and strategy\n  suggestion report generation. Use when managing a contrarian investment portfolio,\n  generating buy/sell suggestions based on market sentiment thresholds, or producing\n  daily strategy reports.\n\n  NOTE: This tool provides strategy suggestions only - it does NOT connect to any broker APIs\n  or execute actual trades. All trades must be manually executed by users on their brokerage platforms\n  and then recorded via CLI commands.\n\n  Triggers include: \"管理投资组合\", \"生成策略建议\", \"获取市场报告\", \"查看持仓收益\",\n  \"更新现金余额\", \"记录买入卖出\", \"查看恐贪指数\", \"投资组合再平衡\", \"MNS 报告\", \"回测策略\"\nlicense: MIT\ncompatibility: Requires Node.js 18+ or Bun.\nmetadata:\n  {\n    \"openclaw\":\n      {\n        \"requires\": { \"anyBins\": [\"npx\", \"bunx\", \"npm\", \"bun\"] },\n        \"source\": \"https://github.com/sopaco/money-never-sleep\",\n        \"homepage\": \"https://github.com/sopaco/money-never-sleep\",\n        \"author\": \"Sopaco\",\n        \"os\": [\"darwin\", \"linux\", \"win32\"]\n      }\n  }\n  \n---\n\n# MNS CLI 投资管理 Skill\n\n## 概述\n\n本 skill 提供 MNS 逆向投资策略的 CLI 操作能力。MNS 是基于 CNN Fear & Greed Index 情绪指标的量化投资工具，通过 contrarian 策略在情绪极度恐慌时买入，极度贪婪时卖出，实现市场中性风格的长期投资。\n\n### 安全声明\n\n> - **源码公开**: 所有源码公开托管于 [GitHub](https://github.com/sopaco/money-never-sleep)\n> - **无网络交易**: 不连接任何券商 API，所有数据存储在本地 SQLite 数据库\n> - **无敏感权限**: 无需使用也不自动读取用户任何金融账户配置\n\n## 核心能力\n\n1. **投资组合管理**: 查看持仓、现金余额、资产配置、年化收益\n2. **交易记录**: 记录买入/卖出操作，更新资产当前价格（手动输入或自动获取）\n3. **策略建议**: 自动生成基于最新恐贪指数的买卖建议报告（仅建议，不执行交易）\n4. **配置管理**: 查看和调整策略参数（阈值、买入/卖出比例、止盈线）\n5. **历史查询**: 查看交易历史、价格更新记录\n6. **策略回测**: 基于历史数据验证策略参数表现\n\n> **重要说明**: 本工具仅提供策略建议和记录功能，不连接任何券商 API。\n> 用户需自行在券商平台执行交易后，通过 CLI 记录交易结果。\n\n## 快速开始\n\n### 安装\n\n```bash\n# 通过 npm 安装（推荐）\nnpm install -g @never-sleeps/mns-cli\n\n# 或通过 bun 安装\nbun install -g @never-sleeps/mns-cli\n\n# 或直接使用 npx（无需安装）\nnpx @never-sleeps/mns-cli --help\n```\n\n### 初始化\n\n```bash\n# 初始化配置文件和数据库\n# 如果已有数据，会提示确认后再覆盖\nmns init\n\n# 使用 --force 跳过确认直接覆盖\nmns init --force\n\n# 设置初始现金\nmns cash set 100000\n```\n\n### 添加资产到持仓池\n\n```bash\nmns add QQQ \"纳指100\" us_stocks\nmns add SH600000 \"浦发银行\" cn_stocks\nmns add GLD \"黄金ETF\" counter_cyclical\n```\n\n### 记录买入交易\n\n```bash\nmns buy QQQ 100 450.50\nmns buy SH600000 500 12.30\n```\n\n### 查看持仓和策略建议\n\n```bash\n# 查看当前持仓（含年化收益）\nmns portfolio\n\n# 获取今日策略报告（基于最新恐贪指数）\nmns report\n\n# 查看当前恐贪指数\nmns sentiment\n```\n\n### 更新价格和查看历史\n\n```bash\n# 手动更新单个资产价格\nmns price QQQ 460.00\n\n# 自动更新所有资产价格（需要网络）\nmns update-prices\n\n# 查看最近交易历史\nmns history --limit 50\n\n# 查看现金余额\nmns cash\n```\n\n### 配置管理\n\n```bash\n# 查看所有配置\nmns config\n\n# 查看特定配置项（支持 dot-path 语法）\nmns config thresholds.fear\nmns config buy_ratio.extreme_fear\n\n# 修改配置项（策略参数）\nmns config thresholds.greed 75\nmns config buy_ratio.fear 30.0\nmns config sell_ratio.extreme_greed_target_high 60.0\n```\n\n### 策略回测\n\n```bash\n# 查看可调参数列表\nmns backtest params\n\n# 运行默认配置回测\nmns backtest run\n\n# 使用自定义配置回测\nmns backtest run --config path/to/config.toml\n\n# 对比多个配置\nmns backtest run --compare config1.toml,config2.toml\n```\n\n## 数据存储\n\n- **配置文件**: `~/.mns/config.toml`\n- **数据库**: `~/.mns/mns.db`\n- **报告输出**: `./reports/`（可通过 `settings.report_output_dir` 配置）\n\n## 策略逻辑详解\n\n### 情绪驱动的买入决策\n\n买入比例基于恐贪指数区间：\n\n| 恐贪区间 | 指数范围 | 买入比例 | 逻辑 |\n|---------|---------|---------|------|\n| Extreme Fear | 0-25 | 50% (默认) | 极度恐慌，重仓买入 |\n| Fear | 25-45 | 30% (默认) | 恐慌，适度买入 |\n| Neutral | 45-55 | 20% (默认) | 中性，小额买入 |\n| Greed | 55-75 | 0% (默认) | 贪婪，不买入 |\n| Extreme Greed | 75-100 | 0% (默认) | 极度贪婪，不买入 |\n\n### 卖出决策（双准则）\n\n卖出建议综合考虑：\n1. **年化收益止盈**: 基于持有天数计算年化收益率，对照卖出矩阵\n2. **绝对收益线**: 绝对收益 ≥ 30% 且持仓 ≥ 90 天时也可考虑卖出\n\n卖出矩阵（按情绪区间和收益档位）：\n\n| 情绪区间 | target_high | target_low | below_target |\n|---------|-------------|------------|--------------|\n| Extreme Greed | 50% | 30% | 20% |\n| Greed | 40% | 20% | 0% |\n| Neutral | 30% | 0% | 0% |\n| Fear/Extreme Fear | 0% | 0% | 0% |\n\n> 注：target_high = 年化收益 ≥ annualized_target_high（默认15%），target_low = 年化收益 ≥ annualized_target_low（默认10%）\n\n### 买入资金分配：Contrarian 权重\n\n可用现金按 contrarian 权重分配到各资产：\n\n- **权重公式**: `weight = min(max_weight, max(1.0, cost_price / current_price))`\n- **解释**: 浮亏资产（当前价格 < 成本价）获得更高权重，符合逆向抄底逻辑\n- **上限控制**: `max_contrarian_weight`（默认 2.0）防止过度集中单一标的\n- **浮盈资产**: 权重为 1.0（基线）\n\n### 风险警告机制\n\n当持仓浮亏 ≥ 20% 时触发风险警告，建议根据市场情绪差异化处理：\n\n| 情绪环境 | 建议操作 |\n|---------|---------|\n| Extreme Fear/Fear | 可能是加仓机会 |\n| Neutral | 审视基本面 |\n| Greed/Extreme Greed | 紧急审视（别人赚钱你还在亏） |\n\n## 常见工作流\n\n### 日常报告（Agent 每日执行）\n\n```bash\n# 1. 自动更新所有资产价格\nmns update-prices\n\n# 2. 查看策略报告\nmns report\n\n# 3. 根据建议执行买入（如有）\nmns buy QQQ 50 445.00\n\n# 4. 记录卖出（如有）\nmns sell QQQ 100 455.00\n\n# 5. 查看最新持仓\nmns portfolio\n```\n\n### 策略参数调优\n\n```bash\n# 查看当前买入比例\nmns config buy_ratio\n\n# 调整极端恐慌买入比例到 60%\nmns config buy_ratio.extreme_fear 60.0\n\n# 降低中性区间买入到 10%\nmns config buy_ratio.neutral 10.0\n\n# 调整卖出矩阵\nmns config sell_ratio.extreme_greed_target_high 70.0\n\n# 调整止盈线\nmns config settings.annualized_target_low 12.0\nmns config settings.annualized_target_high 18.0\n\n# 调整逆向权重上限（防止单标的过度集中）\nmns config settings.max_contrarian_weight 1.5\n```\n\n### 新资产添加流程\n\n```bash\n# 1. 添加资产到池子\nmns add TSLA \"特斯拉\" us_stocks\n\n# 2. 初始建仓买入\nmns buy TSLA 50 250.00\n\n# 3. 更新当前价格\nmns price TSLA 255.00\n```\n\n## 配置参数\n\n完整的配置参数说明请参考 `references/strategy.md`，其中包含：\n- 所有配置项的默认值速查表\n- 策略参数的详细解释\n- 买入/卖出比例矩阵说明\n\n命令使用方法请参考 `references/commands.md`。\n\n## 注意事项\n\n- **价格更新**: 买入/卖出后建议调用 `price` 或 `update-prices` 命令更新价格，确保持仓收益数据准确\n- **时间敏感性**: `report` 和 `sentiment` 命令通过 HTTP 获取实时 CNN Fear & Greed Index，需要网络访问\n- **异步要求**: 这两个命令是异步的，agent 调用时需确保环境支持 async execution\n- **Windows 编码**: PowerShell 默认 GBK 编码可能导致中文乱码，建议使用 UTF-8 终端或重定向输出到文件\n- **年化收益计算**: 使用 `annualized = (current / cost) ^ (365 / holding_days) - 1`，持仓天数 < min_holding_days 时不显示\n- **绝对收益止盈**: 持仓绝对收益 ≥ 30% 且天数 ≥ min_absolute_profit_days 时，即使年化收益率未达阈值也可能触发卖出\n\n## 错误处理\n\n- **网络错误**: `sentiment` 和 `report` 可能因 API 不可用失败，建议重试或使用缓存数据\n- **数据库锁定**: 多进程并发操作 SQLite 会导致锁定，agent 应确保串行访问\n\n## 相关文件\n\n- `references/commands.md` - 完整命令参考\n- `references/strategy.md` - 策略参数详解\n\n## 开源信息\n\nMNS (money-never-sleep) 是开源项目，源码托管于 GitHub：\n\n**[https://github.com/sopaco/money-never-sleep](https://github.com/sopaco/money-never-sleep)**\n\nFile v0.5.8:_meta.json\n\n{\n  \"ownerId\": \"kn7a2vy7ys7aj3gzm2vvw7zc158311b2\",\n  \"slug\": \"money-never-sleep\",\n  \"version\": \"0.5.8\",\n  \"publishedAt\": 1776778851948\n}\n\nFile v0.5.8:references/commands.md\n\n# MNS CLI 命令参考\n\n本文档详细描述 MNS CLI 的所有命令、参数和用法。\n\n## 命令概览\n\n| 命令 | 用途 | 异步 |\n|------|------|------|\n| `init` | 初始化配置文件和数据库 | 否 |\n| `config` | 查看/修改配置 | 否 |\n| `cash` | 现金余额管理 | 否 |\n| `portfolio` | 查看持仓概览 | 否 |\n| `add` | 新增资产到持仓池 | 否 |\n| `buy` | 记录买入交易 | 否 |\n| `sell` | 记录卖出交易 | 否 |\n| `price` | 更新资产当前价格 | 否 |\n| `sentiment` | 查看当前恐贪指数 | 是 |\n| `report` | 生成策略报告 | 是 |\n| `history` | 查看交易历史 | 否 |\n| `backtest` | 策略回测 | 否 |\n| `update-prices` | 自动更新所有资产价格 | 是 |\n\n---\n\n## `init`\n\n**语法**: `mns init [-f, --force]`\n\n**功能**: 初始化配置文件和数据库。\n\n**参数**:\n- `-f, --force`: 跳过确认提示，强制覆盖已有数据\n\n**行为说明**:\n- 如果检测到已有配置文件或数据库，会提示用户确认后再覆盖\n- 使用 `--force` 参数可跳过确认直接覆盖\n\n**示例**:\n```bash\n# 普通初始化（如有数据会提示确认）\nmns init\n\n# 强制初始化（跳过确认）\nmns init --force\n```\n\n**输出示例（已有数据时）**:\n```\n⚠️  检测到已有数据：\n\n继续将覆盖上述文件，数据将丢失。是否继续？[y/N]: y\n✓ 初始化完成\n  配置文件: ~/.mns/config.toml\n  数据库: ~/.mns/mns.db\n  报告目录: ./reports\n```\n\n**注意**: \n- 报告目录默认为当前目录下的 `reports/`，可通过配置修改\n- 输入 `y` 或 `yes` 确认覆盖，其他任何输入都会取消操作\n\n---\n\n## `config`\n\n**语法**: `mns config [KEY] [VALUE]`\n\n**功能**: 查看或修改配置项。支持 dot-path 语法访问嵌套配置。\n\n### 查看所有配置\n```bash\nmns config\n```\n\n输出 TOML 格式的完整配置。\n\n### 查看特定配置项\n```bash\nmns config thresholds.fear\nmns config buy_ratio.extreme_fear\nmns config sell_ratio.extreme_greed_target_high\n```\n\n输出:\n```\nthresholds.fear = 45\nbuy_ratio.extreme_fear = 50.0\nsell_ratio.extreme_greed_target_high = 50.0\n```\n\n### 修改配置项\n```bash\nmns config thresholds.greed 75\nmns config buy_ratio.fear 30.0\n```\n\n**支持的配置路径**:\n\n| 路径 | 说明 | 默认值 |\n|------|------|--------|\n| `settings.annualized_target_low` | 年化止盈下限(%) | 10.0 |\n| `settings.annualized_target_high` | 年化止盈上限(%) | 15.0 |\n| `settings.min_holding_days` | 最小持仓天数 | 45 |\n| `settings.min_absolute_profit_days` | 绝对收益最小天数 | 120 |\n| `settings.max_contrarian_weight` | 最大逆向权重 | 2.0 |\n| `settings.report_output_dir` | 报告输出目录 | ./reports |\n| `allocation.us_stocks` | 美股配置比例(%) | 55.0 |\n| `allocation.cn_stocks` | A股配置比例(%) | 25.0 |\n| `allocation.counter_cyclical` | 逆周期配置比例(%) | 20.0 |\n| `thresholds.extreme_fear` | 极度恐慌阈值 | 30.0 |\n| `thresholds.fear` | 恐慌阈值 | 45.0 |\n| `thresholds.neutral` | 中性阈值 | 55.0 |\n| `thresholds.greed` | 贪婪阈值 | 70.0 |\n| `buy_ratio.extreme_fear` | 极度恐慌买入比例(%) | 60.0 |\n| `buy_ratio.fear` | 恐慌买入比例(%) | 35.0 |\n| `buy_ratio.neutral` | 中性买入比例(%) | 0.0 |\n| `buy_ratio.greed` | 贪婪买入比例(%) | 0.0 |\n| `sell_ratio.extreme_greed_target_high` | 极度贪婪+高收益卖出(%) | 50.0 |\n| `sell_ratio.extreme_greed_target_low` | 极度贪婪+低收益卖出(%) | 30.0 |\n| `sell_ratio.extreme_greed_below_target` | 极度贪婪+未达标卖出(%) | 20.0 |\n| `sell_ratio.greed_target_high` | 贪婪+高收益卖出(%) | 40.0 |\n| `sell_ratio.greed_target_low` | 贪婪+低收益卖出(%) | 25.0 |\n| `sell_ratio.neutral_target_high` | 中性+高收益卖出(%) | 15.0 |\n\n**示例 - 完整参数调优**:\n```bash\n# 调整买入比例\nmns config buy_ratio.extreme_fear 60.0\nmns config buy_ratio.fear 25.0\nmns config buy_ratio.neutral 10.0\n\n# 调整卖出矩阵\nmns config sell_ratio.extreme_greed_target_high 60.0\nmns config sell_ratio.greed_target_high 50.0\n\n# 调整止盈线\nmns config settings.annualized_target_low 12.0\nmns config settings.annualized_target_high 18.0\n\n# 调整逆向权重上限\nmns config settings.max_contrarian_weight 1.5\n```\n\n---\n\n## `cash`\n\n**语法**: `mns cash [ACTION]`\n\n**功能**: 查看或设置现金余额。\n\n### 查看余额\n```bash\nmns cash\n```\n\n输出:\n```\n现金余额: ¥125430.50\n```\n\n### 设置现金余额\n```bash\nmns cash set 100000\n```\n\n### 增加现金\n```bash\nmns cash add 5000\n```\n\n**注意**:\n- `set` 会覆盖当前余额\n- `add` 在当前余额基础上增加\n- 金额不能为负数\n\n---\n\n## `portfolio`\n\n**语法**: `mns portfolio`\n\n**功能**: 显示当前持仓概览，包括：\n- 资产代码和名称\n- 持仓份额和成本价\n- 当前价格（需通过 `price` 命令更新）\n- 持仓市值和盈亏\n- 年化收益率（基于持有天数）\n\n**示例输出**:\n```\n┌───────┬────────────┬──────────┬──────────┬─────────────┬─────────────┬────────────┐\n│ 代码  │   名称     │  份额    │ 成本价   │ 当前价      │  市值       │ 年化收益   │\n├───────┼────────────┼──────────┼──────────┼─────────────┼─────────────┼────────────┤\n│ QQQ   │ 纳指100    │ 150.0    │ 450.00   │ 460.50      │ 69075.00    │  +8.2%     │\n│ SH600 │ 浦发银行   │ 500.0    │ 12.30    │ 12.80       │ 6400.00     │ +15.3%     │\n└───────┴────────────┴──────────┴──────────┴─────────────┴─────────────┴────────────┘\n\n总市值: ¥75475.00\n现金余额: ¥24685.50\n总资产: ¥100160.50\n```\n\n**注意事项**:\n- 年化收益计算公式: `(current / cost) ^ (365 / holding_days) - 1`\n- 如果持有天数小于配置的 `min_holding_days`，年化收益显示为 `N/A`\n- 当前价格需要定期通过 `price` 命令更新\n\n---\n\n## `add`\n\n**语法**: `mns add <CODE> <NAME> <CATEGORY>`\n\n**功能**: 新增资产到持仓池，后续可通过 `buy` 命令买入。\n\n**参数**:\n- `CODE`: 资产代码（如 `QQQ`, `SH600000`, `AAPL`）\n- `NAME`: 资产名称（任意描述性字符串）\n- `CATEGORY`: 类别，预设可选值：\n  - `us_stocks` - 美股\n  - `cn_stocks` - A股\n  - `counter_cyclical` - 逆周期资产\n\n**示例**:\n```bash\nmns add QQQ \"纳指100\" us_stocks\nmns add SH600000 \"浦发银行\" cn_stocks\nmns add GLD \"黄金ETF\" counter_cyclical\n```\n\n**注意**:\n- 资产代码在数据库中必须唯一\n- 添加后立即用 `buy` 记录初始买入\n\n---\n\n## `buy`\n\n**语法**: `mns buy <CODE> <SHARES> <PRICE>`\n\n**功能**: 记录买入交易，增加持仓份额。\n\n**参数**:\n- `CODE`: 资产代码（必须已通过 `add` 添加）\n- `SHARES`: 买入份额（支持小数，如股票可支持碎股）\n- `PRICE`: 买入单价（元/股）\n\n**示例**:\n```bash\n# 买入 100 股 QQQ，单价 450.50 元\nmns buy QQQ 100 450.50\n\n# 买入 50 份黄金 ETF，单价 180.00 元\nmns buy GLD 50 180.00\n```\n\n**行为**:\n- 现金余额相应减少\n- 持仓成本价重新计算（加权平均）\n- 交易记录存入 `transactions` 表\n\n---\n\n## `sell`\n\n**语法**: `mns sell <CODE> <SHARES> <PRICE>`\n\n**功能**: 记录卖出交易，减少持仓份额。\n\n**参数**:\n- `CODE`: 资产代码\n- `SHARES`: 卖出份额（不能超过当前持仓）\n- `PRICE`: 卖出单价\n\n**示例**:\n```bash\n# 卖出 30 股 QQQ，单价 455.00 元\nmns sell QQQ 30 455.00\n\n# 清仓某资产\nmns sell SH600000 500 13.20\n```\n\n**行为**:\n- 现金余额相应增加\n- 持仓份额减少，成本价保持不变（剩余份额）\n- 交易记录存入 `transactions` 表\n\n---\n\n## `price`\n\n**语法**: `mns price <CODE> [PRICE]`\n\n**功能**: 查看或更新单个资产的当前价格。\n\n### 查看当前价格\n```bash\nmns price QQQ\n```\n\n输出:\n```\nQQQ (纳指100): ¥460.50\n```\n\n### 更新当前价格\n```bash\nmns price QQQ 460.50\n```\n\n**注意**:\n- 每次更新价格会更新对应持仓的 `current_price` 和 `current_at` 字段\n- 不更新价格会导致 `portfolio` 和 `report` 显示的市值不准确\n- 如需批量更新所有资产价格，请使用 `update-prices` 命令\n\n---\n\n## `update-prices`\n\n**语法**: `mns update-prices`\n\n**功能**: 自动更新所有持仓资产的当前价格。\n\n**行为说明**:\n- 遍历所有有持仓的资产\n- 尝试从网络获取最新价格（需要网络连接）\n- 更新数据库中的 `current_price` 字段\n- 此命令为异步命令\n\n**示例**:\n```bash\nmns update-prices\n```\n\n**输出示例**:\n```\n正在更新所有资产价格...\n✓ QQQ: 460.50\n✓ SH600000: 12.80\n✓ GLD: 182.35\n已完成 3 个资产的价格更新\n```\n\n**注意**:\n- 需要网络连接\n- 部分资产可能无法获取价格（如 A 股需要特定数据源）\n- 建议在执行 `report` 前先运行此命令\n\n---\n\n## `sentiment`\n\n**语法**: `mns sentiment`\n\n**功能**: 从 CNN 官网获取最新的 Fear & Greed Index 数据。\n\n**示例**:\n```bash\nmns sentiment\n```\n\n输出:\n```\nCNN Fear & Greed Index: 42 (Fear)\nPrevious Close: 38\n1 Week Ago: 35\n1 Month Ago: 28\n```\n\n**注意**:\n- 此命令是异步的，需要网络访问\n- 如果 API 不可用，可能返回错误\n- 数据来自 CNN 官方 API 端点\n\n---\n\n## `report`\n\n**语法**: `mns report`\n\n**功能**: 生成今日策略报告，包含：\n1. 当前恐贪指数和情绪判断\n2. 买入建议（基于可用现金和 contrarian 分配）\n3. 卖出建议（基于年化收益和绝对收益）\n4. 持仓摘要和风险警告（浮亏过大）\n5. 现金预测（按建议执行后）\n\n**示例**:\n```bash\nmns report\n```\n\n**输出节选**:\n```\n╔═══════════════════════════════════════════════════════════════╗\n║           MNS 逆向投资策略报告 - 2026-04-21                     ║\n╚═══════════════════════════════════════════════════════════════╝\n\n📊 市场情绪 (CNN Fear & Greed)\n┌─────────────────────────────────────┐\n│ 当前指数: 42 (Fear)                  │\n│ 状态解读: 市场处于恐慌区间，建议逐步  │\n│         买入                          │\n└─────────────────────────────────────┘\n\n💰 买入建议 (可用现金: ¥25000)\n┌─────────────────────────────────────┐\n│ QQQ (Fear 区间权重: 1.2)             │\n│  建议买入: ¥12000 (50 股 @ ¥240)    │\n│                                     │\n│ SH600000 (Fear 区间权重: 1.5)        │\n│  建议买入: ¥13000 (1042 股 @ ¥12.5) │\n└─────────────────────────────────────┘\n\n⚠️  卖出建议\n┌─────────────────────────────────────┐\n│ 暂无满足卖出条件的持仓              │\n└─────────────────────────────────────┘\n\n🚨 风险警告\n┌─────────────────────────────────────┐\n│ [无]                                │\n└─────────────────────────────────────┘\n```\n\n**注意**:\n- 异步命令，需要网络获取恐贪指数\n- 报告同时保存到报告目录（默认 `./reports/`）\n- 买入/卖出建议仅供参考，agent 需根据实际执行顺序调整\n\n---\n\n## `history`\n\n**语法**: `mns history [--limit N]`\n\n**功能**: 查看最近的交易历史。\n\n**参数**:\n- `--limit N`: 显示条数，默认 20\n\n**示例**:\n```bash\n# 查看最近 20 条\nmns history\n\n# 查看最近 50 条\nmns history --limit 50\n```\n\n**输出**:\n```\n最近交易记录 (按时间倒序):\n┌─────────────────┬───────┬────────┬──────┬────────┬──────────┐\n│ 时间            │ 类型  │ 资产   │ 份额 │ 价格   │ 金额     │\n├─────────────────┼───────┼────────┼──────┼────────┼──────────┤\n│ 2025-06-15 10:30│ buy   │ QQQ    │ 50   │ 448.50 │ 22425.00 │\n│ 2025-06-14 14:20│ sell  │ SH600  │ 100  │ 13.00  │ 1300.00  │\n│ 2025-06-14 09:15│ price │ QQQ    │ -    │ 445.00 │ -        │\n└─────────────────┴───────┴────────┴──────┴────────┴──────────┘\n```\n\n**类型说明**:\n- `buy` - 买入交易\n- `sell` - 卖出交易\n- `price` - 价格更新记录\n\n---\n\n## `backtest`\n\n**语法**: `mns backtest [SUBCOMMAND]`\n\n**功能**: 策略回测相关命令，基于历史数据验证策略表现。\n\n### 子命令\n\n#### `backtest run`\n运行回测。\n\n**语法**: `mns backtest run [-c, --config <PATH>] [-C, --compare <PATHS>]`\n\n**参数**:\n- `-c, --config <PATH>`: 配置文件路径，省略则使用默认配置\n- `-C, --compare <PATHS>`: 对比多个配置文件，逗号分隔\n\n**示例**:\n```bash\n# 使用默认配置运行回测\nmns backtest run\n\n# 指定配置文件\nmns backtest run --config ./my_strategy.toml\n\n# 对比多个策略配置\nmns backtest run --compare config1.toml,config2.toml,config3.toml\n```\n\n#### `backtest params`\n查看可调参数列表。\n\n**语法**: `mns backtest params`\n\n**示例**:\n```bash\nmns backtest params\n```\n\n**输出示例**:\n```\n可调参数列表:\n┌─────────────────────────────┬────────────────┬─────────────────┐\n│ 参数名                       │ 默认值          │ 说明             │\n├─────────────────────────────┼────────────────┼─────────────────┤\n│ buy_ratio.extreme_fear      │ 50.0           │ 极度恐慌买入比例  │\n│ buy_ratio.fear             │ 30.0           │ 恐慌买入比例     │\n│ ...                        │ ...            │ ...             │\n└─────────────────────────────┴────────────────┴─────────────────┘\n```\n\n---\n\n## 通用 Exit Code\n\n| Code | 含义 |\n|------|------|\n| 0    | 成功 |\n| 1    | 通用错误（配置错误、参数错误、数据库错误等） |\n| 2    | 网络错误（仅影响 `sentiment`/`report`/`update-prices`） |\n\n---\n\n## 数据存储位置\n\nMNS 数据存储在用户主目录下的 `.mns` 文件夹：\n\n| 文件 | 路径 | 说明 |\n|------|------|------|\n| 配置文件 | `~/.mns/config.toml` | TOML 格式的策略配置 |\n| 数据库 | `~/.mns/mns.db` | SQLite 数据库 |\n| 报告目录 | `./reports/` | 默认报告输出目录（可配置） |\n\n---\n\n## 数据库 Schema 参考\n\n主要表结构：\n\n### `cash`\n- `id` INTEGER PRIMARY KEY\n- `balance` REAL NOT NULL\n- `updated_at` TIMESTAMP\n\n### `positions`\n- `id` INTEGER PRIMARY KEY\n- `code` TEXT NOT NULL UNIQUE\n- `name` TEXT NOT NULL\n- `category` TEXT NOT NULL\n- `shares` REAL NOT NULL\n- `cost_price` REAL NOT NULL\n- `current_price` REAL NOT NULL\n- `first_buy_date` TEXT NOT NULL\n- `updated_at` TIMESTAMP\n- `created_at` TIMESTAMP\n\n### `transactions`\n- `id` INTEGER PRIMARY KEY\n- `type` TEXT NOT NULL ('buy' | 'sell' | 'price')\n- `code` TEXT NOT NULL\n- `shares` REAL\n- `price` REAL\n- `amount` REAL\n- `created_at` TIMESTAMP\n\n---\n\n## 错误信息速查\n\n| 错误信息 | 原因 | 解决方案 |\n|----------|------|----------|\n| `未知的配置项` | 配置路径错误或不存在 | 用 `config` 查看有效的配置项 |\n| `现金余额不能为负数` | `cash set` 参数 < 0 | 检查金额参数 |\n| `资产代码不存在` | `buy`/`sell`/`price` 使用未添加的代码 | 先用 `add` 添加资产 |\n| `卖出份额超过持仓` | `sell` 参数 > 当前持仓 | 检查持仓数量 |\n| `API error: ...` | CNN API 不可用 | 稍后重试或检查网络 |\n| `Database is locked` | 并发访问数据库 | 确保同一时间只有一个进程操作 |\n\n---\n\n**最后更新**: 2026-04-21\n\nFile v0.5.8:references/strategy.md\n\n# MNS 策略参数参考\n\n本文档详细说明 MNS 逆向投资策略的核心参数，包括阈值定义、买入/卖出比例配置、止盈线设置等。这些参数通过 `mns config` 命令动态调整。\n\n---\n\n## 配置层级\n\nMNS 配置采用分层结构，存储于 `~/.mns/config.toml`：\n\n```toml\n[settings]\nannualized_target_low = 10.0      # 年化止盈线下限(%)\nannualized_target_high = 15.0     # 年化止盈线上限(%)\nmin_holding_days = 45             # 年化收益计算最小天数\nmin_absolute_profit_days = 120    # 绝对收益止盈最小天数\nmax_contrarian_weight = 2.0      # 逆向权重上限\nreport_output_dir = \"./reports\"   # 报告输出目录\n\n[allocation]\nus_stocks = 55.0          # 美股目标配置比例(%)\ncn_stocks = 25.0          # A股目标配置比例(%)\ncounter_cyclical = 20.0   # 逆周期资产配置比例(%)\n\n[thresholds]\nextreme_fear = 30.0       # 极度恐慌阈值\nfear = 45.0               # 恐慌阈值\nneutral = 55.0            # 中性阈值\ngreed = 70.0              # 贪婪阈值\n\n[buy_ratio]\nextreme_fear = 60.0       # 极度恐慌买入比例(%)\nfear = 35.0               # 恐慌买入比例(%)\nneutral = 0.0             # 中性买入比例(%)\ngreed = 0.0               # 贪婪买入比例(%)\n\n[sell_ratio]\nextreme_greed_target_high = 50.0    # 极度贪婪+高年化卖出(%)\nextreme_greed_target_low = 30.0     # 极度贪婪+低年化卖出(%)\nextreme_greed_below_target = 20.0  # 极度贪婪+未达标卖出(%)\ngreed_target_high = 40.0            # 贪婪+高年化卖出(%)\ngreed_target_low = 25.0             # 贪婪+低年化卖出(%)\nneutral_target_high = 15.0          # 中性+高年化卖出(%)\n\n[api]\nfear_greed_url = \"https://production.dataviz.cnn.io/index/fearandgreed/graphdata\"\n```\n\n---\n\n## 恐贪指数区间划分\n\nCNN Fear & Greed Index 是一个 0-100 的指数，0 表示极度恐慌（Extreme Fear），100 表示极度贪婪（Extreme Greed）。\n\n### 默认区间配置\n\n| 区间名称 | 指数范围 | 含义 | 买入比例 |\n|---------|---------|------|---------|\n| Extreme Fear | 0-30 | 市场极度恐慌，逆向买入信号强 | 60% |\n| Fear | 30-45 | 市场恐慌，适度买入 | 35% |\n| Neutral | 45-55 | 中性，观望不买入 | 0% |\n| Greed | 55-70 | 市场贪婪，谨慎持有 | 0% |\n| Extreme Greed | 70-100 | 市场极度贪婪，考虑减仓 | 0% |\n\n### 调整阈值\n\n通过修改 `thresholds` 可改变区间边界：\n\n```bash\n# 将贪婪阈值从 70 降至 65，使贪婪区间更早触发\nmns config thresholds.greed 65.0\n\n# 将极度恐慌阈值从 30 提升至 35，减少极端情况下的买入频率\nmns config thresholds.extreme_fear 35.0\n```\n\n**注意**: 区间必须保持连续性，建议:\n- `extreme_fear < fear < neutral < greed`\n- 阈值单位为百分比数值（如 25.0 表示 25）\n\n---\n\n## 买入比例矩阵 (`buy_ratio`)\n\n定义在不同情绪区间下，用多少比例的可用现金进行买入。\n\n### 参数说明\n\n- **可用现金**: `cash_balance + 卖出回笼资金`（买卖互感知）\n- **分配方式**: 按 contrarian 权重分配到各资产类别\n- **类别配置**: 按 `allocation` 比例分配到美股/A股/逆周期\n\n### 默认配置\n\n| 情绪区间 | 买入比例 | 适用场景 |\n|---------|---------|---------|\n| extreme_fear | 60.0% | 恐慌极致，重仓抄底 |\n| fear | 35.0% | 恐慌情绪，积极建仓 |\n| neutral | 0.0% | 中性市场，观望不买入 |\n| greed | 0.0% | 贪婪时暂停买入 |\n\n### 调优示例\n\n```bash\n# 策略1: 极度贪婪时也可能小幅买入（左侧布局）\nmns config buy_ratio.greed 10.0\n\n# 策略2: 中性区间也暂停买入，只在明确的恐慌区间出手\nmns config buy_ratio.neutral 0.0\n\n# 策略3: 极端恐慌时加大买入\nmns config buy_ratio.extreme_fear 70.0\n```\n\n---\n\n## 卖出比例矩阵 (`sell_ratio`)\n\n定义在特定情绪区间和年化收益档位下的卖出比例。卖出逻辑基于 **双准则**:\n\n1. **年化收益止盈**: 当持仓年化收益率达标且处于可卖出情绪区间\n2. **绝对收益止盈**: 当持仓绝对收益 ≥ 30% 且持有天数足够长\n\n### 收益档位定义\n\n- `target_high`: 年化收益 ≥ `annualized_target_high`（默认 15%）\n- `target_low`: 年化收益 ≥ `annualized_target_low`（默认 10%）但 < target_high\n- `below_target`: 年化收益 < target_low（仅在极度贪婪时考虑部分卖出）\n\n### 默认卖出矩阵\n\n| 情绪区间 | target_high | target_low | below_target |\n|---------|-------------|------------|--------------|\n| extreme_greed | 50% | 30% | 20% |\n| greed | 40% | 25% | 0% |\n| neutral | 15% | 0% | 0% |\n| fear/extreme_fear | 0% | 0% | 0% |\n\n### 配置路径\n\n```bash\n# 查看卖出配置\nmns config sell_ratio\n\n# 调整极度贪婪时的高收益卖出比例\nmns config sell_ratio.extreme_greed_target_high 70.0\n\n# 调整贪婪时的中等收益卖出比例\nmns config sell_ratio.greed_target_low 30.0\n\n# 启用中性区间的部分止盈\nmns config sell_ratio.neutral_target_high 20.0\n```\n\n---\n\n## 止盈线参数 (`settings`)\n\n### `annualized_target_low` (默认 10.0)\n\n年化收益率的下限阈值。当持仓年化收益 ≥ 此值且处于可卖出情绪区间时，触发部分卖出建议。\n\n### `annualized_target_high` (默认 15.0)\n\n年化收益率的上限阈值。当持仓年化收益 ≥ 此值时，卖出比例达到该情绪区间的最大值。\n\n**调优示例**:\n\n```bash\n# 保守止盈：年化 8% 就开始卖\nmns config settings.annualized_target_low 8.0\nmns config settings.annualized_target_high 12.0\n\n# 激进止盈：年化 20% 才开始卖\nmns config settings.annualized_target_low 15.0\nmns config settings.annualized_target_high 25.0\n```\n\n### `min_holding_days` (默认 45)\n\n最小持有天数。持仓天数小于此值时，不计算年化收益率（显示为 N/A），避免短期波动误导。\n\n### `min_absolute_profit_days` (默认 120)\n\n绝对收益止盈的最小天数。只有持仓天数 ≥ 此值且绝对收益 ≥ 30% 时，才触发绝对收益止盈。\n\n**目的**: 避免短期投机操作，确保长期持有才能享受\"坐过山车保护\"。\n\n---\n\n## 逆向权重参数 (`settings`)\n\n### `max_contrarian_weight` (默认 2.0)\n\n逆向权重的上限。防止浮亏过大的标的获得过多资金，导致过度集中风险。\n\n**权重公式**:\n```\nweight = min(max_contrarian_weight, max(1.0, cost_price / current_price))\n```\n\n**调优示例**:\n\n```bash\n# 降低权重上限，避免过度集中\nmns config settings.max_contrarian_weight 1.5\n\n# 提高权重上限，更激进抄底\nmns config settings.max_contrarian_weight 3.0\n```\n\n---\n\n## 资产配置参数 (`allocation`)\n\n定义买入资金在不同资产类别间的目标分配比例。\n\n### 默认配置\n\n| 类别 | 比例 | 说明 |\n|------|------|------|\n| us_stocks | 55% | 美股（如 QQQ, SPY） |\n| cn_stocks | 25% | A股（如沪深300成分股） |\n| counter_cyclical | 20% | 逆周期资产（如黄金ETF, 债券） |\n\n### 注意事项\n\n- 配置比例之和必须为 100%\n- 这是**目标参考比例**，非强制约束\n- 实际分配还会受 contrarian 权重影响\n\n### 调整示例\n\n```bash\n# 查看当前配置\nmns config allocation\n\n# 调整美股占比\nmns config allocation.us_stocks 60.0\nmns config allocation.cn_stocks 30.0\nmns config allocation.counter_cyclical 10.0\n```\n\n---\n\n## 买入资金分配: Contrarian 权重详解\n\nMNS 的买入资金不是平均分配，而是采用 **逆向权重**：\n\n```\nweight_i = min(max_contrarian_weight, max(1.0, cost_price_i / current_price_i))\n```\n\n### 权重计算示例\n\n假设 Fear 区间可用买入资金 30,000 元，有两个美股持仓：\n\n| 资产 | 成本价 | 当前价 | 浮亏/浮盈 | 权重计算 | 权重 |\n|------|--------|--------|----------|---------|------|\n| QQQ  | 450.00 | 460.50 | +2.3%    | min(2.0, max(1.0, 450/460.5)) = 1.0 | 1.0 |\n| AAPL | 180.00 | 150.00 | -16.7%   | min(2.0, max(1.0, 180/150)) = 1.2 | 1.2 |\n\n**分配结果**:\n- QQQ: `30000 × (1.0 / 2.2) = 13,636 元`\n- AAPL: `30000 × (1.2 / 2.2) = 16,364 元`\n\n浮亏资产获得更高权重，符合\"越跌越买\"的逆向逻辑，但权重上限防止过度集中。\n\n### 高浮亏排除机制\n\n当持仓浮亏 ≥ 30% 时，该标的会被**排除加仓列表**，避免\"越亏越买\"的基本面恶化风险。\n\n---\n\n## 卖出决策双准则详解\n\n### 准则1：年化收益 + 情绪区间\n\n当同时满足以下条件时触发：\n1. 当前情绪在可卖出区间（neutral 及以上）\n2. 持仓年化收益 ≥ `annualized_target_low`\n3. 持仓天数 ≥ `min_holding_days`\n\n卖出比例根据年化收益档位和情绪区间从 `sell_ratio` 矩阵查出。\n\n### 准则2：绝对收益止盈\n\n当满足以下条件时触发：\n- 绝对收益 = (当前价 - 成本价) / 成本价 ≥ 30%\n- 持仓天数 ≥ `min_absolute_profit_days`（默认 120 天）\n\n**目的**: 锁定长期盈利，即使年化收益率因持有时间较长而降低。\n\n---\n\n## 风险警告机制\n\n当持仓浮亏 ≥ 20% 时触发风险警告，建议根据市场情绪差异化处理：\n\n| 情绪环境 | 建议操作 |\n|---------|---------|\n| Extreme Fear/Fear | 可能是加仓机会 |\n| Neutral | 审视基本面 |\n| Greed/Extreme Greed | 紧急审视（别人赚钱你还在亏） |\n\n---\n\n## 完整参数调优工作流\n\n### 1. 查看当前配置\n\n```bash\nmns config\n\n# 查看特定分组\nmns config buy_ratio\nmns config sell_ratio\nmns config settings\n```\n\n### 2. 运行回测验证\n\n```bash\n# 查看可调参数\nmns backtest params\n\n# 运行默认配置回测\nmns backtest run\n\n# 测试新参数组合\nmns backtest run --config my_strategy.toml\n```\n\n### 3. 调整参数\n\n```bash\n# 每次只调整 1-2 个参数\nmns config buy_ratio.extreme_fear 60.0\n\n# 观察 report 变化\nmns report\n```\n\n### 4. 备份配置\n\n```bash\nmns config > config_backup_$(date +%Y%m%d).toml\n```\n\n---\n\n## 配置路径速查表\n\n| 配置路径 | 说明 | 默认值 |\n|---------|------|--------|\n| `settings.annualized_target_low` | 年化止盈下限(%) | 10.0 |\n| `settings.annualized_target_high` | 年化止盈上限(%) | 15.0 |\n| `settings.min_holding_days` | 年化收益最小天数 | 45 |\n| `settings.min_absolute_profit_days` | 绝对收益最小天数 | 120 |\n| `settings.max_contrarian_weight` | 逆向权重上限 | 2.0 |\n| `settings.report_output_dir` | 报告输出目录 | ./reports |\n| `allocation.us_stocks` | 美股目标比例(%) | 55.0 |\n| `allocation.cn_stocks` | A股目标比例(%) | 25.0 |\n| `allocation.counter_cyclical` | 逆周期比例(%) | 20.0 |\n| `thresholds.extreme_fear` | 极度恐慌阈值 | 30.0 |\n| `thresholds.fear` | 恐慌阈值 | 45.0 |\n| `thresholds.neutral` | 中性阈值 | 55.0 |\n| `thresholds.greed` | 贪婪阈值 | 70.0 |\n| `buy_ratio.extreme_fear` | 极度恐慌买入(%) | 60.0 |\n| `buy_ratio.fear` | 恐慌买入(%) | 35.0 |\n| `buy_ratio.neutral` | 中性买入(%) | 0.0 |\n| `buy_ratio.greed` | 贪婪买入(%) | 0.0 |\n| `sell_ratio.extreme_greed_target_high` | 极度贪婪高收益卖(%) | 50.0 |\n| `sell_ratio.extreme_greed_target_low` | 极度贪婪低收益卖(%) | 30.0 |\n| `sell_ratio.extreme_greed_below_target` | 极度贪婪未达标卖(%) | 20.0 |\n| `sell_ratio.greed_target_high` | 贪婪高收益卖(%) | 40.0 |\n| `sell_ratio.greed_target_low` | 贪婪低收益卖(%) | 25.0 |\n| `sell_ratio.neutral_target_high` | 中性高收益卖(%) | 15.0 |\n\n---\n\n## 风险提示\n\n- **参数调优需结合实际市场环境**: 回测结果是历史数据，不代表未来表现\n- **避免频繁调整**: 每次调整后至少观察 1-2 个月的实盘表现\n- **分散投资**: `max_contrarian_weight` 可防止单一标的过度集中\n\n---\n\n**文档版本**: v0.5.8 | **更新日期**: 2026-04-21\n\nFile v0.5.8:assets/examples/portfolio-example.json\n\n{\n  \"portfolio\": {\n    \"timestamp\": \"2025-06-16T10:30:00Z\",\n    \"total_value\": 100160.50,\n    \"total_market_value\": 75475.00,\n    \"cash_balance\": 24685.50,\n    \"positions\": [\n      {\n        \"code\": \"QQQ\",\n        \"name\": \"纳指100\",\n        \"category\": \"us_stocks\",\n        \"shares\": 150.0,\n        \"cost_price\": 450.00,\n        \"current_price\": 460.50,\n        \"market_value\": 69075.00,\n        \"cost_basis\": 67500.00,\n        \"absolute_return\": 0.022222,\n        \"absolute_return_amount\": 1575.00,\n        \"annualized_return\": 0.082,\n        \"annualized_return_formatted\": \"+8.2%\",\n        \"holding_days\": 45,\n        \"updated_at\": \"2025-06-16T09:00:00Z\"\n      },\n      {\n        \"code\": \"SH600000\",\n        \"name\": \"浦发银行\",\n        \"category\": \"cn_stocks\",\n        \"shares\": 500.0,\n        \"cost_price\": 12.30,\n        \"current_price\": 12.80,\n        \"market_value\": 6400.00,\n        \"cost_basis\": 6150.00,\n        \"absolute_return\": 0.04065,\n        \"absolute_return_amount\": 250.00,\n        \"annualized_return\": 0.153,\n        \"annualized_return_formatted\": \"+15.3%\",\n        \"holding_days\": 67,\n        \"updated_at\": \"2025-06-16T09:00:00Z\"\n      }\n    ],\n    \"summary\": {\n      \"total_cost_basis\": 73650.00,\n      \"total_absolute_return\": 1825.00,\n      \"total_absolute_return_rate\": 0.02478,\n      \"positions_with_gain\": 2,\n      \"positions_with_loss\": 0,\n      \"average_annualized_return\": 0.1175\n    }\n  }\n}\n\nFile v0.5.8:assets/examples/report-example.json\n\n{\n  \"report\": {\n    \"timestamp\": \"2025-06-16T10:30:00Z\",\n    \"date\": \"2025-06-16\",\n    \"market_sentiment\": {\n      \"fear_greed_index\": 42,\n      \"classification\": \"Fear\",\n      \"previous_close\": 38,\n      \"one_week_ago\": 35,\n      \"one_month_ago\": 28,\n      \"interpretation\": \"市场处于恐慌区间，建议逐步买入\"\n    },\n    \"portfolio_summary\": {\n      \"total_assets\": 100160.50,\n      \"total_market_value\": 75475.00,\n      \"cash_balance\": 24685.50,\n      \"positions_count\": 2,\n      \"total_absolute_return\": 1825.00,\n      \"total_absolute_return_rate\": 0.02478\n    },\n    \"buy_suggestions\": {\n      \"available_cash\": 24685.50,\n      \"total_buy_amount\": 14200.00,\n      \"remaining_cash_after\": 10485.50,\n      \"suggestions\": [\n        {\n          \"code\": \"QQQ\",\n          \"name\": \"纳指100\",\n          \"current_price\": 460.50,\n          \"sentiment_zone\": \"Fear\",\n          \"buy_ratio\": 0.30,\n          \"weight\": 1.0,\n          \"suggested_amount\": 7200.00,\n          \"suggested_shares\": 15.63,\n          \"reason\": \"恐惧区间，按策略买入30%可用现金，该资产浮盈状态权重为1.0\"\n        },\n        {\n          \"code\": \"SH600000\",\n          \"name\": \"浦发银行\",\n          \"current_price\": 11.80,\n          \"sentiment_zone\": \"Fear\",\n          \"buy_ratio\": 0.30,\n          \"weight\": 1.043,\n          \"suggested_amount\": 7000.00,\n          \"suggested_shares\": 593.22,\n          \"reason\": \"恐惧区间，按策略买入30%可用现金，该资产浮亏状态权重提升至1.043\"\n        }\n      ]\n    },\n    \"sell_suggestions\": {\n      \"total_sell_amount\": 0.00,\n      \"suggestions\": []\n    },\n    \"risk_warnings\": {\n      \"has_warnings\": false,\n      \"warnings\": []\n    },\n    \"recommendations\": [\n      \"当前恐惧指数42，市场处于恐慌状态，建议执行上述买入操作\",\n      \"建议在买入后及时更新价格数据，保持持仓准确\",\n      \"检查是否有持仓年化收益达到止盈线，考虑减仓\"\n    ],\n    \"config_snapshot\": {\n      \"thresholds\": {\n        \"extreme_fear\": 25,\n        \"fear\": 45,\n        \"neutral\": 55,\n        \"greed\": 75,\n        \"extreme_greed\": 100\n      },\n      \"buy_ratio\": {\n        \"extreme_fear\": 0.50,\n        \"fear\": 0.30,\n        \"neutral\": 0.20,\n        \"greed\": 0.00\n      },\n      \"sell_ratio\": {\n        \"extreme_greed_above_high\": 0.50,\n        \"extreme_greed_between\": 0.30,\n        \"extreme_greed_below_low\": 0.20,\n        \"greed_above_high\": 0.40,\n        \"greed_between\": 0.20\n      },\n      \"annualized_target_low\": 10.0,\n      \"annualized_target_high\": 15.0\n    }\n  }\n}\n\nArchive v0.5.7: 6 files, 16544 bytes\n\nFiles: assets/examples/portfolio-example.json (1426b), assets/examples/report-example.json (2580b), references/commands.md (17197b), references/strategy.md (11692b), SKILL.md (9140b), _meta.json (136b)\n\nFile v0.5.7:SKILL.md\n\n---\nname: money-never-sleep\nversion: 0.5.7\ndescription: |\n  MNS (Money Never Sleep, Market Neutral Strategist) CLI skill for autonomous agents. Provides investment\n  portfolio tracking, market sentiment analysis using CNN Fear & Greed Index, and strategy\n  suggestion report generation. Use when managing a contrarian investment portfolio,\n  generating buy/sell suggestions based on market sentiment thresholds, or producing\n  daily strategy reports.\n\n  NOTE: This tool provides strategy suggestions only - it does NOT connect to any broker APIs\n  or execute actual trades. All trades must be manually executed by users on their brokerage platforms\n  and then recorded via CLI commands.\n\n  Triggers include: \"管理投资组合\", \"生成策略建议\", \"获取市场报告\", \"查看持仓收益\",\n  \"更新现金余额\", \"记录买入卖出\", \"查看恐贪指数\", \"投资组合再平衡\", \"MNS 报告\", \"回测策略\"\nlicense: MIT\ncompatibility: Requires Node.js 18+ or Bun.\nmetadata:\n  {\n    \"openclaw\":\n      {\n        \"requires\": { \"anyBins\": [\"npx\", \"bunx\", \"npm\", \"bun\"] },\n        \"source\": \"https://github.com/sopaco/money-never-sleep\",\n        \"homepage\": \"https://github.com/sopaco/money-never-sleep\",\n        \"author\": \"Sopaco\",\n        \"os\": [\"darwin\", \"linux\", \"win32\"]\n      }\n  }\n  \n---\n\n# MNS CLI 投资管理 Skill\n\n## 概述\n\n本 skill 提供 MNS 逆向投资策略的 CLI 操作能力。MNS 是基于 CNN Fear & Greed Index 情绪指标的量化投资工具，通过 contrarian 策略在情绪极度恐慌时买入，极度贪婪时卖出，实现市场中性风格的长期投资。\n\n### 安全声明\n\n> - **源码公开**: 所有源码公开托管于 [GitHub](https://github.com/sopaco/money-never-sleep)\n> - **无网络交易**: 不连接任何券商 API，所有数据存储在本地 SQLite 数据库\n> - **无敏感权限**: 无需使用也不自动读取用户任何金融账户配置\n\n## 核心能力\n\n1. **投资组合管理**: 查看持仓、现金余额、资产配置、年化收益\n2. **交易记录**: 记录买入/卖出操作，更新资产当前价格（手动输入或自动获取）\n3. **策略建议**: 自动生成基于最新恐贪指数的买卖建议报告（仅建议，不执行交易）\n4. **配置管理**: 查看和调整策略参数（阈值、买入/卖出比例、止盈线）\n5. **历史查询**: 查看交易历史、价格更新记录\n6. **策略回测**: 基于历史数据验证策略参数表现\n\n> **重要说明**: 本工具仅提供策略建议和记录功能，不连接任何券商 API。\n> 用户需自行在券商平台执行交易后，通过 CLI 记录交易结果。\n\n## 快速开始\n\n### 安装\n\n```bash\n# 通过 npm 安装（推荐）\nnpm install -g @never-sleeps/mns-cli\n\n# 或通过 bun 安装\nbun install -g @never-sleeps/mns-cli\n\n# 或直接使用 npx（无需安装）\nnpx @never-sleeps/mns-cli --help\n```\n\n### 初始化\n\n```bash\n# 初始化配置文件和数据库\n# 如果已有数据，会提示确认后再覆盖\nmns init\n\n# 使用 --force 跳过确认直接覆盖\nmns init --force\n\n# 设置初始现金\nmns cash set 100000\n```\n\n### 添加资产到持仓池\n\n```bash\nmns add QQQ \"纳指100\" us_stocks\nmns add SH600000 \"浦发银行\" cn_stocks\nmns add GLD \"黄金ETF\" counter_cyclical\n```\n\n### 记录买入交易\n\n```bash\nmns buy QQQ 100 450.50\nmns buy SH600000 500 12.30\n```\n\n### 查看持仓和策略建议\n\n```bash\n# 查看当前持仓（含年化收益）\nmns portfolio\n\n# 获取今日策略报告（基于最新恐贪指数）\nmns report\n\n# 查看当前恐贪指数\nmns sentiment\n```\n\n### 更新价格和查看历史\n\n```bash\n# 手动更新单个资产价格\nmns price QQQ 460.00\n\n# 自动更新所有资产价格（需要网络）\nmns update-prices\n\n# 查看最近交易历史\nmns history --limit 50\n\n# 查看现金余额\nmns cash\n```\n\n### 配置管理\n\n```bash\n# 查看所有配置\nmns config\n\n# 查看特定配置项（支持 dot-path 语法）\nmns config thresholds.fear\nmns config buy_ratio.extreme_fear\n\n# 修改配置项（策略参数）\nmns config thresholds.greed 75\nmns config buy_ratio.fear 30.0\nmns config sell_ratio.extreme_greed_target_high 60.0\n```\n\n### 策略回测\n\n```bash\n# 查看可调参数列表\nmns backtest params\n\n# 运行默认配置回测\nmns backtest run\n\n# 使用自定义配置回测\nmns backtest run --config path/to/config.toml\n\n# 对比多个配置\nmns backtest run --compare config1.toml,config2.toml\n```\n\n## 数据存储\n\n- **配置文件**: `~/.mns/config.toml`\n- **数据库**: `~/.mns/mns.db`\n- **报告输出**: `./reports/`（可通过 `settings.report_output_dir` 配置）\n\n## 策略逻辑详解\n\n### 情绪驱动的买入决策\n\n买入比例基于恐贪指数区间：\n\n| 恐贪区间 | 指数范围 | 买入比例 | 逻辑 |\n|---------|---------|---------|------|\n| Extreme Fear | 0-25 | 50% (默认) | 极度恐慌，重仓买入 |\n| Fear | 25-45 | 30% (默认) | 恐慌，适度买入 |\n| Neutral | 45-55 | 20% (默认) | 中性，小额买入 |\n| Greed | 55-75 | 0% (默认) | 贪婪，不买入 |\n| Extreme Greed | 75-100 | 0% (默认) | 极度贪婪，不买入 |\n\n### 卖出决策（双准则）\n\n卖出建议综合考虑：\n1. **年化收益止盈**: 基于持有天数计算年化收益率，对照卖出矩阵\n2. **绝对收益线**: 绝对收益 ≥ 30% 且持仓 ≥ 90 天时也可考虑卖出\n\n卖出矩阵（按情绪区间和收益档位）：\n\n| 情绪区间 | target_high | target_low | below_target |\n|---------|-------------|------------|--------------|\n| Extreme Greed | 50% | 30% | 20% |\n| Greed | 40% | 20% | 0% |\n| Neutral | 30% | 0% | 0% |\n| Fear/Extreme Fear | 0% | 0% | 0% |\n\n> 注：target_high = 年化收益 ≥ annualized_target_high（默认15%），target_low = 年化收益 ≥ annualized_target_low（默认10%）\n\n### 买入资金分配：Contrarian 权重\n\n可用现金按 contrarian 权重分配到各资产：\n\n- **权重公式**: `weight = min(max_weight, max(1.0, cost_price / current_price))`\n- **解释**: 浮亏资产（当前价格 < 成本价）获得更高权重，符合逆向抄底逻辑\n- **上限控制**: `max_contrarian_weight`（默认 2.0）防止过度集中单一标的\n- **浮盈资产**: 权重为 1.0（基线）\n\n### 风险警告机制\n\n当持仓浮亏 ≥ 20% 时触发风险警告，建议根据市场情绪差异化处理：\n\n| 情绪环境 | 建议操作 |\n|---------|---------|\n| Extreme Fear/Fear | 可能是加仓机会 |\n| Neutral | 审视基本面 |\n| Greed/Extreme Greed | 紧急审视（别人赚钱你还在亏） |\n\n## 常见工作流\n\n### 日常报告（Agent 每日执行）\n\n```bash\n# 1. 自动更新所有资产价格\nmns update-prices\n\n# 2. 查看策略报告\nmns report\n\n# 3. 根据建议执行买入（如有）\nmns buy QQQ 50 445.00\n\n# 4. 记录卖出（如有）\nmns sell QQQ 100 455.00\n\n# 5. 查看最新持仓\nmns portfolio\n```\n\n### 策略参数调优\n\n```bash\n# 查看当前买入比例\nmns config buy_ratio\n\n# 调整极端恐慌买入比例到 60%\nmns config buy_ratio.extreme_fear 60.0\n\n# 降低中性区间买入到 10%\nmns config buy_ratio.neutral 10.0\n\n# 调整卖出矩阵\nmns config sell_ratio.extreme_greed_target_high 70.0\n\n# 调整止盈线\nmns config settings.annualized_target_low 12.0\nmns config settings.annualized_target_high 18.0\n\n# 调整逆向权重上限（防止单标的过度集中）\nmns config settings.max_contrarian_weight 1.5\n```\n\n### 新资产添加流程\n\n```bash\n# 1. 添加资产到池子\nmns add TSLA \"特斯拉\" us_stocks\n\n# 2. 初始建仓买入\nmns buy TSLA 50 250.00\n\n# 3. 更新当前价格\nmns price TSLA 255.00\n```\n\n## 配置参数\n\n完整的配置参数说明请参考 `references/strategy.md`，其中包含：\n- 所有配置项的默认值速查表\n- 策略参数的详细解释\n- 买入/卖出比例矩阵说明\n\n命令使用方法请参考 `references/commands.md`。\n\n## 注意事项\n\n- **价格更新**: 买入/卖出后建议调用 `price` 或 `update-prices` 命令更新价格，确保持仓收益数据准确\n- **时间敏感性**: `report` 和 `sentiment` 命令通过 HTTP 获取实时 CNN Fear & Greed Index，需要网络访问\n- **异步要求**: 这两个命令是异步的，agent 调用时需确保环境支持 async execution\n- **Windows 编码**: PowerShell 默认 GBK 编码可能导致中文乱码，建议使用 UTF-8 终端或重定向输出到文件\n- **年化收益计算**: 使用 `annualized = (current / cost) ^ (365 / holding_days) - 1`，持仓天数 < min_holding_days 时不显示\n- **绝对收益止盈**: 持仓绝对收益 ≥ 30% 且天数 ≥ min_absolute_profit_days 时，即使年化收益率未达阈值也可能触发卖出\n\n## 错误处理\n\n- **网络错误**: `sentiment` 和 `report` 可能因 API 不可用失败，建议重试或使用缓存数据\n- **数据库锁定**: 多进程并发操作 SQLite 会导致锁定，agent 应确保串行访问\n\n## 相关文件\n\n- `references/commands.md` - 完整命令参考\n- `references/strategy.md` - 策略参数详解\n\n## 开源信息\n\nMNS (money-never-sleep) 是开源项目，源码托管于 GitHub：\n\n**[https://github.com/sopaco/money-never-sleep](https://github.com/sopaco/money-never-sleep)**\n\nFile v0.5.7:_meta.json\n\n{\n  \"ownerId\": \"kn7a2vy7ys7aj3gzm2vvw7zc158311b2\",\n  \"slug\": \"money-never-sleep\",\n  \"version\": \"0.5.7\",\n  \"publishedAt\": 1776763619121\n}\n\nFile v0.5.7:references/commands.md\n\n# MNS CLI 命令参考\n\n本文档详细描述 MNS CLI 的所有命令、参数和用法。\n\n## 命令概览\n\n| 命令 | 用途 | 异步 |\n|------|------|------|\n| `init` | 初始化配置文件和数据库 | 否 |\n| `config` | 查看/修改配置 | 否 |\n| `cash` | 现金余额管理 | 否 |\n| `portfolio` | 查看持仓概览 | 否 |\n| `add` | 新增资产到持仓池 | 否 |\n| `buy` | 记录买入交易 | 否 |\n| `sell` | 记录卖出交易 | 否 |\n| `price` | 更新资产当前价格 | 否 |\n| `sentiment` | 查看当前恐贪指数 | 是 |\n| `report` | 生成策略报告 | 是 |\n| `history` | 查看交易历史 | 否 |\n| `backtest` | 策略回测 | 否 |\n| `update-prices` | 自动更新所有资产价格 | 是 |\n\n---\n\n## `init`\n\n**语法**: `mns init [-f, --force]`\n\n**功能**: 初始化配置文件和数据库。\n\n**参数**:\n- `-f, --force`: 跳过确认提示，强制覆盖已有数据\n\n**行为说明**:\n- 如果检测到已有配置文件或数据库，会提示用户确认后再覆盖\n- 使用 `--force` 参数可跳过确认直接覆盖\n\n**示例**:\n```bash\n# 普通初始化（如有数据会提示确认）\nmns init\n\n# 强制初始化（跳过确认）\nmns init --force\n```\n\n**输出示例（已有数据时）**:\n```\n⚠️  检测到已有数据：\n\n继续将覆盖上述文件，数据将丢失。是否继续？[y/N]: y\n✓ 初始化完成\n  配置文件: ~/.mns/config.toml\n  数据库: ~/.mns/mns.db\n  报告目录: ./reports\n```\n\n**注意**: \n- 报告目录默认为当前目录下的 `reports/`，可通过配置修改\n- 输入 `y` 或 `yes` 确认覆盖，其他任何输入都会取消操作\n\n---\n\n## `config`\n\n**语法**: `mns config [KEY] [VALUE]`\n\n**功能**: 查看或修改配置项。支持 dot-path 语法访问嵌套配置。\n\n### 查看所有配置\n```bash\nmns config\n```\n\n输出 TOML 格式的完整配置。\n\n### 查看特定配置项\n```bash\nmns config thresholds.fear\nmns config buy_ratio.extreme_fear\nmns config sell_ratio.extreme_greed_target_high\n```\n\n输出:\n```\nthresholds.fear = 45\nbuy_ratio.extreme_fear = 50.0\nsell_ratio.extreme_greed_target_high = 50.0\n```\n\n### 修改配置项\n```bash\nmns config thresholds.greed 75\nmns config buy_ratio.fear 30.0\n```\n\n**支持的配置路径**:\n\n| 路径 | 说明 | 默认值 |\n|------|------|--------|\n| `settings.annualized_target_low` | 年化止盈下限(%) | 10.0 |\n| `settings.annualized_target_high` | 年化止盈上限(%) | 15.0 |\n| `settings.min_holding_days` | 最小持仓天数 | 45 |\n| `settings.min_absolute_profit_days` | 绝对收益最小天数 | 120 |\n| `settings.max_contrarian_weight` | 最大逆向权重 | 2.0 |\n| `settings.report_output_dir` | 报告输出目录 | ./reports |\n| `allocation.us_stocks` | 美股配置比例(%) | 55.0 |\n| `allocation.cn_stocks` | A股配置比例(%) | 25.0 |\n| `allocation.counter_cyclical` | 逆周期配置比例(%) | 20.0 |\n| `thresholds.extreme_fear` | 极度恐慌阈值 | 30.0 |\n| `thresholds.fear` | 恐慌阈值 | 45.0 |\n| `thresholds.neutral` | 中性阈值 | 55.0 |\n| `thresholds.greed` | 贪婪阈值 | 70.0 |\n| `buy_ratio.extreme_fear` | 极度恐慌买入比例(%) | 60.0 |\n| `buy_ratio.fear` | 恐慌买入比例(%) | 35.0 |\n| `buy_ratio.neutral` | 中性买入比例(%) | 0.0 |\n| `buy_ratio.greed` | 贪婪买入比例(%) | 0.0 |\n| `sell_ratio.extreme_greed_target_high` | 极度贪婪+高收益卖出(%) | 50.0 |\n| `sell_ratio.extreme_greed_target_low` | 极度贪婪+低收益卖出(%) | 30.0 |\n| `sell_ratio.extreme_greed_below_target` | 极度贪婪+未达标卖出(%) | 20.0 |\n| `sell_ratio.greed_target_high` | 贪婪+高收益卖出(%) | 40.0 |\n| `sell_ratio.greed_target_low` | 贪婪+低收益卖出(%) | 25.0 |\n| `sell_ratio.neutral_target_high` | 中性+高收益卖出(%) | 15.0 |\n\n**示例 - 完整参数调优**:\n```bash\n# 调整买入比例\nmns config buy_ratio.extreme_fear 60.0\nmns config buy_ratio.fear 25.0\nmns config buy_ratio.neutral 10.0\n\n# 调整卖出矩阵\nmns config sell_ratio.extreme_greed_target_high 60.0\nmns config sell_ratio.greed_target_high 50.0\n\n# 调整止盈线\nmns config settings.annualized_target_low 12.0\nmns config settings.annualized_target_high 18.0\n\n# 调整逆向权重上限\nmns config settings.max_contrarian_weight 1.5\n```\n\n---\n\n## `cash`\n\n**语法**: `mns cash [ACTION]`\n\n**功能**: 查看或设置现金余额。\n\n### 查看余额\n```bash\nmns cash\n```\n\n输出:\n```\n现金余额: ¥125430.50\n```\n\n### 设置现金余额\n```bash\nmns cash set 100000\n```\n\n### 增加现金\n```bash\nmns cash add 5000\n```\n\n**注意**:\n- `set` 会覆盖当前余额\n- `add` 在当前余额基础上增加\n- 金额不能为负数\n\n---\n\n## `portfolio`\n\n**语法**: `mns portfolio`\n\n**功能**: 显示当前持仓概览，包括：\n- 资产代码和名称\n- 持仓份额和成本价\n- 当前价格（需通过 `price` 命令更新）\n- 持仓市值和盈亏\n- 年化收益率（基于持有天数）\n\n**示例输出**:\n```\n┌───────┬────────────┬──────────┬──────────┬─────────────┬─────────────┬────────────┐\n│ 代码  │   名称     │  份额    │ 成本价   │ 当前价      │  市值       │ 年化收益   │\n├───────┼────────────┼──────────┼──────────┼─────────────┼─────────────┼────────────┤\n│ QQQ   │ 纳指100    │ 150.0    │ 450.00   │ 460.50      │ 69075.00    │  +8.2%     │\n│ SH600 │ 浦发银行   │ 500.0    │ 12.30    │ 12.80       │ 6400.00     │ +15.3%     │\n└───────┴────────────┴──────────┴──────────┴─────────────┴─────────────┴────────────┘\n\n总市值: ¥75475.00\n现金余额: ¥24685.50\n总资产: ¥100160.50\n```\n\n**注意事项**:\n- 年化收益计算公式: `(current / cost) ^ (365 / holding_days) - 1`\n- 如果持有天数小于配置的 `min_holding_days`，年化收益显示为 `N/A`\n- 当前价格需要定期通过 `price` 命令更新\n\n---\n\n## `add`\n\n**语法**: `mns add <CODE> <NAME> <CATEGORY>`\n\n**功能**: 新增资产到持仓池，后续可通过 `buy` 命令买入。\n\n**参数**:\n- `CODE`: 资产代码（如 `QQQ`, `SH600000`, `AAPL`）\n- `NAME`: 资产名称（任意描述性字符串）\n- `CATEGORY`: 类别，预设可选值：\n  - `us_stocks` - 美股\n  - `cn_stocks` - A股\n  - `counter_cyclical` - 逆周期资产\n\n**示例**:\n```bash\nmns add QQQ \"纳指100\" us_stocks\nmns add SH600000 \"浦发银行\" cn_stocks\nmns add GLD \"黄金ETF\" counter_cyclical\n```\n\n**注意**:\n- 资产代码在数据库中必须唯一\n- 添加后立即用 `buy` 记录初始买入\n\n---\n\n## `buy`\n\n**语法**: `mns buy <CODE> <SHARES> <PRICE>`\n\n**功能**: 记录买入交易，增加持仓份额。\n\n**参数**:\n- `CODE`: 资产代码（必须已通过 `add` 添加）\n- `SHARES`: 买入份额（支持小数，如股票可支持碎股）\n- `PRICE`: 买入单价（元/股）\n\n**示例**:\n```bash\n# 买入 100 股 QQQ，单价 450.50 元\nmns buy QQQ 100 450.50\n\n# 买入 50 份黄金 ETF，单价 180.00 元\nmns buy GLD 50 180.00\n```\n\n**行为**:\n- 现金余额相应减少\n- 持仓成本价重新计算（加权平均）\n- 交易记录存入 `transactions` 表\n\n---\n\n## `sell`\n\n**语法**: `mns sell <CODE> <SHARES> <PRICE>`\n\n**功能**: 记录卖出交易，减少持仓份额。\n\n**参数**:\n- `CODE`: 资产代码\n- `SHARES`: 卖出份额（不能超过当前持仓）\n- `PRICE`: 卖出单价\n\n**示例**:\n```bash\n# 卖出 30 股 QQQ，单价 455.00 元\nmns sell QQQ 30 455.00\n\n# 清仓某资产\nmns sell SH600000 500 13.20\n```\n\n**行为**:\n- 现金余额相应增加\n- 持仓份额减少，成本价保持不变（剩余份额）\n- 交易记录存入 `transactions` 表\n\n---\n\n## `price`\n\n**语法**: `mns price <CODE> [PRICE]`\n\n**功能**: 查看或更新单个资产的当前价格。\n\n### 查看当前价格\n```bash\nmns price QQQ\n```\n\n输出:\n```\nQQQ (纳指100): ¥460.50\n```\n\n### 更新当前价格\n```bash\nmns price QQQ 460.50\n```\n\n**注意**:\n- 每次更新价格会更新对应持仓的 `current_price` 和 `current_at` 字段\n- 不更新价格会导致 `portfolio` 和 `report` 显示的市值不准确\n- 如需批量更新所有资产价格，请使用 `update-prices` 命令\n\n---\n\n## `update-prices`\n\n**语法**: `mns update-prices`\n\n**功能**: 自动更新所有持仓资产的当前价格。\n\n**行为说明**:\n- 遍历所有有持仓的资产\n- 尝试从网络获取最新价格（需要网络连接）\n- 更新数据库中的 `current_price` 字段\n- 此命令为异步命令\n\n**示例**:\n```bash\nmns update-prices\n```\n\n**输出示例**:\n```\n正在更新所有资产价格...\n✓ QQQ: 460.50\n✓ SH600000: 12.80\n✓ GLD: 182.35\n已完成 3 个资产的价格更新\n```\n\n**注意**:\n- 需要网络连接\n- 部分资产可能无法获取价格（如 A 股需要特定数据源）\n- 建议在执行 `report` 前先运行此命令\n\n---\n\n## `sentiment`\n\n**语法**: `mns sentiment`\n\n**功能**: 从 CNN 官网获取最新的 Fear & Greed Index 数据。\n\n**示例**:\n```bash\nmns sentiment\n```\n\n输出:\n```\nCNN Fear & Greed Index: 42 (Fear)\nPrevious Close: 38\n1 Week Ago: 35\n1 Month Ago: 28\n```\n\n**注意**:\n- 此命令是异步的，需要网络访问\n- 如果 API 不可用，可能返回错误\n- 数据来自 CNN 官方 API 端点\n\n---\n\n## `report`\n\n**语法**: `mns report`\n\n**功能**: 生成今日策略报告，包含：\n1. 当前恐贪指数和情绪判断\n2. 买入建议（基于可用现金和 contrarian 分配）\n3. 卖出建议（基于年化收益和绝对收益）\n4. 持仓摘要和风险警告（浮亏过大）\n5. 现金预测（按建议执行后）\n\n**示例**:\n```bash\nmns report\n```\n\n**输出节选**:\n```\n╔═══════════════════════════════════════════════════════════════╗\n║           MNS 逆向投资策略报告 - 2026-04-21                     ║\n╚═══════════════════════════════════════════════════════════════╝\n\n📊 市场情绪 (CNN Fear & Greed)\n┌─────────────────────────────────────┐\n│ 当前指数: 42 (Fear)                  │\n│ 状态解读: 市场处于恐慌区间，建议逐步  │\n│         买入                          │\n└─────────────────────────────────────┘\n\n💰 买入建议 (可用现金: ¥25000)\n┌─────────────────────────────────────┐\n│ QQQ (Fear 区间权重: 1.2)             │\n│  建议买入: ¥12000 (50 股 @ ¥240)    │\n│                                     │\n│ SH600000 (Fear 区间权重: 1.5)        │\n│  建议买入: ¥13000 (1042 股 @ ¥12.5) │\n└─────────────────────────────────────┘\n\n⚠️  卖出建议\n┌─────────────────────────────────────┐\n│ 暂无满足卖出条件的持仓              │\n└─────────────────────────────────────┘\n\n🚨 风险警告\n┌─────────────────────────────────────┐\n│ [无]                                │\n└─────────────────────────────────────┘\n```\n\n**注意**:\n- 异步命令，需要网络获取恐贪指数\n- 报告同时保存到报告目录（默认 `./reports/`）\n- 买入/卖出建议仅供参考，agent 需根据实际执行顺序调整\n\n---\n\n## `history`\n\n**语法**: `mns history [--limit N]`\n\n**功能**: 查看最近的交易历史。\n\n**参数**:\n- `--limit N`: 显示条数，默认 20\n\n**示例**:\n```bash\n# 查看最近 20 条\nmns history\n\n# 查看最近 50 条\nmns history --limit 50\n```\n\n**输出**:\n```\n最近交易记录 (按时间倒序):\n┌─────────────────┬───────┬────────┬──────┬────────┬──────────┐\n│ 时间            │ 类型  │ 资产   │ 份额 │ 价格   │ 金额     │\n├─────────────────┼───────┼────────┼──────┼────────┼──────────┤\n│ 2025-06-15 10:30│ buy   │ QQQ    │ 50   │ 448.50 │ 22425.00 │\n│ 2025-06-14 14:20│ sell  │ SH600  │ 100  │ 13.00  │ 1300.00  │\n│ 2025-06-14 09:15│ price │ QQQ    │ -    │ 445.00 │ -        │\n└─────────────────┴───────┴────────┴──────┴────────┴──────────┘\n```\n\n**类型说明**:\n- `buy` - 买入交易\n- `sell` - 卖出交易\n- `price` - 价格更新记录\n\n---\n\n## `backtest`\n\n**语法**: `mns backtest [SUBCOMMAND]`\n\n**功能**: 策略回测相关命令，基于历史数据验证策略表现。\n\n### 子命令\n\n#### `backtest run`\n运行回测。\n\n**语法**: `mns backtest run [-c, --config <PATH>] [-C, --compare <PATHS>]`\n\n**参数**:\n- `-c, --config <PATH>`: 配置文件路径，省略则使用默认配置\n- `-C, --compare <PATHS>`: 对比多个配置文件，逗号分隔\n\n**示例**:\n```bash\n# 使用默认配置运行回测\nmns backtest run\n\n# 指定配置文件\nmns backtest run --config ./my_strategy.toml\n\n# 对比多个策略配置\nmns backtest run --compare config1.toml,config2.toml,config3.toml\n```\n\n#### `backtest params`\n查看可调参数列表。\n\n**语法**: `mns backtest params`\n\n**示例**:\n```bash\nmns backtest params\n```\n\n**输出示例**:\n```\n可调参数列表:\n┌─────────────────────────────┬────────────────┬─────────────────┐\n│ 参数名                       │ 默认值          │ 说明             │\n├─────────────────────────────┼────────────────┼─────────────────┤\n│ buy_ratio.extreme_fear      │ 50.0           │ 极度恐慌买入比例  │\n│ buy_ratio.fear             │ 30.0           │ 恐慌买入比例     │\n│ ...                        │ ...            │ ...             │\n└─────────────────────────────┴────────────────┴─────────────────┘\n```\n\n---\n\n## 通用 Exit Code\n\n| Code | 含义 |\n|------|------|\n| 0    | 成功 |\n| 1    | 通用错误（配置错误、参数错误、数据库错误等） |\n| 2    | 网络错误（仅影响 `sentiment`/`report`/`update-prices`） |\n\n---\n\n## 数据存储位置\n\nMNS 数据存储在用户主目录下的 `.mns` 文件夹：\n\n| 文件 | 路径 | 说明 |\n|------|------|------|\n| 配置文件 | `~/.mns/config.toml` | TOML 格式的策略配置 |\n| 数据库 | `~/.mns/mns.db` | SQLite 数据库 |\n| 报告目录 | `./reports/` | 默认报告输出目录（可配置） |\n\n---\n\n## 数据库 Schema 参考\n\n主要表结构：\n\n### `cash`\n- `id` INTEGER PRIMARY KEY\n- `balance` REAL NOT NULL\n- `updated_at` TIMESTAMP\n\n### `positions`\n- `id` INTEGER PRIMARY KEY\n- `code` TEXT NOT NULL UNIQUE\n- `name` TEXT NOT NULL\n- `category` TEXT NOT NULL\n- `shares` REAL NOT NULL\n- `cost_price` REAL NOT NULL\n- `current_price` REAL NOT NULL\n- `first_buy_date` TEXT NOT NULL\n- `updated_at` TIMESTAMP\n- `created_at` TIMESTAMP\n\n### `transactions`\n- `id` INTEGER PRIMARY KEY\n- `type` TEXT NOT NULL ('buy' | 'sell' | 'price')\n- `code` TEXT NOT NULL\n- `shares` REAL\n- `price` REAL\n- `amount` REAL\n- `created_at` TIMESTAMP\n\n---\n\n## 错误信息速查\n\n| 错误信息 | 原因 | 解决方案 |\n|----------|------|----------|\n| `未知的配置项` | 配置路径错误或不存在 | 用 `config` 查看有效的配置项 |\n| `现金余额不能为负数` | `cash set` 参数 < 0 | 检查金额参数 |\n| `资产代码不存在` | `buy`/`sell`/`price` 使用未添加的代码 | 先用 `add` 添加资产 |\n| `卖出份额超过持仓` | `sell` 参数 > 当前持仓 | 检查持仓数量 |\n| `API error: ...` | CNN API 不可用 | 稍后重试或检查网络 |\n| `Database is locked` | 并发访问数据库 | 确保同一时间只有一个进程操作 |\n\n---\n\n**最后更新**: 2026-04-21\n\nFile v0.5.7:references/strategy.md\n\n# MNS 策略参数参考\n\n本文档详细说明 MNS 逆向投资策略的核心参数，包括阈值定义、买入/卖出比例配置、止盈线设置等。这些参数通过 `mns config` 命令动态调整。\n\n---\n\n## 配置层级\n\nMNS 配置采用分层结构，存储于 `~/.mns/config.toml`：\n\n```toml\n[settings]\nannualized_target_low = 10.0      # 年化止盈线下限(%)\nannualized_target_high = 15.0     # 年化止盈线上限(%)\nmin_holding_days = 45             # 年化收益计算最小天数\nmin_absolute_profit_days = 120    # 绝对收益止盈最小天数\nmax_contrarian_weight = 2.0      # 逆向权重上限\nreport_output_dir = \"./reports\"   # 报告输出目录\n\n[allocation]\nus_stocks = 55.0          # 美股目标配置比例(%)\ncn_stocks = 25.0          # A股目标配置比例(%)\ncounter_cyclical = 20.0   # 逆周期资产配置比例(%)\n\n[thresholds]\nextreme_fear = 30.0       # 极度恐慌阈值\nfear = 45.0               # 恐慌阈值\nneutral = 55.0            # 中性阈值\ngreed = 70.0              # 贪婪阈值\n\n[buy_ratio]\nextreme_fear = 60.0       # 极度恐慌买入比例(%)\nfear = 35.0               # 恐慌买入比例(%)\nneutral = 0.0             # 中性买入比例(%)\ngreed = 0.0               # 贪婪买入比例(%)\n\n[sell_ratio]\nextreme_greed_target_high = 50.0    # 极度贪婪+高年化卖出(%)\nextreme_greed_target_low = 30.0     # 极度贪婪+低年化卖出(%)\nextreme_greed_below_target = 20.0  # 极度贪婪+未达标卖出(%)\ngreed_target_high = 40.0            # 贪婪+高年化卖出(%)\ngreed_target_low = 25.0             # 贪婪+低年化卖出(%)\nneutral_target_high = 15.0          # 中性+高年化卖出(%)\n\n[api]\nfear_greed_url = \"https://production.dataviz.cnn.io/index/fearandgreed/graphdata\"\n```\n\n---\n\n## 恐贪指数区间划分\n\nCNN Fear & Greed Index 是一个 0-100 的指数，0 表示极度恐慌（Extreme Fear），100 表示极度贪婪（Extreme Greed）。\n\n### 默认区间配置\n\n| 区间名称 | 指数范围 | 含义 | 买入比例 |\n|---------|---------|------|---------|\n| Extreme Fear | 0-30 | 市场极度恐慌，逆向买入信号强 | 60% |\n| Fear | 30-45 | 市场恐慌，适度买入 | 35% |\n| Neutral | 45-55 | 中性，观望不买入 | 0% |\n| Greed | 55-70 | 市场贪婪，谨慎持有 | 0% |\n| Extreme Greed | 70-100 | 市场极度贪婪，考虑减仓 | 0% |\n\n### 调整阈值\n\n通过修改 `thresholds` 可改变区间边界：\n\n```bash\n# 将贪婪阈值从 70 降至 65，使贪婪区间更早触发\nmns config thresholds.greed 65.0\n\n# 将极度恐慌阈值从 30 提升至 35，减少极端情况下的买入频率\nmns config thresholds.extreme_fear 35.0\n```\n\n**注意**: 区间必须保持连续性，建议:\n- `extreme_fear < fear < neutral < greed`\n- 阈值单位为百分比数值（如 25.0 表示 25）\n\n---\n\n## 买入比例矩阵 (`buy_ratio`)\n\n定义在不同情绪区间下，用多少比例的可用现金进行买入。\n\n### 参数说明\n\n- **可用现金**: `cash_balance + 卖出回笼资金`（买卖互感知）\n- **分配方式**: 按 contrarian 权重分配到各资产类别\n- **类别配置**: 按 `allocation` 比例分配到美股/A股/逆周期\n\n### 默认配置\n\n| 情绪区间 | 买入比例 | 适用场景 |\n|---------|---------|---------|\n| extreme_fear | 60.0% | 恐慌极致，重仓抄底 |\n| fear | 35.0% | 恐慌情绪，积极建仓 |\n| neutral | 0.0% | 中性市场，观望不买入 |\n| greed | 0.0% | 贪婪时暂停买入 |\n\n### 调优示例\n\n```bash\n# 策略1: 极度贪婪时也可能小幅买入（左侧布局）\nmns config buy_ratio.greed 10.0\n\n# 策略2: 中性区间也暂停买入，只在明确的恐慌区间出手\nmns config buy_ratio.neutral 0.0\n\n# 策略3: 极端恐慌时加大买入\nmns config buy_ratio.extreme_fear 70.0\n```\n\n---\n\n## 卖出比例矩阵 (`sell_ratio`)\n\n定义在特定情绪区间和年化收益档位下的卖出比例。卖出逻辑基于 **双准则**:\n\n1. **年化收益止盈**: 当持仓年化收益率达标且处于可卖出情绪区间\n2. **绝对收益止盈**: 当持仓绝对收益 ≥ 30% 且持有天数足够长\n\n### 收益档位定义\n\n- `target_high`: 年化收益 ≥ `annualized_target_high`（默认 15%）\n- `target_low`: 年化收益 ≥ `annualized_target_low`（默认 10%）但 < target_high\n- `below_target`: 年化收益 < target_low（仅在极度贪婪时考虑部分卖出）\n\n### 默认卖出矩阵\n\n| 情绪区间 | target_high | target_low | below_target |\n|---------|-------------|------------|--------------|\n| extreme_greed | 50% | 30% | 20% |\n| greed | 40% | 25% | 0% |\n| neutral | 15% | 0% | 0% |\n| fear/extreme_fear | 0% | 0% | 0% |\n\n### 配置路径\n\n```bash\n# 查看卖出配置\nmns config sell_ratio\n\n# 调整极度贪婪时的高收益卖出比例\nmns config sell_ratio.extreme_greed_target_high 70.0\n\n# 调整贪婪时的中等收益卖出比例\nmns config sell_ratio.greed_target_low 30.0\n\n# 启用中性区间的部分止盈\nmns config sell_ratio.neutral_target_high 20.0\n```\n\n---\n\n## 止盈线参数 (`settings`)\n\n### `annualized_target_low` (默认 10.0)\n\n年化收益率的下限阈值。当持仓年化收益 ≥ 此值且处于可卖出情绪区间时，触发部分卖出建议。\n\n### `annualized_target_high` (默认 15.0)\n\n年化收益率的上限阈值。当持仓年化收益 ≥ 此值时，卖出比例达到该情绪区间的最大值。\n\n**调优示例**:\n\n```bash\n# 保守止盈：年化 8% 就开始卖\nmns config settings.annualized_target_low 8.0\nmns config settings.annualized_target_high 12.0\n\n# 激进止盈：年化 20% 才开始卖\nmns config settings.annualized_target_low 15.0\nmns config settings.annualized_target_high 25.0\n```\n\n### `min_holding_days` (默认 45)\n\n最小持有天数。持仓天数小于此值时，不计算年化收益率（显示为 N/A），避免短期波动误导。\n\n### `min_absolute_profit_days` (默认 120)\n\n绝对收益止盈的最小天数。只有持仓天数 ≥ 此值且绝对收益 ≥ 30% 时，才触发绝对收益止盈。\n\n**目的**: 避免短期投机操作，确保长期持有才能享受\"坐过山车保护\"。\n\n---\n\n## 逆向权重参数 (`settings`)\n\n### `max_contrarian_weight` (默认 2.0)\n\n逆向权重的上限。防止浮亏过大的标的获得过多资金，导致过度集中风险。\n\n**权重公式**:\n```\nweight = min(max_contrarian_weight, max(1.0, cost_price / current_price))\n```\n\n**调优示例**:\n\n```bash\n# 降低权重上限，避免过度集中\nmns config settings.max_contrarian_weight 1.5\n\n# 提高权重上限，更激进抄底\nmns config settings.max_contrarian_weight 3.0\n```\n\n---\n\n## 资产配置参数 (`allocation`)\n\n定义买入资金在不同资产类别间的目标分配比例。\n\n### 默认配置\n\n| 类别 | 比例 | 说明 |\n|------|------|------|\n| us_stocks | 55% | 美股（如 QQQ, SPY） |\n| cn_stocks | 25% | A股（如沪深300成分股） |\n| counter_cyclical | 20% | 逆周期资产（如黄金ETF, 债券） |\n\n### 注意事项\n\n- 配置比例之和必须为 100%\n- 这是**目标参考比例**，非强制约束\n- 实际分配还会受 contrarian 权重影响\n\n### 调整示例\n\n```bash\n# 查看当前配置\nmns config allocation\n\n# 调整美股占比\nmns config allocation.us_stocks 60.0\nmns config allocation.cn_stocks 30.0\nmns config allocation.counter_cyclical 10.0\n```\n\n---\n\n## 买入资金分配: Contrarian 权重详解\n\nMNS 的买入资金不是平均分配，而是采用 **逆向权重**：\n\n```\nweight_i = min(max_contrarian_weight, max(1.0, cost_price_i / current_price_i))\n```\n\n### 权重计算示例\n\n假设 Fear 区间可用买入资金 30,000 元，有两个美股持仓：\n\n| 资产 | 成本价 | 当前价 | 浮亏/浮盈 | 权重计算 | 权重 |\n|------|--------|--------|----------|---------|------|\n| QQQ  | 450.00 | 460.50 | +2.3%    | min(2.0, max(1.0, 450/460.5)) = 1.0 | 1.0 |\n| AAPL | 180.00 | 150.00 | -16.7%   | min(2.0, max(1.0, 180/150)) = 1.2 | 1.2 |\n\n**分配结果**:\n- QQQ: `30000 × (1.0 / 2.2) = 13,636 元`\n- AAPL: `30000 × (1.2 / 2.2) = 16,364 元`\n\n浮亏资产获得更高权重，符合\"越跌越买\"的逆向逻辑，但权重上限防止过度集中。\n\n### 高浮亏排除机制\n\n当持仓浮亏 ≥ 30% 时，该标的会被**排除加仓列表**，避免\"越亏越买\"的基本面恶化风险。\n\n---\n\n## 卖出决策双准则详解\n\n### 准则1：年化收益 + 情绪区间\n\n当同时满足以下条件时触发：\n1. 当前情绪在可卖出区间（neutral 及以上）\n2. 持仓年化收益 ≥ `annualized_target_low`\n3. 持仓天数 ≥ `min_holding_days`\n\n卖出比例根据年化收益档位和情绪区间从 `sell_ratio` 矩阵查出。\n\n### 准则2：绝对收益止盈\n\n当满足以下条件时触发：\n- 绝对收益 = (当前价 - 成本价) / 成本价 ≥ 30%\n- 持仓天数 ≥ `min_absolute_profit_days`（默认 120 天）\n\n**目的**: 锁定长期盈利，即使年化收益率因持有时间较长而降低。\n\n---\n\n## 风险警告机制\n\n当持仓浮亏 ≥ 20% 时触发风险警告，建议根据市场情绪差异化处理：\n\n| 情绪环境 | 建议操作 |\n|---------|---------|\n| Extreme Fear/Fear | 可能是加仓机会 |\n| Neutral | 审视基本面 |\n| Greed/Extreme Greed | 紧急审视（别人赚钱你还在亏） |\n\n---\n\n## 完整参数调优工作流\n\n### 1. 查看当前配置\n\n```bash\nmns config\n\n# 查看特定分组\nmns config buy_ratio\nmns config sell_ratio\nmns config settings\n```\n\n### 2. 运行回测验证\n\n```bash\n# 查看可调参数\nmns backtest params\n\n# 运行默认配置回测\nmns backtest run\n\n# 测试新参数组合\nmns backtest run --config my_strategy.toml\n```\n\n### 3. 调整参数\n\n```bash\n# 每次只调整 1-2 个参数\nmns config buy_ratio.extreme_fear 60.0\n\n# 观察 report 变化\nmns report\n```\n\n### 4. 备份配置\n\n```bash\nmns config > config_backup_$(date +%Y%m%d).toml\n```\n\n---\n\n## 配置路径速查表\n\n| 配置路径 | 说明 | 默认值 |\n|---------|------|--------|\n| `settings.annualized_target_low` | 年化止盈下限(%) | 10.0 |\n| `settings.annualized_target_high` | 年化止盈上限(%) | 15.0 |\n| `settings.min_holding_days` | 年化收益最小天数 | 45 |\n| `settings.min_absolute_profit_days` | 绝对收益最小天数 | 120 |\n| `settings.max_contrarian_weight` | 逆向权重上限 | 2.0 |\n| `settings.report_output_dir` | 报告输出目录 | ./reports |\n| `allocation.us_stocks` | 美股目标比例(%) | 55.0 |\n| `allocation.cn_stocks` | A股目标比例(%) | 25.0 |\n| `allocation.counter_cyclical` | 逆周期比例(%) | 20.0 |\n| `thresholds.extreme_fear` | 极度恐慌阈值 | 30.0 |\n| `thresholds.fear` | 恐慌阈值 | 45.0 |\n| `thresholds.neutral` | 中性阈值 | 55.0 |\n| `thresholds.greed` | 贪婪阈值 | 70.0 |\n| `buy_ratio.extreme_fear` | 极度恐慌买入(%) | 60.0 |\n| `buy_ratio.fear` | 恐慌买入(%) | 35.0 |\n| `buy_ratio.neutral` | 中性买入(%) | 0.0 |\n| `buy_ratio.greed` | 贪婪买入(%) | 0.0 |\n| `sell_ratio.extreme_greed_target_high` | 极度贪婪高收益卖(%) | 50.0 |\n| `sell_ratio.extreme_greed_target_low` | 极度贪婪低收益卖(%) | 30.0 |\n| `sell_ratio.extreme_greed_below_target` | 极度贪婪未达标卖(%) | 20.0 |\n| `sell_ratio.greed_target_high` | 贪婪高收益卖(%) | 40.0 |\n| `sell_ratio.greed_target_low` | 贪婪低收益卖(%) | 25.0 |\n| `sell_ratio.neutral_target_high` | 中性高收益卖(%) | 15.0 |\n\n---\n\n## 风险提示\n\n- **参数调优需结合实际市场环境**: 回测结果是历史数据，不代表未来表现\n- **避免频繁调整**: 每次调整后至少观察 1-2 个月的实盘表现\n- **分散投资**: `max_contrarian_weight` 可防止单一标的过度集中\n\n---\n\n**文档版本**: v0.5.7 | **更新日期**: 2026-04-21\n\nFile v0.5.7:assets/examples/portfolio-example.json\n\n{\n  \"portfolio\": {\n    \"timestamp\": \"2025-06-16T10:30:00Z\",\n    \"total_value\": 100160.50,\n    \"total_market_value\": 75475.00,\n    \"cash_balance\": 24685.50,\n    \"positions\": [\n      {\n        \"code\": \"QQQ\",\n        \"name\": \"纳指100\",\n        \"category\": \"us_stocks\",\n        \"shares\": 150.0,\n        \"cost_price\": 450.00,\n        \"current_price\": 460.50,\n        \"market_value\": 69075.00,\n        \"cost_basis\": 67500.00,\n        \"absolute_return\": 0.022222,\n        \"absolute_return_amount\": 1575.00,\n        \"annualized_return\": 0.082,\n        \"annualized_return_formatted\": \"+8.2%\",\n        \"holding_days\": 45,\n        \"updated_at\": \"2025-06-16T09:00:00Z\"\n      },\n      {\n        \"code\": \"SH600000\",\n        \"name\": \"浦发银行\",\n        \"category\": \"cn_stocks\",\n        \"shares\": 500.0,\n        \"cost_price\": 12.30,\n        \"current_price\": 12.80,\n        \"market_value\": 6400.00,\n        \"cost_basis\": 6150.00,\n        \"absolute_return\": 0.04065,\n        \"absolute_return_amount\": 250.00,\n        \"annualized_return\": 0.153,\n        \"annualized_return_formatted\": \"+15.3%\",\n        \"holding_days\": 67,\n        \"updated_at\": \"2025-06-16T09:00:00Z\"\n      }\n    ],\n    \"summary\": {\n      \"total_cost_basis\": 73650.00,\n      \"total_absolute_return\": 1825.00,\n      \"total_absolute_return_rate\": 0.02478,\n      \"positions_with_gain\": 2,\n      \"positions_with_loss\": 0,\n      \"average_annualized_return\": 0.1175\n    }\n  }\n}\n\nFile v0.5.7:assets/examples/report-example.json\n\n{\n  \"report\": {\n    \"timestamp\": \"2025-06-16T10:30:00Z\",\n    \"date\": \"2025-06-16\",\n    \"market_sentiment\": {\n      \"fear_greed_index\": 42,\n      \"classification\": \"Fear\",\n      \"previous_close\": 38,\n      \"one_week_ago\": 35,\n      \"one_month_ago\": 28,\n      \"interpretation\": \"市场处于恐慌区间，建议逐步买入\"\n    },\n    \"portfolio_summary\": {\n      \"total_assets\": 100160.50,\n      \"total_market_value\": 75475.00,\n      \"cash_balance\": 24685.50,\n      \"positions_count\": 2,\n      \"total_absolute_return\": 1825.00,\n      \"total_absolute_return_rate\": 0.02478\n    },\n    \"buy_suggestions\": {\n      \"available_cash\": 24685.50,\n      \"total_buy_amount\": 14200.00,\n      \"remaining_cash_after\": 10485.50,\n      \"suggestions\": [\n        {\n          \"code\": \"QQQ\",\n          \"name\": \"纳指100\",\n          \"current_price\": 460.50,\n          \"sentiment_zone\": \"Fear\",\n          \"buy_ratio\": 0.30,\n          \"weight\": 1.0,\n          \"suggested_amount\": 7200.00,\n          \"suggested_shares\": 15.63,\n          \"reason\": \"恐惧区间，按策略买入30%可用现金，该资产浮盈状态权重为1.0\"\n        },\n        {\n          \"code\": \"SH600000\",\n          \"name\": \"浦发银行\",\n          \"current_price\": 11.80,\n          \"sentiment_zone\": \"Fear\",\n          \"buy_ratio\": 0.30,\n          \"weight\": 1.043,\n          \"suggested_amount\": 7000.00,\n          \"suggested_shares\": 593.22,\n          \"reason\": \"恐惧区间，按策略买入30%可用现金，该资产浮亏状态权重提升至1.043\"\n        }\n      ]\n    },\n    \"sell_suggestions\": {\n      \"total_sell_amount\": 0.00,\n      \"suggestions\": []\n    },\n    \"risk_warnings\": {\n      \"has_warnings\": false,\n      \"warnings\": []\n    },\n    \"recommendations\": [\n      \"当前恐惧指数42，市场处于恐慌状态，建议执行上述买入操作\",\n      \"建议在买入后及时更新价格数据，保持持仓准确\",\n      \"检查是否有持仓年化收益达到止盈线，考虑减仓\"\n    ],\n    \"config_snapshot\": {\n      \"thresholds\": {\n        \"extreme_fear\": 25,\n        \"fear\": 45,\n        \"neutral\": 55,\n        \"greed\": 75,\n        \"extreme_greed\": 100\n      },\n      \"buy_ratio\": {\n        \"extreme_fear\": 0.50,\n        \"fear\": 0.30,\n        \"neutral\": 0.20,\n        \"greed\": 0.00\n      },\n      \"sell_ratio\": {\n        \"extreme_greed_above_high\": 0.50,\n        \"extreme_greed_between\": 0.30,\n        \"extreme_greed_below_low\": 0.20,\n        \"greed_above_high\": 0.40,\n        \"greed_between\": 0.20\n      },\n      \"annualized_target_low\": 10.0,\n      \"annualized_target_high\": 15.0\n    }\n  }\n}\n\nArchive v0.5.4: 6 files, 15833 bytes\n\nFiles: assets/examples/portfolio-example.json (1426b), assets/examples/report-example.json (2580b), references/commands.md (14134b), references/strategy.md (10796b), SKILL.md (7779b), _meta.json (136b)\n\nFile v0.5.4:SKILL.md\n\n---\nname: money-never-sleep\ndescription: |\n  MNS (Money Never Sleep, Market Neutral Strategist) CLI skill for autonomous agents. Provides investment\n  portfolio tracking, market sentiment analysis using CNN Fear & Greed Index, and strategy\n  suggestion report generation. Use when managing a contrarian investment portfolio,\n  generating buy/sell suggestions based on market sentiment thresholds, or producing\n  daily strategy reports.\n\n  NOTE: This tool provides strategy suggestions only - it does NOT connect to any broker APIs\n  or execute actual trades. All trades must be manually executed by users on their brokerage platforms\n  and then recorded via CLI commands.\n\n  Triggers include: \"管理投资组合\", \"生成策略建议\", \"获取市场报告\", \"查看持仓收益\",\n  \"更新现金余额\", \"记录买入卖出\", \"查看恐贪指数\", \"投资组合再平衡\", \"MNS 报告\"\nlicense: MIT\ncompatibility: Requires Node.js 18+ or Bun.\nmetadata:\n  {\n    \"openclaw\":\n      {\n        \"requires\": { \"anyBins\": [\"npx\", \"bunx\", \"npm\", \"bun\"] },\n        \"source\": \"https://github.com/sopaco/money-never-sleep\",\n        \"homepage\": \"https://github.com/sopaco/money-never-sleep\",\n        \"author\": \"Sopaco\",\n        \"os\": [\"darwin\", \"linux\", \"win32\"]\n      }\n  }\n---\n\n# MNS CLI 投资管理 Skill\n\n## 概述\n\n本 skill 提供 MNS 逆向投资策略的 CLI 操作能力。MNS 是基于 CNN Fear & Greed Index 情绪指标的量化投资工具，通过 contrarian 策略在情绪极度恐慌时买入，极度贪婪时卖出，实现市场中性风格的长期投资。\n\n### 安全声明\n\n> - **源码公开**: 所有源码公开托管于 [GitHub](https://github.com/sopaco/money-never-sleep)\n> - **无网络交易**: 不连接任何券商 API，所有数据存储在本地 SQLite 数据库\n> - **无敏感权限**: 无需使用也不自动读取用户任何金融账户配置\n\n## 核心能力\n\n1. **投资组合管理**: 查看持仓、现金余额、资产配置、年化收益\n2. **交易记录**: 记录买入/卖出操作，更新资产当前价格（手动输入，非自动抓取）\n3. **策略建议**: 自动生成基于最新恐贪指数的买卖建议报告（仅建议，不执行交易）\n4. **配置管理**: 查看和调整策略参数（阈值、买入/卖出比例、止盈线）\n5. **历史查询**: 查看交易历史、价格更新记录\n\n> **重要说明**: 本工具仅提供策略建议和记录功能，不连接任何券商 API。\n> 用户需自行在券商平台执行交易后，通过 CLI 记录交易结果。\n\n## 快速开始\n\n### 安装（首次使用）\n\n```bash\n# 安装 mns CLI（所有源码公开托管于 [GitHub](https://github.com/sopaco/money-never-sleep)）\nnpm install -g @never-sleeps/mns-cli\n```\n\n### 初始化\n\n```bash\n# 如果已有数据，会提示确认后再覆盖\nmns init\nmns cash set 100000\n```\n\n### 添加资产到持仓池\n\n```bash\nmns add QQQ \"纳指100\" us_stocks\nmns add SH600000 \"浦发银行\" cn_stocks\n```\n\n### 记录买入交易\n\n```bash\nmns buy QQQ 100 450.50\nmns buy SH600000 500 12.30\n```\n\n### 查看持仓和策略建议\n\n```bash\n# 查看当前持仓（含年化收益）\nmns portfolio\n\n# 获取今日策略报告（基于最新恐贪指数）\nmns report\n\n# 查看当前恐贪指数\nmns sentiment\n```\n\n### 更新价格和查看历史\n\n```bash\n# 更新资产当前价格\nmns price QQQ 460.00\n\n# 查看最近交易历史\nmns history --limit 50\n\n# 查看现金余额\nmns cash\n```\n\n### 配置管理\n\n```bash\n# 查看所有配置\nmns config\n\n# 查看特定配置项（支持 dot-path 语法）\nmns config thresholds.fear\nmns config buy_ratio.extreme_fear\n\n# 修改配置项（策略参数）\nmns config thresholds.greed 75\nmns config buy_ratio.fear 0.30\nmns config sell_ratio.(\"greed\",\"between\") 0.20\n```\n\n## 数据存储\n- **报告输出**: `./reports/`（执行MNS CLI到目录），或通过 `settings.report_output_dir` 指定\n\n## 策略逻辑详解\n\n### 情绪驱动的买入决策\n\n买入比例基于恐贪指数区间：\n\n| 恐贪区间 | 指数范围 | 买入比例 | 逻辑 |\n|---------|---------|---------|------|\n| Extreme Fear | 0-25 | 50% (默认) | 极度恐慌，重仓买入 |\n| Fear | 25-45 | 30% (默认) | 恐慌，适度买入 |\n| Neutral | 45-55 | 20% (默认) | 中性，小额买入 |\n| Greed | 55-75 | 0% (默认) | 贪婪，不买入 |\n| Extreme Greed | 75-100 | 0% (默认) | 极度贪婪，不买入 |\n\n### 卖出决策（双准则）\n\n卖出建议综合考虑：\n1. **年化收益止盈**: 基于持有天数计算年化收益率，对照卖出矩阵\n2. **绝对收益线**: 绝对收益 ≥ 30% 时也可考虑卖出（即使年化收益率不高）\n\n卖出矩阵（按情绪区间和价格位置）：\n\n| 情绪 | 价格位置 | 卖出比例 |\n|------|---------|---------|\n| Extreme Greed | 高于阻力位 | 50% |\n| Extreme Greed | 在支撑阻力间 | 30% |\n| Extreme Greed | 低于支撑位 | 20% |\n| Greed | 高于阻力位 | 40% |\n| Greed | 在支撑阻力间 | 20% |\n| Greed | 低于支撑位 | 0% |\n| Neutral/Fear | 任何位置 | 0% |\n\n### 买入资金分配：Contrarian 权重\n\n可用现金按 contrarian 权重分配到各资产：\n\n- **权重公式**: `weight = max(1.0, cost_price / current_price)`\n- **解释**: 浮亏资产（当前价格 < 成本价）获得更高权重，符合逆向抄底逻辑\n- **浮盈资产**: 权重为 1.0（基线）\n\n## 常见工作流\n\n### 日常报告（Agent 每日执行）\n\n```bash\n# 1. 查看策略报告（包含买卖建议、现金预测、风险警告）\nmns report\n\n# 2. 根据建议执行买入（如有）\nmns buy QQQ 50 445.00\n\n# 3. 更新价格（如有新价格）\nmns price QQQ 448.50\n\n# 4. 记录卖出（如有）\nmns sell QQQ 100 455.00\n\n# 5. 查看最新持仓\nmns portfolio\n```\n\n### 策略参数调优（Agent 负责优化）\n\n```bash\n# 查看当前买入比例\nmns config buy_ratio\n\n# 调整极端恐慌买入比例到 60%\nmns config buy_ratio.extreme_fear 0.60\n\n# 降低中性区间买入到 10%\nmns config buy_ratio.neutral 0.10\n\n# 提高极度贪婪时的卖出比例\nmns config sell_ratio.(\"extreme_greed\",\"above_high\") 0.60\n\n# 调整年化止盈线\nmns config annualized_target_low 12.0\nmns config annualized_target_high 18.0\n```\n\n### 新资产添加流程\n\n```bash\n# 1. 添加资产到池子\nmns add TSLA \"特斯拉\" us_stocks\n\n# 2. 初始建仓买入\nmns buy TSLA 50 250.00\n\n# 3. 记录当前价格（后续需要定期更新）\nmns price TSLA 255.00\n```\n\n## 注意事项\n\n- **价格更新**: 买入/卖出后必须调用 `price` 命令更新成本价到当前市值，否则持仓收益数据不准确\n- **时间敏感性**: `report` 和 `sentiment` 命令通过 HTTP 获取实时 CNN Fear & Greed Index，需要网络访问\n- **异步要求**: 这两个命令是异步的，agent 调用时需确保环境支持 async execution\n- **Windows 编码**: PowerShell 默认 GBK 编码可能导致中文乱码，建议使用 UTF-8 终端或重定向输出到文件\n- **年化收益计算**: 使用 `annualized = (current / cost) ^ (365 / holding_days) - 1`，短期持仓（< min_holding_days）的年化收益不显示\n- **绝对收益止盈**: 当持仓绝对收益 ≥ 30% 时，即使年化收益率未达阈值也可能触发卖出建议\n\n## 错误处理\n\n- **网络错误**: `sentiment` 和 `report` 可能因 API 不可用失败，建议重试或使用缓存数据\n- **数据库锁定**: 多进程并发操作 SQLite 会导致锁定，agent 应确保串行访问\n\n## 相关文件\n\n- `references/` - 详细的技术参考文档（配置结构、数据库 schema、策略参数）\n- `assets/` - 模板文件（如报告 HTML 模板）\n\n## 开源信息\n\nMNS (money-never-sleep) 是开源项目，源码托管于 GitHub：\n\n**[https://github.com/sopaco/money-never-sleep](https://github.com/sopaco/money-never-sleep)**\n\nFile v0.5.4:_meta.json\n\n{\n  \"ownerId\": \"kn7a2vy7ys7aj3gzm2vvw7zc158311b2\",\n  \"slug\": \"money-never-sleep\",\n  \"version\": \"0.5.4\",\n  \"publishedAt\": 1776671146137\n}\n\nFile v0.5.4:references/commands.md\n\n# MNS CLI 命令参考\n\n本文档详细描述 MNS CLI 的所有命令、参数和用法。\n\n## 命令概览\n\n| 命令 | 用途 | 异步 |\n|------|------|------|\n| `init` | 初始化和数据库 | 否 |\n| `config` | 查看/修改配置 | 否 |\n| `cash` | 现金余额管理 | 否 |\n| `portfolio` | 查看持仓概览 | 否 |\n| `add` | 新增资产到持仓池 | 否 |\n| `buy` | 记录买入交易 | 否 |\n| `sell` | 记录卖出交易 | 否 |\n| `price` | 更新资产当前价格 | 否 |\n| `sentiment` | 查看当前恐贪指数 | 是 |\n| `report` | 生成策略报告 | 是 |\n| `history` | 查看交易历史 | 否 |\n\n---\n\n## `init`\n\n**语法**: `mns init [-f, --force]`\n\n**功能**: 初始化。\n\n**参数**:\n- `-f, --force`: 跳过确认提示，强制覆盖已有数据\n\n**行为说明**:\n- 如果检测到已有配置文件或数据库，会提示用户确认后再覆盖\n- 使用 `--force` 参数可跳过确认直接覆盖\n\n**示例**:\n```bash\n# 普通初始化（如有数据会提示确认）\nmns init\n\n# 强制初始化（跳过确认）\nmns init --force\n```\n\n**输出示例（已有数据时）**:\n```\n⚠️  检测到已有数据：\n\n继续将覆盖上述文件，数据将丢失。是否继续？[y/N]: y\n✓ 初始化完成\n  报告目录: ./reports\n```\n\n**输出示例（使用 --force）**:\n```\n✓ 初始化完成\n  报告目录: ./reports\n```\n\n**注意**: \n- 报告目录默认为当前目录下的 `reports/`，可通过配置修改\n- 输入 `y` 或 `yes` 确认覆盖，其他任何输入都会取消操作\n\n---\n\n## `config`\n\n**语法**: `mns config [KEY] [VALUE]`\n\n**功能**: 查看或修改配置项。支持 dot-path 语法访问嵌套配置。\n\n### 查看所有配置\n```bash\nmns config\n```\n\n输出 TOML 格式的完整配置。\n\n### 查看特定配置项\n```bash\nmns config thresholds.fear\nmns config buy_ratio.extreme_fear\n```\n\n输出:\n```\nthresholds.fear = 45\nbuy_ratio.extreme_fear = 0.50\n```\n\n### 修改配置项\n```bash\nmns config thresholds.greed 75\nmns config buy_ratio.fear 0.30\n```\n\n**支持的特殊语法**:\n- 嵌套键: `thresholds.fear`\n- 数组索引: `sell_ratio.(\"greed\",\"between\")`（注意引号和括号）\n\n**示例 - 完整参数调优**:\n```bash\n# 调整买入比例\nmns config buy_ratio.extreme_fear 0.60\nmns config buy_ratio.fear 0.25\nmns config buy_ratio.neutral 0.10\n\n# 调整卖出矩阵\nmns config sell_ratio.(\"extreme_greed\",\"above_high\") 0.60\nmns config sell_ratio.(\"greed\",\"above_high\") 0.50\n\n# 调整止盈线\nmns config annualized_target_low 12.0\nmns config annualized_target_high 18.0\n\n# 调整最小持有天数（避免短期年化收益失真）\nmns config min_holding_days 30\n```\n\n---\n\n## `cash`\n\n**语法**: `mns cash [ACTION]`\n\n**功能**: 查看或设置现金余额。\n\n### 查看余额\n```bash\nmns cash\n```\n\n输出:\n```\n现金余额: ¥125430.50\n```\n\n### 设置现金余额\n```bash\nmns cash set 100000\n```\n\n### 增加现金\n```bash\nmns cash add 5000\n```\n\n**注意**:\n- `set` 会覆盖当前余额\n- `add` 在当前余额基础上增加\n- 金额不能为负数\n\n---\n\n## `portfolio`\n\n**语法**: `mns portfolio`\n\n**功能**: 显示当前持仓概览，包括：\n- 资产代码和名称\n- 持仓份额和成本价\n- 当前价格（需通过 `price` 命令更新）\n- 持仓市值和盈亏\n- 年化收益率（基于持有天数）\n\n**示例输出**:\n```\n┌───────┬────────────┬──────────┬──────────┬─────────────┬─────────────┬────────────┐\n│ 代码  │   名称     │  份额    │ 成本价   │ 当前价      │  市值       │ 年化收益   │\n├───────┼────────────┼──────────┼──────────┼─────────────┼─────────────┼────────────┤\n│ QQQ   │ 纳指100    │ 150.0    │ 450.00   │ 460.50      │ 69075.00    │  +8.2%     │\n│ SH600 │ 浦发银行   │ 500.0    │ 12.30    │ 12.80       │ 6400.00     │ +15.3%     │\n└───────┴────────────┴──────────┴──────────┴─────────────┴─────────────┴────────────┘\n\n总市值: ¥75475.00\n现金余额: ¥24685.50\n总资产: ¥100160.50\n```\n\n**注意事项**:\n- 年化收益计算公式: `(current / cost) ^ (365 / holding_days) - 1`\n- 如果持有天数小于配置的 `min_holding_days`，年化收益显示为 `N/A`\n- 当前价格需要定期通过 `price` 命令更新\n\n---\n\n## `add`\n\n**语法**: `mns add <CODE> <NAME> <CATEGORY>`\n\n**功能**: 新增资产到持仓池，后续可通过 `buy` 命令买入。\n\n**参数**:\n- `CODE`: 资产代码（如 `QQQ`, `SH600000`, `AAPL`）\n- `NAME`: 资产名称（任意描述性字符串）\n- `CATEGORY`: 类别，预设可选值：\n  - `us_stocks` - 美股\n  - `cn_stocks` - A股\n  - `counter_cyclical` - 逆周期资产\n\n**示例**:\n```bash\nmns add QQQ \"纳指100\" us_stocks\nmns add SH600000 \"浦发银行\" cn_stocks\nmns add GLD \"黄金ETF\" counter_cyclical\n```\n\n**注意**:\n- 资产代码在数据库中必须唯一\n- 添加后立即用 `buy` 记录初始买入\n\n---\n\n## `buy`\n\n**语法**: `mns buy <CODE> <SHARES> <PRICE>`\n\n**功能**: 记录买入交易，增加持仓份额。\n\n**参数**:\n- `CODE`: 资产代码（必须已通过 `add` 添加）\n- `SHARES`: 买入份额（支持小数，如股票可支持碎股）\n- `PRICE`: 买入单价（元/股）\n\n**示例**:\n```bash\n# 买入 100 股 QQQ，单价 450.50 元\nmns buy QQQ 100 450.50\n\n# 买入 50 份黄金 ETF，单价 180.00 元\nmns buy GLD 50 180.00\n```\n\n**行为**:\n- 现金余额相应减少\n- 持仓成本价重新计算（加权平均）\n- 交易记录存入 `transactions` 表\n\n---\n\n## `sell`\n\n**语法**: `mns sell <CODE> <SHARES> <PRICE>`\n\n**功能**: 记录卖出交易，减少持仓份额。\n\n**参数**:\n- `CODE`: 资产代码\n- `SHARES`: 卖出份额（不能超过当前持仓）\n- `PRICE`: 卖出单价\n\n**示例**:\n```bash\n# 卖出 30 股 QQQ，单价 455.00 元\nmns sell QQQ 30 455.00\n\n# 清仓某资产\nmns sell SH600000 500 13.20\n```\n\n**行为**:\n- 现金余额相应增加\n- 持仓份额减少，成本价保持不变（剩余份额）\n- 交易记录存入 `transactions` 表\n\n---\n\n## `price`\n\n**语法**: `mns price <CODE> [PRICE]`\n\n**功能**: 查看或更新资产的当前价格。\n\n### 查看当前价格\n```bash\nmns price QQQ\n```\n\n输出:\n```\nQQQ (纳指100): ¥460.50\n```\n\n### 更新当前价格\n```bash\nmns price QQQ 460.50\n```\n\n**注意**:\n- 每次更新价格会更新对应持仓的 `current_price` 和 `current_at` 字段\n- 不更新价格会导致 `portfolio` 和 `report` 显示的市值不准确\n- 建议每日运行 `report` 前先更新价格，或编写脚本自动更新\n\n---\n\n## `sentiment`\n\n**语法**: `mns sentiment`\n\n**功能**: 从 CNN 官网获取最新的 Fear & Greed Index 数据。\n\n**示例**:\n```bash\nmns sentiment\n```\n\n输出:\n```\nCNN Fear & Greed Index: 42 (Fear)\nPrevious Close: 38\n1 Week Ago: 35\n1 Month Ago: 28\n```\n\n**注意**:\n- 此命令是异步的，需要网络访问\n- 如果 API 不可用，可能返回错误\n- 数据来自 `https://cnn.com/data/api/ Fear & Greed` 端点\n\n---\n\n## `report`\n\n**语法**: `mns report`\n\n**功能**: 生成今日策略报告，包含：\n1. 当前恐贪指数和情绪判断\n2. 买入建议（基于可用现金和 contrarian 分配）\n3. 卖出建议（基于年化收益和绝对收益）\n4. 持仓摘要和风险警告（浮亏过大）\n5. 现金预测（按建议执行后）\n\n**示例**:\n```bash\nmns report\n```\n\n**输出节选**:\n```\n╔═══════════════════════════════════════════════════════════════╗\n║           MNS 逆向投资策略报告 - 2026-04-20                     ║\n╚═══════════════════════════════════════════════════════════════╝\n\n📊 市场情绪 (CNN Fear & Greed)\n┌─────────────────────────────────────┐\n│ 当前指数: 42 (Fear)                  │\n│ 状态解读: 市场处于恐慌区间，建议逐步  │\n│         买入                          │\n└─────────────────────────────────────┘\n\n💰 买入建议 (可用现金: ¥25000)\n┌─────────────────────────────────────┐\n│ QQQ (Fear 区间权重: 1.2)             │\n│  建议买入: ¥12000 (50 股 @ ¥240)    │\n│                                     │\n│ SH600000 (Fear 区间权重: 1.5)        │\n│  建议买入: ¥13000 (1042 股 @ ¥12.5) │\n└─────────────────────────────────────┘\n\n⚠️  卖出建议\n┌─────────────────────────────────────┐\n│ 暂无满足卖出条件的持仓              │\n└─────────────────────────────────────┘\n\n🚨 风险警告\n┌─────────────────────────────────────┐\n│ [无]                                │\n└─────────────────────────────────────┘\n```\n\n**注意**:\n- 异步命令，需要网络获取恐贪指数\n- 报告同时保存到报告目录（默认 `./reports/`）\n- 买入/卖出建议仅供参考，agent 需根据实际执行顺序调整\n\n---\n\n## `history`\n\n**语法**: `mns history [--limit N]`\n\n**功能**: 查看最近的交易历史。\n\n**参数**:\n- `--limit N`: 显示条数，默认 20，最大 100\n\n**示例**:\n```bash\n# 查看最近 20 条\nmns history\n\n# 查看最近 50 条\nmns history --limit 50\n```\n\n**输出**:\n```\n最近交易记录 (按时间倒序):\n┌─────────────────┬───────┬────────┬──────┬────────┬──────────┐\n│ 时间            │ 类型  │ 资产   │ 份额 │ 价格   │ 金额     │\n├─────────────────┼───────┼────────┼──────┼────────┼──────────┤\n│ 2025-06-15 10:3│ buy   │ QQQ    │ 50   │ 448.50 │ 22425.00 │\n│ 2025-06-14 14:2│ sell  │ SH600  │ 100  │ 13.00  │ 1300.00  │\n│ 2025-06-14 09:1│ price │ QQQ    │ -    │ 445.00 │ -        │\n└─────────────────┴───────┴────────┴──────┴────────┴──────────┘\n```\n\n**类型说明**:\n- `buy` - 买入交易\n- `sell` - 卖出交易\n- `price` - 价格更新记录\n\n---\n\n## 通用 Exit Code\n\n| Code | 含义 |\n|------|------|\n| 0    | 成功 |\n| 1    | 通用错误（配置错误、参数错误、数据库错误等） |\n| 2    | 网络错误（仅影响 `sentiment`/`report`） |\n\n---\n\n## 数据库 Schema 参考\n\n主要表结构：\n\n### `cash`\n- `id` INTEGER PRIMARY KEY\n- `balance` REAL NOT NULL\n- `updated_at` TIMESTAMP\n\n### `positions`\n- `id` INTEGER PRIMARY KEY\n- `code` TEXT NOT NULL UNIQUE\n- `name` TEXT NOT NULL\n- `category` TEXT NOT NULL\n- `shares` REAL NOT NULL\n- `cost_price` REAL NOT NULL\n- `current_price` REAL NOT NULL\n- `updated_at` TIMESTAMP\n- `created_at` TIMESTAMP\n\n### `transactions`\n- `id` INTEGER PRIMARY KEY\n- `type` TEXT NOT NULL ('buy' | 'sell' | 'price')\n- `code` TEXT NOT NULL\n- `shares` REAL\n- `price` REAL\n- `amount` REAL\n- `created_at` TIMESTAMP\n\n### `snapshots` (用于数据导出和审计)\n- `id` INTEGER PRIMARY KEY\n- `data` TEXT (JSON 格式的快照)\n\n---\n\n## 错误信息速查\n\n| 错误信息 | 原因 | 解决方案 |\n|----------|------|----------|\n| `未知的配置项` | 配置路径错误或不存在 | 用 `config` 查看有效的配置项 |\n| `现金余额不能为负数` | `cash set` 参数 < 0 | 检查金额参数 |\n| `资产代码不存在` | `buy`/`sell`/`price` 使用未添加的代码 | 先用 `add` 添加资产 |\n| `卖出份额超过持仓` | `sell` 参数 > 当前持仓 | 检查持仓数量 |\n| `API error: ...` | CNN API 不可用 | 稍后重试或检查网络 |\n| `Database is locked` | 并发访问数据库 | 确保同一时间只有一个进程操作 |\n\n---\n\n## 常见问题\n\n### Q: 如何批量导入历史交易？\nA: 暂无批量导入命令。可编写脚本依次调用 `buy`、`sell`、`price`，或直接操作 SQLite 数据库。\n\n### Q: 年化收益显示为 `N/A`？\nA: 持仓天数小于 `min_holding_days`（默认 30 天）时不计算年化收益，避免短期波动误导。\n\n### Q: 如何查看详细的卖出建议计算过程？\nA: 查看 `report` 输出中的 \"卖出建议\" 部分，或读取数据库中的 `positions` 表计算 `annualized_return`。\n\n### Q: 怎样将报告导出为 HTML？\nA: 当前报告为纯文本格式。可将输出重定向到文件后用第三方工具转换，或自行编写 wrapper 脚本生成 HTML。\n\n### Q: 能否在 Windows PowerShell 中正确显示中文？\nA: PowerShell 默认 GBK 编码可能导致乱码。解决方案：\n```powershell\n# 使用 UTF-8 编码\nchcp 65001\n# 或在命令前设置\n[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new()\n```\n\n---\n\n## 版本历史\n\n### v0.5.5 (当前)\n- 完整的 CLI 命令集\n- 异步 CNN Fear & Greed Index 获取\n- dot-path 配置管理\n- contrarian 买入分配\n- 双准则卖出决策\n- 多平台二进制分发（npm）\n\n---\n\n**最后更新**: 2026-04-20\n\nFile v0.5.4:references/strategy.md\n\n# MNS 策略参数参考\n\n本文档详细说明 MNS 逆向投资策略的核心参数，包括阈值定义、买入/卖出比例配置、止盈线设置等。这些参数通过 `mns config` 命令动态调整。\n\n---\n\n## 配置层级\n\nMNS 配置采用分层结构：\n\n```toml\n[database]\npath = \"~/.mns/mns.db\"\n\n[settings]\nmin_holding_days = 30          # 最小持有天数（年化收益计算用）\nannualized_target_low = 10.0   # 年化止盈线下限\nannualized_target_high = 15.0  # 年化止盈线上限\nreport_output_dir = \"./reports\"\n\n[thresholds]\nextreme_fear = 25      # 极度恐慌阈值\nfear = 45              # 恐慌阈值\nneutral = 55           # 中性阈值\ngreed = 75             # 贪婪阈值\nextreme_greed = 100    # 极度贪婪阈值（通常固定为 100）\n\n[buy_ratio]\nextreme_fear = 0.50    # 极度恐慌时买入比例（可用现金的 50%）\nfear = 0.30            # 恐慌时买入比例\nneutral = 0.20         # 中性时买入比例\ngreed = 0.00           # 贪婪时不买入\n# extreme_greed 默认 0.00（通常不买入）\n\n[sell_ratio]\n# 格式: (\"情绪\", \"价格位置\") = 卖出比例\n# 价格位置定义:\n#   above_high  - 当前价格高于阻力位（盈利状态）\n#   between     - 价格在支撑位和阻力位之间\n#   below_low   - 当前价格低于支撑位（浮亏状态）\n\n\"sell_ratio.(\\\"extreme_greed\\\",\\\"above_high\\\")\" = 0.50\n\"sell_ratio.(\\\"extreme_greed\\\",\\\"between\\\")\" = 0.30\n\"sell_ratio.(\\\"extreme_greed\\\",\\\"below_low\\\")\" = 0.20\n\"sell_ratio.(\\\"greed\\\",\\\"above_high\\\")\" = 0.40\n\"sell_ratio.(\\\"greed\\\",\\\"between\\\")\" = 0.20\n\"sell_ratio.(\\\"greed\\\",\\\"below_low\\\")\" = 0.00\n# neutral/fear/extreme_fear 默认无卖出（值为 0.00）\n```\n\n---\n\n## 恐贪指数区间划分\n\nCNN Fear & Greed Index 是一个 0-100 的指数，0 表示极度恐慌（Extreme Fear），100 表示极度贪婪（Extreme Greed）。\n\n### 默认区间配置\n\n| 区间名称 | 指数范围 | 含义 | 买入比例 |\n|---------|---------|------|---------|\n| Extreme Fear | 0-25 | 市场极度恐慌，逆向买入信号强 | 50% |\n| Fear | 25-45 | 市场恐慌，适度买入 | 30% |\n| Neutral | 45-55 | 中性，小额买入或观望 | 20% |\n| Greed | 55-75 | 市场贪婪，谨慎持有 | 0% |\n| Extreme Greed | 75-100 | 市场极度贪婪，考虑减仓 | 0% |\n\n### 调整阈值\n\n通过修改 `thresholds` 可改变区间边界：\n\n```bash\n# 将贪婪阈值从 75 降至 70，使贪婪区间更早触发\nmns config thresholds.greed 70\n\n# 将极度恐慌阈值从 25 提升至 30，减少极端情况下的买入频率\nmns config thresholds.extreme_fear 30\n```\n\n**注意**: 区间必须保持连续性，建议:\n- `extreme_fear < fear < neutral < greed < extreme_greed`\n- 通常 `extreme_greed` 固定为 100\n\n---\n\n## 买入比例矩阵 (`buy_ratio`)\n\n定义在不同情绪区间下，用多少比例的可用现金进行买入。\n\n### 参数说明\n\n- **可用现金**: `cash_balance + 卖出回笼资金`\n- **分配方式**: 按 contrarian 权重（浮亏资产权重更高）分配到各资产\n- **单次买入上限**: 单个资产不超过该比例 × 总可用现金\n\n### 默认配置\n\n| 情绪区间 | 买入比例 | 适用场景 |\n|---------|---------|---------|\n| extreme_fear | 0.50 | 恐慌极致，重仓抄底 |\n| fear | 0.30 | 恐慌情绪，积极建仓 |\n| neutral | 0.20 | 中性市场，小额布局 |\n| greed | 0.00 | 贪婪时暂停买入 |\n| extreme_greed | 0.00 | 极度贪婪时完全不买入 |\n\n### 调优示例\n\n```bash\n# 策略1: 极度贪婪时也可能小幅买入（左侧布局）\nmns config buy_ratio.extreme_greed 0.10\n\n# 策略2: 中性区间也暂停买入，只在明确的恐慌区间出手\nmns config buy_ratio.neutral 0.00\n\n# 策略3: 极端恐慌时全仓出击\nmns config buy_ratio.extreme_fear 0.70\n```\n\n---\n\n## 卖出比例矩阵 (`sell_ratio`)\n\n定义在特定情绪区间和价格位置下的卖出比例。卖出逻辑基于 **双准则**:\n\n1. **年化收益止盈**: 当持仓年化收益率达到 `annualized_target_high` 且在对应情绪区间\n2. **绝对收益**: 当持仓绝对收益 ≥ 30% 时，也可考虑卖出（即使年化收益未达阈值）\n\n### 价格位置定义\n\n- `above_high`: 当前价格高于某个阻力位（通常意味着盈利）\n- `between`: 价格在支撑位和阻力位之间（中性区域）\n- `below_low`: 当前价格低于支撑位（浮亏状态）\n\n实际实现中，\"价格位置\" 是通过比较当前价格与成本价来判断的：\n- `above_high`: 当前价格显著高于成本（如 +10% 以上）\n- `between`: 价格在成本附近浮动（如 -10% ~ +10%）\n- `below_low`: 当前价格显著低于成本（如 -10% 以下）\n\n### 默认卖出矩阵\n\n| 情绪区间 | above_high | between | below_low |\n|---------|-----------|---------|-----------|\n| extreme_greed | 50% | 30% | 20% |\n| greed | 40% | 20% | 0% |\n| neutral | 0% | 0% | 0% |\n| fear | 0% | 0% | 0% |\n| extreme_fear | 0% | 0% | 0% |\n\n**解读**:\n- 只在 `Greed` 和 `Extreme Greed` 区间考虑卖出\n- 极度贪婪时卖出更激进（above_high 卖出 50%）\n- 浮亏状态（below_low）即使在贪婪区间也只部分卖出或持有\n\n### 调优示例\n\n```bash\n# 极度贪婪且大幅盈利时，卖出 70%\nmns config sell_ratio.(\"extreme_greed\",\"above_high\") 0.70\n\n# 贪婪区间小幅盈利时也卖出 30%\nmns config sell_ratio.(\"greed\",\"between\") 0.30\n\n# 中性区间也开始部分止盈（保守策略）\nmns config sell_ratio.(\"neutral\",\"above_high\") 0.20\n```\n\n---\n\n## 止盈线参数 (`settings`)\n\n### `annualized_target_low` (默认 10.0)\n\n年化收益率的下限阈值。当持仓年化收益 ≥ 此值且处于可卖出的情绪区间时，触发部分卖出建议。\n\n**单位**: 百分比（0-100）\n\n### `annualized_target_high` (默认 15.0)\n\n年化收益率的上限阈值。当持仓年化收益 ≥ 此值时，建议卖出比例达到最大。\n\n**调优示例**:\n\n```bash\n# 保守止盈：年化 8% 就开始卖\nmns config annualized_target_low 8.0\nmns config annualized_target_high 12.0\n\n# 激进止盈：年化 20% 才开始卖\nmns config annualized_target_low 15.0\nmns config annualized_target_high 25.0\n```\n\n### `min_holding_days` (默认 30)\n\n最小持有天数。持仓天数小于此值时，不计算年化收益率（显示为 N/A），避免短期波动误导。\n\n**建议**: \n- 短线策略可降至 7-15 天\n- 长线投资可提升至 60-90 天\n\n---\n\n## 买入资金分配: Contrarian 权重\n\nMNS 的买入资金不是平均分配到各资产，而是采用 **逆向权重**:\n\n```\nweight_i = max(1.0, cost_price_i / current_price_i)\n```\n\n### 权重计算示例\n\n假设可用现金 100,000 元，有两个资产可供买入:\n\n| 资产 | 成本价 | 当前价 | 浮亏/浮盈 | 权重计算 | 权重 |\n|------|--------|--------|----------|---------|------|\n| QQQ  | 450.00 | 460.50 | +2.3%    | max(1.0, 450/460.5) = 1.0 | 1.0 |\n| SH600| 12.30  | 11.80  | -4.1%    | max(1.0, 12.3/11.8) = 1.043 | 1.043 |\n\n**分配结果**:\n- QQQ: `100000 × (1.0 / 2.043) × buy_ratio(fear) = 100000 × 0.489 × 0.30 = 14,670 元`\n- SH600: `100000 × (1.043 / 2.043) × buy_ratio(fear) = 100000 × 0.511 × 0.30 = 15,330 元`\n\n浮亏资产获得更高权重，符合 \"越跌越买\" 的逆向逻辑。\n\n---\n\n## 卖出决策双准则详解\n\n### 准则1：年化收益率 + 情绪区间\n\n当同时满足以下条件时，触发基于年化收益的卖出建议:\n\n1. 当前情绪区间在 `sell_ratio` 矩阵中定义了卖出比例（如 `greed` 或 `extreme_greed`）\n2. 持仓年化收益率 ≥ `annualized_target_low`\n3. 根据年化收益率所处的区间（low/high）和情绪区间，查出对应的卖出比例\n\n**卖出比例插值**:\n```rust\n// 伪代码\nif annualized < annualized_target_low:\n    ratio = 0.0\nelse if annualized >= annualized_target_high:\n    ratio = sell_ratio[emotion][price_position]\nelse:\n    // 线性插值\n    t = (annualized - low) / (high - low)\n    ratio = t * sell_ratio[emotion][price_position]\n```\n\n### 准则2：绝对收益 ≥ 30%\n\n当持仓满足以下条件时，即使年化收益率未达阈值，也建议卖出:\n\n```\nabsolute_return = (current_price - cost_price) / cost_price\nif absolute_return >= 0.30:\n    建议卖出比例 = sells 矩阵中对应值（根据情绪和价格位置）\n```\n\n**目的**: 锁定长期盈利，避免 \"坐过山车\"。\n\n---\n\n## 完整参数调优工作流\n\n### 1. 查看当前配置\n\n```bash\n# 查看所有配置\nmns config\n\n# 查看特定分组\nmns config buy_ratio\nmns config sell_ratio\nmns config thresholds\n```\n\n### 2. 基于回测结果调整\n\n参考 `回测结果`（见 `backtest_runner.py` 输出）调整:\n\n- 如果回测显示 \"中性区间买入过多\"，降低 `buy_ratio.neutral` 到 0.10 或 0.00\n- 如果回测显示 \"极度恐慌时收益高但仓位不足\"，提升 `buy_ratio.extreme_fear` 到 0.60-0.70\n- 如果回测显示 \"极度贪婪时卖出不够及时\"，提升 `sell_ratio.(\"extreme_greed\",\"above_high\")` 到 0.60-0.70\n\n### 3. 小步快跑验证\n\n每次只调整 1-2 个参数，观察后续 `report` 输出和实际持仓表现。\n\n```bash\n# 调整 - 降低中性买入\nmns config buy_ratio.neutral 0.10\n\n# 观察 1 周后的 report 变化\n# 如果感觉买入频率下降明显，可继续微调\n```\n\n### 4. 保存参数快照\n\n将满意配置备份到文件:\n\n```bash\nmns config > config_backup_2025-06-16.toml\n```\n\n---\n\n## 参数命名空间说明\n\n### dot-path 语法\n\nMNS 支持 Rust TOML crate 的 dot-path 访问:\n\n```bash\n# 访问 thresholds.fear\nmns config thresholds.fear\n\n# 访问 sell_ratio 的元组键\nmns config sell_ratio.(\"greed\",\"above_high\")\n```\n\n### 特殊字符转义\n\n当键名包含引号或括号时，需转义:\n\n```bash\n# 正确的写法（外层引号，内层转义）\nmns config 'sell_ratio.(\"greed\",\"above_high\")' 0.50\n```\n\n在 shell 中，建议用单引号包裹整个参数以避免转义问题。\n\n---\n\n## 风险提示\n\n- **参数调优需结合实际市场环境**: 回测结果是历史数据，不代表未来表现\n- **避免频繁调整**: 每次调整后至少观察 1-2 个月的实盘表现\n- **极端行情测试**: 回测中已包含 2020 年疫情、2022 年熊市等极端情况，但实际黑天鹅可能更严重\n\n---\n\n## 进阶话题\n\n### 动态阈值调整（未来方向）\n\n当前阈值为静态配置。未来可考虑:\n- 基于 VIX 指数动态调整 `thresholds`\n- 根据账户总资产规模调整 `buy_ratio`（规模越大，单次买入比例越低）\n- 基于持仓集中度调整 `sell_ratio`（单一资产占比过高时优先卖出）\n\n### 多因子情绪模型\n\n当前仅使用 CNN Fear & Greed Index。可扩展:\n- 加入 A 股情绪指标（沪深 300 波动率、涨跌停家数等）\n- 加入技术指标（RSI、MACD）作为补充过滤器\n\n---\n\n**文档版本**: v0.5.5 | **更新日期**: 2026-04-20\n\nFile v0.5.4:assets/examples/portfolio-example.json\n\n{\n  \"portfolio\": {\n    \"timestamp\": \"2025-06-16T10:30:00Z\",\n    \"total_value\": 100160.50,\n    \"total_market_value\": 75475.00,\n    \"cash_balance\": 24685.50,\n    \"positions\": [\n      {\n        \"code\": \"QQQ\",\n        \"name\": \"纳指100\",\n        \"category\": \"us_stocks\",\n        \"shares\": 150.0,\n        \"cost_price\": 450.00,\n        \"current_price\": 460.50,\n        \"market_value\": 69075.00,\n        \"cost_basis\": 67500.00,\n        \"absolute_return\": 0.022222,\n        \"absolute_return_amount\": 1575.00,\n        \"annualized_return\": 0.082,\n        \"annualized_return_formatted\": \"+8.2%\",\n        \"holding_days\": 45,\n        \"updated_at\": \"2025-06-16T09:00:00Z\"\n      },\n      {\n        \"code\": \"SH600000\",\n        \"name\": \"浦发银行\",\n        \"category\": \"cn_stocks\",\n        \"shares\": 500.0,\n        \"cost_price\": 12.30,\n        \"current_price\": 12.80,\n        \"market_value\": 6400.00,\n        \"cost_basis\": 6150.00,\n        \"absolute_return\": 0.04065,\n        \"absolute_return_amount\": 250.00,\n        \"annualized_return\": 0.153,\n        \"annualized_return_formatted\": \"+15.3%\",\n        \"holding_days\": 67,\n        \"updated_at\": \"2025-06-16T09:00:00Z\"\n      }\n    ],\n    \"summary\": {\n      \"total_cost_basis\": 73650.00,\n      \"total_absolute_return\": 1825.00,\n      \"total_absolute_return_rate\": 0.02478,\n      \"positions_with_gain\": 2,\n      \"positions_with_loss\": 0,\n      \"average_annualized_return\": 0.1175\n    }\n  }\n}\n\nFile v0.5.4:assets/examples/report-example.json\n\n{\n  \"report\": {\n    \"timestamp\": \"2025-06-16T10:30:00Z\",\n    \"date\": \"2025-06-16\",\n    \"market_sentiment\": {\n      \"fear_greed_index\": 42,\n      \"classification\": \"Fear\",\n      \"previous_close\": 38,\n      \"one_week_ago\": 35,\n      \"one_month_ago\": 28,\n      \"interpretation\": \"市场处于恐慌区间，建议逐步买入\"\n    },\n    \"portfolio_summary\": {\n      \"total_assets\": 100160.50,\n      \"total_market_value\": 75475.00,\n      \"cash_balance\": 24685.50,\n      \"positions_count\": 2,\n      \"total_absolute_return\": 1825.00,\n      \"total_absolute_return_rate\": 0.02478\n    },\n    \"buy_suggestions\": {\n      \"available_cash\": 24685.50,\n      \"total_buy_amount\": 14200.00,\n      \"remaining_cash_after\": 10485.50,\n      \"suggestions\": [\n        {\n          \"code\": \"QQQ\",\n          \"name\": \"纳指100\",\n          \"current_price\": 460.50,\n          \"sentiment_zone\": \"Fear\",\n          \"buy_ratio\": 0.30,\n          \"weight\": 1.0,\n          \"suggested_amount\": 7200.00,\n          \"suggested_shares\": 15.63,\n          \"reason\": \"恐惧区间，按策略买入30%可用现金，该资产浮盈状态权重为1.0\"\n        },\n        {\n          \"code\": \"SH600000\",\n          \"name\": \"浦发银行\",\n          \"current_price\": 11.80,\n          \"sentiment_zone\": \"Fear\",\n          \"buy_ratio\": 0.30,\n          \"weight\": 1.043,\n          \"suggested_amount\": 7000.00,\n          \"suggested_shares\": 593.22,\n          \"reason\": \"恐惧区间，按策略买入30%可用现金，该资产浮亏状态权重提升至1.043\"\n        }\n      ]\n    },\n    \"sell_suggestions\": {\n      \"total_sell_amount\": 0.00,\n      \"suggestions\": []\n    },\n    \"risk_warnings\": {\n      \"has_warnings\": false,\n      \"warnings\": []\n    },\n    \"recommendations\": [\n      \"当前恐惧指数42，市场处于恐慌状态，建议执行上述买入操作\",\n      \"建议在买入后及时更新价格数据，保持持仓准确\",\n      \"检查是否有持仓年化收益达到止盈线，考虑减仓\"\n    ],\n    \"config_snapshot\": {\n      \"thresholds\": {\n        \"extreme_fear\": 25,\n        \"fear\": 45,\n        \"neutral\": 55,\n        \"greed\": 75,\n        \"extreme_greed\": 100\n      },\n      \"buy_ratio\": {\n        \"extreme_fear\": 0.50,\n        \"fear\": 0.30,\n        \"neutral\": 0.20,\n        \"greed\": 0.00\n      },\n      \"sell_ratio\": {\n        \"extreme_greed_above_high\": 0.50,\n        \"extreme_greed_between\": 0.30,\n        \"extreme_greed_below_low\": 0.20,\n        \"greed_above_high\": 0.40,\n        \"greed_between\": 0.20\n      },\n      \"annualized_target_low\": 10.0,\n      \"annualized_target_high\": 15.0\n    }\n  }\n}\n\nArchive v0.5.3: 6 files, 17317 bytes\n\nFiles: assets/examples/portfolio-example.json (1426b), assets/examples/report-example.json (2580b), references/commands.md (17748b), references/strategy.md (11555b), SKILL.md (8324b), _meta.json (136b)\n\nFile v0.5.3:SKILL.md\n\n---\nname: money-never-sleep\ndescription: |\n  MNS (Money Never Sleep, Market Neutral Strategist) CLI skill for autonomous agents. Provides investment\n  portfolio tracking, market sentiment analysis using CNN Fear & Greed Index, and strategy\n  suggestion report generation. Use when managing a contrarian investment portfolio,\n  generating buy/sell suggestions based on market sentiment thresholds, or producing\n  daily strategy reports.\n\n  NOTE: This tool provides strategy suggestions only - it does NOT connect to any broker APIs\n  or execute actual trades. All trades must be manually executed by users on their brokerage platforms\n  and then recorded via CLI commands.\n\n  Triggers include: \"管理投资组合\", \"生成策略建议\", \"获取市场报告\", \"查看持仓收益\",\n  \"更新现金余额\", \"记录买入卖出\", \"查看恐贪指数\", \"投资组合再平衡\", \"MNS 报告\"\nlicense: MIT\ncompatibility: Requires Node.js runtime. Prebuilt binaries available for darwin-arm64, linux-x64, win-x64. Access to local SQLite database at ~/.mns/mns.db.\nmetadata:\n  version: \"0.5.5\"\n  author: \"Sopaco\"\n  language: \"rust\"\n  platform: \"cli\"\n  binary_distribution: \"npm\"\n  security_verified: \"ClawHub Security Verified\"\n  source_code: \"https://github.com/sopaco/money-never-sleep\"\n---\n\n# MNS CLI 投资管理 Skill\n\n## 概述\n\n本 skill 为 autonomous agents 提供 MNS 逆向投资策略的 CLI 操作能力。MNS 是基于 CNN Fear & Greed Index 情绪指标的量化投资工具，通过 contrarian 策略在情绪极度恐慌时买入，极度贪婪时卖出，实现市场中性风格的长期投资。\n\n### 安全认证\n\n> **✓ ClawHub Security Verified** - 本 skill 已通过 ClawHub 安全认证审核。\n>\n> - **开源项目**: 源码公开托管于 [GitHub](https://github.com/sopaco/money-never-sleep)\n> - **预编译二进制**: 通过 npm 分发，由 GitHub Actions 从源码自动构建\n> - **无网络交易**: 不连接任何券商 API，所有数据存储在本地 SQLite 数据库\n> - **无敏感权限**: 仅访问 `~/.mns/` 目录下的本地配置和数据库\n\n## 核心能力\n\n1. **投资组合管理**: 查看持仓、现金余额、资产配置、年化收益\n2. **交易记录**: 记录买入/卖出操作，更新资产当前价格（手动输入，非自动抓取）\n3. **策略建议**: 自动生成基于最新恐贪指数的买卖建议报告（仅建议，不执行交易）\n4. **配置管理**: 查看和调整策略参数（阈值、买入/卖出比例、止盈线）\n5. **历史查询**: 查看交易历史、价格更新记录\n\n> **重要说明**: 本工具仅提供策略建议和记录功能，不连接任何券商 API。\n> 用户需自行在券商平台执行交易后，通过 CLI 记录交易结果。\n\n## 快速开始\n\n### 安装（首次使用）\n\n```bash\n# 安装 mns CLI，npm 会根据当前平台自动选择并安装对应的预编译 binary\nnpm install -g @never-sleeps/mns-cli\n```\n\n### 初始化\n\n```bash\n# ⚠️ 警告：init 命令会创建或覆盖 ~/.mns/config.toml 和 ~/.mns/mns.db\n# 如果已有数据，系统会提示确认后再覆盖\nmns init\nmns cash set 100000\n```\n\n### 添加资产到持仓池\n\n```bash\nmns add QQQ \"纳指100\" us_stocks\nmns add SH600000 \"浦发银行\" cn_stocks\n```\n\n### 记录买入交易\n\n```bash\nmns buy QQQ 100 450.50\nmns buy SH600000 500 12.30\n```\n\n### 查看持仓和策略建议\n\n```bash\n# 查看当前持仓（含年化收益）\nmns portfolio\n\n# 获取今日策略报告（基于最新恐贪指数）\nmns report\n\n# 查看当前恐贪指数\nmns sentiment\n```\n\n### 更新价格和查看历史\n\n```bash\n# 更新资产当前价格\nmns price QQQ 460.00\n\n# 查看最近交易历史\nmns history --limit 50\n\n# 查看现金余额\nmns cash\n```\n\n### 配置管理\n\n```bash\n# 查看所有配置\nmns config\n\n# 查看特定配置项（支持 dot-path 语法）\nmns config thresholds.fear\nmns config buy_ratio.extreme_fear\n\n# 修改配置项（策略参数）\nmns config thresholds.greed 75\nmns config buy_ratio.fear 0.30\nmns config sell_ratio.(\"greed\",\"between\") 0.20\n```\n\n## 数据存储\n\n- **配置文件**: `~/.mns/config.toml`（TOML 格式）\n- **数据库**: `~/.mns/mns.db`（SQLite，包含 cash、positions、transactions、snapshots 表）\n- **报告输出**: `./reports/`（当前目录），或通过 `settings.report_output_dir` 配置\n\n## 策略逻辑详解\n\n### 情绪驱动的买入决策\n\n买入比例基于恐贪指数区间：\n\n| 恐贪区间 | 指数范围 | 买入比例 | 逻辑 |\n|---------|---------|---------|------|\n| Extreme Fear | 0-25 | 50% (默认) | 极度恐慌，重仓买入 |\n| Fear | 25-45 | 30% (默认) | 恐慌，适度买入 |\n| Neutral | 45-55 | 20% (默认) | 中性，小额买入 |\n| Greed | 55-75 | 0% (默认) | 贪婪，不买入 |\n| Extreme Greed | 75-100 | 0% (默认) | 极度贪婪，不买入 |\n\n### 卖出决策（双准则）\n\n卖出建议综合考虑：\n1. **年化收益止盈**: 基于持有天数计算年化收益率，对照卖出矩阵\n2. **绝对收益线**: 绝对收益 ≥ 30% 时也可考虑卖出（即使年化收益率不高）\n\n卖出矩阵（按情绪区间和价格位置）：\n\n| 情绪 | 价格位置 | 卖出比例 |\n|------|---------|---------|\n| Extreme Greed | 高于阻力位 | 50% |\n| Extreme Greed | 在支撑阻力间 | 30% |\n| Extreme Greed | 低于支撑位 | 20% |\n| Greed | 高于阻力位 | 40% |\n| Greed | 在支撑阻力间 | 20% |\n| Greed | 低于支撑位 | 0% |\n| Neutral/Fear | 任何位置 | 0% |\n\n### 买入资金分配：Contrarian 权重\n\n可用现金按 contrarian 权重分配到各资产：\n\n- **权重公式**: `weight = max(1.0, cost_price / current_price)`\n- **解释**: 浮亏资产（当前价格 < 成本价）获得更高权重，符合逆向抄底逻辑\n- **浮盈资产**: 权重为 1.0（基线）\n\n## 常见工作流\n\n### 日常报告（Agent 每日执行）\n\n```bash\n# 1. 查看策略报告（包含买卖建议、现金预测、风险警告）\nmns report\n\n# 2. 根据建议执行买入（如有）\nmns buy QQQ 50 445.00\n\n# 3. 更新价格（如有新价格）\nmns price QQQ 448.50\n\n# 4. 记录卖出（如有）\nmns sell QQQ 100 455.00\n\n# 5. 查看最新持仓\nmns portfolio\n```\n\n### 策略参数调优（Agent 负责优化）\n\n```bash\n# 查看当前买入比例\nmns config buy_ratio\n\n# 调整极端恐慌买入比例到 60%\nmns config buy_ratio.extreme_fear 0.60\n\n# 降低中性区间买入到 10%\nmns config buy_ratio.neutral 0.10\n\n# 提高极度贪婪时的卖出比例\nmns config sell_ratio.(\"extreme_greed\",\"above_high\") 0.60\n\n# 调整年化止盈线\nmns config annualized_target_low 12.0\nmns config annualized_target_high 18.0\n```\n\n### 新资产添加流程\n\n```bash\n# 1. 添加资产到池子\nmns add TSLA \"特斯拉\" us_stocks\n\n# 2. 初始建仓买入\nmns buy TSLA 50 250.00\n\n# 3. 记录当前价格（后续需要定期更新）\nmns price TSLA 255.00\n```\n\n## 注意事项\n\n- **价格更新**: 买入/卖出后必须调用 `price` 命令更新成本价到当前市值，否则持仓收益数据不准确\n- **时间敏感性**: `report` 和 `sentiment` 命令通过 HTTP 获取实时 CNN Fear & Greed Index，需要网络访问\n- **异步要求**: 这两个命令是异步的，agent 调用时需确保环境支持 async execution\n- **Windows 编码**: PowerShell 默认 GBK 编码可能导致中文乱码，建议使用 UTF-8 终端或重定向输出到文件\n- **年化收益计算**: 使用 `annualized = (current / cost) ^ (365 / holding_days) - 1`，短期持仓（< min_holding_days）的年化收益不显示\n- **绝对收益止盈**: 当持仓绝对收益 ≥ 30% 时，即使年化收益率未达阈值也可能触发卖出建议\n\n## 错误处理\n\n- **网络错误**: `sentiment` 和 `report` 可能因 API 不可用失败，建议重试或使用缓存数据\n- **数据库锁定**: 多进程并发操作 SQLite 会导致锁定，agent 应确保串行访问\n- **配置错误**: 检查 `~/.mns/config.toml` 语法，使用 `config` 命令验证可访问的配置项\n\n## 相关文件\n\n- `references/` - 详细的技术参考文档（配置结构、数据库 schema、策略参数）\n- `assets/` - 模板文件（如报告 HTML 模板）\n\n## 开源信息\n\nMNS (money-never-sleep) 是开源项目，源码托管于 GitHub：\n\n**[https://github.com/sopaco/money-never-sleep](https://github.com/sopaco/money-never-sleep)**\n\nFile v0.5.3:_meta.json\n\n{\n  \"ownerId\": \"kn7a2vy7ys7aj3gzm2vvw7zc158311b2\",\n  \"slug\": \"money-never-sleep\",\n  \"version\": \"0.5.3\",\n  \"publishedAt\": 1776668983704\n}\n\nFile v0.5.3:references/commands.md\n\n# MNS CLI 命令参考\n\n本文档详细描述 MNS CLI 的所有命令、参数和用法。\n\n## 命令概览\n\n| 命令 | 用途 | 异步 |\n|------|------|------|\n| `init` | 初始化和数据库 | 否 |\n| `config` | 查看/修改配置 | 否 |\n| `cash` | 现金余额管理 | 否 |\n| `portfolio` | 查看持仓概览 | 否 |\n| `add` | 新增资产到持仓池 | 否 |\n| `buy` | 记录买入交易 | 否 |\n| `sell` | 记录卖出交易 | 否 |\n| `price` | 更新资产当前价格 | 否 |\n| `sentiment` | 查看当前恐贪指数 | 是 |\n| `report` | 生成策略报告 | 是 |\n| `history` | 查看交易历史 | 否 |\n\n---\n\n## `init`\n\n**语法**: `mns init [-f, --force]`\n\n**功能**: 创建默认配置文件 `~/.mns/config.toml` 和空的 SQLite 数据库 `~/.mns/mns.db`，同时创建报告输出目录。\n\n**参数**:\n- `-f, --force`: 跳过确认提示，强制覆盖已有数据\n\n**行为说明**:\n- 如果检测到已有配置文件或数据库，会提示用户确认后再覆盖\n- 使用 `--force` 参数可跳过确认直接覆盖\n\n**示例**:\n```bash\n# 普通初始化（如有数据会提示确认）\nmns init\n\n# 强制初始化（跳过确认）\nmns init --force\n```\n\n**输出示例（已有数据时）**:\n```\n⚠️  检测到已有数据：\n   配置文件: /home/user/.mns/config.toml\n   数据库:   /home/user/.mns/mns.db\n\n继续将覆盖上述文件，数据将丢失。是否继续？[y/N]: y\n✓ 初始化完成\n  配置文件: /home/user/.mns/config.toml\n  数据库:   /home/user/.mns/mns.db\n  报告目录: ./reports\n```\n\n**输出示例（使用 --force）**:\n```\n✓ 初始化完成\n  配置文件: /home/user/.mns/config.toml\n  数据库:   /home/user/.mns/mns.db\n  报告目录: ./reports\n```\n\n**注意**: \n- 报告目录默认为当前目录下的 `reports/`，可通过配置修改\n- 输入 `y` 或 `yes` 确认覆盖，其他任何输入都会取消操作\n\n---\n\n## `config`\n\n**语法**: `mns config [KEY] [VALUE]`\n\n**功能**: 查看或修改配置项。支持 dot-path 语法访问嵌套配置。\n\n### 查看所有配置\n```bash\nnpx @never-sleeps/bin-darwin-arm64 config\n```\n\n输出 TOML 格式的完整配置。\n\n### 查看特定配置项\n```bash\nnpx @never-sleeps/bin-darwin-arm64 config thresholds.fear\nnpx @never-sleeps/bin-darwin-arm64 config buy_ratio.extreme_fear\n```\n\n输出:\n```\nthresholds.fear = 45\nbuy_ratio.extreme_fear = 0.50\n```\n\n### 修改配置项\n```bash\nnpx @never-sleeps/bin-darwin-arm64 config thresholds.greed 75\nnpx @never-sleeps/bin-darwin-arm64 config buy_ratio.fear 0.30\n```\n\n**支持的特殊语法**:\n- 嵌套键: `thresholds.fear`\n- 数组索引: `sell_ratio.(\"greed\",\"between\")`（注意引号和括号）\n\n**示例 - 完整参数调优**:\n```bash\n# 调整买入比例\nnpx @never-sleeps/bin-darwin-arm64 config buy_ratio.extreme_fear 0.60\nnpx @never-sleeps/bin-darwin-arm64 config buy_ratio.fear 0.25\nnpx @never-sleeps/bin-darwin-arm64 config buy_ratio.neutral 0.10\n\n# 调整卖出矩阵\nnpx @never-sleeps/bin-darwin-arm64 config sell_ratio.(\"extreme_greed\",\"above_high\") 0.60\nnpx @never-sleeps/bin-darwin-arm64 config sell_ratio.(\"greed\",\"above_high\") 0.50\n\n# 调整止盈线\nnpx @never-sleeps/bin-darwin-arm64 config annualized_target_low 12.0\nnpx @never-sleeps/bin-darwin-arm64 config annualized_target_high 18.0\n\n# 调整最小持有天数（避免短期年化收益失真）\nnpx @never-sleeps/bin-darwin-arm64 config min_holding_days 30\n```\n\n---\n\n## `cash`\n\n**语法**: `mns cash [ACTION]`\n\n**功能**: 查看或设置现金余额。\n\n### 查看余额\n```bash\nnpx @never-sleeps/bin-darwin-arm64 cash\n```\n\n输出:\n```\n现金余额: ¥125430.50\n```\n\n### 设置现金余额\n```bash\nnpx @never-sleeps/bin-darwin-arm64 cash set 100000\n```\n\n### 增加现金\n```bash\nnpx @never-sleeps/bin-darwin-arm64 cash add 5000\n```\n\n**注意**:\n- `set` 会覆盖当前余额\n- `add` 在当前余额基础上增加\n- 金额不能为负数\n\n---\n\n## `portfolio`\n\n**语法**: `mns portfolio`\n\n**功能**: 显示当前持仓概览，包括：\n- 资产代码和名称\n- 持仓份额和成本价\n- 当前价格（需通过 `price` 命令更新）\n- 持仓市值和盈亏\n- 年化收益率（基于持有天数）\n\n**示例输出**:\n```\n┌───────┬────────────┬──────────┬──────────┬─────────────┬─────────────┬────────────┐\n│ 代码  │   名称     │  份额    │ 成本价   │ 当前价      │  市值       │ 年化收益   │\n├───────┼────────────┼──────────┼──────────┼─────────────┼─────────────┼────────────┤\n│ QQQ   │ 纳指100    │ 150.0    │ 450.00   │ 460.50      │ 69075.00    │  +8.2%     │\n│ SH600 │ 浦发银行   │ 500.0    │ 12.30    │ 12.80       │ 6400.00     │ +15.3%     │\n└───────┴────────────┴──────────┴──────────┴─────────────┴─────────────┴────────────┘\n\n总市值: ¥75475.00\n现金余额: ¥24685.50\n总资产: ¥100160.50\n```\n\n**注意事项**:\n- 年化收益计算公式: `(current / cost) ^ (365 / holding_days) - 1`\n- 如果持有天数小于配置的 `min_holding_days`，年化收益显示为 `N/A`\n- 当前价格需要定期通过 `price` 命令更新\n\n---\n\n## `add`\n\n**语法**: `mns add <CODE> <NAME> <CATEGORY>`\n\n**功能**: 新增资产到持仓池，后续可通过 `buy` 命令买入。\n\n**参数**:\n- `CODE`: 资产代码（如 `QQQ`, `SH600000`, `AAPL`）\n- `NAME`: 资产名称（任意描述性字符串）\n- `CATEGORY`: 类别，预设可选值：\n  - `us_stocks` - 美股\n  - `cn_stocks` - A股\n  - `counter_cyclical` - 逆周期资产\n\n**示例**:\n```bash\nnpx @never-sleeps/bin-darwin-arm64 add QQQ \"纳指100\" us_stocks\nnpx @never-sleeps/bin-darwin-arm64 add SH600000 \"浦发银行\" cn_stocks\nnpx @never-sleeps/bin-darwin-arm64 add GLD \"黄金ETF\" counter_cyclical\n```\n\n**注意**:\n- 资产代码在数据库中必须唯一\n- 添加后立即用 `buy` 记录初始买入\n\n---\n\n## `buy`\n\n**语法**: `mns buy <CODE> <SHARES> <PRICE>`\n\n**功能**: 记录买入交易，增加持仓份额。\n\n**参数**:\n- `CODE`: 资产代码（必须已通过 `add` 添加）\n- `SHARES`: 买入份额（支持小数，如股票可支持碎股）\n- `PRICE`: 买入单价（元/股）\n\n**示例**:\n```bash\n# 买入 100 股 QQQ，单价 450.50 元\nnpx @never-sleeps/bin-darwin-arm64 buy QQQ 100 450.50\n\n# 买入 50 份黄金 ETF，单价 180.00 元\nnpx @never-sleeps/bin-darwin-arm64 buy GLD 50 180.00\n```\n\n**行为**:\n- 现金余额相应减少\n- 持仓成本价重新计算（加权平均）\n- 交易记录存入 `transactions` 表\n\n---\n\n## `sell`\n\n**语法**: `mns sell <CODE> <SHARES> <PRICE>`\n\n**功能**: 记录卖出交易，减少持仓份额。\n\n**参数**:\n- `CODE`: 资产代码\n- `SHARES`: 卖出份额（不能超过当前持仓）\n- `PRICE`: 卖出单价\n\n**示例**:\n```bash\n# 卖出 30 股 QQQ，单价 455.00 元\nnpx @never-sleeps/bin-darwin-arm64 sell QQQ 30 455.00\n\n# 清仓某资产\nnpx @never-sleeps/bin-darwin-arm64 sell SH600000 500 13.20\n```\n\n**行为**:\n- 现金余额相应增加\n- 持仓份额减少，成本价保持不变（剩余份额）\n- 交易记录存入 `transactions` 表\n\n---\n\n## `price`\n\n**语法**: `mns price <CODE> [PRICE]`\n\n**功能**: 查看或更新资产的当前价格。\n\n### 查看当前价格\n```bash\nnpx @never-sleeps/bin-darwin-arm64 price QQQ\n```\n\n输出:\n```\nQQQ (纳指100): ¥460.50\n```\n\n### 更新当前价格\n```bash\nnpx @never-sleeps/bin-darwin-arm64 price QQQ 460.50\n```\n\n**注意**:\n- 每次更新价格会更新对应持仓的 `current_price` 和 `current_at` 字段\n- 不更新价格会导致 `portfolio` 和 `report` 显示的市值不准确\n- 建议每日运行 `report` 前先更新价格，或编写脚本自动更新\n\n---\n\n## `sentiment`\n\n**语法**: `mns sentiment`\n\n**功能**: 从 CNN 官网获取最新的 Fear & Greed Index 数据。\n\n**示例**:\n```bash\nnpx @never-sleeps/bin-darwin-arm64 sentiment\n```\n\n输出:\n```\nCNN Fear & Greed Index: 42 (Fear)\nPrevious Close: 38\n1 Week Ago: 35\n1 Month Ago: 28\n```\n\n**注意**:\n- 此命令是异步的，需要网络访问\n- 如果 API 不可用，可能返回错误\n- 数据来自 `https://cnn.com/data/api/ Fear & Greed` 端点\n\n---\n\n## `report`\n\n**语法**: `mns report`\n\n**功能**: 生成今日策略报告，包含：\n1. 当前恐贪指数和情绪判断\n2. 买入建议（基于可用现金和 contrarian 分配）\n3. 卖出建议（基于年化收益和绝对收益）\n4. 持仓摘要和风险警告（浮亏过大）\n5. 现金预测（按建议执行后）\n\n**示例**:\n```bash\nnpx @never-sleeps/bin-darwin-arm64 report\n```\n\n**输出节选**:\n```\n╔═══════════════════════════════════════════════════════════════╗\n║           MNS 逆向投资策略报告 - 2026-04-20                     ║\n╚═══════════════════════════════════════════════════════════════╝\n\n📊 市场情绪 (CNN Fear & Greed)\n┌─────────────────────────────────────┐\n│ 当前指数: 42 (Fear)                  │\n│ 状态解读: 市场处于恐慌区间，建议逐步  │\n│         买入                          │\n└─────────────────────────────────────┘\n\n💰 买入建议 (可用现金: ¥25000)\n┌─────────────────────────────────────┐\n│ QQQ (Fear 区间权重: 1.2)             │\n│  建议买入: ¥12000 (50 股 @ ¥240)    │\n│                                     │\n│ SH600000 (Fear 区间权重: 1.5)        │\n│  建议买入: ¥13000 (1042 股 @ ¥12.5) │\n└─────────────────────────────────────┘\n\n⚠️  卖出建议\n┌─────────────────────────────────────┐\n│ 暂无满足卖出条件的持仓              │\n└─────────────────────────────────────┘\n\n🚨 风险警告\n┌─────────────────────────────────────┐\n│ [无]                                │\n└─────────────────────────────────────┘\n```\n\n**注意**:\n- 异步命令，需要网络获取恐贪指数\n- 报告同时保存到报告目录（默认 `./reports/`）\n- 买入/卖出建议仅供参考，agent 需根据实际执行顺序调整\n\n---\n\n## `history`\n\n**语法**: `mns history [--limit N]`\n\n**功能**: 查看最近的交易历史。\n\n**参数**:\n- `--limit N`: 显示条数，默认 20，最大 100\n\n**示例**:\n```bash\n# 查看最近 20 条\nnpx @never-sleeps/bin-darwin-arm64 history\n\n# 查看最近 50 条\nnpx @never-sleeps/bin-darwin-arm64 history --limit 50\n```\n\n**输出**:\n```\n最近交易记录 (按时间倒序):\n┌─────────────────┬───────┬────────┬──────┬────────┬──────────┐\n│ 时间            │ 类型  │ 资产   │ 份额 │ 价格   │ 金额     │\n├─────────────────┼───────┼────────┼──────┼────────┼──────────┤\n│ 2025-06-15 10:3│ buy   │ QQQ    │ 50   │ 448.50 │ 22425.00 │\n│ 2025-06-14 14:2│ sell  │ SH600  │ 100  │ 13.00  │ 1300.00  │\n│ 2025-06-14 09:1│ price │ QQQ    │ -    │ 445.00 │ -        │\n└─────────────────┴───────┴────────┴──────┴────────┴──────────┘\n```\n\n**类型说明**:\n- `buy` - 买入交易\n- `sell` - 卖出交易\n- `price` - 价格更新记录\n\n---\n\n## 异步命令说明\n\n`sentiment` 和 `report` 是异步命令，调用方式略有不同：\n\n### 在 Shell 中直接调用\n```bash\nnpx @never-sleeps/bin-darwin-arm64 sentiment\nnpx @never-sleeps/bin-darwin-arm64 report\n```\n\n### 在 Node.js/TypeScript 中调用\n```javascript\nimport { spawn } from 'child_process';\n\nconst result = spawn('npx', [\n  '@never-sleeps/bin-darwin-arm64',\n  'report'\n], { shell: true });\n\nresult.stdout.on('data', data => console.log(data.toString()));\nresult.stderr.on('data', data => console.error(data.toString()));\n```\n\n### 在 Python 中调用\n```python\nimport subprocess\n\nresult = subprocess.run(\n    ['npx', '@never-sleeps/bin-darwin-arm64', 'report'],\n    capture_output=True,\n    text=True\n)\nprint(result.stdout)\nif result.returncode != 0:\n    print(f\"Error: {result.stderr}\")\n```\n\n---\n\n## 通用 Exit Code\n\n| Code | 含义 |\n|------|------|\n| 0    | 成功 |\n| 1    | 通用错误（配置错误、参数错误、数据库错误等） |\n| 2    | 网络错误（仅影响 `sentiment`/`report`） |\n\n---\n\n## 平台适配\n\n根据目标平台选择相应的 npm 包名：\n\n| 平台 | npm 包名 |\n|------|----------|\n| macOS (Apple Silicon) | `@never-sleeps/bin-darwin-arm64` |\n| Linux (x64) | `@never-sleeps/bin-linux-x64` |\n| Windows (x64) | `@never-sleeps/bin-win-x64` |\n\n**示例使用方式**:\n```bash\n# 在 agent skill 中动态选择平台\nnpx @never-sleeps/cli-${PLATFORM} report\n# 其中 PLATFORM 为 darwin-arm64 / linux-x64 / win-x64\n```\n\n**注意**: 这些包是预编译的二进制分发，安装时需要解除 Node.js 的 npm 包限制（`--ignore-scripts` 或使用 `npx` 直接运行）。\n\n---\n\n## 配置文件结构参考\n\n完整的配置结构（`~/.mns/config.toml`）:\n\n```toml\n[database]\npath = \"~/.mns/mns.db\"\n\n[settings]\nmin_holding_days = 30\nannualized_target_low = 10.0\nannualized_target_high = 15.0\nreport_output_dir = \"./reports\"\n\n[thresholds]\nextreme_fear = 25\nfear = 45\nneutral = 55\ngreed = 75\nextreme_greed = 100\n\n[buy_ratio]\nextreme_fear = 0.50\nfear = 0.30\nneutral = 0.20\ngreed = 0.00\n\n[sell_ratio]\n# 格式: sell_ratio.(\"情绪\", \"价格位置\") = 比例\n# 情绪: extreme_greed, greed, neutral, fear, extreme_fear\n# 价格位置: above_high, between, below_low\n\"sell_ratio.(\\\"extreme_greed\\\",\\\"above_high\\\")\" = 0.50\n\"sell_ratio.(\\\"extreme_greed\\\",\\\"between\\\")\" = 0.30\n\"sell_ratio.(\\\"extreme_greed\\\",\\\"below_low\\\")\" = 0.20\n\"sell_ratio.(\\\"greed\\\",\\\"above_high\\\")\" = 0.40\n\"sell_ratio.(\\\"greed\\\",\\\"between\\\")\" = 0.20\n```\n\n---\n\n## 数据库 Schema 参考\n\n主要表结构：\n\n### `cash`\n- `id` INTEGER PRIMARY KEY\n- `balance` REAL NOT NULL\n- `updated_at` TIMESTAMP\n\n### `positions`\n- `id` INTEGER PRIMARY KEY\n- `code` TEXT NOT NULL UNIQUE\n- `name` TEXT NOT NULL\n- `category` TEXT NOT NULL\n- `shares` REAL NOT NULL\n- `cost_price` REAL NOT NULL\n- `current_price` REAL NOT NULL\n- `updated_at` TIMESTAMP\n- `created_at` TIMESTAMP\n\n### `transactions`\n- `id` INTEGER PRIMARY KEY\n- `type` TEXT NOT NULL ('buy' | 'sell' | 'price')\n- `code` TEXT NOT NULL\n- `shares` REAL\n- `price` REAL\n- `amount` REAL\n- `created_at` TIMESTAMP\n\n### `snapshots` (用于数据导出和审计)\n- `id` INTEGER PRIMARY KEY\n- `data` TEXT (JSON 格式的快照)\n\n---\n\n## 错误信息速查\n\n| 错误信息 | 原因 | 解决方案 |\n|----------|------|----------|\n| `未知的配置项` | 配置路径错误或不存在 | 用 `config` 查看有效的配置项 |\n| `现金余额不能为负数` | `cash set` 参数 < 0 | 检查金额参数 |\n| `资产代码不存在` | `buy`/`sell`/`price` 使用未添加的代码 | 先用 `add` 添加资产 |\n| `卖出份额超过持仓` | `sell` 参数 > 当前持仓 | 检查持仓数量 |\n| `API error: ...` | CNN API 不可用 | 稍后重试或检查网络 |\n| `Database is locked` | 并发访问数据库 | 确保同一时间只有一个进程操作 |\n| `配置文件解析错误` | `config.toml` 语法错误 | 检查 TOML 语法 |\n\n---\n\n## 常见问题\n\n### Q: 如何批量导入历史交易？\nA: 暂无批量导入命令。可编写脚本依次调用 `buy`、`sell`、`price`，或直接操作 SQLite 数据库。\n\n### Q: 年化收益显示为 `N/A`？\nA: 持仓天数小于 `min_holding_days`（默认 30 天）时不计算年化收益，避免短期波动误导。\n\n### Q: 如何查看详细的卖出建议计算过程？\nA: 查看 `report` 输出中的 \"卖出建议\" 部分，或读取数据库中的 `positions` 表计算 `annualized_return`。\n\n### Q: 怎样将报告导出为 HTML？\nA: 当前报告为纯文本格式。可将输出重定向到文件后用第三方工具转换，或自行编写 wrapper 脚本生成 HTML。\n\n### Q: 能否在 Windows PowerShell 中正确显示中文？\nA: PowerShell 默认 GBK 编码可能导致乱码。解决方案：\n```powershell\n# 使用 UTF-8 编码\nchcp 65001\n# 或在命令前设置\n[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new()\n```\n\n---\n\n## 版本历史\n\n### v0.5.5 (当前)\n- 完整的 CLI 命令集\n- 异步 CNN Fear & Greed Index 获取\n- dot-path 配置管理\n- contrarian 买入分配\n- 双准则卖出决策\n- 多平台二进制分发（npm）\n\n---\n\n**最后更新**: 2026-04-20\n\nFile v0.5.3:references/strategy.md\n\n# MNS 策略参数参考\n\n本文档详细说明 MNS 逆向投资策略的核心参数，包括阈值定义、买入/卖出比例配置、止盈线设置等。这些参数通过 `~/.mns/config.toml` 管理，可通过 `mns config` 命令动态调整。\n\n---\n\n## 配置层级\n\nMNS 配置采用分层结构：\n\n```toml\n[database]\npath = \"~/.mns/mns.db\"\n\n[settings]\nmin_holding_days = 30          # 最小持有天数（年化收益计算用）\nannualized_target_low = 10.0   # 年化止盈线下限\nannualized_target_high = 15.0  # 年化止盈线上限\nreport_output_dir = \"./reports\"\n\n[thresholds]\nextreme_fear = 25      # 极度恐慌阈值\nfear = 45              # 恐慌阈值\nneutral = 55           # 中性阈值\ngreed = 75             # 贪婪阈值\nextreme_greed = 100    # 极度贪婪阈值（通常固定为 100）\n\n[buy_ratio]\nextreme_fear = 0.50    # 极度恐慌时买入比例（可用现金的 50%）\nfear = 0.30            # 恐慌时买入比例\nneutral = 0.20         # 中性时买入比例\ngreed = 0.00           # 贪婪时不买入\n# extreme_greed 默认 0.00（通常不买入）\n\n[sell_ratio]\n# 格式: (\"情绪\", \"价格位置\") = 卖出比例\n# 价格位置定义:\n#   above_high  - 当前价格高于阻力位（盈利状态）\n#   between     - 价格在支撑位和阻力位之间\n#   below_low   - 当前价格低于支撑位（浮亏状态）\n\n\"sell_ratio.(\\\"extreme_greed\\\",\\\"above_high\\\")\" = 0.50\n\"sell_ratio.(\\\"extreme_greed\\\",\\\"between\\\")\" = 0.30\n\"sell_ratio.(\\\"extreme_greed\\\",\\\"below_low\\\")\" = 0.20\n\"sell_ratio.(\\\"greed\\\",\\\"above_high\\\")\" = 0.40\n\"sell_ratio.(\\\"greed\\\",\\\"between\\\")\" = 0.20\n\"sell_ratio.(\\\"greed\\\",\\\"below_low\\\")\" = 0.00\n# neutral/fear/extreme_fear 默认无卖出（值为 0.00）\n```\n\n---\n\n## 恐贪指数区间划分\n\nCNN Fear & Greed Index 是一个 0-100 的指数，0 表示极度恐慌（Extreme Fear），100 表示极度贪婪（Extreme Greed）。\n\n### 默认区间配置\n\n| 区间名称 | 指数范围 | 含义 | 买入比例 |\n|---------|---------|------|---------|\n| Extreme Fear | 0-25 | 市场极度恐慌，逆向买入信号强 | 50% |\n| Fear | 25-45 | 市场恐慌，适度买入 | 30% |\n| Neutral | 45-55 | 中性，小额买入或观望 | 20% |\n| Greed | 55-75 | 市场贪婪，谨慎持有 | 0% |\n| Extreme Greed | 75-100 | 市场极度贪婪，考虑减仓 | 0% |\n\n### 调整阈值\n\n通过修改 `thresholds` 可改变区间边界：\n\n```bash\n# 将贪婪阈值从 75 降至 70，使贪婪区间更早触发\nnpx @never-sleeps/bin-darwin-arm64 config thresholds.greed 70\n\n# 将极度恐慌阈值从 25 提升至 30，减少极端情况下的买入频率\nnpx @never-sleeps/bin-darwin-arm64 config thresholds.extreme_fear 30\n```\n\n**注意**: 区间必须保持连续性，建议:\n- `extreme_fear < fear < neutral < greed < extreme_greed`\n- 通常 `extreme_greed` 固定为 100\n\n---\n\n## 买入比例矩阵 (`buy_ratio`)\n\n定义在不同情绪区间下，用多少比例的可用现金进行买入。\n\n### 参数说明\n\n- **可用现金**: `cash_balance + 卖出回笼资金`\n- **分配方式**: 按 contrarian 权重（浮亏资产权重更高）分配到各资产\n- **单次买入上限**: 单个资产不超过该比例 × 总可用现金\n\n### 默认配置\n\n| 情绪区间 | 买入比例 | 适用场景 |\n|---------|---------|---------|\n| extreme_fear | 0.50 | 恐慌极致，重仓抄底 |\n| fear | 0.30 | 恐慌情绪，积极建仓 |\n| neutral | 0.20 | 中性市场，小额布局 |\n| greed | 0.00 | 贪婪时暂停买入 |\n| extreme_greed | 0.00 | 极度贪婪时完全不买入 |\n\n### 调优示例\n\n```bash\n# 策略1: 极度贪婪时也可能小幅买入（左侧布局）\nnpx @never-sleeps/bin-darwin-arm64 config buy_ratio.extreme_greed 0.10\n\n# 策略2: 中性区间也暂停买入，只在明确的恐慌区间\n\nArchive v0.5.2: 6 files, 16488 bytes\n\nFiles: assets/examples/portfolio-example.json (1426b), assets/examples/report-example.json (2580b), references/commands.md (17025b), references/strategy.md (11555b), SKILL.md (7135b), _meta.json (136b)\n\nArchive v0.5.1: 11 files, 20918 bytes\n\nFiles: assets/examples/portfolio-example.json (1426b), assets/examples/report-example.json (2580b), package.json (721b), README.md (202b), references/commands.md (17025b), references/strategy.md (11555b), scripts/detect-platform.js (2028b), scripts/run-mns.js (2644b), scripts/validate-skill.js (2566b), SKILL.md (8568b), _meta.json (136b)\n\nArchive v0.5.0: 11 files, 20849 bytes\n\nFiles: assets/examples/portfolio-example.json (1426b), assets/examples/report-example.json (2580b), package.json (745b), README.md (184b), references/commands.md (16682b), references/strategy.md (11365b), scripts/detect-platform.js (2001b), scripts/run-mns.js (2756b), scripts/validate-skill.js (2566b), SKILL.md (8253b), _meta.json (136b)","readmeExcerpt":"Skill: money-never-sleep Owner: sopaco Summary: MNS (Money Never Sleeps) CLI operations manual for autonomous agents. Tracks an investment portfolio in a local ledger, reads market sentiment (CNN Fear & Greed Index), and generates target-weight rebalancing suggestions. Use when the user asks to view holdings, record a trade they already executed, Tags: latest:0.6.0 Version history: v0.6.0 | 2026-07-31T15:47:05.459Z |","codeSnippets":[],"executableExamples":[{"language":"bash","snippet":"mns --version"},{"language":"bash","snippet":"npm install -g @never-sleeps/mns-cli"},{"language":"bash","snippet":"mns update-prices   # 先刷新价格，否则报告基于过期价格\nmns report          # 生成调仓报告"},{"language":"bash","snippet":"# 用户：\"我在券商买了 300 份 018966，成交价 1.52\"\nmns buy 018966 300 1.52\nmns portfolio            # 复核登记结果"},{"language":"bash","snippet":"mns add 518880 \"黄金ETF华安\" counter_cyclical   # 先入池\nmns buy 518880 1000 8.38                        # 再登记已成交买入"},{"language":"bash","snippet":"mns backtest params                    # 先查键名与默认值\nmns config rebalance.band_pp           # 读当前值\nmns config rebalance.band_pp 6         # 改（校验不通过会拒绝）\nmns backtest                           # 改完跑回测看影响"}],"parameters":null,"dependencies":[],"permissions":[],"extractedFiles":[{"path":"SKILL.md","content":"---\nname: money-never-sleep\nversion: 0.6.0\ndescription: |\n  MNS (Money Never Sleeps) CLI operations manual for autonomous agents. Tracks an investment\n  portfolio in a local ledger, reads market sentiment (CNN Fear & Greed Index), and generates\n  target-weight rebalancing suggestions. Use when the user asks to view holdings, record a\n  trade they already executed, generate a daily strategy report, inspect or tune strategy\n  parameters, or run a backtest.\n\n  CRITICAL: MNS connects to NO broker and executes NO trades. `mns buy` / `mns sell` are\n  bookkeeping entries that record trades the human has ALREADY executed elsewhere. Never call\n  them to \"act on\" a suggestion — doing so silently corrupts every downstream number.\n\n  Triggers: \"查看持仓\", \"记录买入\", \"记录卖出\", \"生成策略报告\", \"调仓建议\", \"再平衡\",\n  \"恐贪指数\", \"更新价格\", \"现金余额\", \"交易历史\", \"回测策略\", \"调整策略参数\", \"MNS\"\nlicense: MIT\ncompatibility: Single static binary (Rust). No runtime dependencies.\nmetadata:\n  {\n    \"openclaw\":\n      {\n        \"source\": \"https://github.com/sopaco/money-never-sleep\",\n        \"homepage\": \"https://github.com/sopaco/money-never-sleep\",\n        \"author\": \"Sopaco\",\n        \"os\": [\"darwin\", \"linux\", \"win32\"]\n      }\n  }\n---\n\n# MNS 操作手册（面向 Agent）\n\n## 0. 先读这三条硬约束\n\n**① `mns buy` / `mns sell` 是记账，不是下单。**\nMNS 不连接任何券商。这两个命令的唯一用途是把**用户已经在券商完成的**交易登记进本地账本。\n\n- ✅ 用户说\"我刚买了 100 份 QQQ，成交价 450\" → `mns buy QQQ 100 450`\n- ❌ `mns report` 建议买入 ¥2000 → **不要**据此调用 `mns buy`\n\n记入一笔并未真实发生的交易，会同时污染现金余额、成本价、持有天数、收益率和后续所有调仓建议，且没有撤销命令。**不确定用户是否真的成交过，就先问。**\n\n**② 建议不是投资建议。**\n`mns report` 的输出是规则引擎的机械计算结果。向用户转述时要说明它来自什么规则，不要包装成推荐意见，也不要替用户做买卖决定。用户自己的判断和持牌顾问才是决策来源。\n\n**③ 数字只能来自命令输出。**\n不要凭记忆或推算填写价格、份额、收益率。拿不到数据就说拿不到——不要编。\n\n---\n\n## 1. 安装与可用性检查\n\n**执行任何操作前，先判断 `mns` 是否已安装可用，不要重复安装。**\n\n```bash\nmns --version\n```\n\n- 输出正常版本号 → 已安装，直接跳到第 2 节使用即可。\n- 报 `command not found` / 找不到命令 → 执行下方安装步骤。\n\n**通过 npm 安装**（会按当前系统自动拉取对应平台的预编译二进制，支持 macOS Apple Silicon / Linux x64 / Windows x64）：\n\n```bash\nnpm install -g @never-sleeps/mns-cli\n```\n\n安装完成后重新执行 `mns --version` 复核。若已执行过安装且 `mns --version` 仍失败，说明是 PATH 未生效或当前平台/架构暂无预编译包，直接向用户反馈原因即可，**不要**反复重跑安装命令。\n\n---\n\n## 2. 命令速查（语法已逐条实测）\n\n| 命令 | 作用 | 备注 |\n|---|---|---|\n| `mns init` | 初始化配置与数据库 | **会清空既有数据**，有确认提示；`--force` 跳过确认 |\n| `mns cash` | 查看现金余额 | |\n| `mns cash set <金额>` | 设为指定余额 | 覆盖式 |\n| `mns cash add <金额>` | 增加现金（注资） | 金额须为正 |\n| `mns portfolio` | 持仓概览（份额/成本/现价/市值/收益） | 只读，最常用 |\n| `mns add <代码> <名称> <类别>` | 把标的加入持仓池（份额为0） | 类别只能是 `us_stocks` / `cn_stocks` / `counter_cyclical` |\n| `mns buy <代码> <份额> <价格>` | **登记**已成交买入 | 现金不足会报错；须先 `add` |\n| `mns sell <代码> <份额> <价格>` | **登记**已成交卖出 | 份额超出持有量会报错 |\n| `mns price <代码> [价格]` | 省略价格=查看；带价格=手工更新 | |\n| `mns update-prices` | 自动抓取全部持仓现价 | 需要网络；单个失败会跳过并继续 |\n| `mns remove <代码>` | 从持仓池删除标的 | 不可逆，先与用户确认 |\n| `mns sentiment` | 当前恐贪指数 | 需要网络 |\n| `mns report` | 生成今日调仓报告并存盘 | 需要网络；同时写入 `reports/YYYY-MM-DD.txt` |\n| `mns history [条数]` | 交易历史，默认 20 条 | **位置参数**，不是 `--limit` |\n| `mns config` | 打印全部配置 | |\n| `mns config <键>` | 读单项 | 必须是完整叶子键 |\n| `mns config <键> <值>` | 改单项 | 校验不通过则拒绝写入，原配"},{"path":"_meta.json","content":"{\n  \"ownerId\": \"kn7a2vy7ys7aj3gzm2vvw7zc158311b2\",\n  \"slug\": \"money-never-sleep\",\n  \"version\": \"0.6.0\",\n  \"publishedAt\": 1785512825459\n}"},{"path":"skill-card.md","content":"## Description:\n\nMNS (Money Never Sleeps) is a CLI operations manual that guides agents through local portfolio ledger review, already-executed trade recording, market sentiment checks, target-weight rebalancing reports, strategy parameter inspection, and backtesting.\n\nThis skill is ready for commercial/non-commercial use.\n\n## Publisher:\n\n[sopaco](https://clawhub.ai/user/sopaco)\n\n### License/Terms of Use:\n\nMIT-0\n\n## Use Case:\n\nExternal users and agents use this skill to operate the MNS CLI for local portfolio bookkeeping, daily or weekly strategy reporting, manual price and configuration workflows, and backtest review. The skill is for recording user-confirmed transactions and explaining rule-based outputs, not for executing broker trades or making investment decisions.\n\n### Deployment Geography for Use:\n\nGlobal\n\n## Known Risks and Mitigations:\n\nRisk: The skill asks agents to install and run an unpinned third-party npm package.\n\nMitigation: Review the npm package and publisher before installation, prefer a pinned audited version, and run it in an isolated environment when possible.\n\nRisk: The CLI can mutate local financial ledger records, including recording trades and resetting data.\n\nMitigation: Only record trades or reset data after explicit user confirmation of the real-world transaction or destructive action.\n\nRisk: Rule-based rebalancing reports may be mistaken for investment advice.\n\nMitigation: Present reports as mechanical calculations, avoid making buy or sell decisions for the user, and preserve the skill's stated limitations.\n\n## Reference(s):\n\n- [ClawHub skill page](https://clawhub.ai/sopaco/skills/money-never-sleep)\n- [Project homepage](https://github.com/sopaco/money-never-sleep)\n- [OpenClaw source link](https://github.com/sopaco/money-never-sleep)\n\n## Skill Output:\n\n**Output Type(s):** [text, markdown, shell commands, configuration, guidance]\n\n**Output Format:** [Markdown guidance with inline shell commands and command-output summaries]\n\n**Output Parameters:** [1D]\n\n**Other Properties Related to Output:** [Outputs should distinguish bookkeeping from investment advice and use command output as the source for portfolio figures.]\n\n## Skill Version(s):\n\n0.6.0 (source: server release evidence and skill frontmatter)\n\n## Ethical Considerations:\n\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment."}],"languages":[],"docsSourceLabel":"CLAWHUB","editorialOverview":"MNS (Money Never Sleeps) CLI operations manual for autonomous agents. Tracks an investment portfolio in a local ledger, reads market sentiment (CNN Fear & Greed Index), and generates target-weight rebalancing suggestions. Use when the user asks to view holdings, record a trade they already executed, Skill: money-never-sleep Owner: sopaco Summary: MNS (Money Never Sleeps) CLI operations manual for autonomous agents. Tracks an investment portfolio in a local ledger, reads market sentiment (CNN Fear & Greed Index), and generates target-weight rebalancing suggestions. Use when the user asks to view holdings, record a trade they already executed, Tags: latest:0.6.0 Version history: v0.6.0 | 2026-07-31T15:47:05.459Z |","editorialQuality":{"score":100,"threshold":65,"status":"ready","wordCount":1408,"uniquenessScore":48,"reasons":[]}},"media":{"evidence":{"source":"no-media","verified":false,"confidence":"low","updatedAt":"2026-10-10T17:42:02.110Z","emptyReason":"No screenshots, media assets, or demo links are available."},"primaryImageUrl":null,"mediaAssetCount":0,"assets":[],"demoUrl":null},"ownerResources":{"evidence":{"source":"unclaimed","verified":false,"confidence":"low","updatedAt":"2026-10-10T17:42:02.110Z","emptyReason":"This page has not been claimed by the agent owner."},"hasCustomPage":false,"customPageUpdatedAt":null,"customLinks":[],"structuredLinks":{"docsUrl":null,"demoUrl":null,"supportUrl":null,"pricingUrl":null,"statusUrl":null},"customPage":null},"relatedAgents":{"evidence":{"source":"protocol-neighbors","verified":false,"confidence":"medium","updatedAt":"2026-10-10T21:53:18.845Z","emptyReason":null},"items":[{"id":"8ebccd8e-3863-4187-8355-c3f14e1f9edf","entityType":"agent","canonicalPath":"/agent/iofficeai-aionui","slug":"iofficeai-aionui","name":"AionUi","description":"Free, local, open-source 24/7 Cowork app and OpenClaw for Gemini CLI, Claude Code, Codex, OpenCode, Qwen Code, Goose CLI, Auggie, and more | 🌟 Star if you like it!","url":"https://github.com/iOfficeAI/AionUi","homepage":"https://www.aionui.com","source":"GITHUB_REPOS","protocols":["MCP","OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-10-09T19:11:12.944Z","createdAt":"2026-02-25T03:38:16.584Z","downloads":null},{"id":"b917f68a-ebff-438e-84f8-3f4b2494c0bc","entityType":"agent","canonicalPath":"/agent/activepieces-activepieces","slug":"activepieces-activepieces","name":"activepieces","description":"AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents","url":"https://github.com/activepieces/activepieces","homepage":"https://www.activepieces.com","source":"GITHUB_REPOS","protocols":["OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-04-15T02:22:12.426Z","createdAt":"2026-02-25T03:38:12.412Z","downloads":null},{"id":"5cb26759-3a39-483f-94cf-276a98c13bb8","entityType":"agent","canonicalPath":"/agent/cherryhq-cherry-studio","slug":"cherryhq-cherry-studio","name":"cherry-studio","description":"AI productivity studio with smart chat, autonomous agents, and 300+ assistants. Unified access to frontier LLMs","url":"https://github.com/CherryHQ/cherry-studio","homepage":"https://cherry-ai.com","source":"GITHUB_REPOS","protocols":["MCP","OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-04-11T14:38:40.986Z","createdAt":"2026-02-25T03:38:19.379Z","downloads":null},{"id":"6f6582d0-5d76-4f0f-b81d-86520247950b","entityType":"agent","canonicalPath":"/agent/copilotkit-copilotkit","slug":"copilotkit-copilotkit","name":"CopilotKit","description":"The Frontend for Agents & Generative UI. React + Angular","url":"https://github.com/CopilotKit/CopilotKit","homepage":"https://docs.copilotkit.ai","source":"GITHUB_REPOS","protocols":["OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-03-25T09:50:57.846Z","createdAt":"2026-02-25T03:39:14.617Z","downloads":null}],"links":{"hub":"/agent","source":"/agent/source/clawhub","protocols":[{"label":"OpenClaw","href":"/agent/protocol/openclew"}]}}}