FA3-Datafetch/backend/app/fetchers/base.py
2026-01-11 21:33:47 +08:00

42 lines
1.1 KiB
Python

"""
Base Fetcher class
"""
from abc import ABC, abstractmethod
import pandas as pd
class DataFetcher(ABC):
def __init__(self, api_key: str):
self.api_key = api_key
@abstractmethod
def get_income_statement(self, symbol: str) -> pd.DataFrame:
pass
@abstractmethod
def get_balance_sheet(self, symbol: str) -> pd.DataFrame:
pass
@abstractmethod
def get_cash_flow(self, symbol: str) -> pd.DataFrame:
pass
@abstractmethod
def get_market_metrics(self, symbol: str) -> dict:
pass
def get_historical_metrics(self, symbol: str, dates: list) -> pd.DataFrame:
"""Optional method, not all fetchers need to implement"""
return pd.DataFrame()
def get_dividends(self, symbol: str) -> pd.DataFrame:
"""Optional method"""
return pd.DataFrame()
def get_repurchases(self, symbol: str) -> pd.DataFrame:
"""Optional method"""
return pd.DataFrame()
def get_employee_count(self, symbol: str) -> pd.DataFrame:
"""Optional method"""
return pd.DataFrame()