2026-11-05 15:25:57 +08:00
|
|
|
|
"""ETF观测单进程入口,不启动交易worker或QMT连接。"""
|
|
|
|
|
|
import logging
|
|
|
|
|
|
import signal
|
|
|
|
|
|
from threading import Event
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
|
from app.services.etf_observation import consume_once
|
2026-11-06 10:38:29 +08:00
|
|
|
|
from app.services.broad_funds import consume_once as consume_daily
|
2026-11-05 15:25:57 +08:00
|
|
|
|
logging.basicConfig(level=logging.INFO)
|
|
|
|
|
|
stopping = Event()
|
|
|
|
|
|
signal.signal(signal.SIGTERM, lambda *_: stopping.set())
|
|
|
|
|
|
signal.signal(signal.SIGINT, lambda *_: stopping.set())
|
|
|
|
|
|
while not stopping.is_set():
|
|
|
|
|
|
try:
|
|
|
|
|
|
result = consume_once()
|
|
|
|
|
|
if result.get('status') == 'unavailable':
|
|
|
|
|
|
logging.warning('ETF观测暂不可用:%s', result.get('error'))
|
|
|
|
|
|
except Exception as exc:
|
|
|
|
|
|
logging.warning('ETF观测保存失败:%s', type(exc).__name__)
|
2026-11-06 10:38:29 +08:00
|
|
|
|
try:
|
|
|
|
|
|
result = consume_daily()
|
|
|
|
|
|
if result.get('status') == 'unavailable':
|
|
|
|
|
|
logging.warning('每日资金暂不可用:%s', result.get('error'))
|
|
|
|
|
|
except Exception as exc:
|
|
|
|
|
|
logging.warning('每日资金保存失败:%s', type(exc).__name__)
|
2026-11-05 15:25:57 +08:00
|
|
|
|
stopping.wait(15)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
|
main()
|