@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 ...
Summary
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.
View Cached Full Text
Cached at: 08/17/26, 10:22 PM
InStock Stock System
A repository with over 13.8K stars that needs no further praise. If you need it, go ahead and get it—one of the best open-source stock systems, and it’s natively in Chinese.
Repository URL: https://github.com/myhhub/stock
A brief overview of its features:
- Comprehensive stock screening
- Daily stock data
- Stock indicator calculation
- Buy and sell signal detection
- K-line pattern recognition
- Chip distribution (Position Cost Distribution)
- Strategy-based stock selection
- Stock selection validation
- Automated trading
I’m Nika, and I regularly share useful and interesting tools and projects related to AI, U.S. stocks, and Web3. If you’re interested, feel free to follow. See you next time~
myhhub/stock
Source: https://github.com/myhhub/stock
Corresponding IMA Knowledge Base (https://ima.qq.com/wiki/?shareId=8b0da768c77bc863f1cad8eb9482e37a6eeb26ad7171523b687d48c1a67c8e2c): Stock Quantitative Factor AI Decision Engine, with over 2,200 professional factor dimensions. AI deep analysis of multidimensional data, precisely identifies high-certainty stocks, empowering efficient and stable professional investment decisions. https://ima.qq.com/wiki/?shareId=8b0da768c77bc863f1cad8eb9482e37a6eeb26ad7171523b687d48c1a67c8e2c.
InStock Stock System
The InStock stock system captures daily key data for stocks and ETFs, calculates technical indicators, chip distribution (Position Cost Distribution - CYQ), identifies various K-line patterns, performs comprehensive stock selection, includes built-in multiple stock selection strategies, supports stock selection validation and backtesting, supports automated trading, supports batch processing, runs efficiently, supports display on PC, tablet, and mobile devices, and provides Docker images for easy installation. It is a valuable assistant for quantitative investment.
Docker Image: https://hub.docker.com/r/mayanghua/instock
Feature Introduction
1: Comprehensive Stock Selection
Comprehensive stock selection supports free combination of stock screening based on over 200 information categories across stock scope, fundamentals, technicals, news, sentiment indicators, and market data. Stock screening conditions are divided into the following main categories:
1. Stock Scope
Market, Industry, Region, Concept, Style, Index Component, Listing Date.
2. Fundamentals
Valuation Indicators, Per-Share Indicators, Profitability, Growth Ability, Capital Structure & Debt Solvency, Equity & Shareholders.
3. Technicals
MACD Golden Cross, KDJ Golden Cross, Volume Breakout, Low-Position Net Capital Inflow, High-Position Net Capital Outflow, Upward Breakthrough Moving Averages, Bullish MA Arrangement, Bearish MA Arrangement, Rising with Volume, Falling without Volume, One Large Bullish Candle, Two Large Bullish Candles, Morning Star (Rising Sun), Strong Bullish, Cannon Shot Through Clouds, Seven Fairies Descending (Seven Consecutive Yin), Eight Immortals Crossing the Sea (Eight Consecutive Yang), Nine Yang Divine Art (Nine Consecutive Yang), Four Consecutive Yang, Volume Rule, Volume-Upward Attack, Engulfing Pattern (Piercing), Inverted Hammer, Shooting Star, Evening Star, Morning Star (Dawn), Harami, Dark Cloud Cover, Morning Star, Narrow Range Consolidation.
4. News
Announcements of Major Events, Institutional Attention, Number of Institutional Holdings, Percentage of Institutional Holdings.
5. Sentiment Indicators
Stock Forum Popularity Ranking, Popularity Ranking Change, Popularity Ranking Consecutive Rise, Popularity Ranking Consecutive Fall, Popularity Ranking New High, Popularity Ranking New Low, Proportion of New Fans, Proportion of Loyal Fans, 7-Day Attention Ranking, Today's View Ranking.
6. Market Data
Stock Price Performance, Trading Volume, Capital Flow, Market Statistics, Shanghai/Shenzhen Stock Connect.
2: Daily Stock Data
Includes daily stock data, stock capital flow, stock dividends and distributions, stock Dragon & Tiger List, stock block trades, stock fundamental data, industry capital flow, concept capital flow, pre-market capital grabbing data, post-market capital grabbing data, limit-up reason disclosure, and daily ETF data.
Captures A-share daily data, focusing on key metrics, while encapsulating data fetching methods to facilitate extending the system to acquire data of personal interest.
3: Stock Indicator Calculation
Calculates indicators based on talib and pandas, offering high efficiency and accuracy. Adjusts specific indicator formulas to ensure results align with those from platforms like TongHuaShun and TongXinDa. Indicators:
1. MACD 2. KDJ 3. BOLL 4. TRIX, TRMA 5. CR 6. SMA 7. RSI
8. VR, MAVR 9. ROC 10. DMI, +DI, -DI, DX, ADX, ADXR 11. W&R
12. CCI 13. TR, ATR 14. DMA, AMA 15. OBV 16. SAR 17. PSY
18. BRAR 19. EMV 20. BIAS 21. TEMA 22. MFI 23. VWMA
24. PPO 25. WT 26. Supertrend 27. DPO 28. VHF 29. RVI
30. FI 31. ENE 32. STOCHRSI
4: Determine Buy/Sell Signals for Stocks
Determines potential buy/sell signals based on indicators. Specific screening conditions are as follows:
KDJ:
1. Overbought Zone: K above 80, D above 70, J above 90 indicates overbought. Generally, the stock price may fall. Investors should act with caution; outsiders should avoid chasing the rise, and insiders should sell at appropriate times.
2. Oversold Zone: K below 20, D below 30 indicates oversold. Generally, the stock price may rise, and the possibility of a rebound increases. Insiders should not sell stocks lightly, and outsiders can look for entry opportunities.
RSI:
1. When the 6-day indicator rises to 80, it indicates overbought conditions. If it continues to rise above 90, it enters a severe overbought warning zone, the stock price has likely formed a top, and a reversal in the short term is very possible.
2. When the 6-day strength indicator falls to 20, it indicates oversold conditions. If it continues to fall below 10, it enters a severe oversold zone, and the stock price has a very high chance of stopping its decline and rebounding.
CCI:
1. When CCI > +100, it indicates the stock price has entered an abnormal range—the overbought range. Abnormal price movements should be watched closely.
2. When CCI < -100, it indicates the stock price has entered another abnormal range—the oversold range. Investors can buy stocks on dips.
CR:
1. When CR falls below the a, b, c, d lines, then climbs back up to 160 from a low point, it is a good opportunity for short-term profit-taking, and stocks should be sold appropriately.
2. When CR falls below 40, it is a good opportunity to build positions.
WR:
1. When the %R line reaches 20, the market is overbought, and the trend may soon peak.
2. When the %R line reaches 80, the market is oversold, and the stock price trend may bottom out at any time.
VR:
1. Profit-taking zone 160-450: Take profits based on the situation.
2. Low-price zone 40-70: Can buy in.
5: K-line Pattern Recognition
Accurately identifies 61 K-line patterns and supports user-defined pattern recognition.
Identified Patterns:
1. Two Crows 2. Three Crows 3. Three Inside Up/Down 4. Three Line Strike 5. Three Outside Up/Down 6. Three Stars in the South 7. Three White Soldiers 8. Abandoned Baby
9. Concealing Baby Swallow 10. Belt Hold Line 11. Breakaway 12. Closing Marubozu (No Shadow) 13. Concealing Baby Swallow 14. Counterattack Lines 15. Dark Cloud Cover 16. Doji 17. Doji Star
18. Dragonfly Doji / T-shaped Doji 19. Engulfing Pattern 20. Doji Evening Star 21. Evening Star 22. Falling/ Rising Gapping Side-by-Side White Lines 23. Gravestone Doji / Inverted T Doji
24. Hammer 25. Hanging Man 26. Harami (Bullish/Bearish) 27. Harami Cross 28. High Wave 29. Hook Reversal 30. Modified Hikkake 31. Homing Pigeon 32. Identical Three Crows
33. In-Neck Line 34. Inverted Hammer 35. Kickback Reversal 36. Kicking 37. Ladder Bottom 38. Long-Legged Doji 39. Long Line (Marubozu)
40. Marubozu / 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
48. Rising/ Falling Three Methods 49. Separating Lines 50. Shooting Star 51. Short Line 52. Spinning Top 53. Stall Pattern 54. Stick Sandwich 55. Take Me Higher
56. Tasuki Gap (Downside/ Upside) 57. Thrusting Pattern 58. Tri Star 59. Tristar Pattern 60. Upside Gap Two Crows 61. Upside/ Downside Gap Three Methods
Pattern Recognition Results:
Negative: Sell signal appeared
0: Pattern did not appear
Positive: Buy signal appeared
6: Position Cost Distribution (Chip Distribution)
Position Cost Distribution calculates, within a certain time range, the highest price, lowest price, and trading volume of a stock, outputting a distribution graph of the trading volume at corresponding prices relative to the total tradable shares. The calculation is highly efficient and accurate, with results consistent with professional software like East Money. The default calculation covers the cost over 210 trading days, which can be customized.
7: Strategy-Based Stock Selection
Includes built-in multiple stock selection strategies such as Volume Surge Rise, Tarmac, Yearly Line Retest, Platform Breakthrough, Volume Limit-Down, and more. It also encapsulates strategy templates to facilitate implementing custom strategies.
1. Volume Surge Rise
1) Current day rise from previous day is less than 2%, or closing price is lower than opening price.
2) Current day trading amount is not less than 200 million.
3) Current day volume / 5-day average volume >= 2.
2. Bullish MA Arrangement
MA30 upward trend
1) 30-day MA from 30 days ago < 20-day MA < 10-day MA < Current day's 30-day MA.
2) (Current day's 30-day MA / 30-day MA from 30 days ago) > 1.2.
3. Tarmac
1) Within the last 15 days, there is a rise greater than 9.5%, and it must be a volume-up rise.
2) The immediately following trading day must open higher, close higher, and the difference between closing and opening price must not be greater than or equal to 3%.
3) For the next 2-3 trading days, it must open higher, close higher, and the difference between closing and opening price must not be greater than or equal to 3%, with daily fluctuations within 5%.
4. Yearly Line Retest
1) Divided into two time periods: Pre-period = trading days before the highest closing price in the last 60 trading days (length > 0), Post-period = the day of the highest price and subsequent trading days.
2) The pre-period shows a breakout from below the yearly line (250-day MA).
3) The post-period must operate above the yearly line, and the difference between the day of the lowest price and the day of the highest price in the post-period must be between 10-50 days.
4) Retest accompanied by shrinking volume: Volume on the highest price day / Volume on the post-period's lowest price day > 2, and post-period's lowest price / highest price < 0.8.
5. Platform Breakthrough
1) Within 60 days, there is a day where closing price >= 60-day MA > opening price.
2) And on that day, there is a volume-up rise.
3) And on any day prior to that day within the 60-day period, the closing price deviation from the 60-day MA is between -5% and 20%.
6. No Significant Drawdown
1) The current day's closing price increase from the closing price 60 days ago is less than 0.6.
2) Within the last 60 days, there should be no single-day drop exceeding 7%, no high-open-low-close exceeding 7%, no two-day cumulative drop of 10%, and no two-day cumulative high-open-low-close of 10%.
7. Turtle Trading Rules
The closing price of the last trading day is the highest price within a specified range.
1) Current day's closing price >= Highest closing price in the last 60 days.
8. High and Narrow Flag
1) Must have been listed for at least 60 trading days.
2) Current day's closing price / Lowest price within the previous 24-10 days >= 1.9.
3) Within the previous 24-10 days, there must be two consecutive days with rises greater than or equal to 9.5%.
9. Volume Limit-Down
1) Drop > 9.5%.
2) Trading amount is not less than 200 million.
3) Volume is at least 4 times the 5-day average volume.
10. Low ATR Growth
1) Must have been listed for at least 250 trading days.
2) The highest closing price in the last 10 trading days must be 1.1 times higher than the lowest closing price in the last 10 trading days.
11. Fundamental Stock Selection
1) Price-to-Earnings Ratio <= 20, and > 0.
2) Price-to-Book Ratio <= 10.
3) Return on Equity >= 15.
8: Stock Selection Validation
Conducts backtesting on stocks selected by indicators or strategies to verify the success rate and usability of the strategy.
9: Automated Trading
Supports automated trading, with built-in IPO subscription strategies and example strategies. Due to involving money, to mitigate potential risks, other trading strategies are not provided.
Includes trade logs and supports configuring trade logs for each trading strategy.
Special Reminder: The trading day at 10:00 triggers IPO subscription. If you do not want to subscribe, delete stagging.py or do not start the “Trading Service”.
10: Watchlist Feature
Supports adding stocks to a watchlist. Watchlisted stocks are pinned to the top and highlighted in red across all relevant modules.
11: Batch Processing Support
Supports indicator calculation, strategy-based stock selection, and backtesting across time periods, enumerated dates, or the current date. It also intelligently identifies trading days, allowing input of any date.
Specific execution settings are as follows:
------Overall Job, Supports Batch Jobs------
Current Date Job: python execute_daily_job.py
Single Date Job: python execute_daily_job.py 2022-03-01
Enumerated Dates Job: python execute_daily_job.py 2022-01-01,2021-02-08,2022-03-12
Date Range Job: python execute_daily_job.py 2022-01-01 2022-03-01
------Single Function Jobs, Supports Batch Jobs, Backtest Data Automatically Fills to Current Date
Real-time Basic Data Job: python basic_data_daily_job.py
Non-real-time Basic Data 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 Job: python backtest_data_daily_job.py
12: Proxy and Cookie Support
Supports multiple proxies for data fetching. Many websites have protection mechanisms against large volumes of requests. Frequent access from a single IP address may lead to blocking or rate limiting. Proxy IPs help distribute request sources, avoiding single IP bans, thus ensuring the stable operation of the crawling program. Supports Cookie injection to resolve high-frequency data fetching limits.
13: Database Storage Design
Data storage uses a database design, capable of preserving historical data and enabling extended analysis, statistics, and mining of data. The system implements automatic database and table creation, encapsulating batch updates and data insertion to facilitate business expansion.
14: Web-based Display Design
Uses web design for visual result presentation. Display components are encapsulated; adding new business forms only requires configuring a view dictionary to automatically generate the corresponding business visualization interface, facilitating business function expansion.
15: High Efficiency
Utilizes multithreading and singleton pattern for shared resources to effectively improve computation efficiency. The entire process of capturing 1 day of data, calculating indicators, pattern recognition, strategy stock selection, backtesting, etc., takes approximately 4 minutes on an ordinary laptop. Efficiency increases with more calculation days.
16: Easy Debugging
Important logs for system operation 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 based on your needs.
Below are step-by-step instructions for regular installation and Docker image installation.
1: Regular Installation Method
It is recommended to install on Windows for easier operation and use of the system. Installation is also very simple.
The following installation and running instructions use Windows as an example.
1. Install Python
The project was developed using Python 3.11. The latest version is recommended.
(1) Download the installation package 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 domestic mirror repository (due to the Great Firewall, 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 remove the "--global" option below.
2. Install MySQL
The latest version is recommended.
Download the installation package 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 follow the instructions for installation.
The installation method recommended by the official site is simpler:
Windows Executable Installer
macOS Homebrew
Linux Debian packages
4. Install Dependencies
Dependencies are all the latest versions.
a. Install dependencies:
# Switch DOS 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, use the following method:
Open requirements.txt, change “==” to “>=” in the file, 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 using the following method:
# Use pipreqs to generate requirements.txt for project-related 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 facilitates database management and allows manual viewing, processing, analysis, and mining of data.
Navicat is a database management tool that supports multiple connections, making it convenient to manage various database types such as MySQL, Oracle, PostgreSQL, SQLite, SQL Server, MariaDB, and MongoDB.
(1) Download the installation package 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 the Database
The information that might be modified is the “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
If not using a proxy, skip this step.
Specific settings are as follows:
Edit proxy.txt, adding 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 proxies.
After editing and saving the proxy file, if the system is already running, it needs to be restarted for the changes to take effect.
Example proxies:
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: The above are all invalid proxies.
8. Set East Money Cookie
Frequent data fetching from East Money may lead to rate limiting, which can be resolved by injecting a cookie. Here are the detailed steps:
1. Obtain the Cookie
Open a browser and visit the East Money quote page: https://quote.eastmoney.com/center/gridlist.html#hs_a_board
Log in (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's refresh button).
Select any request: In 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.
2. Two Methods to Set the Cookie
Method 1: Via Environment Variable (Recommended)
Windows:
Command Prompt: setx EAST_MONEY_COOKIE "Your Cookie Value"
Restart Python environment: After setting the environment variable, restart your Python IDE or Command Prompt window.
Linux/macOS:
Bash command: export EAST_MONEY_COOKIE="Your Cookie Value"
Note: This method is only effective in the current terminal session. To set it permanently, edit ~/.bashrc or ~/.zshrc.
Method 2: Via File
Edit the `eastmoney_cookie.txt` file, replacing the Cookie.
3. Notes
Cookie Validity: East Money Cookies typically expire after a period (usually a few days to weeks). If it suddenly stops working, the Cookie might have expired and needs to be re-obtained and set.
Regular Updates: It's recommended to update the Cookie periodically (e.g., weekly) to ensure crawling stability.
Multiple Account Rotation: If you have multiple East Money accounts, you can rotate Cookies from different accounts to further reduce the risk of being rate-limited.
9. Install Automated Trading (Optional)
1. Install Trading Software
1.1 For clients using the universal TongHuaShun client
Universal TongHuaShun client:
https://activity.ths123.com/acmake/cache/1361.html
1.2 For clients using the specialized TongHuaShun client for specific brokers
Visit the broker's official website to find the specialized TongHuaShun version.
Example: GF Securities download the Hexin Standalone Order Terminal (TongHuaShun Version):
http://www.gf.com.cn/softdownload/index?tab=1
2. Install Tesseract (Automatic CAPTCHA Recognition)
Method 1: Download Pre-compiled Version
From the link below, select the appropriate version based on your operating system:
https://digi.bib.uni-mannheim.de/tesseract/
Method 2: Compile from Source
Download source code: https://github.com/tesseract-ocr/tesseract
Note:
After installation, set the installation path to the PATH environment variable.
The following DOS command can be used (run cmd as administrator):
setx /m PATH "%PATH%;C:\Program Files\Tesseract-OCR"
3. Configure Trading Settings
3.1 Modify trade_client.json
"user": "888888888888", # Trading account
"password": "888888", # Trading password
"exe_path": "C:/gfzqrzrq/xiadan.exe" # Path to trading software
3.2 Modify trade_service.py
broker = 'gf_client' # This is for GF Securities
For details, refer to usage.md to configure for your specific broker.
10. Running Instructions
10.1. Execute Data Fetching, Processing, Analysis, Recognition
Supports batch jobs. Please refer to the comments in run_job.bat for details.
It is recommended to add this to a Task Scheduler, executing daily at 17:00 on working days.
Principles for Data Fetching and Processing: 1). Available at market open and without historical data: Comprehensive stock selection, daily stock data, stock capital flow, stock dividends and distributions, Dragon & Tiger List, daily ETF data. 2). Available at market close and with historical data: Stock indicator data, stock K-line patterns, stock strategy data. 3). Available 1-2 hours after market close and with historical data: Block trades.
Running run_job.bat will fetch data for each module based on the above principles for the current or previous trading day.
Run run_job.bat
To view current real-time data after market open, you can run the following, which is very fast (about 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 Virtual Machine Installation Ubuntu (https://www.ljjyy.com/archives/2019/10/100590.html), which also covers the installation of common software like Python and Docker. To install Docker on Windows, please search online.
1. Configure Proxy
If not using a proxy, skip this step.
After system installation, you can configure the proxy by editing the proxy file on the host machine.
Specific settings are as follows:
Edit the host’s proxy file, adding 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 proxies.
After editing the proxy file, if the system is already running, it needs to be restarted for the changes to take effect.
Example to create proxy:
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: The above are all invalid proxies.
2. Configure East Money Cookie
If not using a Cookie, skip this step.
After system installation, you can configure the Cookie by editing the cookie file on the host machine. For details, please refer to: Regular Installation Method, Setting East Money Cookie.
sudo sh -c 'echo "Your Cookie Value" > /data/eastmoneycookie.txt'
# Create cookie file, will automatically replace the original cookie file
3. Install Database Image
If you already have a MySQL or MariaDB database, skip this step.
Run the following command:
Special Reminder: The user executing the commands must have root privileges. The same applies to other commands. For example, in Ubuntu, add sudo before commands , e.g., 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 described in [3. Install Database Image], 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 description:
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 the parameters according to your actual database settings.
5. System Operation
After starting the container, it will run automatically. It will first 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
To fetch, process, analyze, recognize, and backtest historical data, run the following commands:
docker exec -it InStock bash
cat InStock/instock/bin/run_job.sh
# View run_job.sh comments and choose jobs as needed
------Overall Job, Supports Batch Jobs------
Current Date Job: python execute_daily_job.py
Single Date Job: python execute_daily_job.py 2022-03-01
Enumerated Dates Job: python execute_daily_job.py 2022-01-01,2021-02-08,2022-03-12
Date Range Job: python execute_daily_job.py 2022-01-01 2022-03-01
------Single Function Jobs, Supports Batch Jobs, Backtest Data Automatically Fills to Current Date
Comprehensive Stock Selection Job: python selection_data_daily_job.py
Real-time Basic Data Job: python basic_data_daily_job.py
Basic Data Job 2 Hours After Close: python backtest_data_daily_job.py
Non-real-time Basic Data 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 Job: python backtest_data_daily_job.py
Method 1:
python execute_daily_job.py 2023-03-01,2023-03-02
Method 2:
Modify run_job.sh, then run: bash InStock/instock/bin/run_job.sh
7. View Logs
Run the following commands:
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
# Prune 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 supports Windows. Refer to the Regular Installation Method; only Python and dependencies need to be installed. MySQL, Talib, etc., do NOT need to be installed.
Special Disclaimer
The stock market involves risks, and investments should be made with caution. This system is for learning and stock analysis purposes only. The developers assume no responsibility for any gains or losses incurred from investment.
The tables used in this system are third-party commercial controls, and only the evaluation version is used for learning and testing.
Nika (@eastweb3eth): One-Screen Global Financial News
I’ve been searching for a repository that can display global financial information on a single screen, and I finally found it this time. Setting aside the features, a significant use of this repository is to [show off]. After all, when my wife sees the
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.
@eastweb3eth: Github US Stock Quant Compilation - A Must-Use Tool for Smart People. Since Github came along, ordinary people can also do quant. But don't start by grinding away writing your own backtesting engine; really, most people's code is less robust than a three-year-old repo on Github. There are many repos, but I've already filtered them for you: these 4…
Recommends 4 open-source quantitative trading tools/frameworks (VeighNa, AI-Trader, StockSharp, QuantDinger), emphasizing that they are suitable for ordinary users to conduct US stock quantitative trading, helping to free your hands and let the model handle trading.
@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…
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.
@SusChan444: Guys, no more backend needed for stock data! chengzuopeng/stock-sdk — pure JS/TS stock market SDK, zero Python, zero backend, get real-time data directly from browser/Node.js! Highlights: · Supports A-shares, Hong Kong stocks, US stocks, mutual funds, real-time quotes…
Stock-SDK is a pure JavaScript/TypeScript stock market data SDK that supports browser and Node.js to get real-time data for A-shares/H-shares/US stocks/mutual funds, provides CLI and MCP to connect AI tools, designed for frontend and quantitative development.
@BTCqzy1: Found an A-share open-source investment research tool — TradingAgents-Astock, deeply customized for A-shares, completely free data sources, direct connections to mootdx + East Money + Sina + Tencent Finance + Tonghuashun, no API Key required, with detailed data on dragon and tiger lists, lock-up expirations, and capital flows. ...
TradingAgents-Astock is an A-share specialized open-source investment research tool based on TradingAgents, built-in 7 Agent analysts, supporting free data sources and multiple large language models, with Web UI and CLI.