fix: harden Structural S/R after OHLCV writes and surface cleanup failures
Honor custom S/R tolerance as a transient detect, refresh levels after OHLCV mutations without failing committed price writes, report per-ticker S/R rebuild failures from admin cleanup, and warn in the admin UI when refresh is partial.
This commit is contained in:
@@ -19,6 +19,7 @@ from app.dependencies import get_db, require_access
|
||||
from app.exceptions import ProviderError
|
||||
from app.models.ohlcv import OHLCVRecord
|
||||
from app.models.settings import IngestionProgress
|
||||
from app.models.sr_level import SRLevel
|
||||
from app.models.ticker import Ticker
|
||||
from app.models.user import User
|
||||
from app.providers.alpaca import AlpacaOHLCVProvider
|
||||
@@ -105,8 +106,13 @@ async def fetch_symbol(
|
||||
await db.execute(
|
||||
delete(IngestionProgress).where(IngestionProgress.ticker_id == ticker_obj.id)
|
||||
)
|
||||
# Drop Structural S/R with the bars; a failed re-fetch must not
|
||||
# leave zones computed from deleted history.
|
||||
await db.execute(
|
||||
delete(SRLevel).where(SRLevel.ticker_id == ticker_obj.id)
|
||||
)
|
||||
await db.commit()
|
||||
logger.info("force_refetch: cleared OHLCV and progress for %s", symbol_upper)
|
||||
logger.info("force_refetch: cleared OHLCV, S/R, and progress for %s", symbol_upper)
|
||||
except Exception as exc:
|
||||
logger.error("force_refetch cleanup failed for %s: %s", symbol_upper, exc)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user