Skip to content

Commit

Permalink
Update Version 3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
shinny-pack authored and shinny-mayanqiong committed Dec 31, 2021
1 parent 949f170 commit b766b45
Show file tree
Hide file tree
Showing 36 changed files with 2,833 additions and 119 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.1.1
Version: 3.2.0
Summary: TianQin SDK
Home-page: https://www.shinnytech.com/tqsdk
Author: TianQin
Expand Down
11 changes: 6 additions & 5 deletions doc/advanced/for_vnpy_user.rst
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,15 @@ TqSdk针对行情数据和交易信息都采用相同的 wait_update/is_changing

图形界面
-------------------------------------------------
TqSdk 本身并不包含任何图形界面. 这部分功能由天勤软件提供支持:
TqSdk 提供 :ref:`web_gui` 来供有图形化需求的用户使用:

* 策略运行时, 提供交易记录/日志的监控表格. 交易记录和持仓记录自动在行情图上标记, 可以快速定位跳转, 可以跨周期缩放定位
* 策略回测时, 提供回测报告/图上标记.
* 策略运行时, 交易记录和持仓记录自动在行情图上标记, 可以快速定位跳转, 可以跨周期缩放定位
* 策略回测时, 提供回测报告/图上标记和对应的回测分析报告.
* 策略运行和回测信息自动保存, 可事后随时查阅显示

TqSdk配合天勤使用时, 还支持自定义绘制行情图表, 像这样::
TqSdk配合web_gui使用时, 还支持自定义绘制行情图表, 像这样::

api = TqApi(auth=TqAuth("信易账户","账户密码"), web_gui=True)
# 获取 cu1905 和 cu1906 的日线数据
klines = api.get_kline_serial("SHFE.cu1905", 86400)
klines2 = api.get_kline_serial("SHFE.cu1906", 86400)
Expand Down Expand Up @@ -263,7 +264,7 @@ TqSdk配合天勤使用时, 还支持自定义绘制行情图表, 像这样::
-------------------------------------------------
此外, 还有一些差别值得注意

* TqSdk 要求 Python 3.6 以上版本, 不支持 Python 2.x
* TqSdk 要求 Python 3.6.4 以上版本, 不支持 Python 2.x
* TqSdk 使用了Python3的async框架, 某些 IDE 不支持, 需要使用支持 async 的IDE, 例如 pycharm

要学习使用 TqSdk, 推荐从 :ref:`quickstart` 开始
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.1.1'
version = u'3.2.0'
# The full version, including alpha/beta/rc tags.
release = u'3.1.1'
release = u'3.2.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
13 changes: 11 additions & 2 deletions doc/reference/tqsdk.sim.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
.. _tqsdk.sim:

tqsdk.sim - 本地模拟交易
tqsdk.tqsim - 本地模拟交易
------------------------------------------------------------------
.. automodule:: tqsdk.tradeable.sim.tqsim
.. autoclass:: tqsdk.tradeable.sim.tqsim.TqSim
:members:
:inherited-members:


.. _tqsdk.sim_stock:

tqsdk.tqsim_stock - 本地股票模拟交易
------------------------------------------------------------------
.. autoclass:: tqsdk.tradeable.sim.tqsim_stock.TqSimStock
:members:
:inherited-members:
8 changes: 8 additions & 0 deletions doc/version.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

版本变更
=============================
3.2.0 (2021/12/31)

* 新增::py:class:`~tqsdk.tradeable.sim.tqsim_stock.TqSimStock` 类实现本地股票模拟交易,同时支持在实盘/回测模式下使用。
**专业版用户** 可用,专业版购买网址:https://account.shinnytech.com。
* web_gui:修复回测时不能正常显示结果报告的问题
* 修复:windows 下调用 :py:meth:`~tqsdk.api.TqApi.get_kline_data_series` 时,可能出现缓存文件不允许重复重命的问题


3.1.1 (2021/12/24)

* 修复:穿管采集文件读取失败
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.1.1",
version="3.2.0",
description='TianQin SDK',
author='TianQin',
author_email='[email protected]',
Expand Down
2 changes: 1 addition & 1 deletion tqsdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
name = "tqsdk"

