Stock Scanner

market_scanner Stock Scanner

value QuoteClient::market_scanner(utility::string_t market, const value &filters, const value &sort_field_data, int page, int page_size, utility::string_t cursor_id)

Description

Scan the entire market using various technical indicator conditions to help you filter symbols that meet specific investment criteria.

Technical indicator conditions include: basic indicators, accumulate indicators, financial indicators, and multi-tag indicators. Refer to the descriptions below for specific parameter meanings.

Parameters

ParameterTypeRequiredDescription
marketutility::string_tYesUS (US stocks), SG (Singapore stocks), HK (HK stocks)
filtersvalue (JSON array)YesFilter list, four types available, see below
sort_field_datavalue (JSON object)NoSort field object, main properties as follows
-- fieldutility::string_tNoSort field, string from StockField / AccumulateField / FinancialField / MultiTagField
-- sort_dirutility::string_tNoSort direction: no sort, ascending (SortDir_Ascend), descending (SortDir_Descend)
pageintNoCurrent page number (starting from 0). Not recommended, use cursor_id instead
cursor_idutility::string_tNoCursor ID for cursor-based pagination. Pass this value from the previous response when fetching the next page. Empty string for first query
page_sizeintNoNumber of records per page, max: 200

StockFilter parameter descriptions:

ParameterTypeRequiredDescription
fieldutility::string_tYesFour types of fields, see below
filter_mindoubleNoLower bound (closed interval), omit for -infinity. If percentage, no % needed, e.g., 10% = 10
filter_maxdoubleNoUpper bound (closed interval), omit for +infinity
is_no_filterboolNoWhether to disable this filter. If true, this filter is inactive
accumulate_periodutility::string_tNoAccumulation period, required only when field is AccumulateField
financial_periodutility::string_tNoFinancial period, required only when field is FinancialField
tag_listvalue (JSON array)NoTag list, required only when field is MultiTagField

StockFilter field types (passed as strings):

TypeDescription
StockFieldSimple indicator filter conditions, including price (OHLC, latest price), volume, shares, market cap, change rate, P/E ratio, turnover rate, etc. Field descriptions: Filter Field Descriptions
AccumulateFieldAccumulate indicator filter conditions, including cumulative change rate, asset growth rate, net profit growth rate, EPS, net profit, operating profit, revenue, ROA, operating cash flow, debt-to-asset ratio, etc. Periods can be: last 5 minutes, last 5/10/20 days, last 6 months, 1/2/5 years, Q1/Q3 reports, semi-annual, etc. Field descriptions: Filter Field Descriptions
FinancialFieldFinancial indicator filter conditions, including gross margin, net margin, total debt/equity, total debt/assets, current ratio, ROA, net profit, operating cash flow, total assets, HK Stock Connect net buying, annualized return, etc. Currently only supports LTM (Last Twelve Months) financial report query. Field descriptions: Filter Field Descriptions
MultiTagFieldMulti-tag relational filter conditions based on industry, concept, historical price highs (current day vs. historical), 52-week highs, OTC status, option support, stock type (stock, ETF), IPO price break, etc. Field descriptions: Filter Field Descriptions

Price fields in filter parameters correspond to the currency of the market the symbol belongs to, e.g., US stocks: USD, HK stocks: HKD, SG stocks: SGD, etc.

Return

web::json::value JSON object

Structure:

{
  "page": 0,
  "totalPage": 208,
  "totalCount": 1040,
  "pageSize": 5,
  "cursorId": "xxxxxx",
  "items": [
    {
      "symbol": "DNP",
      "market": "US",
      "fieldData": { ... }
    }
  ],
  "symbols": ["FEN", "DNP", "FDUS", "KYN", "TYG"]
}

Example

#include "tigerapi/quote_client.h"
#include "tigerapi/client_config.h"

using namespace TIGER_API;
using namespace web::json;

ClientConfig config(false, U("/path/to/your/properties/"));
QuoteClient quote_client(config);

// Stock basic data filter (is_no_filter=true means this filter is disabled)
value base_filter1 = value::object();
base_filter1[U("fieldName")] = value::string(U("FloatShare"));
base_filter1[U("filterType")] = value::string(U("StockField"));
base_filter1[U("filterMin")] = value::number(1e7);
base_filter1[U("filterMax")] = value::number(1e13);
base_filter1[U("isNoFilter")] = value::boolean(true);

value base_filter2 = value::object();
base_filter2[U("fieldName")] = value::string(U("MarketValue"));
base_filter2[U("filterType")] = value::string(U("StockField"));
base_filter2[U("filterMin")] = value::number(1e8);
base_filter2[U("filterMax")] = value::number(1e14);
base_filter2[U("isNoFilter")] = value::boolean(false);

// Accumulate data filter
value accumulate_filter = value::object();
accumulate_filter[U("fieldName")] = value::string(U("ChangeRate"));
accumulate_filter[U("filterType")] = value::string(U("AccumulateField"));
accumulate_filter[U("filterMin")] = value::number(0.01);
accumulate_filter[U("filterMax")] = value::number(1.0);
accumulate_filter[U("isNoFilter")] = value::boolean(false);
accumulate_filter[U("accumulatePeriod")] = value::string(U("Last_Year"));

