Files
crypto_monitor/tests/test_manual_sltp_lib.py
T

33 lines
739 B
Python

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