How Python helps you earn on the stock market without magic or insider tips
Many developers have at least once thought about putting their programming skills to work in algorithmic trading. It seems like all you need is to write a script that buys low and sells high, and life is set. In reality, everything hits a huge barrier to entry: you need to understand finance, be able to work with time series, and know how not to blow your deposit on the very first logic error. The whale-quant project from the Datawhale community is precisely trying to assemble this scattered puzzle into one clear roadmap.
The team managed to create not just a library, but a full-fledged interactive textbook on Quantitative Finance (Quant Finance). The foundation is Jupyter notebooks, where theory sits right alongside Python code.
What's inside this repository
This is an open-source course that takes you by the hand from the basics of investing to building machine learning-based strategies. The authors divided the content into logical blocks that address the main pain points of a beginner in algorithmic trading.
The project is currently in alpha testing, but the foundation is already impressive. The entire journey is broken down into eight chapters. First, they give you the basics of financial markets, then teach you how to pull data (without this, you can't get anywhere in quant work), and then move on to the most interesting part: stock selection strategies and trade entry timing.
How the project benefits a practicing developer
The main value here isn't in the code per se, but in the methodology. Instead of googling "how to download stock quotes," you open chapter three and look at a ready-made pipeline.
Here are a couple of things I liked:
- Stock Selection Strategies. Chapter four covers the algorithms by which a robot decides which specific securities are worth holding in a portfolio.
- Trade Timing. One thing is finding a good company, another is understanding when it's time to buy. Chapter five outlines mathematical approaches to determining entry points.
- Backtesting. This is a critical stage. Chapter seven explains how to test your ideas on historical data before risking real money.
Interestingly, the project uses docsify for documentation generation. This allows you to read the textbook like a regular website, but if you want, you can route everything into a local Jupyter and experiment with parameters directly in the code.
Technical stack and nuances
Under the hood, it's pretty standard for Python Data Science:
- Python 3.9 (the authors emphasize that dependencies may break on other versions, a typical story for scientific software).
- Jupyter Notebook as the main development environment.
- Standard set of libraries for data analysis (Pandas, Numpy, and specific financial packages).
To run the documentation locally, you'll need docsify-cli, but you can simply open the notebook folder in VS Code or PyCharm and start digging into the source code. The entire content writing process in the project is automated: authors write in notebooks, convert them to Markdown, and push to docs. This is a good example of how to keep educational materials up to date.
How this can be applied
Let's say you have a hypothesis that tech company stocks behave in a certain way after AI news releases. With whale-quant, you can:
- Set up data collection from open sources.
- Write company selection logic.
- Run the strategy through a backtest and look at the yield curve.
By the way, chapter eight touches on the topic of machine learning in trading. It covers how to apply ML models for price forecasting, which is currently almost a standard in large hedge funds.
Who should check out the repository
The project is definitely not for those looking for a "big money" button. It's more of an academic, but very practical approach to finance. If you're strong in Python but shaky on terms like "portfolio rebalancing" or "factor models," whale-quant will help close these gaps.
On the other hand, the project is in Chinese (although the code and comments in it are quite readable for a programmer). If you're not scared off by hieroglyphs in the README and know how to use a browser translator, the content inside is more than worthy. For those who want to understand quantitative trading and don't know where to start, this is one of the most structured collections of materials on GitHub.
The only downside is that the project is still in "alpha," so some examples may require some tinkering to fit specific data provider APIs. But for learning, this is more of a plus: you get to make mistakes faster.
Where to start? Clone the repository, install dependencies from requirements.txt, and jump straight into the notebook folder. That's where the essence is.
Related projects