Commit Graph

172 Commits

Author SHA1 Message Date
dekun 2f5b5c4aae Fix dashboard mobile load issues and simplify card layout.
Reduce poll pressure on phone/tablet, cache key prices, and handle live API errors gracefully. Rework mobile position and close cards with inline direction, compact P/L line, and detail modal.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 23:10:20 +08:00
dekun d1ad0f9253 Improve dashboard responsive layout, collapsible risk section, and breakeven badge.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 22:50:48 +08:00
dekun 8b4b1a875c Fix composite margin ratio cap at 50% and add risk guide page with nav toggle.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 22:29:13 +08:00
dekun 9a10ac8a51 Improve dashboard risk card styling, colors, and add risk control docs.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 22:14:11 +08:00
dekun d8c6428eb5 Enhance dashboard with exchange labels, split SL/TP columns, and daily risk limits.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 22:04:44 +08:00
dekun b460c6c4e5 Enhance dashboard with contract symbols and risk control overview.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 21:40:53 +08:00
dekun 28c54b1a3f Add real-time data dashboard with account, positions, keys, and closes.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 21:30:33 +08:00
dekun df79017b30 Stream real-time position quotes via tick-driven SSE with incremental UI updates.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 21:14:41 +08:00
dekun 94c566fbe5 Allow scheduled CTP connect when auto-connect setting is off.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 20:38:30 +08:00
dekun c5262a0a54 Add responsive mobile layout, records cards, and tablet settings fold fix.
Mobile gets compact trade/records UI with detail modals; static assets are cache-busted and settings cards fold correctly on tablet grid layout.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 16:42:38 +08:00
dekun 44bec23296 Add futures roll strategy with breakout monitoring and fixed-amount sizing.
Replace percent-based risk with system fixed amount, support market/breakout add modes only, allow pending submission outside trading hours, and fix short breakout geometry plus route registration.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 12:05:21 +08:00
dekun 7ce59d2d71 Detect 10:15-10:30 morning break in trading session clock.
Split day session into 9:00-10:15 and 10:30-11:30; show 上午休盘 status and countdown to 10:30 reopen.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 10:27:21 +08:00
dekun 19676943d0 Align margin display with CTP counter rates and position margin.
Read margin ratios from CTP instrument query and margin-rate API instead of vnpy ContractData (which lacks ratios). Keep occupied margin on position UseMargin; use per-lot max rate for recommend table.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 10:21:44 +08:00
dekun 71c480a587 Deduct open position margin from recommend max lots.
Recalculate tradable symbol budgets from remaining margin after CTP usage and refresh the table on position updates.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 09:39:42 +08:00
dekun fd2dba22fd Add trailing BE to SL/TP dialog and speed up position refresh.
Use modal for monitor upsert with trailing checkbox, refresh CTP tick every second, and push full snapshot after orders.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 09:32:56 +08:00
dekun d366344b0f Fix trailing break-even stop loss not linked to CTP positions.
Match pending monitors to filled positions, reconcile pending on fast refresh, and refresh CTP before promote.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 09:26:54 +08:00
dekun 45ae57ed43 Fix lot preview crash and improve key monitor WeChat alerts.
Unpack margin_one_lot correctly for fixed-amount sizing, use exchange klines for breakout detection, and notify on pending auto orders.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 09:21:27 +08:00
dekun b02c9d6ca0 Fix empty recommend list and CTP premarket auto-connect.
Correct main_code order in product refresh, refresh on CTP connect, and limit reconnect to trading or premarket windows.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 08:24:10 +08:00
dekun f8ff97f93d Add collapsible rule descriptions to trade, strategy, and key pages.
Shared module-rules styling; key monitor rules collapsed by default like other modules.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 07:46:58 +08:00
dekun 4d2463c9a9 Show Tonghuashun symbol meta inline after the variety label.
Move symbol-selected into the label row across all symbol pickers without shifting the input field.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 07:34:05 +08:00
dekun bfb1b95471 Improve key monitor form with bar period, box direction, and labeled fields.
Match order-monitor layout; persist bar_period and enforce upper-direction filter for box breakouts.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 07:24:36 +08:00
dekun 169136dd4a Add modular docs with index, WeChat templates, and AI guide.
Document per-module order logic, risk rules, and WeChat message templates with a central INDEX for navigation.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-28 10:49:10 +08:00
dekun 840e88daad Add key-level auto trade, AI analysis, and trading UX improvements.
Key monitors use 5m close triggers with WeChat alerts and box/convergence auto orders; add pending-order worker, structured WeChat notify, AI settings/messages, session clock, CTP margin sizing, and dual-layer position limits.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-28 10:36:56 +08:00
dekun 0109b59f27 Use 100k equity for recommend list when CTP is offline.
When SimNow or live CTP is disconnected, the tradable-products section shows four whitelisted symbols and calculates max lots from a fixed 100,000 capital instead of reference capital in settings.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-28 09:16:22 +08:00
dekun e18d5feb72 Apply 200k scope when CTP offline; trailing breakeven order UX.
When SimNow or live CTP is disconnected, default to the four-product whitelist regardless of reference capital. Trailing breakeven defaults off; when enabled hide take-profit and risk-reward, monitor exits via trailing stop only. Document both behaviors in TRADING.md and FEATURES.md.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-27 23:57:11 +08:00
dekun 4f4c4bb9fc Fix missing recommend_payload import; raise small-account cap to 200k.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-27 23:27:19 +08:00
dekun 7bb80ba538 Limit tradable products to four varieties for accounts at or below 100k.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-27 23:18:27 +08:00
dekun 24190bf679 Add period selector and crypto-style trend plan preview table.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 22:52:47 +08:00
dekun d3b92de703 Fix trend strategy symbol input clearing on every keystroke.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 22:40:33 +08:00
dekun 69cf94d1df Fix symbol dropdown broken by JS syntax error in symbol.js.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 22:31:46 +08:00
dekun 7f8b4cfefd Label night-session products and hide day-only symbols at night.
Mark tradable varieties with a night tag; during 21:00-02:30 filter out index futures and other products without night sessions from symbol picker and recommend list.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 22:27:47 +08:00
dekun f2940d41e9 Fix stale pending orders after CTP rejection or cancel.
When the exchange rejects or cancels an order, close local pending monitors once the order leaves CTP active list instead of waiting for the full timeout.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 22:21:15 +08:00
dekun fd49b08c08 Disable turbo client navigation to fix broken page layouts.
Turbo swapping broke page CSS/JS across stats, settings, market, and trade. Restore full page loads; keep external base.css and link prefetch.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 22:05:04 +08:00
dekun 9613fb0737 Fix turbo nav for settings and stats pages.
Extract settings.js, preserve inline scripts from raw HTML (DOMParser strips them), and load trade config via JSON script tag.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 21:26:15 +08:00
dekun 6d55a54946 Fix turbo nav layout flash and stats page not loading.
Wait for page CSS before swapping content, hoist inline styles to head, and boot page scripts immediately when DOM markers exist.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 20:55:36 +08:00
dekun c79bb2ea4b Speed up top nav with turbo routing and external base CSS.
Remove view-transition lag, swap main content without full reload, prefetch pages, and tear down SSE timers on leave.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 20:47:22 +08:00
dekun ddfe2a52aa Merge orders and positions into one card and hide stale pending when CTP is off.
Stop showing DB pending orders while disconnected, invalidate session cache when CTP is down, and add a local DB clear script without embedded credentials.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 19:27:02 +08:00
dekun 631aa2c0ab Add CTP auto-connect toggle to stop off-hours reconnect attempts.
When disabled, disconnect immediately and skip auto-reconnect, premarket connect, and TCP probes that fail outside SimNow trading hours.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 18:53:49 +08:00
dekun 3a150dd3d6 Implement CTP-authoritative trading UI with event-driven state.
Add in-memory order/position books fed by CTP events, split active orders above positions in the UI, tick-triggered local SL/TP, and 30-second full calibration.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 18:12:11 +08:00
dekun 4ef33a367f Fix CTP exchange routing for non-SHFE contracts and duplicate trade closes.
Resolve CZCE/DCE symbols to the correct exchange for orders, dedupe stop-loss closes and trade logs, and rely on CTP sync for authoritative records.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 14:06:49 +08:00
dekun 382a9a0e14 Use Sina-only market K-lines and editable admin login synced to .env.
Market page uses Sina for quotes and bars with an auto-follow toggle and incremental chart updates while panning. Settings lets users change username and password, persisting to the database and .env.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 13:53:12 +08:00
dekun 6905373401 Make settings cards collapsible and tighten backup layout.
All settings sections fold by default with persisted state; backup and password sit in one compact row.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 13:10:43 +08:00
dekun 98239d29c1 Add automatic database backup with download and restore docs.
Back up futures.db and uploads to /root/qihuo_backup on a daily schedule, expose backup downloads in settings, and document cross-server restore.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 13:04:48 +08:00
dekun 508d85a282 Fix SQLite lock errors on /api/stats under concurrent writes.
Retry stats cache commits, serialize refresh, and fall back to read-only compute so the stats API does not return 500 when the database is briefly locked.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 12:23:33 +08:00
dekun d3955309d9 Persist CTP margin, ratio, and fees to DB; use exchange commission in trade logs.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 11:36:56 +08:00
dekun 9a55c61678 Align position margin with account balance and show deducted open commission only.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 11:26:41 +08:00
dekun 038eb9a403 Use CTP contract margin rates for position margin and ratio display.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 11:14:01 +08:00
dekun 7a4a3f08e5 Fix slow CTP position sync after restart and link positions to 15m K-line.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 11:05:13 +08:00
dekun deb9501cbe Show product name, main contract badge, and exchange on position cards.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 10:55:37 +08:00
dekun 42f2dad52a Remove contract profile from navigation and retire its routes.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 03:32:30 +08:00