搭建期货量化管理后台 MVP,支持行情查看、博弈分析、持仓录入、品种合约管理

This commit is contained in:
2026-07-24 21:38:40 +08:00
parent d06ed06f01
commit 1ff2aa17e8
22 changed files with 1486 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
"""振幅锁仓策略计算引擎"""
def compute_amp_5d(diffs: list[float]) -> float:
"""近5日均振幅 = round(mean of 5 diffs)"""
if len(diffs) < 5:
return 0.0
return round(sum(diffs[-5:]) / 5)
def check_stop_profit(
active_profits: list[float],
locked_losses: list[float],
daily_hands: int,
amp_threshold: float,
) -> bool:
"""止盈条件: total_floating_profit >= N * A"""
total = sum(active_profits) + sum(locked_losses)
return total >= daily_hands * amp_threshold
def check_lock(
open_price: float,
current_price: float,
lock_threshold: float,
) -> bool:
"""锁仓条件: 空单亏损 >= 开仓时的振幅阈值"""
return (current_price - open_price) >= lock_threshold
def should_meltdown(lock_count: int) -> bool:
"""3锁熔断"""
return lock_count >= 3