Login/Logout Function

Login Function: THS_iFinDLogin

python
THS_iFinDLogin(username, password)

This command is required to log in before starting the operation.

Parameters:

parametername of parameterparameter typeparametric description
usernameaccount IDcharacter stringAccount ID of data interface
passwordpasswordcharacter stringThe password corresponding to the data interface account ID.

Output:

fieldfield namefield description
errorcodeerror code1. Return 0, indicating successful login; 2. Return-201, indicating repeated login; 3. Return-2, indicating wrong username or password.

Examples:

python
THS_iFinDLogin('user888','888888')

This example represents user888 logging in with password 88888

_Note: _

1. Command timeout is 90 seconds.

_2. When different computers log on to the same account at the same time, mutual exclusion will occur.

Logout Function: THS_iFinDLogout

python
THS_iFinDLogout()

Users can use this function to log out of accounts they have already logged in to.

Output:

fieldfield namefield description
errorcodeerror code1. Returns 0 to indicate successful logout.

Examples:

python
THS_iFinDLogout()

This example indicates that the user is logging out.

Data Function

Basic Data: THS_BD

python
THS_BD(thsCode, indicatorName, paramOption)

This function is used to obtain basic information, financial statements, profit forecasts, mergers and acquisitions and other index data of corresponding securities varieties. It supports multi-code and multi-index input.

_Note: _ 1 piece of data is 1 EXCEL cell

Parameters:

parametername of parameterparameter typeparametric description
thsCodecodecharacter stringStraight flush codes connected by commas, supporting multiple codes, such as: '600004.SH,300330.SZ'
indicatorNameindexcharacter stringMetric name connected by semicolon. Multiple metrics are supported. Metric name can be queried through SuperCommand Client-> Tools-> Metric Function, or command generated directly through SuperCommand Client.
paramOptionparametercharacter stringSemicolon concatenation of indicator parameters, different parameters of each indicator are concatenated with commas. Corresponding indicator in indicatorName. If there is no parameter, the corresponding indicator is blank, such as: '2019-12-09,100,2019-12-09;;2019-12-09,100,2019-12-09'

Output:

fieldfield namefield description
errorcodeerror IDCode error code, errorcode=0 indicates that the code is running normally. If it is other, you need to find the cause of the error
errmsgerror messageIf errorcode returns non-zero, a specific error message is returned here.
indicatorsindex informationReturn all metrics information
datatypepointer formatReturns the metric format of the acquired data
perfprocessing timeTotal Time to Return Request Command (ms)
dataVoldata sizeReturns the amount of data consumed by the current command
timetimeReturns a list of times when data values were taken
thscodeSubject informationReturn all subject codes
datastructural bodyThe returned content includes data content in specific formats such as dataframe, json, list, table, array, etc.

Examples:

python
THS_BD('300033.SZ,600030.SH','ths_open_price_stock;ths_stock_short_name_stock;ths_close_price_stock','2025-01-13,100,2025-01-13;;2025-01-13,100,2025-01-13')
matlab
[data, errorcode, indicators, thscode, errmsg, dataVol, datatype, perf] = THS_BD('300033.SZ,600030.SH','ths_open_price_stock;ths_stock_short_name_stock;ths_close_price_stock','2025-01-13,100,2025-01-13;;2025-01-13,100,2025-01-13','format:table')
r
THS_BasicData('300033.SZ,600030.SH','ths_open_price_stock;ths_stock_short_name_stock;ths_close_price_stock','2025-01-13,100,2025-01-13;;2025-01-13,100,2025-01-13',TRUE)
vba
THS_BasicData("300033.SZ,600030.SH","ths_open_price_stock;ths_stock_short_name_stock;ths_close_price_stock","2025-01-13,100,2025-01-13;;2025-01-13,100,2025-01-13")
csharp
THS_BasicData("300033.SZ,600030.SH","ths_open_price_stock;ths_stock_short_name_stock;ths_close_price_stock","2025-01-13,100,2025-01-13;;2025-01-13,100,2025-01-13")
c++
THS_BasicData("300033.SZ,600030.SH","ths_open_price_stock;ths_stock_short_name_stock;ths_close_price_stock","2025-01-13,100,2025-01-13;;2025-01-13,100,2025-01-13")
java
THS_BasicData("300033.SZ,600030.SH","ths_open_price_stock;ths_stock_short_name_stock;ths_close_price_stock","2025-01-13,100,2025-01-13;;2025-01-13,100,2025-01-13")
http
requestMethod:POST
requestURL:https://quantapi.51ifind.com/api/v1/basic_data_service
requestHeaders:{"Content-Type":"application/json","access_token":"","ifindlang":"cn"}
formData:{"codes":"300033.SZ,600030.SH","indipara":[{"indicator":"ths_open_price_stock","indiparams":["20250113","100","20250113"]},{"indicator":"ths_stock_short_name_stock"},{"indicator":"ths_close_price_stock","indiparams":["20250113","100","20250113"]}]}

This example returns the opening price, security name and closing price of Tonghuashun and CITIC Securities on January 13, 2025.

Date Sequence: THS_DS

python
THS_DS(thscode, jsonIndicator, jsonparam, globalparam, begintime, endtime)

Obtain historical data series of selected securities, including daily market data, fundamental data and various technical indicators.

Parameters:

parametername of parameterparameter typeparametric description
thscodecodecharacter stringStraight flush codes connected by commas, supporting multiple codes, such as: '600004.SH,300330.SZ'
jsonIndicatorindexcharacter stringMetric name connected by semicolon. Multiple metrics are supported. Metric name can be queried through SuperCommand Client-> Tools-> Metric Function, or command generated directly through SuperCommand Client.
jsonparamparametercharacter stringSemicolon concatenation of indicator parameters, different parameters of each indicator are concatenated with commas. Corresponds to the indicator in jsonIndicator. If the corresponding indicator has no parameter, it is empty, such as: '100;;100'
globalparamDate Series Output Settingscharacter stringThe setting of date sequence output connected by half angle comma, and the individual setting is separated by colon. You can set the processing of time period, date type, non-transaction interval processing, etc. of date series output. For example 'Interval:W,Fill:Previous,Days: WorkDays'. For parameters of various settings, see Date Sequence Output Setting Table.
begintimestart datecharacter stringTime format is Y-MM-DD, e.g.'2025-01-13'
endtimeexpiration datecharacter stringTime format is Y-MM-DD, e.g.'20125-01-13'

