Market Scanner
market_scanner
Description Scan the whole market with different technical indicator conditions to help you filter the list of underlying indicators that meet your specific investment needs.
The technical indicator conditions contain the following categories: Basic, Cumulative, Financial, and Multi-label indicators, please refer to the descriptions below for specific parameter meanings.
Arguments
arg | type | required | desc |
---|---|---|---|
market | tigeropen.common.consts.Market | Yes | US ,SG ,HK |
filters | list[StockFilter] | Yes | filter list |
sort_field_data | tigeropen.quote.domain.filter.SortFilterData | No | sort field |
∟ field | enum | No | sort field, tigeropen.common.consts.filter_fields like StockField, AccumulateField |
∟ sort_dir | tigeropen.common.consts.SortDirection | No | sort direction |
page | int | No | current page, start from 0 |
page_size | int | No | page size, max 200 |
StockFilter:
arg | type | required | desc |
---|---|---|---|
field | tigeropen.common.consts.filter_fields.FilterField | Yes | |
filter_min | float | No | lower limit |
filter_max | float | No | upper limit |
is_no_filter | bool | No | is disable filter |
accumulate_period | tigeropen.common.consts.filter_fields.AccumulatePeriod | No | period,only required when field is AccumulateField |
financial_period | tigeropen.common.consts.filter_fields.FinancialPeriod | No | financial period, only required when field is FinancialField |
tag_list | list[int,str] | No | tag list, only required when field is MultiTagField |
StockFilter's field type ( tigeropen.common.consts.filter_fields
)
type | description |
---|---|
StockField | Simple indicator filtering conditions, including price (high open, low close, latest price, etc.), volume, equity, market capitalization, up or down, P/E ratio, turnover ratio and other factors. Screening field meanings: filter field |
AccumulateField | Cumulative indicators screening criteria, including cumulative increase or decrease, asset growth rate, net profit growth rate, earnings per share, net profit, operating profit, operating income, ROA (return on net assets), operating cash flow, gearing ratio, etc. Cumulative indicator period can be: last five minutes, last 5 days, 10 days, 20 days, last six months, one year, two years, five years, quarterly report, quarterly report, mid-term report, etc. Description of the meaning of the filter fields:filter field |
FinancialField | Financial indicators filter criteria, including gross profit, net profit margin, total debt/shareholders' equity, total debt/total assets, current ratio, return on assets, net income, operating cash flow, total assets, HKEx net buy, annualized return, etc. Financial indicators currently only support LTM (Last 12 months annual report indicator) type of financial report query. Description of the meaning of the filter fields:filter field |
MultiTagField | Multi-label correlation screening criteria to select stocks based on industry, concept, historical stock price high (stock price on that day compared to historical price), stock price high within 52 weeks (stock price on that day compared to last 52 weeks), whether it is OTC, whether it supports options, stock type (stock, ETF), whether it is broken, and other indicators. Description of the meaning of the filter fields:filter field |
The currency corresponding to the price field in the filter parameter is consistent with the currency type of the market in which the underlying is located, e.g. US: USD, HK: HKD, IPO: SGD, etc.
Return
tigeropen.quote.domain.filter.ScannerResult
data structure as follows:
class ScannerResult:
def __init__(self, page, page_size, total_page, total_count, items):
# current page, start from 0
self.page = page
self.total_page = total_page
# total data count
self.total_count = total_count
self.page_size = page_size
# data items
self.items: ScannerResultItem = list()
# symbol list
self.symbols = list()
class ScannerResultItem:
def __init__(self, symbol, market, base_data_list=None, accumulate_data_list=None, financial_data_list=None,
multi_tag_data_list=None):
self.symbol = symbol
self.market = market
self.field_data = dict()
Example
from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import get_client_config
from tigeropen.common.consts import TradingSession, Market
from tigeropen.quote.domain.filter import OptionFilter, StockFilter, SortFilterData
from tigeropen.common.consts.filter_fields import StockField, AccumulateField, FinancialField, MultiTagField, \
FinancialPeriod, AccumulatePeriod
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
quote_client = QuoteClient(client_config)
def test_market_scanner():
base_filter1 = StockFilter(StockField.FloatShare, filter_min=1e7, filter_max=1e13, is_no_filter=True)
base_filter2 = StockFilter(StockField.MarketValue, filter_min=1e8, filter_max=1e14, is_no_filter=False)
# filter by earning date
base_filter3 = StockFilter(StockField.EarningDate, filter_min=int(datetime.strptime('2021-01-01', '%Y-%m-%d').timestamp() * 1000),
filter_max=int(datetime.strptime('2023-12-31', '%Y-%m-%d').timestamp() * 1000)
, is_no_filter=False)
accumulate_filter = StockFilter(AccumulateField.ChangeRate, filter_min=0.01, filter_max=1, is_no_filter=False,
accumulate_period=AccumulatePeriod.Last_Year)
financial_filter = StockFilter(FinancialField.LYR_PE, filter_min=1, filter_max=100, is_no_filter=False,
financial_period=FinancialPeriod.LTM)
multi_tag_filter = StockFilter(MultiTagField.isOTC, tag_list=[0])
# sort field
sort_field_data = SortFilterData(StockField.FloatShare, sort_dir=SortDirection.ASC)
begin_page = 0
page_size = 50
is_last_page = False
scanner_result_symbols = set()
while not is_last_page:
result = quote_client.market_scanner(market=Market.US,
filters=[base_filter1, base_filter2, accumulate_filter,
financial_filter,
multi_tag_filter],
sort_field_data=sort_field_data,
page=begin_page,
page_size=page_size)
print(result)
if result.total_page:
for item in result.items:
# item type: ScannerResultItem
symbol = item.symbol
market = item.market
# get value like dict
base_filter1_value = item[base_filter1]
accumulate_filter_value = item[accumulate_filter]
print(
f'page:{result.page}, symbol:{symbol}, base_filter1 value:{base_filter1_value}, accumulate_filter value:{accumulate_filter_value}')
print(f'current page symbols:{result.symbols}')
scanner_result_symbols.update(result.symbols)
time.sleep(1)
if result.page >= result.total_page - 1:
is_last_page = True
else:
begin_page = result.page + 1
print(f'scanned symbols:{scanner_result_symbols}')
Return Example
ScannerResult({'page': 0, 'total_page': 208, 'total_count': 1040, 'page_size': 5,
'items': [
ScannerResultItem({'symbol': 'DNP', 'market': 'US',
'field_data': {
<StockField.FloatShare: 13>: 0.0,
<StockField.MarketValue: 17>: 3855828898.39,
<AccumulateField.ChangeRate: 1>: 0.043925,
<FinancialField.LYR_PE: 45>: 7.359675,
<MultiTagField.isOTC: 3>: '0'}}),
ScannerResultItem({'symbol': 'FEN', 'market': 'US',
'field_data': {
<StockField.FloatShare: 13>: 0.0,
<StockField.MarketValue: 17>: 278571284.64,
<AccumulateField.ChangeRate: 1>: 0.063893,
<FinancialField.LYR_PE: 45>: 6.45728,
<MultiTagField.isOTC: 3>: '0'}}),
ScannerResultItem({'symbol': 'FDUS', 'market': 'US',
'field_data': {
<StockField.FloatShare: 13>: 0.0,
<StockField.MarketValue: 17>: 462844356.0,
<AccumulateField.ChangeRate: 1>: 0.079202,
<FinancialField.LYR_PE: 45>: 3.986464,
<MultiTagField.isOTC: 3>: '0'}}),
ScannerResultItem({'symbol': 'KYN', 'market': 'US',
'field_data': {
<StockField.FloatShare: 13>: 0.0,
<StockField.MarketValue: 17>: 1181621680.4,
<AccumulateField.ChangeRate: 1>: 0.122898,
<FinancialField.LYR_PE: 45>: 3.268946,
<MultiTagField.isOTC: 3>: '0'}}),
ScannerResultItem({'symbol': 'TYG', 'market': 'US',
'field_data': {
<StockField.FloatShare: 13>: 0.0,
<StockField.MarketValue: 17>: 381692896.0,
<AccumulateField.ChangeRate: 1>: 0.180812,
<FinancialField.LYR_PE: 45>: 2.853998,
<MultiTagField.isOTC: 3>: '0'}})],
'symbols': ['FEN', 'DNP', 'FDUS', 'KYN', 'TYG']})
get_market_scanner_tags
Get the tag value of a multi-tag associative filter field
Description
Get tag values of multi-label associated filter fields, only industry and concept tag sets are supported for now.
Parameters
Parameters | Type | Required | Description |
---|---|---|---|
market | tigeropen.common.consts.Market | Yes | US US stocks, SG new stocks, HK HK stocks |
tag_fields | list[tigeropen.common.consts.filter_fields.MultiTagField] | Yes | Supported field enumeration values: MultiTagField.Industry, MultiTagField.Concept |
returns the
list. where each item is as follows
Field | Type | Description |
---|---|---|
market | str | market code (US:US stock, CN:CSI, HK:HK stock) |
multi_tag_field | str | multi_tag_field |
tag_list | list[str] | the set of tags that the multi-tag field can be used to filter |
Example
from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import get_client_config
from tigeropen.common.consts import TradingSession, Market
from tigeropen.common.consts.filter_fields import MultiTagField
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
quote_client = QuoteClient(client_config)
field_list = [ MultiTagField.Concept, MultiTagField.Industry]
result = quote_client.get_market_scanner_tags(market=Market.US, fields=field_list)
print(result)
Return example
[{'market': 'US', 'multi_tag_field': 'MultiTagField_Concept', 'tag_list': [{'tag': 'BK4565', 'value': 'NFT'}]