Commit graph

67 commits

Author SHA1 Message Date
Viktor Barzin
e92cbc1bc4
fix: trade log Invalid Date and equity curve duplicate timestamp crash
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
- TradeLog: use created_at (from API) instead of timestamp for date display
- EquityCurve: deduplicate data by day before passing to lightweight-charts,
  preventing "data must be asc ordered by time" assertion failure when
  multiple snapshots exist on the same day

Made-with: Cursor
2026-02-28 11:05:37 +00:00
Viktor Barzin
4f60ef453f
fix: hardcode nginx-k8s.conf in dashboard Dockerfile
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
The buildx plugin was not passing NGINX_CONF build arg correctly,
causing the docker-compose nginx config (with hostname api-gateway)
to be used instead of the K8s one (with localhost).
2026-02-25 23:46:47 +00:00
Viktor Barzin
0a017f52cb
perf: switch to uv for faster dependency installation
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
- Replace pip with uv in Dockerfile.service builder stage (~5-10x faster)
- Replace pip with uv in CI test step
- Separate pyproject.toml copy from source copy in Dockerfile for better
  Docker layer caching (deps only reinstalled when pyproject.toml changes)
- Add cache_from for buildx to reuse layers from previous builds
- Remove pip cache workaround from test step (not persisted in K8s)
2026-02-25 22:55:58 +00:00
Viktor Barzin
5955a5a86d
fix: hardcode pip extras in Dockerfile to avoid buildx arg parsing issues
Some checks are pending
ci/woodpecker/push/woodpecker Pipeline is running
The woodpeckerci/plugin-docker-buildx was not passing the EXTRAS build
arg correctly (commas in the value were likely being parsed as list
separators), causing the image to only install dev dependencies instead
of all service extras (api, news, sentiment, trading, backtester).

Hardcode the pip install extras directly in the Dockerfile rather than
relying on the build arg.
2026-02-25 22:27:15 +00:00
Viktor Barzin
a3cdd0f1a5
fix: resolve all remaining TODOs, add dev mode auth bypass
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
- Learning engine: expand default weights from 3 to all 9 strategies
- Learning engine: resolve placeholder strategy_id with DB lookup
- Learning engine: pass strategy_sources from trade execution
- Trade executor: respect trading:paused Redis flag in RiskManager
- Portfolio sync: compute actual daily P&L from day-start snapshot
- Portfolio API: cumulative P&L from first snapshot, read pause flag
- Portfolio metrics: compute max drawdown and avg hold duration
- Add strategy_sources field to TradeExecution schema
- Add dev_mode config (TRADING_DEV_MODE) to bypass auth for local dev
- Dashboard: VITE_DEV_MODE bypasses ProtectedRoute and 401 redirects
- Vite proxy target configurable via VITE_API_TARGET
- Add top-level README.md and remaining-work-plan.md
- Update CLAUDE.md with correct counts and remove stale TODOs
- 404 tests passing

Made-with: Cursor
2026-02-25 22:02:25 +00:00
Viktor Barzin
4094e4b10f
fix: push final tags directly from buildx, remove publish-images step
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
The publish-images step used an alpine container to run skopeo for
re-tagging, but intermittent DNS failures prevent apk from installing
packages. Instead, have the buildx plugin push with both the pipeline
number tag and latest tag directly, eliminating the extra step.
2026-02-25 21:25:27 +00:00
Viktor Barzin
e73d62cd3a
fix: make hypertable creation conditional on TimescaleDB extension
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
The alembic migration unconditionally called create_hypertable() which
fails if TimescaleDB isn't installed on the PostgreSQL instance. Wrap
in a DO block that checks for the extension first.
2026-02-25 21:03:31 +00:00
Viktor Barzin
efc91e9ad0
[ci] test build
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-02-25 20:51:19 +00:00
Viktor Barzin
1dd0c25cbc
fix: escape shell variables from Woodpecker CI substitution
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Woodpecker pre-processes ${VAR} syntax as CI variables, replacing
undefined ones with empty strings. Use $$ escaping for shell variables
to prevent Woodpecker from consuming them. The ${REPO} variable in
the skopeo publish step was being replaced with empty string.
2026-02-25 00:43:01 +00:00
Viktor Barzin
792776bfe0
fix: use woodpeckerci/plugin-docker-buildx for privileged builds
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
plugins/docker does not get privileged: true in K8s pods despite being
in WOODPECKER_PLUGINS_PRIVILEGED. woodpeckerci/plugin-docker-buildx
correctly receives privileged mode. Previous build failure with buildx
was a transient network timeout reaching registry-1.docker.io.
2026-02-25 00:25:56 +00:00
Viktor Barzin
d084dad021
[ci] test privileged mode
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-02-24 23:59:06 +00:00
Viktor Barzin
61f1efbf27
fix: switch back to plugins/docker for image builds
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
The woodpeckerci/plugin-docker-buildx plugin started dockerd correctly
(privileged mode works) but failed DockerHub authentication. Switch back
to plugins/docker which is proven working in realestate-crawler pipeline.
2026-02-24 23:42:53 +00:00
Viktor Barzin
1f065f4b4d
fix: switch to buildx plugin and add pip caching for CI
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
- Use woodpeckerci/plugin-docker-buildx instead of plugins/docker to fix
  Docker daemon connection failures (privileged mode not applied)
