Commit Graph

251 Commits

Author SHA1 Message Date
dekun 245b85ad27 feat(instance): add exchange account ledger tab with SSE sync
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-10 09:51:45 +08:00
dekun d41028b766 Fix dashboard PnL using spot contract size of 1.
Prefer perpetual symbols and normalize before market.contractSize lookup so Gate BTC float matches ~0.4U not thousands.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-06 14:20:43 +08:00
dekun 75a4175522 Fix instance dashboard order PnL columns showing empty dashes.
Compute float_pnl and tp_profit from mark/entry/contracts using each exchange contract size during dashboard enrich.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-06 14:12:57 +08:00
dekun 7f22bffbc6 Shorten force-close window to 5m and grey-out open during blocks.
Unify Gate/OKX/Binance: disable the open button with a side note during force-close, cooloff, and daily freeze, and enforce the same gate server-side.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-06 08:38:00 +08:00
dekun f6ea0dc399 Add all-time stats tab with monthly breakdown on instance analytics.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-01 09:49:47 +08:00
dekun a00699aec3 Fix TP/SL exit classification when exchange fill slips past the tight band.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-01 09:38:28 +08:00
dekun a7b75895e6 Preserve settings transfer sub-tab after manual transfer in embed shell.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-26 08:37:26 +08:00
dekun 7ebe1671b2 Keep settings on transfer tab after manual USDT transfer redirect.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-26 08:27:15 +08:00
dekun cb4f6aaa4b Normalize TRANSFER_CCY to uppercase so Gate wallet transfers do not fail.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-26 08:24:26 +08:00
dekun 301a464f29 Add daily loss-count freeze for account risk cooldown.
RISK_DAILY_LOSS_LIMIT (default 2, 0 disables) freezes new opens after N losing closes in the trading day.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-21 22:13:38 +08:00
dekun 1bc12a32c6 Sync exchange PnL when hub loads trade records API.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-21 09:40:42 +08:00
dekun 5e0ce43415 Add instance system guide nav (default off) with overview/options/hedge manual.
EOF

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-19 09:23:30 +08:00
dekun faf21da955 Show trade record prices at exchange tick precision.
API enriches entry/SL/TP with price_to_precision display strings; OKX formatter now uses the same path as Gate/Binance.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-18 15:41:49 +08:00
dekun 8f4ae8ad31 Speed up journal save with AJAX and async K-line charts.
Defer exchange chart generation to a background thread and save via XHR so fill-from-trade no longer blocks on full page reload.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-18 15:15:24 +08:00
dekun 173f09300b Align instance dashboard with hub snapshot+SSE pattern.
Background poll builds a memory snapshot; the page reads snapshot and refreshes on SSE instead of hitting heavy exchange APIs on each load.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-17 22:00:30 +08:00
dekun 53e55aa4b4 Redirect Gate and Binance page routes into the embed shell like OKX.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-17 19:36:39 +08:00
dekun 2269bc51ff Deduct round-trip taker fees from estimated perp PnL.
Unify hub/instance TP profit, calc_pnl, and push/accounting to net of 0.05% per side; leave exchange floating PnL unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-17 15:12:52 +08:00
dekun f27b4bc1ec Fix OKX header trade stats stuck at zero after settings shell load.
Always SSR records summary on embed shell (including settings/risk/env), and refresh total/win-rate/PL ratio via account_snapshot so soft-nav cannot leave the strip blank.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-17 13:03:04 +08:00
dekun c7aae67881 Add instance data dashboard (default off).
Read-only overview of live orders, key monitors, and strategy; show options/hedge only when present. Toggle via system settings nav prefs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-17 12:09:29 +08:00
dekun f7ba7c2f7d Auto-fill journal direction from trade records.
Add a required direction field on the review form, persist it, and set long/short when clicking 填入复盘.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-17 12:00:09 +08:00
dekun d9b8069906 Add shared records review pagination for all three exchanges.
Paginate trade records, journals, and AI history at 5 per page with soft in-card flips; hide the journal form until 填入复盘.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-17 11:52:02 +08:00
dekun 19a4a5194d Use per-exchange PWA names and logos for instance app installs.
Show Binance/OKX/Gate 交易系统 with distinct exchange icons in manifests, apple titles, and login branding.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-16 08:44:07 +08:00
dekun ec30a3999c Fix exchange display names polluted by shared PM2 env.
Require EXCHANGE_DISPLAY_NAME in each instance .env.example and restart with --update-env so Binance/Gate no longer inherit OKX.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-15 16:30:44 +08:00
dekun 1e765f4b2b Silence Flask access logs and retain PM2 logs for 3 days.
Stop werkzeug request spam into PM2 error files, truncate oversized logs, and install daily logrotate with 3-day retention.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-15 07:53:19 +08:00
dekun 02472f19cb Fix breakeven badge still showing after roll lowers stop loss.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-10 16:52:29 +08:00
dekun 23ba725c89 Fix intraday profit amount and hide TP/SL cancel for day trades.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-09 09:55:09 +08:00
dekun d3a44b23db Split journal order type from entry reason and fix review edit toggle in embed shell.
Adds order_type to journal uploads, removes legacy swing/trend labels from entry reason options, and ensures review-edit buttons sync when the records tab loads dynamically.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-09 09:27:03 +08:00
dekun b733e551a0 Normalize fullwidth punctuation to ASCII across codebase.
Add scripts/normalize_ambiguous_unicode.py; fix corrupted patch_instance_theme_templates.py. Preserves curly quotes in string literals; removes Git homoglyph warnings on .env.example.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-08 23:42:26 +08:00
dekun d339971c26 Fix env config UI to show runtime defaults when keys are missing from .env.
Account risk fields now match the risk policy page; uncomment RISK_* defaults in .env.example.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-08 21:54:47 +08:00
dekun 1ee9eb02c3 Add settings page tabs and show env API keys with last four digits.
System settings now use the same CSS tab layout as env config; sensitive env fields display masked values from .env while keeping save-on-empty behavior.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-08 21:31:14 +08:00
dekun aa966114b1 Fix settings and env config stuck on loading via SSR form render
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-08 20:24:15 +08:00
dekun ef4b2f17ca Add instance nav prefs, env config UI, and PM2 restart.
P1-P4: configurable nav/section visibility in system settings, full .env editor with restart badges, password change, runtime hot overrides, and single-instance pm2 restart. Works in hub embed iframe.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-08 20:07:06 +08:00
dekun d84a265b67 Split risk policy into its own navigation tab.
Move read-only risk control docs to /risk_policy before settings; keep transfers and exports on the settings page.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-08 19:42:29 +08:00
dekun e3e53ff7f5 Fix roll position display: live contracts, TP profit, and 2-decimal qty precision.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-08 17:06:33 +08:00
dekun f5f302b97e Add month/quarter/half-year/all list window presets with this month as default.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-08 11:22:29 +08:00
dekun 6571fc9029 fix: enable threaded Flask on binance/gate for SSE embed live push
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-07 11:24:17 +08:00
dekun 814fe67a21 feat: expand header stats with total funds and profit-loss ratio
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-07 02:14:18 +08:00
dekun 659c0969fe fix: show header realtime PnL from exchange positions and order metrics
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-07 02:04:40 +08:00
dekun 6547029a89 feat: compact instance toolbar, stats strip and settings two-column layout
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-07 01:37:19 +08:00
dekun d87081205d feat: instance system settings page with risk docs, export and transfer
顶栏新增系统设置;风控说明读取 .env;数据导出与资金划转迁入三张卡片;顶栏移除导出条与手动划转。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-07 01:26:38 +08:00
dekun 2a3d264c8f fix: allow force-close in trade review and hide strategy nav for intraday
统计核对结果允许强制清仓;日内户顶栏隐藏策略交易与策略交易记录。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-07 01:01:57 +08:00
dekun 5a0d18cf99 feat: add force-close exit trigger and round journal real RR to 2dp
复盘离场触发增加强制清仓;填入复盘与自动计算实际盈亏比保留两位小数。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-07 00:40:55 +08:00
dekun 1092816359 feat: review entry reason picker uses dropdown instead of prompt
Add modal select for trade record review, expand options to two-level labels (反转/启动A), and accept legacy short labels on save.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-07 00:38:16 +08:00
dekun f580e4542d feat: show entry type as category/subtype (反转/启动A)
Format持仓与交易记录开仓类型为两级展示;新平仓写入与旧短标签自动展开。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-07 00:27:53 +08:00
dekun 99eb16dbd8 fix: Gate force-close badge and classify midnight closes correctly
Narrow executing window to 15 minutes after the hour, show countdown when flat, run force_close before reconcile, and map 00:00 synced closes to 强制清仓 instead of 手动平仓.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-07 00:23:40 +08:00
dekun d520ba6904 fix: OKX manual orders save entry_model for trade record 开仓类型
OKX add_order omitted entry_model on insert; align with Binance/Gate and add trade_style fallback when resolving entry_reason for close and display.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-07 00:15:22 +08:00
dekun d3753f1aee Fix Gate price_snapshot 500: define FUNDS_DECIMALS
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-06 22:27:58 +08:00
dekun 8e1492e4f0 Fix mark/PnL display fallback and intraday entry labels
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-06 22:19:42 +08:00
dekun d4a76f05d2 Fix Gate mark/PnL/TP-SL snapshot and intraday order UI
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-06 22:04:19 +08:00
dekun 8b069294b7 refactor: unify three-exchange instance UI with shared templates
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-06 02:43:24 +08:00