41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
import os
|
|
from dataclasses import dataclass
|
|
|
|
|
|
@dataclass
|
|
class MarketConfig:
|
|
channel: str
|
|
provider: str
|
|
cmes_token: str
|
|
futu_host: str
|
|
futu_port: int
|
|
futu_is_encrypt: bool | None
|
|
futu_market: str
|
|
|
|
|
|
def load_market_config() -> MarketConfig:
|
|
channel = os.getenv("MARKET_CHANNEL", "cn").strip().lower()
|
|
provider = os.getenv("MARKET_PROVIDER", "akshare").strip().lower()
|
|
cmes_token = os.getenv("CMES_TOKEN", "").strip()
|
|
futu_host = os.getenv("FUTU_HOST", "127.0.0.1").strip()
|
|
futu_port = int(os.getenv("FUTU_PORT", "11111").strip())
|
|
futu_encrypt_raw = os.getenv("FUTU_IS_ENCRYPT", "").strip().lower()
|
|
if futu_encrypt_raw in {"1", "true", "yes", "y"}:
|
|
futu_is_encrypt = True
|
|
elif futu_encrypt_raw in {"0", "false", "no", "n"}:
|
|
futu_is_encrypt = False
|
|
else:
|
|
futu_is_encrypt = None
|
|
futu_market = os.getenv("FUTU_MARKET", "").strip().lower()
|
|
return MarketConfig(
|
|
channel=channel,
|
|
provider=provider,
|
|
cmes_token=cmes_token,
|
|
futu_host=futu_host,
|
|
futu_port=futu_port,
|
|
futu_is_encrypt=futu_is_encrypt,
|
|
futu_market=futu_market,
|
|
)
|