Commit Graph

223 Commits

Author SHA1 Message Date
dekun a34bcb6bfc Fix test_simnow.py imports for modules layout and config/.env.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-01 14:47:27 +08:00
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 b354d6c701 Document Git-only deploy workflow and reduce positions page IPC blocking.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-01 14:05:37 +08:00
dekun 7748a88219 Fix positions page hang from blocking CTP IPC and SSE lock wait.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-01 13:33:59 +08:00
dekun 5aba31f530 Fix position SSE JSON serialization for datetime fields.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-01 13:27:46 +08:00
dekun 95156ca595 Update docs for CTP worker split and roll breakout off-session.
Refresh DEPLOY, TRADING, STRATEGY, CTP_LIVE, FEATURES, INDEX, and README to document qihuo-ctp architecture, dual PM2 restarts, and休盘突破加仓.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-01 12:56:27 +08:00
dekun 9cd81a3ea7 Isolate CTP in worker process and improve strategy roll UX.
Split vn.py into qihuo-ctp worker with IPC client bridge, keep CTP connected during breaks with cached account fallback, speed up strategy page loads, and allow off-session breakout roll submissions.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-01 12:37:44 +08:00
dekun 08d55411aa Simplify account_risk_state DDL for PostgreSQL compatibility.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-01 08:31:17 +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 06fbff04a7 Ensure account_risk_state table exists even if schema flag was set.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-01 08:25:07 +08:00
dekun ef790c8a80 Fix migration: per-table connections and skip non-serial setval.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-01 08:24:27 +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 e418c2dcec Fix SQLite migration: no app import, commit per table.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-01 08:22:21 +08:00
dekun 1bb0028402 Import rollback_if_postgres in strategy_db for PostgreSQL migrations.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-01 08:21:35 +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 47ee9602d1 Use direct PostgreSQL connections instead of pool to fix init deploy.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-01 08:19:46 +08:00
dekun 843b68b412 Stop PM2 before PostgreSQL init to free connection pool.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-01 08:17:29 +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 1b3a7f1bdc Fix position flicker, drop futures cooloff, prioritize startup display.
Preserve trading state when CTP memory is empty, bootstrap equity/positions on page load, stabilize risk status from DB monitors, and remove app-layer manual close cooling periods.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 23:17:18 +08:00
dekun 2386eca324 Fix stats max profit/loss to use win/loss subsets only.
Corrects misleading breakdown rows and summary max amounts after trade log edits.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 22:28:46 +08:00
dekun d324d30332 Schedule CTP disconnect 30 minutes after day and night session close.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 22:14:39 +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 8d2d09396b Fix missing trade log after manual close when CTP is connected.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 21:23:44 +08:00
dekun e5f264b774 Increase trade calendar cell font sizes for readability. 2026-06-30 12:11:57 +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 d07fc4b70d Prefer CTP PnL-consistent entry when vnpy avg differs from SimNow.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 10:51:16 +08:00
dekun e6208e403e Fix roll average entry: CTP trade-weighted avg, sync after fill, live entry for preview.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 10:42:56 +08:00
dekun 6e954da4e1 Lock CTP entry price from position PnL snapshot; match SimNow avg and float PnL.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 10:36:06 +08:00
dekun 6c68808318 Stop entry price jumping: use fixed CTP position avg, not tick-derived.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 10:10:54 +08:00
dekun fb23ee891c Resolve position average entry from CTP trades and PnL instead of stale monitor cache.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 09:59:02 +08:00
dekun 2f58159372 Fix slow positions and DB lock on fast live refresh by skipping writes.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 09:29:42 +08:00
dekun ec4199b82c Restore stop-loss and take-profit monitors after restart and CTP reconnect.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 09:24:37 +08:00
dekun 963ed141e5 Persist CTP average entry price to monitor DB on every position sync.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 09:22:10 +08:00
dekun f41276806e Sync displayed entry price from CTP exchange position average.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 09:19:27 +08:00
dekun c8fef65de7 Fix float PnL to match displayed entry price and contract multiplier.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 09:14:13 +08:00
dekun 92c222584e Show tablet trade records as close-record table with action column.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 00:12:10 +08:00
dekun a6b3c4a657 Align tablet trade records with close-record layout and row actions.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 00:05:33 +08:00
dekun 21d68f6269 Use compact single-row trade records on tablet with detail modal.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 23:59:02 +08:00
dekun 9dbf6b1f1e Fix position cards, breakeven badge, and tablet equal-height layout.
Stop clipping pos cards and match trailing-BE stop detection for the badge. On tablet, align order and live-trading panels to equal height with internal scroll; keep desktop positions scrollable after three cards.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 23:47:59 +08:00