Date series output settings (globalparam):

fieldfield namefield description
Intervaltime periodD-Day W-Week M-Month Q-Season S-Half Year Y-Year
Daysdate typeTradedays-Trading Days Alldays-Calendar Days
FillNon-transaction interval processingPrevious-Use previous data Blank-null Specific value-custom value

Output:

fieldfield namefield description
errorcodeerror IDCode error code, errorcode=0 indicates that the code is running normally. If it is other, you need to find the cause of the error
errmsgerror messageIf errorcode returns non-zero, a specific error message is returned here.
indicatorsindex informationReturn all metrics information
datatypepointer formatReturns the metric format of the acquired data
perfprocessing timeTotal Time to Return Request Command (ms)
dataVoldata sizeReturns the amount of data consumed by the current command
timetimeReturns a list of times when data values were taken
thscodeSubject informationReturn all subject codes
datastructural bodyThe returned content includes data content in specific formats such as dataframe, json, list, table, array, etc.

Examples:

python
THS_DS('AAPL.O','ths_pre_close_uss','100','Days:Alldays,Fill:-1','2025-01-01','2025-01-13')
matlab
[data,errorcode,time,indicators,thscode,errmsg,dataVol,datatype,perf]=THS_DS('AAPL.O','ths_pre_close_uss','100','Days:Alldays,Fill:-1','2025-01-01','2025-01-13','format:table')
r
THS_DateSerial('AAPL.O','ths_pre_close_uss','100','Days:Alldays,Fill:-1','2025-01-01','2025-01-13',TRUE)
vba
THS_DateSerial("AAPL.O","ths_pre_close_uss","100","Days:Alldays,Fill:-1","2025-01-01","2025-01-13")
csharp
THS_DateSerial("AAPL.O","ths_pre_close_uss","100","Days:Alldays,Fill:-1","2025-01-01","2025-01-13")
c++
THS_DateSerial("AAPL.O","ths_pre_close_uss","100","Days:Alldays,Fill:-1","2025-01-01","2025-01-13")
java
THS_DateSerial("AAPL.O","ths_pre_close_uss","100","Days:Alldays,Fill:-1","2025-01-01","2025-01-13")
http
requestMethod:POST
requestURL:https://quantapi.51ifind.com/api/v1/date_sequence
requestHeaders:{"Content-Type":"application/json","access_token":"","ifindlang":"cn"}
formData:{"codes":"AAPL.O","startdate":"20250101","enddate":"20250113","functionpara":{"Days":"Alldays","Fill":"-1"},"indipara":[{"indicator":"ths_pre_close_uss","indiparams":["","100"]}]}

This example represents taking all previous closing price data of Apple from January 01, 2025 to January 13, 2025.

History: THS_HQ

python
THS_HQ(thscode, jsonIndicator, jsonparam, begintime, endtime)

Acquire historical market data of various securities, including daily market data, fundamental data and technical index data. There are also specific indicators for bonds, funds and futures. The time period can be selected by the user himself. Currently, the selectable time period includes day, week, month and year. Other optional parameters such as recovery method, quotation type ( Bonds), currency, etc. Users can choose according to their own needs.

Parameters:

parametername of parameterparameter typeparametric description
thscodecodecharacter stringStraight flush codes connected by commas, supporting multiple codes, such as: '600004.SH,300330.SZ'
jsonIndicatorindexcharacter stringSemicolon connected metric name, supports multiple metrics, metric name can be directly generated by SuperCommand client
jsonparamHistorical Quotes Output Settingscharacter stringThe setting of date sequence output connected by half angle comma, and the individual setting is separated by colon. You can set the time period of the historical market output, the recovery method, and the processing of non-trading intervals. For example 'Interval:W,Fill:Previous,Days: WorkDays'. For the parameters of each setting, see the historical quotation output setting table
begintimestart datecharacter stringTime format is Y-MM-DD, e.g.'2016-05-23'
endtimeexpiration datecharacter stringTime format is Y-MM-DD, e.g.'2016-05-23'

Historical Quotes Output Settings (jsonparam):

fieldfield namefield descriptiondefault value
Intervaltime periodD-Day W-Week M-Month Q-Season Y-Year Same Sampling Period One out of two, returns period summary statisticsD
SampleIntervalsampling periodD-Day W-Week M-Month Q-Quarter S-Half Year Y-Year Same Time Cycle Choose one of two, return to the last trading day frequency data of the cycleD
fillNon-transaction interval processingPrevious-Use previous data Blank-Empty specific value-Custom value Omit-Default valuePrevious
CPSrecovery mode1-No right recovery 2-Front right recovery (dividend reinvestment) 3-Later right recovery (dividend reinvestment) 4-Full circulation front right recovery (dividend reinvestment) 5-Full circulation rear right recovery (dividend reinvestment) 6-Front right recovery (cash dividend) 7-Later right recovery (cash dividend)1
baseDaterestoration baseForward or backward restoration based on restoration base points1900-01-01 Retroactive reinstatement based on the first day of listing or forward reinstatement based on the latest date
PriceTypeBond Quotation Type1-Full Price 2-Net Price Bond only valid1
Currencycurrency typeMHB-USD GHB-HKD RMB-CNY YSHB-Original CurrencyYSHB

Output:

fieldfield namefield description
errorcodeerror IDCode error code, errorcode=0 indicates that the code is running normally. If it is other, you need to find the cause of the error
errmsgerror messageIf errorcode returns non-zero, a specific error message is returned here.
indicatorsindex informationReturn all metrics information
datatypepointer formatReturns the metric format of the acquired data
perfprocessing timeTotal Time to Return Request Command (ms)
dataVoldata sizeReturns the amount of data consumed by the current command
timetimeReturns a list of times when data values were taken
thscodeSubject informationReturn all subject codes
datastructural bodyThe returned content includes data content in specific formats such as dataframe, json, list, table, array, etc.

Examples:

