Tongdaxin is a commonly used stock quote software query and order system, which can be called and interacted through the API interface. The following are the general steps for using the Tongdaxin interface to call the API:
1. Obtain the stock trading interface API: First, you need to obtain Tongdaxin's API interface documents and related development tools from Tongdaxin's official or other legal channels. The API interface of Tongdaxin mainly includes the market interface and the transaction interface.
related functions |
call result |
Deinit logoff |
none |
Init |
The return value is the number of transaction accounts that are successfully authorized When the return value is < 1, there is no need to call the Deinit interface, nor can you call other interfaces, otherwise an error will occur! |
Logon |
The call is successful: the return value is the client ID Call failed: return value <= 0 |
The parameter ErrorInfo saves the error information and needs to allocate 256 bytes of space |
|
GetExpireDate |
The return value is the API authorization expiration date |
2. Development environment configuration: According to the stock trading interface API interface document, configure the development environment, including installing Tongdaxin interface software, configuring API connection parameters, installing related development tools and dependent libraries, etc.
Yybid |
Business department code, generally 0 |
|
Account |
Login account, usually the fund account or customer number of the brokerage Note: Liangrong account needs to add an additional .C ending, such as 123456 becomes 123456.C |
|
TradeAccount |
The trading account is generally the same as the login account, but there is no need to add an additional .C ending You can log in to the brokerage software to view the list of shareholders, and the capital account in the list of shareholders is the trading account |
|
JyPassword |
transaction password |
|
TxPassword |
Communication password, usually an empty string or the same as the transaction password |
|
ErrorInfo |
Error message, need to allocate 256 bytes of space |
|
return value |
Successful call: Client Id Call failed: return <= 0 |
3. Connect to the market quotation server: connect to Tongdaxin's quotation server through the API interface to obtain real-time market quotation data. During the connection process, correct login information and authentication parameters need to be provided.
4. Subscribe to market data: Use the functions or methods provided by the API interface to subscribe to specific market data, such as real-time stock market data, time-sharing charts, K-line data, etc., as needed. Flexible subscription and filtering can be done according to individual needs.
5. Data processing and analysis: After receiving market data, data processing and analysis can be performed as needed. You can use the API interface functions provided by Tongdaxin to perform data analysis, calculate indicators, draw graphics and other operations.
6. Call the transaction interface: If you need to perform transaction operations, you can use Tongdaxin's transaction interface. Through the API interface, functions such as placing orders, canceling orders, and querying account information can be realized.
sign |
void QueryData(int |
ClientId, int Category, |
char* Result, char* |
ErrorInfo); |
|
Function |
Query various transaction data |
||||
parameter |
ClientId |
Client ID |
|||
Category |
Query Information Category 0: Funds, 1: Shares, 2: Order of the day, 3: Transaction of the day, 4: Cancellation order, 5: Shareholder code, 6: Financing balance, 7: Securities lending balance, 8: Marginable securities, 9: Different securities companies, 10-11: None, 12: Inquiry about new shares that can be subscribed, 13: Inquiry about the quota of new shares, 14: Matching Number Query, 15: Winning Lottery Query |
||||
Result |
Query results, need to allocate 1024*1024 bytes of space Please refer to [Result format] for the format |
||||
ErrorInfo |
Error message, need to allocate 256 bytes of space |
||||
return value |
None, whether the query is successful or not is judged by whether ErrorInfo is an empty string |
sign |
void QueryDatas(int ClientId, int Category[], int Count, char* Result[], char* ErrorInfo[]); |
|
Function |
Batch query various transaction data for a single account, distinguish each query by subscript |
|
parameter |
ClientId |
Client ID |
Category[] |
Query information category array, please refer to [Query Information Category] for specific meaning |
|
Count |
The number of query items, that is, the length of the array |
|
Result[] |
Query result array, each result needs to allocate 1024*1024 bytes of space Please refer to [Result format] for the format |
|
ErrorInfo[] |
Error message array, each error message needs to allocate 256 bytes of space |
|
return value |
None, whether the i-th query is successful or not is judged by whether ErrorInfo[i] is an empty string |
7. Error handling and exception handling: When using the API interface, it is necessary to handle possible errors or exceptions, such as network disconnection, login failure, transaction failure, etc. The error code and error information provided by the API interface can be used for corresponding processing.
It should be noted that the call of the Tongdaxin interface needs to comply with relevant regulations and restrictions, such as authorization authentication, permission restrictions, call frequency restrictions, etc. When developing and using, be sure to comply with relevant regulations and agreements.