The Business & Technology Network
Helping Business Interpret and Use Technology
«  
  »
S M T W T F S
1
 
2
 
3
 
4
 
5
 
6
 
7
 
8
 
9
 
 
 
 
 
 
 
 
 
 
19
 
20
 
21
 
22
 
23
 
24
 
25
 
26
 
27
 
28
 
29
 
30
 
31
 
 
 
 
 

7 Best Generative AI Development Companies in 2026

DATE POSTED:March 17, 2026
How I built a professional stock screening system that analyzes 500 S&P 500 stocks using OpenClaw, Python, and free public APIs — all controllable from Telegram.

TL;DR: I built a stock screening system that scans all 500 S&P 500 stocks for technical oversold signals, then runs Warren Buffett’s 10 quality formulas using official SEC data. The entire system runs from Telegram commands, uses 100% free public APIs, and returns results in 15 seconds to 3 minutes depending on the analysis depth.

The Problem: Wall Street Tools Are Expensive

As someone interested in quantitative investing, I faced a familiar dilemma: professional-grade stock screening tools are prohibitively expensive.

  • Bloomberg Terminal: $24,000/year
  • FactSet: $12,000/year
  • Morningstar Premium: $249/year (limited functionality)
  • Trade Ideas: $118/month (basic scanning only)

What I wanted was simple:

  1. Scan all S&P 500 stocks for technical oversold signals (Williams %R < -80)
  2. Filter by fundamental quality using Warren Buffett’s investment criteria
  3. Get results fast, preferably on my phone
  4. Use official, reliable data sources

The solution? Build it myself using AI agents, free public APIs, and open-source tools.

The Architecture: AI-Powered Automation

The system is built on OpenClaw, an AI agent framework that orchestrates complex workflows through natural language. Think of it as having a senior developer who can write code, manage databases, and deploy services — all from chat commands.

Core Components

1. OpenClaw Agent (Orchestration Layer)

The brains of the operation. Claude Opus 4.5 interprets Telegram commands and executes Python scripts with full context awareness.

2. Python Scripts (Processing Layer)

  • technical_only.py — Fast oversold screening (15-30 seconds)
  • screening.py — Combined technical + fundamental analysis (1-3 minutes)
  • analyze.py — Deep dive on individual stocks (2-3 seconds)

3. SQLite Databases (Caching Layer)

  • price_cache.db — Daily OHLCV data for 500 stocks (1-day TTL)
  • askten.db — SEC financial statements (7-day TTL)

4. Telegram Bot (Interface Layer)

Simple commands like oversold, screen, or analyze AAPL trigger full market scans.

500

S&P 500 Stocks Scanned

15s

Technical Scan Time

10

Buffett Formulas

$0

API Costs

Data Sources: Free, Public, and Authoritative

One of the key constraints was using 100% free data sources. Here’s what I chose and why:

1. Yahoo Finance (Price Data)

Via the yfinance Python library, I get:

  • Daily OHLCV (Open, High, Low, Close, Volume) for all S&P 500 stocks
  • Real-time updates during market hours
  • Historical data going back years
  • Same data source used by TradingView, Robinhood, and many professional platforms
import yfinance as yf# Fetch 90 days of price data
stock = yf.Ticker("AAPL")
df = stock.history(period="90d")# Calculate Williams %R (21-day period)
high = df['High'].rolling(21).max()
low = df['Low'].rolling(21).min()
williams_r = ((high - df['Close']) / (high - low)) * -100

Reliability: 99.4% success rate (500/503 S&P 500 stocks)

Cost: Free, no API key required

2. SEC EDGAR (Fundamental Data)

The U.S. Securities and Exchange Commission provides a free API for company financial statements. This is the official source — the same data Warren Buffett reads in 10-K filings.

import requests# Fetch Apple's company facts (balance sheet, income statement, cash flow)
cik = "0000320193" # Apple's CIK number
url = f"https://data.sec.gov/api/xbrl/companyfacts/CIK{cik}.json"response = requests.get(url, headers={'User-Agent': 'YourApp/1.0'})
data = response.json()# Extract assets, liabilities, equity, revenue, etc.
facts = data['facts']['us-gaap']

Authority: 100% official government data, legally required filings

Cost: Free, rate limit of 10 requests/second

3. GitHub (S&P 500 List)

A community-maintained CSV file with all current S&P 500 constituents:

import pandas as pdurl = "https://raw.githubusercontent.com/datasets/s-and-p-500-companies/main/data/constituents.csv"
df = pd.read_csv(url)
tickers = df['Symbol'].tolist() # 503 tickersFeature #1: The “oversold” Command

This is the speed demon. In 15–30 seconds, it scans all 500 S&P 500 stocks and identifies which ones are technically oversold.

What It Does
  1. Fetches the S&P 500 ticker list (503 stocks)
  2. Retrieves 90 days of price data for each stock (parallel fetching, 10 workers)
  3. Calculates Williams %R (21-day momentum oscillator)
  4. Calculates EMA(13) of Williams %R for trend confirmation
  5. Filters stocks where Williams %R < -80 (oversold threshold)
  6. Ranks by intensity (Extreme, Very Strong, Strong, Moderate)
Technical Indicator: Williams %R

Williams %R measures where the current price sits within the recent 21-day high-low range:

Williams %R = ((Highest High - Close) / (Highest High - Lowest Low)) × -100

Interpretation:

  • -100 to -80: Oversold (potential buy)
  • -80 to -20: Neutral
  • -20 to 0: Overbought (potential sell)

When a stock hits -99.3 (like Visa did in my scan), it means the price is only 0.7% above the 21-day low — extreme panic selling territory.

Real Results (Jan 31, 2026):