python
THS_HQ('300033.SZ','open,high,low,close','Currency:MHB,fill:Omit','2024-01-13','2025-01-13')
matlab
[data,errorcode,time,indicators,thscode,errmsg,dataVol,datatype,perf]=THS_HQ('300033.SZ','open,high,low,close','Currency:MHB,fill:Omit','2024-01-13','2025-01-13','format:table')
r
THS_HistoryQuotes('300033.SZ','open,high,low,close','Currency:MHB,fill:Omit','2024-01-13','2025-01-13',TRUE)
vba
THS_HistoryQuotes("300033.SZ","open,high,low,close","Currency:MHB,fill:Omit","2024-01-13","2025-01-13")
csharp
THS_HistoryQuotes("300033.SZ","open,high,low,close","Currency:MHB,fill:Omit","2024-01-13","2025-01-13")
c++
THS_HistoryQuotes("300033.SZ","open,high,low,close","Currency:MHB,fill:Omit","2024-01-13","2025-01-13")
java
THS_HistoryQuotes("300033.SZ","open,high,low,close","Currency:MHB,fill:Omit","2024-01-13","2025-01-13")
http
requestMethod:POST
requestURL:https://quantapi.51ifind.com/api/v1/cmd_history_quotation
requestHeaders:{"Content-Type":"application/json","access_token":"","ifindlang":"cn"}
formData:{"codes":"300033.SZ","indicators":"open,high,low,close","startdate":"2024-01-13","enddate":"2025-01-13","functionpara":{"Currency":"MHB","Fill":"Omit"}}

This example represents a high open and low close of historical data from 2024-01-13 to 2025-01-13, and does not return a date if there is no trade on that date.

HF Sequence: THS_HF

python
THS_HF(thscode, jsonIndicator, jsonparam, begintime, endtime)

The command is used to obtain minutes of securities history K line market, technical indicators and other data. The cycle of minute line can be selected by yourself. At present, the optional cycles are 1 minute, 3 minutes and 5 minutes. minutes, 10 minutes, 15 minutes, 30 minutes and 60 minutes.

Parameters:

parametername of parameterparameter typeparametric description
thscodecodecharacter stringStraight flush codes connected by commas, supporting multiple codes, such as: '600004.SH,300330.SZ'
jsonIndicatorindexcharacter stringSemicolon connected metric name, supports multiple metrics, metric name can be directly generated by SuperCommand client
jsonparamHF Sequence Output Settingscharacter stringThe setting of date sequence output connected by half angle comma, and the individual setting is separated by colon. You can set the processing of time period, date type, non-transaction interval processing, etc. of date series output. For example 'Interval:W,Fill:Previous,Days: WorkDays'. For the parameters of each setting, see HF Sequence Output Settings
begintimestart timecharacter stringStart time, time format: Y-MM-DD HH:MM:SS, e.g. 2019-12-10 09:30:00
endtimedeadlinecharacter stringDeadline time, time format: Y-MM-DD HH:MM:SS, e.g. 2019-12-10 10:30:00

High frequency sequence output settings (jsonparam):

fieldfield namefield descriptiondefault value
startTimeDaily Data Start TimestartTime and endTime define the start and end times of each trading day's data
endTimeDaily Data Cutoff TimestartTime and endTime define the start and end times of each trading day's data
timeformattimestamp formatEmpty string-Beijing time LocalTime-Local time
Intervaltime period1-1 min 3-3 min 5-5 min 10-10 min 15-15 min 30-30 min 60-60 min1
FillNon-transaction interval processingOriginal-Do not process Previous-Follow previous data Blank-Blank Specific value-Custom valuePrevious
CPSrecovery mode1. Stocks: no-no recovery forward1-forward recovery (dividend scheme calculation) backward1-backward recovery (dividend scheme calculation) forward3-forward recovery (exchange price calculation) backward3-backward recovery (exchange price calculation) forward2-full circulation forward recovery (dividend scheme calculation) backward2-full circulation backward recovery (dividend scheme calculation) forward4-full circulation forward recovery (exchange price calculation) backward4-full circulation backward recovery (exchange price calculation) 2. Other objects: no-forward-backward-back-rightno
baseDaterestoration baseForward or backward restoration based on restoration base points1900-01-01 Retroactive reinstatement based on the first day of listing or forward reinstatement based on the latest date

Output:

fieldfield namefield description
errorcodeerror IDCode error code, errorcode=0 indicates that the code is running normally. If it is other, you need to find the cause of the error
errmsgerror messageIf errorcode returns non-zero, a specific error message is returned here.
indicatorsindex informationReturn all metrics information
datatypepointer formatReturns the metric format of the acquired data
perfprocessing timeTotal Time to Return Request Command (ms)
dataVoldata sizeReturns the amount of data consumed by the current command
timetimeReturns a list of times when data values were taken
thscodeSubject informationReturn all subject codes
datastructural bodyThe returned content includes data content in specific formats such as dataframe, json, list, table, array, etc.

Examples:

python
THS_HF('300033.SZ','close','CPS:forward1,Fill:Previous,timeformat:LocalTime,startTime:09:30:00,endTime:09:40:00','2025-01-01 09:15:00','2025-01-13 15:15:00')
matlab
[data,errorcode,time,indicators,thscode,errmsg,dataVol,datatype,perf]=THS_HF('300033.SZ','close','CPS:forward1,Fill:Previous,timeformat:LocalTime,startTime:09:30:00,endTime:09:40:00','2025-01-01 09:15:00','2025-01-13 15:15:00','format:table')
r
THS_HighFrequenceSequence('300033.SZ','close','CPS:forward1,Fill:Previous,timeformat:LocalTime,startTime:09:30:00,endTime:09:40:00','2025-01-01 09:15:00','2025-01-13 15:15:00',TRUE)
vba
THS_HighFrequenceSequence("300033.SZ","close","CPS:forward1,Fill:Previous,timeformat:LocalTime,startTime:09:30:00,endTime:09:40:00","2025-01-01 09:15:00","2025-01-13 15:15:00")
csharp
THS_HighFrequenceSequence("300033.SZ","close","CPS:forward1,Fill:Previous,timeformat:LocalTime,startTime:09:30:00,endTime:09:40:00","2025-01-01 09:15:00","2025-01-13 15:15:00")
c++
THS_HighFrequenceSequence("300033.SZ","close","CPS:forward1,Fill:Previous,timeformat:LocalTime,startTime:09:30:00,endTime:09:40:00","2025-01-01 09:15:00","2025-01-13 15:15:00")
java
THS_HighFrequenceSequence("300033.SZ","close","CPS:forward1,Fill:Previous,timeformat:LocalTime,startTime:09:30:00,endTime:09:40:00","2025-01-01 09:15:00","2025-01-13 15:15:00")
http
requestMethod:POST
requestURL:https://quantapi.51ifind.com/api/v1/high_frequency
requestHeaders:{"Content-Type":"application/json","access_token":"","ifindlang":"cn"}
formData:{"codes":"300033.SZ","indicators":"close","starttime":"2025-01-01 09:15:00","endtime":"2025-01-13 15:15:00","functionpara":{"CPS":"forward1","Fill":"Previous","Timeformat":"LocalTime","Limitstart":"09:30:00","Limitend":"09:40:00"}}

