Crack Tongdaxin interface method (2)

In Python, the list comprehension of the Tongdaxin interface is a concise syntax that can quickly generate a new list. The basic syntax of a list comprehension is as follows:

Copy Code Copy Code Copy Code [expressionforiteminiterableifcondition]

Among them, expression represents an expression to generate each element in a new list; item represents each element in an iterable object; iterable represents an iterable object, such as a list, tuple, string, etc.; condition represents an optional condition , only elements that satisfy the condition will be added to the new list.

Here are some examples of using list comprehensions to mine the stock data interface:

# Generate a list of square numbers from 1 to 10 squares = [x**2 for x in range(1, 11)] print(squares) # Generate a list of strings with length greater than 3 words = [" apple", "banana", "orange", "pear"] long_words = [word for word in words if len(word) > 3] print(long_words)
However, after the quantitative transaction interface query data, the default is non-empty , if nullable is allowed, use the field type declaration of Nullable(Int32). For example, set the amount and volume to Int64 to prevent data from exceeding the range. In addition, ENGINE is a table engine, and MergeTree is used by default. ReplacingMergeTree is used here to prevent duplicate values. At the same time, it should also be noted that ORDER BY means sorting some data. For example, the stock code and date are sorted here. The columns of ORDER BY will also be set as indexes by the data interface function. Quickly enter your own strategy through the search function to execute automatic trade. Example of implementation documentation: MetaTradeAPI (metatradeapi) - Gitee.com

Example of usage process:

 

Put the three files MetaTrade.dll, MetaTrade.lic, and MetaTrade.ini into the same directory as the application

    1. Call LoadLibrary to load MetaTrade.dll instance
    2. Call GetProcAddress to get the API function address
    3. Call the Init interface for API initialization
    4. Call the Logon interface to log in to the brokerage account and obtain the corresponding ClientId. One application instance can log in to multiple accounts at the same time
    5. Call other API interfaces through ClientId to query or place an order
    6. Call the Logoff interface to log out of the brokerage account
    7. Call the Deinit interface to clean up the API
    8. Call FreeLibrary to unload MetaTrade.dll instance

Note: The API has the function of automatic disconnection and reconnection, and the application only needs to perform simple error handling. Other interfaces except Init/Deinit/Logon are thread-safe.

Guess you like

Origin blog.csdn.net/Q_121463726/article/details/132334877