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,2300 @@
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_exchange_calendar",
12
+ "get_index_info",
13
+ "get_index_components",
14
+ "get_security_info",
15
+ "get_future_contract",
16
+ "get_industry_mapping",
17
+ "get_stock_industry",
18
+ "get_stock_industry_change",
19
+ "get_exright_factor",
20
+ "get_ins_basc_info",
21
+ "get_dominant",
22
+ "get_index_weights",
23
+ "get_index_altt_components",
24
+ "get_commodity_index_quote",
25
+ "get_security_index_quote",
26
+
27
+ # ================================= 后续开放内容 ================================= #
28
+ "get_stk_susp_info",
29
+ "get_stk_st_flag",
30
+ "get_stk_basc_affi",
31
+ "get_bsht",
32
+ "get_cfst",
33
+ "get_proft",
34
+ "get_fin_indx",
35
+ "get_stk_plac_info",
36
+ "get_stk_divd_info",
37
+ "get_stk_addi",
38
+ "get_ins_mngr_info",
39
+ "get_ins_mngr_chg",
40
+ "get_ins_capt_chg",
41
+ "get_ins_top10_shah",
42
+ "get_ins_top10_cir_shah",
43
+ "get_rstk_drrt",
44
+ "get_rstk_drrt_dtl",
45
+ "get_prof_pred",
46
+ "get_marg_scr",
47
+ "get_stk_bloc_rep",
48
+ "get_stk_bloc_recd",
49
+ "get_fund_basc_info",
50
+ "get_cifd_fund_basc_info",
51
+ "get_fund_feer_info",
52
+ "get_fund_rat_info",
53
+ "get_fund_nav_info",
54
+ "get_fund_shr_chg",
55
+ "get_fund_perf_indx",
56
+ "get_fund_ast_cfg_info",
57
+ "get_fund_hldp_dtl",
58
+ "get_crrc_fund_payf_info",
59
+ "get_etf_daly_pr_info",
60
+ ]
61
+
62
+
63
+ def get_exchange_calendar(mkt_code, strt_date='19900101', end_date=None, trdy_flag=None, cols=None, rslt_type=0):
64
+ """
65
+ 获取交易所交易日日历,包括:上海证券交易所,深圳证券交易所等。
66
+
67
+ """
68
+
69
+ int_param = []
70
+ float_param = []
71
+ if cols:
72
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
73
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
74
+ else:
75
+ cols = ['mkt_code', 'busi_date', 'trdy_flag']
76
+
77
+ if mkt_code == 'XSHE':
78
+ mkt_code = 'XSHG'
79
+
80
+ if mkt_code:
81
+ params = {
82
+ "mkt_code": mkt_code,
83
+ "strt_date": strt_date,
84
+ "end_date": end_date,
85
+ "trdy_flag": trdy_flag,
86
+ "cols": cols,
87
+ "rslt_type": rslt_type,
88
+ "int_param": int_param,
89
+ "float_param": float_param
90
+ }
91
+ return get_data("get_exch_trd_cldr", **params)
92
+ else:
93
+ warnings.warn("函数[get_exchange_calendar]的参数(mkt_code)为必填项")
94
+ return None
95
+
96
+
97
+ def get_index_info(scr_num_list=None, indx_elem_type_code=None, indx_rels_ins_name=None,
98
+ indx_wght_type_code=None, cols=None, rslt_type=0):
99
+ """
100
+ 获取国内外指数的基本要素信息,包括指数名称、交易代码、发布机构、发布日期、基日、基点、指数系列、样本证券类型、样本交
101
+ 易市场、加权方式、指数类型等。
102
+
103
+ """
104
+
105
+ int_param = []
106
+ float_param = ['indx_basd_pont']
107
+ if cols:
108
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
109
+ float_param = list({'indx_basd_pont'}.intersection(set(convert_fields(cols))))
110
+ else:
111
+ cols = [
112
+ 'scr_code', 'scr_num', 'scr_abbr', 'mkt_code', 'indx_type_code', 'indx_rels_ins_name', 'indx_basd',
113
+ 'indx_basd_pont', 'puse_date', 'indx_elem_type_code', 'indx_wght_type_code', 'indx_cal_type_code'
114
+ ]
115
+ params = {
116
+ "scr_num_list": scr_num_list,
117
+ "indx_elem_type_code": indx_elem_type_code,
118
+ "indx_rels_ins_name": indx_rels_ins_name,
119
+ "indx_wght_type_code": indx_wght_type_code,
120
+ "cols": cols,
121
+ "rslt_type": rslt_type,
122
+ "int_param": int_param,
123
+ "float_param": float_param
124
+ }
125
+ return get_data("get_indx_basc_info", **params)
126
+
127
+
128
+ def get_index_components(scr_num_list=None, trad_date=None, cols=None, rslt_type=0):
129
+ """
130
+ 获取指数的成分构成情况,包括指数成分股名称、成分股代码、入选日期、剔除日期等。
131
+
132
+ """
133
+
134
+ int_param = []
135
+ float_param = []
136
+ if cols:
137
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
138
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
139
+ else:
140
+ cols = [
141
+ 'trad_date', 'scr_code', 'scr_num', 'scr_abbr', 'mkt_code',
142
+ 'indx_type_code', 'elem_scr_code', 'elem_scr_num', 'elem_scr_abbr', 'elem_mkt_code'
143
+ ]
144
+
145
+ if scr_num_list:
146
+ params = {
147
+ "scr_num_list": scr_num_list,
148
+ "intv_strt_date": trad_date,
149
+ "intv_end_date": trad_date,
150
+ "cols": cols,
151
+ "rslt_type": rslt_type,
152
+ "int_param": int_param,
153
+ "float_param": float_param
154
+ }
155
+ return get_data("get_indx_elem", **params)
156
+ else:
157
+ warnings.warn("函数[get_index_components]的参数(scr_num_list)为必填项")
158
+ return None
159
+
160
+
161
+ def get_security_info(scr_num_list=None, mkt_code=None, cols=None):
162
+ """
163
+ 获取股票的基本信息,包含股票交易代码及其简称、股票类型、上市状态、上市板块、上市日期等;上市状态为最新数据,不显示历
164
+ 史变动信息(含科创板)。
165
+
166
+ """
167
+ STOCK = ['XSHG', 'XSHE', 'XHKG']
168
+ FUTURE = ['XZCE', 'XDCE', 'XSGE', 'CCFX', 'XINE']
169
+
170
+ _stk_num_list = []
171
+ _fut_num_list = []
172
+
173
+ # 同时输入scr_num_list和mkt_code,以输入代码优先
174
+ result = {}
175
+ return_data = None
176
+ if scr_num_list and mkt_code:
177
+ mkt_code = None
178
+ elif mkt_code:
179
+ if mkt_code == "XHKG":
180
+ result['hkstock'] = _get_hkstock_info(mkt_code=mkt_code, cols=cols)
181
+
182
+ elif mkt_code in STOCK:
183
+ result['stock'] = _get_stock_info(mkt_code=mkt_code, cols=cols)
184
+ result['bond'] = _get_bond_info(mkt_code=mkt_code, cols=cols)
185
+ result['fund'] = _get_fund_info(mkt_code=mkt_code, cols=cols)
186
+
187
+
188
+ return result
189
+ elif mkt_code in FUTURE:
190
+ result['future'] = _get_future_info(mkt_code=mkt_code, cols=cols)
191
+ return result
192
+
193
+ if scr_num_list is None and mkt_code is None:
194
+ result['stock'] = _get_stock_info()
195
+ return result
196
+
197
+ if scr_num_list:
198
+ if isinstance(scr_num_list, str):
199
+ scr_num_list = scr_num_list.split(',')
200
+
201
+ for _scr in scr_num_list:
202
+ if _scr[0].isdigit():
203
+ _stk_num_list.append(_scr)
204
+ else:
205
+ _fut_num_list.append(_scr)
206
+
207
+ if len(_stk_num_list) > 0:
208
+ result['stock'] = _get_stock_info(_stk_num_list, mkt_code, cols)
209
+ result['bond'] = _get_bond_info(_stk_num_list, mkt_code, cols)
210
+ result['fund'] = _get_fund_info(_stk_num_list, mkt_code, cols)
211
+ result['hkstock'] = _get_hkstock_info(_stk_num_list, mkt_code, cols)
212
+ if len(_fut_num_list) > 0:
213
+ result['future'] = _get_future_info(_fut_num_list, mkt_code, cols)
214
+
215
+ return result
216
+
217
+
218
+ def _get_stock_info(scr_num_list=None, mkt_code=None, cols=None):
219
+ """
220
+
221
+ """
222
+
223
+ int_param = []
224
+ float_param = ['tot_capt']
225
+ if cols:
226
+ int_param = list(set(int_param).intersection(set(convert_fields(cols))))
227
+ float_param = list(set(float_param).intersection(set(convert_fields(cols))))
228
+ else:
229
+ cols = [
230
+ 'scr_code', 'scr_num', 'stk_abbr', 'stk_name', 'mkt_code',
231
+ 'list_stat', 'list_date', 'delt_date', 'stk_type', 'astk_boar_type_code',
232
+ 'ofer_crrc_code', 'cont_addr', 'main_busi', 'tot_capt'
233
+ ]
234
+
235
+ params = {
236
+ "scr_num_list": scr_num_list,
237
+ "stk_type": "01",
238
+ "mkt_code": mkt_code,
239
+ "cols": cols,
240
+ "int_param": int_param,
241
+ "float_param": float_param
242
+ }
243
+
244
+ return get_data("get_stk_basc_info", **params)
245
+
246
+ # 20240609 add 港股基本信息api
247
+ def _get_hkstock_info(scr_num_list=None, mkt_code=None, cols=None):
248
+ """
249
+
250
+ """
251
+
252
+ int_param = []
253
+ float_param = ['tot_capt']
254
+ if cols:
255
+ int_param = list(set(int_param).intersection(set(convert_fields(cols))))
256
+ float_param = list(set(float_param).intersection(set(convert_fields(cols))))
257
+ else:
258
+ cols = [
259
+ 'scr_code', 'scr_num', 'stk_abbr', 'stk_name', 'mkt_code',
260
+ 'list_stat', 'list_date', 'delt_date', 'stk_type', 'astk_boar_type_code',
261
+ 'ofer_crrc_code', 'cont_addr', 'main_busi', 'tot_capt'
262
+ ]
263
+
264
+ params = {
265
+ "scr_num_list": scr_num_list,
266
+ "mkt_code": "XHKG",
267
+ "cols": cols,
268
+ "int_param": int_param,
269
+ "float_param": float_param
270
+ }
271
+
272
+ return get_data("get_stk_basc_info", **params)
273
+
274
+ def _get_bond_info(scr_num_list=None, mkt_code=None, cols=None):
275
+ """
276
+
277
+ """
278
+
279
+ int_param = []
280
+ float_param = []
281
+ if cols:
282
+ int_param = list(set(int_param).intersection(set(convert_fields(cols))))
283
+ float_param = list(set(float_param).intersection(set(convert_fields(cols))))
284
+ else:
285
+ cols = [
286
+ 'scr_code', 'scr_num', 'scr_abbr', 'scr_name', 'mkt_code', 'list_stat',
287
+ 'list_date', 'delt_date', 'bond_type', 'ofer_crrc_code'
288
+ ]
289
+
290
+ params = {
291
+ "scr_num_list": scr_num_list,
292
+ "mkt_code": mkt_code,
293
+ "cols": cols,
294
+ "int_param": int_param,
295
+ "float_param": float_param
296
+ }
297
+
298
+ return get_data("get_bond_basc_info", **params)
299
+
300
+
301
+ def _get_fund_info(scr_num_list=None, mkt_code=None, cols=None):
302
+ """
303
+
304
+ """
305
+
306
+ int_param = ['mng_ins_num', 'trus_ins_num', ]
307
+ float_param = ['cir_shr']
308
+ if cols:
309
+ int_param = list(set(int_param).intersection(set(convert_fields(cols))))
310
+ float_param = list(set(float_param).intersection(set(convert_fields(cols))))
311
+ else:
312
+ cols = [
313
+ 'scr_num', 'scr_code', 'scr_abbr', 'mkt_code', 'fund_type',
314
+ 'oper_mode_code', 'qdii_flag', 'etf_flag', 'lof_flag', 'list_stat',
315
+ 'mngr_name', 'setp_date', 'at_pd_date', 'list_date', 'delt_date',
316
+ 'mng_ins_num', 'mng_ins_abbr', 'mng_ins_name', 'trus_ins_num',
317
+ 'trus_ins_abbr', 'trus_ins_name', 'ivsm_scop', 'ivsm_tgt',
318
+ 'perf_cont_basi', 'cir_shr'
319
+ ]
320
+
321
+ params = {
322
+ "scr_num_list": scr_num_list,
323
+ "mkt_code": mkt_code,
324
+ "cols": cols,
325
+ "int_param": int_param,
326
+ "float_param": float_param
327
+ }
328
+
329
+ return get_data("get_fund_basc_info", **params)
330
+
331
+
332
+ def _get_future_info(scr_num_list=None, mkt_code=None, cols=None):
333
+ """
334
+
335
+ """
336
+
337
+ int_param = []
338
+ float_param = ['min_mar', 'last_deli_date']
339
+ if cols:
340
+ int_param = list(set(int_param).intersection(set(convert_fields(cols))))
341
+ float_param = list(set(float_param).intersection(set(convert_fields(cols))))
342
+ else:
343
+ cols = [
344
+ 'scr_num', 'scr_code', 'fut_abbr', 'mkt_code', 'mkt_abbr', 'cont_type', 'cont_mth', 'dely_meth',
345
+ 'futr_var_code', 'futr_var_abbr', 'quot_unit', 'tick_sz', 'contr_mtp', 'min_mar', 'list_date',
346
+ 'last_trd_date', 'deli_year', 'deli_mth', 'deli_date', 'last_deli_date', 'tx_fee', 'deli_chag',
347
+ 'lstg_basi_prc', 'limit_up_down_chg', 'cont_stat'
348
+ ]
349
+
350
+ if scr_num_list and '.' not in scr_num_list[0]:
351
+ params = {
352
+ "scr_code_list": scr_num_list,
353
+ "mkt_code": mkt_code,
354
+ "cols": cols,
355
+ "int_param": int_param,
356
+ "float_param": float_param
357
+ }
358
+ else:
359
+ params = {
360
+ "scr_num_list": scr_num_list,
361
+ "mkt_code": mkt_code,
362
+ "cols": cols,
363
+ "int_param": int_param,
364
+ "float_param": float_param
365
+ }
366
+
367
+ return get_data("get_fut_basc_info", **params)
368
+
369
+
370
+ def get_future_contract(futr_var_code=None, trad_date=None, cols=None):
371
+ """
372
+
373
+ """
374
+
375
+ int_param = []
376
+ float_param = ['min_mar', 'last_deli_date']
377
+ if cols:
378
+ int_param = list(set(int_param).intersection(set(convert_fields(cols))))
379
+ float_param = list(set(float_param).intersection(set(convert_fields(cols))))
380
+ else:
381
+ cols = [
382
+ 'scr_num', 'scr_code', 'fut_abbr', 'mkt_code', 'mkt_abbr', 'cont_type', 'cont_mth', 'dely_meth',
383
+ 'futr_var_code', 'futr_var_abbr', 'quot_unit', 'tick_sz', 'contr_mtp', 'min_mar', 'list_date',
384
+ 'last_trd_date', 'deli_year', 'deli_mth', 'deli_date', 'last_deli_date', 'tx_fee', 'deli_chag',
385
+ 'lstg_basi_prc', 'limit_up_down_chg', 'cont_stat'
386
+ ]
387
+
388
+ params = {
389
+ "futr_var_code": futr_var_code,
390
+ "trad_date": trad_date,
391
+ "cols": cols,
392
+ "int_param": int_param,
393
+ "float_param": float_param
394
+ }
395
+
396
+ return get_data("get_fut_trd_contr", **params)
397
+
398
+
399
+ def get_industry_mapping(indt_clas_std_code, indt_code_list=None, indt_prn_code_list=None,
400
+ indt_lvl_list=None, cols=None, rslt_type=0):
401
+ """
402
+ 获取针对机构、证券的行业分类说明,覆盖证监会行业2012、申万行业、中证行业、GICS行业、沪深市场板块等分类体系。
403
+
404
+ """
405
+
406
+ int_param = []
407
+ float_param = []
408
+ if cols:
409
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
410
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
411
+ else:
412
+ cols = [
413
+ 'indt_code', 'indt_name', 'indt_prn_code', 'indt_lvl', 'indt_clas_std_code'
414
+ ]
415
+
416
+ if indt_code_list is not None:
417
+ indt_prn_code_list = None
418
+ indt_lvl_list = None
419
+ elif indt_code_list is None and indt_prn_code_list is not None:
420
+ indt_lvl_list = None
421
+
422
+ if indt_clas_std_code:
423
+ params = {
424
+ "indt_clas_std_code": indt_clas_std_code,
425
+ "indt_code_list": indt_code_list,
426
+ "indt_prn_code_list": indt_prn_code_list,
427
+ "indt_lvl_list": indt_lvl_list,
428
+ "cols": cols,
429
+ "rslt_type": rslt_type,
430
+ "int_param": int_param,
431
+ "float_param": float_param
432
+ }
433
+ return get_data("get_scr_indt_clas", **params)
434
+ else:
435
+ warnings.warn("函数[get_industry_mapping]的参数(indt_clas_std_code)为必填项")
436
+ return None
437
+
438
+
439
+ def get_stock_industry(scr_num_list=None, trad_date=None, clas_code=None, cols=None,
440
+ rslt_type=0):
441
+ """
442
+ 获取沪深股票所属行业信息,输入证券代码则返回证券所属行业,输入行业编码及行业代码则返回行业所含的全部证券
443
+
444
+ """
445
+
446
+ int_param = []
447
+ float_param = []
448
+ if cols:
449
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
450
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
451
+ else:
452
+ cols = [
453
+ 'trad_date', 'scr_num', 'clas_code', 'clas_name',
454
+ 'firs_clas_indu_code', 'firs_clas_indu_name', 'secd_clas_indu_code', 'secd_clas_indu_name',
455
+ 'thir_clas_indu_code', 'thir_clas_indu_name', 'four_clas_indu_code', 'four_clas_indu_name'
456
+ ]
457
+
458
+ if clas_code is None:
459
+ clas_code = '38'
460
+
461
+ if scr_num_list is None:
462
+ scr_num_list = get_security_info()['scr_num'].tolist()
463
+
464
+ params = {
465
+ "scr_num_list": scr_num_list,
466
+ "trad_date": trad_date,
467
+ "clas_code": clas_code,
468
+ "cols": cols,
469
+ "rslt_type": rslt_type,
470
+ "int_param": int_param,
471
+ "float_param": float_param
472
+ }
473
+ return get_data("get_stk_indt_clas", **params)
474
+
475
+
476
+ def get_stock_industry_change(scr_num_list=None, clas_code=None, cols=None,
477
+ rslt_type=0):
478
+ """
479
+ 获取沪深股票所属行业信息,输入证券代码则返回证券所属行业,输入行业编码及行业代码则返回行业所含的全部证券
480
+
481
+ """
482
+
483
+ int_param = []
484
+ float_param = []
485
+ if cols:
486
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
487
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
488
+ else:
489
+ cols = [
490
+ 'scr_num', 'clas_code', 'clas_name', 'pub_date', 'cacl_date',
491
+ 'firs_clas_indu_code', 'firs_clas_indu_name',
492
+ 'secd_clas_indu_code', 'secd_clas_indu_name',
493
+ 'thir_clas_indu_code', 'thir_clas_indu_name',
494
+ 'four_clas_indu_code', 'four_clas_indu_name', 'vali_flag'
495
+ ]
496
+
497
+ if clas_code is None:
498
+ clas_code = '38'
499
+
500
+ if scr_num_list is None:
501
+ scr_num_list = get_security_info()['stock']['scr_num'].tolist()
502
+
503
+ params = {
504
+ "scr_num_list": scr_num_list,
505
+ "clas_code": clas_code,
506
+ "cols": cols,
507
+ "rslt_type": rslt_type,
508
+ "int_param": int_param,
509
+ "float_param": float_param
510
+ }
511
+ return get_data("get_stk_indt_info", **params)
512
+
513
+
514
+ def get_exright_factor(scr_num_list, strt_date=None, end_date=None, cols=None, rslt_type=0):
515
+ """
516
+ 获取股票复权因子数据。
517
+
518
+ """
519
+
520
+ int_param = ['addi_prc']
521
+ float_param = [
522
+ 'bons_amt', 'sdvd_rati', 'tfsh_rati', 'plac_rati', 'plac_prc', 'addi_rati', 'accu_rstr_cnst',
523
+ 'thim_accu_rstr_fctr', 'aggr_accu_rstr_fctr', 'rati_rstr_cnst', 'thim_rati_rstr_fctr',
524
+ 'forward_rstr_fctr', 'aggr_rati_rstr_fctr'
525
+ ]
526
+ if cols:
527
+ int_param = list({'addi_prc'}.intersection(set(convert_fields(cols))))
528
+ float_param = list(
529
+ {'bons_amt', 'sdvd_rati', 'tfsh_rati', 'plac_rati', 'plac_prc', 'addi_rati', 'accu_rstr_cnst',
530
+ 'thim_accu_rstr_fctr', 'aggr_accu_rstr_fctr', 'rati_rstr_cnst', 'thim_rati_rstr_fctr', 'forward_rstr_fctr',
531
+ 'aggr_rati_rstr_fctr'}.intersection(set(convert_fields(cols))))
532
+ else:
533
+ cols = [
534
+ 'scr_code', 'scr_num', 'mkt_code', 'equi_reg_date', 'dr_day', 'bons_amt', 'sdvd_rati', 'tfsh_rati',
535
+ 'plac_rati', 'plac_prc', 'addi_prc', 'accu_rstr_cnst', 'thim_accu_rstr_fctr', 'forward_rstr_fctr',
536
+ 'aggr_rati_rstr_fctr',
537
+ ]
538
+ if scr_num_list:
539
+ params = {
540
+ "scr_num_list": scr_num_list,
541
+ "strt_date": strt_date,
542
+ "end_date": end_date,
543
+ "cols": cols,
544
+ "rslt_type": rslt_type,
545
+ "int_param": int_param,
546
+ "float_param": float_param
547
+ }
548
+ return get_data("get_stk_rstr_fctr", **params)
549
+ else:
550
+ warnings.warn("函数[get_exright_factor]的参数(scr_num_list)为必填项")
551
+ if rslt_type == 0:
552
+ return pd.DataFrame()
553
+ else:
554
+ return np.empty(0)
555
+
556
+
557
+ def get_dominant(futr_var_code, strt_date=None, end_date=None, cont_rank=1, calc_mode=1, cols=None):
558
+ """
559
+ 获取期货主力合约信息
560
+ """
561
+
562
+ int_param = []
563
+ float_param = ['min_mar', 'last_deli_date']
564
+ if cols:
565
+ int_param = list(set(int_param).intersection(set(convert_fields(cols))))
566
+ float_param = list(set(float_param).intersection(set(convert_fields(cols))))
567
+ else:
568
+ cols = [
569
+ 'scr_num', 'scr_code', 'busi_date', 'fut_abbr', 'mkt_code', 'mkt_abbr', 'cont_type', 'cont_mth', 'dely_meth',
570
+ 'futr_var_code', 'futr_var_abbr', 'quot_unit', 'tick_sz', 'contr_mtp', 'min_mar', 'list_date',
571
+ 'last_trd_date', 'deli_year', 'deli_mth', 'deli_date', 'last_deli_date', 'tx_fee', 'deli_chag',
572
+ 'lstg_basi_prc', 'limit_up_down_chg', 'cont_stat'
573
+ ]
574
+
575
+ if strt_date is None:
576
+ strt_date = get_current_date()
577
+ if end_date is None:
578
+ end_date = get_current_date()
579
+
580
+ if futr_var_code:
581
+ params = {
582
+ "futr_var_code": futr_var_code,
583
+ "strt_date": strt_date,
584
+ "end_date": end_date,
585
+ "cont_rank": cont_rank,
586
+ "calc_mode": calc_mode,
587
+ "cols": cols,
588
+ "int_param": int_param,
589
+ "float_param": float_param
590
+ }
591
+
592
+ return get_data("get_fut_main_contr", **params)
593
+ else:
594
+ warnings.warn("函数[get_dominant]的参数(futr_var_code)为必填项")
595
+ return None
596
+
597
+
598
+ def get_index_weights(scr_num_list, trad_date=None, cols=None, rslt_type=0):
599
+ """
600
+ 获取指数成分股权重,包括成分股名称、成分股代码、权重生效日、成分股权重等。其中,中债指数按日更新,上证、中证、深证、
601
+ 国证等股票指数按月更新。
602
+
603
+ """
604
+
605
+ int_param = []
606
+ float_param = ['elem_wght']
607
+ if cols:
608
+ int_param = list({}.intersection(set(convert_fields(cols))))
609
+ float_param = list({'elem_wght'}.intersection(set(convert_fields(cols))))
610
+ else:
611
+ cols = [
612
+ 'scr_code', 'scr_num', 'scr_abbr', 'mkt_code', 'indx_type_code', 'elem_scr_code', 'elem_scr_num',
613
+ 'elem_scr_abbr', 'elem_mkt_code', 'trad_date', 'elem_wght'
614
+ ]
615
+
616
+ if trad_date is None:
617
+ trad_date = get_current_date()
618
+
619
+ if scr_num_list:
620
+ params = {
621
+ "scr_num_list": scr_num_list,
622
+ "trad_date": trad_date,
623
+ "cols": cols,
624
+ "rslt_type": rslt_type,
625
+ "int_param": int_param,
626
+ "float_param": float_param
627
+ }
628
+ return get_data("get_indx_elem_wght", **params)
629
+ else:
630
+ warnings.warn("函数[get_indx_weights]的参数(scr_num_list)为必填项")
631
+ return None
632
+
633
+
634
+ def get_index_altt_components(scr_num_list, trad_date=None, cols=None,
635
+ rslt_type=0):
636
+ """
637
+ 获取指数的备选成分构成情况,包括指数成分股名称、成分股代码、入选日期、剔除日期等。
638
+
639
+ """
640
+
641
+ int_param = []
642
+ float_param = []
643
+ if cols:
644
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
645
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
646
+ else:
647
+ cols = [
648
+ 'scr_code', 'scr_num', 'scr_abbr', 'mkt_code', 'indx_type_code', 'elem_scr_code', 'elem_scr_num',
649
+ 'elem_scr_abbr', 'elem_mkt_code', 'affi_date'
650
+ ]
651
+
652
+ if scr_num_list:
653
+ params = {
654
+ "scr_num_list": scr_num_list,
655
+ "affi_strt_date": trad_date,
656
+ "affi_end_date": trad_date,
657
+ "cols": cols,
658
+ "rslt_type": rslt_type,
659
+ "int_param": int_param,
660
+ "float_param": float_param
661
+ }
662
+ return get_data("get_indx_altt_elem", **params)
663
+ else:
664
+ warnings.warn("函数[get_index_altt_components]的参数(scr_num_list)为必填项")
665
+ return None
666
+
667
+
668
+ def get_commodity_index_quote(scr_num_list, strt_date=None, end_date=None, cols=None,
669
+ rslt_type=0):
670
+ """
671
+ 获取商品指数行情。
672
+
673
+ """
674
+
675
+ int_param = []
676
+ float_param = ['open_px', 'high_px', 'low_px', 'close_px']
677
+ if cols:
678
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
679
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
680
+ else:
681
+ cols = [
682
+ 'scr_code', 'trade_date', 'scr_num', 'mkt_code',
683
+ 'open_px', 'high_px', 'low_px', 'close_px'
684
+ ]
685
+
686
+ if scr_num_list:
687
+ params = {
688
+ "scr_num_list": scr_num_list,
689
+ "strt_date": strt_date,
690
+ "end_date": end_date,
691
+ "cols": cols,
692
+ "rslt_type": rslt_type,
693
+ "int_param": int_param,
694
+ "float_param": float_param
695
+ }
696
+ return get_data("get_comm_indx_quot", **params)
697
+ else:
698
+ warnings.warn("函数[get_commodity_index_quote]的参数(scr_num_list)为必填项")
699
+ return None
700
+
701
+
702
+ def get_security_index_quote(scr_num_list, strt_date=None, end_date=None, cols=None, rslt_type=0):
703
+ """
704
+ 获取证券指数行情。
705
+
706
+ """
707
+
708
+ int_param = []
709
+ float_param = [
710
+ 'preclose_px', 'open_px', 'high_px', 'low_px', 'close_px',
711
+ 'trd_vol', 'trd_amt', 'chg_pct'
712
+ ]
713
+ if cols:
714
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
715
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
716
+ else:
717
+ cols = [
718
+ 'scr_code', 'trade_date', 'scr_num', 'mkt_code',
719
+ 'preclose_px', 'open_px', 'high_px', 'low_px', 'close_px',
720
+ 'trd_vol', 'trd_amt', 'chg_pct'
721
+ ]
722
+
723
+ fix_cols = ['scr_num']
724
+ current_date = get_current_date()
725
+ if strt_date is None and end_date is None:
726
+ df = get_exchange_calendar('XSHG', end_date=current_date, trdy_flag=1)
727
+ if df.shape[0] > 2:
728
+ strt_date = end_date = df['busi_date'].tolist()[-2]
729
+ else:
730
+ strt_date = end_date = current_date
731
+ elif strt_date is None:
732
+ strt_date = end_date
733
+ elif end_date is None:
734
+ end_date = strt_date
735
+
736
+ if isinstance(cols, str):
737
+ cols = cols.split(',')
738
+ tmp_cols = fix_cols + cols
739
+ cols = list(set(tmp_cols))
740
+ cols.sort(key=tmp_cols.index)
741
+
742
+ if scr_num_list:
743
+
744
+ if isinstance(scr_num_list, list):
745
+ scr_num_list = ','.join(scr_num_list)
746
+
747
+ params = {
748
+ "scr_num_list": scr_num_list,
749
+ "strt_date": strt_date,
750
+ "end_date": end_date,
751
+ "cols": cols,
752
+ "rslt_type": rslt_type,
753
+ "int_param": int_param,
754
+ "float_param": float_param
755
+ }
756
+ return get_data("get_scr_indx_quot", **params)
757
+ else:
758
+ warnings.warn("函数[get_security_index_quote]的参数(scr_num_list)为必填项")
759
+ return None
760
+
761
+
762
+ # ================================= 后续开放内容 ================================= #
763
+ def get_ins_basc_info(ins_num=None, ins_abbr=None, ins_fn=None, unif_soci_cred_code=None, cols=None, rslt_type=0):
764
+ """
765
+ 获取公司基本信息。
766
+
767
+ """
768
+
769
+ int_param = []
770
+ float_param = ['reg_cptl']
771
+ if cols:
772
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
773
+ float_param = list({'reg_cptl'}.intersection(set(convert_fields(cols))))
774
+ else:
775
+ cols = [
776
+ 'ins_num', 'ins_fn', 'ins_abbr', 'eng_name', 'eng_abbr',
777
+ 'cont_addr', 'main_busi', 'legp_rep_name', 'setp_date', 'reg_addr',
778
+ 'reg_cptl', 'reg_crrc', 'eml', 'corp_web', 'cont_tel',
779
+ 'fax_num', 'boar_scry_name', 'unif_soci_cred_code', 'ins_savc_stat', 'ins_clas_code'
780
+ ]
781
+
782
+ params = {
783
+ "ins_num": ins_num,
784
+ "ins_abbr": ins_abbr,
785
+ "ins_fn": ins_fn,
786
+ "unif_soci_cred_code": unif_soci_cred_code,
787
+ "cols": cols,
788
+ "rslt_type": rslt_type,
789
+ "int_param": int_param,
790
+ "float_param": float_param
791
+ }
792
+ return get_data("get_ins_basc_info", **params)
793
+
794
+
795
+ def get_stk_susp_info(intv_strt_date=None, intv_end_date=None, cols=None, rslt_type=0):
796
+ """
797
+ 获取证券停牌信息。也可以根据日期范围查询出在这段时间内持续停牌的证券,例如起始日期、结束日期设置为同一天,可以查询出
798
+ 当天停牌的所有证券。
799
+
800
+ """
801
+
802
+ int_param = ['cont_susp_days']
803
+ float_param = []
804
+ if cols:
805
+ int_param = list({'cont_susp_days'}.intersection(set(convert_fields(cols))))
806
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
807
+ else:
808
+ cols = ['trad_date', 'scr_code', 'scr_num', 'scr_abbr', 'mkt_code', 'cont_susp_days']
809
+
810
+ params = {
811
+ "intv_strt_date": intv_strt_date,
812
+ "intv_end_date": intv_end_date,
813
+ "cols": cols,
814
+ "rslt_type": rslt_type,
815
+ "int_param": int_param,
816
+ "float_param": float_param
817
+ }
818
+ return get_data("get_stk_susp_info", **params)
819
+
820
+
821
+ def get_stk_st_flag(intv_strt_date=None, intv_end_date=None, cols=None, rslt_type=0):
822
+ """
823
+ 获取股票交易代码(支持多值输入),选择查询开始日期与结束日期,获取股票在一段时间ST标记信息。
824
+
825
+ """
826
+
827
+ int_param = ['cont_st_days']
828
+ float_param = []
829
+ if cols:
830
+ int_param = list({'cont_st_days'}.intersection(set(convert_fields(cols))))
831
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
832
+ else:
833
+ cols = [
834
+ 'trad_date', 'scr_code', 'scr_num', 'scr_abbr', 'mkt_code',
835
+ 'stk_risk_chg_type_code', 'cont_st_days'
836
+ ]
837
+
838
+ params = {
839
+ "intv_strt_date": intv_strt_date,
840
+ "intv_end_date": intv_end_date,
841
+ "cols": cols,
842
+ "rslt_type": rslt_type,
843
+ "int_param": int_param,
844
+ "float_param": float_param
845
+ }
846
+ return get_data("get_stk_st_flag", **params)
847
+
848
+
849
+ def get_stk_basc_affi(scr_num_list=None, affi_strt_date=None, affi_end_date=None, cols=None, rslt_type=0):
850
+ """
851
+ 获取沪深股票公告详细信息,包括公告来源、公告标题、公告链接、公告日期、公告对应代码。
852
+
853
+ """
854
+
855
+ int_param = []
856
+ float_param = []
857
+ if cols:
858
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
859
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
860
+ else:
861
+ cols = [
862
+ 'scr_code', 'scr_num', 'scr_abbr', 'mkt_code', 'affi_date',
863
+ 'end_date', 'affi_titl', 'affi_link', 'ins_num'
864
+ ]
865
+
866
+ if scr_num_list:
867
+ params = {
868
+ "scr_num_list": scr_num_list,
869
+ "affi_strt_date": affi_strt_date,
870
+ "affi_end_date": affi_end_date,
871
+ "cols": cols,
872
+ "rslt_type": rslt_type,
873
+ "int_param": int_param,
874
+ "float_param": float_param
875
+ }
876
+ return get_data("get_stk_basc_affi", **params)
877
+ else:
878
+ warnings.warn("函数[get_stk_basc_affi]的参数(scr_num_list)为必填项")
879
+ if rslt_type == 0:
880
+ return pd.DataFrame()
881
+ else:
882
+ return np.empty(0)
883
+
884
+
885
+ def get_stk_sect_info(scr_num_list, cols=None, rslt_type=0):
886
+ """
887
+ 获取沪深股票所属板块信息
888
+
889
+ """
890
+
891
+ int_param = ['sect_code']
892
+ float_param = []
893
+ if cols:
894
+ int_param = list({'sect_code'}.intersection(set(convert_fields(cols))))
895
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
896
+ else:
897
+ cols = ['scr_num', 'in_date', 'dele_date', 'sect_code', 'sect_name']
898
+
899
+ if scr_num_list:
900
+ params = {
901
+ "scr_num_list": scr_num_list,
902
+ "cols": cols,
903
+ "rslt_type": rslt_type,
904
+ "int_param": int_param,
905
+ "float_param": float_param
906
+ }
907
+ return get_data("get_stk_sect_info", **params)
908
+ else:
909
+ warnings.warn("函数[get_stk_sect_info]的参数(scr_num_list)为必填项")
910
+ if rslt_type == 0:
911
+ return pd.DataFrame()
912
+ else:
913
+ return np.empty(0)
914
+
915
+
916
+ def get_bsht(scr_num_list, rept_type=None, rept_merg_flag=None, strt_date='19900101', end_date=None,
917
+ date_type='1', cols=None, rslt_type=0):
918
+ """
919
+ 1、根据2007年新会计准则制定的合并资产负债表模板,收集了2007年以来沪深上市公司定期报告中各个会计期间的资产负
920
+ 债表数据; 2、仅收集合并报表数据,包括期末和期初数据; 3、如果上市公司对外财务报表进行更正,调整,均有采集并对外展示; 4、本表中单位为人民币元; 5、每季更新。
921
+
922
+ """
923
+
924
+ int_param = []
925
+ float_param = [
926
+ 'crrc_cptl', 'bal_clr', 'lbofi', 'trd_finl_ast', 'recv_bill', 'recv_acct', 'pre_pay_fund',
927
+ 'recv_prem', 'recv_resr_acct', 'recv_resr_agmt_rsrv', 'recv_intr', 'recv_divd', 'oth_recv_acct',
928
+ 'purc_rese_finl_ast', 'invt', 'one_year_not_liqd_ast', 'oth_liqd_ast', 'curr_ast', 'gant_loan_advm',
929
+ 'avl_sale_finl_ast', 'hmi_ivsm', 'long_recv_acct', 'long_stor_ivsm', 'ivsm_estt', 'fix_ast',
930
+ 'ucst_proj', 'proj_matr', 'fix_ast_disp', 'prod_bilg_matr', 'olga_ast', 'immt_ast', 'dev_pay',
931
+ 'gdwl', 'long_prep_pay_fee', 'defr_tax_ast', 'oth_not_liqd_ast', 'not_liqd_ast', 'ast', 'shor_lend',
932
+ 'borw_pboc', 'absb_deps_intb_deps', 'borw_cptl', 'trd_finl_liab', 'payb_bill', 'payb_acct',
933
+ 'pre_recv_acct', 'sell_repo_st', 'payb_fee', 'payb_empl_saly', 'payb_fax', 'payb_intr', 'payb_divid',
934
+ 'oth_payb_acct', 'payb_resr_acct', 'insr_agmt_rsrv', 'agt_trd_scr_fund', 'agt_undr_scr_fund',
935
+ 'one_year_not_liqd_liab', 'oth_liqd_liab', 'liqd_liab', 'long_loan', 'payb_bond', 'long_acct_payb',
936
+ 'spcl_acct_apyb', 'expe_liab', 'defr_inct_liab', 'other_not_liqd_liab', 'not_liqd_liab', 'liab',
937
+ 'paid_capi', 'capi_resf', 'inv_stk', 'spcl_acct_apyb', 'surp_resf', 'norm_risk_prep', 'un_assn_prof',
938
+ 'repr_cnvr_diff', 'attr_prn_shah_evol', 'mir_num', 'shah_equi', 'liab_shah_equi', 'cash_pobc_fund',
939
+ 'intb_dpsi', 'prcm', 'devd_prcm_ast', 'fin_leas_recv_acct', 'recv_acct_ivsm', 'oth_ast',
940
+ 'intb_oth_finl_ins_dpsi', 'devd_finl_liab', 'absd_dpsi', 'oth_liab', 'recv_subg_recv',
941
+ 'recv_resr_uexp_duty_rsrv', 'recv_resr_otdl_rsrv', 'recv_resr_life_duty_rsrv',
942
+ 'recv_resr_long_helh_rsrv', 'ins_cust_plg_loan', 'term_deps', 'recg_capi_marg', 'alne_acct_ast',
943
+ 'pre_recv_prem', 'payb_clam', 'payb_insr_plcy_divd', 'insr_cust_fund_ivsm', 'uexp_duty_rsrv',
944
+ 'otdl_rsrv', 'life_insr_duty_rsrv', 'long_helh_insr_duty_rsrv', 'alne_acct_liab', 'cust_cptl_dpsi',
945
+ 'cust_pros_dpsi', 'marg', 'trd_seat_pay', 'plg_loan', 'not_liqd_liab_pref_stk',
946
+ 'not_liqd_liab_perp_bond', 'shah_equi_pref_stk', 'shah_equi_perp_bond', 'shah_equi_trea_stk',
947
+ 'shah_equi_spcl_proj', 'hold_prep_sale_liab', 'esti_fee', 'long_payb_emp_slry', 'defr_incm'
948
+ ]
949
+ if cols:
950
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
951
+ float_param = list({
952
+ 'crrc_cptl', 'bal_clr', 'lbofi', 'trd_finl_ast', 'recv_bill', 'recv_acct', 'pre_pay_fund', 'recv_prem',
953
+ 'recv_resr_acct', 'recv_resr_agmt_rsrv', 'recv_intr', 'recv_divd', 'oth_recv_acct', 'purc_rese_finl_ast',
954
+ 'invt', 'one_year_not_liqd_ast', 'oth_liqd_ast', 'curr_ast', 'gant_loan_advm', 'avl_sale_finl_ast',
955
+ 'hmi_ivsm', 'long_recv_acct', 'long_stor_ivsm', 'ivsm_estt', 'fix_ast', 'ucst_proj', 'proj_matr',
956
+ 'fix_ast_disp', 'prod_bilg_matr', 'olga_ast', 'immt_ast', 'dev_pay', 'gdwl', 'long_prep_pay_fee',
957
+ 'defr_tax_ast', 'oth_not_liqd_ast', 'not_liqd_ast', 'ast', 'shor_lend', 'borw_pboc', 'absb_deps_intb_deps',
958
+ 'borw_cptl', 'trd_finl_liab', 'payb_bill', 'payb_acct', 'pre_recv_acct', 'sell_repo_st', 'payb_fee',
959
+ 'payb_empl_saly', 'payb_fax', 'payb_intr', 'payb_divid', 'oth_payb_acct', 'payb_resr_acct',
960
+ 'insr_agmt_rsrv', 'agt_trd_scr_fund', 'agt_undr_scr_fund', 'one_year_not_liqd_liab', 'oth_liqd_liab',
961
+ 'liqd_liab', 'long_loan', 'payb_bond', 'long_acct_payb', 'spcl_acct_apyb', 'expe_liab', 'defr_inct_liab',
962
+ 'other_not_liqd_liab', 'not_liqd_liab', 'liab', 'paid_capi', 'capi_resf', 'inv_stk', 'spcl_acct_apyb',
963
+ 'surp_resf', 'norm_risk_prep', 'un_assn_prof', 'repr_cnvr_diff', 'attr_prn_shah_evol', 'mir_num',
964
+ 'shah_equi', 'liab_shah_equi', 'cash_pobc_fund', 'intb_dpsi', 'prcm', 'devd_prcm_ast',
965
+ 'fin_leas_recv_acct', 'recv_acct_ivsm', 'oth_ast', 'intb_oth_finl_ins_dpsi', 'devd_finl_liab', 'absd_dpsi',
966
+ 'oth_liab', 'recv_subg_recv', 'recv_resr_uexp_duty_rsrv', 'recv_resr_otdl_rsrv',
967
+ 'recv_resr_life_duty_rsrv', 'recv_resr_long_helh_rsrv', 'ins_cust_plg_loan', 'term_deps', 'recg_capi_marg',
968
+ 'alne_acct_ast', 'pre_recv_prem', 'payb_clam', 'payb_insr_plcy_divd', 'insr_cust_fund_ivsm',
969
+ 'uexp_duty_rsrv', 'otdl_rsrv', 'life_insr_duty_rsrv', 'long_helh_insr_duty_rsrv', 'alne_acct_liab',
970
+ 'cust_cptl_dpsi', 'cust_pros_dpsi', 'marg', 'trd_seat_pay', 'plg_loan', 'not_liqd_liab_pref_stk',
971
+ 'not_liqd_liab_perp_bond', 'shah_equi_pref_stk', 'shah_equi_perp_bond', 'shah_equi_trea_stk',
972
+ 'shah_equi_spcl_proj', 'hold_prep_sale_liab', 'esti_fee', 'long_payb_emp_slry', 'defr_incm'}.intersection(
973
+ set(convert_fields(cols))))
974
+ else:
975
+ cols = [
976
+ 'scr_num', 'scr_code', 'scr_abbr', 'mkt_code', 'rept_type', 'affi_date', 'end_date', 'rept_merg_flag',
977
+ 'rept_adj_flag', 'ins_attr_code', 'crrc_cptl', 'bal_clr', 'lbofi', 'trd_finl_ast', 'recv_bill', 'recv_acct',
978
+ 'pre_pay_fund', 'recv_prem', 'recv_resr_acct', 'recv_resr_agmt_rsrv', 'recv_intr', 'recv_divd',
979
+ 'oth_recv_acct', 'purc_rese_finl_ast', 'invt', 'one_year_not_liqd_ast', 'oth_liqd_ast', 'curr_ast',
980
+ 'gant_loan_advm', 'avl_sale_finl_ast', 'hmi_ivsm', 'long_recv_acct', 'long_stor_ivsm', 'ivsm_estt',
981
+ 'fix_ast', 'ucst_proj', 'proj_matr', 'fix_ast_disp', 'prod_bilg_matr', 'olga_ast', 'immt_ast', 'dev_pay',
982
+ 'gdwl', 'long_prep_pay_fee', 'defr_tax_ast', 'oth_not_liqd_ast', 'not_liqd_ast', 'ast', 'shor_lend',
983
+ 'borw_pboc', 'absb_deps_intb_deps', 'borw_cptl', 'trd_finl_liab', 'payb_bill', 'payb_acct', 'pre_recv_acct',
984
+ 'sell_repo_st', 'payb_fee', 'payb_empl_saly', 'payb_fax', 'payb_intr', 'payb_divid', 'oth_payb_acct',
985
+ 'payb_resr_acct', 'insr_agmt_rsrv', 'agt_trd_scr_fund', 'agt_undr_scr_fund', 'one_year_not_liqd_liab',
986
+ 'oth_liqd_liab', 'liqd_liab', 'long_loan', 'payb_bond', 'long_acct_payb', 'spcl_acct_payb', 'expe_liab',
987
+ 'defr_inct_liab', 'other_not_liqd_liab', 'not_liqd_liab', 'liab', 'paid_capi', 'capi_resf', 'inv_stk',
988
+ 'spcl_acct_rsrv', 'surp_resf', 'norm_risk_prep', 'un_assn_prof', 'repr_cnvr_diff', 'attr_prn_shah_evol',
989
+ 'mir_num', 'shah_equi', 'liab_shah_equi', 'cash_pobc_fund', 'intb_dpsi', 'prcm', 'devd_prcm_ast',
990
+ 'fin_leas_recv_acct', 'recv_acct_ivsm', 'oth_ast', 'intb_oth_finl_ins_dpsi', 'devd_finl_liab', 'absd_dpsi',
991
+ 'oth_liab', 'recv_subg_recv', 'recv_resr_uexp_duty_rsrv', 'recv_resr_otdl_rsrv', 'recv_resr_life_duty_rsrv',
992
+ 'recv_resr_long_helh_rsrv', 'ins_cust_plg_loan', 'term_deps', 'recg_capi_marg', 'alne_acct_ast',
993
+ 'pre_recv_prem', 'payb_clam', 'payb_insr_plcy_divd', 'insr_cust_fund_ivsm', 'uexp_duty_rsrv', 'otdl_rsrv',
994
+ 'life_insr_duty_rsrv', 'long_helh_insr_duty_rsrv', 'alne_acct_liab', 'cust_cptl_dpsi', 'cust_pros_dpsi',
995
+ 'marg', 'trd_seat_pay', 'plg_loan', 'not_liqd_liab_pref_stk', 'not_liqd_liab_perp_bond',
996
+ 'shah_equi_pref_stk', 'shah_equi_perp_bond', 'shah_equi_trea_stk', 'shah_equi_spcl_proj',
997
+ 'hold_prep_sale_liab', 'esti_fee', 'long_payb_emp_slry', 'defr_incm'
998
+ ]
999
+ if scr_num_list:
1000
+ params = {
1001
+ "scr_num_list": scr_num_list,
1002
+ "rept_type": rept_type,
1003
+ "rept_merg_flag": rept_merg_flag,
1004
+ "strt_date": strt_date,
1005
+ "end_date": end_date,
1006
+ "date_type": date_type,
1007
+ "cols": cols,
1008
+ "rslt_type": rslt_type,
1009
+ "int_param": int_param,
1010
+ "float_param": float_param
1011
+ }
1012
+ return get_data("get_bsht", **params)
1013
+ else:
1014
+ warnings.warn("函数[get_bsht]的参数(scr_num_list)为必填项")
1015
+ if rslt_type == 0:
1016
+ return pd.DataFrame()
1017
+ else:
1018
+ return np.empty(0)
1019
+
1020
+
1021
+ def get_cfst(scr_num_list, rept_type=None, rept_merg_flag=None, strt_date='19900101', end_date=None,
1022
+ date_type='1', cols=None, rslt_type=0):
1023
+ """
1024
+ 1、根据2007年新会计准则制定的合并现金流量表模板,收集了2007年以来沪深上市公司定期报告中各个会计期间的现金流
1025
+ 量表数据; 2、仅收集合并报表数据,包括本期和上期数据; 3、如果上市公司对外财务报表进行更正,调整,均有采集并对外展示; 4、本表中单位为人民币元; 5、每季更新。
1026
+
1027
+ """
1028
+
1029
+ int_param = []
1030
+ float_param = [
1031
+ 'cash_recv_sale', 'cust_dpsi_intb_dpsi_incr', 'pboc_loan_incr', 'oth_fin_brow_amt_incr',
1032
+ 'cash_recv_prem_in', 'net_cash_resr_busi', 'net_incr_insd_dpst_ivsm', 'net_incr_deal_trd_finl_ast',
1033
+ 'cash_recv_intr_fee', 'brow_amt_net_incr', 'repo_amt_net_incr', 'tax_retu_recv',
1034
+ 'oth_cash_recv_oper', 'cash_in_oper', 'cash_pay_purc_merc_serv', 'net_incr_loan_advn_cust',
1035
+ 'dpst_pboc_intb_net_incr', 'cash_pay_agmt_comp', 'cash_pay_intr_fee', 'inpy_divd_pay',
1036
+ 'cash_pay_emp', 'cash_pay_tax', 'oth_cash_pay_oper', 'cash_out_oper', 'net_cash_oper',
1037
+ 'cash_recv_ivsm', 'cash_recv_ivsm_payf', 'cash_recv_deal_ast', 'cash_recv_deal_sub_oth',
1038
+ 'oth_cash_recv_ivsm', 'cash_in_ivsm', 'cash_pay_purc_ast', 'cash_pay_ivsm', 'plg_loan_net_incr',
1039
+ 'cash_recv_sub_pay', 'cash_pay_ivsm_oth', 'cash_out_ivsm', 'net_cash_ivsm', 'cash_recv_absb_ivsm',
1040
+ 'cash_recv_sub_absb_shah', 'loan_recv', 'cash_recv_bond_iss', 'oth_cash_recv_fin', 'cash_in_fin',
1041
+ 'cash_pay_debt', 'cash_pay_prof_intr', 'sub_pay_prof_intr', 'oth_cash_pay_fin', 'cash_out_fin',
1042
+ 'net_cash_fin', 'er_chg_efft_cash_eq', 'cash_eq_net_incr', 'cash_eq', 'bgng_cash_eq_bal',
1043
+ 'end_cash_eq_bal', 'gant_loan_advm_redc', 'dpst_pboc_intb_redc', 'oth_fin_lend_amt_redc',
1044
+ 'avl_sale_finl_ast_incr', 'net_prof', 'ast_ipoa_prep', 'fix_ipoa_depr', 'imtr_ast_shr',
1045
+ 'long_prep_fee_shr', 'prep_fee_redc', 'pre_fee_incr', 'fix_immt_oth_ast_loss',
1046
+ 'fix_ipoa_depr_abnd_loss', 'fv_chg_loss', 'fin_fee', 'ivsm_loss', 'defr_inct_ast_redc',
1047
+ 'defr_inct_liab_incr', 'inv_redc', 'oper_recv_proj_redc', 'oper_recv_proj_incr', 'oth',
1048
+ 'debt_tran_capt', 'one_traf_corp_bond', 'fin_leas_fix_ipoa', 'cash_end_bal', 'cash_bgng_bal',
1049
+ 'cash_eqvl_end_bal', 'cash_eqvl_bgng_bal', 'cash_cash_eqvl_net_incr'
1050
+ ]
1051
+ if cols:
1052
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
1053
+ float_param = list({
1054
+ 'cash_recv_sale', 'cust_dpsi_intb_dpsi_incr', 'pboc_loan_incr', 'oth_fin_brow_amt_incr',
1055
+ 'cash_recv_prem_in', 'net_cash_resr_busi', 'net_incr_insd_dpst_ivsm',
1056
+ 'net_incr_deal_trd_finl_ast', 'cash_recv_intr_fee', 'brow_amt_net_incr',
1057
+ 'repo_amt_net_incr', 'tax_retu_recv', 'oth_cash_recv_oper', 'cash_in_oper',
1058
+ 'cash_pay_purc_merc_serv', 'net_incr_loan_advn_cust', 'dpst_pboc_intb_net_incr',
1059
+ 'cash_pay_agmt_comp', 'cash_pay_intr_fee', 'inpy_divd_pay', 'cash_pay_emp', 'cash_pay_tax',
1060
+ 'oth_cash_pay_oper', 'cash_out_oper', 'net_cash_oper', 'cash_recv_ivsm',
1061
+ 'cash_recv_ivsm_payf', 'cash_recv_deal_ast', 'cash_recv_deal_sub_oth', 'oth_cash_recv_ivsm',
1062
+ 'cash_in_ivsm', 'cash_pay_purc_ast', 'cash_pay_ivsm', 'plg_loan_net_incr',
1063
+ 'cash_recv_sub_pay', 'cash_pay_ivsm_oth', 'cash_out_ivsm', 'net_cash_ivsm',
1064
+ 'cash_recv_absb_ivsm', 'cash_recv_sub_absb_shah', 'loan_recv', 'cash_recv_bond_iss',
1065
+ 'oth_cash_recv_fin', 'cash_in_fin', 'cash_pay_debt', 'cash_pay_prof_intr',
1066
+ 'sub_pay_prof_intr', 'oth_cash_pay_fin', 'cash_out_fin', 'net_cash_fin',
1067
+ 'er_chg_efft_cash_eq', 'cash_eq_net_incr', 'cash_eq', 'bgng_cash_eq_bal', 'end_cash_eq_bal',
1068
+ 'gant_loan_advm_redc', 'dpst_pboc_intb_redc', 'oth_fin_lend_amt_redc',
1069
+ 'avl_sale_finl_ast_incr', 'net_prof', 'ast_ipoa_prep', 'fix_ipoa_depr', 'imtr_ast_shr',
1070
+ 'long_prep_fee_shr', 'prep_fee_redc', 'pre_fee_incr', 'fix_immt_oth_ast_loss',
1071
+ 'fix_ipoa_depr_abnd_loss', 'fv_chg_loss', 'fin_fee', 'ivsm_loss', 'defr_inct_ast_redc',
1072
+ 'defr_inct_liab_incr', 'inv_redc', 'oper_recv_proj_redc', 'oper_recv_proj_incr', 'oth',
1073
+ 'debt_tran_capt', 'one_traf_corp_bond', 'fin_leas_fix_ipoa', 'cash_end_bal',
1074
+ 'cash_bgng_bal', 'cash_eqvl_end_bal', 'cash_eqvl_bgng_bal', 'cash_cash_eqvl_net_incr'}.intersection(
1075
+ set(convert_fields(cols))))
1076
+ else:
1077
+ cols = [
1078
+ 'scr_num', 'scr_code', 'scr_abbr', 'mkt_code', 'rept_type', 'affi_date', 'end_date', 'rept_merg_flag',
1079
+ 'rept_adj_flag', 'ins_attr_code', 'cash_recv_sale', 'cust_dpsi_intb_dpsi_incr', 'pboc_loan_incr',
1080
+ 'oth_fin_brow_amt_incr', 'cash_recv_prem_in', 'net_cash_resr_busi', 'net_incr_insd_dpst_ivsm',
1081
+ 'net_incr_deal_trd_finl_ast', 'cash_recv_intr_fee', 'brow_amt_net_incr', 'repo_amt_net_incr',
1082
+ 'tax_retu_recv', 'oth_cash_recv_oper', 'cash_in_oper', 'cash_pay_purc_merc_serv', 'net_incr_loan_advn_cust',
1083
+ 'dpst_pboc_intb_net_incr', 'cash_pay_agmt_comp', 'cash_pay_intr_fee', 'inpy_divd_pay', 'cash_pay_emp',
1084
+ 'cash_pay_tax', 'oth_cash_pay_oper', 'cash_out_oper', 'net_cash_oper', 'cash_recv_ivsm',
1085
+ 'cash_recv_ivsm_payf', 'cash_recv_deal_ast', 'cash_recv_deal_sub_oth', 'oth_cash_recv_ivsm', 'cash_in_ivsm',
1086
+ 'cash_pay_purc_ast', 'cash_pay_ivsm', 'plg_loan_net_incr', 'cash_recv_sub_pay', 'cash_pay_ivsm_oth',
1087
+ 'cash_out_ivsm', 'net_cash_ivsm', 'cash_recv_absb_ivsm', 'cash_recv_sub_absb_shah', 'loan_recv',
1088
+ 'cash_recv_bond_iss', 'oth_cash_recv_fin', 'cash_in_fin', 'cash_pay_debt', 'cash_pay_prof_intr',
1089
+ 'sub_pay_prof_intr', 'oth_cash_pay_fin', 'cash_out_fin', 'net_cash_fin', 'er_chg_efft_cash_eq',
1090
+ 'cash_eq_net_incr', 'cash_eq', 'bgng_cash_eq_bal', 'end_cash_eq_bal', 'gant_loan_advm_redc',
1091
+ 'dpst_pboc_intb_redc', 'oth_fin_lend_amt_redc', 'avl_sale_finl_ast_incr', 'net_prof', 'ast_ipoa_prep',
1092
+ 'fix_ipoa_depr', 'imtr_ast_shr', 'long_prep_fee_shr', 'prep_fee_redc', 'pre_fee_incr',
1093
+ 'fix_immt_oth_ast_loss', 'fix_ipoa_depr_abnd_loss', 'fv_chg_loss', 'fin_fee', 'ivsm_loss',
1094
+ 'defr_inct_ast_redc', 'defr_inct_liab_incr', 'inv_redc', 'oper_recv_proj_redc', 'oper_recv_proj_incr',
1095
+ 'oth', 'debt_tran_capt', 'one_traf_corp_bond', 'fin_leas_fix_ipoa', 'cash_end_bal', 'cash_bgng_bal',
1096
+ 'cash_eqvl_end_bal', 'cash_eqvl_bgng_bal', 'cash_cash_eqvl_net_incr',
1097
+ ]
1098
+
1099
+ if scr_num_list:
1100
+ params = {
1101
+ "scr_num_list": scr_num_list,
1102
+ "rept_type": rept_type,
1103
+ "rept_merg_flag": rept_merg_flag,
1104
+ "strt_date": strt_date,
1105
+ "end_date": end_date,
1106
+ "date_type": date_type,
1107
+ "cols": cols,
1108
+ "rslt_type": rslt_type,
1109
+ "int_param": int_param,
1110
+ "float_param": float_param
1111
+ }
1112
+ return get_data("get_cfst", **params)
1113
+ else:
1114
+ warnings.warn("函数[get_cfst]的参数(scr_num_list)为必填项")
1115
+ if rslt_type == 0:
1116
+ return pd.DataFrame()
1117
+ else:
1118
+ return np.empty(0)
1119
+
1120
+
1121
+ def get_proft(scr_num_list, rept_type=None, rept_merg_flag=None, strt_date='19900101', end_date=None, date_type='1',
1122
+ cols=None, rslt_type=0):
1123
+ """
1124
+ 1、根据2007年新会计准则制定的合并利润表模板,收集了2007年以来沪深上市公司定期报告中各个会计期间的利润表数据
1125
+ ; 2、仅收集合并报表数据,包括本期和上期数据; 3、如果上市公司对外财务报表进行更正,调整,均有采集并对外展示; 4、本表中单位为人民币元; 5、每季更新。
1126
+
1127
+ """
1128
+
1129
+ int_param = []
1130
+ float_param = [
1131
+ 'bus_incm', 'inpt_oper_incm', 'intr_incm', 'has_earn_prem', 'chag_cms_incm', 'bus_cost',
1132
+ 'inpt_oper_cost', 'intr_pay', 'chag_cms_pay', 'surr_amt', 'comp_pay_namt', 'feth_inst_rsrv_namt',
1133
+ 'inpy_divd_pay', 'resr_fee', 'bus_tax_atta', 'sale_fee', 'mag_fee', 'fin_fee', 'imfs_loss',
1134
+ 'fair_val_chg', 'ivsm_incm_chg', 'jovs_ivsm_incm_chg', 'exch_incm', 'bus_prof', 'otfb_incm',
1135
+ 'otfb_pay', 'nofw_ast_deal_loss', 'prof_pamt', 'inct_fee', 'net_prof', 'attr_prn_comr_net_prof',
1136
+ 'min_shah_incm', 'basc_eps', 'diln_eps', 'oth_comp_eps', 'comp_eps', 'attr_prn_comr_comp_eps',
1137
+ 'attr_mish_comp_eps', 'intr_net_incm', 'net_chag_cms_incm', 'oth_busi_incm', 'busi_aep',
1138
+ 'oth_busi_cost', 'insr_busi_incm', 'resr_fee_incm', 'cede_prem', 'feth_uexp_duty_rsrv',
1139
+ 'spba_comp_pay', 'feth_insr_duty_rsrv', 'spba_insr_duty_rsrv', 'spba_resr_fee',
1140
+ 'agt_bs_secb_net_incm', 'scr_bs_undb_net_incm', 'bent_cust_asmb_net_incm', 'ast_dsps_payf',
1141
+ 'oth_payf', 'cont_oper_net_prof', 'end_oper_net_prof', 'ent_cust_asmb_net_incm'
1142
+ ]
1143
+ if cols:
1144
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
1145
+ float_param = list({
1146
+ 'bus_incm', 'inpt_oper_incm', 'intr_incm', 'has_earn_prem', 'chag_cms_incm', 'bus_cost', 'inpt_oper_cost',
1147
+ 'intr_pay', 'chag_cms_pay', 'surr_amt', 'comp_pay_namt', 'feth_inst_rsrv_namt', 'inpy_divd_pay',
1148
+ 'resr_fee', 'bus_tax_atta', 'sale_fee', 'mag_fee', 'fin_fee', 'imfs_loss', 'fair_val_chg', 'ivsm_incm_chg',
1149
+ 'jovs_ivsm_incm_chg', 'exch_incm', 'bus_prof', 'otfb_incm', 'otfb_pay', 'nofw_ast_deal_loss', 'prof_pamt',
1150
+ 'inct_fee', 'net_prof', 'attr_prn_comr_net_prof', 'min_shah_incm', 'basc_eps', 'diln_eps', 'oth_comp_eps',
1151
+ 'comp_eps', 'attr_prn_comr_comp_eps', 'attr_mish_comp_eps', 'intr_net_incm', 'net_chag_cms_incm',
1152
+ 'oth_busi_incm', 'busi_aep', 'oth_busi_cost', 'insr_busi_incm', 'resr_fee_incm', 'cede_prem',
1153
+ 'feth_uexp_duty_rsrv', 'spba_comp_pay', 'feth_insr_duty_rsrv', 'spba_insr_duty_rsrv', 'spba_resr_fee',
1154
+ 'agt_bs_secb_net_incm', 'scr_bs_undb_net_incm', 'bent_cust_asmb_net_incm', 'ast_dsps_payf', 'oth_payf',
1155
+ 'cont_oper_net_prof', 'end_oper_net_prof', 'ent_cust_asmb_net_incm'}.intersection(
1156
+ set(convert_fields(cols))))
1157
+ else:
1158
+ cols = [
1159
+ 'scr_num', 'scr_code', 'scr_abbr', 'mkt_code', 'rept_type', 'affi_date', 'end_date', 'rept_merg_flag',
1160
+ 'rept_adj_flag', 'ins_attr_code', 'bus_incm', 'inpt_oper_incm', 'intr_incm', 'has_earn_prem',
1161
+ 'chag_cms_incm', 'bus_cost', 'inpt_oper_cost', 'intr_pay', 'chag_cms_pay', 'surr_amt', 'comp_pay_namt',
1162
+ 'feth_inst_rsrv_namt', 'inpy_divd_pay', 'resr_fee', 'bus_tax_atta', 'sale_fee', 'mag_fee', 'fin_fee',
1163
+ 'imfs_loss', 'fair_val_chg', 'ivsm_incm_chg', 'jovs_ivsm_incm_chg', 'exch_incm', 'bus_prof', 'otfb_incm',
1164
+ 'otfb_pay', 'nofw_ast_deal_loss', 'prof_pamt', 'inct_fee', 'net_prof', 'attr_prn_comr_net_prof',
1165
+ 'min_shah_incm', 'basc_eps', 'diln_eps', 'oth_comp_eps', 'comp_eps', 'attr_prn_comr_comp_eps',
1166
+ 'attr_mish_comp_eps', 'intr_net_incm', 'net_chag_cms_incm', 'oth_busi_incm', 'busi_aep', 'oth_busi_cost',
1167
+ 'insr_busi_incm', 'resr_fee_incm', 'cede_prem', 'feth_uexp_duty_rsrv', 'spba_comp_pay',
1168
+ 'feth_insr_duty_rsrv', 'spba_insr_duty_rsrv', 'spba_resr_fee', 'agt_bs_secb_net_incm',
1169
+ 'scr_bs_undb_net_incm', 'bent_cust_asmb_net_incm', 'ast_dsps_payf', 'oth_payf', 'cont_oper_net_prof',
1170
+ 'end_oper_net_prof', 'ent_cust_asmb_net_incm'
1171
+ ]
1172
+ if scr_num_list:
1173
+ params = {
1174
+ "scr_num_list": scr_num_list,
1175
+ "rept_type": rept_type,
1176
+ "rept_merg_flag": rept_merg_flag,
1177
+ "strt_date": strt_date,
1178
+ "end_date": end_date,
1179
+ "date_type": date_type,
1180
+ "cols": cols,
1181
+ "rslt_type": rslt_type,
1182
+ "int_param": int_param,
1183
+ "float_param": float_param
1184
+ }
1185
+ return get_data("get_proft", **params)
1186
+ else:
1187
+ warnings.warn("函数[get_proft]的参数(scr_num_list)为必填项")
1188
+ if rslt_type == 0:
1189
+ return pd.DataFrame()
1190
+ else:
1191
+ return np.empty(0)
1192
+
1193
+
1194
+ def get_fin_indx(scr_num_list, rept_type=None, strt_date='19900101', end_date=None, date_type='1', cols=None,
1195
+ rslt_type=0):
1196
+ """
1197
+ 根据上市公司披露的财务数据计算的财务指标。
1198
+
1199
+ """
1200
+
1201
+ int_param = []
1202
+ float_param = [
1203
+ 'basc_eps', 'dilu_eps', 'eps_end_capt_dilt', 'eps_ttm', 'bps', 'ps_busi_tot_incm', 'ps_busi_incm',
1204
+ 'ps_busi_incm_ttm', 'ps_busi_prof', 'ps_btax_prof', 'ps_capi_resf', 'ps_surp_resf', 'ps_resf',
1205
+ 'ps_un_assn_prof', 'ps_dpsi_payf', 'ps_net_cash_oper', 'ps_net_cash_oper_ttm', 'ps_net_cash',
1206
+ 'ps_net_cash_ttm', 'ps_corp_cash', 'ps_shah_cash', 'roe_avg', 'roe_wght', 'roe_dilt',
1207
+ 'roe_dect_dilt', 'roe_dect_wght', 'roe_ttm', 'roa', 'roa_ttm', 'jroa', 'jroa_ttm', 'roic', 'npm',
1208
+ 'npm_ttm', 'gpm', 'gpm_ttm', 'cost_rate', 'pd_rate', 'pd_rate_ttm', 'net_prof_rate',
1209
+ 'net_prof_rate_ttm', 'busi_prof_rate', 'busi_prof_rate_ttm', 'btax_prof_rate', 'btax_prof_rate_ttm',
1210
+ 'bus_cost_rate', 'bus_cost_rate_ttm', 'sale_fee_rate', 'sale_fee_rate_ttm', 'mag_fee_rate',
1211
+ 'mag_fee_rate_ttm', 'fin_fee_rate', 'fin_fee_rate_ttm', 'imfs_loss_rate', 'imfs_loss_rate_ttm',
1212
+ 'attr_prn_net_prof', 'dect_pl_net_prof', 'btax_prof', 'btax_depr_prof', 'tot_busi_prof_rate',
1213
+ 'cost_prof_rate', 'curr_rati', 'qr', 'over_qr', 'debt_equity_rati', 'prn_shah_evol_div_liab_tot',
1214
+ 'prn_shah_evol_div_ibrg_debt', 'nv_debt_rate', 'nv_div_ibrg_debt', 'nv_div_net_debt',
1215
+ 'btax_depr_prof_div_liab_tot', 'net_cash_oper_div_liab_tot', 'net_cash_oper_div_ibrg_debt',
1216
+ 'net_cash_oper_div_curr_debt', 'net_cash_oper_div_net_debt', 'intr_prot_mult', 'liab_oper_cptl_rate',
1217
+ 'cash_debt_rati', 'basc_eps_yoy_grow', 'dilu_eps_yoy_grow', 'busi_incm_yoy_grow',
1218
+ 'busi_incm_3year_cmpl_grow_rate', 'busi_prof_yoy_grow', 'prof_pamt_yoy_grow', 'net_prof_yoy_grow',
1219
+ 'prn_net_prof_yoy_grow', 'prn_net_prof_dect_yoy_grow', 'prn_net_prof_3yr_cmpl_grat',
1220
+ 'form_5yr_prn_net_prof_avg_incr', 'net_cash_oper_yoy_grow', 'ps_net_cash_oper_yoy_grow',
1221
+ 'roe_dilt_yoy_grow', 'nv_yoy_grow', 'tot_ast_yoy_grow', 'ps_nv_relt_grow_rate',
1222
+ 'prn_shah_evol_relt_grow_rate', 'ast_sum_relt_grow_rate', 'cont_grow_rate', 'busi_pd',
1223
+ 'inv_turn_rate', 'inv_turn_days', 'recv_acct_turn_rate', 'recv_acct_turn_days',
1224
+ 'payb_acct_turn_rate', 'payb_acct_turn_days', 'curr_ast_turn_rate', 'fix_ast_turn_rate',
1225
+ 'shah_equi_turn_rate', 'tot_ast_turn_rate', 'cash_recv_sale_div_busi_incm',
1226
+ 'cash_sale_div_busi_incm_ttm', 'net_cash_oper_div_busi_incm', 'net_cash_oper_div_bus_incm_ttm',
1227
+ 'net_cash_oper_div_payf_oper', 'net_csh_oper_div_payf_oper_ttm', 'cptl_pay_div_depr',
1228
+ 'cash_eq_net_incr', 'net_cash_oper', 'cash_recv_sale', 'cash_flow', 'net_prof_cash',
1229
+ 'busi_incm_cash', 'tot_ast_cash_recc', 'ps_cash_eq', 'ps_divd', 'divd_prot_mult',
1230
+ 'cash_divd_prot_mult', 'divd_pay_rate', 'dpsi_surp_rate', 'ast_liab_rate', 'curr_ast_div_tot_ast',
1231
+ 'not_liqd_ast_tot_ast', 'fix_ast_rati', 'immt_ast_rati', 'long_loan_div_tot_ast',
1232
+ 'payb_bond_div_tot_ast', 'prn_shah_evol_div_all_cptl', 'ibrg_debt_div_all_cptl',
1233
+ 'liqd_liab_div_liab_tot', 'not_liqd_liab_div_liab_tot', 'shah_equi_rate', 'equi_mult', 'oper_cptl',
1234
+ 'long_liab_div_shah_equi_tot', 'long_ast_fit_rate', 'payf_oper_div_prof_pamt',
1235
+ 'payf_oper_div_prof_pamt_ttm', 'jovt_ivsm_payf_div_prof_pamt', 'jovt_ivsm_payf_div_prof_ttm',
1236
+ 'val_chg_div_prof_pamt', 'val_chg_div_prof_pamt_ttm', 'nopr_net_amt_div_prof_amt',
1237
+ 'nopr_net_amt_div_prof_pamt_ttm', 'inct_div_prof_pamt', 'dect_pl_net_prof_div_net_prof',
1238
+ 'equi_mult_dupont', 'prn_shah_net_prof_div_net_prof', 'net_prof_div_busi_tot_incm',
1239
+ 'net_prof_div_prof_pamt', 'prof_pamt_div_btax_prof', 'btax_prof_div_busi_tot_incm'
1240
+ ]
1241
+ if cols:
1242
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
1243
+ float_param = list(
1244
+ {'basc_eps', 'dilu_eps', 'eps_end_capt_dilt', 'eps_ttm', 'bps', 'ps_busi_tot_incm', 'ps_busi_incm',
1245
+ 'ps_busi_incm_ttm', 'ps_busi_prof', 'ps_btax_prof', 'ps_capi_resf', 'ps_surp_resf', 'ps_resf',
1246
+ 'ps_un_assn_prof', 'ps_dpsi_payf', 'ps_net_cash_oper', 'ps_net_cash_oper_ttm', 'ps_net_cash',
1247
+ 'ps_net_cash_ttm', 'ps_corp_cash', 'ps_shah_cash', 'roe_avg', 'roe_wght', 'roe_dilt', 'roe_dect_dilt',
1248
+ 'roe_dect_wght', 'roe_ttm', 'roa', 'roa_ttm', 'jroa', 'jroa_ttm', 'roic', 'npm', 'npm_ttm', 'gpm',
1249
+ 'gpm_ttm', 'cost_rate', 'pd_rate', 'pd_rate_ttm', 'net_prof_rate', 'net_prof_rate_ttm', 'busi_prof_rate',
1250
+ 'busi_prof_rate_ttm', 'btax_prof_rate', 'btax_prof_rate_ttm', 'bus_cost_rate', 'bus_cost_rate_ttm',
1251
+ 'sale_fee_rate', 'sale_fee_rate_ttm', 'mag_fee_rate', 'mag_fee_rate_ttm', 'fin_fee_rate',
1252
+ 'fin_fee_rate_ttm', 'imfs_loss_rate', 'imfs_loss_rate_ttm', 'attr_prn_net_prof', 'dect_pl_net_prof',
1253
+ 'btax_prof', 'btax_depr_prof', 'tot_busi_prof_rate', 'cost_prof_rate', 'curr_rati', 'qr', 'over_qr',
1254
+ 'debt_equity_rati', 'prn_shah_evol_div_liab_tot', 'prn_shah_evol_div_ibrg_debt', 'nv_debt_rate',
1255
+ 'nv_div_ibrg_debt', 'nv_div_net_debt', 'btax_depr_prof_div_liab_tot', 'net_cash_oper_div_liab_tot',
1256
+ 'net_cash_oper_div_ibrg_debt', 'net_cash_oper_div_curr_debt', 'net_cash_oper_div_net_debt',
1257
+ 'intr_prot_mult', 'liab_oper_cptl_rate', 'cash_debt_rati', 'basc_eps_yoy_grow', 'dilu_eps_yoy_grow',
1258
+ 'busi_incm_yoy_grow', 'busi_incm_3year_cmpl_grow_rate', 'busi_prof_yoy_grow', 'prof_pamt_yoy_grow',
1259
+ 'net_prof_yoy_grow', 'prn_net_prof_yoy_grow', 'prn_net_prof_dect_yoy_grow', 'prn_net_prof_3yr_cmpl_grat',
1260
+ 'form_5yr_prn_net_prof_avg_incr', 'net_cash_oper_yoy_grow', 'ps_net_cash_oper_yoy_grow',
1261
+ 'roe_dilt_yoy_grow', 'nv_yoy_grow', 'tot_ast_yoy_grow', 'ps_nv_relt_grow_rate',
1262
+ 'prn_shah_evol_relt_grow_rate', 'ast_sum_relt_grow_rate', 'cont_grow_rate', 'busi_pd', 'inv_turn_rate',
1263
+ 'inv_turn_days', 'recv_acct_turn_rate', 'recv_acct_turn_days', 'payb_acct_turn_rate',
1264
+ 'payb_acct_turn_days', 'curr_ast_turn_rate', 'fix_ast_turn_rate', 'shah_equi_turn_rate',
1265
+ 'tot_ast_turn_rate', 'cash_recv_sale_div_busi_incm', 'cash_sale_div_busi_incm_ttm',
1266
+ 'net_cash_oper_div_busi_incm', 'net_cash_oper_div_bus_incm_ttm', 'net_cash_oper_div_payf_oper',
1267
+ 'net_csh_oper_div_payf_oper_ttm', 'cptl_pay_div_depr', 'cash_eq_net_incr', 'net_cash_oper',
1268
+ 'cash_recv_sale', 'cash_flow', 'net_prof_cash', 'busi_incm_cash', 'tot_ast_cash_recc', 'ps_cash_eq',
1269
+ 'ps_divd', 'divd_prot_mult', 'cash_divd_prot_mult', 'divd_pay_rate', 'dpsi_surp_rate', 'ast_liab_rate',
1270
+ 'curr_ast_div_tot_ast', 'not_liqd_ast_tot_ast', 'fix_ast_rati', 'immt_ast_rati', 'long_loan_div_tot_ast',
1271
+ 'payb_bond_div_tot_ast', 'prn_shah_evol_div_all_cptl', 'ibrg_debt_div_all_cptl', 'liqd_liab_div_liab_tot',
1272
+ 'not_liqd_liab_div_liab_tot', 'shah_equi_rate', 'equi_mult', 'oper_cptl', 'long_liab_div_shah_equi_tot',
1273
+ 'long_ast_fit_rate', 'payf_oper_div_prof_pamt', 'payf_oper_div_prof_pamt_ttm',
1274
+ 'jovt_ivsm_payf_div_prof_pamt', 'jovt_ivsm_payf_div_prof_ttm', 'val_chg_div_prof_pamt',
1275
+ 'val_chg_div_prof_pamt_ttm', 'nopr_net_amt_div_prof_amt', 'nopr_net_amt_div_prof_pamt_ttm',
1276
+ 'inct_div_prof_pamt', 'dect_pl_net_prof_div_net_prof', 'equi_mult_dupont',
1277
+ 'prn_shah_net_prof_div_net_prof', 'net_prof_div_busi_tot_incm', 'net_prof_div_prof_pamt',
1278
+ 'prof_pamt_div_btax_prof', 'btax_prof_div_busi_tot_incm'}.intersection(set(convert_fields(cols))))
1279
+ else:
1280
+ cols = [
1281
+ 'scr_num', 'scr_code', 'scr_abbr', 'mkt_code', 'rept_type', 'affi_date', 'end_date',
1282
+ 'basc_eps', 'dilu_eps', 'eps_end_capt_dilt', 'eps_ttm', 'bps', 'ps_busi_tot_incm', 'ps_busi_incm',
1283
+ 'ps_busi_incm_ttm', 'ps_busi_prof', 'ps_btax_prof', 'ps_capi_resf', 'ps_surp_resf', 'ps_resf',
1284
+ 'ps_un_assn_prof', 'ps_dpsi_payf', 'ps_net_cash_oper', 'ps_net_cash_oper_ttm', 'ps_net_cash',
1285
+ 'ps_net_cash_ttm', 'ps_corp_cash', 'ps_shah_cash', 'roe_avg', 'roe_wght', 'roe_dilt', 'roe_dect_dilt',
1286
+ 'roe_dect_wght', 'roe_ttm', 'roa', 'roa_ttm', 'jroa', 'jroa_ttm', 'roic', 'npm', 'npm_ttm', 'gpm',
1287
+ 'gpm_ttm', 'cost_rate', 'pd_rate', 'pd_rate_ttm', 'net_prof_rate', 'net_prof_rate_ttm', 'busi_prof_rate',
1288
+ 'busi_prof_rate_ttm', 'btax_prof_rate', 'btax_prof_rate_ttm', 'bus_cost_rate', 'bus_cost_rate_ttm',
1289
+ 'sale_fee_rate', 'sale_fee_rate_ttm', 'mag_fee_rate', 'mag_fee_rate_ttm', 'fin_fee_rate',
1290
+ 'fin_fee_rate_ttm', 'imfs_loss_rate', 'imfs_loss_rate_ttm', 'attr_prn_net_prof', 'dect_pl_net_prof',
1291
+ 'btax_prof', 'btax_depr_prof', 'tot_busi_prof_rate', 'cost_prof_rate', 'curr_rati', 'qr', 'over_qr',
1292
+ 'debt_equity_rati', 'prn_shah_evol_div_liab_tot', 'prn_shah_evol_div_ibrg_debt', 'nv_debt_rate',
1293
+ 'nv_div_ibrg_debt', 'nv_div_net_debt', 'btax_depr_prof_div_liab_tot', 'net_cash_oper_div_liab_tot',
1294
+ 'net_cash_oper_div_ibrg_debt', 'net_cash_oper_div_curr_debt', 'net_cash_oper_div_net_debt',
1295
+ 'intr_prot_mult', 'liab_oper_cptl_rate', 'cash_debt_rati', 'basc_eps_yoy_grow', 'dilu_eps_yoy_grow',
1296
+ 'busi_incm_yoy_grow', 'busi_incm_3year_cmpl_grow_rate', 'busi_prof_yoy_grow', 'prof_pamt_yoy_grow',
1297
+ 'net_prof_yoy_grow', 'prn_net_prof_yoy_grow', 'prn_net_prof_dect_yoy_grow', 'prn_net_prof_3yr_cmpl_grat',
1298
+ 'form_5yr_prn_net_prof_avg_incr', 'net_cash_oper_yoy_grow', 'ps_net_cash_oper_yoy_grow',
1299
+ 'roe_dilt_yoy_grow', 'nv_yoy_grow', 'tot_ast_yoy_grow', 'ps_nv_relt_grow_rate',
1300
+ 'prn_shah_evol_relt_grow_rate', 'ast_sum_relt_grow_rate', 'cont_grow_rate', 'busi_pd', 'inv_turn_rate',
1301
+ 'inv_turn_days', 'recv_acct_turn_rate', 'recv_acct_turn_days', 'payb_acct_turn_rate', 'payb_acct_turn_days',
1302
+ 'curr_ast_turn_rate', 'fix_ast_turn_rate', 'shah_equi_turn_rate', 'tot_ast_turn_rate',
1303
+ 'cash_recv_sale_div_busi_incm', 'cash_sale_div_busi_incm_ttm', 'net_cash_oper_div_busi_incm',
1304
+ 'net_cash_oper_div_bus_incm_ttm', 'net_cash_oper_div_payf_oper', 'net_csh_oper_div_payf_oper_ttm',
1305
+ 'cptl_pay_div_depr', 'cash_eq_net_incr', 'net_cash_oper', 'cash_recv_sale', 'cash_flow', 'net_prof_cash',
1306
+ 'busi_incm_cash', 'tot_ast_cash_recc', 'ps_cash_eq', 'ps_divd', 'divd_prot_mult', 'cash_divd_prot_mult',
1307
+ 'divd_pay_rate', 'dpsi_surp_rate', 'ast_liab_rate', 'curr_ast_div_tot_ast', 'not_liqd_ast_tot_ast',
1308
+ 'fix_ast_rati', 'immt_ast_rati', 'long_loan_div_tot_ast', 'payb_bond_div_tot_ast',
1309
+ 'prn_shah_evol_div_all_cptl', 'ibrg_debt_div_all_cptl', 'liqd_liab_div_liab_tot',
1310
+ 'not_liqd_liab_div_liab_tot', 'shah_equi_rate', 'equi_mult', 'oper_cptl', 'long_liab_div_shah_equi_tot',
1311
+ 'long_ast_fit_rate', 'payf_oper_div_prof_pamt', 'payf_oper_div_prof_pamt_ttm',
1312
+ 'jovt_ivsm_payf_div_prof_pamt', 'jovt_ivsm_payf_div_prof_ttm', 'val_chg_div_prof_pamt',
1313
+ 'val_chg_div_prof_pamt_ttm', 'nopr_net_amt_div_prof_amt', 'nopr_net_amt_div_prof_pamt_ttm',
1314
+ 'inct_div_prof_pamt', 'dect_pl_net_prof_div_net_prof', 'equi_mult_dupont', 'prn_shah_net_prof_div_net_prof',
1315
+ 'net_prof_div_busi_tot_incm', 'net_prof_div_prof_pamt', 'prof_pamt_div_btax_prof',
1316
+ 'btax_prof_div_busi_tot_incm',
1317
+ ]
1318
+ if scr_num_list:
1319
+ params = {
1320
+ "scr_num_list": scr_num_list,
1321
+ "rept_type": rept_type,
1322
+ "strt_date": strt_date,
1323
+ "end_date": end_date,
1324
+ "date_type": date_type,
1325
+ "cols": cols,
1326
+ "rslt_type": rslt_type,
1327
+ "int_param": int_param,
1328
+ "float_param": float_param
1329
+ }
1330
+ return get_data("get_fin_indx", **params)
1331
+ else:
1332
+ warnings.warn("函数[get_fin_indx]的参数(scr_num_list)为必填项")
1333
+ if rslt_type == 0:
1334
+ return pd.DataFrame()
1335
+ else:
1336
+ return np.empty(0)
1337
+
1338
+
1339
+ def get_stk_plac_info(scr_num_list, affi_strt_date='19900101', affi_end_date=None, strt_equi_reg_date='19900101',
1340
+ end_equi_reg_date=None, cols=None, rslt_type=0):
1341
+ """
1342
+ 获取股票历次配股的基本信息包含每次配股方案的内容、方案进度、历史配股预案公布次数以及最终是否配股成功。
1343
+
1344
+ """
1345
+
1346
+ int_param = ['plac_vol', 'plac_capt_radx']
1347
+ float_param = ['ps_plac_num', 'plac_prc']
1348
+ if cols:
1349
+ int_param = list({'plac_vol', 'plac_capt_radx'}.intersection(set(convert_fields(cols))))
1350
+ float_param = list({'ps_plac_num', 'plac_prc'}.intersection(set(convert_fields(cols))))
1351
+ else:
1352
+ cols = [
1353
+ 'scr_code', 'scr_num', 'scr_abbr', 'mkt_code', 'excr_date', 'affi_date', 'equi_reg_date', 'ps_plac_num',
1354
+ 'plac_prc', 'plac_scr_code', 'plac_pay_strt_date', 'plac_pay_end_date', 'plac_list_date', 'plac_vol',
1355
+ 'plac_capt_radx',
1356
+ ]
1357
+ if scr_num_list:
1358
+ params = {
1359
+ "scr_num_list": scr_num_list,
1360
+ "affi_strt_date": affi_strt_date,
1361
+ "affi_end_date": affi_end_date,
1362
+ "strt_equi_reg_date": strt_equi_reg_date,
1363
+ "end_equi_reg_date": end_equi_reg_date,
1364
+ "cols": cols,
1365
+ "rslt_type": rslt_type,
1366
+ "int_param": int_param,
1367
+ "float_param": float_param
1368
+ }
1369
+ return get_data("get_stk_plac_info", **params)
1370
+ else:
1371
+ warnings.warn("函数[get_stk_plac_info]的参数(scr_num_list)为必填项")
1372
+ if rslt_type == 0:
1373
+ return pd.DataFrame()
1374
+ else:
1375
+ return np.empty(0)
1376
+
1377
+
1378
+ def get_stk_divd_info(scr_num_list=None, excr_date=None, affi_strt_date='19900101', affi_end_date=None,
1379
+ reg_strt_date='19900101', reg_end_date=None, bons_type=None, cols=None, rslt_type=0):
1380
+ """
1381
+ 获取股票历次分红(派现、送股、转增股)的基本信息包含历次分红预案的内容、实施进展情况以及历史宣告分红次数。
1382
+
1383
+ """
1384
+
1385
+ int_param = ['bons_type', 'bons_capt_radx']
1386
+ float_param = ['ps_divd', 'atax_ps_divd', 'ps_gant_num', 'ps_tran_incr_num', 'ps_divd_fcrr', 'atax_ps_divd_fcrr']
1387
+ if cols:
1388
+ int_param = list({'bons_type', 'bons_capt_radx'}.intersection(set(convert_fields(cols))))
1389
+ float_param = list(
1390
+ {'ps_divd', 'atax_ps_divd', 'ps_gant_num',
1391
+ 'ps_tran_incr_num', 'ps_divd_fcrr', 'atax_ps_divd_fcrr'}.intersection(set(convert_fields(cols))))
1392
+ else:
1393
+ cols = [
1394
+ 'scr_code', 'scr_num', 'scr_abbr', 'mkt_code', 'affi_date', 'end_date', 'bons_type', 'equi_reg_date',
1395
+ 'equi_arvd_date', 'excr_date', 'ps_divd', 'atax_ps_divd', 'ps_gant_num', 'ps_tran_incr_num',
1396
+ 'gant_list_date', 'ps_divd_fcrr', 'atax_ps_divd_fcrr', 'crrc_code', 'cdvd_dist_date', 'bons_capt_radx'
1397
+ ]
1398
+ params = {
1399
+ "scr_num_list": scr_num_list,
1400
+ "excr_date": excr_date,
1401
+ "affi_strt_date": affi_strt_date,
1402
+ "affi_end_date": affi_end_date,
1403
+ "reg_strt_date": reg_strt_date,
1404
+ "reg_end_date": reg_end_date,
1405
+ "bons_type": bons_type,
1406
+ "cols": cols,
1407
+ "rslt_type": rslt_type,
1408
+ "int_param": int_param,
1409
+ "float_param": float_param
1410
+ }
1411
+ return get_data("get_stk_divd_info", **params)
1412
+
1413
+
1414
+ def get_stk_addi(scr_num_list=None, rspl_affi_strt_date='19900101', rspl_affi_end_date=None,
1415
+ glmt_rsln_affi_strt_date='19900101', glmt_rsln_affi_end_date=None,
1416
+ addi_type_code=None, cols=None, rslt_type=0):
1417
+ """
1418
+ 获取历次增发方案以及实施信息包括发行价、发行量、发行费用的相关信息。
1419
+
1420
+ """
1421
+
1422
+ int_param = ['list_cir_capt']
1423
+ float_param = [
1424
+ 'iss_prc_topl', 'iss_prc_lowl', 'iss_vol_topl', 'iss_vol_lowl', 'onle_purs_topl', 'olds_ratn_rati',
1425
+ 'parv', 'iss_prc', 'iss_vol', 'iss_tot_mval', 'iss_fee_gamt', 'coll_cptl_tot_amt',
1426
+ 'coll_cptl_net_amt'
1427
+ ]
1428
+ if cols:
1429
+ int_param = list({'list_cir_capt'}.intersection(set(convert_fields(cols))))
1430
+ float_param = list(
1431
+ {'iss_prc_topl', 'iss_prc_lowl', 'iss_vol_topl', 'iss_vol_lowl', 'onle_purs_topl',
1432
+ 'olds_ratn_rati', 'parv', 'iss_prc', 'iss_vol', 'iss_tot_mval', 'iss_fee_gamt',
1433
+ 'coll_cptl_tot_amt', 'coll_cptl_net_amt'}.intersection(set(convert_fields(cols))))
1434
+ else:
1435
+ cols = [
1436
+ 'scr_code', 'scr_num', 'scr_abbr', 'mkt_code', 'addi_type_code', 'rspl_affi_date', 'glmt_rsln_affi_date',
1437
+ 'sasac_aprv_affi_date', 'csrc_aprv_affi_date', 'rspl_eff_strt_date', 'rspl_eff_end_date', 'uw_strt_date',
1438
+ 'uw_end_date', 'main_uw_name', 'vice_main_uw_name', 'iss_prc_topl', 'iss_prc_lowl', 'iss_vol_topl',
1439
+ 'iss_vol_lowl', 'onle_iss_date', 'onle_purs_code', 'onle_purs_topl', 'olds_ratn_rati', 'olds_ratn_date',
1440
+ 'olds_ratn_purs_code', 'parv', 'iss_prc', 'iss_vol', 'iss_tot_mval', 'iss_fee_gamt', 'coll_cptl_tot_amt',
1441
+ 'coll_cptl_net_amt', 'list_cir_capt', 'rstk_list_date', 'equi_reg_date', 'crrc_code', 'affi_date',
1442
+ 'plan_chg_type_code',
1443
+ ]
1444
+ params = {
1445
+ "scr_num_list": scr_num_list,
1446
+ "rspl_affi_strt_date": rspl_affi_strt_date,
1447
+ "rspl_affi_end_date": rspl_affi_end_date,
1448
+ "glmt_rsln_affi_strt_date": glmt_rsln_affi_strt_date,
1449
+ "glmt_rsln_affi_end_date": glmt_rsln_affi_end_date,
1450
+ "addi_type_code": addi_type_code,
1451
+ "cols": cols,
1452
+ "rslt_type": rslt_type,
1453
+ "int_param": int_param,
1454
+ "float_param": float_param
1455
+ }
1456
+ return get_data("get_stk_addi", **params)
1457
+
1458
+
1459
+ def get_ins_mngr_info(scr_num_list, affi_strt_date='19900101', affi_end_date=None, cols=None, rslt_type=0):
1460
+ """
1461
+ 获取上市公司历届管理层信息,包括届次,职务,任期起始时间,任期结束时间等(含科创板)。
1462
+
1463
+ """
1464
+
1465
+ int_param = ['aoff_sesn']
1466
+ float_param = []
1467
+ if cols:
1468
+ int_param = list({'aoff_sesn'}.intersection(set(convert_fields(cols))))
1469
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
1470
+
1471
+ if scr_num_list:
1472
+ params = {
1473
+ "scr_num_list": scr_num_list,
1474
+ "affi_strt_date": affi_strt_date,
1475
+ "affi_end_date": affi_end_date,
1476
+ "cols": cols,
1477
+ "rslt_type": rslt_type,
1478
+ "int_param": int_param,
1479
+ "float_param": float_param
1480
+ }
1481
+ return get_data("get_ins_mngr_info", **params)
1482
+ else:
1483
+ warnings.warn("函数[get_ins_mngr_info]的参数(scr_num_list)为必填项")
1484
+ if rslt_type == 0:
1485
+ return pd.DataFrame()
1486
+ else:
1487
+ return np.empty(0)
1488
+
1489
+
1490
+ def get_ins_mngr_chg(scr_num_list, affi_strt_date='19900101', affi_end_date=None, cols=None, rslt_type=0):
1491
+ """
1492
+ 获取公司高管变更信息,包含变更类型、变更职位及教育背景等信息(含科创板)。
1493
+
1494
+ """
1495
+
1496
+ int_param = []
1497
+ float_param = []
1498
+ if cols:
1499
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
1500
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
1501
+ else:
1502
+ cols = [
1503
+ 'scr_code', 'scr_num', 'scr_abbr', 'mkt_code', 'affi_date', 'name', 'birt_date', 'aoff_date', 'leav_date',
1504
+ 'pos_code', 'pos_type_code', 'aoff_chg_type_code', 'leav_resn', 'ins_fn', 'indv_intr'
1505
+ ]
1506
+ if scr_num_list:
1507
+ params = {
1508
+ "scr_num_list": scr_num_list,
1509
+ "affi_strt_date": affi_strt_date,
1510
+ "affi_end_date": affi_end_date,
1511
+ "cols": cols,
1512
+ "rslt_type": rslt_type,
1513
+ "int_param": int_param,
1514
+ "float_param": float_param
1515
+ }
1516
+ return get_data("get_ins_mngr_chg", **params)
1517
+ else:
1518
+ warnings.warn("函数[get_ins_mngr_chg]的参数(scr_num_list)为必填项")
1519
+ if rslt_type == 0:
1520
+ return pd.DataFrame()
1521
+ else:
1522
+ return np.empty(0)
1523
+
1524
+
1525
+ def get_ins_capt_chg(scr_num_list=None, ins_num=None, intv_strt_date=None, intv_end_date=None, cols=None,
1526
+ rslt_type=None):
1527
+ """
1528
+ 获取上市公司股本结构及历次股本变动数据(含科创板)。
1529
+
1530
+ 输入参数:
1531
+ :param str|list scr_num_list : 证券编码列表,如['000001.XSHE']
1532
+ :param str ins_num : 机构编码
1533
+ :param str intv_strt_date : 区间开始日期,格式'YYYYMMDD',参考日期trad_date,默认"19000101"
1534
+ :param str intv_end_date : 区间结束日期,格式'YYYYMMDD',参考日期trad_date,默认"now"
1535
+ :param str|list cols : 筛选字段,默认返回所有
1536
+ :param int rslt_type : 数据返回结果类型,0-pandas.DataFrame,1-numpy.ndarray,默认0
1537
+
1538
+ 输出参数:
1539
+ :param str scr_code : 交易代码,如'000001',
1540
+ :param str scr_num : 证券编码,如'000001.XSHE',
1541
+ :param str scr_abbr : 证券简称,
1542
+ :param str mkt_code : 交易市场代码,取值字典项:
1543
+ NEEQ 全国中小企业股份转让系统
1544
+ XSHE 深圳证券交易所
1545
+ XSHG 上海证券交易所
1546
+ XHKG 香港交易所,
1547
+ :param str ins_num : 机构编码,
1548
+ :param str trad_date : 交易日,
1549
+ :param int tot_capt : 总股本,
1550
+ :param int tot_cir_capt : 总流通股本,
1551
+ :param int astk_capt : A股本,
1552
+ :param int astk_cir_capt : A股流通股本,
1553
+ :param int bstk_capt : B股股本,
1554
+ :param int bstk_cir_capt : B股流通股,
1555
+ :param int hstk_capt : H股股本,
1556
+ :param int hstk_cir_capt : H股流通股本,
1557
+ :param float tlc_capt : 有限售条件股份合计,
1558
+ :param float ntlc_capt : 无限售流通股份合计,
1559
+ :param int astk_tlc_capt : A股自由流通股本,
1560
+ :param float astk_ntlc_capt : A股自由流通市值,
1561
+
1562
+ 返回数据类型:
1563
+
1564
+
1565
+ 代码调用:
1566
+
1567
+
1568
+ 结果输出:
1569
+
1570
+ """
1571
+
1572
+ int_param = ['tot_capt', 'tot_cir_capt', 'astk_capt', 'astk_cir_capt', 'bstk_capt', 'bstk_cir_capt', 'hstk_capt',
1573
+ 'hstk_cir_capt', 'astk_tlc_capt']
1574
+ float_param = ['tlc_capt', 'ntlc_capt', 'astk_ntlc_capt']
1575
+ if cols:
1576
+ int_param = list(
1577
+ {'tot_capt', 'tot_cir_capt', 'astk_capt', 'astk_cir_capt', 'bstk_capt', 'bstk_cir_capt', 'hstk_capt',
1578
+ 'hstk_cir_capt', 'astk_tlc_capt'}.intersection(set(convert_fields(cols))))
1579
+ float_param = list({'tlc_capt', 'ntlc_capt', 'astk_ntlc_capt'}.intersection(set(convert_fields(cols))))
1580
+ params = {
1581
+ "scr_num_list": scr_num_list,
1582
+ "ins_num": ins_num,
1583
+ "intv_strt_date": intv_strt_date,
1584
+ "intv_end_date": intv_end_date,
1585
+ "cols": cols,
1586
+ "rslt_type": rslt_type,
1587
+ "int_param": int_param,
1588
+ "float_param": float_param
1589
+ }
1590
+ return get_data("get_ins_capt_chg", **params)
1591
+
1592
+
1593
+ def get_ins_top10_shah(scr_num_list=None, strt_date=None, end_date=None, cols=None, rslt_type=0):
1594
+ """
1595
+ 获取公司十大股东信息,包含持股数以及持股比例(含科创板)。
1596
+
1597
+ """
1598
+
1599
+ int_param = ['shah_rank', 'hold_num', 'lmt_sale_stk_vol', 'ustk_vol']
1600
+ float_param = ['occp_tscp_rati']
1601
+ if cols:
1602
+ int_param = list(
1603
+ {'shah_rank', 'hold_num', 'lmt_sale_stk_vol', 'ustk_vol'}.intersection(set(convert_fields(cols))))
1604
+ float_param = list({'occp_tscp_rati'}.intersection(set(convert_fields(cols))))
1605
+ else:
1606
+ cols = [
1607
+ 'scr_code', 'scr_num', 'scr_abbr', 'mkt_code', 'end_date', 'affi_date', 'shah_rank', 'shah_name',
1608
+ 'hold_num', 'occp_tscp_rati', 'lmt_sale_stk_vol', 'ustk_vol', 'capt_char_desc', 'shah_clas_num',
1609
+ 'shah_attr_code'
1610
+ ]
1611
+ params = {
1612
+ "scr_num_list": scr_num_list,
1613
+ "strt_date": strt_date,
1614
+ "end_date": end_date,
1615
+ "cols": cols,
1616
+ "rslt_type": rslt_type,
1617
+ "int_param": int_param,
1618
+ "float_param": float_param
1619
+ }
1620
+ return get_data("get_ins_top10_shah", **params)
1621
+
1622
+
1623
+ def get_ins_top10_cir_shah(scr_num_list=None, strt_date=None, end_date=None, cols=None, rslt_type=0):
1624
+ """
1625
+ 获取公司十大流通股东信息,包含持股数以及持股比例。
1626
+
1627
+ """
1628
+
1629
+ int_param = ['shah_rank', 'ustk_vol']
1630
+ float_param = ['occp_tscp_rati']
1631
+ if cols:
1632
+ int_param = list({'shah_rank', 'ustk_vol'}.intersection(set(convert_fields(cols))))
1633
+ float_param = list({'occp_tscp_rati'}.intersection(set(convert_fields(cols))))
1634
+ else:
1635
+ cols = [
1636
+ 'scr_code', 'scr_num', 'scr_abbr', 'mkt_code', 'end_date', 'affi_date', 'shah_rank', 'shah_name',
1637
+ 'ustk_vol', 'occp_tscp_rati'
1638
+ ]
1639
+ params = {
1640
+ "scr_num_list": scr_num_list,
1641
+ "strt_date": strt_date,
1642
+ "end_date": end_date,
1643
+ "cols": cols,
1644
+ "rslt_type": rslt_type,
1645
+ "int_param": int_param,
1646
+ "float_param": float_param
1647
+ }
1648
+ return get_data("get_ins_top10_cir_shah", **params)
1649
+
1650
+
1651
+ def get_rstk_drrt(scr_num_list=None, strt_drrt_date='19900101', end_drrt_date=None,
1652
+ affi_strt_date='19900101', affi_end_date=None, cols=None, rslt_type=0):
1653
+ """
1654
+ 获取上市公司限售股流通时间、数量与股份性质等信息(含科创板)。
1655
+
1656
+ """
1657
+
1658
+ int_param = ['drrt_stk_src_code']
1659
+ float_param = []
1660
+ if cols:
1661
+ int_param = list({'drrt_stk_src_code'}.intersection(set(convert_fields(cols))))
1662
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
1663
+ else:
1664
+ cols = [
1665
+ 'scr_code', 'scr_num', 'scr_abbr', 'mkt_code', 'affi_date', 'drrt_date', 'drrt_stk_src_code'
1666
+ ]
1667
+ params = {
1668
+ "scr_num_list": scr_num_list,
1669
+ "strt_drrt_date": strt_drrt_date,
1670
+ "end_drrt_date": end_drrt_date,
1671
+ "affi_strt_date": affi_strt_date,
1672
+ "affi_end_date": affi_end_date,
1673
+ "cols": cols,
1674
+ "rslt_type": rslt_type,
1675
+ "int_param": int_param,
1676
+ "float_param": float_param
1677
+ }
1678
+ return get_data("get_rstk_drrt", **params)
1679
+
1680
+
1681
+ def get_rstk_drrt_dtl(scr_num_list=None, strt_cir_date='19900101', end_cir_date=None,
1682
+ affi_strt_date='19900101', affi_end_date=None, cols=None, rslt_type=0):
1683
+ """
1684
+ 获取记录上市公司首次公开发行前股东股份解禁的相关信息(含科创板)。
1685
+
1686
+ """
1687
+
1688
+ int_param = ['cir_stk_vol']
1689
+ float_param = []
1690
+ if cols:
1691
+ int_param = list({'cir_stk_vol'}.intersection(set(convert_fields(cols))))
1692
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
1693
+ else:
1694
+ cols = [
1695
+ 'scr_code', 'scr_num', 'scr_abbr', 'mkt_code', 'affi_date', 'shah_onum', 'shah_name', 'cir_strt_date',
1696
+ 'cir_stk_vol'
1697
+ ]
1698
+ params = {
1699
+ "scr_num_list": scr_num_list,
1700
+ "strt_cir_date": strt_cir_date,
1701
+ "end_cir_date": end_cir_date,
1702
+ "affi_strt_date": affi_strt_date,
1703
+ "affi_end_date": affi_end_date,
1704
+ "cols": cols,
1705
+ "rslt_type": rslt_type,
1706
+ "int_param": int_param,
1707
+ "float_param": float_param
1708
+ }
1709
+ return get_data("get_rstk_drrt_dtl", **params)
1710
+
1711
+
1712
+ def get_prof_pred(scr_num_list, strt_date='19900101', end_date=None, cols=None, rslt_type=0):
1713
+ """
1714
+ 记录上市公司盈利预测数据。
1715
+
1716
+ """
1717
+
1718
+ int_param = []
1719
+ float_param = ['busi_incm', 'busi_cost', 'busi_prof', 'prof_gamt', 'net_prof', 'attr_pcrp_ownr_equi', 'eps', 'bps',
1720
+ 'ps_casf']
1721
+ if cols:
1722
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
1723
+ float_param = list(
1724
+ {'busi_incm', 'busi_cost', 'busi_prof', 'prof_gamt', 'net_prof', 'attr_pcrp_ownr_equi', 'eps', 'bps',
1725
+ 'ps_casf'}.intersection(set(convert_fields(cols))))
1726
+ else:
1727
+ cols = [
1728
+ 'scr_code', 'scr_num', 'scr_abbr', 'mkt_code', 'pred_writ_date', 'pred_writ_ins_num', 'pred_writ_ins_name',
1729
+ 'pred_ann', 'busi_incm', 'busi_cost', 'busi_prof', 'prof_gamt', 'net_prof', 'attr_pcrp_ownr_equi', 'eps',
1730
+ 'bps', 'ps_casf'
1731
+ ]
1732
+ if scr_num_list:
1733
+ params = {
1734
+ "scr_num_list": scr_num_list,
1735
+ "strt_date": strt_date,
1736
+ "end_date": end_date,
1737
+ "cols": cols,
1738
+ "rslt_type": rslt_type,
1739
+ "int_param": int_param,
1740
+ "float_param": float_param
1741
+ }
1742
+ return get_data("get_prof_pred", **params)
1743
+ else:
1744
+ warnings.warn("函数[get_prof_pred]的参数(scr_num_list)为必填项")
1745
+ if rslt_type == 0:
1746
+ return pd.DataFrame()
1747
+ else:
1748
+ return np.empty(0)
1749
+
1750
+
1751
+ def get_marg_scr(scr_num_list=None, trad_date=None, rels_ins_name=None, cols=None,
1752
+ rslt_type=0):
1753
+ """
1754
+ 获取东方证券、国泰君安、国信证券、华泰证券、上交所、申万宏源、深交所、银河证券、中信证券所公布的每个交易日的可充抵保
1755
+ 证金标的证券信息。
1756
+
1757
+ """
1758
+
1759
+ int_param = []
1760
+ float_param = ['cnvr_rate']
1761
+ if cols:
1762
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
1763
+ float_param = list({'cnvr_rate'}.intersection(set(convert_fields(cols))))
1764
+ else:
1765
+ cols = [
1766
+ 'scr_code', 'scr_num', 'scr_abbr', 'mkt_code', 'trad_date', 'tect_date', 'invl_date',
1767
+ 'rels_ins_num', 'rels_ins_name', 'cnvr_rate'
1768
+ ]
1769
+ if scr_num_list:
1770
+ params = {
1771
+ "scr_num_list": scr_num_list,
1772
+ "trad_date": trad_date,
1773
+ "rels_ins_name": rels_ins_name,
1774
+ "cols": cols,
1775
+ "rslt_type": rslt_type,
1776
+ "int_param": int_param,
1777
+ "float_param": float_param
1778
+ }
1779
+ return get_data("get_marg_scr", **params)
1780
+ else:
1781
+ warnings.warn("函数[get_marg_scr]的参数(scr_num_list)为必填项")
1782
+ if rslt_type == 0:
1783
+ return pd.DataFrame()
1784
+ else:
1785
+ return np.empty(0)
1786
+
1787
+
1788
+ def get_stk_bloc_rep(scr_num_list, strt_date='19900101', end_date=None, bs_flag=None, cols=None,
1789
+ rslt_type=0):
1790
+ """
1791
+ 获取大宗交易申报信息,包括股票代码、申报日期、申报价格、申报数量等信息。
1792
+
1793
+ """
1794
+
1795
+ int_param = ['rep_onum']
1796
+ float_param = ['rep_prc', 'rep_vol']
1797
+ if cols:
1798
+ int_param = list({'rep_onum'}.intersection(set(convert_fields(cols))))
1799
+ float_param = list({'rep_prc', 'rep_vol'}.intersection(set(convert_fields(cols))))
1800
+ else:
1801
+ cols = [
1802
+ 'scr_code', 'scr_num', 'scr_abbr', 'mkt_code', 'rep_date', 'rep_onum', 'bs_flag', 'rep_prc', 'rep_vol'
1803
+ ]
1804
+ if scr_num_list:
1805
+ params = {
1806
+ "scr_num_list": scr_num_list,
1807
+ "strt_date": strt_date,
1808
+ "end_date": end_date,
1809
+ "bs_flag": bs_flag,
1810
+ "cols": cols,
1811
+ "rslt_type": rslt_type,
1812
+ "int_param": int_param,
1813
+ "float_param": float_param
1814
+ }
1815
+ return get_data("get_stk_bloc_rep", **params)
1816
+ else:
1817
+ warnings.warn("函数[get_stk_bloc_rep]的参数(scr_num_list)为必填项")
1818
+ if rslt_type == 0:
1819
+ return pd.DataFrame()
1820
+ else:
1821
+ return np.empty(0)
1822
+
1823
+
1824
+ def get_stk_bloc_recd(scr_num_list, strt_date='19900101', end_date=None, cols=None, rslt_type=0):
1825
+ """
1826
+ 获取大宗交易信息,包括股票代码、交易日期、成交价、成交量等。
1827
+
1828
+ """
1829
+
1830
+ int_param = ['trd_sn']
1831
+ float_param = ['trd_px', 'mtch_vol', 'mtch_amt', 'trd_tims']
1832
+ if cols:
1833
+ int_param = list({'trd_sn'}.intersection(set(convert_fields(cols))))
1834
+ float_param = list({'trd_px', 'mtch_vol', 'mtch_amt', 'trd_tims'}.intersection(set(convert_fields(cols))))
1835
+ else:
1836
+ cols = [
1837
+ 'scr_code', 'scr_num', 'scr_abbr', 'mkt_code', 'trad_date', 'trd_sn', 'trd_px', 'mtch_vol', 'mtch_amt',
1838
+ 'buyr_busp_name', 'sler_busp_name'
1839
+ ]
1840
+ if scr_num_list:
1841
+ params = {
1842
+ "scr_num_list": scr_num_list,
1843
+ "strt_date": strt_date,
1844
+ "end_date": end_date,
1845
+ "cols": cols,
1846
+ "rslt_type": rslt_type,
1847
+ "int_param": int_param,
1848
+ "float_param": float_param
1849
+ }
1850
+ return get_data("get_stk_bloc_recd", **params)
1851
+ else:
1852
+ warnings.warn("函数[get_stk_bloc_recd]的参数(scr_num_list)为必填项")
1853
+ if rslt_type == 0:
1854
+ return pd.DataFrame()
1855
+ else:
1856
+ return np.empty(0)
1857
+
1858
+
1859
+ def get_fund_basc_info(scr_num_list=None, fund_list_stat=None, fund_type=None, oper_mode_code=None,
1860
+ strt_list_date=None, end_list_date=None, cols=None, rslt_type=0):
1861
+ """
1862
+ 获取基金的基本档案信息,包含基金名称、交易代码、分级情况、所属类别、上市信息、投资范围等信息。
1863
+
1864
+ """
1865
+
1866
+ int_param = ['mng_ins_num', 'trus_ins_num']
1867
+ float_param = ['cir_shr']
1868
+ if cols:
1869
+ int_param = list({'mng_ins_num', 'trus_ins_num'}.intersection(set(convert_fields(cols))))
1870
+ float_param = list({'cir_shr'}.intersection(set(convert_fields(cols))))
1871
+ else:
1872
+ cols = [
1873
+ 'scr_code', 'scr_num', 'scr_abbr', 'mkt_code', 'fund_type', 'oper_mode_code', 'qdii_flag', 'etf_flag',
1874
+ 'lof_flag', 'list_stat', 'mngr_name', 'setp_date', 'at_pd_date', 'list_date', 'delt_date', 'mng_ins_num',
1875
+ 'mng_ins_abbr', 'mng_ins_name', 'trus_ins_num', 'trus_ins_abbr', 'trus_ins_name', 'ivsm_scop', 'ivsm_tgt',
1876
+ 'perf_cont_basi', 'cir_shr'
1877
+ ]
1878
+ params = {
1879
+ "scr_num_list": scr_num_list,
1880
+ "fund_list_stat": fund_list_stat,
1881
+ "fund_type": fund_type,
1882
+ "oper_mode_code": oper_mode_code,
1883
+ "strt_list_date": strt_list_date,
1884
+ "end_list_date": end_list_date,
1885
+ "cols": cols,
1886
+ "rslt_type": rslt_type,
1887
+ "int_param": int_param,
1888
+ "float_param": float_param
1889
+ }
1890
+ return get_data("get_fund_basc_info", **params)
1891
+
1892
+
1893
+ def get_cifd_fund_basc_info(scr_num_list=None, mkt_code=None, cols=None, rslt_type=0):
1894
+ """
1895
+ 获取分级基金的基本信息,包含母、子基金名称、交易代码、分拆比例等信息。
1896
+
1897
+ """
1898
+
1899
+ int_param = []
1900
+ float_param = ['spli_rat']
1901
+ if cols:
1902
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
1903
+ float_param = list({'spli_rat'}.intersection(set(convert_fields(cols))))
1904
+ else:
1905
+ cols = [
1906
+ 'scr_code', 'scr_num', 'scr_abbr', 'mkt_code', 'fund_type', 'subf_scr_num', 'subf_scr_code',
1907
+ 'subf_scr_abbr', 'subf_fund_type', 'subf_mkt_code', 'trac_indx', 'strt_date', 'end_date', 'spli_rat'
1908
+ ]
1909
+ params = {
1910
+ "scr_num_list": scr_num_list,
1911
+ "mkt_code": mkt_code,
1912
+ "cols": cols,
1913
+ "rslt_type": rslt_type,
1914
+ "int_param": int_param,
1915
+ "float_param": float_param
1916
+ }
1917
+ return get_data("get_cifd_fund_basc_info", **params)
1918
+
1919
+
1920
+ def get_fund_feer_info(scr_num_list, fund_feer_type_code=None, fund_amt=None, strt_date=None, end_date=None,
1921
+ cols=None, rslt_type=0):
1922
+ """
1923
+ 获取基金费率,如管理费、销售费、申购费、赎回费等。
1924
+
1925
+ """
1926
+
1927
+ int_param = []
1928
+ float_param = ['fee_amt_lowl', 'fee_amt_topl', 'hldp_almt_lowl', 'hldp_almt_topl', 'fee_rate']
1929
+ if cols:
1930
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
1931
+ float_param = list(
1932
+ {'fee_amt_lowl', 'fee_amt_topl', 'hldp_almt_lowl',
1933
+ 'hldp_almt_topl', 'fee_rate'}.intersection(set(convert_fields(cols))))
1934
+ else:
1935
+ cols = [
1936
+ 'scr_code', 'scr_num', 'scr_abbr', 'mkt_code', 'strt_date', 'end_date', 'fund_feer_type_code',
1937
+ 'chag_mode_code', 'cust_type_code', 'fee_amt_lowl', 'fee_amt_topl', 'shr_lowl', 'shr_topl',
1938
+ 'hldp_almt_lowl', 'hldp_almt_topl', 'date_grul_code', 'fee_rate', 'fee_unit', 'fee_curr', 'fee_rate_des',
1939
+ 'feer_clfi'
1940
+ ]
1941
+ if scr_num_list:
1942
+ params = {
1943
+ "scr_num_list": scr_num_list,
1944
+ "fund_feer_type_code": fund_feer_type_code,
1945
+ "fund_amt": fund_amt,
1946
+ "strt_date": strt_date,
1947
+ "end_date": end_date,
1948
+ "cols": cols,
1949
+ "rslt_type": rslt_type,
1950
+ "int_param": int_param,
1951
+ "float_param": float_param
1952
+ }
1953
+ return get_data("get_fund_feer_info", **params)
1954
+ else:
1955
+ warnings.warn("函数[get_fund_feer_info]的参数(scr_num_list)为必填项")
1956
+ if rslt_type == 0:
1957
+ return pd.DataFrame()
1958
+ else:
1959
+ return np.empty(0)
1960
+
1961
+
1962
+ def get_fund_rat_info(scr_num_list, rat_src_code=None, strt_date='19900101', end_date=None,
1963
+ cols=None, rslt_type=0):
1964
+ """
1965
+ 获取晨星和银河基金评级信息。
1966
+
1967
+ """
1968
+
1969
+ int_param = []
1970
+ float_param = []
1971
+ if cols:
1972
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
1973
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
1974
+ else:
1975
+ cols = [
1976
+ 'scr_code', 'scr_num', 'scr_abbr', 'mkt_code', 'rat_src_ins', 'rat_date', 'intv', 'fund_star_rat'
1977
+ ]
1978
+ if scr_num_list:
1979
+ params = {
1980
+ "scr_num_list": scr_num_list,
1981
+ "rat_src_code": rat_src_code,
1982
+ "strt_date": strt_date,
1983
+ "end_date": end_date,
1984
+ "cols": cols,
1985
+ "rslt_type": rslt_type,
1986
+ "int_param": int_param,
1987
+ "float_param": float_param
1988
+ }
1989
+ return get_data("get_fund_rat_info", **params)
1990
+ else:
1991
+ warnings.warn("函数[get_fund_rat_info]的参数(scr_num_list)为必填项")
1992
+ if rslt_type == 0:
1993
+ return pd.DataFrame()
1994
+ else:
1995
+ return np.empty(0)
1996
+
1997
+
1998
+ def get_fund_nav_info(scr_num_list, fund_clas_abbr=None, strt_date='19900101', end_date=None,
1999
+ cols=None, rslt_type=0):
2000
+ """
2001
+ 获取获取某只基金的历史净值数据(货币型除外),包括了单位份额净值、累计净值与复权净值。
2002
+
2003
+ """
2004
+
2005
+ int_param = ['fund_clas_num']
2006
+ float_param = ['unit_nv', 'aggr_unit_nv', 'aft_rstr_unit_nv']
2007
+ if cols:
2008
+ int_param = list({'fund_clas_num'}.intersection(set(convert_fields(cols))))
2009
+ float_param = list({'unit_nv', 'aggr_unit_nv', 'aft_rstr_unit_nv'}.intersection(set(convert_fields(cols))))
2010
+ else:
2011
+ cols = [
2012
+ 'scr_code', 'scr_num', 'scr_abbr', 'mkt_code', 'fund_clas_num', 'fund_clas_abbr', 'nv_date', 'unit_nv',
2013
+ 'aggr_unit_nv', 'aft_rstr_unit_nv'
2014
+ ]
2015
+ if scr_num_list:
2016
+ params = {
2017
+ "scr_num_list": scr_num_list,
2018
+ "fund_clas_abbr": fund_clas_abbr,
2019
+ "strt_date": strt_date,
2020
+ "end_date": end_date,
2021
+ "cols": cols,
2022
+ "rslt_type": rslt_type,
2023
+ "int_param": int_param,
2024
+ "float_param": float_param
2025
+ }
2026
+ return get_data("get_fund_nav_info", **params)
2027
+ else:
2028
+ warnings.warn("函数[get_fund_nav_info]的参数(scr_num_list)为必填项")
2029
+ if rslt_type == 0:
2030
+ return pd.DataFrame()
2031
+ else:
2032
+ return np.empty(0)
2033
+
2034
+
2035
+ def get_fund_shr_chg(scr_num_list, fund_rept_type=None, strt_date='19900101', end_date=None,
2036
+ cols=None, rslt_type=0):
2037
+ """
2038
+ 获取基金定期报告中开放式基金份额变动情况。
2039
+
2040
+ """
2041
+
2042
+ int_param = []
2043
+ float_param = ['bgng_tot_shr', 'end_tot_shr', 'shr_chg', 'spli_cnvr_shr_chg']
2044
+ if cols:
2045
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
2046
+ float_param = list({'bgng_tot_shr', 'end_tot_shr', 'shr_chg', 'spli_cnvr_shr_chg'}.intersection(
2047
+ set(convert_fields(cols))))
2048
+ else:
2049
+ cols = [
2050
+ 'scr_code', 'scr_num', 'scr_abbr', 'mkt_code', 'rept_type', 'affi_date', 'end_date', 'bgng_tot_shr',
2051
+ 'end_tot_shr', 'shr_chg', 'spli_cnvr_shr_chg'
2052
+ ]
2053
+ if scr_num_list:
2054
+ params = {
2055
+ "scr_num_list": scr_num_list,
2056
+ "fund_rept_type": fund_rept_type,
2057
+ "strt_date": strt_date,
2058
+ "end_date": end_date,
2059
+ "cols": cols,
2060
+ "rslt_type": rslt_type,
2061
+ "int_param": int_param,
2062
+ "float_param": float_param
2063
+ }
2064
+ return get_data("get_fund_shr_chg", **params)
2065
+ else:
2066
+ warnings.warn("函数[get_fund_shr_chg]的参数(scr_num_list)为必填项")
2067
+ if rslt_type == 0:
2068
+ return pd.DataFrame()
2069
+ else:
2070
+ return np.empty(0)
2071
+
2072
+
2073
+ def get_fund_perf_indx(scr_num_list=None, fund_type=None, strt_date=None, end_date=None, cols=None, rslt_type=None):
2074
+ """
2075
+ 获取获取基金相关业绩指标。
2076
+
2077
+ 输入参数:
2078
+ :param str|list scr_num_list : 证券代码列表,如['600570.XSHG'],该字段为必填项
2079
+ :param str|list fund_type : 基金类型。E-股票基金 B-债券基金 M-货币市场基金 F-基金中基金 H-混合基金 O-其他基金
2080
+ :param str strt_date : 开始日期,如:'20190101',参考日期trd_date,默认"19000101"
2081
+ :param str end_date : 结束日期,如:'20190101',参考日期trd_date,默认"now"
2082
+ :param str|list cols : 筛选字段,默认返回所有
2083
+ :param int rslt_type : 数据返回结果类型,0-pandas.DataFrame,1-numpy.ndarray,默认0
2084
+
2085
+ 输出参数:
2086
+ :param str scr_num : 证券编码,如'600570.XSHG',
2087
+ :param str scr_code : 证券代码,
2088
+ :param str scr_abbr : 证券简称,
2089
+ :param str mkt_code : 交易市场代码,
2090
+ :param str fund_type : 基金类型。E-股票基金 B-债券基金 M-货币市场基金 F-基金中基金 H-混合基金 O-其他基金,
2091
+ :param str trd_date : 交易日期,'YYYYMMDD',
2092
+ :param float rect_one_mth_shap : 近一月夏普比率,
2093
+ :param float rect_thre_mth_shap : 近三月夏普比率,
2094
+ :param float rect_half_year_shap : 近六月夏普比率,
2095
+ :param float rect_one_year_shap : 近一年夏普比率,
2096
+ :param float rect_two_year_shap : 近二年夏普比率,
2097
+ :param float rect_thre_year_shap : 近三年夏普比率,
2098
+ :param float this_year_shap : 今年以来夏普比率,
2099
+ :param float sinc_setp_shap : 成立以来夏普比率,
2100
+ :param float rect_one_mth_beta : 近一月贝塔比率,
2101
+ :param float rect_thre_mth_beta : 近三月贝塔比率,
2102
+ :param float rect_half_year_beta : 近六月贝塔比率,
2103
+ :param float rect_one_year_beta : 近一年贝塔比率,
2104
+ :param float rect_two_year_beta : 近二年贝塔比率,
2105
+ :param float rect_thre_year_beta : 近三年贝塔比率,
2106
+ :param float this_year_beta : 今年以来贝塔比率,
2107
+ :param float sinc_setp_beta : 成立以来贝塔比率,
2108
+ :param float rect_one_mth_jesn : 最近一月詹森比率,
2109
+ :param float rect_thre_mth_jesn : 最近三月詹森比率,
2110
+ :param float rect_half_year_jesn : 最近六月詹森比率,
2111
+ :param float rect_one_year_jesn : 最近一年詹森比率,
2112
+ :param float rect_two_year_jesn : 最近两年詹森比率,
2113
+ :param float rect_thre_year_jesn : 最近三年詹森比率,
2114
+ :param float this_year_jesn : 本年詹森比率,
2115
+ :param float sinc_setp_jesn : 成立以来詹森比率,
2116
+
2117
+ 返回数据类型:
2118
+
2119
+
2120
+ 代码调用:
2121
+
2122
+
2123
+ 结果输出:
2124
+
2125
+ """
2126
+
2127
+ int_param = []
2128
+ float_param = ['rect_one_mth_shap', 'rect_thre_mth_shap', 'rect_half_year_shap', 'rect_one_year_shap',
2129
+ 'rect_two_year_shap', 'rect_thre_year_shap', 'this_year_shap', 'sinc_setp_shap', 'rect_one_mth_beta',
2130
+ 'rect_thre_mth_beta', 'rect_half_year_beta', 'rect_one_year_beta', 'rect_two_year_beta',
2131
+ 'rect_thre_year_beta', 'this_year_beta', 'sinc_setp_beta', 'rect_one_mth_jesn', 'rect_thre_mth_jesn',
2132
+ 'rect_half_year_jesn', 'rect_one_year_jesn', 'rect_two_year_jesn', 'rect_thre_year_jesn',
2133
+ 'this_year_jesn', 'sinc_setp_jesn']
2134
+ if cols:
2135
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
2136
+ float_param = list({'rect_one_mth_shap', 'rect_thre_mth_shap', 'rect_half_year_shap', 'rect_one_year_shap',
2137
+ 'rect_two_year_shap', 'rect_thre_year_shap', 'this_year_shap', 'sinc_setp_shap',
2138
+ 'rect_one_mth_beta', 'rect_thre_mth_beta', 'rect_half_year_beta', 'rect_one_year_beta',
2139
+ 'rect_two_year_beta', 'rect_thre_year_beta', 'this_year_beta', 'sinc_setp_beta',
2140
+ 'rect_one_mth_jesn', 'rect_thre_mth_jesn', 'rect_half_year_jesn', 'rect_one_year_jesn',
2141
+ 'rect_two_year_jesn', 'rect_thre_year_jesn', 'this_year_jesn', 'sinc_setp_jesn'}.intersection(set(convert_fields(cols))))
2142
+ if scr_num_list:
2143
+ params = {
2144
+ "scr_num_list": scr_num_list,
2145
+ "fund_type": fund_type,
2146
+ "strt_date": strt_date,
2147
+ "end_date": end_date,
2148
+ "cols": cols,
2149
+ "rslt_type": rslt_type,
2150
+ "int_param": int_param,
2151
+ "float_param": float_param
2152
+ }
2153
+ return get_data("get_fund_perf_indx", **params)
2154
+ else:
2155
+ warnings.warn("函数[get_fund_perf_indx]的参数(scr_num_list)为必填项")
2156
+ if rslt_type == 0:
2157
+ return pd.DataFrame()
2158
+ else:
2159
+ return np.empty(0)
2160
+
2161
+
2162
+ def get_fund_ast_cfg_info(scr_num_list, strt_date='19900101', end_date=None, cols=None, rslt_type=0):
2163
+ """
2164
+ 获取基金定期披露的资产配置情况,包含了资产净值,资产净值中权益类、现金等资产的市值与占比情况。
2165
+
2166
+ """
2167
+
2168
+ int_param = []
2169
+ float_param = ['tot_ast', 'nav', 'stk_mval', 'bond_mval', 'cash_ast', 'stk_mval_nv_pct', 'bond_mval_nv_pct',
2170
+ 'cash_ast_nv_pct']
2171
+ if cols:
2172
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
2173
+ float_param = list(
2174
+ {'tot_ast', 'nav', 'stk_mval', 'bond_mval', 'cash_ast', 'stk_mval_nv_pct', 'bond_mval_nv_pct',
2175
+ 'cash_ast_nv_pct'}.intersection(set(convert_fields(cols))))
2176
+ else:
2177
+ cols = [
2178
+ 'scr_code', 'scr_num', 'scr_abbr', 'mkt_code', 'affi_date', 'end_date', 'tot_ast', 'nav', 'stk_mval',
2179
+ 'bond_mval', 'fund_mval', 'oth_mval', 'stk_mval_nv_pct', 'bond_mval_nv_pct', 'fund_mval_nv_pct',
2180
+ 'oth_mval_nv_pct'
2181
+ ]
2182
+ if scr_num_list:
2183
+ params = {
2184
+ "scr_num_list": scr_num_list,
2185
+ "strt_date": strt_date,
2186
+ "end_date": end_date,
2187
+ "cols": cols,
2188
+ "rslt_type": rslt_type,
2189
+ "int_param": int_param,
2190
+ "float_param": float_param
2191
+ }
2192
+ return get_data("get_fund_ast_cfg_info", **params)
2193
+ else:
2194
+ warnings.warn("函数[get_fund_ast_cfg_info]的参数(scr_num_list)为必填项")
2195
+ if rslt_type == 0:
2196
+ return pd.DataFrame()
2197
+ else:
2198
+ return np.empty(0)
2199
+
2200
+
2201
+ def get_fund_hldp_dtl(scr_num_list=None, hldp_scr_code_mkt=None, hldp_scr_type=None, strt_date='19900101', end_date=None,
2202
+ cols=None, rslt_type=0):
2203
+ """
2204
+ 获取基金定期披露的持仓明细,包含所持有的股票、债券、基金的持仓明细数据。
2205
+
2206
+ """
2207
+
2208
+ int_param = []
2209
+ float_param = ['hldp_vol', 'hldp_val', 'ast_rati']
2210
+ if cols:
2211
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
2212
+ float_param = list({'hldp_vol', 'hldp_val', 'ast_rati'}.intersection(set(convert_fields(cols))))
2213
+ else:
2214
+ cols = [
2215
+ 'scr_code', 'scr_num', 'scr_abbr', 'mkt_code', 'affi_date', 'end_date', 'hldp_scr_code_mkt',
2216
+ 'hldp_scr_abbr', 'hldp_mkt_code', 'hldp_scr_type', 'hldp_vol', 'hldp_val', 'ast_rati'
2217
+ ]
2218
+ params = {
2219
+ "scr_num_list": scr_num_list,
2220
+ "hldp_scr_code_mkt": hldp_scr_code_mkt,
2221
+ "hldp_scr_type": hldp_scr_type,
2222
+ "strt_date": strt_date,
2223
+ "end_date": end_date,
2224
+ "cols": cols,
2225
+ "rslt_type": rslt_type,
2226
+ "int_param": int_param,
2227
+ "float_param": float_param
2228
+ }
2229
+ return get_data("get_fund_hldp_dtl", **params)
2230
+
2231
+
2232
+ def get_crrc_fund_payf_info(scr_num_list=None, strt_date='19900101', end_date=None, cols=None, rslt_type=0):
2233
+ """
2234
+ 获取某只货币型基金的历史收益情况,包含了每万份收益,七日年化收益率等信息。
2235
+
2236
+ """
2237
+
2238
+ int_param = []
2239
+ float_param = ['micp_fund_unit_payf', 'sevn_day_aror', 'unit_net_val']
2240
+ if cols:
2241
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
2242
+ float_param = list(
2243
+ {'micp_fund_unit_payf', 'sevn_day_aror', 'unit_net_val'}.intersection(set(convert_fields(cols))))
2244
+ else:
2245
+ cols = [
2246
+ 'scr_code', 'scr_num', 'scr_abbr', 'mkt_code', 'nv_date', 'micp_fund_unit_payf', 'sevn_day_aror',
2247
+ 'unit_net_val'
2248
+ ]
2249
+ params = {
2250
+ "scr_num_list": scr_num_list,
2251
+ "strt_date": strt_date,
2252
+ "end_date": end_date,
2253
+ "cols": cols,
2254
+ "rslt_type": rslt_type,
2255
+ "int_param": int_param,
2256
+ "float_param": float_param
2257
+ }
2258
+ return get_data("get_crrc_fund_payf_info", **params)
2259
+
2260
+
2261
+ def get_etf_daly_pr_info(scr_num_list, strt_trd_date='19900101', end_trd_date=None, cols=None, rslt_type=0):
2262
+ """
2263
+ 获取ETF基金交易日的申赎清单基本信息,包括标的指数名称,上一交易日的现金差额、最小申赎单位净值、单位净值,交易日当
2264
+ 日的预估现金差额、最小申赎单位、现金替代比例上限、是否允许申购赎回、是否公布IOPV等信息。
2265
+
2266
+ """
2267
+
2268
+ int_param = []
2269
+ float_param = ['cash_diff', 'min_pr_unit_nv', 'fund_shr_nv', 'min_pr_unit', 'esti_cash', 'cash_repl_rati_topl',
2270
+ 'purs_topl', 'redp_topl']
2271
+ if cols:
2272
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
2273
+ float_param = list(
2274
+ {'cash_diff', 'min_pr_unit_nv', 'fund_shr_nv', 'min_pr_unit', 'esti_cash', 'cash_repl_rati_topl',
2275
+ 'purs_topl', 'redp_topl'}.intersection(set(convert_fields(cols))))
2276
+ else:
2277
+ cols = [
2278
+ 'scr_code', 'scr_num', 'scr_abbr', 'mkt_code', 'trd_date', 'cash_diff', 'min_pr_unit_nv', 'fund_shr_nv',
2279
+ 'min_pr_unit', 'esti_cash', 'cash_repl_rati_topl', 'purs_topl', 'redp_topl', 'pbsh_iopv_flag',
2280
+ 'purs_redp_perm', 'trac_indx_code', 'trac_indx_abbr', 'is_pbsh_iopv', 'is_pbsh_purs', 'is_pbsh_redp'
2281
+ ]
2282
+ if scr_num_list:
2283
+ params = {
2284
+ "scr_num_list": scr_num_list,
2285
+ "strt_trd_date": strt_trd_date,
2286
+ "end_trd_date": end_trd_date,
2287
+ "cols": cols,
2288
+ "rslt_type": rslt_type,
2289
+ "int_param": int_param,
2290
+ "float_param": float_param
2291
+ }
2292
+ return get_data("get_etf_daly_pr_info", **params)
2293
+ else:
2294
+ warnings.warn("函数[get_etf_daly_pr_info]的参数(scr_num_list)为必填项")
2295
+ if rslt_type == 0:
2296
+ return pd.DataFrame()
2297
+ else:
2298
+ return np.empty(0)
2299
+
2300
+