Skip to content

Commit 2e54d48

Browse files
authored
Merge pull request #39 from tigerfintech/feature_remove_py2
remove python2 compatible
2 parents f8efc09 + ab3ee73 commit 2e54d48

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+332
-296
lines changed

requirements.txt

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
six==1.13.0
2-
simplejson==3.17.0
1+
simplejson==3.17.3
32
delorean==1.0.0
4-
pandas==0.25.3
5-
python-dateutil==2.8.1
6-
pytz==2019.3
7-
pyasn1==0.4.2
8-
rsa==4.0
9-
stomp.py==4.1.22
10-
enum34==1.1.6
3+
pandas==1.3.0
4+
python-dateutil==2.8.2
5+
pytz==2021.1
6+
pyasn1==0.4.8
7+
rsa==4.7.2
8+
stomp.py==4.1.24
119
getmac==0.8.2

setup.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
@author: gaoan
66
"""
77
from os import path
8+
89
from setuptools import find_packages, setup
910

1011
with open(path.join(path.abspath(path.dirname(__file__)), 'requirements.txt')) as f:
1112
install_requires = f.read()
1213

1314
setup(
1415
name='tigeropen',
15-
version='1.4.0',
16+
version='2.0.0',
1617
description='TigerBrokers Open API',
1718
packages=find_packages(exclude=[]),
1819
author='TigerBrokers',
@@ -26,10 +27,11 @@
2627
'Programming Language :: Python',
2728
'Operating System :: Microsoft :: Windows',
2829
'Operating System :: Unix',
29-
'Programming Language :: Python :: 2.7',
3030
'Programming Language :: Python :: 3.4',
3131
'Programming Language :: Python :: 3.5',
3232
'Programming Language :: Python :: 3.6',
3333
'Programming Language :: Python :: 3.7',
34+
'Programming Language :: Python :: 3.8',
35+
'Programming Language :: Python :: 3.9',
3436
],
3537
)

tigeropen/common/consts/__init__.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,11 @@
55
@author: gaoan
66
"""
77
import threading
8-
import platform
98
from enum import Enum, unique
10-
from .quote_keys import QuoteChangeKey, QuoteKeyType
9+
1110
from .fundamental_fields import Valuation, Income, Balance, CashFlow, BalanceSheetRatio, Growth, \
1211
Leverage, Profitability
13-
14-
python_version = platform.python_version()
15-
16-
if python_version.startswith("3"):
17-
PYTHON_VERSION_3 = True
18-
else:
19-
PYTHON_VERSION_3 = False
12+
from .quote_keys import QuoteChangeKey, QuoteKeyType
2013

2114
OPEN_API_SDK_VERSION = "2.0"
2215

tigeropen/common/response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"""
77

88

9-
class TigerResponse(object):
9+
class TigerResponse:
1010
def __init__(self):
1111
self.code = None
1212
self.message = None

tigeropen/common/util/signature_utils.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
import rsa
1515

16-
from tigeropen.common.consts import PYTHON_VERSION_3
1716
from tigeropen.common.util.string_utils import add_start_end
1817

1918

@@ -58,8 +57,7 @@ def fill_public_key_marker(public_key):
5857

5958

6059
def sign_with_rsa(private_key, sign_content, charset):
61-
if PYTHON_VERSION_3:
62-
sign_content = sign_content.encode(charset)
60+
sign_content = sign_content.encode(charset)
6361
try:
6462
private_key = rsa.PrivateKey.load_pkcs1(fill_private_key_marker(private_key), format='PEM')
6563
except binascii.Error:
@@ -68,9 +66,7 @@ def sign_with_rsa(private_key, sign_content, charset):
6866

6967
signature = rsa.sign(sign_content, private_key, 'SHA-1')
7068

71-
sign = base64.b64encode(signature)
72-
if PYTHON_VERSION_3:
73-
sign = str(sign, encoding=charset)
69+
sign = str(base64.b64encode(signature), encoding=charset)
7470
return sign
7571

7672

tigeropen/common/util/string_utils.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
"""
77
import re
88

9-
from tigeropen.common.consts import PYTHON_VERSION_3
10-
119

1210
def add_start_end(key, start_marker, end_marker):
1311
if key.find(start_marker) < 0:
@@ -23,8 +21,3 @@ def camel_to_underline(hunp_str):
2321
return sub
2422

2523

26-
def get_string(value):
27-
if PYTHON_VERSION_3:
28-
return value
29-
else:
30-
return value.encode('utf-8')

tigeropen/common/util/web_utils.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
@author: gaoan
66
"""
77
import json
8-
from tigeropen.common.consts import PYTHON_VERSION_3, THREAD_LOCAL
8+
9+
from tigeropen.common.consts import THREAD_LOCAL
910
from tigeropen.common.exceptions import RequestException, ResponseException
1011

1112
try:
@@ -28,10 +29,7 @@ def url_encode(params, charset):
2829
value = v
2930
if not isinstance(value, str):
3031
value = json.dumps(value, ensure_ascii=False)
31-
if PYTHON_VERSION_3:
32-
value = quote_plus(value, encoding=charset)
33-
else:
34-
value = quote_plus(value)
32+
value = quote_plus(value, encoding=charset)
3533
query_string += ("&" + k + "=" + value)
3634
query_string = query_string[1:]
3735
return query_string
@@ -69,7 +67,7 @@ def do_post(url, query_string=None, headers=None, params=None, timeout=15, chars
6967
result = response.read()
7068

7169
if response.status != 200:
72-
if PYTHON_VERSION_3 and charset:
70+
if charset:
7371
result = result.decode(charset)
7472
raise ResponseException('[' + THREAD_LOCAL.uuid + ']invalid http status ' + str(response.status) +
7573
',detail body:' + result)

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/fundamental/request/model.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22

33

4-
class FinancialDailyParams(object):
4+
class FinancialDailyParams:
55
def __init__(self):
66
self._symbols = None
77
self._market = None
@@ -82,7 +82,7 @@ def to_openapi_dict(self):
8282
return params
8383

8484

85-
class FinancialReportParams(object):
85+
class FinancialReportParams:
8686
def __init__(self):
8787
self._symbols = None
8888
self._market = None
@@ -139,7 +139,7 @@ def to_openapi_dict(self):
139139
return params
140140

141141

142-
class CorporateActionParams(object):
142+
class CorporateActionParams:
143143
def __init__(self):
144144
self._symbols = None
145145
self._market = None
@@ -208,7 +208,7 @@ def to_openapi_dict(self):
208208
return params
209209

210210

211-
class IndustryParams(object):
211+
class IndustryParams:
212212
def __init__(self):
213213
self._industry_level = None
214214
self._industry_id = None

tigeropen/fundamental/response/financial_daily_response.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# -*- coding: utf-8 -*-
22

33
import pandas as pd
4-
import six
54

65
from tigeropen.common.response import TigerResponse
7-
from tigeropen.common.util.string_utils import get_string
86

97
COLUMNS = ['symbol', 'field', 'date', 'value']
108

@@ -25,8 +23,6 @@ def parse_response_content(self, response_content):
2523
for item in self.data:
2624
item_values = dict()
2725
for key, value in item.items():
28-
if isinstance(value, six.string_types):
29-
value = get_string(value)
3026
item_values[key] = value
3127
items.append(item_values)
3228
self.financial_daily = pd.DataFrame(items, columns=COLUMNS)

0 commit comments

Comments
 (0)