from tqsdk.api import TqApi
from tqsdk.tradeable import TqAccount, TqKq, TqKqStock, TqSim
from tqsdk.tradeable import TqAccount, TqKq, TqKqStock, TqSim, TqSimStock
from tqsdk.auth import TqAuth
from tqsdk.channel import TqChan
from tqsdk.backtest import TqBacktest, TqReplay
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.1.1'
__version__ = '3.2.0'
17 changes: 11 additions & 6 deletions tqsdk/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
from tqsdk.risk_rule import TqRiskRule
from tqsdk.ins_schema import ins_schema, basic, derivative, future, option
from tqsdk.symbols import TqSymbols
from tqsdk.tradeable import TqAccount, TqKq, TqKqStock, TqSim, BaseOtg
from tqsdk.tradeable import TqAccount, TqKq, TqKqStock, TqSim, TqSimStock, BaseOtg
from tqsdk.trading_status import TqTradingStatus
from tqsdk.tqwebhelper import TqWebHelper
from tqsdk.utils import _generate_uuid, _query_for_quote, BlockManagerUnconsolidated, _quotes_add_night, _bisect_value
Expand All @@ -94,8 +94,9 @@ class TqApi(TqBaseApi):
通常情况下, 一个线程中 **应该只有一个** TqApi的实例, 它负责维护网络连接, 接收行情及账户数据, 并在内存中维护业务数据截面
"""

def __init__(self, account: Union[TqMultiAccount, TqAccount, TqKq, TqKqStock, TqSim, None] = None, auth: Union[TqAuth, str, None] = None, url: Optional[str] = None,
backtest: Union[TqBacktest, TqReplay, None] = None, web_gui: [bool, str] = False, debug: Union[bool, str, None] = False,
def __init__(self, account: Union[TqMultiAccount, TqAccount, TqKq, TqKqStock, TqSim, TqSimStock, None] = None,
auth: Union[TqAuth, str, None] = None, url: Optional[str] = None,
backtest: Union[TqBacktest, TqReplay, None] = None, web_gui: Union[bool, str] = False, debug: Union[bool, str, None] = False,
loop: Optional[asyncio.AbstractEventLoop] = None, disable_print: bool = False, _stock: bool = True,
_ins_url=None, _md_url=None, _td_url=None) -> None:
"""
Expand Down Expand Up @@ -1028,7 +1029,7 @@ def get_trading_calendar(self, start_dt: Union[date, datetime], end_dt: Union[da
first_date, latest_date = _init_chinese_rest_days()
if start_dt < first_date or end_dt > latest_date:
raise Exception(f"交易日历可以处理的范围为 {first_date.strftime('%Y-%m-%d')}{latest_date.strftime('%Y-%m-%d')},请修改参数")
return _get_trading_calendar(start_dt, end_dt)
return _get_trading_calendar(start_dt, end_dt, headers=self._base_headers)

# ----------------------------------------------------------------------
def query_his_cont_quotes(self, symbol: Union[str, List[str]], n: int = 200):
Expand Down Expand Up @@ -1081,7 +1082,8 @@ def query_his_cont_quotes(self, symbol: Union[str, List[str]], n: int = 200):
now_dt = self._get_current_datetime()
trading_day = _get_trading_day_from_timestamp(int(now_dt.timestamp() * 1000000000))
end_dt = datetime.fromtimestamp(trading_day / 1000000000)
cont_calendar = TqContCalendar(start_dt=end_dt - timedelta(days=n * 2 + 30), end_dt=end_dt, symbols=symbols)
cont_calendar = TqContCalendar(start_dt=end_dt - timedelta(days=n * 2 + 30), end_dt=end_dt, symbols=symbols,
headers=self._base_headers)
df = cont_calendar.df.loc[cont_calendar.df.date.le(end_dt), ['date'] + symbols]
df = df.iloc[-n:]
df.reset_index(inplace=True, drop=True)
Expand Down Expand Up @@ -3124,7 +3126,10 @@ def _setup_connection(self):
self._auth._add_account(acc._account_id)
elif isinstance(acc, TqKqStock):
if not self._auth._has_account(acc._account_id):
raise Exception(f"您的账户不支持快期股票模拟,需要购买专业版本后使用。升级网址:https://account.shinnytech.com")
raise Exception(f"您的账户不支持快期股票模拟 TqKqStock,需要购买专业版本后使用。升级网址:https://account.shinnytech.com")
elif isinstance(acc, TqSimStock):
if not self._auth._has_feature("sec"):
raise Exception(f"您的账户不支持本地股票模拟 TqSimStock,需要购买专业版本后使用。升级网址:https://account.shinnytech.com")

# 等待复盘服务器启动
if isinstance(self._backtest, TqReplay):
Expand Down
7 changes: 7 additions & 0 deletions tqsdk/backtest/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!usr/bin/env python3
# -*- coding:utf-8 -*-

__author__ = 'mayanqiong'

from tqsdk.backtest.backtest import TqBacktest
from tqsdk.backtest.replay import TqReplay
Loading

0 comments on commit b766b45

Please sign in to comment.