refactor: 将共用代码迁入 lib/ 模块化目录

统一 strategy、key_monitor、trade、hub 等共用库到 lib/ 子包,并补充 lib-structure 文档,便于四所与中控维护。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-02 16:23:09 +08:00
parent 4742a0bb9d
commit 5797d49d8a
190 changed files with 27946 additions and 27499 deletions
+33 -33
View File
@@ -1,33 +1,33 @@
"""Build embed_page_fragment.html from gate index.html."""
from __future__ import annotations
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
src_lines = (ROOT / "crypto_monitor_gate" / "templates" / "index.html").read_text(
encoding="utf-8"
).splitlines()
# 1-based line numbers from index.html
macro_body = src_lines[243:262] # {% macro %} … {% endmacro %}
grid_inner = src_lines[328:736] # inside .grid (exclude outer wrapper)
stats_block = src_lines[738:772]
out_lines = [
"{# Hub iframe tab fragment — shared via embed_templates #}",
*macro_body,
'<div class="grid">',
*grid_inner,
"</div>",
*stats_block,
]
out_dir = ROOT / "embed_templates"
out_dir.mkdir(exist_ok=True)
text = "\n".join(out_lines) + "\n"
text = text.replace(
"{% include 'order_monitor_rule_tips_gate.html' %}",
"{% include order_rule_tips_tpl %}",
)
(out_dir / "embed_page_fragment.html").write_text(text, encoding="utf-8")
print("wrote", out_dir / "embed_page_fragment.html", "lines", len(out_lines))
"""Build embed_page_fragment.html from gate index.html."""
from __future__ import annotations
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
src_lines = (ROOT / "crypto_monitor_gate" / "templates" / "index.html").read_text(
encoding="utf-8"
).splitlines()
# 1-based line numbers from index.html
macro_body = src_lines[243:262] # {% macro %} … {% endmacro %}
grid_inner = src_lines[328:736] # inside .grid (exclude outer wrapper)
stats_block = src_lines[738:772]
out_lines = [
"{# Hub iframe tab fragment — shared via embed_templates #}",
*macro_body,
'<div class="grid">',
*grid_inner,
"</div>",
*stats_block,
]
out_dir = ROOT / "lib" / "instance" / "templates"
out_dir.mkdir(exist_ok=True)
text = "\n".join(out_lines) + "\n"
text = text.replace(
"{% include 'order_monitor_rule_tips_gate.html' %}",
"{% include order_rule_tips_tpl %}",
)
(out_dir / "embed_page_fragment.html").write_text(text, encoding="utf-8")
print("wrote", out_dir / "embed_page_fragment.html", "lines", len(out_lines))