You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
"""
|
|
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
|
|
)
|