# KHunter: an all-in-one A-share quant system for individual investors

> KHunter is a Python system for quantitative trading on the Chinese A-share market, bundling market data, twelve stock selection strategies, eight timing strategies, a five dimension scoring model, risk control and backtesting behind one Flask web interface. It is open source, it is free to run, and it depends on free data sources whose stability it openly flags.

**ling-0729/KHunter** — KHunter 是一套开箱即用的A股量化交易系统，集数据管理、策略选股、择时交易、风险控制、回测验证于一体，为个人投资者提供从数据到交易的全流程量化解决方案。

- Repository: https://github.com/ling-0729/KHunter
- Stars: 638 · Forks: 178
- Language: Python
- License: NOASSERTION
- Published: 2026-10-21 · Updated: 2026-10-21 · Language: en
- Canonical page: https://hysenlabs.com/projects/ling-0729-khunter

## The pipeline runs from data to scored candidates

KHunter is described as an out-of-the-box quantitative trading system for the A-share market that brings data management, strategy based stock selection, timing, risk control and backtest validation together, giving individual investors a full pipeline from data to trade.

The web interface on localhost:5001 is the front door, and the readme lists what it exposes. A system overview with the stock count, the latest data date and system status. A stock list with search and pagination. Stock selection execution with multi-strategy combination. Strategy configuration, editable online. Backtesting with configuration, execution and results. The hunting ground, which shows stocks filtered by the multi-dimension score. Data management, for checking update status and running initialisation and updates. A board showing the gold stocks, hot industries and sector distribution. And a strategy runner for automated strategy execution, which needs a configuration file.

The workflow described in the readme is a sequence. On first use you initialise the data and update it. Daily, after the close, you run a data update that incrementally fetches the latest K-line data. You verify readiness by checking the latest data date and stock count. Then you run selection, save the result, and use the ranking function to score and order the candidates across five dimensions. From there you filter by score threshold and tracking days, compare current price against support level, and move the survivors into the hunting ground. You track the top ranked names, adjust strategy parameters, and backtest to refine further.

The readme is explicit that the more advanced features need more than K-line data, which is the central constraint on the whole system.

## Twelve selection strategies and eight timing strategies

The strategy catalogue is the heart of the system, and the readme is unusually careful about which strategies actually run.

The current version registers twelve selection strategies in the startup registry, and nine others have been archived into a disabled directory where they no longer participate in selection. The archived list is named: bottom trend turning point, trend acceleration turning point, limit-up sideways consolidation, strong washout weak to strong, trend start, W bottom, golden cross not yet green, low position TD9, and bowl rebound. To re-enable one you move the file back into the strategy directory and register it. The readme also points out that a configuration file still lists strategies that no longer exist, so the registry is the source of truth rather than that file. That is a small detail with a real lesson: configuration that drifts from code is a bug waiting to happen, and the readme documents the drift rather than hiding it.

The twelve active selection strategies cover several kinds of idea. The golden triangle strategy looks for a moving average pattern in a bullish alignment for trend starts. The limit-up return spear strategy looks for a pullback after a limit-up that restarts. The morning star strategy is a three candle bottom reversal. Multiple golden cross resonance combines moving average, KDJ and MACD crosses. The multi-cannon formation is two bullish candles bracketing a bearish one. The resistance breakout and the immortal pointing road strategies both look for breakouts, the second via a long upper shadow. The dragon head strategy identifies the leading stock of a theme. The main rise low buy strategy buys a pullback inside a rising wave, the post-listing halving strategy looks for a rebound after a sharp drop in a recent listing, the oversold rebound strategy looks for short-term repair, and the 2560 method is a specific candle pattern.

The eight timing strategies decide when to act. The Bollinger band strategy, the RSI strategy, the support and resistance strategy, the turtle strategy based on ATR for position sizing, a low position turtle variant without the MA20 filter for earlier entry, a turtle plus variant that only takes the second buy point, an uptrend pullback strategy that enters on a pullback with shrinking volume, and a MACD and Bollinger strategy whose rules were simplified to two buy conditions, one add condition sized down by the number of adds already made, and one sell condition that clears everything when the low is below the middle band and MACD turns green.

## A five dimension score and a market wide position cap

The scoring model is what turns a list of candidates into a ranked list, and the weights are set out in a table.

Technical signals carry 35 percent, with the score coming from strategy hits and weights accumulating. Capital flow carries 35 percent, scored from minus 100 to 100, and the readme marks it as the most important indicator. Fundamentals carry 10 percent, scored from minus 60 to plus 60, with the stated purpose of defusing risk. Sector strength carries 10 percent, scored from minus 100 to plus 200, following the sector. Event driven carries 10 percent, from minus 100 to 100, for short term catalysts.

So the model is deliberately asymmetric in what it rewards. Two dimensions of equal weight do the selecting and the ranking, and the other three are risk filters and amplifiers.

The newest release adds a market wide position cap driven by the index ADX. When ADX is above 25 and the market is rising, the cap is 100 percent. When ADX is below 18 and the market is rising and the close is above MA20, the cap is 50 percent. In every other case the cap is 0 percent, meaning no new positions, though adding to existing ones is not restricted.

There is a sector fallback for the all-A case, where part of the market is released according to sector index, limited to the matching sector, plus a rule that if two boards are released at once the whole is not released. The readme also notes a detail that matters for anyone reproducing results: live trading and backtesting now use the same timing convention, both being the signal day's close, with live signals on day T executing on T+1, and the backtest pinning to the previous bar so it cannot look ahead.