This example represents taking 1 minute of data from 2025-01-01 9:30 to 2025-01-13 9:40 for a straight flush.

Real-time Quotes: THS_RQ

python
THS_RQ(thscode, jsonIndicator, jsonparam)

Acquire the latest market data of the corresponding securities. Support multi-code and multi-indicator.

Parameters:

parametername of parameterparameter typeparametric description
thscodecodecharacter stringStraight flush codes connected by commas, supporting multiple codes, such as: '600004.SH,300330.SZ'
jsonIndicatorindexcharacter stringSemicolon connected indicator name, supports multiple indicators, indicator name can be generated directly through SuperCommand client
jsonparamparametercharacter stringColons separate the settings for assignment. Currently, only bonds apply pricetype:1 for net price, pricetype:2 for full price, and pricetype:3 for yield. Request other varieties can not pass or empty string

Output:

fieldfield namefield description
errorcodeerror IDCode error code, errorcode=0 indicates that the code is running normally. If it is other, you need to find the cause of the error
errmsgerror messageIf errorcode returns non-zero, a specific error message is returned here.
indicatorsindex informationReturn all metrics information
datatypepointer formatReturns the metric format of the acquired data
perfprocessing timeTotal Time to Return Request Command (ms)
dataVoldata sizeReturns the amount of data consumed by the current command
timetimeReturns a list of times when data values were taken
thscodeSubject informationReturn all subject codes
datastructural bodyThe returned content includes data content in specific formats such as dataframe, json, list, table, array, etc.

Examples:

python
THS_RQ('300033.SZ,600030.SH','open;high;low;latest')
matlab
[data,errorcode,time,indicators,thscode,errmsg,dataVol,datatype,perf]=THS_RQ('300033.SZ,600030.SH','open;high;low;latest','','format:table')
r
THS_RealtimeQuotes('300033.SZ,600030.SH','open;high;low;latest','',TRUE)
vba
THS_RealtimeQuotes("300033.SZ,600030.SH","open;high;low;latest")
csharp
THS_RealtimeQuotes("300033.SZ,600030.SH","open;high;low;latest","")
c++
THS_RealtimeQuotes("300033.SZ,600030.SH","open;high;low;latest","")
java
THS_RealtimeQuotes("300033.SZ,600030.SH","open;high;low;latest")
http
requestMethod:POST
requestURL:https://quantapi.51ifind.com/api/v1/real_time_quotation
requestHeaders:{"Content-Type":"application/json","access_token":"","ifindlang":"cn"}
formData:{"codes":"300033.SZ,600030.SH","indicators":"open,high,low,latest"}

This example represents the high open low current price data of the latest straight flush and CITIC Securities.

Intraday Snapshot: THS_SS

python
THS_SS(thscode, jsonIndicator, jsonparam, begintime, endtime)

Get intraday and historical snapshots and open data for the corresponding security symbol.

Parameters:

parametername of parameterparameter typeparametric description
thscodecodecharacter stringStraight flush codes connected by commas, supporting multiple codes, such as: '600004.SH,300330.SZ'
jsonIndicatorindexcharacter stringSemicolon connected metric name, supports multiple metrics, metric name can be directly generated by SuperCommand client
jsonparamIntraday snapshot output settingscharacter stringIndividual settings are separated by colons. Currently, only data type is supported, i.e. dataType:Original
begintimestart timecharacter stringStart time, time format: Y-MM-DD HH:MM:SS, e.g. 2019-12-10 09:30:00
endtimedeadlinecharacter stringDeadline time, time format: Y-MM-DD HH:MM:SS, e.g. 2019-12-10 10:30:00

Output:

fieldfield namefield description
errorcodeerror IDCode error code, errorcode=0 indicates that the code is running normally. If it is other, you need to find the cause of the error
errmsgerror messageIf errorcode returns non-zero, a specific error message is returned here.
indicatorsindex informationReturn all metrics information
datatypepointer formatReturns the metric format of the acquired data
perfprocessing timeTotal Time to Return Request Command (ms)
dataVoldata sizeReturns the amount of data consumed by the current command
timetimeReturns a list of times when data values were taken
thscodeSubject informationReturn all subject codes
datastructural bodyThe returned content includes data content in specific formats such as dataframe, json, list, table, array, etc.

Examples:

python
THS_SS('300033.SZ','latest','','2025-01-13 09:15:00','2025-01-17 15:15:00')
matlab
[data,errorcode,time,indicators,thscode,errmsg,dataVol,datatype,perf]=THS_SS('300033.SZ','latest','','2025-01-13 09:15:00','2025-01-17 15:15:00','format:table')
r
THS_Snapshot('300033.SZ','latest','','2025-01-13 09:15:00','2025-01-17 15:15:00',TRUE)
vba
THS_Snapshot("300033.SZ","latest","","2025-01-13 09:15:00","2025-01-17 15:15:00")
csharp
THS_Snapshot("300033.SZ","latest","","2025-01-13 09:15:00","2025-01-17 15:15:00")
c++
THS_Snapshot("300033.SZ","latest","","2025-01-13 09:15:00","2025-01-17 15:15:00")
java
THS_Snapshot("300033.SZ","latest","","2025-01-13 09:15:00","2025-01-17 15:15:00")
http
requestMethod:POST
requestURL:https://quantapi.51ifind.com/api/v1/snap_shot
requestHeaders:{"Content-Type":"application/json","access_token":"","ifindlang":"cn"}
formData:{"codes":"300033.SZ","indicators":"latest","starttime":"2025-01-13 09:15:00","endtime":"2025-01-17 15:15:00"}

