Commit Graph

192 Commits

Author SHA1 Message Date
dekun ee7be3e7f3 Align options realtime PnL with bid-net and show totals in stats.
Header float PnL now uses bid recycle minus premium like position cards. Stats adds realized/open/total net PnL.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-15 22:00:45 +08:00
dekun 1909eea654 Use bid1-only option closes with hard-disabled market exits.
Manual close checks liquidity only; target auto still requires 2x recycle hold once, then reuses the shared bid1 executor. Add /options/guide doc and update hedge-plan refs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-15 21:49:06 +08:00
dekun ab8b2a74e2 Show cancellable pending option orders beside the order form.
Fetch live OKX option hangs on the right after submit, with refresh and one-click cancel.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-15 21:22:29 +08:00
dekun c2a0cea3f4 Gate option closes behind 2x recycle sustained for 2 minutes.
Require bid-side recoverable premium at least 2x cost continuously before target auto-close or depth close can fire.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-15 21:13:43 +08:00
dekun c025c06fac Block option auto-close on stub bids far below mark.
Reject target and depth closes when bid is a residual tick, and show invalid-bid UI instead of recycling at junk prices.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-15 21:05:54 +08:00
dekun e15eca76f3 Show option net P/L from bid recycle minus premium.
Rename floating P/L to net P/L, align ROI, and display bid depth as price/liquidity for only the levels needed to close.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-15 20:54:15 +08:00
dekun da3975e42e Fix BTC option prices losing trailing zeros in display.
Integer tick formatting was stripping zeros (1370 -> 137), so hedge-plan quotes looked wrong versus the options list.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-15 17:12:33 +08:00
dekun 142b6de0f6 Stop repeat WeChat alerts on option target closes.
Commit monitor status before notify, and use a closing state so unfilled limits retry silently instead of re-alerting.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-15 16:45:43 +08:00
dekun 944a211e4a Keep draft target input across position refresh until set.
Polling was re-rendering cards and wiping the field before 设定; drafts and focus are now restored.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-15 16:10:09 +08:00
dekun 0bedb2e972 Clear target input after set and show estimated value/profit.
Position委托 row keeps the field empty for new entry and displays target value plus estimated PnL after arming.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-15 16:05:54 +08:00
dekun 61f63c456b Use bid-only limit closes when option index targets hit.
Target price is only for monitoring; auto flat waits for 买一 instead of falling back to mark.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-15 15:53:08 +08:00
dekun 280e59eb25 Cancel pending option sells before target auto-close.
Prevents duplicate sells from stacking into short opens when the bid book is empty and mark fallback retries.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-15 15:45:36 +08:00
dekun bcb229fc9d Fix option close reduceOnly flag and use position mark when quote has no bid.
OKX expects reduceOnly as the string true; target auto-close also falls back to the live position mark price on empty books.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-15 15:43:19 +08:00
dekun cfc1d42c09 Fall back to mark price when option target close has no bid depth.
Keeps auto limit-close workable on thin books instead of stalling after the index target is hit.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-15 15:37:55 +08:00
dekun d6823a2903 Add options index target monitors that auto limit-close on hit.
Position and order forms can arm a target; right-side and hub panels show active monitors; expiry remains the stop with no separate SL.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-15 15:27:46 +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 8ecc70a61c Support dual breakout targets for options-options hedges.
Replace single S* with up/down targets across UI, preview, persist, monitor, and alerts so ranging breakouts can close the winner either way.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-14 14:32:06 +08:00
dekun f6ef06f659 Add hedge history delete/detail modal and typed stats cards.
History shows contract names with clickable fill details; stats split perp vs options plans for win rate, profit factor, max win/loss, and drawdown.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-14 14:04:48 +08:00
dekun e6907dfbbe Add hedge-plan WeChat start/end alerts and expiry settlement.
Wire idempotent notify on open/close/partial fail, settle OO at expiry, and close orphaned TP option legs without rewriting plan totals.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-14 13:23:32 +08:00
dekun 982497d65a Enable hedge-plan live opens with path validation, DB, and monitor.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-14 13:15:10 +08:00
dekun 5fcf649c79 Move hedge-plan calc actions to second card and add spacing above preview.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-14 13:05:56 +08:00
dekun 8afaea1ea6 Allow entering sheet counts for each options-options hedge leg.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-14 12:59:24 +08:00
dekun 9e0d89bd01 Align hedge-plan perp contract precision with exchange and show TP/SL USDT PnL.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-14 12:49:03 +08:00
dekun 036501b70c Fix hedge-plan option list to 5-row scroll viewport and add auto-deploy rule.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-14 12:43:23 +08:00
dekun 27f4f5e2ee Make hedge-plan dual cards equal width and height.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-14 12:38:19 +08:00
dekun 8d37b2cba3 Compact hedge-plan option list to 5 rows with overflow select.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-14 12:33:30 +08:00
dekun 09cd680e4a Improve hedge-plan option board: moneyness, px/sz, accounts, and denser UI.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-14 12:27:09 +08:00
dekun 4df2cb4253 Switch hedge-plan modes to high-contrast tabs with history/stats placeholders.
EOF

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-14 11:29:50 +08:00
dekun 9e17814e37 Prevent env autofill from overwriting OKX API keys when saving hedge settings.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-14 11:22:28 +08:00
dekun 1fa98425e7 Add OKX hedge-plan P0: env group, preview page, and PnL scenario math.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-14 11:00:15 +08:00
dekun 1bda78ceb2 Fix env save-and-restart by deferring PM2 restart until after HTTP response.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-13 10:54:48 +08:00
dekun c4753ffb89 Fix swap-all balance by reading OKX funding via asset/balances API.
Swap-all targets funding account but ccxt free was often empty; fall back to trading USDT for unified accounts and show balances in errors.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-13 09:01:37 +08:00
dekun c4bac23c48 Parse OKX spot swap errors into friendly Chinese instead of raw JSON.
Map sCode 51008 to a clear insufficient-balance message for the currency exchange UI.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-13 08:54:53 +08:00
dekun 44657e0484 Add confirm dialogs and busy states for swap/transfer all actions.
Use available (free) balances for full-amount ops, support sub-account scope, and show clear success/failure feedback.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-12 09:10:29 +08:00
dekun 5eb9b9f5c5 Force-refresh header balances after transfers and balance SSE events.
Invalidate balance caches on mutation, push SSE balance tick, and bypass 60s cache when refreshing funds.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-12 09:03:15 +08:00
dekun bb53beb22d Hide zero USDT in options balance labels and add swap/transfer all buttons.
Skip 0 balances in header display; fill max funding/trading amount on 全部兑换/全部划转.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-12 08:55:30 +08:00
dekun 551c86264a Fix OKX spot swap tgtCcy and show options trading USDT in header.
OKX requires quote_ccy/base_ccy for market orders; include trading_usdt in balance display and total funds.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-12 08:42:33 +08:00
dekun 04fd84757c Improve light theme contrast on options positions panel.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-11 15:09:02 +08:00
dekun 6f6545ce52 Add T-shaped options chain view with straddle metrics (phase A).
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-11 15:00:50 +08:00
dekun c9c8388250 Improve options order estimates and chain filter defaults.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-11 14:37:53 +08:00
dekun 9f0a30a040 Add hub usage help page with settings nav toggle.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-11 10:02:07 +08:00
dekun 843d87422d Show hub fullscreen options positions as cards matching instance data.
Enrich hub options snapshot with close preview and render read-only option position cards in exchange fullscreen view.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-11 09:40:35 +08:00
dekun baf94b4feb Compute option stats from exchange history instead of local DB.
Share history loading between history and stats APIs so average profit/loss matches the option history tab.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-11 09:34:49 +08:00
dekun 68733eb4f9 Show average profit and loss in option stats panel.
Expose avg_win and avg_loss from stats API and update chart labels and values to match the average-based P/L ratio.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-11 09:29:26 +08:00
dekun bf2d668d3c Fix option history to full closes only, 2-decimal USDC, restore hide-delete.
Filter OKX positions-history to type 2/3/6, format premium and bid recovery to 2 decimals, and allow locally hiding rows via delete button.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-11 09:24:24 +08:00
dekun fdea5bb610 Align option display precision with OKX and use exchange position history.
Format prices by tickSz, move bid depth/recovery to card end with plain styling, and load option history from OKX positions-history instead of local DB.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-11 09:14:43 +08:00
dekun 1b31c61aac Simplify option close depth display.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-11 09:04:17 +08:00
dekun e8a55a0f85 Polish option close depth display.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-11 08:57:19 +08:00
dekun 6e45604d93 Add depth-based option close flow.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-11 08:46:07 +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