行情区图表:成交量、十字线 OHLCV、可视高低点、日线满 500 根
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -40,6 +40,7 @@ def last_closed_bar_open_ms(timeframe: str, now_ms: int | None = None) -> int:
|
||||
|
||||
|
||||
def window_start_ms(timeframe: str, need: int, retention_days: int, now_ms: int | None = None) -> int:
|
||||
"""本地库清理/读库窗口:不超过 retention_days。"""
|
||||
now = int(now_ms if now_ms is not None else time.time() * 1000)
|
||||
period = TIMEFRAME_MS[normalize_chart_timeframe(timeframe)]
|
||||
retention_cutoff = now - max(1, int(retention_days)) * 86400000
|
||||
@@ -47,6 +48,13 @@ def window_start_ms(timeframe: str, need: int, retention_days: int, now_ms: int
|
||||
return max(retention_cutoff, want)
|
||||
|
||||
|
||||
def chart_fetch_start_ms(timeframe: str, need: int, now_ms: int | None = None) -> int:
|
||||
"""行情展示拉取起点:按 need 根回看(日线 500 / 日内 1000),不受 DB 保留天数限制。"""
|
||||
now = int(now_ms if now_ms is not None else time.time() * 1000)
|
||||
period = TIMEFRAME_MS[normalize_chart_timeframe(timeframe)]
|
||||
return max(0, now - max(1, int(need)) * period)
|
||||
|
||||
|
||||
def price_tick_from_market(exchange, exchange_symbol: str) -> Optional[float]:
|
||||
try:
|
||||
markets = getattr(exchange, "markets", None) or {}
|
||||
|
||||
Reference in New Issue
Block a user