Commit Graph

82 Commits

Author SHA1 Message Date
dekun f1da2778ef Add one-expiry-per-day open rhythm gate (default on).
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-01 16:39:32 +08:00
dekun 22c42a19a0 Count exit fees in live/SIM net PnL as entry fee x2.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-01 09:27:41 +08:00
dekun dffcc4eeb9 Show option bid as price/size and option leverage on plan and trades.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-31 16:01:34 +08:00
dekun dffcd77837 Add trade move points; label option UPL price as bid not mark.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-31 15:44:52 +08:00
dekun 8ceb521049 Add WeCom machine name for multi-node push labels.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-30 17:28:32 +08:00
dekun 021b0d0a22 Align emergency option close to OKX: use bid only, never mark.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-30 17:15:38 +08:00
dekun c05478015d Read risk_loss_pct exit base and option lev from strategy settings.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-30 15:03:26 +08:00
dekun 67f22626e9 Show risk params box on control cards and modal.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-30 14:58:30 +08:00
dekun a317822f7a Improve control monitor cards: green when running, detail modal with positions.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-30 11:07:54 +08:00
dekun 08fe06d074 Fix control unauthorized: map strategy 401 to 502 and keep fleet headers on redirect.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-30 10:57:06 +08:00
dekun da5eb4c18c Add Fleet control plane and split manage.sh deploy menu.
Strategy nodes gain fleet token APIs; control/ app for local ops; manage.sh offers strategy vs control one-click deploy.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-30 10:46:40 +08:00
dekun 200702d066 Harden strategy SoT: fail-closed funds gate, shared open pipeline, LIVE switch guards.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-30 01:06:32 +08:00
dekun 4c537e7520 Reset auto USDC cooldown in unit tests for stable assertions.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-30 00:34:36 +08:00
dekun cc0f0ffd0d Run OKX auto USDC convert before option pick when trading USDC is short.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-30 00:28:11 +08:00
dekun a9939bbbdd Route manual USDT/USDC convert through trading account (not funding).
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-30 00:23:16 +08:00
dekun 0837982714 Add OKX trading-account USDC auto-swap and lock exit target while in position.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-30 00:16:47 +08:00
dekun 5eb169a636 Show live risk-sizing estimate on plan page instead of stale manual qty.
When 以损定仓 is on, state() overlays next-open k/qty/exit from market preview.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-29 23:52:43 +08:00
dekun a47a9b6377 Polish risk sizing: 2dp money preview, editable ratio/exit, plan badge.
Exit unit and perp/option units scale with k; plan page shows 以损定仓.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-29 23:48:34 +08:00
dekun 3a4c8d639c Add risk-based position sizing (以损定仓) with per-open k resize.
Manual vs risk modes are exclusive; each open floors k to 1 decimal so estimated premium+fees stay within the loss budget.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-29 23:32:42 +08:00
dekun 101cb3c045 Fix ghost finalize on unknown perp size and open rollback hazards.
Distinguish exchange query None from flat zero; keep opening when size unknown; idempotent half_open cash; scan options while opening; continue manage after recover.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-29 20:47:29 +08:00
dekun e2a19a1614 Recover stuck opening and harden LIVE open/close reconcile.
Stamp open intent, recover opening from exchange option/perp state, skip resell/reopen when already flat, and persist Binance margin mode.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-29 20:32:45 +08:00
dekun 44fd0371b9 Fix OKX abandon residual double-book and fill/residual ledger holes.
After dual-close leaves option pending, continue close_group instead of false residual; reject partial fills on wait timeout; LIVE residual settle allow_negative.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-29 20:20:36 +08:00
dekun ec87cf2104 Fix LIVE open/close double-book and security audit findings.
Prevent expiry dual-close from re-booking option cash, abandon ledger rejection, margin-mode mismatch, and manual close races; harden fill wait and refuse default AUTH_SECRET on LIVE.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-29 20:11:29 +08:00
dekun c6e8f6fe1e Support LIVE exchange funds and perp margin mode.
Hide sim equity when LIVE is selected; OKX funds bar uses exchange balances; add cross/isolated for perp only (options stay cash).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-29 19:57:09 +08:00
dekun 0ee1d8be5d Add fixed-direction switch for perp/option open side.
When enabled, lock perp long→buy Put or short→buy Call with ITM/ATM only; off keeps ATM/ask rules.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-29 19:18:12 +08:00
dekun 55109e82d3 Hide SIM label in WeCom; count completed rounds from closed groups.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-29 18:15:09 +08:00
dekun 71b5fcae79 Show strategy rules in fold; larger nav; notify only when cannot open.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-29 18:12:26 +08:00
dekun a5945f0837 Notify funds short once; check trading only; drop duplicate plan title.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-29 18:07:59 +08:00
dekun 81e51236c0 Align funds to OKX funding/trading only; fold rules; match settings width.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-29 17:59:28 +08:00
dekun 80c561bdce Show open-capacity labels, enlarge funds, move rules; WeCom on short funds.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-29 17:53:43 +08:00
dekun f49365b4d4 Constrain funds bar width and fold strategy rules.
Match page max-width on ultrawide and move the plan subtitle into a collapsible rules section under the funds strip.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-29 17:37:34 +08:00
dekun 5c3bd4b654 Add OKX-style funds bar with USDT/USDC convert and transfer.
SIM uses multi-wallet balances; LIVE hits OKX asset/account APIs and spot USDC-USDT swap. Funds strip hides sim labeling.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-29 17:06:13 +08:00
dekun 1c75db4a19 Split fee stats by leg and hide LIVE slip.
SIM shows perp/option fees and slip separately; LIVE keeps real exchange fees only with slip forced to zero.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-29 16:37:18 +08:00
dekun 8518a207a7 Show expiry settlement as index vs strike intrinsic.
Persist settle_index_px and surface formula in trade detail so expiry closes are not mistaken for book fills.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-29 16:15:22 +08:00
dekun 3df64aeb2d Show open time and hold duration on position cards.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-29 15:41:56 +08:00
dekun 70a294c948 Restore hold_timing open-position unit test.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-27 15:42:10 +08:00
dekun 3d7c453bd1 Fix trades API 500 by supporting sqlite Row in hold timing.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-27 15:41:27 +08:00
dekun 14c6ba51a8 Show trade open/close times and hold period by target exit.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-27 15:37:37 +08:00
dekun 56a4007130 Add WeCom markdown alerts and keep target exits while strategy is paused.
Notify open/close/start/pause/fault with SIM vs LIVE venue labels; configure webhook in Settings.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-26 23:19:39 +08:00
dekun 2b348854fe Add DB+.env auto backup with download and upload restore in Settings.
Backups land under /root/eth_hedge_backups; restore accepts zip body for new-server migration and restarts the process.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-26 23:05:58 +08:00
dekun 9d3b36826c Include LIVE close-fee estimate in target PnL; rest after manual and emergency close.
Align docs so LIVE exit matches SIM fee buffer; manual full close now enters rest_seconds like auto/emergency.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-26 22:58:10 +08:00
dekun 16efa44ffb Hide manual trade by default, block open while running, auto-refresh auth token.
Also fix flat-side reconcile to check both long and short residuals; document in 更新说明.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-26 22:43:38 +08:00
dekun 0cf3756b09 Harden LIVE opens with slot claim and exchange reconcile.
Prevent duplicate opens by atomically claiming an opening slot, verifying exchange perp is flat before live orders, setting leverage from ledger, and preferring exchange position size when closing perps.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-26 22:39:27 +08:00
dekun f48ea5bbcc Audit fixes: LIVE symbols/fills/expiry/pending, security harden, add 更新说明.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-26 22:28:03 +08:00
dekun 86d3c94f32 Rebrand to 比特骆驼自动化对冲系统; clear login autofill and sim subtitle.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-26 22:02:09 +08:00
dekun cb97a45051 Add PWA install badge for desktop and tablet (manifest, SW, Add to Home Screen).
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-26 21:57:39 +08:00
dekun ca66c494e7 Use exchange fees, UPL, funding for LIVE PnL; USDC 1:1 to USDT.
Option open P&L stays local (option net); exit target ignores estimated close fees.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-26 21:49:20 +08:00
dekun dbc86a1ce6 Add Binance live trading, anti-stuck open/close recovery, and configurable rate limits.
OKX/Binance LIVE share half_open and option_closed_perp_pending repair paths; private REST throttles default to 1s and are tunable in settings.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-26 21:35:10 +08:00
dekun e666230d0b Add SIM/LIVE switch with API keys saved to .env and OKX live executor.
Enable settings UI for mode/keys, gate strategy start when LIVE is not ready, and stop PM2 from forcing MODE=SIM.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-26 21:08:39 +08:00
dekun 38ffbf728b Pin market watch to held option strike while a position is open.
Stop falling back to ATM quotes for unrealized/close PnL after ATM drifts or restart.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-26 18:37:20 +08:00