Files
Chan/web/services/runtime/__init__.py
T
jackyu66gitandCursor c22cd48f36 Web 加上资金面/情绪叠图,并收紧默认图面。
默认主/次/次次改为 45m/15m/5m、开始时间一周;SD/CD 按 hist 摆位置和箭头;去掉笔线段背驰与第四类勾选。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-12 02:25:44 +08:00

100 lines
2.6 KiB
Python

"""runtime 门面:保持 `from services.runtime import *` 与 `import services.runtime as R` 兼容。"""
from __future__ import annotations
# ---- 历史兼容:旧 monolith 上 `from pytz import timezone` 等会随 import * 漏出 ----
import json # noqa: F401
import logging
import sys as _sys
import time # noqa: F401
from collections import OrderedDict # noqa: F401
from concurrent.futures import ThreadPoolExecutor, as_completed # noqa: F401
import numpy as np # noqa: F401
from pytz import timezone # noqa: F401
from chanlun.analysis.ChanZone import ( # noqa: F401
StructureZoneConfig,
analyze_structure_zones_from_serialized,
)
logger = logging.getLogger("services.runtime")
from .state import ( # noqa: F401
TRADE_POINT_TYPE,
macd_fast_period,
macd_slow_period,
macd_signal_period,
exchange,
china_stock,
_zone_cache,
DEFAULT_TIMEFRAME_LABELS,
DEFAULT_SYMBOLS,
TIMEFRAMES,
SYMBOLS,
DATA_SERVICE_AVAILABLE,
SERVICE_METADATA_LAST_REFRESH,
)
from .timeframes import ( # noqa: F401
_zone_cache_ttl,
timeframe_to_minutes,
format_timeframe_label,
build_timeframe_labels,
compute_timeframe_defaults,
is_smaller_timeframe,
is_smaller_or_equal_timeframe,
)
from .market_data import ( # noqa: F401
_parse_time_input,
refresh_data_service_metadata,
_fetch_kl_from_datasvc,
A_STOCK_SYMBOLS,
detect_symbol_type,
get_kl_data,
_get_crypto_kl_data_via_ccxt,
get_crypto_kl_data,
get_a_stock_kl_data,
load_crypto_symbols,
fetch_derivatives,
fetch_sentiment_metrics,
fetch_sentiment_latest,
)
from .indicators import ( # noqa: F401
add_indicators,
calculate_macd,
)
from .analyze import ( # noqa: F401
analyze_chan,
classify_trend_stage,
)
from .serialize import ( # noqa: F401
convert_direction,
format_time_safely,
serialize_chan_macd_data,
serialize_fast_bsp_list,
clean_dataframe_for_json,
get_uncompleted_seg_list,
)
# 预取元信息(与拆分前模块加载行为一致)
refresh_data_service_metadata(force=True)
# 标量在 import 时会拷贝;刷新后写回本模块,供 `from services.runtime import *` 读到最新值
from . import state as _state
_mod = _sys.modules[__name__]
_mod.DATA_SERVICE_AVAILABLE = _state.DATA_SERVICE_AVAILABLE
_mod.SERVICE_METADATA_LAST_REFRESH = _state.SERVICE_METADATA_LAST_REFRESH
_mod.macd_fast_period = _state.macd_fast_period
_mod.macd_slow_period = _state.macd_slow_period
_mod.macd_signal_period = _state.macd_signal_period
def __getattr__(name: str):
if hasattr(_state, name):
return getattr(_state, name)
raise AttributeError(name)
def __dir__():
return sorted(set(globals()) | set(dir(_state)))