A lightweight TCP-based desktop market viewer built with Rust
English | 简体中文
China Stock Market Viewer is a lightweight, experimental-but-usable desktop application for viewing Chinese stock market data over a direct TCP connection using a TDX-compatible protocol.
The project is built on top of a custom FeedClient derived from the original Rustdx TCP implementation, and is designed to validate whether direct TCP market data access remains viable, transparent, and controllable compared to modern commercial Web APIs.
Unlike upstream Rustdx (≥ v0.4), which migrated to a commercial HTTP API, this project intentionally continues to explore the Pytdx-style TCP model, emphasizing correctness, observability, and explicit failure handling.
This project provides:
- A blocking, deterministic TCP client
- Explicit request/response decoding
- A usable desktop market viewer UI
- Thread-based concurrency without Tokio
- Clear error propagation and failure visibility
The tool is already functional for real-world exploratory and research use, and no fundamental protocol-level issues have been observed so far.
Starting from Rustdx v0.4, the original project discontinued its TCP transport layer and adopted a commercial Web API, primarily due to IP instability and operational complexity.
The original TCP roadmap included:
- IP probing and health checks
- Connection pooling
- Automatic failover
However, these features were ultimately abandoned upstream due to long-term maintenance costs.
Despite this, the early Rustdx TCP implementation established a strong technical foundation, including:
- Well-structured binary protocol parsing
- Clean domain data models
- Clear separation of transport and decoding logic
This project builds upon that foundation and reintroduces a carefully scoped TCP client, deliberately limiting scope to maintain clarity and robustness.
This is a deliberate architectural choice, not an attempt to replace commercial data providers.
Key motivations:
-
Transparency & Control
- Raw protocol visibility
- No hidden throttling or opaque retries
-
Architectural Simplicity
- No HTTP stacks or JSON parsing
- Fewer dependencies, easier debugging
-
Pytdx-Proven Model
- TCP + IP pool + retry works in practice
- Operational problems are manageable when scoped
-
Vendor Independence
- No API keys or quotas
- Suitable for private or offline use
-
Explicit Failure Handling
- Timeouts, reconnects, and backpressure are visible
- Avoids silent degradation common in wrapped APIs
Trade-off acknowledged: TCP demands stricter engineering discipline.
This project embraces that cost in exchange for control and clarity.
| Feature / Project | Pytdx | Rustdx (≥0.4) | This Project |
|---|---|---|---|
| Transport | TCP | Web API | TCP |
| IP Pooling | ✅ | ❌ | ✅ |
| Failover | ✅ | ❌ | ✅ |
| Connection Pool | ✅ | ❌ | ✅ |
| Blocking API | ✅ | ❌ | ✅ |
| Async Stack | ❌ | ✅ | |
| Data Pipeline | ❌ | ❌ | ✅ (built-in) |
| Vendor Lock-in | ❌ | ✅ | ❌ |
| Debuggability | High | Medium | High |
Legend:
✅ Implemented
What works:
- TCP-based
FeedClient - Stable protocol decoding
- K-line (candlestick) data fetching
- Thread-based concurrency
- Desktop UI viewer
- Deterministic blocking behavior
What this is not:
- A drop-in Pytdx replacement
- A self-healing production data service
- A commercial market data platform
The scope is intentionally conservative and explicit.
- IP health scoring
- Smarter retry strategies
- Configurable timeout policies
- Improved logging and metrics
- Batch request optimizations
- Improved backpressure handling
- Android support
- Windows distribution improvements
- Replacing commercial APIs
- Maximizing throughput at all costs
- Abstracting away TCP semantics
This project prioritizes:
- Correctness over cleverness
- Explicit behavior over hidden automation
- Understandability over abstraction
If you are comfortable with TCP, blocking I/O, and visible failure modes, this tool aims to give you full control over your market data pipeline.
MIT