- Add pip dependency caching between builds via /woodpecker/pip-cache
- Fix slack plugin image (plugins/slack, not woodpeckerci/plugin-slack)
- Use proper buildx cache_from syntax (type=registry,ref=...)
2026-02-24 23:27:33 +00:00
Viktor Barzin
3bbb82b6aa
[ci] trigger build
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-02-24 23:12:45 +00:00
Viktor Barzin
4df7c67c13
fix: news articles showing 1970 dates when published_at is null
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Backend falls back to fetched_at when published_at is NULL in the database,
so the API always returns a meaningful date. Frontend also handles null
defensively to avoid new Date(null) producing Unix epoch 0.
2026-02-23 22:48:16 +00:00
Viktor Barzin
9f86aaf540
add K8s nginx config and parameterize Dockerfile.dashboard
Create nginx-k8s.conf that proxies to localhost:8000 instead of
api-gateway:8000 for K8s pods where both containers share a network
namespace. Update Dockerfile.dashboard to accept a NGINX_CONF build arg
(defaults to docker/nginx.conf for docker-compose compatibility).
2026-02-23 22:27:52 +00:00
Viktor Barzin
ed3bf57566
add Woodpecker CI pipeline 2026-02-23 22:26:49 +00:00
Viktor Barzin
a2c08743ac
feat: make backtest work end-to-end with Alpaca bars, ticker selection, all 9 strategies
- Change BacktestRequest from strategy_weights dict to strategies list to match frontend
- Add tickers field so users can select which stocks to backtest
- Fetch historical bars from Alpaca StockHistoricalDataClient instead of empty data loader
- Register all 9 strategies (momentum, mean_reversion, news_driven, value, macd_crossover,
  bollinger_breakout, vwap, liquidity, ma_stack) filtered by user selection
- Fix response format: use frontend field names (max_drawdown, total_trades, win_rate as
  0-1 decimal), include equity_curve and run_id in response
