Files
crypto_monitor_user/tests/test_manual_sltp_lib.py
dekun 53863559f4 Initialize crypto_monitor_user (user edition) from monitor codebase.
Retarget git remote, install path, and deploy docs from crypto_monitor to crypto_monitor_user.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-17 16:18:13 +08:00

33 lines
781 B
Python

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