Mboum does not have a sector index or a sector filter. The stock screener and the API cannot list "all energy stocks", and no endpoint returns sector performance. What every equity does have is a sector label, an industry label and an exchange, plus live performance fields on its quote. That is enough to build your own comparison for any list of tickers. This tutorial does it in Python: tag each ticker, pull all the quotes in one call, group by sector and industry, and rank the groups.
Prerequisites
- Python 3.8 or later and the
requestspackage. - A Mboum API key from mboum.com/pages/api.
Step 1: tag each ticker with its sector and industry
GET https://api.mboum.com/v1/markets/search has weight 1 and takes one parameter, search. It returns about seven rows for a symbol, including ETFs and other matches, so pick the row whose symbol equals your ticker. Equity rows carry sectorDisp, industryDisp and exchDisp. ETF, option and futures rows have no sector keys. The v2 search endpoint does not return these fields. A trimmed AAPL row:
{
"shortname": "Apple Inc.",
"symbol": "AAPL",
"typeDisp": "Equity",
"exchDisp": "NASDAQ",
"sectorDisp": "Technology",
"industryDisp": "Consumer Electronics"
}
exchDisp is how we keep only Nasdaq and NYSE listings.
Step 2: get performance in one call
GET https://api.mboum.com/v1/markets/stock/quotes has weight 2 and accepts comma-separated tickers, up to 200. Two fields do the work. regularMarketChangePercent is today's move. fiftyTwoWeekChangePercent is the change over 52 weeks. Both are already percentages, so -0.79 means -0.79%. Be careful with the neighbouring fields such as fiftyTwoWeekHighChangePercent, which are fractions.
{
"symbol": "AAPL",
"regularMarketChangePercent": -0.79378456,
"fiftyTwoWeekChangePercent": 23.69405
}
Step 3: group and rank
The script below tags the tickers and saves the labels in sectors.json, so later runs skip the searches. It then averages the two fields for each sector and each industry and sorts by the 52-week figure. Save it as sector_compare.py:
import json
import os
import statistics
from collections import defaultdict
import requests
API_KEY = "YOUR_MBOUM_API_KEY"
BASE = "https://api.mboum.com"
HEADERS = {"Authorization": f"Bearer {API_KEY}", "Accept": "application/json"}
CACHE = "sectors.json"
EXCHANGES = {"NASDAQ", "NYSE"}
SYMBOLS = [
"AAPL", "MSFT", "NVDA", "AVGO", "JPM", "BAC", "GS", "V",
"XOM", "CVX", "COP", "PFE", "LLY", "JNJ", "UNH", "AMZN",
"TSLA", "HD", "WMT", "COST", "PG", "KO", "CAT", "BA",
"GE", "NEE", "DUK", "LIN", "AMT", "NFLX", "DIS",
]
def get(path, **params):
r = requests.get(BASE + path, headers=HEADERS, params=params, timeout=30)
r.raise_for_status()
data = r.json()
if data.get("success") is False: # HTTP 200 can still be a failure
raise RuntimeError(data.get("message", "request failed"))
return data
def classify(symbol):
for row in get("/v1/markets/search", search=symbol)["body"]:
if row.get("symbol") == symbol and row.get("sectorDisp"):
return {
"sector": row["sectorDisp"],
"industry": row["industryDisp"],
"exchange": row["exchDisp"],
}
return None
def load_tags():
tags = json.load(open(CACHE)) if os.path.exists(CACHE) else {}
for symbol in SYMBOLS:
if symbol not in tags:
tags[symbol] = classify(symbol)
json.dump(tags, open(CACHE, "w"), indent=2)
return tags
def load_quotes():
body = get("/v1/markets/stock/quotes", ticker=",".join(SYMBOLS))["body"]
return {q["symbol"]: q for q in body}
def rank(tags, quotes, level):
groups = defaultdict(list)
for symbol, tag in tags.items():
quote = quotes.get(symbol)
if tag and quote and tag["exchange"] in EXCHANGES:
groups[tag[level]].append(quote)
rows = []
for name, items in groups.items():
day = statistics.mean(q["regularMarketChangePercent"] for q in items)
year = statistics.mean(q["fiftyTwoWeekChangePercent"] for q in items)
rows.append((name, len(items), day, year))
return sorted(rows, key=lambda r: r[3], reverse=True)
if __name__ == "__main__":
tags, quotes = load_tags(), load_quotes()
for level in ("sector", "industry"):
print(f"\n{level.upper():<34}{'N':>3}{'1D %':>8}{'52W %':>9}")
for name, n, day, year in rank(tags, quotes, level):
print(f"{name:<34}{n:>3}{day:>8.2f}{year:>9.2f}")
What the output looks like
We ran it on December 1, 2026 with 31 large Nasdaq and NYSE stocks. The sector table:
SECTOR N 1D % 52W %
Energy 3 0.75 45.38
Basic Materials 1 -1.24 29.73
Healthcare 4 -1.39 22.07
Consumer Defensive 4 -1.09 21.78
Financial Services 4 0.51 7.02
Real Estate 1 -1.30 4.98
Utilities 2 0.26 4.92
Consumer Cyclical 3 1.35 2.37
Industrials 3 2.06 -1.28
Technology 4 1.23 -1.95
Communication Services 2 0.47 -10.51
Technology averaged +1.23% on the day and -1.95% over 52 weeks. The industry table shows why. Semiconductors (NVDA and AVGO) averaged -15.47% over 52 weeks, while Consumer Electronics (AAPL) was at +23.69%. One sector label hid two opposite stories. These groups hold one to four stocks each, so treat the numbers as a read on your list, not as a sector index.
The first run costs 33 weighted requests: 31 searches at weight 1 and one quotes call at weight 2. Later runs cost 2, because the labels come from the cache file.
Best practices
- Cache the labels. A company's sector rarely changes. Delete an entry from
sectors.jsonto refresh it. - Use one source for labels. Search returns names such as "Banks—Diversified" with an em dash. The profile module in the stock modules endpoint writes "Banks - Diversified" with a hyphen. Do not mix them in one table.
- Show the group size. An average of one or two stocks is a single stock's move. Keep the
Ncolumn, and try the median if your groups are small. - Check the body, not just the status. A failed lookup can return HTTP 200 with
"success": false, which the script raises as an error. SendAccept: application/jsonso a bad parameter answers with a JSON error and not an HTML page.
Next steps
Replace SYMBOLS with the symbols from a screener run, a watchlist or your portfolio, and the same script ranks the sectors you actually hold. The stock screener at mboum.com/stocks/screener is a good source for a ticker list. The endpoints are described in the search and quotes docs. You can get a free key at mboum.com/pages/api, and every endpoint is described in the API documentation.
The data is for information only. It is not investment advice.