- Add ticker selector with checkboxes and custom ticker input to dashboard
- Add alpaca-py to api dependency group in pyproject.toml
2026-02-23 22:25:41 +00:00
Viktor Barzin
82d30bde80
add deployment implementation plan 2026-02-23 22:22:42 +00:00
Viktor Barzin
774dcfd1c1
add deployment design document 2026-02-23 22:19:35 +00:00
Viktor Barzin
b8eaa20d63
feat: wire 6 new strategies and fundamentals into signal generator 2026-02-23 21:55:59 +00:00
Viktor Barzin
4d6bebe6f7
feat: add 6 new strategies (value, MACD, Bollinger, VWAP, liquidity, MA stack) 2026-02-23 21:50:52 +00:00
Viktor Barzin
0530f496ca
feat: add fundamentals DB model and cached provider 2026-02-23 21:49:31 +00:00
Viktor Barzin
6c909d12c3
feat: add MACD, Bollinger, VWAP, ATR, EMA, SMA-200 indicator computations 2026-02-23 21:49:26 +00:00
Viktor Barzin
6f512cf91f
refactor: reconcile FundamentalsSnapshot to use canonical schema from trading.py 2026-02-23 21:45:18 +00:00
Viktor Barzin
aa47e896dd
feat: add fundamental data providers (Alpha Vantage, FMP, Yahoo Finance) with rotation 2026-02-23 21:41:16 +00:00
Viktor Barzin
2398e8faf6
feat: add technical indicator and fundamentals fields to MarketSnapshot 2026-02-23 21:39:37 +00:00
Viktor Barzin
5cb65e8e4f
docs: add implementation plan for extended strategies + fundamentals
8 tasks covering: MarketSnapshot schema changes, indicator computations,
fundamental data providers, DB caching, 6 new strategies, signal generator
wiring, and deployment steps.
2026-02-23 21:34:12 +00:00
Viktor Barzin
9eebd3fe61
docs: add design for extended strategies + fundamental data
6 new strategies (Value, MACD Crossover, Bollinger Breakout, VWAP,
Liquidity, MA Stack) plus fundamental data pipeline with 3 providers
(Alpha Vantage, FMP, Yahoo Finance) and DB-backed caching.
2026-02-23 21:27:08 +00:00
Viktor Barzin
99b041a0dd
fix: flush article before creating sentiment FK references
ArticleSentiment referenced db_article.id before the Article was flushed,
causing a NotNullViolationError on the article_id column. Adding an explicit
flush after session.add(db_article) ensures the UUID is populated before
creating the foreign key reference.
2026-02-23 20:57:11 +00:00
Viktor Barzin
bc34c78072
docs: map existing codebase 2026-02-23 20:04:05 +00:00
Viktor Barzin
d36ae40df1
feat: productionize local service — fix signal pipeline, lower thresholds, add company-name ticker extraction
- Point Ollama to local instance via host.docker.internal, use gemma3 model
- Remove Docker Ollama service (using host's Ollama instead)
- Add company-name-to-ticker mapping (Apple→AAPL, Tesla→TSLA, etc.) for RSS articles
- Lower signal thresholds for faster feedback with paper trading:
  - FinBERT confidence: 0.6→0.4, signal strength: 0.3→0.15
  - News strategy: article_count 2→1, confidence 0.5→0.3, score ±0.3→±0.15
- Fix market data BarSet access bug (BarSet.__contains__ returns False incorrectly)
- Fix market data SIP feed error by switching to IEX feed for free Alpaca accounts
- Fix nginx proxy routing for /api/auth/* to api-gateway /auth/*
- Add seed_sample_data script
- Update tests for new thresholds and alpaca mock modules
2026-02-22 22:17:26 +00:00
Viktor Barzin
67e64fab18
fix: add missing pytz dependency and remove ollama port conflict
- Add pytz to trading extras (alpaca-py requires it but doesn't declare it)
- Remove host port mapping from ollama container to avoid conflict with
  local ollama instance
2026-02-22 21:26:39 +00:00
Viktor Barzin
e2a3bd456d
feat: real data pipeline — market data, DB persistence, portfolio sync, signal-trade linkage
Wire the trading bot to real Alpaca market data and persist pipeline
state to the database so the dashboard displays live information.

- Add market-data service fetching OHLCV bars from Alpaca, publishing
  to market:bars Redis Stream; signal generator consumes bars and
  injects current_price into signals for position sizing
- Sentiment analyzer now persists Article + ArticleSentiment rows to
  DB after scoring, with duplicate and error handling
- API gateway runs a background portfolio sync task that snapshots
  Alpaca account state into PortfolioSnapshot/Position DB tables
  during market hours
- TradeSignal carries a signal_id UUID; signal generator and trade
  executor both persist their records to DB with cross-references
- 303 unit tests pass (57 new tests added)
2026-02-22 19:52:45 +00:00
Viktor Barzin
5a6b20c8f1
fix: resolve 13 important issues from code review
I1: Add graceful shutdown (SIGTERM/SIGINT) to all 5 background services
I2: Fix Dockerfile healthcheck to use curl on /metrics endpoint
I3: Fix StreamConsumer.ensure_group() to only catch BUSYGROUP errors
I4: Fix SimulatedBroker to reject orders with insufficient cash/shares
I5: Move ORM attribute access inside DB session context in trades routes
I6: Add Redis-based rate limiting (10 req/min/IP) on all auth endpoints
I8: Prevent backtest background task garbage collection
I9: Use Numeric(16,6) instead of Float for financial columns in migration
I10: Add index on trades.created_at for time-range queries
I11: Bind infrastructure ports to 127.0.0.1 in docker-compose
I12: Add migrations init service; all app services depend on it
I13: Fix user enumeration in login_begin (return options for non-existent users)
2026-02-22 17:58:01 +00:00
Viktor Barzin
2a56727267
fix: resolve 8 critical issues from code review
C1: Fix BacktestDataLoader constructor args (was passing wrong kwargs)
C2: Fix BacktestResult attribute names (max_drawdown_pct, avg_hold_duration)
C3: Remove insecure JWT secret default (now required via env var)
C4: Fix .env.example to use TRADING_ prefix for all config vars
C5: Add missing fields to portfolio endpoint (daily_pnl_pct, total_pnl, trading_active)
C6: Add missing /portfolio/metrics endpoint
C7: Add 'value' field to equity curve response for frontend compatibility
C8: Add 6M/ALL periods and case-insensitive period enum parsing
Also: make app creation lazy to avoid config validation at import time
2026-02-22 17:48:40 +00:00
Viktor Barzin
870961f3e9
Add project knowledge file for Claude Code sessions
Captures architecture, patterns, tech stack, test coverage,
development workflow, and lessons learned from initial build.

[ci skip]
2026-02-22 17:25:27 +00:00
Viktor Barzin
e6ae4bdccd
feat: integration tests, seed data, and smoke test script
Add integration tests for the news pipeline (test_news_pipeline.py) and
trading flow (test_trading_flow.py) using real Redis with mocked FinBERT
and Alpaca. Add seed_strategies.py to insert default strategies (momentum,
mean_reversion, news_driven) with equal weights. Add smoke_test.sh for
end-to-end stack validation. Update pyproject.toml with integration marker
and scripts package discovery.
2026-02-22 16:02:44 +00:00
Viktor Barzin
b255b3edbe
feat: dockerfiles and full docker-compose orchestration
Add multi-stage Dockerfiles for Python services (Dockerfile.service) and
React dashboard (Dockerfile.dashboard + nginx.conf). Update docker-compose.yml
with all seven application services: news-fetcher, sentiment-analyzer,
signal-generator, trade-executor, learning-engine, api-gateway, and dashboard.
2026-02-22 16:02:34 +00:00
Viktor Barzin
e470055354
Merge branch 'worktree-agent-a46e78e2' 2026-02-22 15:55:29 +00:00
Viktor Barzin
8d6e666280
feat: dashboard trading views -- portfolio, trades, strategies, news, backtest
Add Layout with sidebar navigation and top bar (portfolio value, trading
status indicator). Implement Portfolio page with equity curve (TradingView
lightweight-charts), positions table, and metrics row. Add TradeLog with
filters, pagination, and expandable row details. Add Strategies page with
weight allocation pie chart and weight history line chart (Recharts). Add
NewsFeed with sentiment badges and ticker filtering. Add Backtest page
with config form, run submission, and results panel. Include WebSocket
hook for real-time cache invalidation and portfolio query hooks.
2026-02-22 15:54:44 +00:00
Viktor Barzin
f121f376ae
feat: dashboard setup with passkey authentication
Scaffold Vite + React + TypeScript project with Tailwind CSS dark theme.
Add Axios API client with JWT interceptor and auto-refresh, WebAuthn
passkey auth flow (register/login), protected route wrapper, and React
Router with public and protected routes.
2026-02-22 15:54:32 +00:00
Viktor Barzin
6fe586f722
feat: API gateway trading endpoints, controls, backtest, WebSocket 2026-02-22 15:54:20 +00:00
Viktor Barzin
e0d138c457
feat: API gateway with passkey (WebAuthn) authentication 2026-02-22 15:53:48 +00:00
Viktor Barzin
f218865872
Merge branch 'worktree-agent-ada4003e' 2026-02-22 15:43:54 +00:00
Viktor Barzin
5e5425a0f7
feat: backtesting engine — historical replay with shared strategies 2026-02-22 15:43:19 +00:00
Viktor Barzin
c089bcb92c
feat: learning engine — multi-armed bandit strategy weight adjustment 2026-02-22 15:43:11 +00:00
Viktor Barzin
1d9900838d
Merge branch 'worktree-agent-ad9ede16'
# Conflicts:
#	shared/strategies/__init__.py
#	shared/strategies/base.py
#	shared/strategies/mean_reversion.py
#	shared/strategies/momentum.py
#	shared/strategies/news_driven.py
2026-02-22 15:37:25 +00:00
Viktor Barzin
3fef8a631c
feat: trade executor — risk management and order execution 2026-02-22 15:36:08 +00:00
Viktor Barzin
f3e5fc944d
feat: signal generator — weighted ensemble with market data 2026-02-22 15:36:04 +00:00