Stock screening V2. Compared with the legacy get_stock_filter, this API covers a wider range of factors (11 categories, 244+ factors), accepts raw values for all numeric inputs (OpenD performs magnification conversion automatically), supports single-field or multi-field sorting, requires explicit declaration of retrieve fields, and returns each result through sval / ival / aval / dval according to its value_type.
Parameters
Parameter
Type
Description
request
StockScreenRequest
Stock screening request object, built via builder methods
StockScreenRequest fields:
Field
Type
Description
page_from
int
Pagination start position
Defaults to 0
page_count
int
Maximum results per page
Defaults to 200
Filter builder methods (each call appends one filter condition; all numeric fields accept raw values, OpenD performs magnification automatically):
Method
Description
add_simple_field(field, values)
Filter by enum field such as market / exchange / index / watchlist
field comes from SimpleField; values is a list of enum values (OR-joined). ScrMarket.MY / JP / SG will be supported later; currently the result is empty
add_plate(plate_ids, parent_plate_id=None)
Plate filter
plate_ids like ["BK1001"]
add_simple_property(name, lower=None, upper=None)
Simple property interval filter
name comes from SimpleProperty (price, market cap, PE, volume ratio, etc.); lower / upper are raw values, e.g. price 10 → 10, market cap ≥ 10B → 10_000_000_000
name comes from CumulativeProperty; days is the cumulative window. Percent-style fields (e.g. PRICE_CHANGE_PCT) take a decimal value (5% as 0.05, NOT 5.0)
name comes from FinancialProperty; term comes from the Term enum (Q1=1, Annual=100, latest single quarter=10, etc.). The Term.SURPRISE_LATEST series (200~204) returns values for both HK and US in practice, but the data is typically identical to ANNUAL — use with caution
HK only. Broker factors 6101 / 6102 / 6105 / 6106 / 6107 use a magnification of 1000 and accept percentage values (e.g. 20% → 20); the days parameter has no effect
direction comes from ScrSortDir: ASC=1, DESC=2, ABS_ASC=3, ABS_DESC=4. property_type is one of 'basic' / 'simple' / 'cumulative' / 'financial' / 'indicator' / 'featured' / 'broker' / 'option' / 'kline_shape'
Corresponding property descriptor (contains name / days / term, etc.)
value_type
int
Value type
1=string(sval), 2=int64(ival), 3=int64 array(aval), 4=double(dval). When OpenD has no data, only value_type is sent (typically 2) and sval/ival/aval/dval are all absent, e.g. HK Q2/Q3/Q4 financial data
sval
str
String value (present when value_type=1)
ival
int
Integer value (present when value_type=2)
aval
list[int]
Integer array value (present when value_type=3)
dval
float
Floating-point value (present when value_type=4)
enum_type_name
str
When ival is an enum code, the corresponding enum type name (e.g. 'KlineShapeType')
enum_name
str
When ival is an enum code, the decoded enum name returned by OpenD/SDK (e.g. 'DOUBLE_BOTTOMS', 'NONE')
end_time
int
Financial report end timestamp
Only for financial type. Current OpenD versions do not populate this field — typically absent from actual results
Example
from futu import OpenQuoteContext, RET_OK, StockScreenRequest
from futu.quote.stock_screen_const import(
ScrMarket, ScrSortDir, SimpleField, SimpleProperty,
CumulativeProperty, FinancialProperty, Term,
Indicator, Period, Position, Pattern,
BasicProperty, KlineShapeProperty, KlineShapeType,)
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)# Example 1: HK large-cap stocks + MACD golden cross
req = StockScreenRequest()
req.add_simple_field(field=SimpleField.MARKET, values=[ScrMarket.HK])
req.add_simple_property(name=SimpleProperty.PRICE, lower=10.0)# Last price >= 10
req.add_simple_property(name=SimpleProperty.MARKET_CAP, lower=10_000_000_000.0)# Market cap >= 10 billion
req.add_simple_property(name=SimpleProperty.PE_TTM, lower=10.0, upper=50.0)# PE(TTM) 10~50
req.add_indicator_pattern(name=Pattern.MACD_GOLD_CROSS, period_type=Period.DAY)# MACD golden cross# Retrieve fields
req.add_retrieve_basic(name=BasicProperty.CODE)
req.add_retrieve_basic(name=BasicProperty.NAME)
req.add_retrieve_simple(name=SimpleProperty.PRICE)
req.add_retrieve_simple(name=SimpleProperty.MARKET_CAP)
req.add_retrieve_simple(name=SimpleProperty.PE_TTM)# Sort
req.set_sort(direction=ScrSortDir.DESC, property_type='simple',
property_params={'name':int(SimpleProperty.MARKET_CAP)})
req.page_count =50
ret, data = quote_ctx.get_stock_screen(req)if ret == RET_OK:
last_page, all_count, items = data
print(f"Total {all_count}, returned {len(items)} this page")for it in items[:3]:print(it['stock_id'], it['results'])else:print('error: ', data)# Example 2: Financial factor + cumulative change ratio
req = StockScreenRequest()
req.add_simple_field(field=SimpleField.MARKET, values=[ScrMarket.HK])
req.add_cumulative_property(name=CumulativeProperty.PRICE_CHANGE_PCT,
days=5, lower=-0.05, upper=0.05)# 5-day change ratio -5%~5% (decimal)
req.add_financial_property(name=FinancialProperty.NET_PROFIT,
term=Term.ANNUAL, lower=0.0)# Annual net profit > 0
req.add_retrieve_basic(name=BasicProperty.CODE)
req.add_retrieve_simple(name=SimpleProperty.PRICE)
req.page_count =200
ret, data = quote_ctx.get_stock_screen(req)# Example 3: K-line shape (double bottom + head-and-shoulders bottom)
req = StockScreenRequest()
req.add_simple_field(field=SimpleField.MARKET, values=[ScrMarket.HK])
req.add_kline_shape(name=KlineShapeProperty.SHAPE_TYPE, period=Period.DAY,
value_set=[KlineShapeType.DOUBLE_BOTTOMS,
KlineShapeType.HEAD_SHOULDERS_BOTTOM])
req.add_retrieve_basic(name=BasicProperty.CODE)
req.add_retrieve_kline_shape(name=KlineShapeProperty.SHAPE_TYPE, period=Period.DAY)
ret, data = quote_ctx.get_stock_screen(req)
quote_ctx.close()
Total 1, returned 154047868453564[{'type':'basic','property':{'name':1101},'value_type':1,'sval':'00700'},{'type':'basic','property':{'name':1102},'value_type':1,'sval':'Tencent Holdings'},{'type':'simple','property':{'name':2201},'value_type':4,'dval':460.0},{'type':'simple','property':{'name':2301},'value_type':4,'dval':4194280264040.0},{'type':'simple','property':{'name':2303},'value_type':4,'dval':15.75126}]