Skip to content

Fix remaining QA issues: technicals, caches, engine, screener#116

Merged
mikejamescalvert merged 1 commit intomainfrom
fix/qa-remaining-issues
Mar 27, 2026
Merged

Fix remaining QA issues: technicals, caches, engine, screener#116
mikejamescalvert merged 1 commit intomainfrom
fix/qa-remaining-issues

Conversation

@mikejamescalvert
Copy link
Copy Markdown
Owner

Summary

Addresses the remaining issues from the comprehensive QA audit (PR #115 covered the first 10).

Technical Analysis (6 fixes)

  • daily_return_pct crashIndexError when <2 bars. Now guarded.
  • Weekly trend proxy broken — Was sampling every 5th bar from the ENTIRE dataset instead of the last 60 bars. Fixed to close.iloc[-60:].iloc[::5].
  • NaN values leak downstream — All indicator outputs now filtered through math.isnan check. Prevents AI from seeing NaN in analysis.
  • Missing momentum indicators — Added ADX (trend strength) and ROC (rate of change). Critical for momentum confirmation that was missing.
  • BB width not normalized — Added bb_width_pct for cross-symbol volatility comparison.
  • Generic Exception catch — Replaced with specific types + logging for debuggability.

Data Provider Cache Fixes (4 fixes)

  • Timezone bugs in ALL cache loadersdatetime.fromisoformat() could return naive datetimes. Comparing with datetime.now(tz=UTC) would raise TypeError. Fixed in fundamentals, earnings, and crypto_market.
  • Earnings HTTP error unhandledurlopen() had no try/except around it. Now catches and logs HTTP errors.
  • Past earnings returned from live fetch — Cache loader filtered days_until < 0 but live fetch didn't. Fixed.

Strategy Engine (2 fixes)

  • Zero-price buy orders — If current_price was 0 (corrupted data), would divide by zero or create invalid orders. Now validates > 0 before using.
  • Zero-price sell limit orders — Limit price of $0.00 from corrupted position data. Now skips limit order generation when price is 0.

Broker (1 fix)

  • Crypto detection too broadendswith("USD") would misidentify stock tickers as crypto (applying wrong time-in-force). Removed; now uses only asset_class enum and / in symbol.

Screener (2 improvements)

  • VIX-adaptive thresholds — Screening thresholds now adjust to market volatility: stricter in low-vol (VIX < 15), relaxed in high-vol (VIX > 25).
  • Auto-add top picks to watchlist — Top 3 screener candidates now auto-added to TRADING_WATCHLIST for immediate trading. Previously, screener only created a GitHub issue and candidates waited days for the weekly watchlist review.

Test plan

  • All 270 tests pass
  • Ruff lint clean
  • mypy strict clean (38 source files)
  • Verify ADX/ROC appear in trading agent analysis logs
  • Verify screener auto-adds to watchlist on next run
  • Verify cache timezone fix prevents TypeError on next cycle

🤖 Generated with Claude Code

Technical analysis:
- Fix daily_return_pct crash with <2 bars (IndexError)
- Fix weekly trend proxy: was sampling entire dataset instead of last 60 bars
- Add NaN filtering on all indicator outputs (prevents downstream issues)
- Add ADX (trend strength) and ROC (momentum rate) indicators
- Add normalized BB width % for cross-symbol comparison
- Replace bare Exception catch with specific types + logging

Data providers:
- Fix timezone bugs in all 3 cache loaders (fundamentals, earnings, crypto)
  that could cause naive-vs-aware datetime TypeError
- Add HTTP error handling to earnings calendar fetch
- Filter past earnings dates from live fetch (was only filtered in cache)

Strategy engine:
- Add zero-price guard for buy orders (validates price > 0 before sizing)
- Add zero-price guard for sell limit orders
- Remove fragile `endswith("USD")` crypto detection from broker (was
  misidentifying stock symbols)

Screener:
- Add VIX-adaptive screening thresholds (low vol = stricter, high vol = relaxed)
- Auto-add top 3 screener picks to watchlist for immediate trading
  (previously screener created issue but candidates weren't tradeable
  until next watchlist review)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mikejamescalvert mikejamescalvert merged commit e8187cb into main Mar 27, 2026
3 checks passed
@mikejamescalvert mikejamescalvert deleted the fix/qa-remaining-issues branch March 27, 2026 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant