siat 3.0.44__py3-none-any.whl → 3.1.1__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.
- siat/fund_china.py +320 -143
- siat/security_prices.py +5 -5
- {siat-3.0.44.dist-info → siat-3.1.1.dist-info}/METADATA +1 -1
- {siat-3.0.44.dist-info → siat-3.1.1.dist-info}/RECORD +6 -6
- {siat-3.0.44.dist-info → siat-3.1.1.dist-info}/WHEEL +0 -0
- {siat-3.0.44.dist-info → siat-3.1.1.dist-info}/top_level.txt +0 -0
siat/fund_china.py
CHANGED
@@ -25,12 +25,12 @@ if __name__=='__main__':
|
|
25
25
|
quarter1='2022Q4'
|
26
26
|
quarter2='2023Q1'
|
27
27
|
|
28
|
-
df=fund_stock_holding_compare_china(fund,quarter1,quarter2,
|
28
|
+
df=fund_stock_holding_compare_china(fund,quarter1,quarter2,rank=10)
|
29
29
|
|
30
30
|
#比较两个季度之间的基金持仓变化
|
31
|
-
def fund_stock_holding_compare_china(fund,quarter1,quarter2,
|
31
|
+
def fund_stock_holding_compare_china(fund,quarter1,quarter2,rank=10):
|
32
32
|
"""
|
33
|
-
功能:基金fund在两个季度quarter1和quarter2的持仓股票对比(股数和金额),前
|
33
|
+
功能:基金fund在两个季度quarter1和quarter2的持仓股票对比(股数和金额),前rank名股票
|
34
34
|
参数:
|
35
35
|
fund,str,基金代码;
|
36
36
|
quarter1,str,靠前的季度, 格式为 'YYYYQ1',例如: '2021Q2';
|
@@ -130,10 +130,10 @@ def fund_stock_holding_compare_china(fund,quarter1,quarter2,top=10):
|
|
130
130
|
df_merge = df_merge[['股票代码', '股票名称', s1_share,s1_value, s1_ratio,s2_share,s2_value,s2_ratio, '持股数变化']]
|
131
131
|
|
132
132
|
df_merge.reset_index(drop=True,inplace=True)
|
133
|
-
if
|
134
|
-
df=df_merge.head(
|
133
|
+
if rank>0:
|
134
|
+
df=df_merge.head(rank)
|
135
135
|
else:
|
136
|
-
df=df_merge.head(-
|
136
|
+
df=df_merge.head(-rank)
|
137
137
|
"""
|
138
138
|
#持股数和持仓比例取整数
|
139
139
|
df.fillna(0)
|
@@ -171,14 +171,14 @@ def fund_stock_holding_compare_china(fund,quarter1,quarter2,top=10):
|
|
171
171
|
name=get_fund_name_china2(fund)
|
172
172
|
|
173
173
|
order='前'
|
174
|
-
if
|
174
|
+
if rank <0:
|
175
175
|
order='后'
|
176
|
-
|
176
|
+
rank=-rank
|
177
177
|
|
178
178
|
# 替换空值
|
179
179
|
df.fillna('---')
|
180
180
|
|
181
|
-
print("===== 中国基金持仓股票分析:"+name+','+s1+"对比"+s2,"(按后者持仓比例高低排列,"+order+str(
|
181
|
+
print("===== 中国基金持仓股票分析:"+name+','+s1+"对比"+s2,"(按后者持仓比例高低排列,"+order+str(rank)+"名股票) =====\n")
|
182
182
|
print(df.to_string(index=False))
|
183
183
|
import datetime; today = datetime.date.today()
|
184
184
|
print("\n*** 注:持股数为万股,持仓市值为万元,持仓比例为占基金资产净值比例%,包括A股与非A股")
|
@@ -329,9 +329,9 @@ def fund_stock_holding_rank_china(fund,year_num=2):
|
|
329
329
|
#==============================================================================
|
330
330
|
if __name__=='__main__':
|
331
331
|
fund='180801'
|
332
|
-
|
332
|
+
rank=10
|
333
333
|
|
334
|
-
def reits_jsl_china(fund='',
|
334
|
+
def reits_jsl_china(fund='',rank=10):
|
335
335
|
"""
|
336
336
|
功能:REITs基金信息概述和列表
|
337
337
|
目前不能正常工作,因为集思录数据源现在需要会员登陆才能显示和下载信息
|
@@ -358,10 +358,10 @@ def reits_jsl_china(fund='',top=10):
|
|
358
358
|
dfa=df[df['代码']==fund]
|
359
359
|
# 未找到
|
360
360
|
if len(dfa)==0:
|
361
|
-
if
|
362
|
-
dfa=df.head(
|
361
|
+
if rank > 0:
|
362
|
+
dfa=df.head(rank)
|
363
363
|
else:
|
364
|
-
dfa=df.tail(-
|
364
|
+
dfa=df.tail(-rank)
|
365
365
|
dfb=dfa[['代码','名称','昨收','规模(亿元)','到期日']]
|
366
366
|
|
367
367
|
#设置打印对齐
|
@@ -372,10 +372,10 @@ def reits_jsl_china(fund='',top=10):
|
|
372
372
|
pd.set_option('display.unicode.east_asian_width', True)
|
373
373
|
|
374
374
|
order='前'
|
375
|
-
if
|
375
|
+
if rank <0:
|
376
376
|
order='后'
|
377
|
-
|
378
|
-
print("\n===== 中国REITs基金列表(按最新价高低排列,"+order+str(
|
377
|
+
rank=-rank
|
378
|
+
print("\n===== 中国REITs基金列表(按最新价高低排列,"+order+str(rank)+"名) =====\n")
|
379
379
|
print(dfb)
|
380
380
|
|
381
381
|
print("*** 数据来源:东方财富/集思录, 总计"+str(num)+"只REITs基金,",today)
|
@@ -399,14 +399,14 @@ def reits_jsl_china(fund='',top=10):
|
|
399
399
|
|
400
400
|
#==============================================================================
|
401
401
|
if __name__=='__main__':
|
402
|
-
|
402
|
+
rank=10
|
403
403
|
|
404
|
-
df=reits_list_china(
|
404
|
+
df=reits_list_china(rank=10)
|
405
405
|
|
406
|
-
def reits_list_china(
|
406
|
+
def reits_list_china(rank=10,sort='最新价'):
|
407
407
|
"""
|
408
408
|
功能:REITs基金信息概述和列表
|
409
|
-
|
409
|
+
目前能正常工作
|
410
410
|
"""
|
411
411
|
import akshare as ak
|
412
412
|
try:
|
@@ -414,11 +414,18 @@ def reits_list_china(top=20):
|
|
414
414
|
except:
|
415
415
|
print(" #Error(reits_profile_china): akshare does not work properly now")
|
416
416
|
return None
|
417
|
+
df2.drop('序号', axis=1, inplace=True)
|
418
|
+
|
419
|
+
sortlist=list(df2)
|
420
|
+
if sort not in sortlist:
|
421
|
+
print(" #Error(reits_list_china):",sort,"is not supported")
|
422
|
+
print(" Supported sort method:",sortlist)
|
423
|
+
return None
|
417
424
|
|
418
425
|
#df2.sort_values(by=['昨收'],ascending=False,inplace=True)
|
419
|
-
df2.sort_values(by=[
|
426
|
+
df2.sort_values(by=[sort],ascending=False,inplace=True)
|
420
427
|
df2.reset_index(drop=True,inplace=True)
|
421
|
-
df2['序号']=df2.index + 1
|
428
|
+
#df2['序号']=df2.index + 1
|
422
429
|
num=len(df2)
|
423
430
|
|
424
431
|
#设置打印对齐
|
@@ -428,22 +435,24 @@ def reits_list_china(top=20):
|
|
428
435
|
pd.set_option('display.unicode.ambiguous_as_wide', True)
|
429
436
|
pd.set_option('display.unicode.east_asian_width', True)
|
430
437
|
|
431
|
-
if
|
438
|
+
if rank > 0:
|
432
439
|
order='前'
|
433
|
-
dfb=df2.head(
|
440
|
+
dfb=df2.head(rank)
|
434
441
|
else:
|
435
442
|
order='后'
|
436
|
-
|
437
|
-
dfb=df2.tail(
|
443
|
+
rank=-rank
|
444
|
+
dfb=df2.tail(rank)
|
438
445
|
|
439
446
|
dfb.fillna("---",inplace=True)
|
440
447
|
dfb['成交额']=dfb['成交额'].apply(lambda x: int(x))
|
441
448
|
|
442
|
-
print("\n===== 中国REITs基金列表(按最新价高低排列,"+order+str(
|
449
|
+
#print("\n===== 中国REITs基金列表(按最新价高低排列,"+order+str(rank)+"名) =====\n")
|
450
|
+
titletxt="中国REITs基金列表(按"+sort+"降序排列,"+order+str(rank)+"名)"
|
443
451
|
"""
|
444
452
|
print(dfb.to_string(index=False))
|
445
453
|
"""
|
446
454
|
#print('') #在标题与表格之间空一行
|
455
|
+
"""
|
447
456
|
alignlist=['right','center','left']+['right']*9
|
448
457
|
try:
|
449
458
|
print(dfb.to_markdown(index=False,tablefmt='plain',colalign=alignlist))
|
@@ -452,10 +461,16 @@ def reits_list_china(top=20):
|
|
452
461
|
print_df=dfb.to_markdown(index=False,tablefmt='plain',colalign=alignlist)
|
453
462
|
print_df2=print_df.encode("utf-8",errors="strict")
|
454
463
|
print(print_df2)
|
455
|
-
|
456
|
-
import datetime
|
457
|
-
|
458
|
-
|
464
|
+
"""
|
465
|
+
import datetime; todaydt = datetime.date.today()
|
466
|
+
#print("\n*** 数据来源:东方财富, 总计"+str(num)+"只REITs基金,",today)
|
467
|
+
footnote="数据来源:东方财富, 总计"+str(num)+"只REITs基金,"+str(todaydt)
|
468
|
+
|
469
|
+
df_display_CSS(dfb,titletxt=titletxt,footnote=footnote,facecolor='papayawhip',decimals=3, \
|
470
|
+
first_col_align='left',second_col_align='left', \
|
471
|
+
last_col_align='right',other_col_align='right', \
|
472
|
+
titile_font_size='16px',heading_font_size='15px', \
|
473
|
+
data_font_size='15px')
|
459
474
|
|
460
475
|
return df2
|
461
476
|
|
@@ -478,7 +493,9 @@ def pof_list_china(fund_type='全部类型',printout=True):
|
|
478
493
|
df = ak.fund_name_em()
|
479
494
|
|
480
495
|
df.sort_values(by=['拼音全称'],na_position='first',inplace=True)
|
481
|
-
df.drop_duplicates(subset=['基金代码','基金类型'], keep='first',inplace=True)
|
496
|
+
df.drop_duplicates(subset=['基金代码','基金类型'], keep='first',inplace=True)
|
497
|
+
df=df[df['基金类型'] != '']
|
498
|
+
df['基金类型']=df['基金类型'].apply(lambda x: x.upper())
|
482
499
|
|
483
500
|
#获取基金类型列表,并去掉重复项
|
484
501
|
typelist=list(set(list(df['基金类型'])))
|
@@ -509,11 +526,14 @@ def pof_list_china(fund_type='全部类型',printout=True):
|
|
509
526
|
if fund_type != '全部类型':
|
510
527
|
print(texttranslate("共找到")+str(num)+texttranslate("支基金, 类型为")+fund_type)
|
511
528
|
return df3
|
512
|
-
|
529
|
+
"""
|
513
530
|
print("\n",texttranslate("======= 中国公募基金种类概况 ======="))
|
514
531
|
print(texttranslate("公募基金总数:"),"{:,}".format(num))
|
515
532
|
print(texttranslate("其中包括:"))
|
516
|
-
|
533
|
+
"""
|
534
|
+
titletxt="中国公募基金的种类与分布概况"
|
535
|
+
footnote1="【注】公募基金总数:"+str("{:,}".format(num))+'\n'
|
536
|
+
|
517
537
|
maxlen=0
|
518
538
|
for t in typelist:
|
519
539
|
tlen=hzlen(t)
|
@@ -529,18 +549,24 @@ def pof_list_china(fund_type='全部类型',printout=True):
|
|
529
549
|
except:
|
530
550
|
pass
|
531
551
|
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
552
|
+
dfg.rename(columns={0:'基金数量'}, inplace=True)
|
553
|
+
dfg['数量占比']=dfg['基金数量'].apply(lambda x: str(round(x/num*100,3))+'%')
|
554
|
+
dfg.reset_index(inplace=True)
|
555
|
+
|
556
|
+
collist=list(dfg)
|
557
|
+
dfg['序号']=dfg.index+1
|
558
|
+
dfg=dfg[['序号']+collist]
|
559
|
+
|
560
|
+
import datetime; todaydt = datetime.date.today()
|
561
|
+
#print(texttranslate("数据来源:东方财富/天天基金,"),today)
|
562
|
+
footnote2="数据来源:东方财富/天天基金,"+str(todaydt)
|
563
|
+
footnote=footnote1+footnote2
|
564
|
+
|
565
|
+
df_display_CSS(dfg,titletxt=titletxt,footnote=footnote,facecolor='papayawhip',decimals=3, \
|
566
|
+
first_col_align='center',second_col_align='left', \
|
567
|
+
last_col_align='right',other_col_align='right', \
|
568
|
+
titile_font_size='16px',heading_font_size='15px', \
|
569
|
+
data_font_size='15px')
|
544
570
|
|
545
571
|
return df3
|
546
572
|
|
@@ -569,13 +595,19 @@ def oef_rank_china(info_type='单位净值',fund_type='全部类型',rank=10):
|
|
569
595
|
df1 = ak.fund_open_fund_daily_em()
|
570
596
|
collist=list(df1)
|
571
597
|
nvname1=collist[2]
|
572
|
-
nvdate=nvname1[:10]
|
573
598
|
nvname2=collist[3]
|
599
|
+
if df1[nvname1].isna().all() or df1[nvname1].eq(0).all() or df1[nvname1].eq('').all():
|
600
|
+
nvname1=collist[4]
|
601
|
+
nvname2=collist[5]
|
602
|
+
nvdate=nvname1[:10]
|
603
|
+
|
604
|
+
df1x=df1[df1[nvname1] != '']
|
605
|
+
|
574
606
|
#修改列名
|
575
|
-
|
607
|
+
df1x.rename(columns={nvname1:'单位净值',nvname2:'累计净值'}, inplace=True)
|
576
608
|
#df1a=df1.drop(df1[df1['单位净值']==''].index)
|
577
609
|
#df1b=df1a.drop(df1a[df1a['累计净值']==''].index)
|
578
|
-
df1c=
|
610
|
+
df1c=df1x[['基金代码','基金简称','单位净值','累计净值','日增长率','申购状态','赎回状态','手续费']]
|
579
611
|
|
580
612
|
|
581
613
|
#获取所有公募基金类型信息
|
@@ -634,23 +666,27 @@ def oef_rank_china(info_type='单位净值',fund_type='全部类型',rank=10):
|
|
634
666
|
df['单位净值']=df['单位净值'].apply(lambda x: round(x,2))
|
635
667
|
df.sort_values(by=['单位净值'],ascending=False,inplace=True)
|
636
668
|
dfprint=df[['基金简称','基金代码','基金类型','单位净值','申购状态','赎回状态']]
|
637
|
-
print(texttranslate("\n===== 中国开放式基金排名:单位净值 ====="))
|
669
|
+
#print(texttranslate("\n===== 中国开放式基金排名:单位净值 ====="))
|
670
|
+
titletxt="中国开放式基金排名:单位净值"
|
638
671
|
|
639
672
|
if info_type == '累计净值':
|
640
673
|
df['累计净值']=df['累计净值'].apply(lambda x: round(x,2))
|
641
674
|
df.sort_values(by=['累计净值'],ascending=False,inplace=True)
|
642
675
|
dfprint=df[['基金简称','基金代码','基金类型','累计净值','申购状态','赎回状态']]
|
643
|
-
print(texttranslate("\n===== 中国开放式基金排名:累计净值 ====="))
|
676
|
+
#print(texttranslate("\n===== 中国开放式基金排名:累计净值 ====="))
|
677
|
+
titletxt="中国开放式基金排名:累计净值"
|
644
678
|
|
645
679
|
if info_type == '手续费':
|
646
680
|
df.sort_values(by=['手续费'],ascending=False,inplace=True)
|
647
681
|
dfprint=df[['基金简称','基金代码','基金类型','手续费','申购状态','赎回状态']]
|
648
|
-
print(texttranslate("\n===== 中国开放式基金排名:手续费 ====="))
|
682
|
+
#print(texttranslate("\n===== 中国开放式基金排名:手续费 ====="))
|
683
|
+
titletxt="中国开放式基金排名:手续费"
|
649
684
|
|
650
685
|
if info_type == '增长率':
|
651
686
|
df.sort_values(by=['日增长率'],ascending=False,inplace=True)
|
652
687
|
dfprint=df[['基金简称','基金代码','基金类型','日增长率','申购状态','赎回状态']]
|
653
|
-
print(texttranslate("\n===== 中国开放式基金排名:增长率% ====="))
|
688
|
+
#print(texttranslate("\n===== 中国开放式基金排名:增长率% ====="))
|
689
|
+
titletxt="中国开放式基金排名:增长率%"
|
654
690
|
|
655
691
|
df=df.replace(0,'--')
|
656
692
|
|
@@ -676,6 +712,7 @@ def oef_rank_china(info_type='单位净值',fund_type='全部类型',rank=10):
|
|
676
712
|
"""
|
677
713
|
alignlist=['left','left']+['center']*(len(list(amac_sum_df.head(10)))-3)+['right']
|
678
714
|
"""
|
715
|
+
"""
|
679
716
|
print('') #在标题与表格之间空一行
|
680
717
|
alignlist=['right','left','center','center','right','center','center']
|
681
718
|
try:
|
@@ -693,6 +730,19 @@ def oef_rank_china(info_type='单位净值',fund_type='全部类型',rank=10):
|
|
693
730
|
import datetime
|
694
731
|
today = datetime.date.today()
|
695
732
|
print(texttranslate("数据来源:东方财富/天天基金,"),today)
|
733
|
+
"""
|
734
|
+
footnote1="披露净值的开放式基金数量:"+str(len(dfprint))+','
|
735
|
+
footnote2="基金类型:"+str(fund_type)+'\n'
|
736
|
+
footnote3="净值日期:"+str(nvdate)+','
|
737
|
+
import datetime; todaydt = datetime.date.today()
|
738
|
+
footnote4="数据来源:东方财富/天天基金,"+str(todaydt)
|
739
|
+
footnote=footnote1+footnote2+footnote3+footnote4
|
740
|
+
|
741
|
+
df_display_CSS(dfprint10,titletxt=titletxt,footnote=footnote,facecolor='papayawhip',decimals=4, \
|
742
|
+
first_col_align='left',second_col_align='right', \
|
743
|
+
last_col_align='right',other_col_align='right', \
|
744
|
+
titile_font_size='16px',heading_font_size='15px', \
|
745
|
+
data_font_size='15px')
|
696
746
|
|
697
747
|
return df
|
698
748
|
|
@@ -731,19 +781,20 @@ def get_oef_name_china(fund_code):
|
|
731
781
|
if __name__=='__main__':
|
732
782
|
fund='050111.SS'
|
733
783
|
fund='000592.SS'
|
734
|
-
|
735
|
-
|
784
|
+
start='MRM'
|
785
|
+
end='today'
|
736
786
|
trend_type='净值'
|
737
787
|
power=0
|
738
788
|
twinx=False
|
739
789
|
zeroline=False
|
740
790
|
|
741
|
-
def oef_trend_china(fund,
|
791
|
+
def oef_trend_china(fund,start,end='today',trend_type='净值', \
|
742
792
|
power=0,twinx=False, \
|
743
793
|
loc1='upper left',loc2='lower left'):
|
744
794
|
"""
|
745
795
|
功能:开放式基金业绩趋势,单位净值,累计净值,近三个月收益率,同类排名,总排名
|
746
796
|
"""
|
797
|
+
fromdate,todate=start_end_preprocess(start,end)
|
747
798
|
#检查走势类型
|
748
799
|
trendlist=["净值","收益率","排名"]
|
749
800
|
if trend_type not in trendlist:
|
@@ -770,9 +821,10 @@ def oef_trend_china(fund,fromdate,todate,trend_type='净值', \
|
|
770
821
|
source=texttranslate("数据来源:东方财富/天天基金")
|
771
822
|
|
772
823
|
fund1=fund[:6]
|
773
|
-
fund_name=ticker_name(fund1,
|
824
|
+
fund_name=ticker_name(fund1,'fund')
|
774
825
|
|
775
826
|
#绘制单位/累计净值对比图
|
827
|
+
import pandas as pd
|
776
828
|
if trend_type == '净值':
|
777
829
|
df1 = ak.fund_open_fund_info_em(fund1, indicator="单位净值走势")
|
778
830
|
df1.rename(columns={'净值日期':'date','单位净值':'单位净值'}, inplace=True)
|
@@ -784,8 +836,9 @@ def oef_trend_china(fund,fromdate,todate,trend_type='净值', \
|
|
784
836
|
df2.set_index(['date'],inplace=True)
|
785
837
|
|
786
838
|
#合并
|
787
|
-
import pandas as pd
|
788
839
|
df = pd.merge(df1,df2,left_index=True,right_index=True,how='inner')
|
840
|
+
df['日期']=df['日期'].apply(lambda x: pd.to_datetime(x))
|
841
|
+
|
789
842
|
dfp=df[(df['日期'] >= start)]
|
790
843
|
dfp=dfp[(dfp['日期'] <= end)]
|
791
844
|
if len(dfp) == 0:
|
@@ -811,10 +864,11 @@ def oef_trend_china(fund,fromdate,todate,trend_type='净值', \
|
|
811
864
|
|
812
865
|
#绘制累计收益率单线图
|
813
866
|
if trend_type == '收益率':
|
814
|
-
df = ak.fund_open_fund_info_em(
|
815
|
-
df.rename(columns={'净值日期':'date','累计收益率':'累计收益率'}, inplace=True)
|
816
|
-
df['
|
867
|
+
df = ak.fund_open_fund_info_em(fund1, indicator="累计收益率走势")
|
868
|
+
#df.rename(columns={'净值日期':'date','累计收益率':'累计收益率'}, inplace=True)
|
869
|
+
df['date']=df['日期']
|
817
870
|
df.set_index(['date'],inplace=True)
|
871
|
+
df['日期']=df['日期'].apply(lambda x: pd.to_datetime(x))
|
818
872
|
dfp=df[(df['日期'] >= start)]
|
819
873
|
dfp=dfp[(dfp['日期'] <= end)]
|
820
874
|
if len(dfp) == 0:
|
@@ -830,7 +884,7 @@ def oef_trend_china(fund,fromdate,todate,trend_type='净值', \
|
|
830
884
|
|
831
885
|
#绘制同类排名图:近三个月收益率
|
832
886
|
if trend_type == '排名':
|
833
|
-
df1 = ak.fund_open_fund_info_em(
|
887
|
+
df1 = ak.fund_open_fund_info_em(fund1, indicator="同类排名走势")
|
834
888
|
df1.rename(columns={'报告日期':'date','同类型排名-每日近三月排名':'同类排名','总排名-每日近三月排名':'总排名'}, inplace=True)
|
835
889
|
df1['日期']=df1['date']
|
836
890
|
df1['总排名']=df1['总排名'].astype('int64')
|
@@ -841,8 +895,8 @@ def oef_trend_china(fund,fromdate,todate,trend_type='净值', \
|
|
841
895
|
df2.set_index(['date'],inplace=True)
|
842
896
|
|
843
897
|
#合并
|
844
|
-
import pandas as pd
|
845
898
|
df = pd.merge(df1,df2,left_index=True,right_index=True,how='inner')
|
899
|
+
df['日期']=df['日期'].apply(lambda x: pd.to_datetime(x))
|
846
900
|
dfp=df[(df['日期'] >= start)]
|
847
901
|
dfp=dfp[(dfp['日期'] <= end)]
|
848
902
|
if len(dfp) == 0:
|
@@ -890,7 +944,9 @@ def mmf_rank_china(rank=10):
|
|
890
944
|
#获取货币型基金实时信息
|
891
945
|
df = ak.fund_money_fund_daily_em()
|
892
946
|
collist=list(df)
|
893
|
-
nvname=collist[
|
947
|
+
nvname=collist[3]
|
948
|
+
if df[nvname].eq('').all():
|
949
|
+
nvname=collist[6]
|
894
950
|
nvdate=nvname[:10]
|
895
951
|
#修改列名
|
896
952
|
df.rename(columns={nvname:'7日年化%'}, inplace=True)
|
@@ -899,7 +955,8 @@ def mmf_rank_china(rank=10):
|
|
899
955
|
|
900
956
|
dfb.sort_values(by=['7日年化%'],ascending=False,inplace=True)
|
901
957
|
dfprint=dfb[['基金简称','基金代码','7日年化%','基金经理','手续费']]
|
902
|
-
print(texttranslate("\n======= 中国货币型基金排名:7日年化收益率 ======="))
|
958
|
+
#print(texttranslate("\n======= 中国货币型基金排名:7日年化收益率 ======="))
|
959
|
+
titletxt="中国货币型基金排名:7日年化收益率"
|
903
960
|
|
904
961
|
#设置打印对齐
|
905
962
|
import pandas as pd
|
@@ -921,6 +978,7 @@ def mmf_rank_china(rank=10):
|
|
921
978
|
"""
|
922
979
|
print(dfprint10)
|
923
980
|
"""
|
981
|
+
"""
|
924
982
|
print('') #在标题与表格之间空一行
|
925
983
|
alignlist=['right','left','center','center','center','right']
|
926
984
|
try:
|
@@ -938,6 +996,18 @@ def mmf_rank_china(rank=10):
|
|
938
996
|
import datetime
|
939
997
|
today = datetime.date.today()
|
940
998
|
print(texttranslate("数据来源:东方财富/天天基金,"),today)
|
999
|
+
"""
|
1000
|
+
footnote1="披露收益率信息的货币型基金数量:"+str(len(dfprint))+'\n'
|
1001
|
+
footnote2="收益率日期:"+str(nvdate)+','
|
1002
|
+
import datetime; todaydt = datetime.date.today()
|
1003
|
+
footnote3="数据来源:东方财富/天天基金,"+str(todaydt)
|
1004
|
+
footnote=footnote1+footnote2+footnote3
|
1005
|
+
|
1006
|
+
df_display_CSS(dfprint10,titletxt=titletxt,footnote=footnote,facecolor='papayawhip',decimals=4, \
|
1007
|
+
first_col_align='left',second_col_align='right', \
|
1008
|
+
last_col_align='right',other_col_align='right', \
|
1009
|
+
titile_font_size='16px',heading_font_size='15px', \
|
1010
|
+
data_font_size='15px')
|
941
1011
|
|
942
1012
|
return df
|
943
1013
|
|
@@ -951,11 +1021,11 @@ if __name__=='__main__':
|
|
951
1021
|
todate='2020-10-16'
|
952
1022
|
power=0
|
953
1023
|
|
954
|
-
def mmf_trend_china(fund,
|
1024
|
+
def mmf_trend_china(fund,start,end='today',power=0):
|
955
1025
|
"""
|
956
1026
|
功能:货币型基金业绩趋势,7日年化收益率
|
957
1027
|
"""
|
958
|
-
|
1028
|
+
fromdate,todate=start_end_preprocess(start,end)
|
959
1029
|
#检查日期
|
960
1030
|
result,start,end=check_period(fromdate,todate)
|
961
1031
|
if not result:
|
@@ -971,7 +1041,6 @@ def mmf_trend_china(fund,fromdate,todate,power=0):
|
|
971
1041
|
#基金历史数据
|
972
1042
|
import datetime; today = datetime.date.today()
|
973
1043
|
source=texttranslate("数据来源:东方财富/天天基金")
|
974
|
-
|
975
1044
|
|
976
1045
|
#绘制收益率单线图
|
977
1046
|
fund1=fund[:6]
|
@@ -1029,8 +1098,12 @@ def etf_rank_china(info_type='单位净值',fund_type='全部类型',rank=10):
|
|
1029
1098
|
#提取净值日期
|
1030
1099
|
collist=list(df2)
|
1031
1100
|
nvname1=collist[3]
|
1032
|
-
nvdate=nvname1[:10]
|
1033
1101
|
nvname2=collist[4]
|
1102
|
+
if df2[nvname1].eq('').all() or df2[nvname1].eq('---').all():
|
1103
|
+
nvname1=collist[5]
|
1104
|
+
nvname2=collist[6]
|
1105
|
+
nvdate=nvname1[:10]
|
1106
|
+
|
1034
1107
|
#修改列名
|
1035
1108
|
df3=df2.rename(columns={nvname1:'单位净值',nvname2:'累计净值'})
|
1036
1109
|
df=df3[['基金简称','基金代码','类型','单位净值','累计净值','增长率','市价']]
|
@@ -1064,27 +1137,35 @@ def etf_rank_china(info_type='单位净值',fund_type='全部类型',rank=10):
|
|
1064
1137
|
df['单位净值']=df['单位净值'].astype(float)
|
1065
1138
|
df.sort_values(by=['单位净值'],ascending=False,inplace=True)
|
1066
1139
|
dfprint=df[['基金简称','基金代码','类型','单位净值','市价']]
|
1067
|
-
print(texttranslate("\n===== 中国ETF基金排名:单位净值 ====="))
|
1140
|
+
#print(texttranslate("\n===== 中国ETF基金排名:单位净值 ====="))
|
1141
|
+
titletxt="中国ETF基金排名:单位净值"
|
1142
|
+
dfprint=dfprint[dfprint['单位净值'] != 0]
|
1068
1143
|
|
1069
1144
|
if info_type == '累计净值':
|
1070
1145
|
df=df.replace('---',0)
|
1071
1146
|
df['累计净值']=df['累计净值'].astype(float)
|
1072
1147
|
df.sort_values(by=['累计净值'],ascending=False,inplace=True)
|
1073
1148
|
dfprint=df[['基金简称','基金代码','类型','累计净值','单位净值']]
|
1074
|
-
print(texttranslate("\n===== 中国ETF基金排名:累计净值 ====="))
|
1149
|
+
#print(texttranslate("\n===== 中国ETF基金排名:累计净值 ====="))
|
1150
|
+
titletxt="中国ETF基金排名:累计净值"
|
1151
|
+
dfprint=dfprint[dfprint['累计净值'] != 0]
|
1075
1152
|
|
1076
1153
|
if info_type == '市价':
|
1077
1154
|
df=df.replace('---',0)
|
1078
1155
|
df['市价']=df['市价'].astype(float)
|
1079
1156
|
df.sort_values(by=['市价'],ascending=False,inplace=True)
|
1080
1157
|
dfprint=df[['基金简称','基金代码','类型','市价','单位净值']]
|
1081
|
-
print(texttranslate("\n===== 中国ETF基金排名:市价 ====="))
|
1158
|
+
#print(texttranslate("\n===== 中国ETF基金排名:市价 ====="))
|
1159
|
+
titletxt="中国ETF基金排名:市价"
|
1160
|
+
dfprint=dfprint[dfprint['市价'] != 0]
|
1082
1161
|
|
1083
1162
|
if info_type == '增长率':
|
1084
1163
|
df['增长率']=df['增长率'].astype(str)
|
1085
1164
|
df.sort_values(by=['增长率'],ascending=False,inplace=True)
|
1086
1165
|
dfprint=df[['基金简称','基金代码','类型','增长率','市价','单位净值']]
|
1087
|
-
print(texttranslate("\n===== 中国ETF基金排名:增长率 ====="))
|
1166
|
+
#print(texttranslate("\n===== 中国ETF基金排名:增长率 ====="))
|
1167
|
+
titletxt="中国ETF基金排名:增长率"
|
1168
|
+
dfprint=dfprint[dfprint['增长率'] != 0]
|
1088
1169
|
|
1089
1170
|
#设置打印对齐
|
1090
1171
|
import pandas as pd
|
@@ -1106,6 +1187,7 @@ def etf_rank_china(info_type='单位净值',fund_type='全部类型',rank=10):
|
|
1106
1187
|
"""
|
1107
1188
|
print(dfprint10)
|
1108
1189
|
"""
|
1190
|
+
"""
|
1109
1191
|
print('') #在标题与表格之间空一行
|
1110
1192
|
alignlist=['right','left','center','center','right','right']
|
1111
1193
|
try:
|
@@ -1124,6 +1206,19 @@ def etf_rank_china(info_type='单位净值',fund_type='全部类型',rank=10):
|
|
1124
1206
|
import datetime
|
1125
1207
|
today = datetime.date.today()
|
1126
1208
|
print(texttranslate("数据来源:东方财富/天天基金,"),today)
|
1209
|
+
"""
|
1210
|
+
footnote1="披露净值信息的ETF基金数量:"+str(len(dfprint))+','
|
1211
|
+
footnote2="基金类型:"+str(fund_type)+'\n'
|
1212
|
+
footnote3="净值日期:"+str(nvdate)+','
|
1213
|
+
import datetime; todaydt = datetime.date.today()
|
1214
|
+
footnote4="数据来源:东方财富/天天基金,"+str(todaydt)
|
1215
|
+
footnote=footnote1+footnote2+footnote3+footnote4
|
1216
|
+
|
1217
|
+
df_display_CSS(dfprint10,titletxt=titletxt,footnote=footnote,facecolor='papayawhip',decimals=3, \
|
1218
|
+
first_col_align='left',second_col_align='right', \
|
1219
|
+
last_col_align='right',other_col_align='right', \
|
1220
|
+
titile_font_size='16px',heading_font_size='15px', \
|
1221
|
+
data_font_size='15px')
|
1127
1222
|
|
1128
1223
|
return df
|
1129
1224
|
|
@@ -1138,10 +1233,12 @@ if __name__=='__main__':
|
|
1138
1233
|
fromdate='2020-1-1'
|
1139
1234
|
todate='2020-10-16'
|
1140
1235
|
|
1141
|
-
def etf_trend_china(fund,
|
1236
|
+
def etf_trend_china(fund,start,end='today',loc1='best',loc2='best',twinx=False,graph=True):
|
1142
1237
|
"""
|
1143
1238
|
功能:ETF基金业绩趋势,单位净值,累计净值
|
1144
1239
|
"""
|
1240
|
+
fromdate,todate=start_end_preprocess(start,end='today')
|
1241
|
+
|
1145
1242
|
#检查日期
|
1146
1243
|
result,start,end=check_period(fromdate,todate)
|
1147
1244
|
if not result:
|
@@ -1167,7 +1264,8 @@ def etf_trend_china(fund,fromdate,todate,loc1='best',loc2='best',twinx=False,gra
|
|
1167
1264
|
df.set_index(['date'],inplace=True)
|
1168
1265
|
df['单位净值']=df['单位净值'].astype("float")
|
1169
1266
|
df['累计净值']=df['累计净值'].astype("float")
|
1170
|
-
|
1267
|
+
|
1268
|
+
df['净值日期']=df['净值日期'].apply(lambda x: pd.to_datetime(x))
|
1171
1269
|
dfp=df[(df['净值日期'] >= start)]
|
1172
1270
|
dfp=dfp[(dfp['净值日期'] <= end)]
|
1173
1271
|
if len(dfp) == 0:
|
@@ -1234,13 +1332,18 @@ def fund_summary_china():
|
|
1234
1332
|
pd.set_option('display.width',1000) # 设置宽度,就是说不换行,比较好看数据
|
1235
1333
|
pd.set_option('display.max_rows',500) # 设置行数的多少
|
1236
1334
|
pd.set_option('display.colheader_justify','left')
|
1237
|
-
|
1335
|
+
"""
|
1238
1336
|
print(texttranslate("\n===== 中国基金投资机构概况 ====="))
|
1239
1337
|
print(texttranslate("机构(会员)数量:"),end='')
|
1240
1338
|
num=len(list(set(list(amac_df["机构(会员)名称"]))))
|
1241
1339
|
print("{:,}".format(num))
|
1242
1340
|
|
1243
1341
|
print(texttranslate("其中包括:"))
|
1342
|
+
"""
|
1343
|
+
titletxt="中国基金投资机构概况"
|
1344
|
+
num=len(list(set(list(amac_df["机构(会员)名称"]))))
|
1345
|
+
footnote1="机构(会员)数量:"+str(num)
|
1346
|
+
|
1244
1347
|
amac_sum_df=pd.DataFrame(columns=['机构类型','数量','占比%'])
|
1245
1348
|
for t in typelist:
|
1246
1349
|
df_sub=amac_df[amac_df['机构类型']==t]
|
@@ -1270,6 +1373,7 @@ def fund_summary_china():
|
|
1270
1373
|
"""
|
1271
1374
|
pandas2prettytable(amac_sum_df.head(10),titletxt='',firstColSpecial=True,leftColAlign='l',otherColAlign='c',tabborder=False)
|
1272
1375
|
"""
|
1376
|
+
"""
|
1273
1377
|
alignlist=['left','left']+['center']*(len(list(amac_sum_df.head(10)))-3)+['right']
|
1274
1378
|
try:
|
1275
1379
|
print(amac_sum_df.head(10).to_markdown(index=True,tablefmt='plain',colalign=alignlist))
|
@@ -1283,6 +1387,17 @@ def fund_summary_china():
|
|
1283
1387
|
source=texttranslate("\n数据来源:中国证券投资基金业协会")
|
1284
1388
|
footnote=source+', '+str(today)
|
1285
1389
|
print(footnote)
|
1390
|
+
"""
|
1391
|
+
import datetime; todaydt = datetime.date.today()
|
1392
|
+
footnote2="数据来源:中国证券投资基金业协会,"+str(todaydt)
|
1393
|
+
footnote=footnote1+'\n'+footnote2
|
1394
|
+
df10=amac_sum_df.head(10)
|
1395
|
+
|
1396
|
+
df_display_CSS(df10,titletxt=titletxt,footnote=footnote,facecolor='papayawhip',decimals=2, \
|
1397
|
+
first_col_align='left',second_col_align='right', \
|
1398
|
+
last_col_align='right',other_col_align='right', \
|
1399
|
+
titile_font_size='16px',heading_font_size='15px', \
|
1400
|
+
data_font_size='15px')
|
1286
1401
|
|
1287
1402
|
"""
|
1288
1403
|
print(texttranslate("\n===== 中国基金投资机构会员代表概况 ====="))
|
@@ -1495,12 +1610,13 @@ if __name__=='__main__':
|
|
1495
1610
|
step_page_list=[100,10,1]
|
1496
1611
|
DEBUG=True
|
1497
1612
|
|
1498
|
-
def get_pef_product_china(max_pages=2000,step_page_list=[
|
1613
|
+
def get_pef_product_china(max_pages=2000,step_page_list=[100,20,1],DEBUG=True):
|
1499
1614
|
"""
|
1500
1615
|
功能:获取中国私募基金产品运营方式和状态信息,耗时较长
|
1501
1616
|
注意:由于获取过程极易失败,因此分割为三个阶段进行下载,然后合成。
|
1502
1617
|
"""
|
1503
|
-
print("
|
1618
|
+
print(" Downloading in pages, which takes long time upon network stability and speed")
|
1619
|
+
print(" If a download is stuck, RESTART Python kernel or even Jupyter, then run again")
|
1504
1620
|
import pandas as pd
|
1505
1621
|
|
1506
1622
|
# 第1步:页数跨度最大
|
@@ -1559,88 +1675,134 @@ def get_pef_product_china(max_pages=2000,step_page_list=[200,10,1],DEBUG=True):
|
|
1559
1675
|
#==============================================================================
|
1560
1676
|
|
1561
1677
|
|
1562
|
-
def pef_product_china(DEBUG=False):
|
1678
|
+
def pef_product_china(rank=20,facecolor='papayawhip',DEBUG=False):
|
1563
1679
|
|
1564
1680
|
"""
|
1565
1681
|
功能:中国私募基金管理人的产品管理概况
|
1566
1682
|
爬虫来源地址:https://zhuanlan.zhihu.com/p/97487003
|
1683
|
+
注意:下载数据需要极长时间,极少完全成功,谨慎运行!
|
1567
1684
|
"""
|
1568
|
-
print("Searching for private equity fund (PEF) info in China
|
1685
|
+
print("Searching for private equity fund (PEF) info in China ...")
|
1569
1686
|
import akshare as ak
|
1570
1687
|
import pandas as pd
|
1571
1688
|
|
1572
1689
|
#私募基金管理人基金产品
|
1573
|
-
product_df = get_pef_product_china(max_pages=2200,step_page_list=[
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1577
|
-
num=len(list(product_df["基金名称"]))
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
|
-
#
|
1583
|
-
|
1690
|
+
product_df = get_pef_product_china(max_pages=2200,step_page_list=[100,22,1],DEBUG=False)
|
1691
|
+
product_df['私募基金管理人类型']=product_df['私募基金管理人类型'].apply(lambda x: '方式不明' if x=='' or x is None else x)
|
1692
|
+
product_df['运行状态']=product_df['运行状态'].apply(lambda x: '状态不明' if x=='' or x is None else x)
|
1693
|
+
|
1694
|
+
#num=len(list(product_df["基金名称"])) #统计可能有问题,原因不明
|
1695
|
+
#footnote1="找到产品数量:"+str("{:,}".format(num))+'\n'
|
1696
|
+
import datetime; todaydt = datetime.date.today()
|
1697
|
+
footnote9="数据来源:中国证券投资基金业协会,"+str(todaydt)
|
1698
|
+
|
1699
|
+
# 产品运营方式==============================================================
|
1700
|
+
titletxt="中国私募基金管理人的产品运营方式"
|
1701
|
+
|
1702
|
+
#typelist=['受托管理','顾问管理','自我管理']
|
1703
|
+
typelist=list(set(list(product_df['私募基金管理人类型'])))
|
1704
|
+
dfprint=pd.DataFrame(columns=['运营方式','产品数量','数量占比%'])
|
1705
|
+
totalnum=0
|
1584
1706
|
for t in typelist:
|
1585
1707
|
df_sub=product_df[product_df['私募基金管理人类型']==t]
|
1586
1708
|
n=len(list(set(list(df_sub['基金名称']))))
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1709
|
+
totalnum=totalnum+n
|
1710
|
+
|
1711
|
+
s=pd.Series({'运营方式':t,'产品数量':n})
|
1712
|
+
try:
|
1713
|
+
dfprint=dfprint.append(s,ignore_index=True)
|
1714
|
+
except:
|
1715
|
+
dfprint=dfprint._append(s,ignore_index=True)
|
1716
|
+
|
1717
|
+
dfprint['数量占比%']=dfprint['产品数量'].apply(lambda x: round(x/totalnum*100,3))
|
1718
|
+
dfprint['产品数量']=dfprint['产品数量'].apply(lambda x: str("{:,}".format(x)))
|
1719
|
+
|
1720
|
+
dfprint.sort_values(by=['数量占比%'],ascending=False,inplace=True)
|
1721
|
+
dfprint.reset_index(drop=True,inplace=True)
|
1722
|
+
dfprint.index=dfprint.index + 1
|
1723
|
+
collist=list(dfprint)
|
1724
|
+
dfprint['序号']=dfprint.index
|
1725
|
+
dfprint=dfprint[['序号']+collist]
|
1726
|
+
|
1727
|
+
footnote1="找到管理产品"+str("{:,}".format(totalnum))+'个\n'
|
1728
|
+
footnote=footnote1+footnote9
|
1729
|
+
|
1730
|
+
df_display_CSS(dfprint,titletxt=titletxt,footnote=footnote,facecolor=facecolor,decimals=3, \
|
1731
|
+
first_col_align='center',second_col_align='left', \
|
1732
|
+
last_col_align='right',other_col_align='right', \
|
1733
|
+
titile_font_size='16px',heading_font_size='15px', \
|
1734
|
+
data_font_size='15px')
|
1735
|
+
|
1736
|
+
#运营状态===================================================================
|
1737
|
+
titletxt="中国私募基金管理人的产品运营状态"
|
1593
1738
|
typelist=list(set(list(product_df['运行状态'])))
|
1594
|
-
|
1595
|
-
|
1596
|
-
typelist=['正在运作','提前清算','正常清算','延期清算','投顾协议已终止','']
|
1597
|
-
maxlen=0
|
1598
|
-
for t in typelist:
|
1599
|
-
tlen=strlen(t)
|
1600
|
-
if tlen > maxlen: maxlen=tlen
|
1601
|
-
maxlen=maxlen+1
|
1602
|
-
|
1739
|
+
dfprint=pd.DataFrame(columns=['运营状态','产品数量','数量占比%'])
|
1740
|
+
totalnum=0
|
1603
1741
|
for t in typelist:
|
1604
1742
|
df_sub=product_df[product_df['运行状态']==t]
|
1605
1743
|
n=len(list(set(list(df_sub['基金名称']))))
|
1606
|
-
if
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1744
|
+
if n==0: continue
|
1745
|
+
totalnum=totalnum+n
|
1746
|
+
|
1747
|
+
s=pd.Series({'运营状态':t,'产品数量':n})
|
1748
|
+
try:
|
1749
|
+
dfprint=dfprint.append(s,ignore_index=True)
|
1750
|
+
except:
|
1751
|
+
dfprint=dfprint._append(s,ignore_index=True)
|
1752
|
+
|
1753
|
+
dfprint['数量占比%']=dfprint['产品数量'].apply(lambda x: round(x/totalnum*100,3))
|
1754
|
+
dfprint['产品数量']=dfprint['产品数量'].apply(lambda x: str("{:,}".format(x)))
|
1755
|
+
|
1756
|
+
dfprint.sort_values(by=['数量占比%'],ascending=False,inplace=True)
|
1757
|
+
dfprint.reset_index(drop=True,inplace=True)
|
1758
|
+
dfprint.index=dfprint.index + 1
|
1759
|
+
collist=list(dfprint)
|
1760
|
+
dfprint['序号']=dfprint.index
|
1761
|
+
dfprint=dfprint[['序号']+collist]
|
1762
|
+
|
1763
|
+
footnote1="找到运营产品"+str("{:,}".format(totalnum))+'个\n'
|
1764
|
+
footnote=footnote1+footnote9
|
1765
|
+
|
1766
|
+
df_display_CSS(dfprint,titletxt=titletxt,footnote=footnote,facecolor=facecolor,decimals=3, \
|
1767
|
+
first_col_align='center',second_col_align='left', \
|
1768
|
+
last_col_align='right',other_col_align='right', \
|
1769
|
+
titile_font_size='16px',heading_font_size='15px', \
|
1770
|
+
data_font_size='15px')
|
1771
|
+
|
1772
|
+
#推出产品数量排行===========================================================
|
1773
|
+
titletxt="中国推出产品数量最多的私募基金管理人(前"+str(rank)+"名)"
|
1618
1774
|
subttl=pd.DataFrame(product_df.groupby(by=['私募基金管理人名称'])['基金名称'].count())
|
1619
1775
|
subttl.rename(columns={'基金名称':'产品数量'}, inplace=True)
|
1620
|
-
subttl['
|
1776
|
+
subttl['数量占比‰']=round(subttl['产品数量']/totalnum*1000.0,2)
|
1621
1777
|
subttl.sort_values(by=['产品数量'],ascending=False,inplace=True)
|
1622
1778
|
subttl.reset_index(inplace=True)
|
1623
1779
|
|
1624
1780
|
subttl.index=subttl.index + 1
|
1625
|
-
subttl10=subttl.head(
|
1626
|
-
|
1627
|
-
#设置打印对齐
|
1628
|
-
pd.set_option('display.max_columns', 1000)
|
1629
|
-
pd.set_option('display.width', 1000)
|
1630
|
-
pd.set_option('display.max_colwidth', 1000)
|
1631
|
-
pd.set_option('display.unicode.ambiguous_as_wide', True)
|
1632
|
-
pd.set_option('display.unicode.east_asian_width', True)
|
1781
|
+
subttl10=subttl.head(rank)
|
1633
1782
|
|
1634
|
-
|
1783
|
+
dfprint=subttl10
|
1784
|
+
dfprint.sort_values(by=['数量占比‰'],ascending=False,inplace=True)
|
1785
|
+
dfprint.reset_index(drop=True,inplace=True)
|
1786
|
+
dfprint.index=dfprint.index + 1
|
1787
|
+
collist=list(dfprint)
|
1788
|
+
dfprint['序号']=dfprint.index
|
1789
|
+
dfprint=dfprint[['序号']+collist]
|
1635
1790
|
|
1636
|
-
pctsum=round(subttl10['
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1640
|
-
|
1641
|
-
|
1791
|
+
pctsum=round(subttl10['数量占比‰'].sum(),2)
|
1792
|
+
footnote1="找到产品"+str("{:,}".format(totalnum))+"个,上述产品合计占比"+str(pctsum)+'%'+'\n'
|
1793
|
+
footnote=footnote1+footnote9
|
1794
|
+
|
1795
|
+
df_display_CSS(dfprint,titletxt=titletxt,footnote=footnote,facecolor=facecolor,decimals=2, \
|
1796
|
+
first_col_align='center',second_col_align='left', \
|
1797
|
+
last_col_align='right',other_col_align='right', \
|
1798
|
+
titile_font_size='16px',heading_font_size='15px', \
|
1799
|
+
data_font_size='15px')
|
1800
|
+
|
1801
|
+
|
1802
|
+
# 托管产品==================================================================
|
1803
|
+
titletxt="中国私募基金管理人的产品托管概况(前"+str(rank)+"名)"
|
1642
1804
|
tnum=len(list(set(list(product_df['托管人名称']))))
|
1643
|
-
|
1805
|
+
footnote1="找到产品"+str("{:,}".format(totalnum))+"个,托管机构"+str("{:,}".format(tnum))+'家\n'
|
1644
1806
|
|
1645
1807
|
subttl=pd.DataFrame(product_df.groupby(by=['托管人名称'])['基金名称'].count())
|
1646
1808
|
subttl.rename(columns={'基金名称':'产品数量'}, inplace=True)
|
@@ -1650,15 +1812,30 @@ def pef_product_china(DEBUG=False):
|
|
1650
1812
|
subttl=subttl[subttl['托管人名称']!='']
|
1651
1813
|
#subttl.drop(subttl.index[0], inplace=True) # 删除第1行
|
1652
1814
|
subttl.reset_index(drop=True,inplace=True)
|
1653
|
-
subttl['
|
1815
|
+
subttl['数量占比%']=round(subttl['产品数量']/totalnum*100.0,3)
|
1654
1816
|
|
1655
1817
|
subttl.index=subttl.index + 1
|
1656
|
-
subttl10=subttl.head(
|
1657
|
-
|
1658
|
-
pctsum=round(subttl10['
|
1659
|
-
print(subttl10)
|
1660
|
-
print(texttranslate("上述金融机构托管产品总计占比:"),pctsum,'\b%')
|
1661
|
-
|
1818
|
+
subttl10=subttl.head(rank)
|
1819
|
+
|
1820
|
+
pctsum=round(subttl10['数量占比%'].sum(),2)
|
1821
|
+
#print(subttl10)
|
1822
|
+
#print(texttranslate("上述金融机构托管产品总计占比:"),pctsum,'\b%')
|
1823
|
+
footnote2="上述机构托管产品合计占比:"+str(pctsum)+'%\n'
|
1824
|
+
footnote=footnote1+footnote2+footnote9
|
1825
|
+
|
1826
|
+
dfprint=subttl10
|
1827
|
+
dfprint.sort_values(by=['数量占比%'],ascending=False,inplace=True)
|
1828
|
+
dfprint.reset_index(drop=True,inplace=True)
|
1829
|
+
dfprint.index=dfprint.index + 1
|
1830
|
+
collist=list(dfprint)
|
1831
|
+
dfprint['序号']=dfprint.index
|
1832
|
+
dfprint=dfprint[['序号']+collist]
|
1833
|
+
|
1834
|
+
df_display_CSS(dfprint,titletxt=titletxt,footnote=footnote,facecolor=facecolor,decimals=3, \
|
1835
|
+
first_col_align='center',second_col_align='left', \
|
1836
|
+
last_col_align='right',other_col_align='right', \
|
1837
|
+
titile_font_size='16px',heading_font_size='15px', \
|
1838
|
+
data_font_size='15px')
|
1662
1839
|
|
1663
1840
|
return product_df
|
1664
1841
|
|
siat/security_prices.py
CHANGED
@@ -1244,8 +1244,8 @@ def get_prices_yahoo(ticker,start,end,retry_count=3,pause=1):
|
|
1244
1244
|
|
1245
1245
|
print(" Successfully retrieved",len(p),"records for",ticker,ptname)
|
1246
1246
|
|
1247
|
-
|
1248
|
-
|
1247
|
+
#去掉时区
|
1248
|
+
p=df_index_timezone_remove(p)
|
1249
1249
|
|
1250
1250
|
return p
|
1251
1251
|
|
@@ -1331,13 +1331,13 @@ def get_prices_yf(ticker,start,end,threads=False):
|
|
1331
1331
|
if ptname == ticker: ptname=''
|
1332
1332
|
|
1333
1333
|
print(" Successfully retrieved",len(p),"records for",ticker1,ptname)
|
1334
|
+
|
1335
|
+
#去掉时区
|
1336
|
+
p=df_index_timezone_remove(p)
|
1334
1337
|
else:
|
1335
1338
|
pass
|
1336
1339
|
#print(" #Error(get_prices_yf):",ticker1,"not found or no prices in the period or inaccessible to yahoo")
|
1337
1340
|
|
1338
|
-
#去掉时区
|
1339
|
-
p=df_index_timezone_remove(p)
|
1340
|
-
|
1341
1341
|
return p
|
1342
1342
|
|
1343
1343
|
if __name__=='__main__':
|
@@ -52,7 +52,7 @@ siat/financials_test.py,sha256=HJ3CPo_Xckz2wXi3AEP6ZNWCF1Duc1pLi0Y10USiImc,23829
|
|
52
52
|
siat/fred_test.py,sha256=KF50ssSbsfpa_kT6iuomD0vG4eXztAcOasZxg1OGX5w,1201
|
53
53
|
siat/fund.py,sha256=wMDORsCBV8ZXfgwbtq-0bu3qqWY66dHnbqgllW0gWCo,24637
|
54
54
|
siat/fund_china.pickle,sha256=QI3IjV46EeJ5ryO3xocmByc-6b_6_nDxgcXDhBHzop0,2380915
|
55
|
-
siat/fund_china.py,sha256=
|
55
|
+
siat/fund_china.py,sha256=e-Ngpm34Kby8CFkso3M6KA4MWOPSi-M9FxS8Nv7Yr5M,90910
|
56
56
|
siat/fund_china_test.py,sha256=-Bh6m0J0GPpIbYXx-H2vpzJoNFI6pE2C2jVPa8DazgE,6649
|
57
57
|
siat/fund_test.py,sha256=V4ADb8Gsp8gyeFTwcgRsJBpnUih_O-Q2V1ILc5oKjK8,1116
|
58
58
|
siat/future_china.py,sha256=F-HsIf2Op8Z22RzTjet1g8COzldgnMjFNSXsAkeGyWo,17595
|
@@ -95,7 +95,7 @@ siat/sector_china.py,sha256=QSNJclhzT6V9NidziMwwAs-Kk6f7nzdK6PiPGkKrBCk,111617
|
|
95
95
|
siat/sector_china_test.py,sha256=1wq7ef8Bb_L8F0h0W6FvyBrIcBTEbrTV7hljtpj49U4,5843
|
96
96
|
siat/security_price.py,sha256=2oHskgiw41KMGfqtnA0i2YjNNV6cYgtlUK0j3YeuXWs,29185
|
97
97
|
siat/security_price2.py,sha256=kuYh0V5cqclkM6MjZUd-N361fv3oxGVVerYINuTzZrE,24622
|
98
|
-
siat/security_prices.py,sha256=
|
98
|
+
siat/security_prices.py,sha256=gubx-HrlnkSTByIhMC9qB2fxTMJTTxW1DH9KDGX22dY,102741
|
99
99
|
siat/security_prices_test.py,sha256=OEphoJ87NPKoNow1QA8EU_5MUYrJF-qKoWKNapVfZNI,10779
|
100
100
|
siat/security_trend.py,sha256=o0vpWdrJkmODCP94X-Bvn-w7efHhj9HpUYBHtLl55D0,17240
|
101
101
|
siat/security_trend2.py,sha256=4yBY3ve0Kddu95JemS02gfLbrHVN2_gl_irr5pA4F6w,24626
|
@@ -132,7 +132,7 @@ siat/valuation.py,sha256=NKfeZMdDJOW42oLVHob6eSVBXUqlN1OCnnzwyGAst8c,48855
|
|
132
132
|
siat/valuation_china.py,sha256=Tde2LzPDQy3Z7xOQQDw4ckQMPdROp_z0-GjFE6Z5_lI,67639
|
133
133
|
siat/valuation_market_china_test.py,sha256=gbJ0ioauuo4koTPH6WKUkqcXiQPafnbhU5eKJ6lpdLA,1571
|
134
134
|
siat/var_model_validation.py,sha256=f-oDewg7bPzyNanz_Y_jLH68NowAA3gXFehW_weKGG0,14898
|
135
|
-
siat-3.
|
136
|
-
siat-3.
|
137
|
-
siat-3.
|
138
|
-
siat-3.
|
135
|
+
siat-3.1.1.dist-info/METADATA,sha256=9fUOM1J5SJKvPEnZpip7QZ4nd_W7tCtWaK6kSPCphNQ,1447
|
136
|
+
siat-3.1.1.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
137
|
+
siat-3.1.1.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
|
138
|
+
siat-3.1.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|