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
+32 -32
View File
@@ -1,32 +1,32 @@
from manual_sltp_lib import (
MANUAL_FIXED_RR_DEFAULT,
calc_tp_from_fixed_rr,
parse_fixed_rr,
resolve_open_sltp_prices,
)
def test_calc_tp_from_fixed_rr_long():
tp = calc_tp_from_fixed_rr("long", 100.0, 95.0, 1.5)
assert tp == 107.5
def test_calc_tp_from_fixed_rr_short():
tp = calc_tp_from_fixed_rr("short", 100.0, 105.0, 1.5)
assert tp == 92.5
def test_resolve_open_fixed_rr_mode():
sl, tp = resolve_open_sltp_prices(
"long",
100.0,
"fixed_rr",
{"sl": "95", "fixed_rr": "1.5"},
)
assert sl == 95.0
assert tp == 107.5
def test_parse_fixed_rr_default():
assert parse_fixed_rr(None) == MANUAL_FIXED_RR_DEFAULT
assert parse_fixed_rr("2") == 2.0
from lib.trade.manual_sltp_lib import (
MANUAL_FIXED_RR_DEFAULT,
calc_tp_from_fixed_rr,
parse_fixed_rr,
resolve_open_sltp_prices,
)
def test_calc_tp_from_fixed_rr_long():
tp = calc_tp_from_fixed_rr("long", 100.0, 95.0, 1.5)
assert tp == 107.5
def test_calc_tp_from_fixed_rr_short():
tp = calc_tp_from_fixed_rr("short", 100.0, 105.0, 1.5)
assert tp == 92.5
def test_resolve_open_fixed_rr_mode():
sl, tp = resolve_open_sltp_prices(
"long",
100.0,
"fixed_rr",
{"sl": "95", "fixed_rr": "1.5"},
)
assert sl == 95.0
assert tp == 107.5
def test_parse_fixed_rr_default():
assert parse_fixed_rr(None) == MANUAL_FIXED_RR_DEFAULT
assert parse_fixed_rr("2") == 2.0