更新bot前端显示
This commit is contained in:
@@ -67,6 +67,17 @@ def resolve_path(path_value):
|
||||
app = Flask(__name__)
|
||||
app.secret_key = os.getenv("FLASK_SECRET_KEY", "crypto_monitor_2026_secret_key")
|
||||
|
||||
|
||||
def trend_add_zone_label(direction):
|
||||
"""趋势回调:做多=补仓上沿,做空=补仓下沿(库字段仍为 add_upper)。"""
|
||||
return "补仓上沿" if (direction or "long").strip().lower() == "long" else "补仓下沿"
|
||||
|
||||
|
||||
@app.context_processor
|
||||
def _inject_trend_ui_helpers():
|
||||
return {"trend_add_zone_label": trend_add_zone_label}
|
||||
|
||||
|
||||
# ====================== 登录配置 ======================
|
||||
USERNAME = os.getenv("APP_USERNAME", "dekun")
|
||||
PASSWORD = os.getenv("APP_PASSWORD", "Woaini88@")
|
||||
@@ -2648,7 +2659,7 @@ def parse_and_compute_trend_pullback_plan(form_dict):
|
||||
return None, "做多:止损价须低于补仓上沿"
|
||||
else:
|
||||
if not (stop_loss > add_upper):
|
||||
return None, "做空:止损价须高于补仓上沿"
|
||||
return None, "做空:止损价须高于补仓下沿"
|
||||
snap = get_available_trading_usdt()
|
||||
if snap is None or snap <= 0:
|
||||
return None, "无法读取合约账户 USDT 可用余额,请检查 API 与账户类型"
|
||||
@@ -2658,7 +2669,7 @@ def parse_and_compute_trend_pullback_plan(form_dict):
|
||||
exchange_symbol = normalize_exchange_symbol(symbol)
|
||||
rf = calc_risk_fraction(direction, add_upper, stop_loss)
|
||||
if rf is None or rf <= 0:
|
||||
return None, "止损与补仓上沿组合无法计算风险比例"
|
||||
return None, "止损与补仓区间边界组合无法计算风险比例"
|
||||
risk_budget = float(snap) * (risk_percent / 100.0)
|
||||
notional = risk_budget / rf
|
||||
margin_plan = notional / float(leverage)
|
||||
@@ -2679,7 +2690,7 @@ def parse_and_compute_trend_pullback_plan(form_dict):
|
||||
remainder_total = 0.0
|
||||
n_legs, leg_json, per_ref = _trend_build_leg_amounts_json(exchange_symbol, remainder_total, TREND_PULLBACK_DCA_LEGS)
|
||||
if n_legs <= 0:
|
||||
return None, "剩余计划张数不足以拆出补仓档(低于交易所最小张数),请提高风险比例、放宽止损与补仓上沿间距,或减少补仓档数"
|
||||
return None, "剩余计划张数不足以拆出补仓档(低于交易所最小张数),请提高风险比例、放宽止损与补仓区间间距,或减少补仓档数"
|
||||
grid = _trend_build_grid_prices(direction, stop_loss, add_upper, n_legs)
|
||||
if len(grid) != n_legs:
|
||||
return None, "补仓网格生成失败"
|
||||
@@ -4067,7 +4078,7 @@ def breakout_too_far(p, edge_price, limit_pct):
|
||||
|
||||
|
||||
def _trend_build_grid_prices(direction, sl, upper, n_legs):
|
||||
"""在 (止损, 补仓上沿) 开区间内生成 n_legs 个补仓触发价(不含端点)。"""
|
||||
"""在 (止损, 补仓区间远侧边界 add_upper) 开区间内生成 n_legs 个补仓触发价(不含端点)。"""
|
||||
sl, upper = float(sl), float(upper)
|
||||
out = []
|
||||
if n_legs <= 0:
|
||||
|
||||
Reference in New Issue
Block a user