Commit Graph
47 Commits
Author SHA1 Message Date
RichardandClaude Fable 5 a1fcb4ace5 API audit: expose 7d/24h windows, remove broken repair-db, add API docs
- TraderDetailDto now exposes PnL7d/WinRate7d/PnL24h/WinRate24h and
  CurrentBalance — the engine has computed these all along but the API
  never delivered them.
- Removed POST /api/dev/repair-db: its raw SQL referenced non-existent
  columns/tables (Trades.Type/Payout, Traders.LastPositionsUpdatedAt,
  table "Jobs") and would have deleted ALL TraderPositions including
  pruned-history conserves. The supported repair path is the WinForms
  "Recalculate All Traders" action.
- Swagger tags for Jobs and Dev groups; full endpoint reference in
  docs/API.md (kept generic — external consumers like PolyTrader adapt
  to our API, not vice versa).
- FIXPLAN Teil E: master-selection gap analysis as generic extensions
  (profile endpoint, out-of-sample window metrics, price-band profile
  with per-band win rate, stop-loss ratio, copyability aggregates with
  category fees, correlation endpoint, martingale trait).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-12 18:34:02 +02:00
RichardandClaude Fable 5 28e112f128 Add per-market win/loss return metrics (D2c) to FIXPLAN Teil D
Win rate alone hides the payoff profile: an arb grinder (95% wins at +2%)
and a longshot holder (25% wins at +400%) need entirely different copy
strategies. D2c adds median+avg return of won AND lost closed markets,
profit factor, UI cards, and two derived traits (thin_margin_wins,
high_payoff_wins). Median leads (outlier-robust), the loss side is
mandatory — high win rates with rare total losses (resolution farming)
are exactly what the win rate alone obscures.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-12 10:30:28 +02:00
RichardandClaude Fable 5 916c3e17a6 Add trait filter spec and possible_insider detection to FIXPLAN Teil D
- Trait filtering is now a binding requirement: trait query parameter on
  GET /api/traders (EXISTS-based), GET /api/traits with counts, dropdown
  plus clickable chips in the UI.
- New trait possible_insider (D2b): detection via market-surprise
  likelihood under market prices (won longshots count, won favorites do
  not), with base filters (rare, large stakes, resolution farmers
  excluded) and a v2 roadmap (buys-before-news timing, one-shot wallets,
  topic concentration, urgency/slippage, niche markets).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-11 14:52:39 +02:00
RichardandClaude Fable 5 d2f3ec2bd0 Fix category mapping and TotalTrades drift, plan traits/tiering (Teil D)
- MarketCategoryMapper: classify from question text (the Gamma /markets
  endpoint delivers neither category nor event tags, so on-demand markets
  had no signal at all), match short tokens on word boundaries ("eth" no
  longer hits inside "whether", "pop" not inside "popular"), widen the
  keyword lists across all categories.
- UpdateMarketFields: never overwrite a tag-derived category with an
  uninformative "Other" from the on-demand path.
- PositionPnLEngine: sync Trader.TotalTrades to the actual replayed row
  count — the worker-side increment counters drift (INSERT IGNORE,
  deletions, historic imports) and produced Trades30d > TotalTrades.
- Tests: 14 new (mapper classification + word-boundary regression,
  TotalTrades sync + Trades30d invariant, category update guard via
  SQLite) — suite now 32 green + 1 skip.
- FIXPLAN Teil D for the larger rebuilds (AggregatedCount column,
  TraderTraits heuristics, IngestMode tiering for ultra-HF traders).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-11 14:09:12 +02:00
RichardandClaude Fable 5 940a99fec2 Retry analytics on concurrent-modification conflicts instead of erroring
The reconciliation worker resets position checkpoints via bulk UPDATE while
the analytics worker saves recalculated positions for the same trader —
MySQL then rejects the stale save ("Record has changed since last read").
The engine run is now retried once with a fresh context (re-reading the
concurrent change); if it still collides, it logs a warning and lets the
next cycle pick the trader up again (LastAnalyzedAt stays unset).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-10 18:48:51 +02:00
RichardandClaude Fable 5 850c47a404 Fix embedded-server endpoint drift, add Recalculate All Traders button
- Shared ApiConfiguration.MapPredictalyticsEndpoints() used by both the
  standalone API and the embedded WinForms Kestrel server: the embedded
  host was missing /api/watchlist and /api/dev (empty watchlist page),
  the standalone host was missing /api/search.
