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.
@@ -0,0 +1 @@
1
+ # -*- coding: UTF-8 -*-
dataquant/ic/api.py ADDED
@@ -0,0 +1,158 @@
1
+ # -*- coding: UTF-8 -*-
2
+ import warnings
3
+ import numpy as np
4
+ import pandas as pd
5
+ from itertools import product
6
+
7
+ from dataquant.apis.base import get_data
8
+ from dataquant.utils.convert import convert_fields
9
+ from dataquant.utils.datetime_func import get_current_date
10
+
11
+ __all__ = [
12
+ "get_level_info",
13
+ "get_index_info",
14
+ "get_index_data"
15
+ ]
16
+
17
+
18
+ def get_level_info(lvl_code=None, lvl_orde=None, lvl_name=None, cols=None, rslt_type=0):
19
+ """
20
+ 获取分类信息
21
+
22
+ """
23
+
24
+ int_param = \
25
+ [
26
+
27
+ ]
28
+ float_param = \
29
+ [
30
+
31
+ ]
32
+ if cols:
33
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
34
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
35
+ else:
36
+ cols = [
37
+ 'firs_lvl_code', 'firs_lvl_name', 'secd_lvl_code', 'secd_lvl_name',
38
+ 'thir_lvl_code', 'thir_lvl_name', 'four_lvl_code', 'four_lvl_name'
39
+ ]
40
+
41
+ if lvl_code is None and lvl_orde is None and lvl_name is None:
42
+ warnings.warn("函数[get_level_info]的参数"
43
+ "(lvl_code, lvl_orde, lvl_name)"
44
+ "不能全部为空")
45
+ return None
46
+
47
+ if (lvl_orde is not None and lvl_name is None) \
48
+ or (lvl_orde is None and lvl_name is not None):
49
+ warnings.warn("函数[get_level_info]的参数"
50
+ "(lvl_orde, lvl_name)"
51
+ "必须同时输入")
52
+ return None
53
+
54
+ params = {
55
+ "lvl_code": lvl_code,
56
+ "lvl_orde": lvl_orde,
57
+ "lvl_name": lvl_name,
58
+ "cols": cols,
59
+ "rslt_type": rslt_type,
60
+ "int_param": int_param,
61
+ "float_param": float_param
62
+ }
63
+ return get_data("ic/get_level_info", **params)
64
+
65
+
66
+ def get_index_info(indx_code_list=None, indx_abbr_list=None, lvl_code=None,
67
+ publ_freq=None, src_name=None, cols=None, rslt_type=0):
68
+ """
69
+ 获取产业链基本信息
70
+
71
+ """
72
+
73
+ int_param = \
74
+ [
75
+ ]
76
+ float_param = \
77
+ [
78
+ ]
79
+ if cols:
80
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
81
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
82
+ else:
83
+ cols = [
84
+ 'indx_code', 'indx_name', 'indx_abbr', 'data_val', 'publ_freq',
85
+ 'src_name', 'meas_name', 'calb_name', 'strt_date', 'end_date', 'indx_stat', 'unit_name',
86
+ 'firs_lvl_code', 'firs_lvl_name', 'secd_lvl_code', 'secd_lvl_name',
87
+ 'thir_lvl_code', 'thir_lvl_name', 'four_lvl_code', 'four_lvl_name'
88
+ ]
89
+
90
+ params = {
91
+ "indx_code_list": indx_code_list,
92
+ "indx_abbr_list": indx_abbr_list,
93
+ "lvl_code": lvl_code,
94
+ "publ_freq": publ_freq,
95
+ "src_name": src_name,
96
+ "cols": cols,
97
+ "rslt_type": rslt_type,
98
+ "int_param": int_param,
99
+ "float_param": float_param
100
+ }
101
+ return get_data("ic/get_index_info", **params)
102
+
103
+
104
+ def get_index_data(indx_code_list, strt_date, end_date=None, date_type=1,
105
+ fill_mode=3, is_delt=0, cols=None, rslt_type=0):
106
+ """
107
+ 获取所有指标
108
+
109
+ """
110
+
111
+ int_param = \
112
+ [
113
+ 'is_delt'
114
+ ]
115
+ float_param = \
116
+ [
117
+ 'data_val'
118
+ ]
119
+ if cols:
120
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
121
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
122
+ else:
123
+ cols = [
124
+ 'indx_code', 'data_date', 'data_val', 'pbsh_time', 'is_delt'
125
+ ]
126
+
127
+ fix_cols = ['indx_code', 'data_date', 'pbsh_time']
128
+ if isinstance(cols, str):
129
+ cols = cols.split(',')
130
+ tmp_cols = fix_cols + cols
131
+ cols = list(set(tmp_cols))
132
+ cols.sort(key=tmp_cols.index)
133
+
134
+ if end_date is None:
135
+ end_date = get_current_date()
136
+
137
+ if indx_code_list and strt_date:
138
+ params = {
139
+ "indx_code_list": indx_code_list,
140
+ "strt_date": strt_date,
141
+ "end_date": end_date,
142
+ "date_type": date_type,
143
+ "fill_mode": fill_mode,
144
+ "is_delt": is_delt,
145
+ "cols": cols,
146
+ "rslt_type": rslt_type,
147
+ "int_param": int_param,
148
+ "float_param": float_param
149
+ }
150
+ result = get_data("ic/get_index_data", **params)
151
+ if result is None:
152
+ return
153
+
154
+ return result
155
+
156
+ else:
157
+ warnings.warn("函数[get_index_data]的参数(indx_code_list, strt_date, end_date)为必填项")
158
+ return None
@@ -0,0 +1 @@
1
+ # -*- coding: UTF-8 -*-
dataquant/intl/api.py ADDED
@@ -0,0 +1,137 @@
1
+ # -*- coding: UTF-8 -*-
2
+ import warnings
3
+ import numpy as np
4
+ import pandas as pd
5
+
6
+ from dataquant.apis.base import get_data
7
+ from dataquant.utils.convert import convert_fields
8
+ from dataquant.utils.datetime_func import get_current_date
9
+
10
+ __all__ = [
11
+ "get_product_info",
12
+ "get_product_value"
13
+ ]
14
+
15
+
16
+ def get_product_info(symbol=None, product=None, proxy_status=None, alive_status=None, admin_name=None, cols=None, rslt_type=0):
17
+ """
18
+ 获取内部产品基本信息
19
+
20
+ """
21
+
22
+ int_param = \
23
+ [
24
+ 'risk_level', 'investment_type', 'proxy_status', 'alive_status', 'product', 'issue_start_date','issue_end_date',
25
+ 'start_date', 'end_date', 'return_type', 'return_mode', 'trade_product_type', 'untrade_product_type', 'private_fund_type',
26
+ 'public_fund_type'
27
+ ]
28
+ float_param = \
29
+ [
30
+ 'issue_price', 'par_value', 'alive_term', 'scale', 'total_shares'
31
+ ]
32
+ if cols:
33
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
34
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
35
+ # else:
36
+ # cols = [
37
+ # 'symbol'
38
+ # ,'chinese_name'
39
+ # ,'chinese_abbr_name'
40
+ # ,'risk_level'
41
+ # ,'investment_type'
42
+ # ,'proxy_status'
43
+ # ,'alive_status'
44
+ # ,'product'
45
+ # ,'admin_name'
46
+ # ,'admin_abbr_name'
47
+ # ,'issue_start_date'
48
+ # ,'issue_end_date'
49
+ # ,'issue_price'
50
+ # ,'par_value'
51
+ # ,'start_date'
52
+ # ,'end_date'
53
+ # ,'alive_term'
54
+ # ,'return_type'
55
+ # ,'return_mode'
56
+ # ,'trade_product_type'
57
+ # ,'untrade_product_type'
58
+ # ,'private_fund_type'
59
+ # ,'public_fund_type'
60
+ # ,'scale'
61
+ # ,'total_shares'
62
+ # ]
63
+
64
+ # if symbol:
65
+ if isinstance(symbol, str):
66
+ symbol = symbol.split(',')
67
+
68
+ params = {
69
+ "symbol": symbol,
70
+ "product": product,
71
+ "proxy_status": proxy_status,
72
+ "alive_status": alive_status,
73
+ "admin_name": admin_name,
74
+ "cols": cols,
75
+ "rslt_type": rslt_type,
76
+ "int_param": int_param,
77
+ "float_param": float_param
78
+ }
79
+ return get_data("intl/get_product_info", **params)
80
+
81
+ # else:
82
+ # warnings.warn("函数[get_nav]的参数(fund_code)为必填项")
83
+ # return None
84
+
85
+
86
+ def get_product_value(symbol=None, start_date=None, end_date=None, cols=None, rslt_type=0):
87
+ """
88
+ 获取内部产品净值
89
+
90
+ """
91
+
92
+ int_param = \
93
+ [
94
+ 'date'
95
+ ]
96
+ float_param = \
97
+ [
98
+ 'unit_value', 'total_value', 'daily_return', 'weekly_return', 'monthly_return', 'quarter_return',
99
+ 'semiannual_return', 'annual_return', 'current_year_return', 'cumulative_return'
100
+
101
+ ]
102
+ if cols:
103
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
104
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
105
+ # else:
106
+ # cols = [
107
+ # 'symbol', 'date',
108
+ # 'unit_value', 'total_value', 'daily_return', 'weekly_return', 'monthly_return', 'quarter_return',
109
+ # 'semiannual_return', 'annual_return', 'current_year_return', 'cumulative_return'
110
+ # ]
111
+
112
+ if symbol is None or start_date is None \
113
+ or end_date is None:
114
+ warnings.warn("函数[intl/get_product_value]的参数"
115
+ "(symbol, start_date, end_date)"
116
+ "不能为空")
117
+ return None
118
+
119
+ if isinstance(symbol, str):
120
+ symbol = symbol.split(',')
121
+
122
+ params = {
123
+ "symbol": symbol,
124
+ "start_date": start_date,
125
+ "end_date": end_date,
126
+ "cols": cols,
127
+ "rslt_type": rslt_type,
128
+ "int_param": int_param,
129
+ "float_param": float_param
130
+ }
131
+ return get_data("intl/get_product_value", **params)
132
+
133
+
134
+
135
+
136
+
137
+
@@ -0,0 +1 @@
1
+ # -*- coding: UTF-8 -*-