Returns the current price data of Flush on January 13, 2025.

EDB Data: THS_EDB

python
THS_EDB(indicators, param, begintime, endtime)

Acquire macroeconomic data, including China macro data, regional macro data, global macro data, industry economic data, economic benefit data, interest rate trend data and world economic data.

Parameters:

parametername of parameterparameter typeparametric description
indicatorsMacro Indicator IDcharacter stringMacro-indicator ID connected by semicolon. Multiple indicators are supported. You can query the indicator name in SuperCommand-> Economic Database Direct Generation Command or SuperCommand-> Tools->EDB Indicator ID Query.
paramparametercharacter stringstartrtime-update start time endrtime-update end time mode-index
begintimestart datecharacter stringTime format is Y-MM-DD, e.g.'2016-05-23'
endtimeexpiration datecharacter stringTime format is Y-MM-DD, e.g.'2017-05-23'

Output:

fieldfield namefield description
errorcodeerror IDCode error code, errorcode=0 indicates that the code is running normally. If it is other, you need to find the cause of the error
errmsgerror messageIf errorcode returns non-zero, a specific error message is returned here.
indicatorsindex informationReturn all metrics information
datatypepointer formatReturns the metric format of the acquired data
perfprocessing timeTotal Time to Return Request Command (ms)
dataVoldata sizeReturns the amount of data consumed by the current command
timetimeReturns a list of times when data values were taken
thscodeSubject informationReturn all subject codes
datastructural bodyThe returned content includes data content in specific formats such as dataframe, json, list, table, array, etc.

Examples:

python
THS_EDB('M001620253;M002826938','','2024-01-18','2025-01-18')
matlab
[data,errorcode,errmsg,dataVol,perf]=THS_EDB('M001620253;M002826938','','2024-01-18','2025-01-18','format:table')
r
THS_EDB('M001620253;M002826938','','2024-01-18','2025-01-18',TRUE)
vba
THS_EDB("M001620253;M002826938","","2024-01-18","2025-01-18")
csharp
THS_EDB("M001620253;M002826938","","2024-01-18","2025-01-18")
c++
THS_EDB("M001620253;M002826938","","2024-01-18","2025-01-18")
java
THS_EDB("M001620253;M002826938","","2024-01-18","2025-01-18")
http
requestMethod:POST
requestURL:http://quantapi.51ifind.com/api/v1/edb_service
requestHeaders:{"Content-Type":"application/json","access_token":"","ifindlang":"cn"}
formData:{"indicators":"M001620253,M002826938","startdate":"2024-01-18","enddate":"2025-01-18"}

This example represents all GDP: per capita and GDP: year-on-year data from January 18, 2024 to January 18, 2025.

characteristic Data

Intelligent Stock Selection: THS_WCQuery

python
THS_WCQuery(query, domain)

Call the interface of asking for wealth and adjust stock selection through semantic recognition.

Parameters:

parametername of parameterparameter typeparametric description
querysearch contentcharacter stringSearch content that needs to be entered in Ask Money
domainparametercharacter stringYou can set the scope of the search content

Output:

fieldfield namefield description
errorcodeerror IDCode error code, errorcode=0 indicates that the code is running normally. If it is other, you need to find the cause of the error
errmsgerror messageIf errorcode returns non-zero, a specific error message is returned here.
indicatorsindex informationReturn all metrics information
datatypepointer formatReturns the metric format of the acquired data
perfprocessing timeTotal Time to Return Request Command (ms)
dataVoldata sizeReturns the amount of data consumed by the current command
timetimeReturns a list of times when data values were taken
thscodeSubject informationReturn all subject codes
datastructural bodyThe returned content includes data content in specific formats such as dataframe, json, list, table, array, etc.

Examples:

python
THS_WCQuery('低市盈率','stock')
matlab
[data,errorcode,errmsg,dataVol,perf]=THS_WCQuery('低市盈率','stock','format:table')
r
THS_WCQuery('低市盈率','stock',TRUE)
vba
THS_WCQuery("低市盈率","stock")
csharp
THS_WCQuery("低市盈率","stock")
c++
THS_WCQuery("低市盈率","stock")
java
THS_WCQuery("低市盈率","stock")
http
requestMethod:POST
requestURL:https://quantapi.51ifind.com/api/v1/smart_stock_picking
requestHeaders:{"Content-Type":"application/json","access_token":"","ifindlang":"cn"}
formData:{"searchstring":"低市盈率","searchtype":"stock"}

Acquire the A shares that the financial inquiry system believes have low P/E ratios.

Announcement Query: THS_ReportQuery

python
THS_ReportQuery(thscode, param, output)

Returns announcement information such as announcement date, release time, security code, announcement title, announcement link, etc. of the selected stock.

Parameters:

parametername of parameterparameter typeparametric description
thscodecodecharacter stringStraight flush codes connected by commas, supporting multiple codes, such as: '600004.SH,300330.SZ'
paraminput parameterscharacter stringSemicolon linked announcement query function parameter settings, single settings separated by colons assigned. You can set whether to extract the plate, set the release start deadline, announcement start deadline, title keywords, announcement type, etc. For example 'mode:allAStock; initirDate:2021-12-09;endrDate:2021-12-09;reportType: 901'. For the parameters of each setting, see the parameter setting table below
outputoutput parametercharacter stringComma concatenation, used to control whether a column output, each set to column name and "Y" or "N" separated by a colon assignment. For example,'reportDate:Y,thscode: Y', where' Y 'represents output. reportDate-announcement date thscode-flush code secName-security abbreviation ctime-release time reportTitle-announcement title pdfURL-announcement link seq-unique label

Parameter setting table (param):

