How kungfu-origin/kungfu works
Overall Project Type and Purpose
• This is a complete trading execution system that targets extremely low latency (down to microseconds or even nanoseconds) while supporting flexible strategy development (in both C++ and Python).
• The system is built as a modular, layered architecture with clearly separated concerns: the backend “core” (data structures, time-series storage, and strategy execution), the strategy interface layer (providing APIs for different languages and reactive programming), and a frontend UI supporting both graphical interfaces and command-line tools.
Key Components
• Backend Core (C++):
– Longfist module: Handles financial data structures and serialization (found in framework/core/src/bindings and related directories).
– Yijinjing module: Provides the ultra-low latency time-series memory database with nanosecond precision (its code is spread across the core library directories).
– Wingchun module: The strategy execution engine that maintains real-time bookkeeping and trading positions.
• Strategy Interfaces:
– The SDK and developer tools (under developer/sdk and developer/toolchain) also provide command modules to build, package, and manage strategies.
• Frontend/UI:
– Built on Electron (Node.js-based desktop app) paired with Vue.js for the UI, which is visible in the “framework/app” directory (with separate main/renderer processes, webpack configurations, and public assets).
– API layer (under framework/api), where Node.js based services use similar config files and build scripts.
– CLI tools (in framework/cli) that offer command-based interactions.
• Extensions/Connectors:
– “extensions” directory contains samples for market connectors (e.g., XTP) and simulation modules that integrate externally.
Relationships and Data Flow
• Connectors to external market data providers or trading counters (e.g., the XTP connector as referenced in the README and built as an extension).
Architectural Patterns & Design Principles
• Modularity and separation of concerns: Backend core components, strategy APIs, and user interfaces are developed and compiled independently.
• Use of modern C++ (with C++20 features) and a multi-language interfacing approach (leveraging pybind11 for Python and Node’s binding interfaces).
• The layered approach also demonstrates a plug-in/extensible architecture (SDKs and connectors).