Commit Graph
68 Commits
Author SHA1 Message Date
eezd 78ca4422af Add demo trading analyst with plan validation and sizing
The analyst prompts the model with trading rules, published skills,
account sizing inputs and prefetched market data, exposes read-only
tools plus submit_trade_plan, and validates and sizes the submitted plan
in pure functions covered by pytest. Manual analyses run as dry runs
while trading is stopped; the trading page shows the latest plan and an
analysis detail drawer.
2026-10-15 10:40:29 +08:00
eezd 7536c9c5de Size demo trading by a configured capital instead of full account equity
Add trading_account.capital_usdt. Position sizing will use
min(capital, account equity); starting requires the capital to be set.
The trading page shows and edits it.
2026-10-15 10:02:36 +08:00
eezd 005943a54c Add demo trading page, trader snapshot service and trading tables
Add trading_symbols, trading_analyses, trading_orders and trading_events.
The new trader service publishes account, position and open-order
snapshots of the Binance demo account to Redis every 3s. The /trading
page shows engine status, start/stop, balances, positions, the symbol
list with angle selection, open orders and the event timeline.
2026-10-15 09:54:47 +08:00
eezd 154fe2b687 Explain demo-only keys in the exchange test error hint 2026-10-15 09:40:56 +08:00
eezd 20fd5a98b2 Add Binance demo trading key settings and signed demo client
Store demo API key/secret encrypted in a single-row trading_account table,
expose get/put/delete/test endpoints under /api/settings/exchange, and add
a settings card to enter and test the key. The client is hard-wired to
demo-fapi.binance.com.
2026-10-15 09:24:58 +08:00
eezd 438d6a00d9 Detect truncated model output and skip truncated tool calls 2026-10-14 23:27:51 +08:00
eezd 5b7490ac48 Report open interest window min and max in get_derivatives 2026-10-14 19:19:23 +08:00
eezd 3e5db79d4e Use live Binance klines in chat and add support/resistance zones
- get_klines always fetches from Binance REST: the stored last open
  candle is a snapshot from the sync and never updates, so 1d/4h data
  read from the database was stale. Mark whether the last bar is closed.
- Cluster swing highs/lows within 0.5 ATR into support/resistance zones
  with touch counts, returning the nearest 5 on each side instead of the
  last 5 raw swing points.
2026-10-14 19:15:19 +08:00
eezd 61486d0c5b Add derivatives tool, trim provider fields, widen model call retries
- New chat tool get_derivatives: funding rate (next estimate and recent
  settlements), premium, open interest change vs price, global and top
  trader long/short ratios, taker buy/sell ratio from Binance public
  endpoints. Each part fails independently.
- Strip whitespace from provider name and model; a leading space in the
  model name made the upstream return 404.
- Retry connection failures and mid-stream disconnects (raw httpx /
  httpx2 errors are not wrapped by the SDKs) up to 3 times while no
  output has been emitted, and surface them as chat errors.
- Return 30 recent bars from get_klines instead of 60 to cut tokens.
2026-10-14 18:16:54 +08:00
eezd b549f3f441 Replace temperature with reasoning effort and retry in-stream errors
- Providers get a default reasoning effort (low..max, empty = not sent);
  chat can override it per message. OpenAI sends reasoning_effort,
  Claude sends output_config.effort with adaptive thinking, and thinking
  blocks are replayed during the tool loop.
- Show a thinking indicator while waiting for model output.
- Surface in-stream upstream errors (e.g. overloaded) instead of
  breaking the SSE stream, and retry them up to 3 times when nothing
  has been emitted yet.
2026-10-14 15:12:27 +08:00
eezd 5db3ead883 Add AI chat with skills management and model provider settings
- Model providers for OpenAI and Anthropic message formats (e.g. via
  Sub2API), with API keys encrypted at rest and never returned
- Skills tree with markdown editing, priorities, drafts, publishing and
  rollback; only published skills enter the chat prompt
- Chat page with tool calls over collected news and Binance USD-M
  klines, a persisted CONTEXT.md, reset, and stop-generation support
- Chat may only create skill drafts and update CONTEXT.md; publishing,
  deleting, moving and priority changes stay with the user
2026-10-14 13:11:45 +08:00
eezd f042f27013 Default market page to USD-M BTCUSDT
Spot kline data was removed, so fall back to BTCUSDT when the remembered
selection no longer exists.
2026-10-14 12:00:45 +08:00
eezd b92b588c67 Stop tracking docs directory
Keep docs/ local only.
2026-10-14 11:24:41 +08:00
eezd e80bcebd75 Replace news infinite scroll with page-based pagination
The news list API now takes page and limit and returns the total count
instead of a cursor, and the news page uses el-pagination with a
persisted page size.
2026-10-13 15:10:04 +08:00
eezd 5c8d773ce1 Add resumable news history backfill
Let the crawler console set a backfill target per source. Each scheduled
run pages backwards from a checkpoint for at most 20s so real-time
crawling is not blocked. The checkpoint is saved only after a successful
run and is also kept in process memory, because the next trigger may be
queued before the database write lands. cls_depth is excluded since its
list API cannot page into history.
2026-10-13 14:58:48 +08:00
eezd 0831971e83 Add default USD-M perpetual BTC/ETH/BNB and fix futures WS stream
Seed um BTCUSDT/ETHUSDT/BNBUSDT as default symbols. The legacy futures
route fstream.binance.com/stream accepts connections but no longer pushes
data, so switch to /market/stream. Receive with a timeout so symbol
changes are picked up and silent connections are reconnected.
2026-10-13 14:10:18 +08:00
eezd 554d224be2 Harden background loops and API edge cases from code review
- crawler manager: retry transient errors inside each loop, never let
  log writes break supervision, run tasks in a TaskGroup so any escaped
  error restarts the container instead of leaving a half-dead process
- market worker: tolerate symbols deleted mid-backfill, retry task
  selection and symbol queries, run loops in a TaskGroup
- market WS: validate subscription messages and close the connection
  when either the receive or forward side ends
- news pipeline: make first insert concurrency-safe with ON CONFLICT
- market API: only proxy ticker/1s klines for added symbols, map Binance
  rate limits to 503 and upstream errors to 502 without blocking
- news API: escape LIKE wildcards in search, return 422 for bad cursors
- market page: cancel pending reconnect timer on unmount
2026-10-13 13:51:00 +08:00
eezd aabc81ba5b Initial AlphaPulse implementation: news crawler and Binance klines
- Backend (FastAPI, SQLAlchemy 2, Alembic): single-admin cookie auth,
  news/crawler/market APIs with SSE and WebSocket streaming
- Crawler (Scrapy + Scrapy-Redis): wscn_news, wscn_live, cls_depth,
  cls_telegraph spiders, idempotent upserts with revisions, raw response
  archiving, per-source subprocess supervision, restart and backoff
- Market worker: full-history Binance spot/USD-M kline backfill,
  realtime WS stream, hourly and on-reconnect catch-up
- Frontend (Vue 3, Element Plus, UnoCSS, KLineChart): news feed,
  crawler console with live logs, Binance-style chart page
- Deploy: docker compose, nginx site, migrate and daily backup scripts
2026-10-13 13:32:55 +08:00