fieldfield namefield descriptionomitted logic
modeExtract by block or extract by codemode: allAStock mode: allBond mode: allFund mode: allHKStockThe default is extract by code mode
begincTimeRelease Start TimeLimit release start timenot limited
endcTimeRelease DeadlineLimit publication deadlinenot limited
beginrDateAnnouncement Start DateLimited announcement start datenot limited
endrDateAnnouncement End DateLimit announcement end datenot limited
beginseqStart SEQLimit Start SEQnot limited
endseqClosing seqlimit cutoff seqnot limited
keywordtitle keywordsqualified by title keywordnot limited
reporttypeannouncement typeIt can be generated according to performance report, IPO announcement, additional issuance announcement, etc. There are too many types, and it is recommended to use super command.not limited

Output:

fieldfield namefield description
errorcodeerror IDCode error code, errorcode=0 indicates that the code is running normally. If it is other, you need to find the cause of the error
errmsgerror messageIf errorcode returns non-zero, a specific error message is returned here.
indicatorsindex informationReturn all metrics information
datatypepointer formatReturns the metric format of the acquired data
perfprocessing timeTotal Time to Return Request Command (ms)
dataVoldata sizeReturns the amount of data consumed by the current command
timetimeReturns a list of times when data values were taken
thscodeSubject informationReturn all subject codes
datastructural bodyThe returned content includes data content in specific formats such as dataframe, json, list, table, array, etc.

Examples:

python
THS_ReportQuery('300033.SZ','beginrDate:2024-01-18;endrDate:2025-01-18;reportType:901','reportDate:Y,thscode:Y,secName:Y,ctime:Y,reportTitle:Y,pdfURL:Y,seq:Y')
matlab
[data,errorcode,errmsg,dataVol,datatype,perf]=THS_ReportQuery('300033.SZ','beginrDate:2024-01-18;endrDate:2025-01-18;reportType:901','reportDate:Y,thscode:Y,secName:Y,ctime:Y,reportTitle:Y,pdfURL:Y,seq:Y','format:table')
r
THS_ReportQuery('300033.SZ','beginrDate:2024-01-18;endrDate:2025-01-18;reportType:901','reportDate:Y,thscode:Y,secName:Y,ctime:Y,reportTitle:Y,pdfURL:Y,seq:Y',TRUE)
vba
THS_ReportQuery("300033.SZ","beginrDate:2024-01-18;endrDate:2025-01-18;reportType:901","reportDate:Y,thscode:Y,secName:Y,ctime:Y,reportTitle:Y,pdfURL:Y,seq:Y")
csharp
THS_ReportQuery("300033.SZ","beginrDate:2024-01-18;endrDate:2025-01-18;reportType:901","reportDate:Y,thscode:Y,secName:Y,ctime:Y,reportTitle:Y,pdfURL:Y,seq:Y")
c++
THS_ReportQuery("300033.SZ","beginrDate:2024-01-18;endrDate:2025-01-18;reportType:901","reportDate:Y,thscode:Y,secName:Y,ctime:Y,reportTitle:Y,pdfURL:Y,seq:Y")
java
THS_ReportQuery("300033.SZ","beginrDate:2024-01-18;endrDate:2025-01-18;reportType:901","reportDate:Y,thscode:Y,secName:Y,ctime:Y,reportTitle:Y,pdfURL:Y,seq:Y")
http
requestMethod:POST
requestURL:https://quantapi.51ifind.com/api/v1/report_query
requestHeaders:{"Content-Type":"application/json","access_token":"","ifindlang":"cn"}
formData:{"codes":"300033.SZ","functionpara":{"reportType":"901"},"beginrDate":"2024-01-18","endrDate":"2025-01-18","outputpara":"reportDate:Y,thscode:Y,secName:Y,ctime:Y,reportTitle:Y,pdfURL:Y,seq:Y"}

Shape Prediction: THS_Special_ShapePredict

python
THS_Special_ShapePredict(thscode, param, begintime, endtime)

According to the security code and parameters required by the user, the stock with high matching degree with the stock selected by the user is returned.

Parameters:

parametername of parameterparameter typeparametric description
thscodesearch contentcharacter stringStraight flush codes connected by commas, supporting multiple codes, such as: '600004.SH,300330.SZ'
paramparametercharacter stringOutput settings that are half-angle comma concatenated, and single-item settings are assigned colons. You can set the matching market range, matching degree, matching period and prediction period, etc. See parameter correspondence table for parameters of each setting
begintimestart datecharacter stringTime format is Y-MM-DD, e.g.'2016-05-23'
endtimeexpiration datecharacter stringTime format is Y-MM-DD, e.g.'2016-05-23'

Output:

fieldfield namefield description
errorcodeerror IDCode error code, errorcode=0 indicates that the code is running normally. If it is other, you need to find the cause of the error
errmsgerror messageIf errorcode returns non-zero, a specific error message is returned here.
tablesstructural bodyReturn content includes ID, time, etc.
datatypepointer formatReturns the metric format of the acquired data
inputParamsinput parametersReturns the parameters entered
perfprocessing timeTotal Time to Return Request Command (ms)
dataVoldata sizeReturns the amount of data consumed by the current command

Examples:

python
THS_Special_ShapePredict('600000.SH','range=SHSE_A_stock;SZSE_A_stock;SHSE_B_stock,match_level=90.0,match_period=20,predict_period=35','2019-07-19','2019-12-01')

Looking for stocks similar to 60000.SH in Shanghai A shares, Shenzhen A shares and Shanghai B shares, the starting date and deadline for prediction are 2019-07-19 and 2019-07-19 respectively. 2019-12-01。The screening criteria are matching degree 90 and above, matching period 20 and prediction period 35.

python
THS_Special_StockLink(thscode, param)

By commodity name of futures, get all the information about stocks related to that commodity.

Parameters:

parametername of parameterparameter typeparametric description
thscodefutures varietiescharacter stringChinese name of futures variety
paramparametercharacter stringIndicator parameters for semicolon concatenation

Output:

