@XAMTO_AI: How to Apply Theoretical Knowledge in the Real A-Share Market? The Two Projects I Found Later Helped Me Bridge the Gap from Both Directions. Let's Start with the myhhub/stock System – It Feels Very Practical, from Daily Automatic Data Fetching for Stocks and ETFs, to Calculating Technical Indicators (MACD, K…
Summary
This article provides a detailed introduction to the InStock stock system, an open-source quantitative investment tool that supports data fetching, technical indicator calculation, K-line pattern recognition, and strategy backtesting, among other functions.
View Cached Full Text
Cached at: 08/16/26, 04:03 PM
The theoretical knowledge learned—how does it actually translate into practice within the real A-share market environment? Two projects I later encountered helped me find two practical paths to make that connection.
First is the myhhub/stock system. It strikes me as a hands-on, battle-tested solution. From automatically fetching daily stock and ETF data, calculating various technical indicators (MACD, KDJ, RSI—all verified against TongHuaShun), to recognizing 61 K-line patterns and computing chip distribution, the feature set is impressive and comprehensive.
It includes over a dozen built-in stock selection strategies (like volume surge, annual line pullback, platform breakout—all pre-packaged), supports backtesting to validate strategy effectiveness, and even allows for automated trading (though I recommend caution with the IPO subscription feature).
I tried running it locally via Docker. The entire process, from data fetching to web dashboard visualization, was smooth. It also supports mobile viewing, so you can even glance at your holdings on the subway.
:https://github.com/myhhub/stock
myhhub/stock
Source: https://github.com/myhhub/stock
Corresponding IMA Knowledge Base (https://ima.qq.com/wiki/?shareId=8b0da768c77bc863f1cad8eb9482e37a6eeb26ad7171523b687d48c1a67c8e2c): Quantitative Factor AI Decision Engine for Stocks, featuring a 2200+ dimensional professional factor pool. AI performs deep analysis of multi-dimensional data, precisely mining high-certainty individual stocks, empowering professional investors with efficient and robust decision-making. https://ima.qq.com/wiki/?shareId=8b0da768c77bc863f1cad8eb9482e37a6eeb26ad7171523b687d48c1a67c8e2c .
InStock Stock System
InStock Stock System captures daily key data on stocks and ETFs, calculates stock technical indicators and chip distribution (CYQ), identifies various K-line patterns, performs comprehensive stock selection with multiple built-in strategies, supports strategy verification and backtesting, supports automated trading, and batch time operations. It runs efficiently, supports display on PCs, tablets, and mobile devices, and provides Docker images for easy installation. It is a valuable aid for quantitative investment.
The stock system captures key daily data on stocks and ETFs, calculates stock technical indicators and chip distribution (Position Cost Distribution - CYQ), identifies various K-line patterns, performs comprehensive stock selection with multiple built-in strategies, supports strategy verification and backtesting, supports automated trading, and batch time operations. It runs efficiently, supports display on PCs, tablets, and mobile devices, and provides Docker images for easy installation, making it a valuable helper for quantitative investment.
Docker Image: https://hub.docker.com/r/mayanghua/instock .
Feature Introduction
1: Comprehensive Stock Selection
Comprehensive stock selection supports over 200 information categories, including stock scope, fundamentals, technicals, news, sentiment indicators, and market data, allowing for flexible combination. Selection conditions are categorized as follows: ``
- Stock Scope Market, Industry, Region, Concept, Style, Index Composition, Listing Date.
- Fundamentals Valuation indicators, per-share indicators, profitability, growth capability, capital structure & solvency, share capital & shareholders.
- Technicals MACD golden cross, KDJ golden cross, volume breakout, low-level net capital inflow, high-level net capital outflow, upward moving average crossover, bullish moving average alignment, bearish moving average alignment, consecutive gains with volume, decline without volume, single long bullish candle, two consecutive long bullish candles, Morning Doji Star (Rising Sun), Strong Bullish, Piercing Line (Parting the Clouds), Seven Fairies Descend (Seven Consecutive Bearish Candles), Eight Immortals Crossing the Sea (Eight Consecutive Bullish Candles), Nine Suns Divine Art (Nine Consecutive Bullish Candles), Four Consecutive Bullish Candles, Massive Volume Rule, Upward Attack with Volume, Engulfing Pattern (Piercing Head and Dragging Feet), Inverted Hammer, Shooting Star, Evening Star, Piercing Line (Dawn Breaking), Harami (Pregnant), Dark Cloud Cover, Morning Star, Narrow Range Consolidation.
- News Company Announcements, Institutional Attention, Number of Institutional Shareholders, Institutional Holding Ratio.
- Sentiment Indicators Stock Bar Popularity Ranking, Popularity Ranking Change, Consecutive Rise in Popularity Ranking, Consecutive Fall in Popularity Ranking, Popularity Ranking Hits New High, Popularity Ranking Hits New Low, Ratio of New Fans, Ratio of Hardcore Fans, 7-Day Attention Ranking, Today’s View Ranking.
- Market Data Stock Price Performance, Trading Volume, Capital Flow, Market Statistics, Shanghai/Shenzhen-Hong Kong Stock Connect. ``
2: Daily Stock Data
Includes daily stock data, stock capital flow, stock dividends and distributions, Dragon & Tiger List, block trades, fundamental stock data, industry capital flow, concept capital flow, pre-market capital grab data, end-of-day capital grab data, limit-up reason analysis, and daily ETF data. Fetches daily data for A-shares, focusing on key metrics, while encapsulating fetching methods for easy system expansion to obtain personally tracked data.
3: Stock Indicator Calculation
Calculates indicators efficiently and accurately based on talib and pandas. Adjusts formulas for specific indicators to ensure results align with TongHuaShun and TongXinDa software. Indicators: ``
- MACD 2. KDJ 3. BOLL 4. TRIX, TRMA 5. CR 6. SMA 7. RSI
- VR, MAVR 9. ROC 10. DMI, +DI, -DI, DX, ADX, ADXR 11. W&R
- CCI 13. TR, ATR 14. DMA, AMA 15. OBV 16. SAR 17. PSY
- BRAR 19. EMV 20. BIAS 21. TEMA 22. MFI 23. VWMA
- PPO 25. WT 26. Supertrend 27. DPO 28. VHF 29. RVI
- FI 31. ENE 32. STOCHRSI ``
4: Identify Buy/Sell Signals for Stocks
Determines potential buy/sell signals based on indicators. Specific screening conditions are as follows: `` KDJ:
- Overbought Zone: K > 80, D > 70, J > 90 is considered overbought. Generally, the stock price may fall. Investors should act cautiously. Outsiders should not chase highs; insiders should sell timely.
- Oversold Zone: K < 20, D < 30 is considered oversold. Generally, the stock price may rise, and the probability of a rebound increases. Insiders should not sell easily; outsiders can look for entry opportunities. RSI:
- When the 6-day indicator rises to 80, it indicates the market is overbought. If it continues to rise above 90, it signals a serious overbought warning zone. The stock price has likely formed a top and may reverse downward shortly.
- When the 6-day RSI drops to 20, it indicates the market is oversold. If it continues to drop below 10, it signals a serious oversold zone. The stock price has a high chance of stopping its decline and rebounding. CCI:
- When CCI > +100, it indicates the stock price has entered an abnormal range—the overbought range. Increased attention to unusual price movements is warranted.
- When CCI < -100, it indicates the stock price has entered another abnormal range—the oversold range. Investors can consider buying on dips. CR:
- When CR drops below the a, b, c, d lines and then climbs back up from a low to 160, it presents a good opportunity for short-term profit-taking. Stocks should be appropriately sold.
- When CR drops below 40, it is a good opportunity to build positions. WR:
- When the %R line reaches 20, the market is overbought, and the trend may be nearing a top.
- When the %R line reaches 80, the market is oversold, and the stock price trend may be at or near a bottom. VR:
- In the profit zone (160-450), take profits as appropriate.
- In the low price zone (40-70), buying is advisable. ``
5: K-line Pattern Recognition
Accurately identifies 61 K-line patterns and supports user-defined pattern recognition. Recognized Patterns: ``
- Two Crows 2. Three Crows 3. Three Inside Up/Down 4. Three-Line Strike 5. Three Outside Up/Down 6. Southern Three Stars 7. Three White Soldiers 8. Abandoned Baby
- Advance Block 10. Belt-Hold Line 11. Breakaway 12. Closing Marubozu 13. Concealing Baby Swallow 14. Counterattack Lines 15. Dark Cloud Cover 16. Doji 17. Doji Star
- Dragonfly Doji/T Doji 19. Engulfing Pattern 20. Evening Doji Star 21. Evening Star 22. Falling/ Rising Three Methods (Side-by-Side White Lines) 23. Gravestone Doji/Inverted T Doji
- Hammer 25. Hanging Man 26. Harami (Mother-Child) 27. Harami Cross 28. High Wave 29. Ladder Bottom/Top 30. Last Engulfing Pattern 31. Ladder Bottom/Top 32. Identical Three Crows
- In-Neck Line 34. Inverted Hammer 35. Kickback (Kicking) 36. Long-legged Doji (Long Shadow Kicking) 37. Ladder Bottom 38. Long-Legged Doji 39. Long Candle
- Marubozu (Shaven Head/Shaven Bottom/No Shadow) 41. Matching Low 42. Mat Hold 43. Morning Doji Star 44. Morning Star 45. On-Neck Line 46. Piercing Line 47. Rickshaw Man
- Rising/Falling Three Methods 49. Separating Lines 50. Shooting Star 51. Short Candle 52. Spinning Top 53. Stall/Stop Pattern 54. Sandwich (Bar Sandwich) 55. Tasuki Gap (Probe Pole)
- Tasuki Gap (Up/Downside Tasuki Gap) 57. Thrusting Line 58. Tri-Star 59. Unique Three River Bottom 60. Upside Gap Two Crows 61. Upside/Downside Gap Three Methods
Pattern Recognition Result:Negative: Sell signal appeared 0: Pattern did not appear Positive: Buy signal appeared ``
6: Chip Distribution
Chip distribution calculates and outputs a graph showing the distribution of trading volume at various price levels relative to the total tradable shares within a specified time range (using High, Low, and Volume). Calculation is efficient and accurate, consistent with professional software like East Money. By default, it calculates the cost over 210 trading days, and the time range can be customized.
7: Strategy-Based Stock Selection
Includes multiple built-in stock selection strategies such as Volume Surge, Parking Lot, Annual Line Pullback, Platform Breakout, Volume Limit-Down, etc. It also encapsulates strategy templates for easy extension to implement custom strategies. ``
- Volume Surge
- Today’s increase from yesterday is less than 2%, or the closing price is lower than the opening price.
- Today’s turnover is at least 200 million CNY.
- Today’s volume / 5-day average volume >= 2.
- Bullish Moving Average Alignment
MA30 is upward.
- 30-day MA 30 days ago < 30-day MA 20 days ago < 30-day MA 10 days ago < Current 30-day MA.
- (Current 30-day MA / 30-day MA 30 days ago) > 1.2.
- Parking Lot
- In the last 15 days, there is a day with a gain > 9.5%, and it must be a volume surge.
- The immediately following trading day must open higher, close higher, and the difference between close and open cannot be >= 3%.
- For the next 2-3 trading days, they must open higher, close higher, the difference between close and open cannot be >= 3%, and daily fluctuation is within 5%.
- Annual Line Pullback
- Divided into 2 time periods: First period = trading days before the day with the highest closing price in the last 60 trading days (length > 0); Second period = the highest price day and subsequent days.
- The first period breaks upward from below the annual line (250-day MA).
- The second period must trade above the annual line, and the difference between the day of the lowest price and the day of the highest price in the second period must be 10-50 days.
- Pullback accompanied by volume shrinkage: Volume on the highest price day / Volume on the second period’s lowest price day > 2, and (Second period’s lowest price / Highest price) < 0.8.
- Platform Breakout
- On a day within 60 days, closing price >= 60-day MA > opening price.
- And [1] is a volume surge.
- And before [1], for any day, the deviation between closing price and 60-day MA is between -5% and 20%.
- No Significant Drawdown
- Today’s closing price increase compared to 60 days ago is less than 0.6 (i.e., < 60% gain).
- In the last 60 days, there cannot be a single-day drop > 7%, a high-open-low-close drop of 7%, a two-day cumulative drop of 10%, or a two-day cumulative high-open-low-close drop of 10%.
- Turtle Trading Rules
The closing price on the last trading day is the highest within a specified range.
- Today’s closing price >= The highest closing price in the last 60 days.
- High and Narrow Flag
- Must have been listed and traded for at least 60 days.
- Today’s closing price / Lowest price in the prior 24-10 days >= 1.9.
- Within the prior 24-10 days, there must be two consecutive days with a gain >= 9.5%.
- Volume Limit-Down
- Drop > 9.5%.
- Turnover is at least 200 million CNY.
- Volume is at least 4 times the 5-day average volume.
- Low ATR Growth
- Must have been listed and traded for at least 250 days.
- The highest closing price in the last 10 trading days must be at least 1.1 times higher than the lowest closing price in the last 10 trading days.
- Fundamental Stock Selection
- P/E ratio <= 20 and > 0.
- P/B ratio <= 10.
- Return on Equity (ROE) >= 15%. ``
8: Selection Verification
Backtests stocks selected by indicators and strategies to verify the success rate and usability of the strategy.
9: Automated Trading
Supports automated trading. Includes built-in IPO subscription strategies and example strategies. Due to involving money, and to mitigate potential risks, no other trading strategies are provided.
Features trading logs and supports configuring separate trading logs for each strategy.
Special Reminder: The IPO subscription is triggered at 10:00 AM on trading days. If you do not want IPO subscription, delete stagging.py or do not start the “Trading Service”.
10: Watchlist Feature
Supports stock watchlisting. Watchlisted stocks are pinned to the top and highlighted in red across relevant modules.
11: Supports Batch Operations
Supports indicator calculation, strategy stock selection, and backtesting over a specific time period, enumerated times, or the current time. It also intelligently recognizes trading days and accepts any date input. Specific execution settings are as follows: `` ——Overall Jobs, Supports Batch Operations—— Current Time Job: python execute_daily_job.py Single Time Job: python execute_daily_job.py 2022-03-01 Enumerated Time Job: python execute_daily_job.py 2022-01-01,2021-02-08,2022-03-12 Time Range Job: python execute_daily_job.py 2022-01-01 2022-03-01
——Single Function Jobs, Supports Batch Operations, Backtest Data Automatically Filled to Current—— Basic Data Real-time Job: python basic_data_daily_job.py Basic Data Non-real-time Job: python basic_data_other_daily_job.py Indicator Data Job: python indicators_data_daily_job.py K-line Pattern Job: klinepattern_data_daily_job.py Strategy Data Job: python strategy_data_daily_job.py Backtest Data: python backtest_data_daily_job.py ``
12: Supports Proxies and Cookies
Supports data fetching via multiple proxies. Many websites have protection mechanisms against high-frequency requests; frequent access from a single IP may lead to blocking or restriction. Proxy IPs help disperse request sources, preventing single-IP blocks and ensuring stable crawler operation. Supports Cookie injection to bypass data fetching frequency limits and restrictions.
13: Database-Designed Storage
Data storage uses a database design, enabling historical data preservation and extended analysis, statistics, and mining. The system automatically creates databases and tables, and encapsulates batch updates and inserts for easy business expansion.
14: Web-Designed Display
Uses web design for visual result presentation. Display is encapsulated; adding new business forms only requires configuring a view dictionary to automatically generate the corresponding business visualization interface, facilitating business function expansion.
15: Efficient Operation
Utilizes multithreading and singleton shared resources to effectively improve computation efficiency. All tasks for one day—data fetching, indicator calculation, pattern recognition, strategy stock selection, backtesting—take approximately 4 minutes total on an ordinary laptop. Efficiency increases with the number of days processed.
16: Convenient Debugging
Key logs of system operations are recorded in stock_execute_job.log (data fetching, processing, analysis), stock_web.log (web service), and stock_trade.log (trading service), facilitating debugging and issue identification.
Installation Instructions
This system supports Windows, Linux, and MacOS. Docker images are also created. Choose the installation method according to your needs. The following covers standard installation and Docker image installation methods separately.
1: Standard Installation Method
Recommended for installation on Windows for ease of operation and use; installation is also straightforward. The following installation and run examples use Windows.
1. Install Python
The project was developed using Python 3.11; the latest version is recommended. `` (1) Download the installer from the official website https://www.python.org/downloads/ and perform a one-click installation. Remember to check the option to automatically set environment variables during installation. (2) Configure a permanent global mirror library (due to the Great Wall, library files cannot be installed normally) by executing the following DOS command: python pip config –global set global.index-url https://mirrors.aliyun.com/pypi/simple/
If you only want to set it for the current user, you can omit the “–global” option
``
2. Install MySQL
The latest version is recommended.
Download the installer from the official website https://dev.mysql.com/downloads/mysql/ and perform a one-click installation.
3. Install TA-Lib Shared Static Library and Header Files
Install the TA-Lib C/C++ shared static library and header files.
Download the latest TA-Lib shared static library and header files from https://ta-lib.org/install/ and install according to the instructions. Installation is simpler following the official recommendation: Windows Executable Installer macOS Homebrew Linux Debian packages
4. Install Dependency Libraries
Dependency libraries are currently the latest versions. a. Install dependency libraries: ``
In DOS, switch to the root directory of this system and execute the following command:
python -m pip install -r requirements.txt
b. To upgrade project dependencies to the latest version: First open `requirements.txt`, then modify the "==" in the file to ">=", then execute the following command:
python -m pip install -r requirements.txt –upgrade
c. If you have extended this project, you can generate project dependencies via:
Use pipreqs to generate requirements.txt for project dependencies
python -m pip install pipreqs
Install pipreqs (skip if already installed)
python -m pipreqs –encoding utf-8 –force ./
This project uses utf-8 encoding
``
5. Install Navicat (Optional)
Navicat conveniently manages databases and allows manual viewing, processing, analysis, and mining of data.
Navicat is a set of database management tools that can create multiple connections to manage different types of databases like MySQL, Oracle, PostgreSQL, SQLite, SQL Server, MariaDB, and MongoDB.
(1) Download the installer from the official website https://www.navicat.com.cn/download/navicat-premium and perform a one-click installation. (2) Then download the crack patch: https://pan.baidu.com/s/18XpTHrm9OiLEl3u6z_uxnw Extraction Code: 8888, and apply the crack.
6. Configure Database
Information commonly modified is “database access password”.
Modify relevant information in database.py:
db_host = "localhost" # Database server host db_user = "root" # Database access user db_password = "root" # Database access password db_port = 3306 # Database server port db_charset = "utf8mb4" # Database character set
7. Configure Proxy
Skip this step if not using a proxy.
Specific settings:
Edit proxy.txt, add valid proxies in the format: ip:port, for authenticated proxies: username:password@ip:port, with each proxy on a new line. Clear the file when not using a proxy.
After editing and saving the proxy file, if the system is already running, it needs to be restarted for the changes to take effect.
Proxy examples:
127.0.0.1:7860 52.13.248.29:3128 35.178.104.4:80 abc:[email protected]:3128 13.126.79.133:80 54.212.22.168:3128
Note: All the above are invalid proxies.
8. Set East Money Cookie
High-frequency data fetching from East Money can lead to restrictions. This can be resolved by injecting a cookie. Detailed steps: ``
- Obtain Cookie
Open a browser and visit the East Money quote page: https://quote.eastmoney.com/center/gridlist.html#hs_a_board
Log in to your account (if you have an East Money account, it’s recommended to log in to obtain a more stable cookie).
Open Developer Tools:
Switch to the Network tab
Refresh the page (press F5 or click the browser refresh button)
Select any request: From the network request list, select any request (preferably one with a URL containing
push2.eastmoney.com). View Cookie: In the request details, find the Request Headers section and copy the complete Cookie value. Save Cookie: Save the copied cookie value for later use. - Two Ways to Set Cookie
Method 1: Via Environment Variable (Recommended)
Windows System:
CMD command:
setx EAST_MONEY_COOKIE "your_cookie_value"Restart Python Environment: After setting the environment variable, restart the Python IDE or command prompt window. Linux/macOS System: Bash command:export EAST_MONEY_COOKIE="your_cookie_value"Note: This method only takes effect in the current terminal session. To set it permanently, you need to edit the~/.bashrcor~/.zshrcfile. Method 2: Via File Edit theeastmoney_cookie.txtfile and replace the cookie. - Notes Cookie Expiry: East Money cookies typically expire after a period (usually a few days to a few weeks). If it suddenly stops working, the cookie may have expired and needs to be re-obtained and set. Regular Updates: It is recommended to update the cookie periodically (e.g., weekly) to ensure stable crawling. Multi-Account Rotation: If you have multiple East Money accounts, rotating between cookies from different accounts can further reduce the risk of restriction. ``
9. Install Automated Trading (Optional)
``
- Install Trading Software 1.1 Clients for brokerages using the generic TongHuaShun client: Generic TongHuaShun client: https://activity.ths123.com/acmake/cache/1361.html 1.2 Clients for brokerages using a dedicated TongHuaShun client: Find the dedicated TongHuaShun version on the brokerage’s official website. Example: GF Securities’ standalone Hexin Order Entry (TongHuaShun version): http://www.gf.com.cn/softdownload/index?tab=1
- Install tesseract (Automatic CAPTCHA Recognition)
First method: Download pre-compiled version
On the following link page, select the version corresponding to your operating system:
https://digi.bib.uni-mannheim.de/tesseract/
Second method: Compile from source
Download source code: https://github.com/tesseract-ocr/tesseract
Note:
After installation, add the installation path to the PATH environment variable.
The following DOS command provides setting instructions (run cmd as administrator):
setx /m PATH "%PATH%;C:\Program Files\Tesseract-OCR" - Set Trading Configuration
3.1. Modify
trade_client.json"user": "888888888888", # Trading account"password": "888888", # Trading password"exe_path": "C:/gfzqrzrq/xiadan.exe" # Path to trading software executable3.2. Modifytrade_service.pybroker = 'gf_client' # This is for GF SecuritiesFor details, refer tousage.mdto configure the corresponding brokerage. ``
10. Running Instructions
10.1. Execute Data Fetching, Processing, Analysis, and Recognition
Supports batch operations. See the comments in run_job.bat for details.
It is recommended to add this to the Task Scheduler to run daily at 17:00 on working days.
Data Fetching and Processing Principles:
1). Available as soon as the market opens and no historical data exists: Comprehensive stock selection, daily stock data, stock capital flow, stock dividends and distributions, Dragon & Tiger List, daily ETF data.
2). Available after market close and historical data exists: Stock indicator data, stock K-line patterns, stock strategy data.
3). Available 1-2 hours after market close and historical data exists: Block trades.
Run run_job.bat. It will fetch data for each module for the current or previous trading day based on the above principles.
``
Run run_job.bat
To view real-time data after market open, you can run the following, which is very fast (approx. 1 second):
Basic data job
python basic_data_daily_job.py ``
10.2. Start Web Service
Run `run_web.bat`
After starting the service, open a browser and enter: http://localhost:9988/ to use the system’s visualization features.
10.3. Start Trading Service
Run `run_trade.bat`
2: Docker Image Installation Method
If you don’t have a Docker environment, you can refer to: VirtualBox VM Installation of Ubuntu (https://www.ljjyy.com/archives/2019/10/100590.html), which also covers the installation of common software like Python and Docker. For installing Docker on Windows, please search online.
1. Configure Proxy
Skip this step if not using a proxy.
After system installation, the proxy can be configured by editing the proxy file on the host machine.
Specific settings:
Edit the proxy file on the host, add valid proxies in the format: ip:port, for authenticated proxies: username:password@ip:port, with each proxy on a new line. Clear the file when not using a proxy.
After editing the proxy file, if the system is already running, it needs to be restarted for the changes to take effect.
Proxy creation examples:
``
sudo sh -c ‘echo “127.0.0.1:7860” > /data/instockproxy.txt’
Create proxy file, will automatically replace the original proxy file
sudo sh -c ‘echo “52.13.248.29:3128” >> /data/instockproxy.txt’
Append proxy
sudo sh -c ‘echo “abc:[email protected]:80” >> /data/instockproxy.txt’
Append proxy
`` Note: All the above are invalid proxies.
2. Configure East Money Cookie
Skip this step if not using a cookie. After system installation, the cookie can be configured by editing the proxy file on the host machine. For details, please refer to: Standard Installation Method, Set East Money Cookie. `` sudo sh -c ‘echo “your_cookie_value” > /data/eastmoneycookie.txt’
Create proxy file, will automatically replace the original proxy file
``
3. Install Database Image
Skip this step if you already have a MySQL or MariaDB database.
Run the following commands:
**Special Reminder: The user executing the commands must have root privileges. The same applies to other commands. For example, on Ubuntu, prefix commands with sudo**: sudo docker……`
``
docker network create InStockService
docker run -d –name InStockDbService
–network InStockService
-v /data/mariadb/data:/var/lib/instockdb
-e MYSQL_ROOT_PASSWORD=root
library/mariadb:latest
``
4. Install System Image
a. If the database was installed as in [1. Install Database Image] above, run the following command:
docker run -dit --name InStock --network=InStockService \ -p 9988:9988 \ -v /data/instockproxy.txt:/data/InStock/instock/config/proxy.txt \ -v /data/eastmoneycookie.txt:/data/InStock/instock/config/eastmoney_cookie.txt \ -e db_host=InStockDbService \ mayanghua/instock:latest
b. If you already have a MySQL or MariaDB database, run the following command:
docker run -dit --name InStock \ -p 9988:9988 \ -v /data/instockproxy.txt:/data/InStock/instock/config/proxy.txt \ -v /data/eastmoneycookie.txt:/data/InStock/instock/config/eastmoney_cookie.txt \ -e db_host=localhost \ -e db_user=root \ -e db_password=root \ -e db_database=instockdb \ -e db_port=3306 \ mayanghua/instock:latest
Docker -e parameter explanation:
db_host # Database server host db_user # Database access user db_password # Database access password db_database # Database name db_port # Database server port
Configure parameters according to your actual database setup.
5. System Operation
After starting the container, it will run automatically. First, it will initialize data and start the web service. Then, it executes “basic data fetching” every hour, and all data fetching, processing, analysis, recognition, and backtesting daily at 17:30. Open a browser and enter: http://localhost:9988/ to use the system’s visualization features.
6. Historical Data
For historical data fetching, processing, analysis, recognition, and backtesting, run the following command: `` docker exec -it InStock bash cat InStock/instock/bin/run_job.sh
View comments in run_job.sh and choose your job accordingly
——Overall Jobs, Supports Batch Operations—— Current Time Job: python execute_daily_job.py Single Time Job: python execute_daily_job.py 2022-03-01 Enumerated Time Job: python execute_daily_job.py 2022-01-01,2021-02-08,2022-03-12 Time Range Job: python execute_daily_job.py 2022-01-01 2022-03-01 ——Single Function Jobs, Supports Batch Operations, Backtest Data Automatically Filled to Current—— Comprehensive Stock Selection Job: python selection_data_daily_job.py Basic Data Real-time Job: python basic_data_daily_job.py Basic Data Post-Market (2 Hours) Job: python backtest_data_daily_job.py Basic Data Non-real-time Job: python basic_data_other_daily_job.py Indicator Data Job: python indicators_data_daily_job.py K-line Pattern Job: klinepattern_data_daily_job.py Strategy Data Job: python strategy_data_daily_job.py Backtest Data: python backtest_data_daily_job.py First method: python execute_daily_job.py 2023-03-01,2023-03-02 Second method: Modify run_job.sh, then run: bash InStock/instock/bin/run_job.sh ``
7. View Logs
Run the following command:
docker exec -it InStock bash cat InStock/instock/log/stock_execute_job.log cat InStock/instock/log/stock_web.log
8. Common Docker Commands
`` docker container stop InStock InStockDbService
Stop containers
docker container prune
Remove stopped containers
docker rmi mayanghua/instock:latest library/mariadb:latest
Delete images
`` For details, see: Docker Basics Part 2 - Basic Operations of Images and Containers (https://www.ljjyy.com/archives/2018/06/100208.html)
9. Automated Trading
Currently only supported on Windows. Refer to the Standard Installation Method; only Python and dependency libraries need to be installed. No need to install MySQL, TA-Lib, etc.
Special Disclaimer
Stock market investment carries risks. This system is for learning and stock analysis purposes only. The developers are not responsible for any gains or losses incurred from investment. The tables in this system are third-party commercial controls, used only in their evaluation version for learning and testing purposes.
Similar Articles
@_zheergen: Guys! Found another all-in-one Python stock tool — InStock. The myhhub/stock repository covers A-share quantitative analysis quite comprehensively: data scraping, indicator calculation, stock selection, backtesting, and automated trading all in one. Let me highlight the core features: Real-time A-share data scraping + 30…
Introduces the open-source Python tool InStock (myhhub/stock) for A-share quantitative analysis, supporting data scraping, technical indicators, stock selection, backtesting, automated trading, etc., and can be deployed via Docker.
@_zheergen: The biggest headache with quantitative stock trading isn't a lack of tools — it's too many tools, and no idea which one to pick. Market data, strategy backtesting, live trading, risk analysis — you have to hunt for a new project at every step. This awesome-systematic-trading repo on GitHub, with 5.3K Stars, maps out...
An introduction to the awesome-systematic-trading open-source project on GitHub (5.3K Stars), which curates the market data, backtesting, live trading, AI quant, and risk management tools needed for quantitative trading into a comprehensive navigation index, covering markets such as stocks, futures, options, and cryptocurrencies.
@axichuhai: Found a 50k-star project on GitHub that turns AI models into automated stock analysts. Just configure your watchlist, and it automatically pulls candlestick charts, technical indicators, news announcements, and fundamental data to generate a decision dashboard. Core conclusions, trend scores, buy/sell points, risk alerts, catalysts, and operations...
This is a 50k-star open-source project on GitHub that uses AI models to automatically analyze stock quotes, technical indicators, and fundamental data, generating a decision dashboard with trend scores, buy/sell points, and risk alerts. It supports daily automated runs and multi-platform push notifications.
@eastweb3eth: InStock Stock System – The repository with 13.8K stars doesn't need any praise. Those interested can just dive in, one of the best open-source stock systems, and natively in Chinese. Repository: https://github.com/myhhub/stock. Quick feature overview: 1. Comprehensive stock selection ...
InStock is an open-source stock quantitative investment system that provides comprehensive stock selection, technical indicator calculation, K-line pattern recognition, automatic trading, and more, with 13.8K GitHub stars.
@geekbb: Open-source A-share quantitative workstation, using TickFlow data for three tasks: stock selection, real-time monitoring, and backtesting. Built-in 20 stock selection strategies (Polars vectorization runs all A-shares in seconds), supports no-code custom signals, AI strategy writing, multi-condition monitoring rules + Feishu push. https:…
Open-source A-share quantitative workstation, based on TickFlow data, implements three functions: stock selection, real-time monitoring, and backtesting. Built-in 20 Polars vectorized strategies, supports AI strategy writing and Feishu push.