$ show timercrack/trader
This repository is a Chinese futures algorithmic trading system centered on the CTP (Commodity Trading Platform) native protocol. It comprises a C++ pybind11 bridge for low-latency market data and order execution, Python trading strategies (e.g., channel breakout, experimental transformer-based models), and a Django web dashboard for monitoring positions, orders, signals, performance, and correlations. The architecture is hybrid: the native module handles real-time CTP communication, while Python strategies run on an in-process event bus with Redis-like pub/sub. The dashboard visualizes trading metrics with ECharts and provides admin CRUD via Django admin. The system is production-oriented but exhibits several maintenance concerns: hardcoded secrets, outdated frontend libraries (Bootstrap 3, jQuery 3.1), duplicate config loading, and an incomplete ML integration. Despite these, the core CTP bridge and strategy framework are well-constructed and demonstrate solid engineering for the niche domain of Chinese futures trading.
The LLM identified 3 files worth highlighting for reuse:
Implements a lightweight in-process publish/subscribe event bus (LocalEventBus and LocalPubSub) that mimics Redis psubscribe/listen but requires no external broker. Uses asyncio for async event forwarding and supports channel pattern matching. Cleanly isolated, with minimal dependencies, making it reusable for any Python project needing decoupled, internal messaging.
A thread-safe persistent key-value store with TTL support. Writes JSON snapshots to disk and gracefully handles corruption. Designed for storing gateway state and limit ratios. Self-contained and can be extracted into other projects requiring a simple, durable cache without an external database.
A custom Python logging handler that asynchronously pushes log messages to WeChat Work (äźä¸ĺžŽäżĄ) via a background thread and a queue. Manages token caching and retries. The pattern of a queue-based async logging handler is reusable for any remote notification service.