Files
crypto_monitor/scripts/build_playbook_xmind.py
T
2026-07-26 10:03:24 +08:00

333 lines
15 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""Generate XMind (Zen/2020+) mind map from playbook + behavior rules."""
from __future__ import annotations
import json
import uuid
import zipfile
from pathlib import Path
OUT = Path(__file__).resolve().parents[1] / "docs" / "交易执行手册与行为准则.xmind"
def tid() -> str:
return uuid.uuid4().hex
def topic(title: str, children: list | None = None, notes: str | None = None) -> dict:
node: dict = {
"id": tid(),
"class": "topic",
"title": title,
}
if notes:
node["notes"] = {"plain": {"content": notes}}
if children:
node["children"] = {"attached": children}
return node
def build_content() -> list:
root = topic(
"交易执行体系\n(手册 v2 + 开单三检)",
[
topic(
"设计理念",
[
topic("少而精,珍惜机会,样本干净"),
topic("不保证收益;过程可控,结果随缘"),
topic("过滤比频率重要;日更不是目标"),
topic("看不懂不做;不为开单找理由"),
topic("丢掉对冲:无「有保护就能多做」幻觉"),
topic(
"工具只留期权与合约",
[
topic("OKX 期权:方向单(虚值等)"),
topic("Gate 合约:结构清楚时的波段"),
topic("同一时段尽量只让一边说话"),
],
),
topic(
"文档分工",
[
topic("行为准则:能不能动手(防火墙)"),
topic("执行手册:怎么做单(玩法/仓位/离场)"),
],
),
],
),
topic(
"资金要求",
[
topic("总资金参考:约 800U"),
topic(
"单笔期权",
[
topic("约 10U 权利金预算"),
topic("一次只持有一个期权仓位"),
topic("按可用打满 = min(余额, 单笔预算)"),
],
),
topic(
"Gate 合约",
[
topic("日内保证金约 50U、约 10 倍"),
topic("止损一般约 5U"),
topic("单笔最大亏损不超过约 10U"),
topic("有单才用保证金,无单为 0"),
],
),
topic(
"日损失心理框",
[
topic("期权+合约都错:合计大约 ≤20U"),
topic("都对:期望可到 40U+(理想,非每日目标)"),
topic("相对 800U:单笔约 1.25%;全错一天约 2.5%"),
],
),
topic(
"叠加红线",
[
topic("同日双开按合计最坏约 20U 接受"),
topic("尽量少同向双开"),
topic("不为「好像有保护」放大仓位"),
],
),
],
),
topic(
"操盘思路",
[
topic(
"行为准则(开单三检)",
[
topic(
"一句话",
[
topic("信号够不够清晰?"),
topic("流程有没有跑通?"),
topic("情绪是不是在证明自己?"),
topic("三检不过 → 不开"),
],
),
topic(
"总循环",
[
topic("信号判断 → 流程确认 → 情绪自检"),
topic("全部通过 → 开仓"),
topic("等待系统结果(止盈/止损/到期)"),
topic("复盘整环 → 等待下一信号"),
topic("任一步否决 → 空仓离开"),
],
),
topic(
"开单前三秒停顿",
[
topic("核心信号是什么?"),
topic("安全流程跑通了吗?"),
topic("冷静执行,还是怕踏空/回本/证明自己?"),
],
),
topic(
"检1·信号判断",
[
topic("通过:一句话说清唯一核心确认"),
topic("通过:点位/结构本身已够清楚"),
topic("否决:说不清、靠宏观故事自圆"),
topic("否决:「好像有戏」但确认模糊"),
topic("对照主链条:1H→空间→结构→定损盈→工具"),
],
),
topic(
"检2·流程确认",
[
topic("通过:资金与当日额度符合"),
topic("通过:单笔/组合敞口在预算内"),
topic("否决:资金或次数已触限"),
topic("否决:单笔或日最坏超限 → 暂停"),
topic("否决:「先开了再说」跳步"),
],
),
topic(
"检3·情绪自检",
[
topic("通过:符合系统 + 账户没问题 → 开"),
topic("通过:可接受空仓,旁观者视角"),
topic("否决:怕踏空"),
topic("否决:上回亏了要回本"),
topic("否决:必须证明我是对的"),
topic("红灯亮了,信号再好看也不开"),
],
),
topic(
"复盘只记什么",
[
topic("信号:是否做了?核心写了什么?"),
topic("流程:资金/敞口是否过关?有无跳步?"),
topic("情绪:当时是哪一类心态?"),
topic("结果不推翻「三检是否完成」评分"),
],
),
],
),
topic(
"开仓逻辑",
[
topic(
"主链条(强制)",
[
topic("1H 方向:明显 N 字;跟 1H 波段"),
topic("空间:空看支撑、多看阻力;至少约 ≥2%"),
topic("结构:15m/5m;量级约 8h+(约 48×15m"),
topic("定损盈:外沿/针尖;RR 须接受"),
topic("选工具:期权 或 合约(不对冲)"),
topic("任一步不过 → 空仓等待"),
],
),
topic(
"结构形态参考",
[
topic("收敛"),
topic("两段式回调"),
topic("箱体"),
topic("假突破"),
],
),
topic(
"期权入场",
[
topic("主链条全过;结构突破/假突破成立"),
topic("一天期方向单;空间够优先虚值"),
topic("默认先只开期权,不上合约"),
topic("尽量下午 4 点后开次日到期(完整会话)"),
topic("不做:期期对冲、偏置壳、为开而开"),
],
),
topic(
"合约入场(Gate",
[
topic("主链条过关;位置极明确"),
topic("想清进场:假突破 / 结构突破"),
topic("止损挂模型位(外沿/针尖)"),
topic("独立假突破:只做合约或空仓"),
topic("勿与「突破期权后再加仓」混仓"),
],
),
],
),
topic(
"平仓逻辑",
[
topic(
"期权离场",
[
topic("只认:系统/规则止盈"),
topic("只认:到期"),
topic("开仓后中间不手动平仓"),
topic("紧急手平 → 标记非策略样本"),
],
),
topic(
"合约离场",
[
topic("结构止盈为准"),
topic("结构止损为准(约 5U 量级)"),
topic("等待系统/挂单结果,不情绪手平"),
],
),
topic(
"开仓后盯什么",
[
topic("程序与纪律是否正常"),
topic("不是浮盈浮亏数字本身"),
topic("无信号空档:空跑三检也是训练"),
],
),
],
),
],
),
topic(
"纪律执行",
[
topic(
"Gate 日纪律",
[
topic("只做很明确的位置"),
topic("同一位置最多两次机会(突破/假突破)"),
topic("两次都错 → 当日不再做单"),
topic("离场以结构止盈/止损为准"),
],
),
topic(
"期权日纪律",
[
topic("不手平;等规则止盈或到期"),
topic("一次一仓;约 10U 权利金"),
topic("不对冲;不做每天默认开期权"),
topic("损位跟模型:外沿/针尖"),
],
),
topic(
"开仓前自检清单",
[
topic("今日只动期权/合约?未开对冲?"),
topic("1H 方向清楚(含 N 字)?"),
topic("空间足够?"),
topic("结构出现且量级够?"),
topic("止损/止盈与 RR 定好?"),
topic("工具选期权还是合约?理由写清?"),
topic("期权:止盈与接受到期写清?"),
topic("合约:本位置第几次?今日两次用完?"),
],
),
topic(
"一句话版本",
[
topic("1H→空间→结构→定损盈→期权/合约"),
topic("不对冲;期权不手平"),
topic("一位置两次,错完收工"),
topic("珍惜机会,日更不是目标"),
],
),
],
),
],
)
root["structureClass"] = "org.xmind.ui.logic.right"
sheet = {
"id": tid(),
"class": "sheet",
"title": "执行手册与行为准则",
"rootTopic": root,
}
return [sheet]
def main() -> None:
content = build_content()
metadata = {
"creator": {"name": "crypto_monitor", "version": "1.0"},
"activeSheetId": content[0]["id"],
}
manifest = {
"file-entries": {
"content.json": {},
"metadata.json": {},
"manifest.json": {},
}
}
OUT.parent.mkdir(parents=True, exist_ok=True)
if OUT.exists():
OUT.unlink()
with zipfile.ZipFile(OUT, "w", compression=zipfile.ZIP_DEFLATED) as zf:
zf.writestr("content.json", json.dumps(content, ensure_ascii=False, indent=2))
zf.writestr("metadata.json", json.dumps(metadata, ensure_ascii=False, indent=2))
zf.writestr("manifest.json", json.dumps(manifest, ensure_ascii=False, indent=2))
print(f"wrote {OUT}")
if __name__ == "__main__":
main()