Commit graph

86 commits

Author SHA1 Message Date
Marko Djordjevic
228f70daf3 docs: add ML pipeline quickstart guide for training first model
Complete step-by-step guide covering:
- Creating training data through annotations
- Exporting annotations and candle data
- Running the full ML pipeline
- Verifying model creation and loading
- Getting predictions in the UI
- Troubleshooting common issues
- Iteration through active learning loop
2026-02-15 19:08:09 +01:00
Marko Djordjevic
21f184aa8d feat(ui): implement disagreement detection, prediction summary, loading states, and update documentation
- Add disagreement detection logic comparing human annotations vs predictions
- Display prediction summary in PredictionPanel (agreements/disagreements)
- Wire up 'Show only disagreements' filter toggle
- Add loading overlay during prediction fetching
- Update docker-compose.yml with healthchecks for all services
- Update DEPLOYMENT.md with comprehensive ML service setup instructions
- Update README.md with ML pipeline overview and architecture diagrams
- Update CLAUDE_DESCRIPTION.md with v3.0.0 ML integration details

Remaining tasks (11.2, 11.4, 11.5) deferred - core functionality complete
2026-02-15 16:34:02 +01:00
Marko Djordjevic
952eb7413c feat(ui): add prediction chart rendering with histogram overlay, markers, filtering, and visibility toggle
- Add histogram series to CandleChart for per-bar prediction colors (15% opacity)
- Add series markers showing label name and confidence % at prediction span starts
- Implement confidence threshold filtering for both histogram and markers
- Implement label type filtering from PredictionPanel checkboxes
- Implement prediction layer visibility toggle (show/hide)
- Add getVisibleCandles method to CandleChartHandle for on-demand prediction fetching
- Pass prediction state props from page.tsx to CandleChart

Tasks 10.1-10.5 complete.
2026-02-15 16:26:17 +01:00
Marko Djordjevic
28ebe2c5d1 feat(ui): add prediction state management and PredictionPanel component
- Create prediction type definitions in src/types/predictions.ts
- Add prediction state management to page.tsx with caching
- Implement PredictionPanel component with:
  - Master visibility toggle
  - Model info display (name, version, type, metrics)
  - Action buttons (Run on Visible, Predict All)
  - Confidence threshold slider
  - Label filter checkboxes with per-class metrics
  - Disagreement filter toggle
  - Prediction summary display
  - Model server offline banner
- Add on-demand and batch prediction fetching
- Implement prediction caching by chart and model version
- Add health polling for inference API (30s interval when offline)
- Ensure annotation tools work independently of prediction API

Tasks completed: 9.1-9.5, 12.1-12.3 (59/78 total)
2026-02-15 16:20:07 +01:00
Marko Djordjevic
bb1b6d573f feat(api): add span annotation export and feedback loop support
- Add GET /api/span-annotations/export endpoint for ML pipeline JSON/CSV export
- Add source and model_prediction fields to span_annotations schema
- Update POST endpoint to accept source (human/model/human_correction) and model_prediction metadata
- Support negative annotations (label 'O' for user corrections to model predictions)
- Create migration 0005 for new schema fields

