2dadd93d91
Co-authored-by: Cursor <cursoragent@cursor.com>
19 lines
550 B
Python
19 lines
550 B
Python
"""交易结果展示与入库时的语义归一化。"""
|
|
|
|
|
|
def normalize_result_with_pnl(result, pnl_amount):
|
|
"""
|
|
非手动平仓且实际盈利时,不应记为「止损」。
|
|
程序触发的止损类平仓若盈亏为正,归类为「移动止盈」。
|
|
"""
|
|
res = (result or "").strip()
|
|
if res == "手动平仓":
|
|
return res
|
|
if res == "止损":
|
|
try:
|
|
if float(pnl_amount or 0) > 0:
|
|
return "移动止盈"
|
|
except (TypeError, ValueError):
|
|
pass
|
|
return res
|