2025-12-05 17:13:20 +08:00
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
|
import pandas as pd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DataSource(ABC):
|
|
|
|
|
"""数据源基类"""
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def try_connection(self):
|
|
|
|
|
"""尝试连接行情"""
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def get_historical_data(self, symbol: str, start_date: str, end_date: str, interval: str = "1d") :
|
|
|
|
|
"""获取历史数据"""
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def get_realtime_data(self, symbol: str) :
|
|
|
|
|
"""获取实时数据"""
|
|
|
|
|
pass
|