How Do Programmers Choose Stocks? Investment Practice Using Code to Analyze Relative Strength Indicators

Stock InvestmentTechnical AnalysisProgrammer FinanceFlaskData AnalysisRelative Strength Indicator
LaFu Code
LaFu Code
-- views

Recently, I read a stock trading book called "How to Make Money in Stocks" which explains how to identify market transitions from bull to bear and bear to bull, using 30-week Exponential Moving Average (EMA) and Relative Strength (RS) indicators for stock selection.

The Author's 6 Key Principles:

  1. Never buy or sell stocks without looking at the charts.

  2. Never buy stocks when good news is announced, especially when the chart shows the stock price has already risen significantly before the news announcement.

  3. Never buy stocks during a price crash just because they seem cheap. Under continuous selling pressure, you'll find stocks can get even cheaper.

  4. Never buy stocks in a downtrend.

  5. Never hold stocks that are in a downtrend, regardless of how low their P/E ratio is.

  6. Always maintain consistency. If you sometimes buy and sometimes sell under identical circumstances, your trading discipline has serious problems.

My Trading Experience

The book describes in detail the four typical stages of stocks, recommending buying stocks in stages 1 and 2, and absolutely avoiding purchases in stages 3 and 4.

https://lafucode.com

Reading this was an eye-opener for me. Looking back at my past performance, I mostly sold too early in stage 2 and stubbornly held on during stage 4, eventually cutting losses.

To turn things around, I read many books, studied sectors, understood company fundamentals, and of course learned technical indicators. But I could never achieve enlightenment. Instead, it felt like pursuing a PhD in the stock market: studying new battery technologies, pig slaughter rates, rare earth compositions, etc...

Some people say: "Be greedy when others are fearful, and fearful when others are greedy."

Others say: "Stocks will eventually rise back up. We're here to make money, not to cut losses."

Still others say: "Buy when no one knows, sell when everyone's talking."

It seems every stock trader is studying human psychology. After all, only a few people make money in this market, while most are just retail investors getting harvested.

Relative Strength Indicator

As a classic financial book, I verified some of the theories mentioned in trading software, but I couldn't find the relative strength technical indicator (perhaps it requires purchasing premium trading software).

So I decided to write a program based on the relative strength formula given in the book to analyze stock relative strength.

Here's the final result: https://lafucode.com https://lafucode.com https://lafucode.com

The entire project was built using Flask, retrieving individual stock data with akshare, and the basic code was written with Claude 4's assistance. https://lafucode.com

Since having AI editors, efficiency has improved significantly, but AI-written code still has issues.

Taking this project as an example, the AI sometimes called Tencent's API to get daily K-line data, and other times used akshare to get weekly K-line data. So it still requires time to communicate with the AI.

Since it's web-based, convenience is limited. I might consider developing an app version later.

As programmers, we have skills that others don't possess. Why not do something meaningful? If we can't benefit society, at least we can benefit ourselves.

So don't let work constrain you - you are your own potential customer.

I hope this little tool helps with my stock trading enlightenment!

Remember: investing involves risks, enter the market with caution.

Follow WeChat Official Account

WeChat Official Account QR Code

Scan to get:

  • • Latest tech articles
  • • Exclusive dev insights
  • • Useful tools & resources

💬 评论讨论

欢迎对《How Do Programmers Choose Stocks? Investment Practice Using Code to Analyze Relative Strength Indicators》发表评论,分享你的想法和经验