Commit Graph
17 Commits
Author SHA1 Message Date
eezd 641351a002 Cancel remaining entries before fetching break-even fees
After the first take-profit fills, cancel outstanding entry orders before calculating remaining-position protection. Missing fee records still fail explicitly and leave existing stops in place without allowing the old entry to remain open.

Cover complete and incomplete fees on Binance and Bybit, including cancellation before the recovery fetch and no duplicate cancellation. Verify the staged snapshot with 61 trading safety and plan tests.
2026-10-26 14:23:51 +08:00
eezd f67a8ca402 Align backend authentication and API response contracts
Replace cookie authentication with revocable Bearer sessions, optional one-use PNG challenges, bounded login limits, and short-lived market WebSocket tickets. Keep captcha disabled by default.

Standardize ordinary JSON responses while preserving HTTP statuses, raw OpenAPI, redirects, SSE, and WebSocket semantics. Revoke long connections with their owning session.

Expose official calendar data and collector status to the frontend and research tools, support bilingual news topics, and keep summaries and forward-only labels explicit. Verify the staged snapshot with all 305 backend tests.
2026-10-26 12:04:21 +08:00
eezd b9d7497a7d Protect remaining positions using actual entry costs
Calculate remaining-position break-even from actual entry fees and estimated closing fees, preserve confirmed tighter stops, and keep existing protection when fill fees are incomplete.

Build historical trade summaries from execution sizing when an acceptance fill has no setup. Clarify unverified price zones and avoid suggesting fabricated structure to satisfy validation.

Verify the staged snapshot with 57 trading safety and plan tests.
2026-10-26 12:03:28 +08:00
eezd 193af01913 Validate reevaluation conditions against their declared timeframe 2026-10-20 18:47:23 +08:00
eezd 285b3952d7 Support selectable demo exchanges and configurable analysis limits
Persist manual requests until exchange confirmation, preserve stop protection, and reconcile fills before settling plans. Tighten model stream, crawler, skill, research accounting, and frontend race handling, with regression coverage. Keep queued analyses pending until a fresh account snapshot is available.
2026-10-20 18:45:00 +08:00
eezd fcaedfb358 Show recent filled plans in the demo analysis prompt
List each plan filled in the last 24 hours with its zone, entry, fill and
close times, close reason and net result, so the model can apply the
skill rules on consecutive stops, re-entry after a stop and the daily
entry cap.
2026-10-17 15:12:10 +08:00
eezd 23a9a5175e Record news signals forward for a no-trade edge test
The trader labels crypto news published after 2026-10-16 15:00 with
the configured model (category and BTC direction) and, four hours
later, backfills BTC/ETH 1m opens at publish, +5m, +1h and +4h from
the klines table. A drawer on the trading page shows the cumulative
returns of trading the labelled direction, after fees. Nothing is
traded; this only collects an out-of-sample record.
2026-10-16 14:47:06 +08:00
eezd 0397e30870 Run demo trading and allocate capital per symbol
Move running, running_changed_at and capital_usdt from the account to
each trading symbol; the migration copies the account capital to every
symbol and leaves them all stopped. Each symbol is sized against its
own capital with a 3x notional cap, and the capitals together must not
exceed account equity. Scheduling, dry-run decisions and the executor
follow the per-symbol flag. The global start/stop button is replaced by
start/stop and capital controls on each symbol's plan card.
2026-10-16 13:44:02 +08:00
eezd e3242f2b7a Add per-symbol close position and clear orders actions to demo trading
The API queues the request in Redis and the executor applies it on its
next pass, so it never races reconciliation. Both actions cancel every
open order on the symbol, including manual ones, and market-close any
position. Plans end as manual_close or manual_cancel without queueing
a new analysis. Closing also stops trading so the engine does not
reopen right away.
2026-10-16 13:25:59 +08:00
eezd 010d89e0f5 Rebuild position history from Binance fills
Sync account fills into a new trading_fills table every 60s and
reconstruct closed positions from them, so positions opened outside
the program are included and external closes get an exit price.
Positions link to plans by order id. The history drawer gains symbol,
close-date, outcome and source filters, a summary bar and pagination.
2026-10-16 11:57:45 +08:00
eezd 665c12fc31 Keep demo stops at least 1 x ATR14(5m) from the limit price
When the limit price sat near the far edge of the zone, the stop beyond
the far edge was well inside normal 5m noise (plan #34: 0.11%). The stop
is now the farther of far edge +/- 0.5 x ATR and entry +/- 1 x ATR.
2026-10-15 17:33:06 +08:00
eezd 250b16b389 Place limit entries as soon as a demo plan is adopted (plan 3.2)
- The model gives a zone and a limit price inside it (below the mark for
  longs, above for shorts); the executor places the GTC limit order with
  the reduce-only stop right away instead of waiting for a 5m
  confirmation and entering at market, so entries pay maker fees
- Stop beyond the far edge of the zone by 0.5 x ATR14(5m), computed with
  the quantity at submission and rejected above 1%
- Unfilled limits are cancelled at expiry; a rejected entry cancels the
  plan instead of being retried every round
2026-10-15 17:13:55 +08:00
eezd 7efa2eb68b Switch demo trading to 5m short-term swing setups (plan 3.1)
- The model now submits a pending setup (direction, zone, confirm price,
  validity); the executor enters at market once a 5m close confirms a
  dip into support or a rejection from resistance, and cancels the setup
  when the zone breaks, the trigger is missed or the stop is too far
- Stop beyond the confirmation extreme by 0.5 x ATR14(5m), skipped above
  1%; fixed take-profit ladders from the fill price (long 60/30/10 at
  +0.5/0.75/1%, short 80/20 at -0.5/0.75%); 4h time stop
- While holding, the model may only keep or exit
- Drop the long-term angle from the program, API, tables and page
2026-10-15 13:09:19 +08:00
eezd 1fcf41952c Add demo trading executor and analysis scheduling (plan 3 C4)
- Executor reconciles each symbol to its desired orders: journaled ap{id}
  client ids, reduce-only quantity stop placed before entries, make-before-
  break stop moves, breakeven after TP1, orphan cancel, -2021 market close
- Plan lifecycle: proposed plans are adopted only if the position is
  unchanged; holding-mode plans may only tighten the stop
- Program rules: time stop, short-term invalidation close, long-term 4h
  review, reevaluate conditions, takeover of unmanaged positions
- Trigger and routine analysis scheduling with a 10 min gap, daily cap and
  bounded retries
- Plan endpoint and plan status, fills and countdowns on the trading page
2026-10-15 11:07:00 +08:00
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 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 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