fieldfield namefield description
errorcodeerror IDCode error code, errorcode=0 indicates that the code is running normally. If it is other, you need to find the cause of the error
errmsgerror messageIf errorcode returns non-zero, a specific error message is returned here.
tablesstructural bodyReturn content includes ID, time, etc.
datatypepointer formatReturns the metric format of the acquired data
inputParamsinput parametersReturns the parameters entered
perfprocessing timeTotal Time to Return Request Command (ms)
dataVoldata sizeReturns the amount of data consumed by the current command

Examples:

python
THS_Special_StockLink('商品焦炭','thscode;thsname')

Returns the flush code and stock abbreviation corresponding to the commodity coke.

Fund Real-Time Valuation: THS_realTimeValuation

python
THS_realTimeValuation(thscode, param, output)

Returns the latest real-time valuation data for a given fund or all real-time valuations for the day.

Parameters:

parametername of parameterparameter typeparametric description
thscodefund varietiescharacter stringRequests for updated estimates are unlimited. The number of funds cannot exceed 500 when requesting historical estimates for all minutes of the day
paraminput parameterscharacter stringIndicator parameters for semicolon concatenation, such as 'onlyLast:0; initiTime:2020-08-10 09:15:00;endTime:2020-08-10 15:15:00'
outputoutput settingcharacter stringComma concatenation, used to control whether a column output, each set to column name and "Y" or "N" separated by a colon assignment. For example,'changeRatioValuation:Y,realTimeValuation:Y,Deviation 30TDays: Y', where' Y 'indicates output.

Output:

fieldfield namefield description
errorcodeerror IDCode error code, errorcode=0 indicates that the code is running normally. If it is other, you need to find the cause of the error
errmsgerror messageIf errorcode returns non-zero, a specific error message is returned here.
indicatorsindex informationReturn all metrics information
datatypepointer formatReturns the metric format of the acquired data
perfprocessing timeTotal Time to Return Request Command (ms)
dataVoldata sizeReturns the amount of data consumed by the current command
timetimeReturns a list of times when data values were taken
thscodeSubject informationReturn all subject codes
datastructural bodyThe returned content includes data content in specific formats such as dataframe, json, list, table, array, etc.
python
THS_realTimeValuation('512880.SH','onlyLastest:0;beginTime:2024-12-06 09:15:00;endTime:2024-12-06 15:15:00','realTimeValuation:Y')
matlab
[data,errorcode,time,indicators,thscode,errmsg,dataVol,datatype,perf]=THS_realTimeValuation('512880.SH','onlyLastest:0;beginTime:2024-12-06 09:15:00;endTime:2024-12-06 15:15:00','realTimeValuation:Y','format:table')
r
THS_realTimeValuation('512880.SH','onlyLastest:0;beginTime:2024-12-06 09:15:00;endTime:2024-12-06 15:15:00','realTimeValuation:Y',TRUE)
vba
'THS_realTimeValuation("512880.SH","onlyLastest:0;beginTime:2024-12-06 09:15:00;endTime:2024-12-06 15:15:00","realTimeValuation:Y")
csharp
THS_realTimeValuation("512880.SH","onlyLastest:0;beginTime:2024-12-06 09:15:00;endTime:2024-12-06 15:15:00","realTimeValuation:Y")
c++
THS_realTimeValuation("512880.SH","onlyLastest:0;beginTime:2024-12-06 09:15:00;endTime:2024-12-06 15:15:00","realTimeValuation:Y")
java
THS_realTimeValuation("512880.SH","onlyLastest:0;beginTime:2024-12-06 09:15:00;endTime:2024-12-06 15:15:00","realTimeValuation:Y")
http
requestMethod:POST
requestURL:https://quantapi.51ifind.com/api/v1/fund_valuation
requestHeaders:{"Content-Type":"application/json","access_token":"","ifindlang":"cn"}
formData:{"codes":"512880.SH","functionpara":{"onlyLastest":"0","beginTime":"2024-12-06 09:15:00","endTime":"2024-12-06 15:15:00"},"outputpara":"realTimeValuation:Y"}

Get real-time fund valuation of 512880.SH (Securities ETF) on December 06, 2024.

Performance Function

Data Statistics: THS_DataStatistics

python
THS_DataStatistics()

Data statistics function does not need input parameters, in the interface language environment directly using THS_DataStatistics() function can be directly queried Use statistics to the corresponding data volume.

Output:

fieldfield namefield description
error IDerrorcodeThe return code runs an error code, errorcode=0 indicates that the code runs normally. If it is other, you need to find the cause of the error
error messageerrmsgIf errorcode returns non-zero, a specific error message is returned here.
structural bodytablesThe returned content includes thscode, time, table (specific data content), etc.
pointer formatdatatypeReturns the metric format of the acquired data
input parametersinputParamsReturns the parameters entered
processing timeperfTotal Time to Return Request Command (ms)
data sizedataVolReturns the amount of data consumed by the current command

Examples:

python
THS_DataStatistics()

Obtain statistics of high frequency data, basic data and EDB data volume of this account.

Date Query: THS_DateQuery

python
THS_DateQuery(exchange, parameters, startDate, endDate)

This command is a function used to obtain the trading calendar of the exchange based on the entered start date and end date.

Parameters:

