Skip to content

Commit 7595f34

Browse files
committed
Merge branch 'feature_upgrade_requirement' into feature_remove_py2
2 parents fad4682 + f177c79 commit 7595f34

File tree

10 files changed

+335
-42
lines changed

10 files changed

+335
-42
lines changed

.gitignore

Lines changed: 133 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,142 @@
1+
# Byte-compiled / optimized / DLL files
12
__pycache__/
23
*.py[cod]
4+
*$py.class
35

6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
411
build/
12+
develop-eggs/
513
dist/
14+
downloads/
615
eggs/
7-
*.egg-info
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
98+
__pypackages__/
99+
100+
# Celery stuff
101+
celerybeat-schedule
102+
celerybeat.pid
103+
104+
# SageMath parsed files
105+
*.sage.py
106+
107+
# Environments
108+
.env
109+
.venv
110+
env/
111+
venv/
112+
ENV/
113+
env.bak/
114+
venv.bak/
115+
116+
# Spyder project settings
117+
.spyderproject
118+
.spyproject
119+
120+
# Rope project settings
121+
.ropeproject
122+
123+
# mkdocs documentation
124+
/site
125+
126+
# mypy
127+
.mypy_cache/
128+
.dmypy.json
129+
dmypy.json
130+
131+
# Pyre type checker
132+
.pyre/
133+
134+
# pytype static type analyzer
135+
.pytype/
136+
137+
# Cython debug symbols
138+
cython_debug/
8139

9140
.idea
10141
.DS_Store
142+

tigeropen/examples/client_config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ def get_client_config():
1818
client_config = TigerOpenClientConfig(sandbox_debug=is_sandbox)
1919
client_config.private_key = read_private_key('your private key file path')
2020
client_config.tiger_id = 'your tiger id'
21-
client_config.account = 'your account' # 环球账户.
22-
# 只使用一个账户时,不论是环球账户, 标准账户或是模拟账户, 都填在 client_config.account 下, 默认只会使用这里的账户.
21+
client_config.account = 'your account' # 账户. 不论是环球账户, 综合账户或是模拟账户, 都填在此处
2322
# standard_account 属性和 paper_account 属性只是为多账户时取用方便, 一般可忽略
24-
client_config.standard_account = None # 标准账户
25-
client_config.paper_account = None # 模拟账户
23+
client_config.standard_account = None
24+
client_config.paper_account = None
25+
client_config.secret_key = None # 机构交易员专有密钥 (机构用户需要填写, 个人开发者无需填写)
2626
client_config.language = Language.en_US
2727
return client_config

tigeropen/tiger_open_config.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,18 @@ class TigerOpenClientConfig(object):
3636
def __init__(self, sandbox_debug=False):
3737
# 开发者应用id
3838
self._tiger_id = ''
39-
# 授权账户(环球账户,推荐)
39+
# 授权账户
4040
self._account = ''
41-
# 标准账户
41+
# 综合账户
4242
self._standard_account = ''
4343
# 模拟账户
4444
self._paper_account = ''
4545
# 开发者应用私钥
4646
self._private_key = ''
4747
# 请求签名类型,推荐RSA2
4848
self._sign_type = SIGN_TYPE
49+
# 机构交易员专有密钥
50+
self._secret_key = ''
4951

5052
# 老虎证券开放平台网关地址
5153
self._server_url = SERVER_URL
@@ -162,24 +164,33 @@ def timeout(self):
162164
def timeout(self, value):
163165
self._timeout = value
164166

167+
@property
168+
def secret_key(self):
169+
return self._secret_key
170+
171+
@secret_key.setter
172+
def secret_key(self, value):
173+
self._secret_key = value
174+
165175

