止盈阈值改为A×跳点价×每日手数
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -37,6 +37,22 @@ def positions_page(request: Request, db: Session = Depends(get_db)):
|
||||
.all()
|
||||
)
|
||||
|
||||
# Compute stop-profit threshold: latest position A × point_value per round
|
||||
round_thresholds: dict[int, dict] = {}
|
||||
for r in active_rounds:
|
||||
if r.positions:
|
||||
latest_a = r.positions[-1].amp_threshold
|
||||
else:
|
||||
latest_a = 0
|
||||
contract = db.query(Contract).filter(Contract.code == r.contract_code).first()
|
||||
pv = contract.product.point_value if contract and contract.product else 20
|
||||
round_thresholds[r.id] = {
|
||||
"amp": latest_a,
|
||||
"point_value": pv,
|
||||
"daily_hands": r.daily_hands,
|
||||
"threshold": latest_a * pv * r.daily_hands,
|
||||
}
|
||||
|
||||
template = request.app.state.templates.get_template("positions.html")
|
||||
return HTMLResponse(
|
||||
template.render(
|
||||
@@ -45,6 +61,7 @@ def positions_page(request: Request, db: Session = Depends(get_db)):
|
||||
contracts=get_active_contracts(db),
|
||||
product_contracts=get_product_contracts(db),
|
||||
active_rounds=active_rounds,
|
||||
round_thresholds=round_thresholds,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -81,12 +81,14 @@
|
||||
|
||||
{# ── 止盈阈值 ── #}
|
||||
{% if round.positions %}
|
||||
{% set latest = round.positions[-1] %}
|
||||
{% set th = round_thresholds.get(round.id, {}) %}
|
||||
<div style="background:var(--accent-light);border:1px solid var(--accent);border-radius:6px;padding:10px 16px;margin-bottom:16px;display:flex;align-items:center;gap:20px;flex-wrap:wrap;">
|
||||
<span style="font-size:0.78rem;color:var(--sub);">止盈阈值</span>
|
||||
<span style="font-weight:700;">{{ round.daily_hands }} × {{ latest.amp_threshold }} = {{ round.daily_hands * latest.amp_threshold }} 点</span>
|
||||
<span style="font-weight:700;">{{ th.get('amp', 0) }} × {{ th.get('point_value', 0) }} × {{ th.get('daily_hands', 0) }} = {{ "%.0f"|format(th.get('threshold', 0)) }} 元</span>
|
||||
<span style="color:var(--sub);">|</span>
|
||||
<span style="font-size:0.78rem;color:var(--sub);">当前 A = {{ latest.amp_threshold }}</span>
|
||||
<span style="font-size:0.78rem;color:var(--sub);">当前 A = {{ th.get('amp', 0) }}</span>
|
||||
<span style="color:var(--sub);">|</span>
|
||||
<span style="font-size:0.78rem;color:var(--sub);">跳点价 {{ th.get('point_value', 0) }} 元/点</span>
|
||||
<span style="color:var(--sub);">|</span>
|
||||
<span style="font-size:0.78rem;color:var(--sub);">总手数 {{ round.daily_hands * round.positions|length }}</span>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user