Completes tasks 8.1-8.4 of candle-backend change
2026-02-15 14:35:31 +01:00
Marko Djordjevic
205021e810 feat(api): add Next.js proxy routes for ML inference service 2026-02-15 14:30:09 +01:00
Marko Djordjevic
3a83fd38e9 feat(ml): implement FastAPI inference service with model loading, preprocessing, and prediction endpoints 2026-02-15 14:29:07 +01:00
Marko Djordjevic
f4c0f9a836 feat(ml): implement training stage with MLflow tracking and model wrappers
- Create RandomForestModel and XGBoostModel wrappers with class weight support
- Implement temporal and random train/val/test splitting
- Add MLflow experiment tracking with full parameter and metric logging
- Create evaluation module for confusion matrix, feature importance, and classification reports
- Implement model training with sklearn/xgboost flavor logging and optional registry registration
- Store training run metadata in PostgreSQL
- Wire training stage into pipeline.py orchestrator
- Support both RandomForest and XGBoost models with configurable hyperparameters
2026-02-15 14:22:19 +01:00
Marko Djordjevic
16763b967e feat(ml): implement annotation ingestion with windowed/BIO encoding and TA-Lib patterns 2026-02-15 12:28:58 +01:00
Marko Djordjevic
fd29ab91e0 feat(ml): implement feature engineering pipeline
- Create pipeline.py with CLI argument parsing for running stages
- Implement TA-Lib indicator computation with multi-output support
- Add candle feature extraction (body_size, wicks, ratios, etc.)
- Create custom feature loader with dynamic module import
- Wire all feature engineering stages with NaN handling
- Tasks completed: 2.2, 2.3, 3.1, 3.2, 3.3, 3.4, 3.5
2026-02-15 12:22:59 +01:00
Marko Djordjevic
ea339a54a7 feat(ml): add database schema, config parser, and DVC setup
- Initialize DVC with local storage backend (task 1.6)
- Create PostgreSQL schema for training_runs table (task 1.7)
- Add SQLAlchemy database connection setup (task 1.8)
- Create Pydantic config models for pipeline.yaml (task 2.1)
- Add migration runner for database setup
- Fix pyproject.toml package discovery config
2026-02-15 12:08:53 +01:00
Marko Djordjevic
1a653c5866 feat: add ML service scaffolding with Python FastAPI, Docker, and MLflow setup 2026-02-15 11:58:31 +01:00
Marko Djordjevic
92abab5316 span annotations are working 2026-02-15 10:16:05 +01:00
Marko Djordjevic
6a899c3ecf feat: add span-label-types link to main page and create migration for default types 2026-02-14 11:16:33 +01:00
Marko Djordjevic
38cbdc22e1 feat: add span label types admin page with seed functionality 2026-02-14 11:12:39 +01:00
Marko Djordjevic
6ef6b2562c add start data 2026-02-14 10:50:49 +01:00
Marko Djordjevic
4b5cc2f174 fix: install missing shadcn/ui components and fix TypeScript build errors
- Install missing shadcn/ui components: dialog, select, label, slider, textarea
- Fix import paths in export API endpoint (@/lib/db instead of @/db)
- Fix CandleChart activeChartId type (handle undefined with nullish coalescing)
- Fix SpanRectanglePrimitive renderer to use proper lightweight-charts v4 API:
  - Implement ISeriesPrimitivePaneRenderer interface
  - Use useBitmapCoordinateSpace for HiDPI rendering
  - Add proper scaling factor for coordinates and dimensions
  - Fix hitTest to return PrimitiveHoveredItem with required zOrder property
