This repository has been archived on 2026-01-07. You can view files and clone it, but cannot push or open issues or pull requests.
Files
resources/stockapp/sample/get_history_kline.py

19 lines
939 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data, page_req_key = quote_ctx.request_history_kline('HK.00700', autype=AuType.NONE, start='2021-10-03', end='2021-11-08', max_count=50) # 每页5个请求第一页
if ret == RET_OK:
print(data)
print(data['code'][0]) # 取第一条的股票代码
print(data['close'].values.tolist()) # 第一页收盘价转为 list
else:
print('error:', data)
while page_req_key != None: # 请求后面的所有结果
print('*************************************')
ret, data, page_req_key = quote_ctx.request_history_kline('HK.00700', start='2024-04-11', end='2024-06-18', max_count=50, page_req_key=page_req_key) # 请求翻页后的数据
if ret == RET_OK:
print(data)
else:
print('error:', data)
print('All pages are finished!')
quote_ctx.close() # 结束后记得关闭当条连接,防止连接条数用尽