Skip to content

Commit 8a6e283

Browse files
committed
enum param optimization
1 parent 343c778 commit 8a6e283

File tree

4 files changed

+34
-27
lines changed

4 files changed

+34
-27
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
simplejson==3.17.3
22
delorean==1.0.0
3-
pandas==1.1.5
3+
pandas
44
python-dateutil==2.8.2
55
pytz==2021.1
66
pyasn1==0.4.8

tigeropen/examples/push_client_demo.py

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -120,25 +120,30 @@ def unsubscribe_callback(destination, content):
120120
print('subscribe:{}, callback content:{}'.format(destination, content))
121121

122122

123-
# def connect_callback():
124-
# """连接建立回调"""
125-
# print('connected')
126-
#
127-
#
128-
# def disconnect_callback():
129-
# """连接断开回调. 此处利用回调进行重连"""
130-
# for t in range(1, 200):
131-
# try:
132-
# print('disconnected, reconnecting')
133-
# push_client.connect(client_config.tiger_id, client_config.private_key)
134-
# except:
135-
# print('connect failed, retry')
136-
# time.sleep(t)
137-
# else:
138-
# print('reconnect success')
139-
# return
140-
# print('reconnect failed, please check your network')
141-
#
123+
def error_callback(content):
124+
"""错误回调"""
125+
print(content)
126+
127+
128+
def connect_callback():
129+
"""连接建立回调"""
130+
print('connected')
131+
132+
133+
def disconnect_callback():
134+
"""连接断开回调. 此处利用回调进行重连"""
135+
for t in range(1, 200):
136+
try:
137+
print('disconnected, reconnecting')
138+
push_client.connect(client_config.tiger_id, client_config.private_key)
139+
except:
140+
print('connect failed, retry')
141+
time.sleep(t)
142+
else:
143+
print('reconnect success')
144+
return
145+
print('reconnect failed, please check your network')
146+
142147

143148
if __name__ == '__main__':
144149
client_config = get_client_config()
@@ -150,21 +155,24 @@ def unsubscribe_callback(destination, content):
150155
# 已订阅 symbol 查询回调
151156
push_client.subscribed_symbols = on_query_subscribed_quote
152157
# 订单变动回调
153-
# push_client.order_changed = on_order_changed
158+
push_client.order_changed = on_order_changed
154159
# 资产变动回调
155-
# push_client.asset_changed = on_asset_changed
160+
push_client.asset_changed = on_asset_changed
156161
# 持仓变动回调
157-
# push_client.position_changed = on_position_changed
162+
push_client.position_changed = on_position_changed
158163

159164
# 订阅成功与否的回调
160165
push_client.subscribe_callback = subscribe_callback
161166
# 退订成功与否的回调
162167
push_client.unsubscribe_callback = unsubscribe_callback
163168

169+
# 错误信息回调
170+
push_client.error_callback = error_callback
171+
164172
# 建立推送连接
165173
push_client.connect(client_config.tiger_id, client_config.private_key)
166174
# 断线重连回调
167-
# push_client.disconnect_callback = disconnect_callback
175+
push_client.disconnect_callback = disconnect_callback
168176

169177
# 订阅行情
170178
push_client.subscribe_quote(['AAPL', 'GOOG'])

tigeropen/quote/quote_client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
55
@author: gaoan
66
"""
7-
import enum
87
import logging
98
import re
109

tigeropen/tiger_open_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def __prepare_request(self, request):
9999

100100
log_url = self.__config.server_url + '?' + sign_content + "&sign=" + sign
101101
if THREAD_LOCAL.logger:
102-
THREAD_LOCAL.logger.info('[' + THREAD_LOCAL.uuid + ']request:' + log_url)
102+
THREAD_LOCAL.logger.debug('[' + THREAD_LOCAL.uuid + ']request:' + log_url)
103103

104104
return all_params
105105

@@ -110,7 +110,7 @@ def __prepare_request(self, request):
110110
def __parse_response(self, response_str, timestamp=None):
111111
response_str = response_str.decode(self.__config.charset)
112112
if THREAD_LOCAL.logger:
113-
THREAD_LOCAL.logger.info('[' + THREAD_LOCAL.uuid + ']response:' + response_str)
113+
THREAD_LOCAL.logger.debug('[' + THREAD_LOCAL.uuid + ']response:' + response_str)
114114

115115
response_content = json.loads(response_str)
116116

0 commit comments

Comments
 (0)