166176
def get_client_config(private_key_path, tiger_id, account, standard_account=None, paper_account=None,
167177
sandbox_debug=False, sign_type=None, timeout=None, language=None, charset=None,
168-
server_url=None, socket_host_port=None):
178+
server_url=None, socket_host_port=None, secret_key=None):
169179
"""
170180
生成客户端配置
171181
:param private_key_path: 私钥文件路径, 如 '/Users/tiger/.ssh/rsa_private_key.pem'
172182
:param tiger_id: 开发者应用 id
173-
:param account: 授权账户 (必填. 作为发送请求时的默认账户)
174-
:param standard_account:
175-
:param paper_account:
183+
:param account: 授权账户 (必填. 作为发送请求时的默认账户. 不论是环球账户, 综合账户或是模拟账户, 都使用此参数)
184+
:param standard_account: 多账户时可将综合账户填在此处, 一般可忽略
185+
:param paper_account: 多账户时可将模拟账户填在此处, 一般可忽略
176186
:param sandbox_debug: 是否请求 sandbox 环境
177187
:param sign_type: 签名类型
178188
:param timeout: 请求超时时间, 单位秒
179189
:param language: 语言, 取值为 tigeropen.common.consts.Language 中的枚举类型
180190
:param charset: 字符集编码
181191
:param server_url: 网关地址
182192
:param socket_host_port: 推送长连接的域名端口, 值为协议, 域名, 端口构成的三元组
193+
:param secret_key: 机构交易员专有密钥 (个人开发者无需指定)
183194
:return:
184195
"""
185196
config = TigerOpenClientConfig(sandbox_debug=sandbox_debug)
@@ -202,5 +213,7 @@ def get_client_config(private_key_path, tiger_id, account, standard_account=None
202213
config.server_url = server_url
203214
if socket_host_port:
204215
config.socket_host_port = socket_host_port
216+
if secret_key:
217+
config.secret_key = secret_key
205218
return config
206219

tigeropen/trade/domain/contract.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,23 @@ class Contract(object):
1111
def __init__(self, symbol, currency, contract_id=None, sec_type=None, exchange=None, origin_symbol=None,
1212
local_symbol=None, expiry=None, strike=None, put_call=None, multiplier=None, name=None,
1313
short_margin=None, short_fee_rate=None, shortable=None, long_initial_margin=None,
14-
long_maintenance_margin=None, contract_month=None, identifier=None):
14+
long_maintenance_margin=None, contract_month=None, identifier=None, primary_exchange=None,
15+
market=None, min_tick=None, trading_class=None, status=None, continuous=None, trade=None,
16+
last_trading_date=None, first_notice_date=None, last_bidding_close_time=None):
1517
self.contract_id = contract_id
1618
self.symbol = symbol
1719
self.currency = currency
1820
self.sec_type = sec_type
1921
self.exchange = exchange
2022
self.origin_symbol = origin_symbol
2123
self.local_symbol = local_symbol
24+
# 到期日
2225
self.expiry = expiry
2326
# 行权价
2427
self.strike = strike
2528
# 看跌/看涨
2629
self.put_call = put_call
30+
self.right = self.put_call
2731
# 合约乘数
2832
self.multiplier = multiplier
2933
# 合约名称
@@ -42,6 +46,26 @@ def __init__(self, symbol, currency, contract_id=None, sec_type=None, exchange=N
4246
self.contract_month = contract_month
4347
# 合约标识符
4448
self.identifier = identifier
49+
# 股票上市交易所
50+
self.primary_exchange = primary_exchange
51+
# 市场
52+
self.market = market
53+
# 最小报价单位
54+
self.min_tick = min_tick
55+
# 合约的交易级别名称
56+
self.trading_class = trading_class
57+
# 状态
58+
self.status = status
59+
# 期货专有,是否连续合约
60+
self.continuous = continuous
61+
# 期货专有,是否可交易
62+
self.trade = trade
63+
# 期货专有,最后交易日
64+
self.last_trading_date = last_trading_date
65+
# 期货专有,第一通知日,合约在第一通知日后无法开多仓. 已有的多仓会在第一通知日之前(通常为前三个交易日)被强制平仓
66+
self.first_notice_date = first_notice_date
67+
# 期货专有,竞价截止时间
68+
self.last_bidding_close_time = last_bidding_close_time
4569

4670
def __repr__(self):
4771
identifier = self.identifier if self.identifier else self.symbol

tigeropen/trade/domain/order.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ class Order(object):
1515
__slots__ = ["account", "id", "order_id", "parent_id", "order_time", "reason", "trade_time", "contract", "action",
1616
"quantity", "filled", "_remaining", "avg_fill_price", "commission", "realized_pnl", "_status",
1717
"trail_stop_price", "limit_price", "aux_price", "trailing_percent", "percent_offset", "action",
18-
"order_type", "time_in_force", "outside_rth", "order_legs", "algo_params"]
18+
"order_type", "time_in_force", "outside_rth", "order_legs", "algo_params", "secret_key"]
1919

2020
def __init__(self, account, contract, action, order_type, quantity, limit_price=None, aux_price=None,
2121
trail_stop_price=None, trailing_percent=None, percent_offset=None, time_in_force=None,
2222
outside_rth=None, filled=0, avg_fill_price=0, commission=None, realized_pnl=None,
2323
id=None, order_id=None, parent_id=None, order_time=None, trade_time=None, order_legs=None,
24-
algo_params=None):
24+
algo_params=None, secret_key=None):
2525
"""
2626
- account: 订单所属的账户
2727
- id: 全局订单 id
@@ -49,6 +49,7 @@ def __init__(self, account, contract, action, order_type, quantity, limit_price=
4949
- remaining: 未成交的数量
5050
- order_legs: 附加订单列表
5151
- algo_params: 算法订单参数
52+
- secret_key: 机构交易员专有密钥
5253
"""
5354

5455
self.id = id
@@ -77,6 +78,7 @@ def __init__(self, account, contract, action, order_type, quantity, limit_price=
7778
self.trade_time = trade_time
7879
self.order_legs = order_legs
7980
self.algo_params = algo_params
81+
self.secret_key = secret_key
8082

8183
def to_dict(self):
8284
dct = {name: getattr(self, name) for name in self.__slots__ if name not in ORDER_FIELDS_TO_IGNORE}

0 commit comments

Comments
 (0)