The Kungfu quantitative trading system is designed with a modular, user-friendly interface that offers flexibility and powerful functionality for traders across futures, stocks, and digital assets. This guide walks you through the core components of the client, including account setup, market data integration, strategy management, and advanced execution tools—all optimized for efficiency, precision, and real-time performance.
Whether you're managing multiple trading accounts, backtesting strategies, or executing large orders with minimal market impact, Kungfu’s modular architecture ensures seamless operation and intuitive control. Let’s dive into how to use each panel effectively.
Modular Interface Overview
Kungfu leverages a modular integration framework to deliver a flexible and visual trading experience. Functional modules are organized into dedicated panels, allowing users to customize layouts based on personal workflow preferences.
Each module supports independent operation and real-time adjustments. For example, the Position Panel dynamically updates based on your selection—showing holdings by strategy, account, or algorithm—for granular performance tracking.
This design enhances usability while supporting advanced statistical capabilities across trading processes.
Trading Account Management
The Trading Account Panel allows you to manage multiple brokerage connections, including CTP (futures), XTP (stocks), OKX (digital assets), Binance Futures, and simulated environments.
How to Add a Trading Account
- Click "Add" in the Trading Account Panel.
Select your counter type:
CTP– FuturesXTP– EquitiesOKX– Cryptocurrency (via OKX)BinanceFuture– Binance FuturesKungfu Sim– Simulation mode (uses random data)
👉 Maximize your crypto trading efficiency with advanced tools
Example: Adding an OKX Account
After selecting OKX as the counter:
| Field | Description |
|---|---|
| Account Alias | Optional label for identification |
| Username | Your OKX account name |
| Password | Login password |
| API Key | Provided in OKX API settings |
| Secret Key | Used for secure authentication |
| Sync External Orders | Enables syncing orders from other platforms |
| Simulated Trading | Enable for demo accounts only |
Once configured, click "Confirm", then toggle the process switch to launch the account. When status shows "Ready", login is successful.
Note: Changes made while the account is running won’t take effect until you restart the process.
Account Operations
- Edit Settings: Modify credentials or parameters via the "Account Settings" button.
- View Logs: Real-time logs help diagnose connectivity issues or order anomalies.
- Delete Account: Removes all associated data—orders, trades, logs. Export records before deletion.
Market Data Source Configuration
Market data is pulled using the same credentials as your trading account. Ensure consistency between login details for seamless operation.
Adding a Market Data Feed
- Click "Add" in the Market Source Panel.
- Choose the matching counter (e.g., CTP, XTP, OKX).
- Enter required fields such as IP, port, and credentials.
Example: Configuring OKX Market Feed
| Option | Function |
|---|---|
| Enable Ticker Push | Streams real-time price updates (memory-intensive) |
| Enable Transaction Push | Delivers tick-level trade data |
| Enable Fee Rate Push | Updates fee structure in real time |
Click "Confirm" to activate. Once the status turns "Ready", data streaming begins.
Warning: Disabling a market source may disrupt dependent strategies or algorithms relying on live quotes.
Strategy Process Panel
This panel acts as a strategy workspace where you can import .py files, edit code in real time, and monitor execution status.
Adding a Strategy
- Click "Add"
Fill in:
- Strategy ID – Unique identifier
- Strategy Path – Local path to your
.pyfile (must be on the same drive as Kungfu installation)
Ensure your trading (TD) and market data (MD) processes are ready before launching—otherwise, orders will fail.
Real-Time Code Editing
An embedded IDE lets you modify strategy logic instantly. Click "Edit", make changes, and save—the system auto-saves without interrupting operations.
Monitoring & Control
- Start/Stop: Toggle strategy execution.
- Logs: View runtime behavior in a pop-up window.
- Delete: Stops the strategy and removes it from the system.
Backtesting & Replay Tools
Use the Replay Tool for post-session debugging and strategy validation using historical data.
Key Use Cases
- Debug-Level Logging: Increase log verbosity to trace logic errors.
- Simulated Order Testing: Modify entry rules (e.g., trigger at
price + 2) and replay against real market data. - Fee Impact Analysis: Adjust commission rates in Global Settings and simulate performance under different cost structures.
To run a replay:
- Click "Replay" in the Strategy Panel
- Select session timeframe
- Review output logs to compare simulated vs actual behavior
Must enable matching engine when testing modified logic or fee scenarios.
Diagnostic Tool for Journal Analysis
Journal files store detailed event logs—including quotes, orders, and trades—ideal for deep-dive analysis.
Accessing Diagnostics
Click the eye icon next to any process → "Enter Visualization"
Features include:
- Time-based navigation
- Message filtering by type or keyword (Ctrl+F)
- Visual timeline of order submissions, cancellations, and market signals
- Cross-referencing between charts and raw journal entries
You can also open diagnostics globally via File > Open Diagnostic Tool to analyze multi-process interactions.
Operator Panel: Boost Efficiency with Shared Calculations
Operators reduce redundant computation by enabling reusable data pipelines—ideal for high-cost operations like machine learning or K-line generation.
Two Types of Operators
- Plugin Operators: Pre-built functions (e.g., bar generators)
- Custom File Operators: User-written Python scripts
Example: Creating a 5-Second Bar
| Parameter | Value |
|---|---|
| Bar ID | Unique identifier (e.g., bar_5s) |
| Data Source | e.g., sim or CTP |
| Instruments | Comma-separated list |
| Period | 5 seconds |
This bar can then be subscribed to by multiple strategies, reducing CPU load.
👉 Access powerful trading APIs for custom algorithm development
Position & Order Tracking Panels
Position Panel
Displays real-time holdings with filtering and export options:
| Field | Description |
|---|---|
| Instrument Code | Ticker + exchange |
| Long/Short | Direction |
| Yesterday / Today | Breakdown of holding age |
| Average Entry Price | Cost basis |
| Floating PnL | Unrealized profit/loss |
Use selection filters to view positions per strategy or account.
Order Record Panel
Tracks all order activity with powerful utilities:
- Search by symbol
- Filter active (non-filled) orders
- Export by date range
- Modify price (Modify Order) or cancel directly
- Use Pre-Cancel for conditional cancellation at market open
Real-time stats include average slippage, fill rate, and system/network latency.
Trade Task Automation
Automate complex executions using four built-in task types:
1. Conditional Orders
Trigger trades based on price or time conditions:
- Single or multiple price triggers (all must be met)
- Time-based execution
- Combine both conditions
2. Excel-Based Orders
Upload CSV files for batch scheduling:
- Supports one sheet only
- Auto-closes after completion
- Fields: time, instrument_id, price_type, volume, side, etc.
3. Iceberg Orders
Break large volumes into smaller chunks:
- New order only triggered after prior fill completes
- Minimizes market impact
4. TWAP Algorithms
Distribute orders evenly over time:
- TWAP Remaining Accumulated: Rolls unfilled quantity into next batch
- TWAP Remaining Averaged: Distributes leftover volume across remaining intervals
Both support squeeze alerts and anti-gaming features like protection pricing.
Basket Trading: Multi-Instrument Execution
Ideal for portfolio rebalancing, arbitrage, or diversified investing.
Create a Basket
Choose:
- By Quantity: Fixed number per asset
- By Proportion: Allocate total capital across assets by percentage
Import via CSV template or add manually.
Execute with Smart Features
- Subscribe to real-time data first
- Set offset and price preferences
- Scale execution using multiplier
- Use Basket TWAP for large-scale passive execution
Monitor progress via:
- Master order (basket level)
- Child orders (individual fills)
Use Chase Order to replace pending orders at better prices during volatility.
Global Settings & Performance Optimization
Access via bottom-left gear icon or Ctrl + ,
System
- Set home directory (no Chinese characters)
- Enable auto-restart on disconnection (3 attempts)
- Skip archiving for faster startup (loses historical journal)
Performance
- Enable Ultra Mode (for 4+ core CPUs) to minimize latency
- Activate pure monitoring mode to reduce UI overhead
- Skip default行情 subscription to lower memory usage
Risk Controls
- Ullage finger threshold: Alerts on extreme mispricing
- Close threshold: Warns when closing near zero position
- Disable confirmation popups for speed
Frequently Asked Questions (FAQ)
Q: Can I use local Python libraries in my strategies?
A: Yes. Enable "Use Local Python" in Global Settings. Only Python 3.9.x is supported. Install the provided .whl file using pip.
Q: How do I recover today's orders after restarting?
A: Enable "Restore Today's Orders" during account setup. The system pulls open orders from the counter upon login.
Q: Why isn't my strategy placing trades?
A: Verify that both TD and MD processes are in "Ready" state. Also ensure operators—used in logic—are running if applicable.
Q: What does 'Sync External Orders' do?
A: Imports trades placed outside Kungfu into your order history ("System External" source), ensuring accurate position tracking.
Q: How can I reduce memory usage with OKX feeds?
A: Disable Ticker, Transaction, or Fee Rate pushes if not needed—they consume significant RAM due to high-frequency updates.
Q: Is there a way to test strategies without risking capital?
A: Use the built-in SimNow simulation counter (Kungfu Sim) with synthetic data for safe testing of logic and execution flow.
Core Keywords: algorithmic trading platform, quantitative trading system, automated order execution, strategy backtesting tool, multi-account trading interface, real-time market data integration, TWAP algorithm trading, basket trading automation