## Risk control, backtesting and a hard limit on free data

The risk control is described in two parts. There is VaR based risk assessment and position management, and there is automatic risk filtering that excludes high risk targets such as ST shares, delisted shares, stocks with too small a market capitalisation, and stocks with too large a recent gain.

The backtest feature covers configuration of the parameters including strategy selection, the time range and money management, execution that simulates a real trading environment, result analysis with return rate, win rate and maximum drawdown, detailed trade records, and an equity curve.

The constraint that shapes everything else is the data. The readme states that because of the stability problems with free data sources, the stock selection function works reliably in testing, but the ranking and hunting ground features depend on data beyond K-lines, namely capital flow, fundamentals, sector and event data, and those may not be obtainable stably, which affects those features. The suggested fix is to register for tushare and get an API token, which needs 6000 points for the complete feature set.

So the practical split is clear. Selection works on free data. Scoring across the capital flow, fundamental, sector and event dimensions, and the hunting ground built on that score, needs paid data. The readme is unusually straight about this, including a request for understanding about the inconvenience, and the newest release takes it further by making the backtest fully offline with local data for the trading calendar, capital flow, fundamentals, announcements and ADX, so results are reproducible. A data source that lacks permission is skipped automatically without aborting, with a trace left per dimension and per index.

## Running it, and the setup step that silently blocks trading

Installation is three steps, and the environment requirement is stricter than the documentation originally claimed:

```bash
git clone https://github.com/ling-0729/KHunter.git
cd KHunter
pip install -r requirements.txt
python main.py web
```

On Windows the second and third steps can also be run by double clicking start.bat in the root directory.

The Python requirement is 3.10 or newer, and the readme explains why it corrected an earlier claim of 3.8 or newer: files such as web_server.py use union type annotations in the form StrategyRunner | None and do not import from __future__ import annotations, so the syntax is evaluated immediately and 3.8 or 3.9 fails outright and the service will not start. Development and production were tested on 3.12.

The stack is akshare for A-share real time and historical data, pandas and numpy for processing and technical indicators, matplotlib for K-line chart generation, Flask for the web interface, and SQLite for storage. The requirements file adds tushare, PyYAML, schedule, flask-socketio, scipy, Pillow, fastdtw, beautifulsoup4 and lxml, and waitress as the production WSGI server, with a note that the earlier production start files were removed from version control and a minimal WSGI entry point should be supplied locally.

The most important operational step is the one the readme marks with a warning. After upgrading or installing, two ADX backfills are mandatory, because the ADX value column is not created with the table, and without it the per-stock gate silently does not release and you buy nothing at all. The documented order is restart so tables and columns are created automatically, tick all seven items on the initialisation page, run the backfills, run the self check for coverage, warm-up start point, wiring and yaml to database consistency, and only then start backtesting.

The readme also states that this repository publishes source only, and that the regression test files and the configuration file containing local credentials are not in the repository.

## Conclusion

Adopt KHunter if you are an individual investor working on the Chinese A-share market, you want a complete pipeline from data collection to scored candidates to backtest, and you are willing to deal with the data source limitations the project documents. Do not adopt it if you need institutional grade data feeds, since the ranking, hunting ground and board features depend on capital flow, fundamental, sector and event data that the free sources cannot supply reliably, and the readme says a tushare token with 6000 points is needed for the full feature set. Before you commit, read the release notes for the current version, run the ADX backfill steps the readme marks as mandatory, and treat the free data path as development-only until you have verified the numbers against a paid source.

## FAQ

### What is KHunter?

KHunter is an out-of-the-box quantitative trading system for the Chinese A-share market that combines data management, strategy based stock selection, timing, risk control and backtest validation, providing individual investors with a full pipeline from data to trade. It is written in Python with a Flask web interface.

### How many stock selection strategies does KHunter have?

Twelve are registered and participate in selection, covering bottom reversal, breakout and moving average resonance patterns. Nine further strategies have been archived into a disabled directory and no longer participate, and the readme states that the startup registry rather than the configuration file is the source of truth.

### What are the five dimensions of the KHunter scoring model?

Technical at 35 percent, capital flow at 35 percent and marked as the most important indicator, fundamentals at 10 percent with a range of minus 60 to plus 60, sector strength at 10 percent with a range of minus 100 to plus 200, and event driven at 10 percent with a range of minus 100 to plus 100.

### Does KHunter work without paid market data?

Partly. The stock selection function works reliably with free data, but the ranking and hunting ground features depend on capital flow, fundamental, sector and event data that free sources may not supply stably. The readme says registering for tushare with an API token, needing 6000 points, is what solves the data stability problem for the full feature set.

### What must you do after installing KHunter before you can backtest?

Restart so tables and columns are created, tick all seven items on the initialisation page, run the two ADX backfills, then run the self check. The readme warns that skipping the backfill makes the per-stock gate silently not release, so no positions are taken at all.

## Sources

- [Issues](https://github.com/ling-0729/KHunter/issues)
- [ling-0729/KHunter on GitHub](https://github.com/ling-0729/KHunter)
- [README](https://github.com/ling-0729/KHunter/blob/main/README.md)
- [Releases](https://github.com/ling-0729/KHunter/releases)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/ling-0729-khunter
