myhhub/stock (InStock): A Self-Hosted A-Share Data, Indicator and Backtest System
stock股票.获取股票数据,计算股票指标,筹码分布,识别股票形态,综合选股,选股策略,股票验证回测,股票自动交易,支持PC及移动设备。
At a glance
- What is it?
- InStock is a Python web system that scrapes daily Chinese A-share and ETF data, computes technical indicators and chip distribution, runs selectable strategies with backtesting, and can place automatic trades. It suits engineers who want the whole pipeline on their own machine, and it is heavy to install.
- Who is it for?
- Adopt InStock if you want an end-to-end, self-hosted A-share pipeline and are willing to run Python 3.11, MySQL and the TA-Lib C library, or to pull the mayanghua/instock Docker image instead. Do not adopt it if you trade US or European equities, need a maintained install guide for a non-Windows host, or expect automatic trading to be safe out of the box, since the README states only a new-share subscription strategy and examples ship.
- Can I use it commercially?
- Yes. Apache-2.0 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?
- Activity is slowing. The repository last received commits 6 months 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 September 27, 2026, and from our analysis. They are not legal advice.
Editorial analysis
What InStock solves, and who it is built for
Screening Chinese A-shares usually means stitching together a data source, an indicator library, a screener and a backtester. InStock packages all four into one repository. The README describes it as capturing daily stock and ETF data, computing technical indicators and chip distribution, identifying K-line patterns, running comprehensive screening and strategies, and validating them with backtests. It is written in Python, licensed Apache-2.0, and the README says it supports Windows, Linux and macOS plus a Docker image at hub.docker.com/r/mayanghua/instock.
The intended user is someone comfortable running a local database and a web service, not a casual investor looking for a hosted dashboard. The screening module alone exposes more than 200 fields across stock scope, fundamentals, technicals, news, popularity and quote data, which is a lot of surface area. If you only want a chart of one ticker, this is far more machinery than you need.
How the pipeline is wired: jobs, database, web layer
The system is built as a set of batch jobs rather than a request-driven API. The README lists separate entry points: basic_data_daily_job.py for real-time basics, basic_data_other_daily_job.py for non-real-time basics, indicators_data_daily_job.py for indicators, klinepattern_data_daily_job.py for pattern recognition, strategy_data_daily_job.py for strategy output, and backtest_data_daily_job.py for backtest data. execute_daily_job.py is the umbrella job that runs the whole chain for a given date or date range.
Data lands in a database. The README states the system creates databases and tables automatically and wraps bulk update and insert operations, which is what makes historical storage and later statistical work possible. The presentation layer is a web application; the README says adding a new business form only requires configuring a view dictionary, and the interface is built to work on PC, tablet and mobile.
Two engineering choices stand out. The README states the system uses multithreading and singleton shared resources, and gives a runtime figure of roughly four minutes for one day's full chain (scrape, indicators, patterns, strategy, backtest) on an ordinary laptop. It also states that indicator formulas were adjusted so results match Tonghuashun and Tongdaxin, which is a compatibility claim rather than a correctness proof, and worth spot-checking against your own data before you trust a signal.
Installing InStock: Python, MySQL, TA-Lib, then a first run
The README presents two install paths and recommends the conventional one on Windows. The conventional path has four prerequisites: Python 3.11 or newer, MySQL, the TA-Lib C/C++ shared library and headers, and the Python dependencies. Note that TA-Lib is a two-part install: the C library from ta-lib.org must exist before the Python wrapper in requirements.txt can build. The README suggests the official installers (Windows executable, macOS Homebrew, Linux Debian packages).
Start by installing dependencies from the repository root. The requirements file pins exact versions, including numpy 2.4.1, pandas 2.3.3, TA_Lib 0.6.8, tornado 6.5.4 and easytrader 0.23.7.
python -m pip install -r requirements.txtThe README also documents a way to float to the latest versions: edit requirements.txt and change each == to >=, then re-run the same command. That trades reproducibility for freshness, so pin the file back if a build breaks.
The README notes that a domestic mirror is configured because package downloads are otherwise blocked in the target environment, and gives this command:
python pip config --global set global.index-url https://mirrors.aliyun.com/pypi/simple/For a first real use, run the whole chain for a single date. The README gives the batch forms explicitly, including a single-date form and an enumerated-date form:
python execute_daily_job.py 2022-03-01
python execute_daily_job.py 2022-01-01,2021-02-08,2022-03-12
python execute_daily_job.py 2022-01-01 2022-03-01After the job finishes, the README says important logs are written to stock_execute_job.log for scraping and analysis, stock_web.log for the web service, and stock_trade.log for the trading service. Read stock_execute_job.log first: it is the fastest way to see whether the scrape, indicator and strategy stages all completed. If you prefer the container route, the README points to the Docker image rather than giving a docker run line, so pull that image and follow its own description.
Chip distribution, pattern recognition and the 61-form list
Two features are less common in open source screening tools. The first is chip distribution, or Position Cost Distribution (CYQ). The README describes it as computing, over a time window, the high price, low price and volume, then outputting the share of float traded at each price level. The default window is 210 trading days and the README says the range is configurable. The README claims results match professional software such as Eastmoney; that is a claim about formula parity, not an independently verified benchmark, and the calculation depends on your price and volume source being clean.
The second is K-line pattern recognition. The README lists 61 named patterns, from two crows and three white soldiers through morning star, piercing pattern and the various gap forms, and says users can add their own. Output is signed: negative means a sell signal, zero means the pattern did not appear, positive means a buy signal. Treating a candlestick pattern as a directional signal is a modelling assumption, and the README does not report hit rates for any single pattern, so the backtest module is where you would have to establish that yourself.
Strategies, backtesting and the automatic trading caveat
The strategy module ships several named screeners with fully written rules, not just labels. The README spells out conditions for volume breakout (turnover at least 200 million, volume at least twice the 5-day average), moving-average bullish alignment, the "helipad" continuation pattern, pullback to the 250-day line, platform breakout, low-drawdown, turtle trading, narrow flag, volume limit-down, low-ATR growth, and a fundamental screen (P/E at or below 20 and above 0, P/B at or below 10, ROE at least 15). Because the thresholds are in the README, you can judge whether a given strategy matches your own definition before running anything.
Backtesting is handled by backtest_data_daily_job.py, which the README says fills backtest data forward to the current date, and the stated purpose is to check a strategy's success rate and whether it is usable. There is no mention of transaction costs, slippage or survivorship handling, so a backtest result here is a screen-quality check rather than a portfolio simulation.
Automatic trading is the part to read twice. The README states the system supports automatic trading and includes a new-share subscription strategy plus example strategies, and that because it involves money and to avoid risk, no other trading strategies are provided. It also warns that at 10:00 on trading days the new-share subscription triggers, and that if you do not want it you should delete stagging.py or not start the trading service. That is an explicit instruction, not a suggestion: an unattended trade service will act.
Where InStock is the wrong tool, and what to use instead
The scope is Chinese A-shares and ETFs. Nothing in the README describes US, European or crypto coverage, so if your universe is not A-shares, the data layer is not usable and the strategy library will not transfer. The install story is also Windows-first: the README says the conventional instructions use Windows as the example, and the Linux and macOS paths lean on installing TA-Lib from source or a package manager. Expect more friction there.
For a direct alternative in the same Python ecosystem, consider backtesting.py or vectorbt if what you actually need is strategy simulation on data you already have. The difference in approach is that those libraries do not fetch or store data and do not compute chip distribution; you bring your own OHLCV frame and they focus on the simulation loop, position sizing and performance statistics. InStock inverts that: it owns the scrape, the database and the indicator layer, and its backtest is a validation step inside that pipeline. If your problem is data acquisition and screening, InStock is the closer fit. If your problem is evaluating a strategy you have already written, InStock adds a database and a scraper you do not need. On the data side, the README mentions proxy and Cookie support explicitly because many sites throttle heavy request volume, which tells you the scraping layer is the part most likely to break when a source changes.
Maintenance, licence and what the README does not cover
The repository is not archived, and the last push was on 2026-04-02. There are no retrieved releases, so there is no tagged version to pin against; you would be tracking the master branch. The README does not document an upgrade procedure, a migration path for the database schema between versions, or a rollback step, and it does not state which MySQL versions are supported beyond "latest". Those are real gaps for anyone running this on a schedule.
The licence is Apache-2.0, which permits commercial use and modification and requires that you retain the licence and notices; it also includes a patent grant. That is a summary of the standard terms, not legal advice, and if you plan to redistribute a modified version you should read the LICENSE file in the repository yourself. The dependency list is another maintenance cost: it pins eighteen packages, and the README's own suggestion to switch == to >= means the project expects you to manage version drift yourself.
Editorial conclusion
Adopt InStock if you want an end-to-end, self-hosted A-share pipeline and are willing to run Python 3.11, MySQL and the TA-Lib C library, or to pull the mayanghua/instock Docker image instead. Do not adopt it if you trade US or European equities, need a maintained install guide for a non-Windows host, or expect automatic trading to be safe out of the box, since the README states only a new-share subscription strategy and examples ship. Before committing, verify that the Docker image tag you plan to use matches the master branch code, confirm your MySQL version is supported, and check whether easytrader supports your broker.
Frequently asked questions
How do I install myhhub/stock?
The README gives two routes: a conventional install with Python 3.11 or newer, MySQL and the TA-Lib C library followed by pip install -r requirements.txt, or the Docker image at hub.docker.com/r/mayanghua/instock. The conventional instructions use Windows as the example.
What data does InStock cover?
It targets Chinese A-shares and ETFs, capturing daily stock and ETF data, fund flows, dividends, dragon-tiger lists, block trades, fundamentals and popularity rankings. The README does not describe coverage of other markets.
Does myhhub/stock place trades automatically?
The README states automatic trading is supported and that a new-share subscription strategy plus example strategies are included, with no other trading strategies provided because of the money involved. It warns that the subscription triggers at 10:00 on trading days and that you should delete stagging.py or not start the trading service if you do not want it.
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/myhhub-stock)