// Financial data filter
value financial_filter = value::object();
financial_filter[U("fieldName")] = value::string(U("LYR_PE"));
financial_filter[U("filterType")] = value::string(U("FinancialField"));
financial_filter[U("filterMin")] = value::number(1.0);
financial_filter[U("filterMax")] = value::number(100.0);
financial_filter[U("isNoFilter")] = value::boolean(false);
financial_filter[U("financialPeriod")] = value::string(U("LTM"));

// Multi-tag data filter
value multi_tag_filter = value::object();
multi_tag_filter[U("fieldName")] = value::string(U("isOTC"));
multi_tag_filter[U("filterType")] = value::string(U("MultiTagField"));
value tag_list = value::array();
tag_list[0] = value::string(U("BK4209"));
multi_tag_filter[U("tagList")] = tag_list;

// Build filters array
value filters = value::array();
filters[0] = base_filter1;
filters[1] = base_filter2;
filters[2] = accumulate_filter;
filters[3] = financial_filter;
filters[4] = multi_tag_filter;

// Sort field
value sort_field_data = value::object();
sort_field_data[U("fieldName")] = value::string(U("FloatShare"));
sort_field_data[U("filterType")] = value::string(U("StockField"));
sort_field_data[U("sortDir")] = value::string(U("SortDir_Ascend"));

value result = quote_client.market_scanner(U("US"), filters, sort_field_data, 0, 50, U(""));
ucout << result.serialize() << std::endl;

Example 1 Filter stocks with dividend yield > 5% and 3-year revenue CAGR > 10%

#include "tigerapi/quote_client.h"
#include "tigerapi/client_config.h"

using namespace TIGER_API;
using namespace web::json;

ClientConfig config(false, U("/path/to/your/properties/"));
QuoteClient quote_client(config);

// Dividend yield > 5%
value base_filter = value::object();
base_filter[U("fieldName")] = value::string(U("DivideRate"));
base_filter[U("filterType")] = value::string(U("StockField"));
base_filter[U("filterMin")] = value::number(0.05);

// 3-year revenue CAGR
value financial_filter = value::object();
financial_filter[U("fieldName")] = value::string(U("TotalRevenues3YrCagr"));
financial_filter[U("filterType")] = value::string(U("FinancialField"));
financial_filter[U("filterMin")] = value::number(0.1);

value filters = value::array();
filters[0] = base_filter;
filters[1] = financial_filter;

value result = quote_client.market_scanner(U("US"), filters, value::null(), 0, 50, U(""));
ucout << result.serialize() << std::endl;

Example 2: Filter by ETF Type

Available ETF type tag values for tag_list:

Popular: package_us_v1_etf_hot
Bank ETF: package_us_v1_etf_bank
Bond ETF: package_us_v1_etf_bond
Buffer: package_us_v1_etf_buffer
Broad Index: package_us_v1_etf_index
Leveraged & Inverse: package_us_v1_etf_leverage
Sector: package_us_v1_etf_sector
Single Stock Leveraged: package_us_v1_etf_single_stock
Market Cap: package_us_v1_etf_market_cap
Thematic: package_us_v1_etf_thematic
International: package_us_v1_etf_international
Growth & Value: package_us_v1_etf_growth
Commodity: package_us_v1_etf_commodity
ARK: package_us_v1_etf_ark
Volatility: package_us_v1_etf_volatility
Currency: package_us_v1_etf_currency
Alternative: package_us_v1_etf_alternative
#include "tigerapi/quote_client.h"
#include "tigerapi/client_config.h"

using namespace TIGER_API;
using namespace web::json;

ClientConfig config(false, U("/path/to/your/properties/"));
QuoteClient quote_client(config);

// Filter by ETF type - Growth and Alternative ETFs
value multi_tag_filter_etftype = value::object();
multi_tag_filter_etftype[U("fieldName")] = value::string(U("ETF_TYPE"));
multi_tag_filter_etftype[U("filterType")] = value::string(U("MultiTagField"));
value etf_tag_list = value::array();
etf_tag_list[0] = value::string(U("package_us_v1_etf_growth"));
etf_tag_list[1] = value::string(U("package_us_v1_etf_alternative"));
multi_tag_filter_etftype[U("tagList")] = etf_tag_list;

value filters = value::array();
filters[0] = multi_tag_filter_etftype;

value result = quote_client.market_scanner(U("US"), filters, value::null(), 0, 50, U(""));
ucout << result.serialize() << std::endl;

get_market_scanner_tags

value QuoteClient::get_market_scanner_tags(utility::string_t market, const value &tag_fields)

Description

Get tag values for multi-tag relational filter fields. Currently only supports retrieving Industry and Concept tag collections.

Parameters

ParameterTypeRequiredDescription
marketutility::string_tYesUS (US stocks), SG (Singapore stocks), HK (HK stocks)
tag_fieldsvalue (JSON array)YesSupported field string values: U("Industry"), U("Concept")

Return

web::json::value JSON array, each item as follows:

FieldTypeDescription
marketstringMarket code (US: US stocks, CN: A-shares, HK: HK stocks)
multi_tag_fieldstringMulti-tag field
tag_listarrayTag collection for the multi-tag field

Example

#include "tigerapi/quote_client.h"
#include "tigerapi/client_config.h"

using namespace TIGER_API;
using namespace web::json;

ClientConfig config(false, U("/path/to/your/properties/"));
QuoteClient quote_client(config);

value tag_fields = value::array();
tag_fields[0] = value::string(U("Concept"));
tag_fields[1] = value::string(U("Industry"));

value result = quote_client.get_market_scanner_tags(U("US"), tag_fields);
ucout << result.serialize() << std::endl;