- Mark all section 12 integration testing tasks as completed
2026-02-14 10:43:10 +01:00
Marko Djordjevic
842a58f12b feat: implement section 11 - span export endpoints (JSON, windowed CSV, BIO-tagged CSV) 2026-02-14 10:14:58 +01:00
Marko Djordjevic
b5e4d6573e feat: implement section 10 - hotkey label assignment for span annotations 2026-02-14 10:14:17 +01:00
Marko Djordjevic
4089aab77c feat: implement section 9 - span annotation sidebar list 2026-02-14 10:13:23 +01:00
Marko Djordjevic
2f05136f20 feat: implement section 8 - span selection, editing, and deletion 2026-02-14 10:11:51 +01:00
Marko Djordjevic
586f02ed69 feat: implement sections 6-7 - span selection, preview, and label assignment popover 2026-02-14 10:10:41 +01:00
Marko Djordjevic
c9d2cbfc4b feat: implement Section 5 - Span Tool State & Integration
- Add SpanAnnotation and SpanLabelType interfaces to page.tsx
- Add span-related state: spanAnnotations, selectedSpanId, spanLabelTypes
- Add fetchSpanAnnotations() and fetchSpanLabelTypes() data fetching functions
- Load span annotations and label types when chart changes
- Add "Span" tool button to Toolbox component with RectangleHorizontal icon
- Mark Section 5 tasks (5.1-5.5) as complete in tasks.md

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-14 06:42:24 +01:00
Marko Djordjevic
5ea63a613e feat: implement SpanRectanglePrimitive for span annotation rendering
- Created SpanRectanglePrimitive.ts implementing ISeriesPrimitive interface
- Implemented updateAllViews() with coordinate conversion from data-space to pixel-space
- Added semi-transparent rectangle rendering with configurable opacity
- Implemented label tag rendering above rectangles showing pattern names
- Added hitTest() for click detection within span bounds
- Implemented highlight state with thicker borders and increased opacity
- Set zOrder to 'bottom' to render rectangles behind candlesticks
- Completed Section 4 tasks (4.1-4.6) from span-annotation specification

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-14 06:35:01 +01:00
Marko Djordjevic
7c1007f712 chore: mark completed tasks in span-annotation tasks.md (sections 1-3) 2026-02-14 06:08:36 +01:00
Marko Djordjevic
dadf515406 feat: add database schema, migrations, and API endpoints for span annotations
- Add span_label_types and span_annotations tables to schema
- Seed default span label types (bull_flag, bear_flag, etc.)
- Implement CRUD API endpoints for span label types
- Implement CRUD API endpoints for span annotations
- Add time swap validation in POST endpoint (start_time <= end_time)
2026-02-14 05:56:28 +01:00
Marko Djordjevic
8a7eb1fb08 openspec: span annotation 2026-02-14 05:51:23 +01:00
Marko Djordjevic
88e7347918 archive: add-dark-light-mode change complete 2026-02-13 09:37:18 +01:00
Marko Djordjevic
a8f9327d19 sync: apply add-dark-light-mode delta specs to main specs 2026-02-13 09:37:06 +01:00
Marko Djordjevic
3da4987f89 archive: multi-chart-management change complete 2026-02-13 09:23:33 +01:00
Marko Djordjevic
603b08209b use github action runners 2026-02-13 09:19:08 +01:00
Marko Djordjevic
4121a87875 sync: apply multi-chart-management delta specs to main specs
- Created new chart-management capability spec
- Updated data-ingestion: chart-scoped candles, duplicate filename handling
- Updated backend-api: all endpoints gain chartId parameter, chart CRUD
- Updated chart-canvas: chart switching, scoped data fetching
- Updated label-management: annotations scoped to active chart
- Updated ui-shell: upload creates/selects chart, theme-aware link styling
2026-02-13 09:06:37 +01:00
Marko Djordjevic
7cb308788e test: verify multi-chart management implementation
- Verified ChartSelector uses theme-aware classes
- Tested full workflow: upload, chart creation, switching, annotation scoping
- Verified migration creates default chart with existing data
- Tested chart deletion with cascade delete of candles/annotations
- Tested edge cases: duplicate filenames, deleting last chart, upload with no charts
- Build passes with no type errors
2026-02-13 00:29:21 +01:00
Marko Djordjevic
b9771fe89f feat: wire frontend state and data flow for multi-chart support
- Add activeChartId/charts state to page.tsx with chart fetching on mount
- ChartSelector integrated in sidebar between header and file upload
- CandleChart and SvgOverlay fetch data scoped by activeChartId
- FileUpload returns chart info, auto-selects new chart after upload
- Annotation create/delete flows include chart_id
- Export scoped by activeChartId
- Toolbox receives activeChartId prop
2026-02-13 00:17:09 +01:00
Marko Djordjevic
a3c7137b01 feat: create ChartSelector component with dropdown, delete, and empty state 2026-02-13 00:14:53 +01:00
Marko Djordjevic
90e1e179cc feat: scope candles/annotations/export APIs by chartId query param
- GET /api/candles accepts ?chartId= with fallback to most recent chart
- GET /api/annotations accepts ?chartId= with fallback to most recent chart
- POST /api/annotations now requires chart_id in request body
- GET /api/export accepts ?chartId= to scope exported annotations
- DELETE /api/annotations supports optional chartId scoping
2026-02-13 00:14:22 +01:00
Marko Djordjevic
98e91b047a feat: upload creates new chart from filename with duplicate handling
- POST /api/upload now creates a chart named from the CSV filename
- Duplicate names get numeric suffix (e.g., btc-daily-2)
- Candles inserted with chart_id instead of replacing all data
- Response includes chart id and name
2026-02-13 00:13:23 +01:00
Marko Djordjevic
b53cb1b7d1 feat: add charts API endpoints (GET list, DELETE with cascade) 2026-02-13 00:12:53 +01:00
Marko Djordjevic
92d3339a48 feat: add charts table schema and migration with data backfill
- Add charts table with id, name (unique), created_at
- Add chart_id FK to candles table with composite unique on (chart_id, time)
- Add chart_id FK to annotations table
- Custom migration handles existing data: creates 'Imported Data' chart and backfills chart_id
- Recreates tables for NOT NULL constraint (SQLite limitation)
2026-02-13 00:12:21 +01:00
Marko Djordjevic
178834f3b2 fix: resolve type errors in ThemeProvider and ThemeToggle
- Remove import from 'next-themes/dist/types' (no longer exported)
- Use React.ComponentProps<typeof NextThemesProvider> instead
- Remove unsupported 'asChild' prop from TooltipTrigger
- Remove unsupported 'side' prop from TooltipContent
2026-02-12 23:48:58 +01:00
Marko Djordjevic
9ec571389b night friendly candle colors 2026-02-12 23:38:11 +01:00
Marko Djordjevic
0d235602af feat: implement dark/light mode with system detection
- Install and configure next-themes for theme management
- Add ThemeProvider wrapper component with suppressHydrationWarning
- Define light theme CSS variables (off-white backgrounds, green accents)
- Define dark theme CSS variables (hacker theme: terminal blacks, matrix green)
- Update scrollbar styles for both themes
- Add CRT scanline/glow effects (dark mode only)
- Create ThemeToggle component with system/light/dark cycling
- Add theme toggle to Toolbox sidebar
- Update CandleChart to apply theme-specific colors
- Chart colors update dynamically on theme change
- All components use CSS variables for theme compatibility
- FOUC prevention via next-themes inline script
2026-02-12 23:31:51 +01:00
Marko Djordjevic
4dad24845e chore: archive update-candle-colors change 2026-02-12 23:26:25 +01:00
Marko Djordjevic
cce55c63c1 docs: sync candlestick color spec from update-candle-colors change 2026-02-12 23:26:10 +01:00
Marko Djordjevic
48883e60f0 feat: update candlestick colors to black/white scheme
- Change bullish candles to white interior with black outline
- Change bearish candles to solid black
- Update all wick colors to black
- Enable borders for candlesticks
2026-02-12 23:23:17 +01:00
Marko Djordjevic
62e0c554df use github actions again 2026-02-12 20:23:13 +01:00
Marko Djordjevic
8330566080 docs: update README with CSV replace mode and initial data loading 2026-02-12 18:49:16 +01:00
Marko Djordjevic
6522f501b6 feat: add EURUSD.csv data loading on Docker startup 2026-02-12 18:48:54 +01:00
Marko Djordjevic
011bea2350 feat: delete old candles on CSV upload before inserting new ones 2026-02-12 18:47:11 +01:00
Marko Djordjevic
974d9f5598 feat: add annotation types management system
- Created annotation_types table with name, display_name, color, category, icon
- Implemented CRUD API endpoints for annotation types management
- Built annotation types management UI page at /annotation-types
- Updated Toolbox component to dynamically load and display annotation types
- Updated CandleChart component to use dynamic annotation types for markers
- Added seed functionality for default types (break_up, break_down, line)
- Cleaned up duplicate migration files
2026-02-12 18:17:44 +01:00