UI: centered nav title, settings tabs, running status, manual buttons.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -40,6 +40,11 @@ class StrategyEngine:
|
||||
rest_left = 0
|
||||
if rest_until:
|
||||
rest_left = max(0, int((int(rest_until) - time.time() * 1000) / 1000))
|
||||
last_error = row["last_error"]
|
||||
# 清掉已修复的旧序列化错误残留
|
||||
if last_error and "PriceResult" in str(last_error) and "__dict__" in str(last_error):
|
||||
self._set_state(last_error=None)
|
||||
last_error = None
|
||||
return {
|
||||
"running": bool(row["running"]),
|
||||
"phase": row["phase"],
|
||||
@@ -51,7 +56,7 @@ class StrategyEngine:
|
||||
"rest_seconds": rest_sec,
|
||||
"exit_move_points": exit_pts,
|
||||
"can_open": can_open_new(open_hhmm=s.open_hhmm, stop_hhmm=s.stop_open_hhmm),
|
||||
"last_error": row["last_error"],
|
||||
"last_error": last_error,
|
||||
"position": upl,
|
||||
"ledger": self.ledger.snapshot(),
|
||||
}
|
||||
@@ -67,16 +72,16 @@ class StrategyEngine:
|
||||
sql = f"UPDATE strategy_state SET {', '.join(cols)} WHERE id=1"
|
||||
self.db.execute(sql, tuple(vals))
|
||||
|
||||
async def pause(self) -> dict[str, Any]:
|
||||
self._set_state(running=0, phase="paused", last_error=None)
|
||||
return self.state()
|
||||
|
||||
async def start(self) -> dict[str, Any]:
|
||||
self._set_state(running=1, last_error=None, phase="idle")
|
||||
if self._task is None or self._task.done():
|
||||
self._task = asyncio.create_task(self._loop(), name="strategy-engine")
|
||||
return self.state()
|
||||
|
||||
async def pause(self) -> dict[str, Any]:
|
||||
self._set_state(running=0, phase="paused")
|
||||
return self.state()
|
||||
|
||||
async def emergency_close(self) -> dict[str, Any]:
|
||||
async with self._lock:
|
||||
r = self.matcher.close_group(reason="emergency")
|
||||
|
||||
Reference in New Issue
Block a user