Python调用pytdx的代码示例
安装pytdx
pip install pytdx
简单示范
from pytdx.hq import TdxHq_API api = TdxHq_API() # 数据获取接口一般返回list结构, with api.connect('119.147.212.81', 7709): # 返回普通list data = api.get_security_bars(9, 0, '000001', 0, 10) print(data)
输出结果
[OrderedDict([('open', 14.75), ('close', 14.8), ('high', 14.88), ('low', 14.52), ('vol', 1057659.0), ('amount', 1561368448.0), ('year', 2023), ('month', 1), ('day', 9), ('hour', 15), ('minute', 0), ('datetime', '2023-01-09 15:00')]), OrderedDict([('open', 14.76), ('close', 14.44), ('high', 14.89), ('low', 14.39), ('vol', 1269423.0), ('amount', 1851093760.0), ('year', 2023), ('month', 1), ('day', 10), ('hour', 15), ('minute', 0), ('datetime', '2023-01-10 15:00')]), OrderedDict([('open', 14.45), ('close', 14.67), ('high', 14.78), ('low', 14.39), ('vol', 830566.0), ('amount', 1217450752.0), ('year', 2023), ('month', 1), ('day', 11), ('hour', 15), ('minute', 0), ('datetime', '2023-01-11 15:00')]), OrderedDict([('open', 14.77), ('close', 14.67), ('high', 14.77), ('low', 14.53), ('vol', 625694.0), ('amount', 914367680.0), ('year', 2023), ('month', 1), ('day', 12), ('hour', 15), ('minute', 0), ('datetime', '2023-01-12 15:00')]), OrderedDict([('open', 14.67), ('close', 14.95), ('high', 14.95), ('low', 14.55), ('vol', 949085.0), ('amount', 1407181056.0), ('year', 2023), ('month', 1), ('day', 13), ('hour', 15), ('minute', 0), ('datetime', '2023-01-13 15:00')]), OrderedDict([('open', 14.95), ('close', 15.08), ('high', 15.28), ('low', 14.85), ('vol', 1560039.0), ('amount', 2356399872.0), ('year', 2023), ('month', 1), ('day', 16), ('hour', 15), ('minute', 0), ('datetime', '2023-01-16 15:00')]), OrderedDict([('open', 15.13), ('close', 14.97), ('high', 15.18), ('low', 14.77), ('vol', 935834.0), ('amount', 1396151552.0), ('year', 2023), ('month', 1), ('day', 17), ('hour', 15), ('minute', 0), ('datetime', '2023-01-17 15:00')]), OrderedDict([('open', 14.95), ('close', 15.11), ('high', 15.18), ('low', 14.91), ('vol', 718434.0), ('amount', 1083362944.0), ('year', 2023), ('month', 1), ('day', 18), ('hour', 15), ('minute', 0), ('datetime', '2023-01-18 15:00')]), OrderedDict([('open', 15.13), ('close', 15.09), ('high', 15.25), ('low', 14.87), ('vol', 641875.0), ('amount', 963744640.0), ('year', 2023), ('month', 1), ('day', 19), ('hour', 15), ('minute', 0), ('datetime', '2023-01-19 15:00')]), OrderedDict([('open', 15.16), ('close', 15.13), ('high', 15.24), ('low', 15.0), ('vol', 608590.0), ('amount', 920144832.0), ('year', 2023), ('month', 1), ('day', 20), ('hour', 15), ('minute', 0), ('datetime', '2023-01-20 15:00')])]
一、基本行情接口索引
1 : 获取股票行情
可以获取多只股票的行情信息
需要传入一个列表,每个列表由一个市场代码, 一个股票代码构成的元祖构成 [ (市场代码1, 股票代码1),(市场代码2, 股票代码2) … (市场代码n, 股票代码n) ]
api.get_security_quotes([(0, '000001'), (1, '600300')])
2 : 获取k线
K线种类: 0 5分钟K线 1 15分钟K线 2 30分钟K线 3 1小时K线 4 日K线 5 周K线 6 月K线 7 1分钟 81分钟K线 9 日K线 10 季K线 11 年K线
api.get_security_bars(9,0, '000001', 4, 3)
3 : 获取市场股票数量
api.get_security_count(0)
4 : 获取股票列表
api.get_security_list(1, 0)
5 : 获取指数k线
api.get_index_bars(9,1, '000001', 1, 2)
6 : 查询分时行情
api.get_minute_time_data(1, '600300')
7 : 查询历史分时行情
api.get_history_minute_time_data(TDXParams.MARKET_SH, '600300', 20161209)
8 : 查询分笔成交
api.get_transaction_data(TDXParams.MARKET_SZ, '000001', 0, 30)
9 : 查询历史分笔成交
api.get_history_transaction_data(TDXParams.MARKET_SZ, '000001', 0, 10, 20170209)
10 : 查询公司信息目录
api.get_company_info_category(TDXParams.MARKET_SZ, '000001')
11 : 读取公司信息详情
api.get_company_info_content(0, '000001', '000001.txt', 0, 100)
12 : 读取除权除息信息
api.get_xdxr_info(1, '600300')
13 : 读取财务信息
api.get_finance_info(0, '000001')
14 : 读取k线信息
get_k_data('000001','2017-07-03','2017-07-10')
15 :读取板块信息
api.get_and_parse_block_info(TDXParams.BLOCK_SZ)
二、扩展行情接口API
from pytdx.exhq import *
1: 获取市场代码
api.get_markets()
2: 查询代码列表
api.get_instrument_info(0, 100)
3: 查询市场中商品数量
api.get_instrument_count()
4: 查询五档行情
api.get_instrument_quote(47, "IF1709")
5: 查询分时行情
api.get_minute_time_data(47, "IF1709")
6: 查询历史分时行情
api.get_history_minute_time_data(31, "00020", 20170811)
7: 查询k线数据
api.get_instrument_bars(TDXParams.KLINE_TYPE_DAILY, 8, "10000843", 0, 100)
8: 查询分笔成交
api.get_transaction_data(31, "00020") api.get_history_transaction_data(47, "IFL0", 20170810, start=1800)
9: 查询历史分笔成交
api.get_history_transaction_data(31, "00020", 20170810)
关于Python调用pytdx的代码示例的文章就介绍至此,更多相关Python调用pytdx内容请搜索编程宝库以前的文章,希望以后支持编程宝库!
问题描述有些小伙伴在使用python做GUI界面的时候可能想添加这么一个小功能,就是在界面的某个角落动态的显示当前的时间,本文将介绍具体方法。 方式一(使用组件的after方法 ...