How guling-pro/guling-trader works
guling-trader is a Windows desktop trading bridge: an AI client sends MCP tool requests through a relay to the running app, which dispatches them to automate the logged-in 同花顺 xiadan client and returns structured results. The app also exposes account, order, settlement, and watchlist queries; watches order and watchlist changes; manages pairing and local settings; and supports OCR setup and self-updating. Relationships are limited to README-documented flows and source-index references or shown excerpts; unsampled subsystem details are not inferred.
Main entry points: main.py App startup · ws_client.py WebSocket client · dispatcher.py Tool dispatcher · win.py THS automation
Components 26
Desktop app
- App startup
src/trader/main.py - Main window
src/trader/main_window.py - System tray
src/trader/tray.py - Local config
src/trader/config.py - Brand/version
src/trader/brand.py
Pairing and RPC
- WebSocket client
src/trader/ws_client.py - Pairing handshake
src/trader/handshake.py - Tool dispatcher
src/trader/dispatcher.py - Reply contract
src/trader/contract.py
Trading runtime
- THS automation
src/trader/ths/win.py - Dialog sentry
src/trader/ths/dialogs.py - Row normalization
src/trader/ths/rows.py - Order ledger
src/trader/order_ledger.py - Order watcher
src/trader/order_watch.py - Watchlist watcher
src/trader/watchlist_watch.py - THS constants
src/trader/ths/const.py
Setup and updates
- THS installer
src/trader/installer/auto_install.py - THS detection
src/trader/installer/detect.py - Download helper
src/trader/installer/download.py - OCR installer
src/trader/installer/tesseract.py - Update checker
src/trader/selfupdate/check.py - Update applier
src/trader/selfupdate/apply.py
Other components
- User
- AI client
- MCP relay
- 同花顺 xiadan
Connections 32
- User → AI client: requests trades
README.md - AI client → MCP relay: sends MCP calls
README.md - MCP relay → WebSocket client: relays frames
README.md - App startup → WebSocket client: starts client
src/trader/main.py - WebSocket client → Pairing handshake: performs handshake
src/trader/ws_client.py - WebSocket client → Tool dispatcher: dispatches calls
src/trader/ws_client.py - Tool dispatcher → Reply contract: builds replies
src/trader/dispatcher.py - Tool dispatcher → THS automation: invokes tools
src/trader/dispatcher.py - Tool dispatcher → Order ledger: records orders
src/trader/dispatcher.py - Tool dispatcher → Row normalization: uses normalization
src/trader/dispatcher.py - THS automation → 同花顺 xiadan: automates trades
README.md - THS automation → Dialog sentry: handles dialogs
src/trader/ths/win.py - THS automation → Row normalization: normalizes tables
src/trader/ths/win.py - THS automation → Order ledger: checks order records
src/trader/ths/win.py - Dialog sentry → THS constants: uses dialog rules
src/trader/ths/dialogs.py - App startup → Order watcher: starts watcher
src/trader/main.py - App startup → Watchlist watcher: starts watcher
src/trader/main.py - Order watcher → WebSocket client: sends order events
src/trader/main.py - Watchlist watcher → WebSocket client: sends watchlist events
src/trader/main.py - App startup → Main window: runs interface
src/trader/main.py - App startup → System tray: starts tray
src/trader/main.py - Main window → Local config: reads settings
src/trader/main_window.py - System tray → WebSocket client: controls connection
src/trader/tray.py - App startup → Local config: loads settings
src/trader/main.py - App startup → THS installer: runs setup
src/trader/main.py - THS installer → THS detection: checks installation
src/trader/installer/auto_install.py - THS installer → Download helper: downloads installer
src/trader/installer/auto_install.py - App startup → OCR installer: sets up OCR
src/trader/main.py - App startup → Update checker: checks releases
src/trader/main.py - App startup → Update applier: applies updates
src/trader/main.py - Update applier → Download helper: downloads update
src/trader/selfupdate/apply.py - Main window → Brand/version: shows version
src/trader/main_window.py