Skip to content

Commit

Permalink
Update Version 3.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
shinny-pack authored and shinny-mayanqiong committed Dec 8, 2021
1 parent 474aadc commit 9830c30
Show file tree
Hide file tree
Showing 27 changed files with 235 additions and 163 deletions.
2 changes: 1 addition & 1 deletion PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: tqsdk
Version: 3.0.1
Version: 3.0.2
Summary: TianQin SDK
Home-page: https://www.shinnytech.com/tqsdk
Author: TianQin
Expand Down
4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
# built documents.
#
# The short X.Y version.
version = u'3.0.1'
version = u'3.0.2'
# The full version, including alpha/beta/rc tags.
release = u'3.0.1'
release = u'3.0.2'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
22 changes: 22 additions & 0 deletions doc/profession.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,28 @@ TqSdk 提供了 :py:class:`~tqsdk.account.TqKqStock` 方法供用户来进行股

需要注意股票模拟交易下,get_account,get_order,get_position 会返回对应股票交易模型下的 objs ,如 :py:class:`~tqsdk.objs.SecurityAccount`, :py:class:`~tqsdk.objs.SecurityOrder`,:py:class:`~tqsdk.objs.SecurityPosition`

参考代码如下::

from tqsdk import TqApi, TqAuth, TqKqStock

tq_kq_stock = TqKqStock()
api = TqApi(account=tq_kq_stock, auth=TqAuth("信易账户", "账户密码"))
quote = api.get_quote("SSE.688529")
print(quote)
# 下单限价单
order = api.insert_order("SSE.688529", volume=200, direction="BUY", limit_price=quote.ask_price1)
while order.status == 'ALIVE':
api.wait_update()
print(order) # 打印委托单信息

print(api.get_account()) # 打印快期股票模拟账户信息

print(api.get_position("SSE.688529")) # 打印持仓信息

for trade in order.trade_records.values():
print(trade) # 打印委托单对应的成交信息
api.close()


下载数据功能
-------------------------------------------------
Expand Down
10 changes: 5 additions & 5 deletions doc/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@

api = TqApi(auth=TqAuth("信易账户", "账户密码"))

获得上期所 ni2010 合约的行情引用::
获得上期所 ni2206 合约的行情引用::

quote = api.get_quote("SHFE.ni2010")
quote = api.get_quote("SHFE.ni2206")

现在, 我们获得了一个对象 quote. 这个对象总是指向 SHFE.ni2010 合约的最新行情. 我们可以通过 quote 的各个字段访问行情数据::
现在, 我们获得了一个对象 quote. 这个对象总是指向 SHFE.ni2206 合约的最新行情. 我们可以通过 quote 的各个字段访问行情数据::

print (quote.last_price, quote.volume)

Expand Down Expand Up @@ -93,9 +93,9 @@

使用K线数据
-------------------------------------------------
你很可能会需要合约的K线数据. 在TqSdk中, 你可以很方便的获得K线数据. 我们来请求 ni2010 合约的10秒线::
你很可能会需要合约的K线数据. 在TqSdk中, 你可以很方便的获得K线数据. 我们来请求 ni2206 合约的10秒线::

klines = api.get_kline_serial("SHFE.ni2010", 10)
klines = api.get_kline_serial("SHFE.ni2206", 10)

klines是一个pandas.DataFrame对象. 跟 api.get_quote() 一样, api.get_kline_serial() 也是返回K线序列的引用对象. K线序列数据也会跟实时行情一起同步自动更新. 你也同样需要用 api.wait_update() 等待数据刷新.

Expand Down
9 changes: 9 additions & 0 deletions doc/version.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

版本变更
=============================
3.0.2 (2021/12/07)

* 修复:调用 :py:meth:`~tqsdk.api.TqApi.get_kline_serial` 接口获取股票前复权 Kline 时,复权计算结果可能出错的问题
* 新增:节假日表添加 2022 年节假日信息
* 新增:支持在 python 3.10 下使用 TqApi
* web_gui:支持多账户下使用
* docs:更新示例合约代码


3.0.1 (2021/11/26)

* 修复:调用 :py:meth:`~tqsdk.api.TqApi.query_symbol_info`,当参数中包含主连/指数合约会报错的问题
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def get_tag(self):

