-
Notifications
You must be signed in to change notification settings - Fork 659
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ab4cf1
commit a24d884
Showing
16 changed files
with
121 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.. _tqsdk.tqrohon: | ||
|
||
tqsdk.TqRohon - 融航资管交易类 | ||
------------------------------------------------------------------ | ||
.. autoclass:: tqsdk.TqRohon | ||
:members: | ||
:inherited-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
|
||
setuptools.setup( | ||
name='tqsdk', | ||
version="3.7.1", | ||
version="3.7.2", | ||
description='TianQin SDK', | ||
author='TianQin', | ||
author_email='[email protected]', | ||
|
@@ -18,7 +18,7 @@ | |
packages=setuptools.find_packages(exclude=["tqsdk.test", "tqsdk.test.*"]), | ||
python_requires='>=3.6.4', | ||
install_requires=["websockets>=8.1", "requests", "numpy", "pandas>=1.1.0", "scipy", "simplejson", "aiohttp", | ||
"certifi", "pyjwt", "psutil", "shinny_structlog", "sgqlc", "filelock", "tqsdk_ctpse", "tqsdk_sm", "tqsdk_zq_otg==1.1.1"], | ||
"certifi", "pyjwt", "psutil", "shinny_structlog", "sgqlc", "filelock", "tqsdk_ctpse", "tqsdk_sm"], | ||
classifiers=[ | ||
"Programming Language :: Python :: 3", | ||
"License :: OSI Approved :: Apache Software License", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = '3.7.1' | ||
__version__ = '3.7.2' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
from tqsdk.tradeable import TqAccount, TqZq, TqKq, TqKqStock, TqSim, TqSimStock, BaseSim, BaseOtg, TqCtp, TqRohon | ||
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, \ | ||
|
@@ -82,7 +82,7 @@ | |
from .__version__ import __version__ | ||
|
||
|
||
UnionTradeable = Union[TqAccount, TqKq, TqZq, TqKqStock, TqSim, TqSimStock, TqCtp] | ||
UnionTradeable = Union[TqAccount, TqKq, TqZq, TqKqStock, TqSim, TqSimStock, TqCtp, TqRohon] | ||
|
||
|
||
class TqApi(TqBaseApi): | ||
|
@@ -119,8 +119,10 @@ def __init__(self, account: Optional[Union[TqMultiAccount, UnionTradeable]] = No | |
* :py:class:`~tqsdk.TqCtp` : 使用直连 CTP 账号 | ||
* :py:class:`~tqsdk.TqRohon` : 使用融航资管账号 | ||
* :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.TqCtp` 中的 0 至 N 个或者组合 | ||
:py:class:`~tqsdk.TqSim`、:py:class:`~tqsdk.TqSimStock`、:py:class:`~tqsdk.TqZq`、:py:class:`~tqsdk.TqRohon` 和 :py:class:`~tqsdk.TqCtp` 中的 0 至 N 个或者组合 | ||
auth (TqAuth/str): [必填]用户快期账户: | ||
* :py:class:`~tqsdk.TqAuth` : 添加快期账户类,例如:TqAuth("[email protected]", "123456") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 TqRohon(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, TqRohon | ||
account = TqRohon(account_id="融航账户", password="融航密码", front_broker="融航柜台代码", front_url="融航柜台地址", app_id="融航 AppID", auth_code="融航 AuthCode") | ||
api = TqApi(account, auth=TqAuth("快期账户", "账户密码")) | ||
注意: | ||
1. 使用 TqRohon 账户需要安装 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(TqRohon, 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": "rohon" | ||
} | ||
await self._td_send_chan.send(req) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters