chan.py: a Python framework for Chan Theory whose public repository holds only about a quarter of the described system
An open Python framework implementing Chan Theory (Chanlun), supporting morphological/dynamic buy-sell point analysis, multi-timeframe K-line correlation, nested interval strategies, visualization, multiple data sources, strategy development and trading system integration.
At a glance
- What is it?
- chan.py by Vespa314 computes Chan Theory structures (fractals, strokes, segments, hubs and buy-sell points) from K-line data. This page covers the one-call CChan interface, the data sources and the large gap between the public code and the README.
- Who is it for?
- chan.py fits Python users who want to compute strokes, segments, hubs and buy-sell points from their own K-line data, and who will write strategies themselves. It does not fit anyone who expects the machine learning, AutoML or Futu trading features from the README, because the public code leaves those out.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 6 days ago.
- What is it written in?
- Mainly Python, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 24, 2026, and from our analysis. They are not legal advice.
Star history
- Vespa314/chan.py2,351 ★ · +154
| Repository | 2026-10-08 | 2026-11-24 |
|---|---|---|
| Vespa314/chan.py | 2.2k | 2.4k |
154 Stars in the last 47 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
The public repository is about 5300 lines of a 22000 line system
The first thing the README says, in a note marked as special, is that the public code currently contains only basic static calculation. It does not include strategy classes, features, models, the AutoML framework or the trading engine connection. The full code is about 22000 lines, the public version about 5300. The README text describes the full version, and the author warns that in some places it may not match the public code, pointing readers to quick_guide.md first.
That gap shapes everything else. The README lists four levels of use: basic element calculation, strategy buy-sell point development, machine learning scoring and online trading. Only the first level, and part of the second, is in the repository you can clone. If you read the feature list and plan a trading system around it, you will find the code for it missing. The author invites questions by Telegram group or email, so support for the missing parts is a conversation, not a package.
Python 3.11 is the floor because the calculation is heavy
The second special note sets the minimum dependency at Python 3.11. The author calls the project highly compute intensive and says that, measured against Python 3.8.5, the calculation time came down by about 16 percent on 3.11, so later development is based on 3.11. That 16 percent figure is the author's own measurement and comes with no dataset or hardware description.
The consequence is simple: an environment pinned to 3.8, 3.9 or 3.10 will not do. The repository gives no install command, no requirements file and no package name, and the top level has no packaging metadata. It also has no GitHub releases, so you run it from a checkout and install the dependencies yourself.
One CChan call does the whole calculation, and level order matters
The core class is CChan, and the README says the calculation needs only that one constructor call. The demo starts from these imports and a default configuration:
from Chan import CChan
from ChanConfig import CChanConfig
from Common.CEnum import AUTYPE, KL_TYPE
from Plot.PlotDriver import CPlotDriver
config = CChanConfig({})The module names mirror the repository layout, so run it from a checkout. The CChan parameters are code, begin_time, end_time, data_src, lv_list, autype, config and extra_kl. Both time arguments default to None, and what None means depends on the data source. The lv_list default is the daily and 60 minute K-lines, and levels must be passed from large to small. The available levels run from year, quarter and month down to week, day, 60M, 30M, 15M, 10M, 5M, 3M, 1M and second levels from 30S to 1S. The author jokes that year and quarter lines are of little use because a whole history may hold a single stroke.
The autype argument takes AUTYPE.QFQ by default (forward adjusted), or AUTYPE.HFQ or AUTYPE.NONE. The extra_kl argument exists for patching a data source that lags, for example an offline source that ends yesterday while you need today's live bars. As a list of CKLine_Unit objects, it raises an error if lv_list holds more than one level. As a dictionary keyed by level, it works for several levels.
Five data sources, and BaoStock is the default
The data_src parameter accepts DATA_SRC.FUTU, DATA_SRC.BAO_STOCK (the default), DATA_SRC.CCXT and DATA_SRC.CSV, or a string in the form custom:filename:classname for your own parser. The framework ships one custom demo, written as custom: OfflineDataAPI.CStockFileReader. The feature list also names akshare among the supported sources, and mentions high-performance local offline data update and storage.
The stock code format depends on the source. The README example uses HK.00700 with the Futu source. Because the format changes between sources, the same instrument needs a different code string for BaoStock, ccxt or a CSV reader. The repository has a DataAPI directory for the reader implementations, and a section on adding your own source is referenced in the README table of contents. A live trading setup also needs real time prices, and the README names sina, pytdx, futu and akshare as the real time interfaces in the full version.
bsp is computed in hindsight and cbsp is decided bar by bar
The README defines two kinds of buy-sell points, and the difference decides whether a backtest means anything. A bsp is a morphological buy-sell point: from the trend and its definitions, the framework can compute where past points were, and those are described as always correct. A cbsp is a custom buy-sell point produced by your own strategy, supplied through the cbsp_strategy parameter in CChanConfig. The strategy class sees only the K-lines up to the current bar and judges, on each new bar, whether now is a buy-sell point.
The README says a cbsp generally arrives later than the matching bsp and is not necessarily correct. In charts, cbsp points are drawn with dashed lines, and a check mark in front means that, looking back, the strategy got it right. If you test a strategy by looking at the bsp list, you are testing on information that was not available at the time. Use cbsp for any claim about what could have been traded.
Three segment algorithms and hub options live in separate packages
The directory layout shows how the pieces split. The Bi package holds strokes, with BiConfig, BiList and Bi. The Seg package holds segments, including Eigen and EigenFX for the feature sequence, and three segment calculators: SegListChan follows the original text, SegListDef follows the definition, and SegListDYH follows the Du Yehua 1+1 breakout method. The ZS package holds hubs, and KLine holds the unit and merged K-lines. The top level also has BuySellPoint, ChanModel, Combiner, Common, DataAPI, Math, Plot and Script directories.
A segseg is a segment built by treating segments as strokes, effectively a parent level segment, with segbsp and segzs as its buy-sell points and hubs. In CChanConfig, hub options include zs_combine (default True), zs_combine_mode with zs as the default overlap rule, one_bi_zs (default False) and zs_algo, which takes normal, over_seg or auto. Choosing a segment algorithm or hub mode changes every downstream point, so fix those settings before comparing results.
Charts come from matplotlib, and the model, trading and database layers are not in the public code
For charts, CPlotDriver draws a single figure and CAnimateDriver plays back the build step by step. Matplotlib is the default, and plot element data can be extracted to feed any other engine, with bokeh given as an example. Calling CChan.toJson() returns all the related information, which is how the README suggests deploying the calculation as an API service. With one level, CChan[0].bi_list works without naming the K-line type.
The full version, per the README, adds more than 500 features per buy-sell point, XGBoost, LightGBM and MLP models, a backtest and evaluation framework, an AutoML search, consistency checks between online and offline models, a Futu trading engine for paper and live accounts, and MySQL or SQLite storage. None of that code is in the public tree, so none of it can be tried. The license is MIT and the last push was on 2026-10-27, but with no GitHub releases there is no version to pin.
Editorial conclusion
chan.py fits Python users who want to compute strokes, segments, hubs and buy-sell points from their own K-line data, and who will write strategies themselves. It does not fit anyone who expects the machine learning, AutoML or Futu trading features from the README, because the public code leaves those out.
Frequently asked questions
What does chan.py compute?
It computes Chan Theory elements from K-line data: fractals, strokes, segments, hubs and buy-sell points, with support for multi-level calculation and nested interval strategies.
Does the public chan.py code include the trading engine and machine learning models?
No. The README says the public code only includes basic static calculation, without strategy classes, features, models, the AutoML framework or trading engine connections.
Which Python version does chan.py need?
Python 3.11 or newer. The author says development is based on 3.11 because the calculation ran about 16 percent faster than on Python 3.8.5.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/vespa314-chan-py)Star history chart for your README
[](https://hysenlabs.com/projects/vespa314-chan-py)Was this useful?