Skip to content

Commit

Permalink
Update Version 3.7.3
Browse files Browse the repository at this point in the history
  • Loading branch information
shinny-hongyan authored and shinny-chenli committed Sep 23, 2024
1 parent a24d884 commit fac614c
Show file tree
Hide file tree
Showing 18 changed files with 215 additions and 72 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.7.2
Version: 3.7.3
Summary: TianQin SDK
Home-page: https://www.shinnytech.com/tqsdk
Author: TianQin
Expand Down
17 changes: 7 additions & 10 deletions doc/advanced/for_vnpy_user.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ TqSdk 则使用基于网络协作的组件设计. 如下图:
* 交易相关接口被大幅度简化, 不再需要处理CTP接口的复杂回调, 也不需要发起任何查询请求


也有一些不如vn.py方便的地方:

* 由于交易指令经交易网关转发, 用户无法直接指定CTP服务器地址. 用户如果需要连接到官方交易网关不支持的期货公司, 需要自行部署交易网关.
对于需要直连期货公司交易的用户, TqSdk 也提供了 :py:meth:`~tqsdk.TqCtp` 模块支持用户直连


每个策略是一个单独运行的py文件
Expand Down Expand Up @@ -260,13 +258,12 @@ TqSdk配合web_gui使用时, 还支持自定义绘制行情图表, 像这样::
关于策略回测的详细说明, 请见 :ref:`backtest`


其它区别
-------------------------------------------------
此外, 还有一些差别值得注意

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

推荐学习步骤
-------------------------------
要学习使用 TqSdk, 推荐从 :ref:`quickstart` 开始
使用过程中有任何问题可以 `询问天勤 AI 助手! <https://udify.app/chat/im02prcHNEOVbPAx/>`_ ,尝试帮助解答用户以下问题:

* 具体函数的详细介绍
* 根据具体需求或策略提供天勤实现的示例
* 天勤或 Python 报错的可能解决方案

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.7.2'
version = u'3.7.3'
# The full version, including alpha/beta/rc tags.
release = u'3.7.2'
release = u'3.7.3'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
67 changes: 19 additions & 48 deletions doc/enterprise.rst
Original file line number Diff line number Diff line change
@@ -1,74 +1,45 @@
.. _enterprise:

TqSdk2 企业版
TqSdk 企业版
=================================================
除了 TqSdk 专业版以外,我们还提供 TqSdk2 企业版本来供用户使用,如果想了解专业版和企业版的区别,`可以点击查看 TqSdk2 文档 <https://doc.shinnytech.com/tqsdk2/latest/advanced/for_tqsdk1_user.html#tqsdk2-tqsdk>`_
除了 TqSdk 专业版以外,我们还提供 TqSdk 企业版本

如果想使用 TqSdk2 企业版功能,可以点击 `个人中心 <https://account.shinnytech.com/>`_ 申请15天试用或购买
企业版和专业版相比的主要区别是柜台支持上的区别,企业版支持直连 CTP/融航/杰宜斯等柜台,专业版只能通过中继的方式去进行连接

企业版本提供专业版的全部功能 :ref:`profession` ,且 TqSdk 和 TqSdk2 专业版权限通用,此外还包含如下功能
如果想使用 TqSdk 企业版功能,可以点击 `个人中心 <https://account.shinnytech.com/>`_ 申请15天试用或购买

TqSdk2 直连功能

TqSdk 直连功能
-------------------------------------------------
TqSdk2 中除了通过中继模式接入期货公司以外,还提供用户通过直连模式接入任意一家指定期货公司
TqSdk 企业版支持用户通过直连模式接入任意一家指定期货公司

除了接入指定期货公司的优点以外,直连模式还带来了一下好处:

* 交易指令直达期货公司,省去中继服务器路径,交易延迟平均减少10ms左右
* 减少了交易服务器依赖,程序运行稳定性提升

TqSdk 直连CTP模式的详细介绍,请点击 :py:class:`~tqsdk.TqCtp`

.. _tqjees:

TqSdk2 连接资管平台功能
-------------------------------------------------
TqSdk2 提供了资管平台的对接支持,支持用户连接到指定资管平台

以连接杰宜斯的模拟服务器为例::