parameterdescribe
exchangeExchange English abbreviation, can only be a single input. For example 'SSE'.
parametersParameters can be default parameters or customized according to the description. Parameters and parameters are separated by commas (','), and parameter assignments are colons ('😂. For example 'dateType:0,period:D,dateFormat: 0'.
startDateStart time, time format is Y-MM-DD, for example 2015-06-23.
endDateDeadline time, time format Y-MM-DD, for example 2016-06-23.

Description of parameters: (parameters)

Exchange (required):
parameterparameter valuesparameter typeparametric description
exchangeSSEcharacter stringShanghai Stock Exchange
exchangeSZSEcharacter stringShenzhen Stock Exchange
exchangeHKEXcharacter stringHong Kong Exchanges and Clearing Limited
exchangeYJZHQcharacter stringinterbank bond market
exchangeNYSEARCAcharacter stringNYSE Arca
exchangeNASDAQcharacter stringNASDAQ Stock Exchange
exchangeNYSEcharacter stringthe New York Stock Exchange
exchangeAMEXcharacter stringAmerican Stock Exchange
exchangeCZCEcharacter stringZhengzhou Commodity Exchange
exchangeSHFEcharacter stringShanghai Futures Exchange
exchangeDCEcharacter stringDalian Commodity Exchange
exchangeBMDcharacter stringMalaysian Derivatives Exchange
exchangeNYBOTcharacter stringNew York Futures Exchange
exchangeCOMEXcharacter stringNew York Mercantile Exchange
exchangeNYMEXcharacter stringNew York Mercantile Exchange
exchangeCBOTcharacter stringChicago Mercantile Exchange
exchangeICEcharacter stringIntercontinental Exchange
python
Example:"SSE"
Date Type (optional):
parameterparameter valuesparameter typeparametric description
dateType0plastictrading day
dateType1plasticcalendar days
python
Example:"dateType:0",Default dateType: 0
Time period (optional):
parameterparameter valuesparameter typeparametric description
periodDcharacter stringday
periodWcharacter stringweek
periodMcharacter stringmonth
periodQcharacter stringseason
periodScharacter stringhalf a year
periodYcharacter stringyear
python
Example:"period:D", Default period: D
Date output format (optional):
parameterparameter valuesparameter typeparametric description
dateFormat0plasticYYYY-MM-DD
dateFormat1plasticYYYY/MM/DD
dateFormat2plasticYYYYMMDD
python
Example:"dateFormat:0",Default dateFormat: 0
Start date (required):
parameterparameter valuesparameter typeparametric description
StartDate\character stringStart date of date series
python
Example:'2024-12-01'
Deadline (required):
parameterparameter valuesparameter typeparametric description
EndDate\character stringDeadline date of date series. If blank, default to current date of system.
python
Example:'2024-12-06'

Output:

fieldfield namefield description
error IDerrorcodeThe return code runs an error code, errorcode=0 indicates that the code runs normally. If it is other, you need to find the cause of the error
error messageerrmsgIf errorcode returns non-zero, a specific error message is returned here.
structural bodytablesThe returned content includes thscode, time, table (specific data content), etc.
pointer formatdatatypeReturns the metric format of the acquired data
input parametersinputParamsReturns the parameters entered
processing timeperfTotal Time to Return Request Command (ms)
data sizedataVolReturns the amount of data consumed by the current command

Examples:

python
THS_DateQuery('SSE','dateType:0,period:D,dateFormat:0','2019-06-01','2019-06-06')

Date Offset: THS_DateOffset

python
THS_DateOffset(exchange, parameters, startDate, endDate)

This command is used to obtain the date function of the corresponding set parameter according to the input date and offset.

Parameters:

parameterdescribe
exchangeThe English short name of the exchange can only be entered individually. For example 'SSE'.
parametersParameters can be default parameters or customized according to the description. Parameters and parameters are separated by commas (','), and parameter assignments are colons ('😂. For example 'dateType:0,period:D,dateFormat: 0'.
startDateStart time, time format is Y-MM-DD, for example 2015 - 06 - 23.
endDateDeadline time, time format Y-MM-DD, for example 2016-06-23.

Description of parameters: (parameters)

Exchange (required):
parameterparameter valuesparameter typeparametric description
exchangeSSEcharacter stringShanghai Stock Exchange
exchangeSZSEcharacter stringShenzhen Stock Exchange
exchangeHKEXcharacter stringHong Kong Exchanges and Clearing Limited
exchangeYJZHQcharacter stringinterbank bond market
exchangeNYSEARCAcharacter stringNYSE Arca
exchangeNASDAQcharacter stringNASDAQ Stock Exchange
exchangeNYSEcharacter stringthe New York Stock Exchange
exchangeAMEXcharacter stringAmerican Stock Exchange
exchangeCZCEcharacter stringZhengzhou Commodity Exchange
exchangeSHFEcharacter stringShanghai Futures Exchange
exchangeDCEcharacter stringDalian Commodity Exchange
exchangeBMDcharacter stringMalaysian Derivatives Exchange
exchangeNYBOTcharacter stringNew York Futures Exchange
exchangeCOMEXcharacter stringNew York Mercantile Exchange
exchangeNYMEXcharacter stringNew York Mercantile Exchange
exchangeCBOTcharacter stringChicago Mercantile Exchange
exchangeICEcharacter stringIntercontinental Exchange
python
Example:"SSE"
Date Type (optional):
parameterparameter valuesparameter typeparametric description
dateType0plastictrading day
dateType1plasticcalendar days
python
Example:"dateType:0",Default dateType: 0
Offset (optional):
parameterparameter valuesparameter typeparametric description
offset\plasticThe value entered is the offset days, positive for forward offset, negative for backward offset
python
Example:"offset:1",Default offset: 1
Time period (optional):
parameterparameter valuesparameter typeparametric description
periodDcharacter stringday
periodWcharacter stringweek
periodMcharacter stringmonth
periodQcharacter stringseason
periodScharacter stringhalf a year
periodYcharacter stringyear
python
Example:"period:D",Default period: D
Date output format (optional):
parameterparameter valuesparameter typeparametric description
dateFormat0plasticYYYY-MM-DD
dateFormat1plasticYYYY/MM/DD
dateFormat2plasticYYYYMMDD
python
Example:"dateFormat:0",Default dateFormat: 0
Reference date (required):
parameterparameter valuesparameter typeparametric description
sdate\character stringReference date, default system current date
python
Example:"2019-01-01"

Output:

fieldfield namefield description
error IDerrorcodeThe return code runs an error code, errorcode=0 indicates that the code runs normally. If it is other, you need to find the cause of the error
error messageerrmsgIf errorcode returns non-zero, a specific error message is returned here.
structural bodytablesThe returned content includes thscode, time, table (specific data content), etc.
pointer formatdatatypeReturns the metric format of the acquired data
input parametersinputParamsReturns the parameters entered
processing timeperfTotal Time to Return Request Command (ms)
data sizedataVolReturns the amount of data consumed by the current command

Examples:

python
THS_DateOffset('SSE','dateType:0,period:D,offset:-5,dateFormat:0','2019-06-06')

Get the date sequence of all trading days pushed forward 5 days before June 6,2019 on Shanghai Stock Exchange.