Tortoise/sidecar/sources/base.py
2026-06-23 10:37:31 +08:00

27 lines
935 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""数据源适配器公共协议。"""
from __future__ import annotations
from typing import List, Protocol
from sidecar.models import KlineBar, Snapshot
class MarketDataSource(Protocol):
"""行情数据源协议。"""
def fetch_kline(self, symbol: str, period: str, limit: int) -> List[KlineBar]:
"""
功能说明:从远端数据源获取 K 线。
参数说明symbol 为股票代码period 为周期limit 为最大条数。
返回值说明:返回统一 KlineBar 列表。
注意事项:不支持 K 线的数据源可抛出 NotImplementedError。
"""
def fetch_snapshot(self, symbol: str) -> Snapshot:
"""
功能说明:从远端数据源获取实时快照。
参数说明symbol 为股票代码。
返回值说明:返回统一 Snapshot。
注意事项:数据源字段缺失时用 None 表示。
"""