fix: show archive chart times in UTC+8 and parse Beijing wall clock

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-08 16:47:09 +08:00
parent 947b58084d
commit 55a979eee5
5 changed files with 103 additions and 32 deletions
+16
View File
@@ -6,10 +6,16 @@ import tempfile
from pathlib import Path
from hub_ohlcv_lib import aggregate_ohlcv_bars
from datetime import datetime, timezone
from zoneinfo import ZoneInfo
from hub_symbol_archive_lib import (
CHART_DISPLAY_TZ,
_fill_missing_bars,
init_db,
load_symbol_trades,
ms_to_wall_clock_str,
parse_wall_clock_ms,
resolve_archive_chart,
upsert_bars_5m,
upsert_trade_overlay,
@@ -200,3 +206,13 @@ def test_list_with_overlay_filters():
assert len(sick_only) == 1
profit_only = list_symbol_rows(filter_profit=True, db_path=db)
assert len(profit_only) == 1
def test_parse_wall_clock_ms_uses_utc_plus_8():
ms = parse_wall_clock_ms("2026-06-07 20:30:00")
assert ms is not None
dt_utc = datetime.fromtimestamp(ms / 1000.0, tz=timezone.utc)
dt_bj = dt_utc.astimezone(CHART_DISPLAY_TZ)
assert dt_bj.strftime("%Y-%m-%d %H:%M:%S") == "2026-06-07 20:30:00"
assert ms_to_wall_clock_str(ms) == "2026-06-07 20:30:00"
assert parse_wall_clock_ms("2026-06-07 20:30") == ms