Introduction
A Data‑Driven Look at Gold’s Upward Trend
Recent historical pricing retrieved from XAUFIX= shows a noticeable upward movement in the price of gold over the past year. Rising gold prices often spark renewed interest in gold‑mining companies because higher prices can translate into higher revenues, stronger margins, and improved financial performance for efficient producers.
In this environment, analysts and developers may want to examine:
- Which gold‑mining companies generate the most revenue
- Which miners exhibit strong cost efficiency (via gross profit and gross margin)
- How mining‑company performance relates to gold‑price trends
- How to build a consistent analysis using only commonly available data fields
This article demonstrates how to use LSEG Workspace - Screener application and the Data Library to identify gold‑mining companies and analyze their performance with these data:
- TR.Revenue
- TR.GrossProfit
- Historical XAUFIX= (LBMA Gold Price)
Requirements
To follow along this article, you will need:
- LSEG Workspace running and logged-in on the same machine that uses to run Python script (To connect to the data platform with Desktop session, or a Platform Session license)
- Python 3 environment
- lseg-data Python library installed
- Basic understanding of Python and DataFrame operations
More detail can be found in the Quick Start guide.
Step 1) Finding Gold‑Mining Equities Using Screener
Advanced Search returns instruments (e.g., futures, ETFs), but we want companies, so we are using Screener app here to retrieve gold-mining companies. For how to use the application to generate the Screener syntax can be found at article Find Your Right Companies with SCREENER | Devportal
Recommended Screener Filters
| Category | Filter |
| TRBC Activity Name | Gold Mining |
| GICS Sub-Industry Name | Gold |
Export Screener Code to be used with the Data Library
Then we're going to export the screener syntax as an Workspace Excel formula and convert it into screener syntax for the Data Library to get a list of companies that are likely to be engaged in gold production or mining.
Here's the Screener syntax exported
# screener syntax
=@TR("SCREEN(U(IN(Equity(active,public,primary))/*UNV:Public*/), IN(TR.TRBCActivityCode,""5120106011""), IN(TR.GICSSubIndustryCode,""15104030""), CURN=USD)","TR.CommonName;TR.GICSSubIndustry;TR.TRBCActivity","curn=USD RH=In CH=Fd")
Which is converted into Python code for the Data Library as below.
import lseg.data as ld
from lseg.data.discovery import Screener
from datetime import date, timedelta
import plotly.express as px
ld.open_session()
miner = Screener('U(IN(Equity(active,public,primary))/*UNV:Public*/), IN(TR.TRBCActivityCode,"5120106011"), IN(TR.GICSSubIndustryCode,"15104030"), CURN=USD')
print(list(miner))
Here's the result of the code.
Step 2) Retrieving Revenue & Gross Profit Fundamentals
This retrieves basic financial fundamentals for each mining company:
- TR.Revenue: total company revenue
- TR.GrossProfit: revenue minus direct operating costs
These two metrics are available for nearly all equities, making them good universal indicators.
fundamentals = ld.get_data(
universe = miner,
fields = [
"TR.Revenue",
"TR.GrossProfit"
]
)
fundamentals
Step 3) Cleaning the Dataset
Screener returns: Explorers (zero revenue), Shell companies, Newly listed companies, Companies misclassified as gold miners
These often distort charts.
The cleaning pipeline does the following:
- Removes rows with missing revenue or gross profit
- Drops companies with 0 revenue (explorers)
- Computes gross margin %
- Removes extreme outliers:
- Very large revenue (not real miners)
- Very small revenue (< 1 million USD)
- Margin outside −100% to +100% (data anomalies)
After cleaning, only real producing miners remain.
df = fundamentals.dropna(subset=["Revenue", "Gross Profit"]).copy()
# Remove zero revenues (explorers)
df = df[df["Revenue"] > 0]
# Compute margin
df["GrossMarginPct"] = df["Gross Profit"] / df["Revenue"] * 100
# ---- REMOVE OUTLIERS ----
# 1. Revenue too large (likely not miners)
df = df[df["Revenue"] < 2e11] # < 200 billion USD
# 2. Remove microscopic companies (not producers)
df = df[df["Revenue"] > 1e6] # > 1 million USD revenue
# 3. Remove insane gross margin outliers
df = df[(df["GrossMarginPct"] > -100) & (df["GrossMarginPct"] < 100)]
# Optional: Remove negative margins if you want to focus on producers
# df = df[df["GrossMarginPct"] > 0]
df
Step 4) Retrieving Historical Gold Price (XAUFIX=)
This pulls 1 year of daily gold‑fixing prices from XAUFIX=, which is an official benchmark price.
We use this price trend to understand the context in which gold miners operate.
XAUFIX= is a reliable time series and does not require any market facts - the chart speaks for itself.
end = date.today().strftime("%Y-%m-%d")
start = (date.today() - timedelta(days=365)).strftime("%Y-%m-%d")
gold_history = ld.get_history(
universe="XAUFIX=",
fields=["TRDPRC_1"],
interval="1D",
start=start,
end=end
)
gold_history
Then this code shows chart that reflects the internal LSEG gold‑fixing series.
fig = px.line(
gold_history,
x=gold_history.index,
y="TRDPRC_1",
title="Gold Price Trend (XAUFIX=) - Last 12 Months",
labels={"TRDPRC_1": "Gold Price (USD/oz)"}
)
fig.show()
This line chart shows how the gold fixing price (XAUFIX=) has changed over the past 12 months. The data rises and dips over time, forming a generally upward‑moving pattern across the year.
What the chart tells us:
- The gold price starts in a lower range (near the left side of the chart) and gradually moves into a higher range as time progresses.
- There are several short‑term fluctuations along the way, with both local peaks and dips.
- Towards the middle and right part of the chart, gold prices show a noticeable increase before another decline near the end.
- The overall pattern indicates increased volatility and upward momentum within the observed period.
Why this is useful:
You can use this visual trend to understand the pricing backdrop under which gold miners operate. When prices rise, miners often experience improved financial performance, which you can explore in the subsequent charts.
Step 5) Visualizing Gold Miner Fundamentals
5.1) Top 20 Miners by Revenue
This selects the 20 companies with the highest revenue and plots a bar chart.
Revenue approximates:
- Scale of operations
- Company size
- Potential production capacity
df_rev = df.sort_values("Revenue", ascending=False).head(20)
fig = px.bar(
df_rev,
x=df_rev.index,
y="Revenue",
title="Top 20 Gold Miners by Revenue",
labels={"Revenue": "Revenue (USD)"}
)
fig.show()
This bar chart displays the 20 companies with the highest revenue from your cleaned dataset. Each bar corresponds to one company, and the height represents its total reported revenue.
What the chart tells us:
- A few companies have very large revenue values compared to the rest; these stand out clearly in the chart.
- Many miners have moderate‑sized revenue bars clustered near the lower section of the chart.
- The distribution shows that gold‑mining companies vary significantly in size, with a mix of large diversified miners and smaller‑scale producers.
Why this is useful:
Revenue reflects the scale of a mining company’s overall operations. Larger revenue generally indicates broader production or diversified mineral portfolios.
5.2) Top 20 Miners by Gross Profit
This sorts by gross profit, which is Revenue - Direct operating cost
Gross profit is a helpful proxy for: Cost efficiency. Profitability, Operational strength
df_gp = df.sort_values("Gross Profit", ascending=False).head(20)
fig = px.bar(
df_gp,
x=df_gp.index,
y="Gross Profit",
title="Top 20 Gold Miners by Gross Profit",
labels={"Gross Profit": "Gross Profit (USD)"}
)
fig.show()
This chart shows the top 20 companies by gross profit. Gross profit represents revenue minus the direct costs associated with production.
What the chart tells us:
- Just like in the revenue chart, a few companies have extremely high gross profit.
- Many companies show moderate positive gross profit values.
- Companies with very tall bars likely have either large‑scale operations, more efficient cost structures, or both.
Why this is useful:
Gross profit is a direct indicator of how well a miner converts its revenue into profit after absorbing direct extraction and production costs.
5.3) Gross Margin Distribution
This shows the distribution of gross margin percentages across miners.
It helps identify:
- Efficient miners (higher margins)
- Less efficient or loss-making miners
- The overall health of the sector
fig = px.histogram(
df,
x="GrossMarginPct",
nbins=30,
title="Gross Margin Distribution Across Gold Miners",
labels={"GrossMarginPct": "Gross Margin (%)"}
)
fig.show()
This histogram shows how gross margin (%) is distributed across the mining companies.
What the chart tells us:
- Most values fall between roughly 10% and 70%.
- A few companies have margins above 70%, indicating high operating efficiency.
- A small number have negative margins, indicating they generated less gross profit than revenue (i.e., they operated at a loss).
- The shape suggests a wide performance spread across the industry.
Why this is useful:
Gross margin allows you to compare mining cost efficiency at a high level. Miners toward the right side of the histogram tend to generate more profit per revenue dollar.
5.4) Revenue VS Gross Profit (Bubble Chart)
This chart visualizes:
- Horizontal axis: Revenue (size)
- Vertical axis: Gross Profit (profitability)
- Bubble size: Absolute gross margin (efficiency)
This provides a 3‑dimensional view of company performance.
df["BubbleSize"] = df["GrossMarginPct"].abs()
fig = px.scatter(
df,
x="Revenue",
y="Gross Profit",
size="BubbleSize",
hover_name=df.index,
title="Revenue vs Gross Profit (Mining Efficiency Proxy)",
labels={
"Revenue": "Revenue (USD)",
"Gross Profit": "Gross Profit (USD)"
}
)
fig.show()
This scatter plot shows each gold‑mining company positioned in two‑dimensional space:
- Horizontal axis: Revenue
- Vertical axis: Gross Profit
- Bubble size: Absolute gross margin (%)
What the chart tells us:
- Companies with higher revenue and higher gross profit cluster toward the top‑right region.
- Smaller miners stay in the lower‑left area with smaller bubbles.
- The spread shows the diversity of the sector: different companies operate at different scales and efficiencies.
- Larger bubbles usually indicate higher operational efficiency, while smaller bubbles may indicate more limited cost advantage.
Why this is useful:
This visualization brings together scale (revenue), profitability (gross profit), and efficiency (bubble size) into one combined view, making it easy to compare miners.
Step 6) Mining Profit Sensitivity Dashboard
This creates a ranked table sorted by GrossMarginPct, allowing you to quickly see:
- Which miners have the strongest margin profiles
- Which miners are likely operating efficiently
- Which miners may be under cost pressure
Even without mining‑specific fields like AISC or production volume, this still reveals useful insights.
dashboard = df[["Revenue", "Gross Profit", "GrossMarginPct"]]
dashboard.sort_values("GrossMarginPct", ascending=False).head(20)
This table ranks companies by gross margin percentage from highest to lowest.
What the table tells us:
- The companies at the top demonstrate strong cost efficiency, retaining a higher proportion of revenue as profit.
- Companies with higher margins may be better positioned financially.
- The sorted structure highlights which miners show consistent profitability and which operate closer to breakeven.
Why this is useful:
Gross margin is a quick way to gauge each company’s sensitivity to changes in gold price and operating conditions. Higher margins often mean better resilience and upside potential.
Sidebar — How Rising Gold Prices Influence Miners
- Rising gold prices often support miner revenue performance.
- Efficient miners may expand profitability more quickly when prices rise.
- Gross margin (%) provides a useful proxy for comparing operating efficiency.
- Historical XAUFIX= pricing helps contextualize miner performance over time.
- Even without detailed cost or production datasets, fundamentals reveal strong insights.
Conclusion
Using only universally available data—TR.Revenue, TR.GrossProfit, and historical XAUFIX= pricing data—we can build a practical, data‑driven approach to analyzing gold‑mining equities using the Data Library.
This article demonstrated how to:
- Identify gold miners via Screener
- Retrieve key fundamentals
- Clean and prepare the dataset
- Visualize revenue, profitability, and efficiency
- Compare miner performance
- Use historical gold pricing to contextualize results
Even without premium datasets such as AISC or production tonnage, meaningful mining analysis is entirely possible using common fundamentals and pricing data.
This workflow is simple, scalable, and ideal for both market analysts and developers who want to explore the gold‑mining sector using LSEG data.
- Register or Log in to applaud this article
- Let the author know how much this article helped you
Get In Touch
Source Code
Related APIs
Related Articles
Request Free Trial
Call your local sales team
Americas
All countries (toll free): +1 800 427 7570
Brazil: +55 11 47009629
Argentina: +54 11 53546700
Chile: +56 2 24838932
Mexico: +52 55 80005740
Colombia: +57 1 4419404
Europe, Middle East, Africa
Europe: +442045302020
Africa: +27 11 775 3188
Middle East & North Africa: 800035704182
Asia Pacific (Sub-Regional)
Australia & Pacific Islands: +612 8066 2494
China mainland: +86 10 6627 1095
Hong Kong & Macau: +852 3077 5499
India, Bangladesh, Nepal, Maldives & Sri Lanka:
+91 22 6180 7525
Indonesia: +622150960350
Japan: +813 6743 6515
Korea: +822 3478 4303
Malaysia & Brunei: +603 7 724 0502
New Zealand: +64 9913 6203
Philippines: 180 089 094 050 (Globe) or
180 014 410 639 (PLDT)
Singapore and all non-listed ASEAN Countries:
+65 6415 5484
Taiwan: +886 2 7734 4677
Thailand & Laos: +662 844 9576