from tqsdk2 import TqApi, TqAuth, TqJees

acc = TqJees(td_url="tcp://129.211.138.170:10001", broker_id="JeesDemo", app_id="shinny_tqsdk_01", auth_code= "0000000000000000", user_name="杰宜斯模拟账户", password="杰宜斯模拟账户密码")
api = TqApi(acc,auth= TqAuth("快期账户","账户密码"))

其中杰宜斯的 **模拟账户** 和 **模拟账户密码** 需要自行和杰宜斯联系获取,其他参数在杰宜斯模拟下为

td_url="tcp://39.101.174.218:40205"

broker_id="JeesDemo"

app_id="shinny_tqsdk_01"

auth_code="0000000000000000"

杰宜斯实盘情况下将对应信息换成实盘信息即可

资管平台连接模式的详细介绍,请点击 :py:class:`~tqsdk2.api.TqJees` .


.. _tqrohon:
.. _tqjees:

TqSdk2 连接资管平台功能
TqSdk 连接平台功能
-------------------------------------------------
TqSdk2 提供了资管平台的对接支持,支持用户连接到指定资管平台

以连接融航的模拟服务器为例::

from tqsdk2 import TqApi, TqAuth, TqRohon
TqSdk 提供了资管平台的对接支持,支持用户连接到指定资管平台,例如杰宜斯或者融航资管系统等

acc = TqRohon(td_url="tcp://129.211.138.170:10001", broker_id="RohonDemo", app_id="shinny_tqsdk_01", auth_code= "qZWmA7iTXaEO2w40", user_name="融航模拟账户", password="融航模拟账户密码")
api = TqApi(acc,auth= TqAuth("快期账户","账户密码"))
以连融航的模拟服务器为例::

其中融航模拟的 **模拟账户** 和 **模拟账户密码** 需要自行和融航联系获取,其他参数在融航模拟下为
from tqsdk import TqApi, TqRohon, TqAuth

td_url="tcp://129.211.138.170:10001"
account = TqRohon(account_id="融航账户", password="融航密码", front_broker="融航柜台代码", front_url="融航柜台地址", app_id="融航 AppID", auth_code="融航 AuthCode")
api = TqApi(account, auth=TqAuth("快期账户", "账户密码"))

broker_id="RohonDemo"
其中融航的 **模拟账户** 、 **模拟账户密码** 、 **app_id** 和 **auth_code** 需要自行和融航联系获取,其他参数在融航模拟下为

app_id="shinny_tqsdk_01"
front_url="tcp://129.211.138.170:10001"

auth_code="qZWmA7iTXaEO2w40"
front_broker="RohonDemo"

融航实盘情况下将对应信息换成实盘信息即可

资管平台连接模式的详细介绍,请点击 :py:class:`~tqsdk2.api.TqRohon` .
融航资管平台连接模式的详细介绍,请点击 :py:class:`~tqsdk.TqRohon`
2 changes: 2 additions & 0 deletions doc/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ TqSdk 模块参考
tqsdk.tqzq.rst
tqsdk.tqctp.rst
tqsdk.tqrohon.rst
tqsdk.tqjees.rst
tqsdk.tqyida.rst
tqsdk.sim.rst
tqsdk.multiaccount.rst
tqsdk.objs.rst
Expand Down
7 changes: 7 additions & 0 deletions doc/reference/tqsdk.tqjees.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.. _tqsdk.tqjees:

tqsdk.TqJees - 杰宜斯资管交易类
------------------------------------------------------------------
.. autoclass:: tqsdk.TqJees
:members:
:inherited-members:
7 changes: 7 additions & 0 deletions doc/reference/tqsdk.tqyida.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.. _tqsdk.tqyida:

tqsdk.TqYida - 易达交易类
------------------------------------------------------------------
.. autoclass:: tqsdk.TqYida
:members:
:inherited-members:
2 changes: 1 addition & 1 deletion doc/tqsdk_llm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* 根据具体需求或策略提供天勤实现的示例
* 天勤或 Python 报错的可能解决方案

点击即刻尝试 `使用智能机器人<https://udify.app/chat/im02prcHNEOVbPAx/>`_
点击即刻尝试 `使用天勤 AI 助手<https://udify.app/chat/im02prcHNEOVbPAx/>`_

