修复斐波做多盈亏比
This commit is contained in:
@@ -18,8 +18,9 @@ def fib_ratio_from_type(monitor_type):
|
||||
|
||||
def calc_fib_plan(direction, upper, lower, ratio):
|
||||
"""
|
||||
上沿 H、下沿 L;挂单价 E = L + ratio*(H-L)。
|
||||
多:SL=L,TP=H;空:SL=H,TP=L。
|
||||
上沿 H、下沿 L(H > L)。
|
||||
做多:自 H 向下回撤 ratio,E = H - ratio*(H-L);SL=L,TP=H。
|
||||
做空:自 L 向上反弹 ratio,E = L + ratio*(H-L);SL=H,TP=L。
|
||||
返回 (entry, stop_loss, take_profit) 或 None。
|
||||
"""
|
||||
try:
|
||||
@@ -31,10 +32,11 @@ def calc_fib_plan(direction, upper, lower, ratio):
|
||||
if h <= l or r <= 0 or r >= 1:
|
||||
return None
|
||||
span = h - l
|
||||
entry = l + r * span
|
||||
direction = (direction or "long").strip().lower()
|
||||
if direction == "short":
|
||||
entry = l + r * span
|
||||
return entry, h, l
|
||||
entry = h - r * span
|
||||
return entry, l, h
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user