feat: 修复报错
This commit is contained in:
29
python-app/app/market/factory.py
Normal file
29
python-app/app/market/factory.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from market.config import MarketConfig
|
||||
from market.provider_base import MarketDataProvider
|
||||
from market.providers.akshare_provider import AkshareCnProvider
|
||||
from market.providers.cmes_provider import CmesCnProvider
|
||||
|
||||
|
||||
def create_provider(config: MarketConfig) -> MarketDataProvider:
|
||||
if config.channel == "cn" and config.provider == "akshare":
|
||||
return AkshareCnProvider()
|
||||
if config.channel == "cn" and config.provider == "cmesdata":
|
||||
return CmesCnProvider(token=config.cmes_token)
|
||||
if config.provider == "futu" and config.channel in {"cn", "hk", "us"}:
|
||||
from market.providers.futu_provider import FutuProvider
|
||||
|
||||
return FutuProvider(
|
||||
channel=config.channel,
|
||||
host=config.futu_host,
|
||||
port=config.futu_port,
|
||||
is_encrypt=config.futu_is_encrypt,
|
||||
market=config.futu_market,
|
||||
)
|
||||
if config.channel in {"us", "hk"}:
|
||||
raise RuntimeError(
|
||||
f"channel={config.channel} provider={config.provider} 尚未实现,"
|
||||
"请新增 Provider 后接入 factory。"
|
||||
)
|
||||
raise RuntimeError(f"不支持的通道配置: channel={config.channel}, provider={config.provider}")
|
||||
Reference in New Issue
Block a user