TurtleTrade/data_fetcher.py

23 lines
682 B
Python
Raw Normal View History

2025-05-20 22:54:54 +08:00
import ak
class DataFetcher:
def __init__(self, config):
self.config = config
def fetch_stock_data(self):
"""Fetches stock data from Akshare."""
try:
stock_data = ak.stock_zh_a_spot(symbol=self.config.symbol)
return stock_data
except Exception as e:
print(f"Error fetching stock data: {e}")
return None
def fetch_etf_data(self):
"""Fetches ETF data from Akshare."""
try:
etf_data = ak.fund_etf_spot(symbol=self.config.symbol)
return etf_data
except Exception as e:
print(f"Error fetching ETF data: {e}")
return None