- New Development menu action "Recalculate All Traders": backfills
  ResolutionOutcome from snapped outcome prices, wipes derived analytics
  (snapshots, category stats, rebuildable positions), zeroes aggregates
  and marks every trader for re-analysis. Raw trades untouched.
- Static files now served with Cache-Control: no-cache in both hosts,
  plus ?v= cache-buster on app.js/style.css (stale browser JS masked
  earlier UI fixes).
- Watchlist hardened: endpoint null-safe, real Analytics.CopytradingScore,
  Platform field; repository includes Trader.Analytics; page shows a
  visible error row instead of staying silently blank.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-10 17:58:10 +02:00
Richard 1787422243 Fix: Implement FixPlan part A9, A10, B 2026-07-10 12:04:27 +02:00
Richard 44f48284a2 Fix 10 critical bugs in Engine, Retention, Reconciliation and API 2026-07-09 19:37:02 +02:00
Richard 21da1e867f Add Fable's Stufe A invariant tests 2026-07-09 18:42:31 +02:00
Richard 7964194e9e Implement WinRate, Bankroll, Positions UI and add Trades30d to Analytics 2026-07-09 12:44:32 +02:00
Richard 3b11b71188 Add EF migration for CopytradingScores 2026-07-08 20:40:48 +02:00
Richard 651f8f3ad1 Add Analyze Backlog button to WebUI 2026-07-08 20:18:03 +02:00
Richard a4acd23a60 Fix worker pagination, apply Analytics fixes, add analyze backlog endpoint 2026-07-08 20:13:52 +02:00
Richard 882226c6c6 Add unit tests for Engine and Scoring fixes 2026-07-07 18:38:23 +02:00
Richard 4eb0d99b4e Fix Estimator scoring and PnL engine cashflow 2026-07-07 18:30:20 +02:00
Richard 8d056653f9 Fix EF Core ExecuteSqlRawAsync DBNull mapping error by using null instead of DBNull.Value 2026-07-07 13:06:27 +02:00
Richard 3105f6f28e Use raw SQL INSERT IGNORE for TradeRepository.AddRangeAsync to prevent DbUpdateException on duplicates 2026-07-07 13:01:31 +02:00
Richard 2375a193e6 Fix EF Core missing OrderBy warning 2026-07-07 12:32:08 +02:00
Richard 5ca50836a9 Fix DbUpdateException in TradeRepository and Polymarket API 400 on max offset 2026-07-07 12:23:37 +02:00
Richard 1485c7cba9 Fix TradeReconciliationWorker: Fetch missing markets from API on demand before linking orphaned trades 2026-07-07 12:05:00 +02:00
Richard d24f0ecc2e Fix WinRate 0% bug: Optimize TradeReconciliationWorker with bulk SQL and reset Trader analytics flag 2026-07-07 10:56:52 +02:00
Richard 910d25159a Add tracking for analyzed traders and add crawling configuration to appsettings.json 2026-07-07 09:45:51 +02:00
Richard 2c7c643fdb Fix styling, job endpoints, and infinite worker loops 2026-07-07 09:21:37 +02:00
Richard 10eefd3546 Fix API offset limit 400 Bad Request, implement requested UI/UX improvements 2026-07-06 22:34:33 +02:00
Richard fb703b6c81 feat: Jobs infrastructure, endpoints, UI and worker prioritization 2026-07-06 19:58:23 +02:00
Richard 33a52ed173 fix: Polymarket API offset limit crash in CopytradingEstimator 2026-07-06 13:01:06 +02:00
Richard a564c016bb feat: Implement copytrading analytics and update WebUI
- Add v4 Tape-based CopytradingEstimator (Clustering, MAE, Tape Fills)
- Add CopytradingBacktestHarness (Walk-Forward testing, Shrinkage, LCB ranking)
- Add EF Core Migrations for FollowerFillPrice and Scoring fields
- Update WebUI: Fix Trader Detail tab layout blowout
- Update WebUI: Redesign Trader Detail menubar
- Update WebUI: Display separate Quality and Copyability metric cards
- Update WebUI: Add 'Highly Copyable' filter to Trader List
2026-07-06 11:55:38 +02:00
Richard c0c598b86a Fix Trader Detail Page layout constraint and improve menu bar 2026-07-05 20:23:16 +02:00
Richard 689ba45533 Fix index drop order in AddTradeContextAndSubcategory migration to satisfy MySQL FK constraints 2026-07-05 20:16:45 +02:00
Richard d3fac35785 Fix EF Core shadow property mapping bug for TraderAnalytics 2026-07-05 20:14:23 +02:00
Richard dc0b67deaa test: fix AnalyticsServiceTests by mocking missing dependencies and adding moq 2026-07-05 19:46:21 +02:00
Richard 3f6f8fc17d feat: rebuild trader detail UI with tabs and manual recalculate button 2026-07-05 19:04:35 +02:00
Richard b5dfa6bb1b refactor: use existing TradeContextEnrichmentWorker for TradeContext and Slippage calculations 2026-07-05 19:03:04 +02:00
Richard 0b799123db feat: prioritize trader analytics via LastAnalyzedAt and add force-analyze endpoint 2026-07-05 18:58:33 +02:00
Richard c38b4d498f feat: add TradeContext, Subcategory and LastAnalyzedAt 2026-07-05 18:56:18 +02:00
Richard 8f6bce23f3 fix: filter unmapped trades from UI display 2026-07-05 15:01:54 +02:00
Richard d533374ced fix: remove TestSql.cs that caused build errors 2026-07-05 14:30:45 +02:00
Richard c81e5638b5 fix: Resolve EF Core shadow property issue and increase migration timeout 2026-07-05 14:22:16 +02:00
Richard e9e9ce0d5a feat: Add category performance, update WebUI and OpenRouter integration, fix bugs 2026-07-05 14:13:16 +02:00
Richard d102af2965 Enhance UI, add AI integration, improve logging and database stats 2026-07-04 21:11:31 +02:00
Richard 7a44914d9d Implement B4: Add Predictalytics.Application.Tests project with unit tests for PositionPnLEngine and AnalyticsService 2026-07-03 11:22:43 +02:00
Richard f8c8230d99 Implement A3, A4, A5, B3: Add MarketOutcomePriceSnapshot, implement Polymarket CLOB prices-history endpoint, improve strategy classification, introduce CopytradingScore, and decouple/optimize scoring pipeline into a separate worker 2026-07-03 11:20:28 +02:00
Richard e994e1ce72 Implement A1, A6, A2: Add TraderPosition entity, PositionPnLEngine (Average-Cost-Method), Market-level WinRate, and integrate with TraderAnalyticsWorker 2026-07-03 11:16:42 +02:00
Richard 5fe7ab63ac Fix B6: Market concurrency lock, watchlist exclusion from cleanup, optimized trade ID deduplication query, and TradeHistoryWorker sync logic 2026-07-03 11:10:53 +02:00
Richard 434c631290 Document additional bugs/perf issues found in second review pass
Added B6 to UMSETZUNGSPLAN.md: unbounded MarketSyncWorker re-sync of all
closed markets, watchlisted traders not exempt from auto-cleanup deletion,
full trade-history load in GetKnownPlatformTradeIdsAsync, a race condition
in MarketRepository.AddOrUpdateAsync under concurrent access, and an
early-break assumption in TradeHistoryWorker that isn't applied consistently.

No functional code changed yet — these are earmarked for Phase 2 (B3-adjacent).
2026-07-03 10:37:06 +02:00
Richard 340bfdaa82 B1: EF Core migrations baseline validated against real dev DB
- Design-time AppDbContextFactory now builds its connection string via
  MySqlConnectionStringBuilder from PREDICTALYTICS_DB_* env vars instead of a
  hardcoded local default, so no secret needs to live in source/config to run
  migrations against any target database.
- InitialBaseline migration applied end-to-end against a fresh dev MySQL DB
  and confirmed via `dotnet ef migrations list`.
2026-07-03 10:30:13 +02:00
Richard afb251acfc Initial commit: Predictalytics solution
Clean Architecture .NET 8 solution (Domain/Application/Infrastructure/Api/Worker/WinFormsHost)
for analyzing Polymarket traders for copytrading/strategy-replication candidates.

Includes EF Core InitialBaseline migration and DB secrets removed from source/config
in preparation for version control.
2026-07-01 19:53:29 +02:00