""" Service for fetching and processing SEC data """ from datetime import datetime, timedelta from typing import Dict, List, Optional import logging from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy import select, and_ import sys import os # Add parent directory to path for imports sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) from app.models.financial import Company, FinancialData, CalculatedMetrics from app.schemas.financial import ErrorType, DataSource from app.core.config import settings from app.services.real_sec_financial_service import RealSECFinancialService logger = logging.getLogger(__name__) class SECDataService: def __init__(self): self.financial_service = RealSECFinancialService() async def get_or_update_company_data( self, db: AsyncSession, ticker: str, start_date: datetime, end_date: datetime, force_refresh: bool = False ) -> Dict: """ Get company data using real financial service with price-based calculations """ # Use the real SEC financial service for actual SEC data return await self.financial_service.get_or_create_company_data( db, ticker, start_date, end_date, force_refresh )