Commit Graph

213 Commits

Author SHA1 Message Date
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
dekun c6c6c3fe83 Replace K-line SMA with configurable EMA periods.
Default to EMA 21/55 with editable period inputs and localStorage persistence on the market chart.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 23:17:18 +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 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