dataquant 1.1.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
dataquant/pof/api.py ADDED
@@ -0,0 +1,1963 @@
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_nav",
12
+ "get_fund_info",
13
+ "get_all_funds",
14
+ "get_fund_fee",
15
+ "get_fund_attributes",
16
+ "get_company_info",
17
+ "get_all_companies",
18
+ "get_company_shareholder",
19
+ "get_company_honor",
20
+ "get_personnel_honor",
21
+ "get_fund_honor",
22
+ "get_personnel_info",
23
+ "get_all_personnel",
24
+ "get_personnel_company_map",
25
+ "get_assets_allocation",
26
+ "get_industry_sw",
27
+ "get_industry_zz",
28
+ "get_industry_zx",
29
+ "get_allocation_jc",
30
+ "get_bond_attribution",
31
+ "get_futures_assets_allocation",
32
+ "get_performance",
33
+ "get_performance_topn",
34
+ "get_strategy_tree",
35
+ "get_company_fund_map",
36
+ "get_manager_fund_map",
37
+ "get_personnel_company_map",
38
+ "get_personnel_position",
39
+ "get_strategy_fund_map",
40
+ "get_benchmark_fund_map",
41
+ "get_index_confidence",
42
+ "get_index_info",
43
+ "get_dividends",
44
+ "get_fund_rank",
45
+ "get_adjusted_risk_index",
46
+ "get_capture_return",
47
+ "get_fund_portfolio",
48
+ "get_assets_position",
49
+ "get_relative_value_allocation",
50
+ "get_index_value"
51
+ ]
52
+
53
+
54
+ def get_nav(fund_code=None, fund_code_list=None, strt_date='19900101', end_date=None, cols=None, rslt_type=0):
55
+ """
56
+ 获取基金净值
57
+
58
+ """
59
+
60
+ int_param = \
61
+ [
62
+ 'ishigh_or_low', 'nav_src'
63
+ ]
64
+ float_param = \
65
+ [
66
+ 'unit_nv', 'bons_reiv_unit_nv',
67
+ 'bons_no_reiv_unit_nv', 'tohigh_nav_ratio'
68
+ ]
69
+ if cols:
70
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
71
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
72
+ else:
73
+ cols = [
74
+ 'fund_code', 'nv_date', 'unit_nv', 'bons_reiv_unit_nv',
75
+ 'bons_no_reiv_unit_nv', 'ishigh_or_low', 'tohigh_nav_ratio', 'nav_src'
76
+ ]
77
+
78
+ if end_date is None:
79
+ end_date = get_current_date()
80
+
81
+ if fund_code:
82
+ params = {
83
+ "fund_code": fund_code,
84
+ "strt_date": strt_date,
85
+ "end_date": end_date,
86
+ "cols": cols,
87
+ "rslt_type": rslt_type,
88
+ "int_param": int_param,
89
+ "float_param": float_param
90
+ }
91
+ return get_data("pof/get_nav", **params)
92
+ elif fund_code_list:
93
+ if isinstance(fund_code_list, str):
94
+ fund_code_list = fund_code_list.split(',')
95
+
96
+ params = {
97
+ "fund_code_list": fund_code_list,
98
+ "strt_date": strt_date,
99
+ "end_date": end_date,
100
+ "cols": cols,
101
+ "rslt_type": rslt_type,
102
+ "int_param": int_param,
103
+ "float_param": float_param
104
+ }
105
+ return get_data("pof/get_nav", **params)
106
+
107
+ else:
108
+ warnings.warn("函数[get_nav]的参数(fund_code)为必填项")
109
+ return None
110
+
111
+
112
+ def get_fund_info(fund_code_list=None, fund_cn_abbr_list=None, fund_cn_fn_list=None,
113
+ kord_num_list=None, cols=None, rslt_type=0):
114
+ """
115
+ 获取基金基本信息
116
+
117
+ """
118
+
119
+ int_param = \
120
+ [
121
+ 'fund_type', 'fund_stat', 'firs_stra', 'secd_stra',
122
+ 'thir_stra', 'durt'
123
+ ]
124
+ float_param = \
125
+ [
126
+
127
+ ]
128
+ if cols:
129
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
130
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
131
+ else:
132
+ cols = [
133
+ 'fund_code', 'fund_cn_abbr', 'fund_cn_fn', 'fund_type', 'setp_date',
134
+ 'kord_date', 'kord_num', 'corp_id', 'corp_cn_fn', 'corp_cn_abbr',
135
+ 'fund_stat', 'fund_mngr', 'firs_stra', 'secd_stra', 'thir_stra',
136
+ 'lock_pd', 'clos_pd', 'open_pd', 'pri_basi_id', 'durt', 'ivsm_scop',
137
+ 'fund_stra_desc', 'cstdins_id', 'brok_id', 'brok_futr_id'
138
+ ]
139
+
140
+ if fund_code_list is None and fund_cn_abbr_list is None \
141
+ and fund_cn_fn_list is None and kord_num_list is None:
142
+ warnings.warn("函数[get_fund_info]的参数"
143
+ "(fund_code_list, fund_cn_abbr_list, fund_cn_fn_list, kord_num_list)"
144
+ "不能全部为空")
145
+ return None
146
+
147
+ if isinstance(fund_code_list, str):
148
+ fund_code_list = fund_code_list.split(',')
149
+
150
+ if isinstance(fund_cn_abbr_list, str):
151
+ fund_cn_abbr_list = fund_cn_abbr_list.split(',')
152
+
153
+ if isinstance(fund_cn_fn_list, str):
154
+ fund_cn_fn_list = fund_cn_fn_list.split(',')
155
+
156
+ if isinstance(kord_num_list, str):
157
+ kord_num_list = kord_num_list.split(',')
158
+
159
+ params = {
160
+ "fund_code_list": fund_code_list,
161
+ "fund_cn_abbr_list": fund_cn_abbr_list,
162
+ "fund_cn_fn_list": fund_cn_fn_list,
163
+ "kord_num_list": kord_num_list,
164
+ "cols": cols,
165
+ "rslt_type": rslt_type,
166
+ "int_param": int_param,
167
+ "float_param": float_param
168
+ }
169
+ return get_data("pof/get_fund_info", **params)
170
+
171
+
172
+ def get_all_funds(qury_date, fund_stat=2, cols=None, rslt_type=0):
173
+ """
174
+ 获取所有基金
175
+
176
+ """
177
+
178
+ int_param = \
179
+ [
180
+ 'fund_stat', 'perf_basi'
181
+ ]
182
+ float_param = \
183
+ [
184
+
185
+ ]
186
+ if cols:
187
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
188
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
189
+ else:
190
+ cols = [
191
+ 'fund_code', 'fund_cn_abbr', 'fund_cn_fn', 'corp_cn_abbr', 'fund_mngr',
192
+ 'perf_strt_date', 'clr_date', 'fund_stat', 'pri_basi_id', 'perf_basi'
193
+ ]
194
+
195
+ if qury_date:
196
+ params = {
197
+ "qury_date": qury_date,
198
+ "fund_stat": fund_stat,
199
+ "cols": cols,
200
+ "rslt_type": rslt_type,
201
+ "int_param": int_param,
202
+ "float_param": float_param
203
+ }
204
+ return get_data("pof/get_all_funds", **params)
205
+ else:
206
+ warnings.warn("函数[get_all_funds]的参数(qury_date)为必填项")
207
+ return None
208
+
209
+
210
+ def get_fund_fee(fund_code_list, cols=None, rslt_type=0):
211
+ """
212
+ 获取基金费率
213
+
214
+ """
215
+
216
+ int_param = \
217
+ [
218
+ ]
219
+ float_param = \
220
+ [
221
+ 'min_scrp_shr', 'appd_scrp_shr', 'max_scrp_fee', 'max_redp_fee',
222
+ 'purs_fee', 'ivsm_advr_fee', 'mngr_aep', 'cstd_fee', 'perf_remu',
223
+ 'warl', 'stopl', 'oper_serv_fee'
224
+ ]
225
+ if cols:
226
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
227
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
228
+ else:
229
+ cols = [
230
+ 'fund_code', 'min_scrp_shr', 'appd_scrp_shr', 'max_scrp_fee',
231
+ 'scrp_fee_expl', 'max_redp_fee', 'redp_fee_expl', 'expl_ahed_app_time',
232
+ 'aep_accr_pd', 'purs_fee', 'purs_fee_expl', 'ivsm_advr_fee', 'mngr_aep',
233
+ 'cstd_fee', 'perf_remu', 'perf_remu_expl', 'accr_mode', 'accr_freq',
234
+ 'accr_day_type', 'warl', 'stopl', 'stopl_expl', 'oper_serv_fee'
235
+ ]
236
+
237
+ if fund_code_list:
238
+
239
+ if isinstance(fund_code_list, str):
240
+ fund_code_list = fund_code_list.split(',')
241
+
242
+ params = {
243
+ "fund_code_list": fund_code_list,
244
+ "cols": cols,
245
+ "rslt_type": rslt_type,
246
+ "int_param": int_param,
247
+ "float_param": float_param
248
+ }
249
+ return get_data("pof/get_fund_fee", **params)
250
+ else:
251
+ warnings.warn("函数[get_fund_fee]的参数(fund_code_list)为必填项")
252
+ return None
253
+
254
+
255
+ def get_fund_attributes(fund_code_list, cols=None, rslt_type=0):
256
+ """
257
+ 获取基金属性
258
+
259
+ """
260
+
261
+ int_param = \
262
+ [
263
+ 'is_mstfd', 'is_umbrl', 'tot_flag', 'is_shr', 'fee_clas_a', 'fee_clas_oth'
264
+ ]
265
+ float_param = \
266
+ [
267
+
268
+ ]
269
+ if cols:
270
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
271
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
272
+ else:
273
+ cols = [
274
+ 'fund_code', 'is_mstfd', 'is_umbrl', 'tot_flag', 'is_shr', 'fee_clas_a', 'fee_clas_oth'
275
+ ]
276
+
277
+ if fund_code_list:
278
+
279
+ if isinstance(fund_code_list, str):
280
+ fund_code_list = fund_code_list.split(',')
281
+
282
+ params = {
283
+ "fund_code_list": fund_code_list,
284
+ "cols": cols,
285
+ "rslt_type": rslt_type,
286
+ "int_param": int_param,
287
+ "float_param": float_param
288
+ }
289
+ return get_data("pof/get_fund_attributes", **params)
290
+ else:
291
+ warnings.warn("函数[get_fund_attributes]的参数(fund_code_list)为必填项")
292
+ return None
293
+
294
+
295
+ def get_company_info(corp_id_list=None, corp_cn_abbr_list=None, corp_cn_fn_list=None, cols=None, rslt_type=0):
296
+ """
297
+ 获取基金相关公司信息
298
+
299
+ """
300
+
301
+ int_param = \
302
+ [
303
+ 'corp_type', 'reg_stat', 'mem_type', 'ins_clas_code', 'corp_ast_scal'
304
+ ]
305
+ float_param = \
306
+ [
307
+
308
+ ]
309
+ if cols:
310
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
311
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
312
+ else:
313
+ cols = [
314
+ 'corp_id', 'corp_cn_fn', 'corp_cn_abbr', 'corp_type', 'setp_date',
315
+ 'unif_soci_cred_code', 'city', 'prov', 'cntr', 'reg_city', 'reg_prov',
316
+ 'reg_cntr', 'reg_stat', 'reg_date', 'mem_type', 'ins_clas_code', 'corp_ast_scal'
317
+ ]
318
+
319
+ if corp_id_list is None and corp_cn_abbr_list is None and corp_cn_fn_list is None:
320
+ warnings.warn("函数[get_company_info]的参数"
321
+ "(corp_id_list, corp_cn_abbr_list, corp_cn_fn_list)"
322
+ "不能全部为空")
323
+ return None
324
+
325
+ if isinstance(corp_id_list, str):
326
+ corp_id_list = corp_id_list.split(',')
327
+
328
+ if isinstance(corp_cn_abbr_list, str):
329
+ corp_cn_abbr_list = corp_cn_abbr_list.split(',')
330
+
331
+ if isinstance(corp_cn_fn_list, str):
332
+ corp_cn_fn_list = corp_cn_fn_list.split(',')
333
+
334
+ params = {
335
+ "corp_id_list": corp_id_list,
336
+ "corp_cn_abbr_list": corp_cn_abbr_list,
337
+ "corp_cn_fn_list": corp_cn_fn_list,
338
+ "cols": cols,
339
+ "rslt_type": rslt_type,
340
+ "int_param": int_param,
341
+ "float_param": float_param
342
+ }
343
+ return get_data("pof/get_company_info", **params)
344
+
345
+
346
+ def get_all_companies(city, reg_stat=2, corp_ast_scal=None, corp_type=None, cols=None, rslt_type=0):
347
+ """
348
+ 获取所有公司
349
+
350
+ """
351
+
352
+ int_param = \
353
+ [
354
+ 'corp_type', 'reg_stat', 'mem_type', 'ins_clas_code', 'corp_ast_scal'
355
+ ]
356
+ float_param = \
357
+ [
358
+
359
+ ]
360
+ if cols:
361
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
362
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
363
+ else:
364
+ cols = [
365
+ 'corp_id', 'corp_cn_fn', 'corp_cn_abbr', 'corp_type',
366
+ 'setp_date', 'unif_soci_cred_code', 'city', 'prov', 'cntr',
367
+ 'reg_city', 'reg_prov', 'reg_cntr', 'reg_stat', 'reg_date',
368
+ 'mem_type', 'ins_clas_code', 'corp_ast_scal'
369
+ ]
370
+
371
+ if city:
372
+ params = {
373
+ "city": city,
374
+ "reg_stat": reg_stat,
375
+ "corp_ast_scal": corp_ast_scal,
376
+ "corp_type": corp_type,
377
+ "cols": cols,
378
+ "rslt_type": rslt_type,
379
+ "int_param": int_param,
380
+ "float_param": float_param
381
+ }
382
+ return get_data("pof/get_all_companies", **params)
383
+ else:
384
+ warnings.warn("函数[get_all_companies]的参数(city)为必填项")
385
+ return None
386
+
387
+
388
+ def get_company_shareholder(corp_id_list, is_last=1, cols=None, rslt_type=0):
389
+ """
390
+ 获取公司股权结构信息
391
+
392
+ """
393
+
394
+ int_param = \
395
+ [
396
+ 'crrc', 'shah_type', 'data_src', 'is_last'
397
+ ]
398
+ float_param = \
399
+ [
400
+ 'hold_rati', 'sscr_amt', 'paid_amt'
401
+ ]
402
+ if cols:
403
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
404
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
405
+ else:
406
+ cols = [
407
+ 'corp_id', 'shah_id', 'shah_name', 'hold_rati', 'sscr_amt',
408
+ 'sscr_date', 'paid_amt', 'paid_date', 'crrc', 'shah_type',
409
+ 'inpt_date', 'data_src', 'is_last'
410
+ ]
411
+
412
+ if corp_id_list:
413
+
414
+ if isinstance(corp_id_list, str):
415
+ corp_id_list = corp_id_list.split(',')
416
+
417
+ params = {
418
+ "corp_id_list": corp_id_list,
419
+ "is_last": is_last,
420
+ "cols": cols,
421
+ "rslt_type": rslt_type,
422
+ "int_param": int_param,
423
+ "float_param": float_param
424
+ }
425
+ return get_data("pof/get_company_shareholder", **params)
426
+ else:
427
+ warnings.warn("函数[get_company_shareholder]的参数(corp_id_list)为必填项")
428
+ return None
429
+
430
+
431
+ def get_company_honor(corp_id_list, cols=None, rslt_type=0):
432
+ """
433
+ 获取公司荣誉信息
434
+
435
+ """
436
+
437
+ int_param = \
438
+ [
439
+
440
+ ]
441
+ float_param = \
442
+ [
443
+
444
+ ]
445
+ if cols:
446
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
447
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
448
+ else:
449
+ cols = [
450
+ 'corp_id', 'corp_cn_fn', 'earn_year', 'prze_name', 'prze_sitm', 'org_name'
451
+ ]
452
+
453
+ if corp_id_list:
454
+
455
+ if isinstance(corp_id_list, str):
456
+ corp_id_list = corp_id_list.split(',')
457
+
458
+ params = {
459
+ "corp_id_list": corp_id_list,
460
+ "cols": cols,
461
+ "rslt_type": rslt_type,
462
+ "int_param": int_param,
463
+ "float_param": float_param
464
+ }
465
+ return get_data("pof/get_company_honor", **params)
466
+ else:
467
+ warnings.warn("函数[get_company_honor]的参数(corp_id_list)为必填项")
468
+ return None
469
+
470
+
471
+ def get_personnel_honor(prsn_id_list, cols=None, rslt_type=0):
472
+ """
473
+ 获取公司历史管理规模
474
+
475
+ """
476
+
477
+ int_param = \
478
+ [
479
+
480
+ ]
481
+ float_param = \
482
+ [
483
+
484
+ ]
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
+ 'prsn_id', 'prsn_name', 'earn_date', 'prze_name', 'prze_sitm', 'org_name'
491
+ ]
492
+
493
+ if prsn_id_list:
494
+
495
+ if isinstance(prsn_id_list, str):
496
+ prsn_id_list = prsn_id_list.split(',')
497
+
498
+ params = {
499
+ "prsn_id_list": prsn_id_list,
500
+ "cols": cols,
501
+ "rslt_type": rslt_type,
502
+ "int_param": int_param,
503
+ "float_param": float_param
504
+ }
505
+ return get_data("pof/get_personnel_honor", **params)
506
+ else:
507
+ warnings.warn("函数[get_personnel_honor]的参数(prsn_id_list)为必填项")
508
+ return None
509
+
510
+
511
+ def get_fund_honor(fund_code_list, cols=None, rslt_type=0):
512
+ """
513
+ 获取基金荣誉信息
514
+
515
+ """
516
+
517
+ int_param = \
518
+ [
519
+
520
+ ]
521
+ float_param = \
522
+ [
523
+
524
+ ]
525
+ if cols:
526
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
527
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
528
+ else:
529
+ cols = [
530
+ 'fund_code', 'fund_name', 'earn_year', 'prze_name', 'prze_sitm', 'org_name'
531
+ ]
532
+
533
+ if fund_code_list:
534
+
535
+ if isinstance(fund_code_list, str):
536
+ fund_code_list = fund_code_list.split(',')
537
+
538
+ params = {
539
+ "fund_code_list": fund_code_list,
540
+ "cols": cols,
541
+ "rslt_type": rslt_type,
542
+ "int_param": int_param,
543
+ "float_param": float_param
544
+ }
545
+ return get_data("pof/get_fund_honor", **params)
546
+ else:
547
+ warnings.warn("函数[get_fund_honor]的参数(fund_code_list)为必填项")
548
+ return None
549
+
550
+
551
+ def get_personnel_info(prsn_id_list=None, prsn_name_list=None, cols=None, rslt_type=0):
552
+ """
553
+ 获取人员信息
554
+
555
+ """
556
+
557
+ int_param = \
558
+ [
559
+ 'occu_bkgd', 'occu_year', 'sex', 'edu', 'is_qlfy'
560
+ ]
561
+ float_param = \
562
+ [
563
+
564
+ ]
565
+ if cols:
566
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
567
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
568
+ else:
569
+ cols = [
570
+ 'prsn_id', 'prsn_name', 'occu_bkgd', 'occu_strt_year',
571
+ 'occu_year', 'sex', 'edu', 'intr', 'qlfy_mode', 'is_qlfy',
572
+ 'prze_name'
573
+ ]
574
+
575
+ if prsn_id_list is None and prsn_name_list is None:
576
+ warnings.warn("函数[get_personnel_info]的参数"
577
+ "(prsn_id_list, prsn_name_list)"
578
+ "不能全部为空")
579
+ return None
580
+
581
+ if isinstance(prsn_id_list, str):
582
+ prsn_id_list = prsn_id_list.split(',')
583
+
584
+ if isinstance(prsn_name_list, str):
585
+ prsn_name_list = prsn_name_list.split(',')
586
+
587
+ params = {
588
+ "prsn_id_list": prsn_id_list,
589
+ "prsn_name_list": prsn_name_list,
590
+ "cols": cols,
591
+ "rslt_type": rslt_type,
592
+ "int_param": int_param,
593
+ "float_param": float_param
594
+ }
595
+ return get_data("pof/get_personnel_info", **params)
596
+
597
+
598
+ def get_all_personnel(edu=5, occu_bkgd=13, is_qlfy=1, cols=None, rslt_type=0):
599
+ """
600
+ 获取所有人员
601
+
602
+ """
603
+
604
+ int_param = \
605
+ [
606
+ 'occu_bkgd', 'occu_year', 'sex', 'edu', 'is_qlfy'
607
+ ]
608
+ float_param = \
609
+ [
610
+
611
+ ]
612
+ if cols:
613
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
614
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
615
+ else:
616
+ cols = [
617
+ 'prsn_id', 'prsn_name', 'occu_bkgd', 'occu_strt_year',
618
+ 'occu_year', 'sex', 'edu', 'intr', 'qlfy_mode', 'is_qlfy',
619
+ 'prze_name'
620
+ ]
621
+
622
+ params = {
623
+ "edu": edu,
624
+ "occu_bkgd": occu_bkgd,
625
+ "is_qlfy": is_qlfy,
626
+ "cols": cols,
627
+ "rslt_type": rslt_type,
628
+ "int_param": int_param,
629
+ "float_param": float_param
630
+ }
631
+ return get_data("pof/get_all_personnel", **params)
632
+
633
+
634
+ def get_personnel_company_map(prsn_id_list=None, corp_id_list=None, cols=None, rslt_type=0):
635
+ """
636
+ 获取基金人员与公司映射
637
+
638
+ """
639
+
640
+ int_param = \
641
+ [
642
+ 'corp_onum', 'prsn_onum', 'is_core',
643
+ 'is_incl', 'is_leav', 'is_exec', 'is_legp'
644
+ ]
645
+ float_param = \
646
+ [
647
+
648
+ ]
649
+ if cols:
650
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
651
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
652
+ else:
653
+ cols = [
654
+ 'prsn_id', 'corp_id', 'corp_onum', 'prsn_onum', 'is_core',
655
+ 'is_incl', 'is_leav', 'is_exec', 'is_legp', 'strt_date', 'end_date'
656
+ ]
657
+
658
+ if isinstance(prsn_id_list, str):
659
+ prsn_id_list = prsn_id_list.split(',')
660
+
661
+ if isinstance(corp_id_list, str):
662
+ corp_id_list = corp_id_list.split(',')
663
+
664
+ params = {
665
+ "prsn_id_list": prsn_id_list,
666
+ "corp_id_list": corp_id_list,
667
+ "cols": cols,
668
+ "rslt_type": rslt_type,
669
+ "int_param": int_param,
670
+ "float_param": float_param
671
+ }
672
+ return get_data("pof/get_personnel_company_map", **params)
673
+
674
+
675
+ def get_assets_allocation(fund_code, strt_date='19000101', end_date=None, cols=None, rslt_type=0):
676
+ """
677
+ 获取基金大类资产配置
678
+
679
+ """
680
+
681
+ int_param = \
682
+ [
683
+ 'data_type', 'max_ctb'
684
+ ]
685
+ float_param = \
686
+ [
687
+ 'alpha', 'csi300_agil', 'csi300_ctb',
688
+ 'cnbd_agil', 'cnbd_ctb', 'megr_futr_agil', 'megr_futr_ctb',
689
+ 'cash_agil', 'cash_ctb', 'crrc_perf_beta', 'crrc_perf_ctb',
690
+ 'rsdu', 'fitgdn'
691
+ ]
692
+ if cols:
693
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
694
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
695
+ else:
696
+ cols = [
697
+ 'fund_code', 'nv_pbsh_date', 'data_type', 'alpha', 'csi300_agil',
698
+ 'csi300_ctb', 'cnbd_agil', 'cnbd_ctb', 'megr_futr_agil', 'megr_futr_ctb',
699
+ 'cash_agil', 'cash_ctb', 'crrc_perf_beta', 'crrc_perf_ctb',
700
+ 'max_ctb', 'rsdu', 'fitgdn'
701
+ ]
702
+
703
+ if end_date is None:
704
+ end_date = get_current_date()
705
+
706
+ if fund_code:
707
+ params = {
708
+ "fund_code": fund_code,
709
+ "strt_date": strt_date,
710
+ "end_date": end_date,
711
+ "cols": cols,
712
+ "rslt_type": rslt_type,
713
+ "int_param": int_param,
714
+ "float_param": float_param
715
+ }
716
+ return get_data("pof/get_assets_allocation", **params)
717
+ else:
718
+ warnings.warn("函数[get_assets_allocation]的参数(fund_code)为必填项")
719
+ return None
720
+
721
+
722
+ def get_industry_sw(fund_code, strt_date='19000101', end_date=None, cols=None, rslt_type=0):
723
+ """
724
+ 获取基金申万行业配置
725
+
726
+ """
727
+
728
+ int_param = \
729
+ [
730
+ 'data_type', 'max_ctb'
731
+ ]
732
+ float_param = \
733
+ [
734
+ 'alpha',
735
+ 'sw_110_agil', 'sw_110_ctb', 'sw_210_agil', 'sw_210_ctb',
736
+ 'sw_220_agil', 'sw_220_ctb', 'sw_230_agil', 'sw_230_ctb',
737
+ 'sw_240_agil', 'sw_240_ctb', 'sw_270_beta', 'sw_270_ctb',
738
+ 'sw_280_beta', 'sw_280_ctb', 'sw_330_beta', 'sw_330_ctb',
739
+ 'sw_340_beta', 'sw_340_ctb', 'sw_350_beta', 'sw_350_ctb',
740
+ 'sw_360_beta', 'sw_360_ctb', 'sw_370_beta', 'sw_370_ctb',
741
+ 'sw_410_beta', 'sw_410_ctb', 'sw_420_beta', 'sw_420_ctb',
742
+ 'sw_430_beta', 'sw_430_ctb', 'sw_450_beta', 'sw_450_ctb',
743
+ 'sw_460_beta', 'sw_460_ctb', 'sw_480_beta', 'sw_480_ctb',
744
+ 'sw_490_beta', 'sw_490_ctb', 'sw_510_beta', 'sw_510_ctb',
745
+ 'sw_610_beta', 'sw_610_ctb', 'sw_620_beta', 'sw_620_ctb',
746
+ 'sw_630_beta', 'sw_630_ctb', 'sw_640_beta', 'sw_640_ctb',
747
+ 'sw_650_beta', 'sw_650_ctb', 'sw_710_beta', 'sw_710_ctb',
748
+ 'sw_720_beta', 'sw_720_ctb', 'sw_730_beta', 'sw_730_ctb',
749
+ 'rsdu', 'fitgdn'
750
+ ]
751
+ if cols:
752
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
753
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
754
+ else:
755
+ cols = [
756
+ 'fund_code', 'nv_pbsh_date', 'data_type', 'alpha',
757
+ 'sw_110_agil', 'sw_110_ctb', 'sw_210_agil', 'sw_210_ctb',
758
+ 'sw_220_agil', 'sw_220_ctb', 'sw_230_agil', 'sw_230_ctb',
759
+ 'sw_240_agil', 'sw_240_ctb', 'sw_270_beta', 'sw_270_ctb',
760
+ 'sw_280_beta', 'sw_280_ctb', 'sw_330_beta', 'sw_330_ctb',
761
+ 'sw_340_beta', 'sw_340_ctb', 'sw_350_beta', 'sw_350_ctb',
762
+ 'sw_360_beta', 'sw_360_ctb', 'sw_370_beta', 'sw_370_ctb',
763
+ 'sw_410_beta', 'sw_410_ctb', 'sw_420_beta', 'sw_420_ctb',
764
+ 'sw_430_beta', 'sw_430_ctb', 'sw_450_beta', 'sw_450_ctb',
765
+ 'sw_460_beta', 'sw_460_ctb', 'sw_480_beta', 'sw_480_ctb',
766
+ 'sw_490_beta', 'sw_490_ctb', 'sw_510_beta', 'sw_510_ctb',
767
+ 'sw_610_beta', 'sw_610_ctb', 'sw_620_beta', 'sw_620_ctb',
768
+ 'sw_630_beta', 'sw_630_ctb', 'sw_640_beta', 'sw_640_ctb',
769
+ 'sw_650_beta', 'sw_650_ctb', 'sw_710_beta', 'sw_710_ctb',
770
+ 'sw_720_beta', 'sw_720_ctb', 'sw_730_beta', 'sw_730_ctb',
771
+ 'max_ctb', 'rsdu', 'fitgdn'
772
+ ]
773
+
774
+ if end_date is None:
775
+ end_date = get_current_date()
776
+
777
+ if fund_code:
778
+ params = {
779
+ "fund_code": fund_code,
780
+ "strt_date": strt_date,
781
+ "end_date": end_date,
782
+ "cols": cols,
783
+ "rslt_type": rslt_type,
784
+ "int_param": int_param,
785
+ "float_param": float_param
786
+ }
787
+ return get_data("pof/get_industry_sw", **params)
788
+ else:
789
+ warnings.warn("函数[get_industry_sw]的参数(fund_code)为必填项")
790
+ return None
791
+
792
+
793
+ def get_industry_zz(fund_code, strt_date='19000101', end_date=None, cols=None, rslt_type=0):
794
+ """
795
+ 获取基金中证行业配置
796
+
797
+ """
798
+
799
+ int_param = \
800
+ [
801
+ 'data_type', 'max_ctb'
802
+ ]
803
+ float_param = \
804
+ [
805
+ 'alpha', 'zz_00_beta',
806
+ 'zz_00_ctb', 'zz_01_beta', 'zz_01_ctb', 'zz_02_beta', 'zz_02_ctb',
807
+ 'zz_03_beta', 'zz_03_ctb', 'zz_04_beta', 'zz_04_ctb', 'zz_05_beta',
808
+ 'zz_05_ctb', 'zz_06_beta', 'zz_06_ctb', 'zz_07_beta', 'zz_07_ctb',
809
+ 'zz_08_beta', 'zz_08_ctb', 'zz_09_beta', 'zz_09_ctb ', 'crrc_perf_beta',
810
+ 'crrc_perf_ctb', 'rsdu', 'fitgdn'
811
+ ]
812
+ if cols:
813
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
814
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
815
+ else:
816
+ cols = [
817
+ 'fund_code', 'nv_pbsh_date', 'data_type', 'alpha', 'zz_00_beta',
818
+ 'zz_00_ctb', 'zz_01_beta', 'zz_01_ctb', 'zz_02_beta', 'zz_02_ctb',
819
+ 'zz_03_beta', 'zz_03_ctb', 'zz_04_beta', 'zz_04_ctb', 'zz_05_beta',
820
+ 'zz_05_ctb', 'zz_06_beta', 'zz_06_ctb', 'zz_07_beta', 'zz_07_ctb',
821
+ 'zz_08_beta', 'zz_08_ctb', 'zz_09_beta', 'zz_09_ctb', 'crrc_perf_beta',
822
+ 'crrc_perf_ctb', 'max_ctb', 'rsdu', 'fitgdn'
823
+ ]
824
+
825
+ if end_date is None:
826
+ end_date = get_current_date()
827
+
828
+ if fund_code:
829
+ params = {
830
+ "fund_code": fund_code,
831
+ "strt_date": strt_date,
832
+ "end_date": end_date,
833
+ "cols": cols,
834
+ "rslt_type": rslt_type,
835
+ "int_param": int_param,
836
+ "float_param": float_param
837
+ }
838
+ return get_data("pof/get_industry_zz", **params)
839
+ else:
840
+ warnings.warn("函数[get_industry_zz]的参数(fund_code)为必填项")
841
+ return None
842
+
843
+
844
+ def get_industry_zx(fund_code, strt_date='19000101', end_date=None, cols=None, rslt_type=0):
845
+ """
846
+ 获取基金中信行业配置
847
+
848
+ """
849
+
850
+ int_param = \
851
+ [
852
+ 'data_type', 'max_ctb'
853
+ ]
854
+ float_param = \
855
+ [
856
+ 'alpha',
857
+ 'citc_finl_agil', 'citc_finl_ctb', 'citc_pd_agil',
858
+ 'citc_pd_ctb', 'citc_cons_agil', 'citc_cons_ctb',
859
+ 'citc_grow_agil', 'citc_grow_ctb', 'citc_stb_agil',
860
+ 'citc_stb_ctb', 'crrc_perf_beta', 'crrc_perf_ctb',
861
+ 'rsdu', 'fitgdn'
862
+ ]
863
+ if cols:
864
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
865
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
866
+ else:
867
+ cols = [
868
+ 'fund_code', 'nv_pbsh_date', 'data_type', 'alpha',
869
+ 'citc_finl_agil', 'citc_finl_ctb', 'citc_pd_agil',
870
+ 'citc_pd_ctb', 'citc_cons_agil', 'citc_cons_ctb',
871
+ 'citc_grow_agil', 'citc_grow_ctb', 'citc_stb_agil',
872
+ 'citc_stb_ctb', 'crrc_perf_beta', 'crrc_perf_ctb',
873
+ 'max_ctb', 'rsdu', 'fitgdn'
874
+ ]
875
+
876
+ if end_date is None:
877
+ end_date = get_current_date()
878
+
879
+ if fund_code:
880
+ params = {
881
+ "fund_code": fund_code,
882
+ "strt_date": strt_date,
883
+ "end_date": end_date,
884
+ "cols": cols,
885
+ "rslt_type": rslt_type,
886
+ "int_param": int_param,
887
+ "float_param": float_param
888
+ }
889
+ return get_data("pof/get_industry_zx", **params)
890
+ else:
891
+ warnings.warn("函数[get_industry_zx]的参数(fund_code)为必填项")
892
+ return None
893
+
894
+
895
+ def get_allocation_jc(fund_code, strt_date='19000101', end_date=None, cols=None, rslt_type=0):
896
+ """
897
+ 获取基金巨潮行业配置
898
+
899
+ """
900
+
901
+ int_param = \
902
+ [
903
+ 'data_type', 'max_ctb'
904
+ ]
905
+ float_param = \
906
+ [
907
+ 'alpha', 'makt_grow_agil',
908
+ 'makt_grow_ctb', 'makt_val_agil', 'makt_val_ctb', 'midg_grow_agil',
909
+ 'midg_grow_ctb', 'midg_val_agil', 'midg_val_ctb', 'smalp_grow_agil',
910
+ 'smalp_grow_ctb', 'smalp_val_agil', 'smalp_val_ctb', 'crrc_perf_beta',
911
+ 'crrc_perf_ctb', 'rsdu', 'fitgdn'
912
+ ]
913
+ if cols:
914
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
915
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
916
+ else:
917
+ cols = [
918
+ 'fund_code', 'nv_pbsh_date', 'data_type', 'alpha', 'makt_grow_agil',
919
+ 'makt_grow_ctb', 'makt_val_agil', 'makt_val_ctb', 'midg_grow_agil',
920
+ 'midg_grow_ctb', 'midg_val_agil', 'midg_val_ctb', 'smalp_grow_agil',
921
+ 'smalp_grow_ctb', 'smalp_val_agil', 'smalp_val_ctb', 'crrc_perf_beta',
922
+ 'crrc_perf_ctb', 'max_ctb', 'rsdu', 'fitgdn'
923
+ ]
924
+
925
+ if end_date is None:
926
+ end_date = get_current_date()
927
+
928
+ if fund_code:
929
+ params = {
930
+ "fund_code": fund_code,
931
+ "strt_date": strt_date,
932
+ "end_date": end_date,
933
+ "cols": cols,
934
+ "rslt_type": rslt_type,
935
+ "int_param": int_param,
936
+ "float_param": float_param
937
+ }
938
+ return get_data("pof/get_allocation_jc", **params)
939
+ else:
940
+ warnings.warn("函数[get_allocation_jc]的参数(fund_code)为必填项")
941
+ return None
942
+
943
+
944
+ def get_bond_attribution(fund_code, strt_date='19000101', end_date=None, cols=None, rslt_type=0):
945
+ """
946
+ 获取基金债券因子暴露
947
+
948
+ """
949
+
950
+ int_param = \
951
+ [
952
+ ]
953
+ float_param = \
954
+ [
955
+ 'alpha',
956
+ 'durt_mag_perf_beta', 'durt_mag_perf_ctb', 'maty_stru_perf_beta',
957
+ 'maty_stru_perf_ctb', 'max_maty_perf_beta', 'max_maty_perf_ctb',
958
+ 'cbnd_perf_beta', 'cbnd_perf_ctb', 'max_payf_cbnd_perf_beta',
959
+ 'max_payf_cbnd_perf_ctb', 'cvtb_perf_beta', 'cvtb_perf_ctb',
960
+ 'crrc_perf_beta', 'crrc_perf_ctb', 'rsdu', 'fitgdn'
961
+ ]
962
+ if cols:
963
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
964
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
965
+ else:
966
+ cols = [
967
+ 'fund_code', 'nv_pbsh_date', 'alpha',
968
+ 'durt_mag_perf_beta', 'durt_mag_perf_ctb', 'maty_stru_perf_beta',
969
+ 'maty_stru_perf_ctb', 'max_maty_perf_beta', 'max_maty_perf_ctb',
970
+ 'cbnd_perf_beta', 'cbnd_perf_ctb', 'max_payf_cbnd_perf_beta',
971
+ 'max_payf_cbnd_perf_ctb', 'cvtb_perf_beta', 'cvtb_perf_ctb',
972
+ 'crrc_perf_beta', 'crrc_perf_ctb', 'rsdu', 'fitgdn'
973
+ ]
974
+
975
+ if end_date is None:
976
+ end_date = get_current_date()
977
+
978
+ if fund_code:
979
+ params = {
980
+ "fund_code": fund_code,
981
+ "strt_date": strt_date,
982
+ "end_date": end_date,
983
+ "cols": cols,
984
+ "rslt_type": rslt_type,
985
+ "int_param": int_param,
986
+ "float_param": float_param
987
+ }
988
+ return get_data("pof/get_bond_attribution", **params)
989
+ else:
990
+ warnings.warn("函数[get_bond_attribution]的参数(fund_code)为必填项")
991
+ return None
992
+
993
+
994
+ def get_futures_assets_allocation(fund_code, strt_date='19000101', end_date=None, cols=None, rslt_type=0):
995
+ """
996
+ 获取基金期货配置
997
+
998
+ """
999
+
1000
+ int_param = \
1001
+ [
1002
+ 'data_type', 'max_ctb'
1003
+ ]
1004
+ float_param = \
1005
+ [
1006
+ 'alpha',
1007
+ 'csi300_agil', 'csi300_ctb', 'agri_pd_agil', 'agri_pd_ctb',
1008
+ 'idst_futr_indx_agil', 'idst_futr_indx_ctb', 'crrc_perf_beta',
1009
+ 'crrc_perf_ctb', 'rsdu', 'fitgdn'
1010
+ ]
1011
+ if cols:
1012
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
1013
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
1014
+ else:
1015
+ cols = [
1016
+ 'fund_code', 'nv_pbsh_date', 'data_type', 'alpha',
1017
+ 'csi300_agil', 'csi300_ctb', 'agri_pd_agil', 'agri_pd_ctb',
1018
+ 'idst_futr_indx_agil', 'idst_futr_indx_ctb', 'crrc_perf_beta',
1019
+ 'crrc_perf_ctb', 'max_ctb', 'rsdu', 'fitgdn'
1020
+ ]
1021
+
1022
+ if end_date is None:
1023
+ end_date = get_current_date()
1024
+
1025
+ if fund_code:
1026
+ params = {
1027
+ "fund_code": fund_code,
1028
+ "strt_date": strt_date,
1029
+ "end_date": end_date,
1030
+ "cols": cols,
1031
+ "rslt_type": rslt_type,
1032
+ "int_param": int_param,
1033
+ "float_param": float_param
1034
+ }
1035
+ return get_data("pof/get_futures_assets_allocation", **params)
1036
+ else:
1037
+ warnings.warn("函数[get_futures_assets_allocation]的参数(fund_code)为必填项")
1038
+ return None
1039
+
1040
+
1041
+ def get_performance(fund_code=None, fund_code_list=None, strt_date='19000101', end_date=None, cols=None, rslt_type=0):
1042
+ """
1043
+ 获取基金统计收益
1044
+
1045
+ """
1046
+
1047
+ int_param = \
1048
+ [
1049
+
1050
+ ]
1051
+ float_param = \
1052
+ [
1053
+ 'aggr_nav',
1054
+ 'ror_1m', 'ror_1m_basi', 'ror_3m', 'ror_3m_basi', 'ror_6m',
1055
+ 'ror_6m_basi', 'ror_1y', 'ror_1y_basi', 'ror_2y',
1056
+ 'ror_2y_basi', 'aror_2y', 'aror_2y_basi', 'ror_3y', 'ror_3y_basi',
1057
+ 'ror_3y_a', 'aror_3y_basi', 'ror_ytd', 'ror_ytd_basi', 'ror_incep',
1058
+ 'ror_incep_basi', 'aror_incep', 'aror_incep_basi'
1059
+ ]
1060
+ if cols:
1061
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
1062
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
1063
+ else:
1064
+ cols = [
1065
+ 'fund_code', 'aggr_nav_date', 'end_date', 'aggr_nav',
1066
+ 'ror_1m', 'ror_1m_basi', 'ror_3m', 'ror_3m_basi', 'ror_6m',
1067
+ 'ror_6m_basi', 'ror_1y', 'ror_1y_basi', 'ror_2y',
1068
+ 'ror_2y_basi', 'aror_2y', 'aror_2y_basi', 'ror_3y', 'ror_3y_basi',
1069
+ 'ror_3y_a', 'aror_3y_basi', 'ror_ytd', 'ror_ytd_basi', 'ror_incep',
1070
+ 'ror_incep_basi', 'aror_incep', 'aror_incep_basi'
1071
+ ]
1072
+
1073
+ if end_date is None:
1074
+ end_date = get_current_date()
1075
+
1076
+ if fund_code:
1077
+ params = {
1078
+ "fund_code": fund_code,
1079
+ "strt_date": strt_date,
1080
+ "end_date": end_date,
1081
+ "cols": cols,
1082
+ "rslt_type": rslt_type,
1083
+ "int_param": int_param,
1084
+ "float_param": float_param
1085
+ }
1086
+ return get_data("pof/get_performance", **params)
1087
+ elif fund_code_list:
1088
+ if isinstance(fund_code_list, str):
1089
+ fund_code_list = fund_code_list.split(',')
1090
+
1091
+ params = {
1092
+ "fund_code_list": fund_code_list,
1093
+ "strt_date": strt_date,
1094
+ "end_date": end_date,
1095
+ "cols": cols,
1096
+ "rslt_type": rslt_type,
1097
+ "int_param": int_param,
1098
+ "float_param": float_param
1099
+ }
1100
+ return get_data("pof/get_performance", **params)
1101
+ else:
1102
+ warnings.warn("函数[get_performance]的参数(fund_code或fund_code_list)不能全部为空")
1103
+ return None
1104
+
1105
+
1106
+ def get_performance_topn(firs_stra=1, yld_type=1, topN=10, cols=None, rslt_type=0):
1107
+ """
1108
+ 获取私募基金收益排行榜
1109
+
1110
+ """
1111
+
1112
+ int_param = \
1113
+ [
1114
+ 'firs_stra', 'secd_stra', 'thir_stra'
1115
+ ]
1116
+ float_param = \
1117
+ [
1118
+ 'ror_1m', 'ror_3m',
1119
+ 'ror_6m', 'ror_1y', 'ror_2y', 'ror_3y', 'ror_ytd'
1120
+ ]
1121
+ if cols:
1122
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
1123
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
1124
+ else:
1125
+ cols = [
1126
+ 'fund_code', 'end_date', 'fund_cn_abbr', 'fund_mngr',
1127
+ 'firs_stra', 'secd_stra', 'thir_stra', 'ror_1m', 'ror_3m',
1128
+ 'ror_6m', 'ror_1y', 'ror_2y', 'ror_3y', 'ror_ytd'
1129
+ ]
1130
+
1131
+ params = {
1132
+ "firs_stra": firs_stra,
1133
+ "yld_type": yld_type,
1134
+ "topN": topN,
1135
+ "cols": cols,
1136
+ "rslt_type": rslt_type,
1137
+ "int_param": int_param,
1138
+ "float_param": float_param
1139
+ }
1140
+ return get_data("pof/get_performance_topn", **params)
1141
+
1142
+
1143
+ def get_strategy_tree(stra_code=1, cols=None, rslt_type=0):
1144
+ """
1145
+ 获取私募基金收益排行榜
1146
+
1147
+ """
1148
+
1149
+ int_param = \
1150
+ [
1151
+ ]
1152
+ float_param = \
1153
+ [
1154
+ ]
1155
+ if cols:
1156
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
1157
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
1158
+ else:
1159
+ cols = [
1160
+ 'firs_stra', 'firs_stra_name', 'secd_stra', 'secd_stra_name', 'thir_stra', 'thir_stra_name'
1161
+ ]
1162
+
1163
+ if stra_code < 0:
1164
+ warnings.warn("函数[stra_code]的参数"
1165
+ "(stra_code)"
1166
+ "必须大于等于1")
1167
+ return None
1168
+
1169
+ params = {
1170
+ "stra_code": stra_code,
1171
+ "cols": cols,
1172
+ "rslt_type": rslt_type,
1173
+ "int_param": int_param,
1174
+ "float_param": float_param
1175
+ }
1176
+ return get_data("pof/get_strategy_tree", **params)
1177
+
1178
+
1179
+ def get_company_fund_map(fund_code_list=None, corp_id_list=None, cols=None, rslt_type=0):
1180
+ """
1181
+ 获取基金与基金公司映射关系
1182
+
1183
+ """
1184
+
1185
+ int_param = \
1186
+ [
1187
+ ]
1188
+ float_param = \
1189
+ [
1190
+ ]
1191
+ if cols:
1192
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
1193
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
1194
+ else:
1195
+ cols = [
1196
+ 'fund_code', 'fund_cn_abbr', 'fund_cn_fn', 'corp_id', 'setp_date'
1197
+ ]
1198
+
1199
+ if fund_code_list is None and corp_id_list is None:
1200
+ warnings.warn("函数[get_company_fund_map]的参数"
1201
+ "(fund_code_list, corp_id_list)"
1202
+ "不能全部为空")
1203
+ return None
1204
+
1205
+ if isinstance(fund_code_list, str):
1206
+ fund_code_list = fund_code_list.split(',')
1207
+
1208
+ if isinstance(corp_id_list, str):
1209
+ corp_id_list = corp_id_list.split(',')
1210
+
1211
+ params = {
1212
+ "fund_code_list": fund_code_list,
1213
+ "corp_id_list": corp_id_list,
1214
+ "cols": cols,
1215
+ "rslt_type": rslt_type,
1216
+ "int_param": int_param,
1217
+ "float_param": float_param
1218
+ }
1219
+ return get_data("pof/get_company_fund_map", **params)
1220
+
1221
+
1222
+ def get_manager_fund_map(fund_code_list=None, fund_mngr_id_list=None, cols=None, rslt_type=0):
1223
+ """
1224
+ 获取基金与基金经理映射关系
1225
+
1226
+ """
1227
+
1228
+ int_param = \
1229
+ [
1230
+ ]
1231
+ float_param = \
1232
+ [
1233
+ ]
1234
+ if cols:
1235
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
1236
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
1237
+ else:
1238
+ cols = [
1239
+ 'fund_code', 'fund_mngr_id', 'mngr_strt_date', 'mngr_end_date'
1240
+ ]
1241
+
1242
+ if isinstance(fund_code_list, str):
1243
+ fund_code_list = fund_code_list.split(',')
1244
+
1245
+ if isinstance(fund_mngr_id_list, str):
1246
+ fund_mngr_id_list = fund_mngr_id_list.split(',')
1247
+
1248
+ params = {
1249
+ "fund_code_list": fund_code_list,
1250
+ "fund_mngr_id_list": fund_mngr_id_list,
1251
+ "cols": cols,
1252
+ "rslt_type": rslt_type,
1253
+ "int_param": int_param,
1254
+ "float_param": float_param
1255
+ }
1256
+ return get_data("pof/get_manager_fund_map", **params)
1257
+
1258
+
1259
+ def get_personnel_company_map(corp_id_list=None, prsn_id_list=None, cols=None, rslt_type=0):
1260
+ """
1261
+ 获取人员公司任职映射关系
1262
+
1263
+ """
1264
+
1265
+ int_param = \
1266
+ [
1267
+ 'corp_onum', 'prsn_onum',
1268
+ 'is_core', 'is_incl', 'is_leav', 'is_exec', 'is_legp'
1269
+ ]
1270
+ float_param = \
1271
+ [
1272
+ ]
1273
+ if cols:
1274
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
1275
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
1276
+ else:
1277
+ cols = [
1278
+ 'prsn_id', 'corp_id', 'corp_onum', 'prsn_onum',
1279
+ 'is_core', 'is_incl', 'is_leav', 'is_exec', 'is_legp',
1280
+ 'strt_date', 'end_date'
1281
+ ]
1282
+
1283
+ if corp_id_list is None and prsn_id_list is None:
1284
+ warnings.warn("函数[get_personnel_company_map]的参数"
1285
+ "(corp_id_list, prsn_id_list)"
1286
+ "不能全部为空")
1287
+ return None
1288
+
1289
+ if isinstance(corp_id_list, str):
1290
+ corp_id_list = corp_id_list.split(',')
1291
+
1292
+ if isinstance(prsn_id_list, str):
1293
+ prsn_id_list = prsn_id_list.split(',')
1294
+
1295
+ params = {
1296
+ "corp_id_list": corp_id_list,
1297
+ "prsn_id_list": prsn_id_list,
1298
+ "cols": cols,
1299
+ "rslt_type": rslt_type,
1300
+ "int_param": int_param,
1301
+ "float_param": float_param
1302
+ }
1303
+ return get_data("pof/get_personnel_company_map", **params)
1304
+
1305
+
1306
+ def get_personnel_position(prsn_id_list=None, cols=None, rslt_type=0):
1307
+ """
1308
+ 获取人员职务信息
1309
+
1310
+ """
1311
+
1312
+ int_param = \
1313
+ [
1314
+ 'pos_orde'
1315
+ ]
1316
+ float_param = \
1317
+ [
1318
+ ]
1319
+ if cols:
1320
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
1321
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
1322
+ else:
1323
+ cols = [
1324
+ 'prsn_id', 'corp_id', 'pos_type', 'pos', 'dept', 'strt_date', 'end_date', 'pos_orde'
1325
+ ]
1326
+
1327
+ if isinstance(prsn_id_list, str):
1328
+ prsn_id_list = prsn_id_list.split(',')
1329
+
1330
+ params = {
1331
+ "prsn_id_list": prsn_id_list,
1332
+ "cols": cols,
1333
+ "rslt_type": rslt_type,
1334
+ "int_param": int_param,
1335
+ "float_param": float_param
1336
+ }
1337
+ return get_data("pof/get_personnel_position", **params)
1338
+
1339
+
1340
+ def get_strategy_fund_map(fund_code_list=None, stra_code=None, cols=None, rslt_type=0):
1341
+ """
1342
+ 获取基金与策略映射关系
1343
+
1344
+ """
1345
+
1346
+ int_param = \
1347
+ [
1348
+ 'firs_stra', 'secd_stra', 'thir_stra', 'src_type'
1349
+ ]
1350
+ float_param = \
1351
+ [
1352
+ ]
1353
+ if cols:
1354
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
1355
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
1356
+ else:
1357
+ cols = [
1358
+ 'fund_code', 'firs_stra', 'secd_stra', 'thir_stra', 'src_type'
1359
+ ]
1360
+
1361
+ if fund_code_list is None and stra_code is None:
1362
+ warnings.warn("函数[get_strategy_fund_map]的参数"
1363
+ "(fund_code_list, stra_code)"
1364
+ "不能全部为空")
1365
+ return None
1366
+ elif stra_code is not None \
1367
+ and stra_code < 1000 \
1368
+ and stra_code != 1:
1369
+ warnings.warn("函数[get_strategy_fund_map]的参数"
1370
+ "(stra_code)"
1371
+ "有效范围应大于1000")
1372
+ return None
1373
+
1374
+ if isinstance(fund_code_list, str):
1375
+ fund_code_list = fund_code_list.split(',')
1376
+
1377
+ if stra_code == None:
1378
+ stra_code = 1
1379
+
1380
+ params = {
1381
+ "fund_code_list": fund_code_list,
1382
+ "stra_code": stra_code,
1383
+ "cols": cols,
1384
+ "rslt_type": rslt_type,
1385
+ "int_param": int_param,
1386
+ "float_param": float_param
1387
+ }
1388
+ return get_data("pof/get_strategy_fund_map", **params)
1389
+
1390
+
1391
+ def get_benchmark_fund_map(fund_code_list=None, pri_basi_id_list=None, cols=None, rslt_type=0):
1392
+ """
1393
+ 获取基金与基准映射关系
1394
+
1395
+ """
1396
+
1397
+ int_param = \
1398
+ [
1399
+ ]
1400
+ float_param = \
1401
+ [
1402
+ ]
1403
+ if cols:
1404
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
1405
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
1406
+ else:
1407
+ cols = [
1408
+ 'fund_code', 'fund_cn_abbr', 'fund_cn_fn', 'pri_basi_id', 'perf_basi'
1409
+ ]
1410
+
1411
+ if fund_code_list is None and pri_basi_id_list is None:
1412
+ warnings.warn("函数[get_benchmark_fund_map]的参数"
1413
+ "(fund_code_list, pri_basi_id_list)"
1414
+ "不能全部为空")
1415
+ return None
1416
+
1417
+ if isinstance(fund_code_list, str):
1418
+ fund_code_list = fund_code_list.split(',')
1419
+
1420
+ if isinstance(pri_basi_id_list, str):
1421
+ pri_basi_id_list = pri_basi_id_list.split(',')
1422
+
1423
+ params = {
1424
+ "fund_code_list": fund_code_list,
1425
+ "pri_basi_id_list": pri_basi_id_list,
1426
+ "cols": cols,
1427
+ "rslt_type": rslt_type,
1428
+ "int_param": int_param,
1429
+ "float_param": float_param
1430
+ }
1431
+ return get_data("pof/get_benchmark_fund_map", **params)
1432
+
1433
+
1434
+ def get_index_confidence(strt_mth, end_mth, cols=None, rslt_type=0):
1435
+ """
1436
+ 获取对冲基金经理信心指数
1437
+
1438
+ """
1439
+
1440
+ int_param = \
1441
+ [
1442
+ 'indx_val',
1443
+ 'mkt_expe_indx', 'pos_plan_indx', 'me_extrm_optimstc',
1444
+ 'me_optimstc', 'me_nturl', 'me_psmstc', 'me_extrm_psmstc',
1445
+ 'pp_extrm_grow', 'pp_grow', 'pp_unchg', 'pp_redc', 'pp_extrm_redc'
1446
+ ]
1447
+ float_param = \
1448
+ [
1449
+ ]
1450
+ if cols:
1451
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
1452
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
1453
+ else:
1454
+ cols = [
1455
+ 'indx_id', 'indx_code', 'indx_date', 'indx_val',
1456
+ 'mkt_expe_indx', 'pos_plan_indx', 'me_extrm_optimstc',
1457
+ 'me_optimstc', 'me_nturl', 'me_psmstc', 'me_extrm_psmstc',
1458
+ 'pp_extrm_grow', 'pp_grow', 'pp_unchg', 'pp_redc', 'pp_extrm_redc'
1459
+ ]
1460
+
1461
+ if strt_mth is None or end_mth is None:
1462
+ warnings.warn("函数[get_index_confidence]的参数"
1463
+ "(strt_mth, end_mth)"
1464
+ "不能为空")
1465
+ return None
1466
+
1467
+ if len(strt_mth) == 6:
1468
+ strt_mth = '%s01' % strt_mth
1469
+ if len(end_mth) == 6:
1470
+ end_mth = '%s31' % end_mth
1471
+
1472
+ if strt_mth and end_mth:
1473
+ params = {
1474
+ "strt_mth": strt_mth,
1475
+ "end_mth": end_mth,
1476
+ "cols": cols,
1477
+ "rslt_type": rslt_type,
1478
+ "int_param": int_param,
1479
+ "float_param": float_param
1480
+ }
1481
+ return get_data("pof/get_index_confidence", **params)
1482
+ else:
1483
+ warnings.warn("函数[get_index_confidence]的参数(strt_mth, end_mth)为必填项")
1484
+ return None
1485
+
1486
+
1487
+ def get_index_info(indx_id_list=None, indx_code_list=None, cols=None, rslt_type=0):
1488
+ """
1489
+ 获取指数基本信息
1490
+
1491
+ """
1492
+
1493
+ int_param = \
1494
+ [
1495
+ 'indx_type', 'indx_area_flag', 'publ_freq',
1496
+ 'cal_crrc', 'ctrt_freq', 'adj_freq'
1497
+ ]
1498
+ float_param = \
1499
+ [
1500
+ 'init_val'
1501
+ ]
1502
+ if cols:
1503
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
1504
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
1505
+ else:
1506
+ cols = [
1507
+ 'indx_id', 'indx_type', 'indx_code', 'indx_name', 'indx_cn_abbr',
1508
+ 'indx_area_flag', 'ind_prov_id', 'publ_freq', 'publ_date',
1509
+ 'init_val', 'cal_crrc', 'cal_mode', 'wght_mode', 'scre_mode',
1510
+ 'ctrt_freq', 'adj_freq'
1511
+ ]
1512
+
1513
+ if indx_id_list is None and indx_code_list is None:
1514
+ warnings.warn("函数[get_index_info]的参数"
1515
+ "(indx_id_list, indx_code_list)"
1516
+ "不能全部为空")
1517
+ return None
1518
+
1519
+ if isinstance(indx_id_list, str):
1520
+ indx_id_list = indx_id_list.split(',')
1521
+
1522
+ if isinstance(indx_code_list, str):
1523
+ indx_code_list = indx_code_list.split(',')
1524
+
1525
+ params = {
1526
+ "indx_id_list": indx_id_list,
1527
+ "indx_code_list": indx_code_list,
1528
+ "cols": cols,
1529
+ "rslt_type": rslt_type,
1530
+ "int_param": int_param,
1531
+ "float_param": float_param
1532
+ }
1533
+ return get_data("pof/get_index_info", **params)
1534
+
1535
+
1536
+ def get_dividends(fund_code_list, cols=None, rslt_type=0):
1537
+ """
1538
+ 获取分红信息
1539
+
1540
+ """
1541
+
1542
+ int_param = \
1543
+ [
1544
+ 'divd_type', 'src_type'
1545
+ ]
1546
+ float_param = \
1547
+ [
1548
+ 'divd_rati'
1549
+ ]
1550
+ if cols:
1551
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
1552
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
1553
+ else:
1554
+ cols = [
1555
+ 'fund_code', 'divd_date', 'divd_type', 'divd_rati', 'src_type'
1556
+ ]
1557
+
1558
+ if fund_code_list:
1559
+
1560
+ if isinstance(fund_code_list, str):
1561
+ fund_code_list = fund_code_list.split(',')
1562
+
1563
+ params = {
1564
+ "fund_code_list": fund_code_list,
1565
+ "cols": cols,
1566
+ "rslt_type": rslt_type,
1567
+ "int_param": int_param,
1568
+ "float_param": float_param
1569
+ }
1570
+ return get_data("pof/get_dividends", **params)
1571
+ else:
1572
+ warnings.warn("函数[get_dividends]的参数(fund_code_list)为必填项")
1573
+ return None
1574
+
1575
+
1576
+ def get_fund_rank(fund_code_list, strt_mth='190001', end_mth=None, cols=None, rslt_type=0):
1577
+ """
1578
+ 获取私募基金收益排名
1579
+
1580
+ """
1581
+
1582
+ int_param = \
1583
+ [
1584
+ 'abs_ror_1m', 'relt_ror_1m', 'abs_ror_3m', 'relt_ror_3m', 'abs_ror_6m',
1585
+ 'relt_ror_6m', 'abs_ror_1y', 'relt_ror_1y', 'abs_ror_2y', 'relt_ror_2y',
1586
+ 'abs_ror_3y', 'relt_ror_3y', 'abs_ror_4y', 'relt_ror_4y', 'abs_ror_5y',
1587
+ 'relt_ror_5y', 'abs_ror_ytd', 'relt_ror_ytd', 'abs_ror_incep', 'relt_ror_incep',
1588
+ 'abs_maxdrad_1y', 'relt_maxdrad_1y', 'abs_maxdrad_2y', 'relt_maxdrad_2y', 'abs_maxdrad_3y',
1589
+ 'relt_maxdrad_3y', 'abs_maxdrad_4y', 'relt_maxdrad_4y', 'abs_maxdrad_5y', 'relt_maxdrad_5y',
1590
+ 'abs_adjror_1y', 'relt_adjror_1y', 'abs_adjror_2y', 'relt_adjror_2y', 'abs_adjror_3y',
1591
+ 'relt_adjror_3y', 'abs_adjror_4y', 'relt_adjror_4y', 'abs_adjror_5y', 'relt_adjror_5y',
1592
+ 'abs_upcaptr_1y', 'relt_upcaptr_1y', 'abs_upcaptr_2y', 'relt_upcaptr_2y', 'abs_upcaptr_3y',
1593
+ 'relt_upcaptr_3y', 'abs_upcaptr_4y', 'relt_upcaptr_4y', 'abs_upcaptr_5y', 'relt_upcaptr_5y',
1594
+ 'abs_downcaptr_1y', 'relt_downcaptr_1y', 'abs_downcaptr_2y', 'relt_downcaptr_2y', 'abs_downcaptr_3y',
1595
+ 'relt_downcaptr_3y', 'abs_downcaptr_4y', 'relt_downcaptr_4y', 'abs_downcaptr_5y', 'relt_downcaptr_5y',
1596
+ 'abs_shap_1y', 'relt_shap_1y', 'abs_shap_2y', 'relt_shap_2y', 'abs_shap_3y', 'relt_shap_3y',
1597
+ 'abs_shap_5y', 'relt_shap_5y', 'abs_stddev_1y', 'relt_stddev_1y', 'abs_stddev_2y', 'relt_stddev_2y',
1598
+ 'abs_stddev_3y', 'relt_stddev_3y', 'abs_stddev_5y', 'relt_stddev_5y'
1599
+ ]
1600
+ float_param = \
1601
+ [
1602
+
1603
+ ]
1604
+ if cols:
1605
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
1606
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
1607
+ else:
1608
+ cols = [
1609
+ 'fund_code', 'clas_id', 'cal_mth',
1610
+ 'abs_ror_1m', 'relt_ror_1m', 'abs_ror_3m', 'relt_ror_3m', 'abs_ror_6m',
1611
+ 'relt_ror_6m', 'abs_ror_1y', 'relt_ror_1y', 'abs_ror_2y', 'relt_ror_2y',
1612
+ 'abs_ror_3y', 'relt_ror_3y', 'abs_ror_4y', 'relt_ror_4y', 'abs_ror_5y',
1613
+ 'relt_ror_5y', 'abs_ror_ytd', 'relt_ror_ytd', 'abs_ror_incep', 'relt_ror_incep',
1614
+ 'abs_maxdrad_1y', 'relt_maxdrad_1y', 'abs_maxdrad_2y', 'relt_maxdrad_2y', 'abs_maxdrad_3y',
1615
+ 'relt_maxdrad_3y', 'abs_maxdrad_4y', 'relt_maxdrad_4y', 'abs_maxdrad_5y', 'relt_maxdrad_5y',
1616
+ 'abs_adjror_1y', 'relt_adjror_1y', 'abs_adjror_2y', 'relt_adjror_2y', 'abs_adjror_3y',
1617
+ 'relt_adjror_3y', 'abs_adjror_4y', 'relt_adjror_4y', 'abs_adjror_5y', 'relt_adjror_5y',
1618
+ 'abs_upcaptr_1y', 'relt_upcaptr_1y', 'abs_upcaptr_2y', 'relt_upcaptr_2y', 'abs_upcaptr_3y',
1619
+ 'relt_upcaptr_3y', 'abs_upcaptr_4y', 'relt_upcaptr_4y', 'abs_upcaptr_5y', 'relt_upcaptr_5y',
1620
+ 'abs_downcaptr_1y', 'relt_downcaptr_1y', 'abs_downcaptr_2y', 'relt_downcaptr_2y', 'abs_downcaptr_3y',
1621
+ 'relt_downcaptr_3y', 'abs_downcaptr_4y', 'relt_downcaptr_4y', 'abs_downcaptr_5y', 'relt_downcaptr_5y',
1622
+ 'abs_shap_1y', 'relt_shap_1y', 'abs_shap_2y', 'relt_shap_2y', 'abs_shap_3y', 'relt_shap_3y',
1623
+ 'abs_shap_5y', 'relt_shap_5y', 'abs_stddev_1y', 'relt_stddev_1y', 'abs_stddev_2y', 'relt_stddev_2y',
1624
+ 'abs_stddev_3y', 'relt_stddev_3y', 'abs_stddev_5y', 'relt_stddev_5y'
1625
+ ]
1626
+
1627
+ if end_mth is None:
1628
+ end_mth = get_current_date()[0: 6]
1629
+
1630
+ if fund_code_list:
1631
+
1632
+ if isinstance(fund_code_list, str):
1633
+ fund_code_list = fund_code_list.split(',')
1634
+
1635
+ params = {
1636
+ "fund_code_list": fund_code_list,
1637
+ "strt_mth": strt_mth,
1638
+ "end_mth": end_mth,
1639
+ "cols": cols,
1640
+ "rslt_type": rslt_type,
1641
+ "int_param": int_param,
1642
+ "float_param": float_param
1643
+ }
1644
+ return get_data("pof/get_fund_rank", **params)
1645
+ else:
1646
+ warnings.warn("函数[get_fund_rank]的参数(fund_code_list)为必填项")
1647
+ return None
1648
+
1649
+
1650
+ def get_adjusted_risk_index(fund_code_list, strt_mth='190001', end_mth=None, cols=None, rslt_type=0):
1651
+ """
1652
+ 获取调整后风险指标
1653
+
1654
+ """
1655
+
1656
+ int_param = \
1657
+ [
1658
+
1659
+ ]
1660
+ float_param = \
1661
+ [
1662
+ 'shap_1m', 'shap_3m', 'shap_6m', 'shap_1y',
1663
+ 'shap_2y', 'shap_3y', 'shap_4y', 'shap_5y', 'shap_10y', 'shap_incep',
1664
+ 'shap_ytd', 'sotn_1m', 'sotn_3m', 'sotn_6m', 'sotn_1y', 'sotn_2y',
1665
+ 'sotn_3y', 'sotn_4y', 'sotn_5y', 'sotn_10y', 'sotn_incep', 'sotn_ytd',
1666
+ 'sotn_mar_1y', 'sotn_mar_2y', 'sotn_mar_3y', 'sotn_mar_4y', 'sotn_mar_5y',
1667
+ 'sotn_mar_10y', 'sotn_mar_incep', 'sotn_mar_ytd', 'tryn_1m', 'tryn_3m',
1668
+ 'tryn_6m', 'tryn_1y', 'tryn_2y', 'tryn_3y', 'tryn_4y', 'tryn_5y', 'tryn_10y',
1669
+ 'tryn_incep', 'tryn_ytd', 'jesn_6m', 'jesn_1y', 'jesn_2y', 'jesn_3y', 'jesn_4y',
1670
+ 'jesn_5y', 'jesn_10y', 'jesn_incep', 'jesn_ytd', 'calm_1y', 'calm_2y', 'calm_3y',
1671
+ 'calm_4y', 'calm_5y', 'calm_10y', 'calm_incep', 'calm_ytd', 'omega_1y', 'omega_2y',
1672
+ 'omega_3y', 'omega_4y', 'omega_5y', 'omega_10y', 'omega_incep', 'omega_ytd', 'kappa_1y',
1673
+ 'kappa_2y', 'kappa_3y', 'kappa_4y', 'kappa_5y', 'kappa_10y', 'kappa_incep', 'kappa_ytd'
1674
+ ]
1675
+ if cols:
1676
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
1677
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
1678
+ else:
1679
+ cols = [
1680
+ 'fund_code', 'cal_mth', 'shap_1m', 'shap_3m', 'shap_6m', 'shap_1y',
1681
+ 'shap_2y', 'shap_3y', 'shap_4y', 'shap_5y', 'shap_10y', 'shap_incep',
1682
+ 'shap_ytd', 'sotn_1m', 'sotn_3m', 'sotn_6m', 'sotn_1y', 'sotn_2y',
1683
+ 'sotn_3y', 'sotn_4y', 'sotn_5y', 'sotn_10y', 'sotn_incep', 'sotn_ytd',
1684
+ 'sotn_mar_1y', 'sotn_mar_2y', 'sotn_mar_3y', 'sotn_mar_4y', 'sotn_mar_5y',
1685
+ 'sotn_mar_10y', 'sotn_mar_incep', 'sotn_mar_ytd', 'tryn_1m', 'tryn_3m',
1686
+ 'tryn_6m', 'tryn_1y', 'tryn_2y', 'tryn_3y', 'tryn_4y', 'tryn_5y', 'tryn_10y',
1687
+ 'tryn_incep', 'tryn_ytd', 'jesn_6m', 'jesn_1y', 'jesn_2y', 'jesn_3y', 'jesn_4y',
1688
+ 'jesn_5y', 'jesn_10y', 'jesn_incep', 'jesn_ytd', 'calm_1y', 'calm_2y', 'calm_3y',
1689
+ 'calm_4y', 'calm_5y', 'calm_10y', 'calm_incep', 'calm_ytd', 'omega_1y', 'omega_2y',
1690
+ 'omega_3y', 'omega_4y', 'omega_5y', 'omega_10y', 'omega_incep', 'omega_ytd', 'kappa_1y',
1691
+ 'kappa_2y', 'kappa_3y', 'kappa_4y', 'kappa_5y', 'kappa_10y', 'kappa_incep', 'kappa_ytd'
1692
+ ]
1693
+
1694
+ if end_mth is None:
1695
+ end_mth = get_current_date()[0: 6]
1696
+
1697
+ if fund_code_list:
1698
+
1699
+ if isinstance(fund_code_list, str):
1700
+ fund_code_list = fund_code_list.split(',')
1701
+
1702
+ params = {
1703
+ "fund_code_list": fund_code_list,
1704
+ "strt_mth": strt_mth,
1705
+ "end_mth": end_mth,
1706
+ "cols": cols,
1707
+ "rslt_type": rslt_type,
1708
+ "int_param": int_param,
1709
+ "float_param": float_param
1710
+ }
1711
+ return get_data("pof/get_adjusted_risk_index", **params)
1712
+ else:
1713
+ warnings.warn("函数[get_adjusted_risk_index]的参数(fund_code_list)为必填项")
1714
+ return None
1715
+
1716
+
1717
+ def get_capture_return(fund_code_list, strt_mth='190001', end_mth=None, cols=None, rslt_type=0):
1718
+ """
1719
+ 获取基金上行|下行捕获率
1720
+
1721
+ """
1722
+
1723
+ int_param = \
1724
+ [
1725
+
1726
+ ]
1727
+ float_param = \
1728
+ [
1729
+ 'upcaptr_ror_1y', 'upcaptr_ror_2y', 'upcaptr_ror_3y', 'upcaptr_ror_4y',
1730
+ 'upcaptr_ror_5y', 'upcaptr_ror_10y', 'upcaptr_ror_incep', 'upcaptr_ror_ytd', 'downcaptr_ror_1y',
1731
+ 'downcaptr_ror_2y', 'downcaptr_ror_3y', 'downcaptr_ror_4y', 'downcaptr_ror_5y', 'downcaptr_ror_10y',
1732
+ 'downcaptr_ror_incep', 'downcaptr_ror_ytd', 'upcaptr_1y', 'upcaptr_2y', 'upcaptr_3y', 'upcaptr_4y',
1733
+ 'upcaptr_5y', 'upcaptr_10y', 'upcaptr_incep', 'upcaptr_ytd', 'downcaptr_1y', 'downcaptr_2y', 'downcaptr_3y',
1734
+ 'downcaptr_4y', 'downcaptr_5y', 'downcaptr_10y', 'downcaptr_incep', 'downcaptr_ytd'
1735
+ ]
1736
+ if cols:
1737
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
1738
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
1739
+ else:
1740
+ cols = [
1741
+ 'fund_code', 'cal_mth', 'upcaptr_ror_1y', 'upcaptr_ror_2y', 'upcaptr_ror_3y', 'upcaptr_ror_4y',
1742
+ 'upcaptr_ror_5y', 'upcaptr_ror_10y', 'upcaptr_ror_incep', 'upcaptr_ror_ytd', 'downcaptr_ror_1y',
1743
+ 'downcaptr_ror_2y', 'downcaptr_ror_3y', 'downcaptr_ror_4y', 'downcaptr_ror_5y', 'downcaptr_ror_10y',
1744
+ 'downcaptr_ror_incep', 'downcaptr_ror_ytd', 'upcaptr_1y', 'upcaptr_2y', 'upcaptr_3y', 'upcaptr_4y',
1745
+ 'upcaptr_5y', 'upcaptr_10y', 'upcaptr_incep', 'upcaptr_ytd', 'downcaptr_1y', 'downcaptr_2y', 'downcaptr_3y',
1746
+ 'downcaptr_4y', 'downcaptr_5y', 'downcaptr_10y', 'downcaptr_incep', 'downcaptr_ytd'
1747
+ ]
1748
+
1749
+ if end_mth is None:
1750
+ end_mth = get_current_date()[0: 6]
1751
+
1752
+ if fund_code_list:
1753
+
1754
+ if isinstance(fund_code_list, str):
1755
+ fund_code_list = fund_code_list.split(',')
1756
+
1757
+ params = {
1758
+ "fund_code_list": fund_code_list,
1759
+ "strt_mth": strt_mth,
1760
+ "end_mth": end_mth,
1761
+ "cols": cols,
1762
+ "rslt_type": rslt_type,
1763
+ "int_param": int_param,
1764
+ "float_param": float_param
1765
+ }
1766
+ return get_data("pof/get_capture_return", **params)
1767
+ else:
1768
+ warnings.warn("函数[get_capture_return]的参数(fund_code_list)为必填项")
1769
+ return None
1770
+
1771
+
1772
+ def get_fund_portfolio(fund_code_list, strt_date='19000101', end_date=None, cols=None, rslt_type=0):
1773
+ """
1774
+ 获取基金重仓股统计
1775
+
1776
+ """
1777
+
1778
+ int_param = \
1779
+ [
1780
+ 'sec_type'
1781
+ ]
1782
+ float_param = \
1783
+ [
1784
+ 'sec_mkt_val', 'nv_rati', 'hldp', 'hldp_rati'
1785
+ ]
1786
+ if cols:
1787
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
1788
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
1789
+ else:
1790
+ cols = [
1791
+ 'fund_code', 'stat_date', 'scr_num', 'scr_type', 'scr_mkt_val', 'nv_rati', 'hldp', 'hldp_rati'
1792
+ ]
1793
+
1794
+ if end_date is None:
1795
+ end_date = get_current_date()
1796
+
1797
+ if fund_code_list:
1798
+
1799
+ if isinstance(fund_code_list, str):
1800
+ fund_code_list = fund_code_list.split(',')
1801
+
1802
+ params = {
1803
+ "fund_code_list": fund_code_list,
1804
+ "strt_date": strt_date,
1805
+ "end_date": end_date,
1806
+ "cols": cols,
1807
+ "rslt_type": rslt_type,
1808
+ "int_param": int_param,
1809
+ "float_param": float_param
1810
+ }
1811
+ return get_data("pof/get_fund_portfolio", **params)
1812
+ else:
1813
+ warnings.warn("函数[get_fund_portfolio]的参数(fund_code_list)为必填项")
1814
+ return None
1815
+
1816
+
1817
+ def get_assets_position(fund_code_list, strt_date='19000101', end_date=None, cols=None, rslt_type=0):
1818
+ """
1819
+ 获取基金资产持仓
1820
+
1821
+ """
1822
+
1823
+ int_param = \
1824
+ [
1825
+ 'scr_type'
1826
+ ]
1827
+ float_param = \
1828
+ [
1829
+ 'hldp'
1830
+ ]
1831
+ if cols:
1832
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
1833
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
1834
+ else:
1835
+ cols = [
1836
+ 'fund_code', 'stat_date', 'scr_type', 'scr_mkt_val', 'hldp'
1837
+ ]
1838
+
1839
+ if end_date is None:
1840
+ end_date = get_current_date()
1841
+
1842
+ if fund_code_list:
1843
+
1844
+ if isinstance(fund_code_list, str):
1845
+ fund_code_list = fund_code_list.split(',')
1846
+
1847
+ params = {
1848
+ "fund_code_list": fund_code_list,
1849
+ "strt_date": strt_date,
1850
+ "end_date": end_date,
1851
+ "cols": cols,
1852
+ "rslt_type": rslt_type,
1853
+ "int_param": int_param,
1854
+ "float_param": float_param
1855
+ }
1856
+ return get_data("pof/get_assets_position", **params)
1857
+ else:
1858
+ warnings.warn("函数[get_assets_position]的参数(fund_code_list)为必填项")
1859
+ return None
1860
+
1861
+
1862
+ def get_relative_value_allocation(fund_code_list, strt_date='19000101', end_date=None, cols=None, rslt_type=0):
1863
+ """
1864
+ 获取基金相对价值配置
1865
+
1866
+ """
1867
+
1868
+ int_param = \
1869
+ [
1870
+ 'samp_num'
1871
+ ]
1872
+ float_param = \
1873
+ [
1874
+ 'mkt_beta', 'big_smal_beta', 'grow_beta',
1875
+ 'hedg_beta', 'crrc_beta', 'relt_beta', 'mkt_contrb', 'big_smal_contrb',
1876
+ 'grow_contrb', 'hedg_contrb', 'crrc_contrb', 'relt_contrv', 'alpha',
1877
+ 'rsdu', 'eval_rati', 'fitgdn'
1878
+ ]
1879
+ if cols:
1880
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
1881
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
1882
+ else:
1883
+ cols = [
1884
+ 'fund_code', 'end_date', 'mkt_beta', 'big_smal_beta', 'grow_beta',
1885
+ 'hedg_beta', 'crrc_beta', 'relt_beta', 'mkt_contrb', 'big_smal_contrb',
1886
+ 'grow_contrb', 'hedg_contrb', 'crrc_contrb', 'relt_contrv', 'alpha',
1887
+ 'rsdu', 'eval_rati', 'fitgdn', 'samp_num'
1888
+ ]
1889
+
1890
+ if end_date is None:
1891
+ end_date = get_current_date()
1892
+
1893
+ if fund_code_list:
1894
+
1895
+ if isinstance(fund_code_list, str):
1896
+ fund_code_list = fund_code_list.split(',')
1897
+
1898
+ params = {
1899
+ "fund_code_list": fund_code_list,
1900
+ "strt_date": strt_date,
1901
+ "end_date": end_date,
1902
+ "cols": cols,
1903
+ "rslt_type": rslt_type,
1904
+ "int_param": int_param,
1905
+ "float_param": float_param
1906
+ }
1907
+ return get_data("pof/get_relative_value_allocation", **params)
1908
+ else:
1909
+ warnings.warn("函数[get_relative_value_allocation]的参数(fund_code_list)为必填项")
1910
+ return None
1911
+
1912
+
1913
+ def get_index_value(indx_id_list=None, indx_code_list=None, strt_date='19000101', end_date=None, cols=None, rslt_type=0):
1914
+ """
1915
+ 获取融智指数
1916
+
1917
+ """
1918
+
1919
+ int_param = \
1920
+ [
1921
+ 'weeks', 'year', 'incl_cal_fund_vol'
1922
+ ]
1923
+ float_param = \
1924
+ [
1925
+ 'indx_val'
1926
+ ]
1927
+ if cols:
1928
+ int_param = list(set([]).intersection(set(convert_fields(cols))))
1929
+ float_param = list(set([]).intersection(set(convert_fields(cols))))
1930
+ else:
1931
+ cols = [
1932
+ 'indx_id', 'indx_code', 'end_date', 'weeks', 'year',
1933
+ 'indx_val', 'incl_cal_fund_vol'
1934
+ ]
1935
+
1936
+ if end_date is None:
1937
+ end_date = get_current_date()
1938
+
1939
+ if indx_id_list is None and indx_code_list is None:
1940
+ warnings.warn("函数[get_index_value]的参数"
1941
+ "(indx_id_list, indx_code_list)"
1942
+ "不能全部为空")
1943
+ return None
1944
+
1945
+ if isinstance(indx_id_list, str):
1946
+ indx_id_list = indx_id_list.split(',')
1947
+
1948
+ if isinstance(indx_code_list, str):
1949
+ indx_code_list = indx_code_list.split(',')
1950
+
1951
+ params = {
1952
+ "indx_id_list": indx_id_list,
1953
+ "indx_code_list": indx_code_list,
1954
+ "strt_date": strt_date,
1955
+ "end_date": end_date,
1956
+ "cols": cols,
1957
+ "rslt_type": rslt_type,
1958
+ "int_param": int_param,
1959
+ "float_param": float_param
1960
+ }
1961
+ return get_data("pof/get_index_value", **params)
1962
+
1963
+