A Powerful Tool for Finding Potential Stocks: Building a Multi-Dimensional Financial Screener with Luckdata Yahu Financials API
In the vast ocean of the stock market, identifying high-potential stocks among thousands of tickers is a challenging task. A financial screener is an essential tool that helps investors quickly filter stocks based on multiple financial indicators like PE ratio, PB ratio, revenue growth, and ROE. It turns stock picking from "needle in a haystack" into "targeted selection."
This article will walk you through building a flexible, multi-dimensional financial screener using the Luckdata Yahu Financials API, particularly focusing on the screeners module. We will also show how to present the filtered results through a simple interactive web interface built with Flask and Bootstrap.
Why Use an API for Financial Screening
Structured and Real-Time Data
Unlike many broker websites that offer limited filtering options and outdated data, using an API provides real-time, structured JSON data directly from the source.Highly Customizable Filtering
You can define flexible screening criteria like "PE < 20", "ROE > 15%", and "revenue growth > 10%" to target very specific stock characteristics.Automation-Ready
Screening logic can be embedded into automated trading systems or scheduled jobs, enabling a complete end-to-end investment pipeline.
Luckdata’s screeners module is designed for this exact use case, offering several key endpoints:
/screeners/get-filters
: Retrieve all available screening fields and categories;/screeners/get-symbols-by-predefined
: Get a list of stocks based on predefined screening IDs;/screeners/list-by-ticker
: Query detailed screening data for an individual stock.
Overview of Screener Filters and Fields
To build a customizable screener, we first need to know what fields we can screen on. The following API call returns all available filters by region and category:
GET https://luckdata.io/api/yahu-financials/vclchw21z2no?region=US&category=keystats,financials,valuation,profitability_ratios_and_dividends&eType=equity
Sample response (partial):
{"filters": [
{
"id": "trailingPE",
"name": "PE Ratio (TTM)",
"type": "number"
},
{
"id": "priceToBook",
"name": "Price to Book",
"type": "number"
},
{
"id": "revenueQuarterlyGrowth",
"name": "Quarterly Revenue Growth (%)",
"type": "number"
},
{
"id": "returnOnEquity",
"name": "Return on Equity (ROE, %)",
"type": "number"
}
// … More fields …
]
}
These fields can be used to dynamically build user-selectable filters in your frontend.
Practical Example: Filter Stocks by PE, ROE, and Revenue Growth
Currently, Luckdata does not support direct POST requests with multiple custom filters. However, we can combine the /screeners/get-symbols-by-predefined
endpoint to fetch a base list, and then apply our logic by calling /screeners/list-by-ticker
for each stock.
Step 1: Fetch Most Active Tickers
import requestsAPI_KEY = 'your-luckdata-key'
url = 'https://luckdata.io/api/yahu-financials/ke6gzl1mrinc'
params = {
'count': 100,
'start': 0,
'scrIds': 'MOST_ACTIVES'
}
headers = {'X-Luckdata-Api-Key': API_KEY}
response = requests.get(url, headers=headers, params=params)
tickers = [item['symbol'] for item in response.json().get('finance', {}).get('result', [])[0].get('quotes', [])]
Step 2: Check Each Ticker's Financial Data
qualified = []for ticker in tickers:
detail_url = 'https://luckdata.io/api/yahu-financials/5xbac871zs11'
params = {'ticker': ticker}
resp = requests.get(detail_url, headers=headers, params=params)
data = resp.json()
try:
pe = data['trailingPE']
roe = data['returnOnEquity']
rev_growth = data['revenueQuarterlyGrowth']
if pe < 20 and roe > 15 and rev_growth > 10:
qualified.append({
'symbol': ticker,
'PE': pe,
'ROE': roe,
'RevenueGrowth': rev_growth
})
except KeyError:
continue
for stock in qualified:
print(f"{stock['symbol']}: PE={stock['PE']}, ROE={stock['ROE']}%, Revenue Growth={stock['RevenueGrowth']}%")
Build a Simple Frontend with Flask + Bootstrap
To make it interactive, we’ll use Flask to create a form where users can input custom filters.
Flask Backend Code:
from flask import Flask, render_template, requestimport requests
app = Flask(__name__)
API_KEY = 'your-luckdata-key'
@app.route('/', methods=['GET', 'POST'])
def index():
results = []
if request.method == 'POST':
pe = float(request.form.get('pe'))
roe = float(request.form.get('roe'))
rev = float(request.form.get('rev'))
ticker_resp = requests.get(
'https://luckdata.io/api/yahu-financials/ke6gzl1mrinc',
headers={'X-Luckdata-Api-Key': API_KEY},
params={'scrIds': 'MOST_ACTIVES', 'count': 100, 'start': 0}
)
tickers = [i['symbol'] for i in ticker_resp.json()['finance']['result'][0]['quotes']]
for ticker in tickers:
detail = requests.get(
'https://luckdata.io/api/yahu-financials/5xbac871zs11',
headers={'X-Luckdata-Api-Key': API_KEY},
params={'ticker': ticker}
).json()
try:
if detail['trailingPE'] < pe and detail['returnOnEquity'] > roe and detail['revenueQuarterlyGrowth'] > rev:
results.append({
'symbol': ticker,
'PE': detail['trailingPE'],
'ROE': detail['returnOnEquity'],
'RevenueGrowth': detail['revenueQuarterlyGrowth']
})
except:
continue
return render_template('index.html', results=results)
HTML Template templates/index.html
<!doctype html><html>
<head>
<meta charset="utf-8">
<title>Financial Screener Example</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-4">
<h1 class="mb-4">Multi-Dimensional Financial Screener</h1>
<form method="post" class="row g-3 mb-4">
<div class="col-auto">
<label class="form-label">PE <=</label>
<input name="pe" type="number" step="0.1" value="20" class="form-control">
</div>
<div class="col-auto">
<label class="form-label">ROE >=</label>
<input name="roe" type="number" step="0.1" value="15" class="form-control">
</div>
<div class="col-auto">
<label class="form-label">Revenue Growth >=</label>
<input name="rev" type="number" step="0.1" value="10" class="form-control">
</div>
<div class="col-auto align-self-end">
<button type="submit" class="btn btn-primary">Screen</button>
</div>
</form>
{% if results %}
<table class="table table-striped">
<thead>
<tr>
<th>Symbol</th><th>PE</th><th>ROE (%)</th><th>Revenue Growth (%)</th>
</tr>
</thead>
<tbody>
{% for s in results %}
<tr>
<td>{{ s.symbol }}</td>
<td>{{ s.PE }}</td>
<td>{{ s.ROE }}</td>
<td>{{ s.RevenueGrowth }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
</body>
</html>
Advanced Tips and Extensions
Dynamic Filter Options
Automatically load available filters from/screeners/get-filters
and create a flexible UI for users to define their own conditions.Chart Visualization
Combine historical data with visualization tools like ECharts or Recharts for trend analysis.Automation and Alerts
Use scheduled jobs to run daily screenings and push alerts via email, Slack, or LINE.Integrate with Backtesting Platforms
Export results to backtesting tools for validation and strategy refinement.
Conclusion
From understanding available filters, fetching a base list, to applying custom screening logic per ticker, this guide shows how to build a flexible multi-dimensional financial screener using Luckdata Yahu Financials API. With high customizability and integration capabilities, this system empowers investors to find high-potential stocks and streamline their decision-making process.