pytdx call real-time market

pytdx is a Python library that can be used to call Tongdaxin's real-time quotes. To use pytdx, you need to install Tongdaxin software, and you need to put the program folders of pytdx and Tongdaxin in the same directory.

To call pytdx to get real-time quotes, you first need to import the pytdx library and create a TdxHq_API object. Then you can use the get_security_quotes function to get real-time quotes.

For example, the following code can be used to obtain the real-time quotes of a certain stock in the Shanghai and Shenzhen stock markets:

import pytdx

api = pytdx.TdxHq_API()

# 连接通达信程序
api.connect()

# 获取股票代码为 000001 的股票的实时行情
quotes = api.get_security_quotes([(0, '000001')])

# 断开与通达信程序的连接
api.disconnect()

print(quotes)

The parameter of the get_security_quotes function is a list of two-tuples, the first element of the two-tuple represents the stock market (0 represents the Shanghai stock market, 1 represents the Shenzhen stock market), and the second element represents the stock code. The function returns a list of dictionaries, which contain the real-time market information of the stock.

おすすめ

転載: blog.csdn.net/weixin_35756690/article/details/128871736