How does Tongdaxin transaction dll interface realize programmatic transactions?

Nowadays, many traders choose between quantitative investment and traditional stock trading, and they often choose automated trading and quantitative trading. After all, many trading software that can be developed now have quantitative characteristics and can grasp more in time. Profit opportunities, such as the commonly used Datongdaxin trading dll interface is an example. Through the Tongdaxin interface to transmit your own trading strategy, you can modify your own dll in the interface to call to realize programmatic transactions. Then, specifically, it is How?

Specifically:

Put the three files MetaTrade.dll, MetaTrade.lic, and MetaTrade.ini in 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

If the Tongdaxin transaction dll interface wants to automatically entrust orders through a piece of code, it needs the stock api transaction interface , and uses the various parameter functions of the interface to automatically place orders:

name

Features

basic function

Heat

API initialization

Deinit

API deinitialization

Logon

Login to trading account

logoff

Log out of trading account

QueryData

Query various transaction data

QueryHistoryData

Query various historical data

SendOrder

Order

CancelOrder

Order Cancellation

GetQuote

Get five quotes

Repay

Margin and securities lending account direct repayment

GetExpireDate

Query API authorization expiration date

Single Account Batch Function

QueryDatas

Single-account batch query of various transaction data

SendOrders

Single account batch order

CancelOrders

Single account batch cancellation

GetQuotes

Get five quotes in batches for a single account

Multi-account batch function

QueryMultiAccountsDatas

Multi-account batch query of various transaction data

SendMultiAccountsOrders

Batch orders for multiple accounts

CancelMultiAccountsOrders

Batch Cancellation of Multiple Accounts

GetMultiAccountsQuotes

Get five quotes in batches for multiple accounts

Code example:

import requests;
import time;
import json;
import pandas as pd; 
def fenshishuju_dfcf(daima);

//Here we need to define an array to distinguish them, make the printing results more detailed, realize the real-time data captured by the stock trading interface in detail, and print them out accurately;
    if daima[:2] == "sh" :
        lsbl = '1.'+daima[2:]
    else:
        lsbl = '0.' + daima[2:]
    wangzhi = "http://push2his.eastmoney.com/api/qt/stock/trends2/get? &fields1=f1%2Cf2%2Cf3%2Cf4%2Cf5%2Cf6%2Cf7%2Cf8%2Cf9" \
              "%2Cf10%2Cf11%2Cf12%2Cf13&fields2=f51%2Cf52%2Cf53%2Cf54%2Cf55%2Cf56%2Cf57%2Cfut58&
              " =7eea3edcaed734bea9cbfc24409ed989&ndays=1&iscr=0&secid="+lsbl+ \
              "&_=1643253749790"+str(time.time)
    resp = requests.get(wangzhi, timeout=6)
    # print (resp)

#Print the status code of the request result
    data = json.loads(resp.text)
    shuju = {'date and time': [], 'latest price': [], 'average price': [], 'turnover': [ ]}
    for k in data['data']['trends']:
        lsbl = k.split(",")
        shuju['date and time'].append(lsbl[0])
        shuju['latest price']. append(lsbl[2])
        shuju['average price'].append(lsbl[-1])
        shuju['turnover'].append(lsbl[-2])
        
    shuju = pd.DataFrame(shuju)
    print(shuju )
    return shuju
 
if __name__ == '__main__':
    while 1:
        fenshishuju_dfcf('sh603102')
        time.sleep(3)

return{
}

Position data display:

Therefore, the parameter function invoked by Tongdaxin trading dll interface can accurately execute the trader's quantitative strategy, timely customize the entrustment and place an order, and realize programmatic trading.

Supongo que te gusta

Origin blog.csdn.net/Q_121463726/article/details/127983482
Recomendado
Clasificación