2.source基类实现 3.时间转换工具datetime convert实现 4.使用binance restapi获取数据实现 5.binance获取数据单元测试
21 lines
487 B
Python
21 lines
487 B
Python
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 |