setuptools.setup(
name='tqsdk',
version="3.0.1",
version="3.0.2",
description='TianQin SDK',
author='TianQin',
author_email='[email protected]',
Expand Down
2 changes: 1 addition & 1 deletion tqsdk/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '3.0.1'
__version__ = '3.0.2'
8 changes: 5 additions & 3 deletions tqsdk/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def __init__(self, account: Union[TqMultiAccount, TqAccount, TqSim, None] = None
while self._data.get("mdhis_more_data", True) or trade_more_data:
if not self.wait_update(deadline=deadline): # 等待连接成功并收取截面数据
raise TqTimeoutError("接收数据超时,请检查客户端及网络是否正常")
trade_more_data = self._account._get_trade_more_data_and_order_id(self, self._data)
trade_more_data = self._account._get_trade_more_data_and_order_id(self._data)
except:
self.close()
raise
Expand Down Expand Up @@ -3157,7 +3157,7 @@ def _setup_connection(self):

self._ws_md_recv_chan = ws_md_recv_chan # 记录 ws_md_recv_chan 引用

conn = TqConnect(md_logger)
conn = TqConnect(md_logger, conn_id="md")
self.create_task(conn._run(self, self._md_url, ws_md_send_chan, ws_md_recv_chan))

md_handler_logger = ShinnyLoggerAdapter(self._logger.getChild("MdReconnect"), url=self._md_url)
Expand Down Expand Up @@ -3288,6 +3288,7 @@ def _init_serial(self, root_list, width, default, adj_type):
"array": np.array(array, order="F"),
"init": False, # 是否初始化完成. 完成状态: 订阅K线后已获取所有主、副合约的数据并填满df序列.
"adj_type": adj_type,
"calc_ids_F": [], # 前复权已经计算过的id,每个 id 只计算一次
"update_row": 0, # 起始更新数据行
"all_attr": set(columns) | {"symbol" + str(i) for i in range(1, len(root_list))} | {"symbol", "duration"},
"extra_array": {},
Expand Down Expand Up @@ -3364,7 +3365,8 @@ def _update_serial_single(self, serial):
item = item.copy()
for c in cols:
item[c] = item[c] * self._dividend_cache[symbol]["back_factor"]
elif serial["adj_type"] == "F" and factor != 1.0:
elif serial["adj_type"] == "F" and factor != 1.0 and i not in serial['calc_ids_F']:
serial['calc_ids_F'].append(i)
for c in cols:
col_index = keys.index(c) + 2
array[:i, col_index] = array[:i, col_index] * factor
Expand Down
5 changes: 3 additions & 2 deletions tqsdk/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
import pandas as pd


# 2003-01-01 ~ 2021-12-31 节假日,不包含周末
CHINESE_REST_DAYS = ['2003-01-01', '2003-01-30', '2003-01-31', '2003-02-03', '2003-02-04', '2003-02-05', '2003-02-06', '2003-02-07', '2003-05-01', '2003-05-02', '2003-05-05', '2003-05-06', '2003-05-07', '2003-10-01', '2003-10-02', '2003-10-03', '2003-10-06', '2003-10-07', '2004-01-01', '2004-01-19', '2004-01-20', '2004-01-21', '2004-01-22', '2004-01-23', '2004-01-26', '2004-01-27', '2004-01-28', '2004-05-03', '2004-05-04', '2004-05-05', '2004-05-06', '2004-05-07', '2004-10-01', '2004-10-04', '2004-10-05', '2004-10-06', '2004-10-07', '2005-01-03', '2005-02-07', '2005-02-08', '2005-02-09', '2005-02-10', '2005-02-11', '2005-02-14', '2005-02-15', '2005-05-02', '2005-05-03', '2005-05-04', '2005-05-05', '2005-05-06', '2005-10-03', '2005-10-04', '2005-10-05', '2005-10-06', '2005-10-07', '2006-01-02', '2006-01-03', '2006-01-30', '2006-01-31', '2006-02-01', '2006-02-02', '2006-02-03', '2006-05-01', '2006-05-02', '2006-05-03', '2006-05-04', '2006-05-05', '2006-10-02', '2006-10-03', '2006-10-04', '2006-10-05', '2006-10-06', '2007-01-01', '2007-01-02', '2007-01-03', '2007-02-19', '2007-02-20', '2007-02-21', '2007-02-22', '2007-02-23', '2007-05-01', '2007-05-02', '2007-05-03', '2007-05-04', '2007-05-07', '2007-10-01', '2007-10-02', '2007-10-03', '2007-10-04', '2007-10-05', '2007-12-31', '2008-01-01', '2008-02-06', '2008-02-07', '2008-02-08', '2008-02-11', '2008-02-12', '2008-04-04', '2008-05-01', '2008-05-02', '2008-06-09', '2008-09-15', '2008-09-29', '2008-09-30', '2008-10-01', '2008-10-02', '2008-10-03', '2009-01-01', '2009-01-02', '2009-01-26', '2009-01-27', '2009-01-28', '2009-01-29', '2009-01-30', '2009-04-06', '2009-05-01', '2009-05-28', '2009-05-29', '2009-10-01', '2009-10-02', '2009-10-05', '2009-10-06', '2009-10-07', '2009-10-08', '2010-01-01', '2010-02-15', '2010-02-16', '2010-02-17', '2010-02-18', '2010-02-19', '2010-04-05', '2010-05-03', '2010-06-14', '2010-06-15', '2010-06-16', '2010-09-22', '2010-09-23', '2010-09-24', '2010-10-01', '2010-10-04', '2010-10-05', '2010-10-06', '2010-10-07', '2011-01-03', '2011-02-02', '2011-02-03', '2011-02-04', '2011-02-07', '2011-02-08', '2011-04-04', '2011-04-05', '2011-05-02', '2011-06-06', '2011-09-12', '2011-10-03', '2011-10-04', '2011-10-05', '2011-10-06', '2011-10-07', '2012-01-02', '2012-01-03', '2012-01-23', '2012-01-24', '2012-01-25', '2012-01-26', '2012-01-27', '2012-04-02', '2012-04-03', '2012-04-04', '2012-04-30', '2012-05-01', '2012-06-22', '2012-10-01', '2012-10-02', '2012-10-03', '2012-10-04', '2012-10-05', '2013-01-01', '2013-01-02', '2013-01-03', '2013-02-11', '2013-02-12', '2013-02-13', '2013-02-14', '2013-02-15', '2013-04-04', '2013-04-05', '2013-04-29', '2013-04-30', '2013-05-01', '2013-06-10', '2013-06-11', '2013-06-12', '2013-09-19', '2013-09-20', '2013-10-01', '2013-10-02', '2013-10-03', '2013-10-04', '2013-10-07', '2014-01-01', '2014-01-31', '2014-02-03', '2014-02-04', '2014-02-05', '2014-02-06', '2014-04-07', '2014-05-01', '2014-05-02', '2014-06-02', '2014-09-08', '2014-10-01', '2014-10-02', '2014-10-03', '2014-10-06', '2014-10-07', '2015-01-01', '2015-01-02', '2015-02-18', '2015-02-19', '2015-02-20', '2015-02-23', '2015-02-24', '2015-04-06', '2015-05-01', '2015-06-22', '2015-09-03', '2015-09-04', '2015-10-01', '2015-10-02', '2015-10-05', '2015-10-06', '2015-10-07', '2016-01-01', '2016-02-08', '2016-02-09', '2016-02-10', '2016-02-11', '2016-02-12', '2016-04-04', '2016-05-02', '2016-06-09', '2016-06-10', '2016-09-15', '2016-09-16', '2016-10-03', '2016-10-04', '2016-10-05', '2016-10-06', '2016-10-07', '2017-01-02', '2017-01-27', '2017-01-30', '2017-01-31', '2017-02-01', '2017-02-02', '2017-04-03', '2017-04-04', '2017-05-01', '2017-05-29', '2017-05-30', '2017-10-02', '2017-10-03', '2017-10-04', '2017-10-05', '2017-10-06', '2018-01-01', '2018-02-15', '2018-02-16', '2018-02-19', '2018-02-20', '2018-02-21', '2018-04-05', '2018-04-06', '2018-04-30', '2018-05-01', '2018-06-18', '2018-09-24', '2018-10-01', '2018-10-02', '2018-10-03', '2018-10-04', '2018-10-05', '2018-12-31', '2019-01-01', '2019-02-04', '2019-02-05', '2019-02-06', '2019-02-07', '2019-02-08', '2019-04-05', '2019-05-01', '2019-05-02', '2019-05-03', '2019-06-07', '2019-09-13', '2019-10-01', '2019-10-02', '2019-10-03', '2019-10-04', '2019-10-07', '2020-01-01', '2020-01-24', '2020-01-27', '2020-01-28', '2020-01-29', '2020-01-30', '2020-01-31', '2020-04-06', '2020-05-01', '2020-05-04', '2020-05-05', '2020-06-25', '2020-06-26', '2020-10-01', '2020-10-02', '2020-10-05', '2020-10-06', '2020-10-07', '2020-10-08', '2021-01-01', '2021-02-11', '2021-02-12', '2021-02-15', '2021-02-16', '2021-02-17', '2021-04-05', '2021-05-03', '2021-05-04', '2021-05-05', '2021-06-14', '2021-09-20', '2021-09-21', '2021-10-01', '2021-10-04', '2021-10-05', '2021-10-06', '2021-10-07']
# 2003-01-01 ~ 2022-12-31 节假日,不包含周末
CHINESE_REST_DAYS = ['2003-01-01', '2003-01-30', '2003-01-31', '2003-02-03', '2003-02-04', '2003-02-05', '2003-02-06', '2003-02-07', '2003-05-01', '2003-05-02', '2003-05-05', '2003-05-06', '2003-05-07', '2003-10-01', '2003-10-02', '2003-10-03', '2003-10-06', '2003-10-07', '2004-01-01', '2004-01-19', '2004-01-20', '2004-01-21', '2004-01-22', '2004-01-23', '2004-01-26', '2004-01-27', '2004-01-28', '2004-05-03', '2004-05-04', '2004-05-05', '2004-05-06', '2004-05-07', '2004-10-01', '2004-10-04', '2004-10-05', '2004-10-06', '2004-10-07', '2005-01-03', '2005-02-07', '2005-02-08', '2005-02-09', '2005-02-10', '2005-02-11', '2005-02-14', '2005-02-15', '2005-05-02', '2005-05-03', '2005-05-04', '2005-05-05', '2005-05-06', '2005-10-03', '2005-10-04', '2005-10-05', '2005-10-06', '2005-10-07', '2006-01-02', '2006-01-03', '2006-01-30', '2006-01-31', '2006-02-01', '2006-02-02', '2006-02-03', '2006-05-01', '2006-05-02', '2006-05-03', '2006-05-04', '2006-05-05', '2006-10-02', '2006-10-03', '2006-10-04', '2006-10-05', '2006-10-06', '2007-01-01', '2007-01-02', '2007-01-03', '2007-02-19', '2007-02-20', '2007-02-21', '2007-02-22', '2007-02-23', '2007-05-01', '2007-05-02', '2007-05-03', '2007-05-04', '2007-05-07', '2007-10-01', '2007-10-02', '2007-10-03', '2007-10-04', '2007-10-05', '2007-12-31', '2008-01-01', '2008-02-06', '2008-02-07', '2008-02-08', '2008-02-11', '2008-02-12', '2008-04-04', '2008-05-01', '2008-05-02', '2008-06-09', '2008-09-15', '2008-09-29', '2008-09-30', '2008-10-01', '2008-10-02', '2008-10-03', '2009-01-01', '2009-01-02', '2009-01-26', '2009-01-27', '2009-01-28', '2009-01-29', '2009-01-30', '2009-04-06', '2009-05-01', '2009-05-28', '2009-05-29', '2009-10-01', '2009-10-02', '2009-10-05', '2009-10-06', '2009-10-07', '2009-10-08', '2010-01-01', '2010-02-15', '2010-02-16', '2010-02-17', '2010-02-18', '2010-02-19', '2010-04-05', '2010-05-03', '2010-06-14', '2010-06-15', '2010-06-16', '2010-09-22', '2010-09-23', '2010-09-24', '2010-10-01', '2010-10-04', '2010-10-05', '2010-10-06', '2010-10-07', '2011-01-03', '2011-02-02', '2011-02-03', '2011-02-04', '2011-02-07', '2011-02-08', '2011-04-04', '2011-04-05', '2011-05-02', '2011-06-06', '2011-09-12', '2011-10-03', '2011-10-04', '2011-10-05', '2011-10-06', '2011-10-07', '2012-01-02', '2012-01-03', '2012-01-23', '2012-01-24', '2012-01-25', '2012-01-26', '2012-01-27', '2012-04-02', '2012-04-03', '2012-04-04', '2012-04-30', '2012-05-01', '2012-06-22', '2012-10-01', '2012-10-02', '2012-10-03', '2012-10-04', '2012-10-05', '2013-01-01', '2013-01-02', '2013-01-03', '2013-02-11', '2013-02-12', '2013-02-13', '2013-02-14', '2013-02-15', '2013-04-04', '2013-04-05', '2013-04-29', '2013-04-30', '2013-05-01', '2013-06-10', '2013-06-11', '2013-06-12', '2013-09-19', '2013-09-20', '2013-10-01', '2013-10-02', '2013-10-03', '2013-10-04', '2013-10-07', '2014-01-01', '2014-01-31', '2014-02-03', '2014-02-04', '2014-02-05', '2014-02-06', '2014-04-07', '2014-05-01', '2014-05-02', '2014-06-02', '2014-09-08', '2014-10-01', '2014-10-02', '2014-10-03', '2014-10-06', '2014-10-07', '2015-01-01', '2015-01-02', '2015-02-18', '2015-02-19', '2015-02-20', '2015-02-23', '2015-02-24', '2015-04-06', '2015-05-01', '2015-06-22', '2015-09-03', '2015-09-04', '2015-10-01', '2015-10-02', '2015-10-05', '2015-10-06', '2015-10-07', '2016-01-01', '2016-02-08', '2016-02-09', '2016-02-10', '2016-02-11', '2016-02-12', '2016-04-04', '2016-05-02', '2016-06-09', '2016-06-10', '2016-09-15', '2016-09-16', '2016-10-03', '2016-10-04', '2016-10-05', '2016-10-06', '2016-10-07', '2017-01-02', '2017-01-27', '2017-01-30', '2017-01-31', '2017-02-01', '2017-02-02', '2017-04-03', '2017-04-04', '2017-05-01', '2017-05-29', '2017-05-30', '2017-10-02', '2017-10-03', '2017-10-04', '2017-10-05', '2017-10-06', '2018-01-01', '2018-02-15', '2018-02-16', '2018-02-19', '2018-02-20', '2018-02-21', '2018-04-05', '2018-04-06', '2018-04-30', '2018-05-01', '2018-06-18', '2018-09-24', '2018-10-01', '2018-10-02', '2018-10-03', '2018-10-04', '2018-10-05', '2018-12-31', '2019-01-01', '2019-02-04', '2019-02-05', '2019-02-06', '2019-02-07', '2019-02-08', '2019-04-05', '2019-05-01', '2019-05-02', '2019-05-03', '2019-06-07', '2019-09-13', '2019-10-01', '2019-10-02', '2019-10-03', '2019-10-04', '2019-10-07', '2020-01-01', '2020-01-24', '2020-01-27', '2020-01-28', '2020-01-29', '2020-01-30', '2020-01-31', '2020-04-06', '2020-05-01', '2020-05-04', '2020-05-05', '2020-06-25', '2020-06-26', '2020-10-01', '2020-10-02', '2020-10-05', '2020-10-06', '2020-10-07', '2020-10-08', '2021-01-01', '2021-02-11', '2021-02-12', '2021-02-15', '2021-02-16', '2021-02-17', '2021-04-05', '2021-05-03', '2021-05-04', '2021-05-05', '2021-06-14', '2021-09-20', '2021-09-21', '2021-10-01', '2021-10-04', '2021-10-05', '2021-10-06', '2021-10-07',
"2022-01-03", "2022-01-31", "2022-02-01", "2022-02-02", "2022-02-03", "2022-02-04", "2022-04-04", "2022-04-05", "2022-05-02", "2022-05-03", "2022-05-04", "2022-06-03", "2022-09-12", "2022-10-03", "2022-10-04", "2022-10-05", "2022-10-06", "2022-10-07"]
rest_days_df = pd.DataFrame(data={'date': pd.Series(pd.to_datetime(CHINESE_REST_DAYS, format='%Y-%m-%d'))})
rest_days_df['trading_restdays'] = False # 节假日为 False

Expand Down
4 changes: 3 additions & 1 deletion tqsdk/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
__author__ = 'yanqiong'

import asyncio
import sys
from logging import Logger
from typing import Any, TYPE_CHECKING, Union

Expand Down Expand Up @@ -42,7 +43,8 @@ def __init__(self, api: 'TqApi', last_only: bool = False, logger: Union[Logger,
elif isinstance(logger, ShinnyLoggerAdapter):
self._logger = logger.bind(chan_id=TqChan._chan_id, chan_name=chan_name)
TqChan._chan_id += 1
asyncio.Queue.__init__(self, loop=api._loop)
py_ver = sys.version_info
asyncio.Queue.__init__(self, loop=api._loop) if (py_ver.major == 3 and py_ver.minor < 10) else asyncio.Queue.__init__(self)
self._last_only = last_only
self._closed = False

Expand Down
15 changes: 12 additions & 3 deletions tqsdk/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@
import json
import random
import ssl
import sys
import time
import warnings
from abc import abstractmethod
from asyncio import Future
from datetime import datetime
from logging import Logger
from queue import Queue
from typing import Optional

import certifi
import websockets
from shinny_structlog import ShinnyLoggerAdapter

from tqsdk.diff import _merge_diff, _get_obj
from tqsdk.entity import Entity
Expand Down Expand Up @@ -90,11 +91,16 @@ async def read_message(self):
class TqConnect(object):
"""用于与 websockets 服务器通讯"""

def __init__(self, logger) -> None:
def __init__(self, logger, conn_id: Optional[str] = None) -> None:
"""
创建 TqConnect 实例
"""
self._conn_id = conn_id if conn_id else _generate_uuid()
self._logger = logger
if isinstance(logger, Logger):
self._logger = ShinnyLoggerAdapter(logger, conn_id=self._conn_id)
elif isinstance(logger, ShinnyLoggerAdapter):
self._logger = logger.bind(conn_id=self._conn_id)
self._first_connect = True
self._keywords = {"max_size": None}

Expand All @@ -121,6 +127,7 @@ async def _run(self, api, url, send_chan, recv_chan):
"type": "MESSAGE",
"level": "WARNING",
"code": 2019112910,
"conn_id": self._conn_id,
"content": f"开始与 {url} 的重新建立网络连接",
"url": url
}
Expand All @@ -140,6 +147,7 @@ async def _run(self, api, url, send_chan, recv_chan):
"type": "MESSAGE",
"level": "INFO",
"code": 2019112901,
"conn_id": self._conn_id,
"content": "与 %s 的网络连接已建立" % url,
"url": url
}
Expand Down Expand Up @@ -188,6 +196,7 @@ async def _run(self, api, url, send_chan, recv_chan):
"type": "MESSAGE",
"level": "WARNING",
"code": 2019112911,
"conn_id": self._conn_id,
"content": f"与 {url} 的网络连接断开,请检查客户端及网络是否正常",
"url": url
}
Expand Down
6 changes: 3 additions & 3 deletions tqsdk/demo/tutorial/t10.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

# 创建API实例,传入自己的信易账户
api = TqApi(auth=TqAuth("信易账户", "账户密码"))
# 获得上期所 ni2011 的行情引用,当行情有变化时 quote 中的字段会对应更新
quote = api.get_quote("SHFE.ni2011")
# 获得上期所 ni2206 的行情引用,当行情有变化时 quote 中的字段会对应更新
quote = api.get_quote("SHFE.ni2206")

# 输出 ni2011 的最新行情时间和最新价
# 输出 ni2206 的最新行情时间和最新价
print(quote.datetime, quote.last_price)

# 关闭api,释放资源
Expand Down
Loading

0 comments on commit 9830c30

Please sign in to comment.