Kungfu Quant Client User Guide

·

This guide provides a comprehensive overview of the Kungfu Quant trading system's client interface, designed for modularity, flexibility, and enhanced visibility to streamline your quantitative trading operations.

Core Concepts and Interface Overview

The system organizes functionality into distinct panels, allowing users to customize their workspace according to individual preferences. The modular architecture offers powerful statistical capabilities. For instance, the positions panel can display holdings aggregated by strategy, account, or trading algorithm based on your selection.

Trading Account Panel

This panel serves as the central hub for managing all your connected trading accounts. Here, you can add new accounts, delete or edit existing ones, create account groups, and individually start or stop an account's connection process.

Adding a New Trading Account

Initiate the process by clicking the "Add" button within the Trading Account panel.

You will then select the broker counter (API) you wish to connect to. The supported counters are:

Example: Adding a CTP Account

After selecting the CTP counter, a configuration window will appear. Key fields include:

👉 Explore more strategies for account configuration

Example: Adding an OKX Account

For connecting to OKX, the required fields are:

Fill in the details and click "OK" to complete the setup. You can then toggle the process switch to start the account.

Managing Accounts

Market Data Panel

This panel manages the connections to market data feeds.

Important Note: Kungfu retrieves market data through the connected trading accounts. Therefore, the login credentials for a market data source typically must match those of its corresponding trading account.

Adding a Market Data Source

Click the "Add" button in the Market Data panel and select the desired counter API (CTP, XTP, OKX, BinanceFuture, Sim).

The configuration fields for each counter (like CTP or XTP) will mirror the information used in their respective trading account setup. For counters like OKX and BinanceFuture, you can toggle specific data streams (Ticker, Transaction, Rate data), keeping in mind their potential memory usage.

Managing Market Data Sources

Operations for market data sources are similar to trading accounts: start/stop the connection, view/edit settings (requires restart), check logs, and delete sources. Caution: Deleting an active market data source will stop the feed and may impact strategies and trading tasks that depend on it.

Strategy Process Panel

This panel acts as your strategy pool, allowing you to import Python strategy files (*.py), edit code in real-time (with an embedded IDE), and manage their execution.

Pro Tip: Select a specific strategy in this panel to filter and view its holdings, orders, and trades in their respective panels.

Adding a Strategy

Click "Add", provide a unique Strategy ID, and select the local .py file.

Managing Strategies

Playback Tool

The playback tool is essential for post-market analysis, debugging, and strategy复盘 (review). It allows you to replay historical trading sessions under different conditions.

Key Use Cases:

  1. Enhanced Logging: Replay a session with a lower log level (e.g., Debug) to see more detailed information than was captured during live trading.
  2. Strategy Logic Simulation: Modify your strategy's code (e.g., change an entry condition) and use the built-in matcher to simulate how it would have performed using real historical market data.
  3. Commission Testing: Adjust futures commission rates in the Global Settings and replay a session to see the impact on trading costs and performance.

Diagnostic Tool

Journal files contain rich, detailed records of process activities, including full market depth quotes. The Diagnostic Tool allows you to browse and analyze these journals.

Features:

Operator Panel

Operators are computational units that process data. They can be used to offload intensive calculations (e.g., machine learning models) from strategies or to create reusable components like synthetic K-line data or factors that multiple strategies can subscribe to.

Types of Operators:

Adding an Operator

Click "Add" and choose the type. For a Plugin, configure its ID, data source, instruments, and calculation period. For a File, specify its ID and select the local Python file.

Subscribing to Operator Data

Strategies or other operators can subscribe to the synthetic data published by an operator. This promotes code reusability and improves system efficiency by avoiding redundant calculations.

Monitoring Panels: Positions, Orders, and Trades

Kungfu provides detailed panels to monitor your trading activity.

Trading Tasks Panel

Automate your order execution with predefined trading algorithms. Kungfu offers several types:

Frequently Asked Questions (FAQ)

Q: What should I do if my strategy fails to send orders?
A: First, check the status lights in the Trading Account and Market Data panels. Ensure both the relevant TD (Trading) and MD (Market Data) processes show a "Ready" status before starting your strategy. Also, verify your strategy code has correctly subscribed to the necessary market data and/or operator feeds.

Q: How can I test a change to my strategy without risking live capital?
A: Use the Simulated Trading account (sim) for initial logic testing with random data. For rigorous backtesting against real historical data, use the Playback Tool with the matcher enabled. This allows you to modify your code and simulate its performance using actual past market conditions.

Q: My journal files are very large. How can I manage them?
A: You can enable "Skip Archiving" in the Global Settings under the System tab. This will delete older journal files on startup, freeing up disk space and improving startup speed. Use this option if you do not need historical journal data for analysis.

Q: What is the difference between an Operator and a Strategy?
A: An Operator is designed for data processing and computation (e.g., calculating indicators, synthesizing K-lines). A Strategy primarily focuses on making trading decisions (e.g., based on operator data) and sending orders. Operators help keep strategies lean and efficient.

Q: Can I cancel a single order from a large TWAP task?
A: Yes. You can navigate to the Order Record panel, find the specific child order generated by the TWAP task, and cancel it individually. The TWAP algorithm will typically account for this change in its subsequent orders.

Q: Where can I get help with custom plugins or advanced features?
A: Kungfu offers a library of plugins for advanced backtesting, additional brokers, and algorithms. For custom requirements or support, you will need to contact the Kungfu development team directly through their official channels. 👉 Get advanced methods for system optimization