A daily market recap takes about 30 minutes to write by hand: copy the biggest gainers, check tomorrow's earnings, look for splits, paste it all into an email. It is also the same 30 minutes every day, which makes it a job for a script.
This guide builds a Python script that pulls four blocks of data from SteadyAPI, turns them into an HTML issue, and is ready to run from cron after the close. The four blocks are top gainers, top losers, tomorrow's earnings, and stock splits.
Prerequisites
- A SteadyAPI API key from steadyapi.com. The Free plan covers it. See the cost section.
- Python 3.8+ with
requests. - A scheduler, such as cron.
The four data blocks
Gainers and losers: GET https://api.steadyapi.com/v1/markets/screener (weight 2). Set list to day_gainers or day_losers. Each row is a full quote, with symbol, shortName, regularMarketPrice and regularMarketChangePercent. The response is already sorted, so the top five are the first five. meta.total shows how many stocks are on the list.
Earnings: GET https://api.steadyapi.com/v1/markets/calendar/earnings (weight 2). Pass date as YYYY-MM-DD. It returns every company reporting that day, which can be hundreds. Each row has symbol, name, time, marketCap, epsForecast and noOfEsts.
Splits: GET https://api.steadyapi.com/v1/markets/calendar/stock-splits (weight 1). It returns splits from the previous trading day up to an end date. Each row has ticker, companyshortname, old_share_worth and share_worth.
The date: GET https://api.steadyapi.com/v2/markets/market-info (weight 1). It gives isBusinessDay and nextTradeDate. We use them to skip holidays and to ask for the right earnings date. The market holidays guide has more on those fields.
Four things in the data you need to handle
- Money comes as strings. Market caps look like
"$386,964,914,000". EPS estimates look like"$1.15", and a negative estimate is"($0.61)", in brackets. Some are empty. The script has onemoney()helper for all of it. - The earnings list is long and unordered. Sort by market cap and keep the top few. Companies with no market cap are dropped.
- The
timefield has three values.time-pre-market,time-after-hoursandtime-not-supplied. The script turns them into plain words. - Splits include foreign listings. Tickers such as
288980.KSand7523.Tare exchange-suffixed. The script keeps US tickers by dropping any ticker that contains a dot.
A quiet day can also return HTTP 200 with "success": false and a message such as No data returned. get() raises on it, and safe() turns it into an empty section.
The script
from datetime import datetime
from html import escape
import requests
API_KEY = "YOUR_STEADYAPI_KEY"
BASE = "https://api.steadyapi.com"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}
WHEN = {"time-pre-market": "before open", "time-after-hours": "after close"}
def get(path, **params):
r = requests.get(f"{BASE}{path}", headers=HEADERS, params=params, timeout=30)
r.raise_for_status()
data = r.json()
if data.get("success") is False:
raise RuntimeError(data.get("message", "Request failed"))
return data
def money(v):
"""'$386,964,914,000' -> 386964914000.0, '($0.61)' -> -0.61, '' -> None."""
s = str(v).strip()
try:
n = float(s.strip("()").replace("$", "").replace(",", ""))
except ValueError:
return None
return -n if s.startswith("(") else n
def safe(path, **params):
try:
return get(path, **params)["body"]
except RuntimeError: # "No data returned" on a quiet day
return []
info = get("/v2/markets/market-info")["body"]
if not info["isBusinessDay"]:
raise SystemExit("Market closed today. No issue.")
next_day = datetime.strptime(info["nextTradeDate"], "%b %d, %Y").strftime("%Y-%m-%d")
def movers(name):
return safe("/v1/markets/screener", list=name, offset=0)[:5]
earnings = [r for r in safe("/v1/markets/calendar/earnings", date=next_day) if money(r["marketCap"])]
earnings = sorted(earnings, key=lambda r: money(r["marketCap"]), reverse=True)[:8]
splits = [s for s in safe("/v1/markets/calendar/stock-splits") if "." not in s["ticker"]]
def mover_li(q):
pct = q["regularMarketChangePercent"]
color = "#0a8f3c" if pct >= 0 else "#c62828"
return (f'<li><b>{escape(q["symbol"])}</b> {escape(q.get("shortName") or "")} '
f'{q["regularMarketPrice"]:.2f} <span style="color:{color}">{pct:+.1f}%</span></li>')
def section(title, items):
body = "".join(items) or "<li>Nothing to report.</li>"
return f"<h2>{title}</h2><ul>{body}</ul>"
page = f"<h1>Market recap, {datetime.now():%A %B %d}</h1>" + "".join([
section("Top gainers", [mover_li(q) for q in movers("day_gainers")]),
section("Top losers", [mover_li(q) for q in movers("day_losers")]),
section(f"Earnings on {next_day}", [
f'<li><b>{escape(r["symbol"])}</b> {escape(r["name"])}, {WHEN.get(r["time"], "time not set")}, '
f'EPS estimate {escape(r["epsForecast"] or "n/a")}</li>' for r in earnings]),
section("Stock splits", [
f'<li><b>{escape(s["ticker"])}</b> {escape(s["companyshortname"])}: '
f'{"forward" if s["share_worth"] > s["old_share_worth"] else "reverse"} split, '
f'{s["old_share_worth"]} old to {s["share_worth"]} new</li>' for s in splits]),
])
open("newsletter.html", "w", encoding="utf-8").write(f"<html><body>{page}</body></html>")
print(f"Wrote newsletter.html with {len(earnings)} earnings and {len(splits)} splits.")
What it writes
An issue from one run, as plain text:
Market recap, Wednesday November 11
Top gainers
CRWV CoreWeave, Inc. 60.77 +24.7%
AZTA Azenta, Inc. 48.90 +20.8%
AXTI AXT Inc 46.97 +19.5%
Top losers
BGSI Boyd Group Services Inc. 77.18 -12.8%
RGTI Rigetti Computing, Inc. 11.11 -8.6%
Earnings on 2026-11-12
CSCO Cisco Systems, Inc., after close, EPS estimate $1.15
AMAT Applied Materials, Inc., after close, EPS estimate $4.06
BN Brookfield Corporation, before open, EPS estimate $0.72
Stock splits
JOB GEE Group Inc: reverse split, 30 old to 1 new
The real file is HTML, with bold symbols and green and red percentages. The text above is a shortened view of the same data.
Schedule it
Run the script after the close, when the day's changes are final. For 4:35 PM New York time, on weekdays:
35 16 * * 1-5 cd /path/to/newsletter && STEADYAPI_KEY=... python3 newsletter.py
Make sure the server's time zone is New York, or use CRON_TZ=America/New_York where your cron supports it. On a market holiday, the script reads isBusinessDay and exits without writing an issue.
Send it
To email the file to yourself or a small list, the standard library is enough. Add this to the end of the script:
import smtplib
from email.message import EmailMessage
msg = EmailMessage()
msg["Subject"] = "Market recap"
msg["From"] = "[email protected]"
msg["To"] = "[email protected]"
msg.set_content("Open this email in a client that shows HTML.")
msg.add_alternative(open("newsletter.html", encoding="utf-8").read(), subtype="html")
with smtplib.SMTP_SSL("smtp.example.com", 465) as server:
server.login("[email protected]", "YOUR_SMTP_PASSWORD")
server.send_message(msg)
For a real subscriber list, use an email service instead. It handles unsubscribe links, bounces and sending limits, which you do not want to build.
Count your requests
One issue costs 8 requests: 1 for market info, 2 each for gainers, losers and earnings, and 1 for splits. With about 21 trading days a month, that is roughly 170 requests, well inside the Free plan's 500 requests a month.
Before you publish
- Add a line saying this is data, not advice. Put it in the footer.
- Check the plan for commercial use. If the newsletter is paid or part of a business, use a paid plan. Commercial use is allowed on paid tiers.
- Read the output once a week. A recap with an empty section is usually a quiet day. A recap with the wrong date is a bug.
- Add headlines.
GET /v1/markets/newsreturns up to 20 general headlines for 1 request. It is a good fifth block.
Conclusion
Four API calls, one helper for money strings, and a cron line replace the daily copy-and-paste. The script skips holidays and shows an empty section on a quiet day instead of failing.
Create a free account at steadyapi.com (no card required), run the script once, and read the API documentation for every parameter and ready-made examples in cURL, JavaScript, PHP, and Python.