fix bug
This commit is contained in:
@@ -14,6 +14,7 @@ import config
|
||||
from libs.calc import trading_time
|
||||
from libs.market import market_allow_open
|
||||
from libs.signal import init_signals, SignalItem
|
||||
from libs.dataset import dataset_push
|
||||
from sdk import Client
|
||||
from libs.grid_take_profit import GridTrailingTracker
|
||||
from .state import State
|
||||
@@ -79,7 +80,7 @@ def StartTrend() -> None:
|
||||
open_watch=DipWatch(),
|
||||
add_watch=DipWatch(),
|
||||
profit_tracker=GridTrailingTracker(config.account_config.grid_step_pct),
|
||||
executor=ThreadPoolExecutor(max_workers=2, thread_name_prefix="trend"),
|
||||
executor=ThreadPoolExecutor(max_workers=3, thread_name_prefix="trend"),
|
||||
)
|
||||
|
||||
Overview(assets, positions, config.account_config)
|
||||
@@ -126,6 +127,17 @@ def RunOnce(run: Runtime, signals:list[SignalItem]) -> None:
|
||||
log.exception("[Portfolio] 刷新账户快照失败")
|
||||
return
|
||||
|
||||
futures: list[tuple[str, Future]] = [
|
||||
(
|
||||
"数据提交",
|
||||
run.executor.submit(
|
||||
dataset_push,
|
||||
assets,
|
||||
positions,
|
||||
),
|
||||
)
|
||||
]
|
||||
|
||||
# 2. 验证可用资金;低于资金安全线时禁止开新仓。
|
||||
allow_open_by_cash = assets.available >= assets.total * run.account_cfg.min_cash_ratio
|
||||
if not allow_open_by_cash:
|
||||
@@ -164,19 +176,7 @@ def RunOnce(run: Runtime, signals:list[SignalItem]) -> None:
|
||||
|
||||
# 启动线程,开始计算
|
||||
# 7. 持仓计算。
|
||||
futures: list[tuple[str, Future]] = [
|
||||
(
|
||||
"持仓计算",
|
||||
run.executor.submit(
|
||||
manage_positions,
|
||||
run,
|
||||
ticks,
|
||||
positions,
|
||||
market_ok,
|
||||
assets.available,
|
||||
),
|
||||
)
|
||||
]
|
||||
futures.append(("持仓计算",run.executor.submit(manage_positions,run,ticks,positions,market_ok,assets.available)))
|
||||
|
||||
# 8. 开仓计算:必须同时存在有效信号且大盘允许开仓。
|
||||
if allow_open and market_ok and allow_open_by_cash:
|
||||
|
||||
Reference in New Issue
Block a user