Commit Graph

83 Commits

Author SHA1 Message Date
dekun e5a586f903 Restructure into modules/ with single-process CTP and config/ layout.
Move business code under modules/, env template to config/, PM2 single qihuo process, and _legacy shims for old imports.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-01 14:42:16 +08:00
dekun cd636ff1c3 Fix account_risk_state missing on PostgreSQL: probe table before cache skip.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-01 08:29:46 +08:00
dekun d7ea7b9e8a Inline account_risk_state DDL in init_db; use autocommit for migration.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-01 08:26:13 +08:00
dekun 6abe06d935 Ensure all PG tables on init; fix migration commits per table.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-01 08:22:54 +08:00
dekun 8e1baf9a73 Commit each schema migration separately on PostgreSQL.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-01 08:20:49 +08:00
dekun 2347276bf4 Fix PostgreSQL schema init: commit DDL before ALTER migrations.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-01 08:15:31 +08:00
dekun 008f042fcc Fix init-only mode for PostgreSQL deploy script imports.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-01 08:14:43 +08:00
dekun a1f22624de Harden PostgreSQL deploy: auto-rollback on SQL errors, clean DB on migrate.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-01 08:13:51 +08:00
dekun bc79ad308c Fix PostgreSQL init_db: rollback after benign schema migration errors.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-01 08:13:14 +08:00
dekun 1b276b5897 Fix PostgreSQL DDL: use single-quoted DEFAULT literals.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-01 08:12:34 +08:00
dekun 52aca456e9 Add PostgreSQL production backend to eliminate SQLite lock contention.
Support DATABASE_URL with connection pooling, pg_dump backups, SQLite migration script, and deploy_postgres.sh with docs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-01 08:11:42 +08:00
dekun 39eac983ff Fix positions and records pages hanging on load.
Stop blocking page render on full trading live rebuild and CTP trade sync; use cached snapshot and background prime instead.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 23:31:13 +08:00
dekun 32838daae0 Align trade record verify/edit UX with Binance instance single-row prompts.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 22:02:48 +08:00
dekun b6b7bfb248 Add close price column to trade records for overnight position PnL review.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 21:51:53 +08:00
dekun 4552f4ef9c Default equity chain baseline to 100k when live_capital unset.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 21:44:15 +08:00
dekun 0b924fca87 Fix trade log equity_after to chain from initial capital by close time.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 21:41:37 +08:00
dekun 726ed7adef Add standalone trade calendar page with solar and lunar dates.
Move calendar from stats to /calendar nav page; show Gregorian and lunar on cells, month title, and day detail.
2026-06-30 12:07:58 +08:00
dekun 8ebad6e8a2 Add stats trading calendar and fix CTP position avg/sync.
Calendar shows daily closed trade count and PnL with emotion-day highlighting; day click loads review-first trade list. Use exchange-only entry average and improve vnpy position sync after CTP reconnect.
2026-06-30 11:59:25 +08:00
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 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 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 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 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 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 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 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 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 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 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
dekun ab9987e4c7 Add personal license agreement and rename product section to tradable symbols.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 02:52:45 +08:00
dekun bdfa21def8 Rename positions nav to order monitor and set as default landing page.
Remove stats recalculate button; login and home now open /positions without affecting refresh on other routes.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 01:51:22 +08:00
dekun 9f48f22d16 Gate order cancel to trading hours and sync trade logs from CTP.
Disable cancel UI outside sessions, query exchange fills for records, and label local vs counterparty rows.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 00:35:51 +08:00
dekun a23f2c80ca Track open orders as pending until CTP fill, with cancel and timeout.
Add configurable pending timeout in settings and clearer CTP password save feedback.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 00:05:45 +08:00
dekun ca541d5fc3 Auto-reconnect CTP with new front-end addresses after saving settings
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-25 17:51:18 +08:00
dekun 259d9e812d fix: CTP登录冷却持久化到数据库,取消页面自动连并刷新JS缓存
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-25 17:01:36 +08:00
dekun 5a6c89c662 feat: CTP/SimNow 配置迁入系统设置,登录失败即时报错
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-25 16:46:01 +08:00
dekun 240fbe7994 feat: 交易记录增加保证金占比与最新资金,上方展示资金曲线
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-25 16:17:22 +08:00
dekun 9772f3d986 feat: 计仓改为固定手数/固定金额,推荐过滤与CTP保证金,下单与持仓UI优化
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-25 15:31:34 +08:00
dekun 4d60b958ce fix: 开仓时间读CTP OpenDate,止盈止损持久化且重启不丢失
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-25 15:05:58 +08:00
dekun f31164076f feat: 非交易时段禁开仓、移动保本与交易结果分类。
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-25 13:33:17 +08:00
dekun fc425c0e9f feat: 品种下拉统一展示推荐列表,与下方品种推荐表一致。
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-25 13:01:20 +08:00
dekun 9875ee6d44 本地监控止盈止损、盘前自动连CTP,并完善保证金与推荐手数。
- 止盈止损改为程序本地监控,触发后市价平仓(含跳空)
- 交易前30分钟后台自动连接 CTP
- 保证金占用上限默认30%,可在系统设置修改
- K线标准蜡烛图红跌绿涨,费率表全宽固定表头
- 品种推荐按保证金比例×总资金计算推荐手数

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-25 12:18:18 +08:00
dekun 049aaffdcf fix: CTP连接改后台异步,避免多路重连互相阻塞
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-24 13:49:25 +08:00
dekun 1d95950b5c fix: 手续费同步改为后台执行,避免阻塞 Web 请求
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-24 13:45:39 +08:00
dekun e01c011df5 feat: 手续费仅CTP每日后台同步入库,前端只读展示
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-24 13:33:14 +08:00
dekun de6815d481 fix: K线新浪历史补齐与手续费页布局及CTP批量同步
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-24 13:26:53 +08:00