-
Notifications
You must be signed in to change notification settings - Fork 650
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
53f7aaf
commit 5cc39d4
Showing
27 changed files
with
9,621 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ Jupyter 示例 | |
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
:caption: Contents: | ||
:caption: 目录: | ||
|
||
notebooks/demo | ||
|
||
notebooks/factor |
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
|
@@ -23,6 +23,7 @@ TianQin Python Sdk User Guide | |
dev/index.rst | ||
profession.rst | ||
enterprise.rst | ||
tqsdk_llm.rst | ||
qa.rst | ||
version.rst | ||
|
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,37 @@ | ||
.. _tqsdk_llm: | ||
|
||
天勤量化机器人助手 | ||
----------------------------------------------- | ||
在使用天勤的过程中,用户往往会遇到各种问题,尤其是初学者,他们可能会关心以下几点: | ||
|
||
* 天勤量化可以实现哪些功能? | ||
* 如何编写实现这些功能的大致代码? | ||
* 文档中某些函数的具体参数是什么意思? | ||
|
||
当度过初学者的阶段后,用户可能会遇到以下情况: | ||
|
||
* 如何解决天勤或 Python 报错? | ||
* 如何优化策略代码逻辑? | ||
* 某个特定功能在天勤中如何实现? | ||
|
||
这些问题都会成为用户使用天勤量化时的障碍。 | ||
|
||
为了帮助用户解决这些问题,我们结合了国内先进的大语言模型,推出了专门的智能机器人助手,旨在解答以下问题: | ||
|
||
* 具体函数的详细介绍 | ||
* 根据具体需求或策略提供天勤实现的示例 | ||
* 天勤或 Python 报错的可能解决方案 | ||
|
||
点击即刻尝试 `使用智能机器人! <https://udify.app/chat/im02prcHNEOVbPAx/>`_ | ||
|
||
下图是具体的使用示例 demo | ||
|
||
.. figure:: images/llm_pic1.png | ||
.. figure:: images/llm_pic2.png | ||
.. figure:: images/llm_pic3.png | ||
.. figure:: images/llm_pic4.png | ||
.. figure:: images/llm_pic5.png | ||
.. figure:: images/llm_pic6.png | ||
.. figure:: images/llm_pic7.png | ||
|
||
|
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 |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
|
||
setuptools.setup( | ||
name='tqsdk', | ||
version="3.6.0", | ||
version="3.6.1", | ||
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"], | ||
"certifi", "pyjwt", "psutil", "shinny_structlog", "sgqlc", "filelock", "tqsdk_ctpse", "tqsdk_sm", "tqsdk_zq_otg==1.0.1"], | ||
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.6.0' | ||
__version__ = '3.6.1' |
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 | ||
from tqsdk.tradeable import TqAccount, TqZq, TqKq, TqKqStock, TqSim, TqSimStock, BaseSim, BaseOtg, TqCtp | ||
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] | ||
UnionTradeable = Union[TqAccount, TqKq, TqZq, TqKqStock, TqSim, TqSimStock, TqCtp] | ||
|
||
|
||
class TqApi(TqBaseApi): | ||
|
@@ -117,8 +117,10 @@ def __init__(self, account: Optional[Union[TqMultiAccount, UnionTradeable]] = No | |
* :py:class:`~tqsdk.TqZq` : 使用众期账号 | ||
* :py:class:`~tqsdk.TqMultiAccount` : 多账户列表,列表中支持 :py:class:`~tqsdk.TqAccount`、:py:class:`~tqsdk.TqKq`、\ | ||
:py:class:`~tqsdk.TqKqStock`、:py:class:`~tqsdk.TqSim` 和 :py:class:`~tqsdk.TqSimStock` 中的 0 至 N 个或者组合 | ||
* :py:class:`~tqsdk.TqCtp` : 使用直连 CTP 账号 | ||
* :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 个或者组合 | ||
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,71 @@ | ||
#!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 TqCtp(BaseOtg, FutureMixin): | ||
"""直连 CTP 账户类""" | ||
|
||
def __init__(self, account_id: str, password: str, front_broker: str, front_url: str, app_id: str, auth_code: str) -> None: | ||
""" | ||
创建直连 CTP 账户实例 | ||
Args: | ||
account_id (str): 帐号 | ||
password (str): 密码 | ||
front_broker (str): CTP 柜台代码 | ||
front_url (str): CTP 柜台地址 | ||
app_id (str): CTP AppID | ||
auth_code (str): CTP AuthCode | ||
Example1:: | ||
from tqsdk import TqApi, TqCtp | ||
account = TqCtp(account_id="CTP 账户", password="CTP 密码", front_broker="CTP 柜台代码", "front_url"="CTP 柜台地址", app_id="CTP AppID", auth_code="CTP AuthCode") | ||
api = TqApi(account, auth=TqAuth("快期账户", "账户密码")) | ||
""" | ||
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(TqCtp, 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": "ctp" | ||
} | ||
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
Oops, something went wrong.