You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
2.1 KiB
86 lines
2.1 KiB
|
2 months ago
|
from abc import ABC, abstractmethod
|
||
|
|
from typing import List, Optional
|
||
|
|
from models import (
|
||
|
|
MarketOverview,
|
||
|
|
MarketIndex,
|
||
|
|
SentimentData,
|
||
|
|
MomentumData,
|
||
|
|
HighLowStock,
|
||
|
|
PriceDistribution,
|
||
|
|
AIAnalysis,
|
||
|
|
KLineData,
|
||
|
|
NewsItem,
|
||
|
|
HotNews,
|
||
|
|
SentimentTrend,
|
||
|
|
Stock,
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
class BaseDataAdapter(ABC):
|
||
|
|
def __init__(self, name: str, base_url: str):
|
||
|
|
self.name = name
|
||
|
|
self.base_url = base_url
|
||
|
|
|
||
|
|
@abstractmethod
|
||
|
|
async def fetch_market_overview(self) -> MarketOverview:
|
||
|
|
pass
|
||
|
|
|
||
|
|
@abstractmethod
|
||
|
|
async def fetch_market_indices(self) -> List[MarketIndex]:
|
||
|
|
pass
|
||
|
|
|
||
|
|
@abstractmethod
|
||
|
|
async def fetch_sentiment(self) -> SentimentData:
|
||
|
|
pass
|
||
|
|
|
||
|
|
@abstractmethod
|
||
|
|
async def fetch_sentiment_trend(self, days: int = 15) -> List[SentimentTrend]:
|
||
|
|
pass
|
||
|
|
|
||
|
|
@abstractmethod
|
||
|
|
async def fetch_momentum_data(self) -> List[MomentumData]:
|
||
|
|
pass
|
||
|
|
|
||
|
|
@abstractmethod
|
||
|
|
async def fetch_high_stocks(self, limit: int = 10) -> List[HighLowStock]:
|
||
|
|
pass
|
||
|
|
|
||
|
|
@abstractmethod
|
||
|
|
async def fetch_low_stocks(self, limit: int = 10) -> List[HighLowStock]:
|
||
|
|
pass
|
||
|
|
|
||
|
|
@abstractmethod
|
||
|
|
async def fetch_price_distribution(self) -> List[PriceDistribution]:
|
||
|
|
pass
|
||
|
|
|
||
|
|
@abstractmethod
|
||
|
|
async def fetch_stock_detail(self, code: str) -> Optional[Stock]:
|
||
|
|
pass
|
||
|
|
|
||
|
|
@abstractmethod
|
||
|
|
async def fetch_kline_data(self, code: str, days: int = 30) -> List[KLineData]:
|
||
|
|
pass
|
||
|
|
|
||
|
|
@abstractmethod
|
||
|
|
async def fetch_ai_analysis(self, code: str) -> AIAnalysis:
|
||
|
|
pass
|
||
|
|
|
||
|
|
@abstractmethod
|
||
|
|
async def fetch_news(self, limit: int = 10) -> List[NewsItem]:
|
||
|
|
pass
|
||
|
|
|
||
|
|
@abstractmethod
|
||
|
|
async def fetch_hot_news(self, limit: int = 10) -> List[HotNews]:
|
||
|
|
pass
|
||
|
|
|
||
|
|
@abstractmethod
|
||
|
|
async def fetch_hot_stocks(self, limit: int = 10) -> List[Stock]:
|
||
|
|
pass
|
||
|
|
|
||
|
|
@abstractmethod
|
||
|
|
async def fetch_cold_stocks(self, limit: int = 10) -> List[Stock]:
|
||
|
|
pass
|
||
|
|
|
||
|
|
@abstractmethod
|
||
|
|
async def is_available(self) -> bool:
|
||
|
|
pass
|