下图是具体的使用示例 demo

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

版本变更
=============================
3.7.3 (2024/09/20)

* 新增::py:class:`~tqsdk.TqJees` 账户类型,支持杰宜斯资管柜台
* 新增::py:class:`~tqsdk.TqYida` 账户类型,支持易达交易柜台


3.7.2 (2024/09/12)

* 新增::py:class:`~tqsdk.TqRohon` 账户类型,支持融航资管柜台
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setuptools.setup(
name='tqsdk',
version="3.7.2",
version="3.7.3",
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, TqZq, TqKq, TqKqStock, TqSim, TqSimStock, TqCtp, TqRohon
from tqsdk.tradeable import TqAccount, TqZq, TqKq, TqKqStock, TqSim, TqSimStock, TqCtp, TqRohon, TqJees, TqYida
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.7.2'
__version__ = '3.7.3'
11 changes: 8 additions & 3 deletions tqsdk/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,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, TqZq, TqKq, TqKqStock, TqSim, TqSimStock, BaseSim, BaseOtg, TqCtp, TqRohon
from tqsdk.tradeable import TqAccount, TqZq, TqKq, TqKqStock, TqSim, TqSimStock, BaseSim, BaseOtg, TqCtp, TqRohon, TqJees, TqYida
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 @@ -82,7 +82,7 @@
from .__version__ import __version__


UnionTradeable = Union[TqAccount, TqKq, TqZq, TqKqStock, TqSim, TqSimStock, TqCtp, TqRohon]
UnionTradeable = Union[TqAccount, TqKq, TqZq, TqKqStock, TqSim, TqSimStock, TqCtp, TqRohon, TqJees, TqYida]


class TqApi(TqBaseApi):
Expand Down Expand Up @@ -121,8 +121,13 @@ def __init__(self, account: Optional[Union[TqMultiAccount, UnionTradeable]] = No
* :py:class:`~tqsdk.TqRohon` : 使用融航资管账号
* :py:class:`~tqsdk.TqJees` : 使用杰宜斯资管账号
* :py:class:`~tqsdk.TqYida` : 使用易达账号
* :py:class:`~tqsdk.TqMultiAccount` : 多账户列表,列表中支持 :py:class:`~tqsdk.TqAccount`、:py:class:`~tqsdk.TqKq`、:py:class:`~tqsdk.TqKqStock`、\
:py:class:`~tqsdk.TqSim`、:py:class:`~tqsdk.TqSimStock`、:py:class:`~tqsdk.TqZq`、:py:class:`~tqsdk.TqRohon` 和 :py:class:`~tqsdk.TqCtp` 中的 0 至 N 个或者组合
:py:class:`~tqsdk.TqSim`、:py:class:`~tqsdk.TqSimStock`、:py:class:`~tqsdk.TqZq`、:py:class:`~tqsdk.TqRohon`、:py:class:`~tqsdk.TqJees`、\
:py:class:`~tqsdk.TqYida` 和 :py:class:`~tqsdk.TqCtp` 中的 0 至 N 个或者组合
auth (TqAuth/str): [必填]用户快期账户:
* :py:class:`~tqsdk.TqAuth` : 添加快期账户类,例如:TqAuth("[email protected]", "123456")
Expand Down
6 changes: 3 additions & 3 deletions tqsdk/multiaccount.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from shinny_structlog import ShinnyLoggerAdapter

from tqsdk.channel import TqChan
from tqsdk.tradeable import TqAccount, TqKq, TqKqStock, TqSim, TqSimStock, BaseSim, TqZq, TqCtp, TqRohon
from tqsdk.tradeable import TqAccount, TqKq, TqKqStock, TqSim, TqSimStock, BaseSim, TqZq, TqCtp, TqRohon, TqJees, TqYida
from tqsdk.tradeable.mixin import StockMixin


Expand All @@ -27,12 +27,12 @@ class TqMultiAccount(object):
"""

def __init__(self, accounts: Optional[List[Union[TqAccount, TqKq, TqZq, TqKqStock, TqSim, TqSimStock, TqZq, TqCtp, TqRohon]]] = None):
def __init__(self, accounts: Optional[List[Union[TqAccount, TqKq, TqZq, TqKqStock, TqSim, TqSimStock, TqZq, TqCtp, TqRohon, TqJees, TqYida]]] = None):
"""
创建 TqMultiAccount 实例
Args:
accounts (List[Union[TqAccount, TqKq, TqKqStock, TqSim, TqSimStock, TqZq, TqCtp, TqRohon]]): [可选] 多账户列表, 若未指定任何账户, 则为 [TqSim()]
accounts (List[Union[TqAccount, TqKq, TqKqStock, TqSim, TqSimStock, TqZq, TqCtp, TqRohon, TqJees, TqYida]]): [可选] 多账户列表, 若未指定任何账户, 则为 [TqSim()]
Example1::
Expand Down
2 changes: 1 addition & 1 deletion tqsdk/tradeable/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@


from tqsdk.tradeable.otg.base_otg import BaseOtg
from tqsdk.tradeable.otg import TqAccount, TqZq, TqKq, TqKqStock, TqCtp, TqRohon
from tqsdk.tradeable.otg import TqAccount, TqZq, TqKq, TqKqStock, TqCtp, TqRohon, TqJees, TqYida
from tqsdk.tradeable.sim.basesim import BaseSim
from tqsdk.tradeable.sim import TqSim, TqSimStock
2 changes: 2 additions & 0 deletions tqsdk/tradeable/otg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@
from tqsdk.tradeable.otg.tqkq import TqKq, TqKqStock
from tqsdk.tradeable.otg.tqctp import TqCtp
from tqsdk.tradeable.otg.tqrohon import TqRohon
from tqsdk.tradeable.otg.tqjees import TqJees
from tqsdk.tradeable.otg.tqyida import TqYida
75 changes: 75 additions & 0 deletions tqsdk/tradeable/otg/tqjees.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!usr/bin/env python3
# -*- coding:utf-8 -*-
__author__ = 'chenli'

import hashlib

from tqsdk.tradeable.otg.base_otg import BaseOtg
from tqsdk.tradeable.mixin import FutureMixin


class TqJees(BaseOtg, FutureMixin):
"""杰宜斯资管账户类"""

def __init__(self, account_id: str, password: str, front_broker: str, front_url: str, app_id: str, auth_code: str) -> None:
"""
创建杰宜斯资管账户实例
Args:
account_id (str): 帐号
password (str): 密码
front_broker (str): 杰宜斯柜台代码
front_url (str): 杰宜斯柜台地址
app_id (str): 杰宜斯 AppID
auth_code (str): 杰宜斯 AuthCode
Example1::
from tqsdk import TqApi, TqJees
account = TqJees(account_id="杰宜斯账户", password="杰宜斯密码", front_broker="杰宜斯柜台代码", front_url="杰宜斯柜台地址", app_id="杰宜斯 AppID", auth_code="杰宜斯 AuthCode")
api = TqApi(account, auth=TqAuth("快期账户", "账户密码"))
注意:
1. 使用 TqJees 账户需要安装 tqsdk_zq_otg 包: pip install -U tqsdk_zq_otg
2. front_broker, front_url, app_id 和 auth_code 信息需要向杰宜斯申请程序化外接后取得
"""
self._account_id = account_id
self._front_broker = front_broker
self._front_url = front_url
self._app_id = app_id
self._auth_code = auth_code
super(TqJees, self).__init__(broker_id="", account_id=account_id, password=password, td_url="zqotg://127.0.0.1:0/trade")

@property
def _account_auth(self):
return {
"feature": "tq_direct",
"account_id": self._account_id,
"auto_add": True,
}

def _get_account_key(self):
s = self._broker_id + self._account_id
s += self._front_broker if self._front_broker else ""
s += self._front_url if self._front_url else ""
return hashlib.md5(s.encode('utf-8')).hexdigest()

async def _send_login_pack(self):
req = {
"aid": "req_login",
"bid": "tqsdk_zq_otg",
"user_name": self._account_id,
"password": self._password,
"broker_id": self._front_broker,
"front": self._front_url,
"app_id": self._app_id,
"auth_code": self._auth_code,
"backend": "jees"
}
await self._td_send_chan.send(req)
Loading

0 comments on commit fac614c

Please sign in to comment.