Skip to content

Fize/mmtickerlab / plan-review

plan-review

Verified

基于已校验市场数据生成盘前计划、午间复盘和收盘复盘的三段式交易操作系统,并提供交易日志记录与纪律打分功能。当用户提到盘前准备、盘中复盘、午间复盘、盘后复盘、收盘复盘、今日计划、写日志或交易日志时触发(包含触发词:盘前准备, 午间复盘, 晚间复盘, 交易计划, 复盘, 写日志, 交易日志, 今日计划, 纪律打分, plan review)。

tests/test_derived_metrics.py

View on GitHub
from __future__ import annotations

import importlib.util
import unittest
from pathlib import Path


MODULE_PATH = Path(__file__).resolve().parents[1] / "scripts" / "derived_metrics.py"
SPEC = importlib.util.spec_from_file_location("plan_review_derived_metrics", MODULE_PATH)
metrics = importlib.util.module_from_spec(SPEC)
assert SPEC.loader
SPEC.loader.exec_module(metrics)


class FearGreedTests(unittest.TestCase):
    def test_fear_greed_score_is_weighted_and_exposes_components(self) -> None:
        result = metrics.fear_greed_index({
            "volume": 41.5,
            "breadth": 50.0,
            "rsi": 50.0,
            "momentum": 44.4,
            "volatility": 75.5,
        })
        self.assertEqual(result["version"], "fg-v1")
        self.assertAlmostEqual(result["score"], 52.4, places=1)
        self.assertEqual(set(result["components"]), {"volume", "breadth", "rsi", "momentum", "volatility"})

    def test_fear_greed_from_market_data_uses_validated_snapshots(self) -> None:
        snapshot = {"data": {"metrics": {"total_turnover_yuan": 120, "up_count": 60, "down_count": 40}}}
        previous = {"data": {"metrics": {"total_turnover_yuan": 100}}}
        indices = {"data": {"indices": {"000001": {"rows": [
            {"close": 100 + value} for value in (0, 1, 2, 1, 3, 4, 5, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)
        ]}}}}
        result = metrics.fear_greed_from_market_data(snapshot, previous, indices)
        self.assertEqual(result["version"], "fg-v1")
        self.assertIn("components", result)

    def test_commodity_rows_require_timestamped_status(self) -> None:
        rows = [{
            "category": "贵金属", "instrument": "黄金主连", "price": 800,
            "change_pct": 1.2, "change_5d": 2.3, "unit": "元/克",
            "as_of": "2026-09-17T15:00:00+08:00", "status": "final",
        }]
        self.assertEqual(metrics.validate_commodity_rows(rows), rows)


if __name__ == "__main__":
    unittest.main()
receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementationStars: 322kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 322kUpdated Claude CodeCodexVerifiedInstall
using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallbackStars: 322kUpdated Claude CodeCodexVerifiedInstall
verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions alwaysStars: 322kUpdated Claude CodeCodexVerifiedInstall