dataquant 1.1.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
dataquant/__init__.py ADDED
@@ -0,0 +1,150 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ import warnings
4
+ import importlib
5
+ import pkgutil
6
+ import dataquant
7
+
8
+ from dataquant.utils.client import init
9
+ __version__ = '1.1.6'
10
+ __all__ = []
11
+
12
+
13
+ def _init():
14
+ for loader, module_name, is_pkg in pkgutil.walk_packages(__path__, "dataquant."):
15
+ if module_name.startswith("dataquant.apis") and not is_pkg:
16
+ try:
17
+ api_module = importlib.import_module(module_name)
18
+ except ImportError as ex:
19
+ warnings.warn("import module[{}] error, msg={}".format(module_name, ex))
20
+
21
+ for api_name in api_module.__all__:
22
+ try:
23
+ api = getattr(api_module, api_name)
24
+ globals()[api_name] = api
25
+ except AttributeError as ex:
26
+ warnings.warn("load api[{}] error, msg={}".format(api_name, ex))
27
+ elif module_name.startswith("dataquant.pof") and not is_pkg:
28
+ namespace = module_name.split('.')[-2]
29
+ namespace_name = namespace
30
+ namespace = type(namespace, (object,), {})
31
+ namespace.__module__ = "dataquant"
32
+ setattr(dataquant, namespace_name, namespace)
33
+ dataquant.__all__.append(namespace_name)
34
+
35
+ try:
36
+ api_module = importlib.import_module(module_name)
37
+ except ImportError as ex:
38
+ warnings.warn("import module[{}] error, msg={}".format(module_name, ex))
39
+
40
+ _module = getattr(dataquant, namespace_name)
41
+ for api_name in api_module.__all__:
42
+ try:
43
+ api = getattr(api_module, api_name)
44
+ setattr(_module, api_name, api)
45
+ except AttributeError as ex:
46
+ warnings.warn("load api[{}] error, msg={}".format(api_name, ex))
47
+ elif module_name.startswith("dataquant.ic") and not is_pkg:
48
+ namespace = module_name.split('.')[-2]
49
+ namespace_name = namespace
50
+ namespace = type(namespace, (object,), {})
51
+ namespace.__module__ = "dataquant"
52
+ setattr(dataquant, namespace_name, namespace)
53
+ dataquant.__all__.append(namespace_name)
54
+
55
+ try:
56
+ api_module = importlib.import_module(module_name)
57
+ except ImportError as ex:
58
+ warnings.warn("import module[{}] error, msg={}".format(module_name, ex))
59
+
60
+ _module = getattr(dataquant, namespace_name)
61
+ for api_name in api_module.__all__:
62
+ try:
63
+ api = getattr(api_module, api_name)
64
+ setattr(_module, api_name, api)
65
+ except AttributeError as ex:
66
+ warnings.warn("load api[{}] error, msg={}".format(api_name, ex))
67
+ elif module_name.startswith("dataquant.cd") and not is_pkg:
68
+ namespace = module_name.split('.')[-2]
69
+ namespace_name = namespace
70
+ namespace = type(namespace, (object,), {})
71
+ namespace.__module__ = "dataquant"
72
+ setattr(dataquant, namespace_name, namespace)
73
+ dataquant.__all__.append(namespace_name)
74
+
75
+ try:
76
+ api_module = importlib.import_module(module_name)
77
+ except ImportError as ex:
78
+ warnings.warn("import module[{}] error, msg={}".format(module_name, ex))
79
+
80
+ _module = getattr(dataquant, namespace_name)
81
+ for api_name in api_module.__all__:
82
+ try:
83
+ api = getattr(api_module, api_name)
84
+ setattr(_module, api_name, api)
85
+ except AttributeError as ex:
86
+ warnings.warn("load api[{}] error, msg={}".format(api_name, ex))
87
+ elif module_name.startswith("dataquant.sql") and not is_pkg:
88
+ namespace = module_name.split('.')[-2]
89
+ namespace_name = namespace
90
+ namespace = type(namespace, (object,), {})
91
+ namespace.__module__ = "dataquant"
92
+ setattr(dataquant, namespace_name, namespace)
93
+ dataquant.__all__.append(namespace_name)
94
+
95
+ try:
96
+ api_module = importlib.import_module(module_name)
97
+ except ImportError as ex:
98
+ warnings.warn("import module[{}] error, msg={}".format(module_name, ex))
99
+
100
+ _module = getattr(dataquant, namespace_name)
101
+ for api_name in api_module.__all__:
102
+ try:
103
+ api = getattr(api_module, api_name)
104
+ setattr(_module, api_name, api)
105
+ except AttributeError as ex:
106
+ warnings.warn("load api[{}] error, msg={}".format(api_name, ex))
107
+ elif module_name.startswith("dataquant.hk") and not is_pkg:
108
+ namespace = module_name.split('.')[-2]
109
+ namespace_name = namespace
110
+ namespace = type(namespace, (object,), {})
111
+ namespace.__module__ = "dataquant"
112
+ setattr(dataquant, namespace_name, namespace)
113
+ dataquant.__all__.append(namespace_name)
114
+
115
+ try:
116
+ api_module = importlib.import_module(module_name)
117
+ except ImportError as ex:
118
+ warnings.warn("import module[{}] error, msg={}".format(module_name, ex))
119
+
120
+ _module = getattr(dataquant, namespace_name)
121
+ for api_name in api_module.__all__:
122
+ try:
123
+ api = getattr(api_module, api_name)
124
+ setattr(_module, api_name, api)
125
+ except AttributeError as ex:
126
+ warnings.warn("load api[{}] error, msg={}".format(api_name, ex))
127
+ elif module_name.startswith("dataquant.intl") and not is_pkg:
128
+ namespace = module_name.split('.')[-2]
129
+ namespace_name = namespace
130
+ namespace = type(namespace, (object,), {})
131
+ namespace.__module__ = "dataquant"
132
+ setattr(dataquant, namespace_name, namespace)
133
+ dataquant.__all__.append(namespace_name)
134
+
135
+ try:
136
+ api_module = importlib.import_module(module_name)
137
+ except ImportError as ex:
138
+ warnings.warn("import module[{}] error, msg={}".format(module_name, ex))
139
+
140
+ _module = getattr(dataquant, namespace_name)
141
+ for api_name in api_module.__all__:
142
+ try:
143
+ api = getattr(api_module, api_name)
144
+ setattr(_module, api_name, api)
145
+ except AttributeError as ex:
146
+ warnings.warn("load api[{}] error, msg={}".format(api_name, ex))
147
+
148
+ _init()
149
+
150
+ del _init
@@ -0,0 +1 @@
1
+ # -*- coding: UTF-8 -*-
@@ -0,0 +1,2 @@
1
+ # -*- coding: utf-8 -*-
2
+ from dataquant.apis.base.api import init, get_data, get_qdata
@@ -0,0 +1,77 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ __all__ = [
4
+ "init",
5
+ "environ",
6
+ "load_conf",
7
+ "get_data",
8
+ "get_qdata"
9
+ ]
10
+
11
+ from dataquant.utils.config import read_config
12
+
13
+ global QUOTE_FORMAT
14
+
15
+
16
+ def load_conf():
17
+ global QUOTE_FORMAT
18
+ CONFIG = read_config()['system']
19
+ QUOTE_FORMAT = CONFIG.get('quote_format')
20
+
21
+
22
+ load_conf()
23
+
24
+
25
+ def init(**kwargs):
26
+ """
27
+ :param str username: 用户名,license模式下为'license'
28
+ :param str password: 用户密码,license模式下为下发的license
29
+ :param str protocol:传输协议,默认HTTP
30
+ :param str url: 数据服务的URL
31
+ :param int connect_timeout: 连接建立超时时间,默认5秒
32
+ :param int timeout: 数据传输超时时间,默认30秒
33
+ :param str compressor: 数据传输过程中的压缩算法,默认不使用
34
+ :param int max_pool_size: 连接池大小,默认10
35
+ :param int page_size: 数据请求分页大小,默认100000
36
+ :return:
37
+ """
38
+ from dataquant.utils.client import init as _init
39
+
40
+ _init(**kwargs)
41
+ return
42
+
43
+
44
+ def environ():
45
+ """
46
+ 获取环境配置信息
47
+ :return:
48
+ """
49
+ from dataquant.utils.client import environ as _environ
50
+ return _environ()
51
+
52
+
53
+ def get_data(method, **kwargs):
54
+ """
55
+ 共用获取数据接口
56
+ :param method: 接口名称
57
+ :param kwargs: 接口参数
58
+ """
59
+ from dataquant.utils.client import get_client
60
+ result = get_client().send(method, **kwargs)
61
+ if result['result_code'] == '0' or result['result_code'] == 0:
62
+ return result['data']
63
+ else:
64
+ raise Exception('异常代码[%s], 异常信息[%s]' % (result['result_code'], result['result_msg']))
65
+
66
+
67
+ def get_qdata(method, **kwargs):
68
+ """
69
+ 共用获取行情数据接口
70
+ :param method: 接口名称
71
+ :param kwargs: 接口参数
72
+ """
73
+ from dataquant.utils.client import get_client
74
+ global QUOTE_FORMAT
75
+ kwargs.setdefault('format', QUOTE_FORMAT) # TabSeparatedWithNames Parquet Arrow
76
+ ret = get_client().send(method, **kwargs)
77
+ return ret
@@ -0,0 +1 @@
1
+ # -*- coding: UTF-8 -*-