siat 3.1.1__py3-none-any.whl → 3.1.3__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/common.py
CHANGED
@@ -3866,4 +3866,14 @@ def df_index_timezone_remove(df):
|
|
3866
3866
|
|
3867
3867
|
return df
|
3868
3868
|
#==============================================================================
|
3869
|
+
|
3870
|
+
def df_swap_columns(df, col1, col2):
|
3871
|
+
"""
|
3872
|
+
功能:交换df中的两个列的位置
|
3873
|
+
"""
|
3874
|
+
cols = df.columns.tolist()
|
3875
|
+
i1, i2 = cols.index(col1), cols.index(col2)
|
3876
|
+
cols[i2], cols[i1] = cols[i1], cols[i2]
|
3877
|
+
|
3878
|
+
return df[cols]
|
3869
3879
|
#==============================================================================
|
siat/fund_china.py
CHANGED
@@ -403,7 +403,7 @@ if __name__=='__main__':
|
|
403
403
|
|
404
404
|
df=reits_list_china(rank=10)
|
405
405
|
|
406
|
-
def reits_list_china(
|
406
|
+
def reits_list_china(indicator='最新价',rank=10):
|
407
407
|
"""
|
408
408
|
功能:REITs基金信息概述和列表
|
409
409
|
目前能正常工作
|
@@ -415,26 +415,37 @@ def reits_list_china(rank=10,sort='最新价'):
|
|
415
415
|
print(" #Error(reits_profile_china): akshare does not work properly now")
|
416
416
|
return None
|
417
417
|
df2.drop('序号', axis=1, inplace=True)
|
418
|
+
df2['成交额']=df2['成交额'].apply(lambda x: int(x))
|
419
|
+
df2.fillna("---",inplace=True)
|
418
420
|
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
421
|
+
df2=df_swap_columns(df2, col1='代码', col2='名称')
|
422
|
+
num=len(df2)
|
423
|
+
|
424
|
+
indicatorlist=list(df2)
|
425
|
+
if indicator not in indicatorlist:
|
426
|
+
print(" #Error(reits_list_china):",indicator,"is not supported")
|
427
|
+
print(" Supported indicators:",indicatorlist)
|
423
428
|
return None
|
424
429
|
|
425
|
-
#df2.
|
426
|
-
df2.sort_values(by=[
|
430
|
+
#df2.indicator_values(by=['昨收'],ascending=False,inplace=True)
|
431
|
+
df2.sort_values(by=[indicator],ascending=False,inplace=True)
|
427
432
|
df2.reset_index(drop=True,inplace=True)
|
428
|
-
|
429
|
-
num=len(df2)
|
433
|
+
collist=list(df2)
|
430
434
|
|
435
|
+
for i in ['名称','代码',indicator]:
|
436
|
+
collist.remove(i)
|
437
|
+
collist1=['名称','代码',indicator]+collist
|
438
|
+
|
439
|
+
df2['序号']=df2.index + 1
|
440
|
+
df2=df2[['序号']+collist1]
|
441
|
+
"""
|
431
442
|
#设置打印对齐
|
432
443
|
pd.set_option('display.max_columns', 1000)
|
433
444
|
pd.set_option('display.width', 1000)
|
434
445
|
pd.set_option('display.max_colwidth', 1000)
|
435
446
|
pd.set_option('display.unicode.ambiguous_as_wide', True)
|
436
447
|
pd.set_option('display.unicode.east_asian_width', True)
|
437
|
-
|
448
|
+
"""
|
438
449
|
if rank > 0:
|
439
450
|
order='前'
|
440
451
|
dfb=df2.head(rank)
|
@@ -443,11 +454,8 @@ def reits_list_china(rank=10,sort='最新价'):
|
|
443
454
|
rank=-rank
|
444
455
|
dfb=df2.tail(rank)
|
445
456
|
|
446
|
-
dfb.fillna("---",inplace=True)
|
447
|
-
dfb['成交额']=dfb['成交额'].apply(lambda x: int(x))
|
448
|
-
|
449
457
|
#print("\n===== 中国REITs基金列表(按最新价高低排列,"+order+str(rank)+"名) =====\n")
|
450
|
-
titletxt="中国REITs基金列表(按"+
|
458
|
+
titletxt="中国REITs基金列表(按"+indicator+"降序排列,"+order+str(rank)+"名)"
|
451
459
|
"""
|
452
460
|
print(dfb.to_string(index=False))
|
453
461
|
"""
|
@@ -464,10 +472,10 @@ def reits_list_china(rank=10,sort='最新价'):
|
|
464
472
|
"""
|
465
473
|
import datetime; todaydt = datetime.date.today()
|
466
474
|
#print("\n*** 数据来源:东方财富, 总计"+str(num)+"只REITs基金,",today)
|
467
|
-
footnote="
|
475
|
+
footnote="数据来源:东方财富,共找到"+str(num)+"只REITs基金,"+str(todaydt)
|
468
476
|
|
469
477
|
df_display_CSS(dfb,titletxt=titletxt,footnote=footnote,facecolor='papayawhip',decimals=3, \
|
470
|
-
first_col_align='
|
478
|
+
first_col_align='center',second_col_align='left', \
|
471
479
|
last_col_align='right',other_col_align='right', \
|
472
480
|
titile_font_size='16px',heading_font_size='15px', \
|
473
481
|
data_font_size='15px')
|
@@ -481,7 +489,7 @@ if __name__=='__main__':
|
|
481
489
|
fund_type='债券型'
|
482
490
|
printout=True
|
483
491
|
|
484
|
-
def pof_list_china(fund_type='全部类型',printout=True):
|
492
|
+
def pof_list_china(rank=10,fund_type='全部类型',printout=True):
|
485
493
|
"""
|
486
494
|
功能:抓取公募基金列表,按照基金类型列表,按照基金名称拼音排序
|
487
495
|
"""
|
@@ -517,6 +525,7 @@ def pof_list_china(fund_type='全部类型',printout=True):
|
|
517
525
|
df2=df[df['基金类型'].apply(lambda x: fund_type in x)]
|
518
526
|
else:
|
519
527
|
df2=df
|
528
|
+
|
520
529
|
df3=df2[['基金简称','基金代码','基金类型']]
|
521
530
|
df3.reset_index(drop=True,inplace=True)
|
522
531
|
|
@@ -526,13 +535,9 @@ def pof_list_china(fund_type='全部类型',printout=True):
|
|
526
535
|
if fund_type != '全部类型':
|
527
536
|
print(texttranslate("共找到")+str(num)+texttranslate("支基金, 类型为")+fund_type)
|
528
537
|
return df3
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
print(texttranslate("其中包括:"))
|
533
|
-
"""
|
534
|
-
titletxt="中国公募基金的种类与分布概况"
|
535
|
-
footnote1="【注】公募基金总数:"+str("{:,}".format(num))+'\n'
|
538
|
+
|
539
|
+
titletxt="中国公募基金的类型与分布(前"+str(rank)+"名)"
|
540
|
+
footnote1="共有"+str(len(typelist))+"种类型,"+str("{:,}".format(num))+'支基金\n'
|
536
541
|
|
537
542
|
maxlen=0
|
538
543
|
for t in typelist:
|
@@ -541,8 +546,10 @@ def pof_list_china(fund_type='全部类型',printout=True):
|
|
541
546
|
maxlen=maxlen+1
|
542
547
|
|
543
548
|
#排序
|
544
|
-
|
545
|
-
|
549
|
+
dfg0=pd.DataFrame(df.groupby("基金类型").size())
|
550
|
+
dfg0.sort_values(by=[0], ascending=False, inplace=True)
|
551
|
+
dfg=dfg0.head(rank)
|
552
|
+
|
546
553
|
typelist2=list(dfg.index)
|
547
554
|
try:
|
548
555
|
typelist2.remove('')
|
@@ -556,11 +563,11 @@ def pof_list_china(fund_type='全部类型',printout=True):
|
|
556
563
|
collist=list(dfg)
|
557
564
|
dfg['序号']=dfg.index+1
|
558
565
|
dfg=dfg[['序号']+collist]
|
559
|
-
|
566
|
+
|
567
|
+
footnote2="表中类型的数量占比为"+str(round(dfg['基金数量'].sum()/num*100,2))+"%\n"
|
560
568
|
import datetime; todaydt = datetime.date.today()
|
561
|
-
|
562
|
-
|
563
|
-
footnote=footnote1+footnote2
|
569
|
+
footnote9="数据来源:东方财富/天天基金,"+str(todaydt)
|
570
|
+
footnote=footnote1+footnote2+footnote9
|
564
571
|
|
565
572
|
df_display_CSS(dfg,titletxt=titletxt,footnote=footnote,facecolor='papayawhip',decimals=3, \
|
566
573
|
first_col_align='center',second_col_align='left', \
|
@@ -578,10 +585,12 @@ if __name__=='__main__':
|
|
578
585
|
info_type='单位净值'
|
579
586
|
fund_type='股票型'
|
580
587
|
|
581
|
-
def oef_rank_china(
|
588
|
+
def oef_rank_china(indicator='单位净值',fund_type='全部类型',rank=5):
|
582
589
|
"""
|
583
590
|
功能:中国开放式基金排名,单位净值,累计净值,手续费
|
584
591
|
"""
|
592
|
+
info_type=indicator
|
593
|
+
|
585
594
|
typelist=['单位净值','累计净值','手续费','增长率']
|
586
595
|
if info_type not in typelist:
|
587
596
|
print(" #Error(oef_rank_china): unsupported info type",info_type)
|
@@ -665,26 +674,30 @@ def oef_rank_china(info_type='单位净值',fund_type='全部类型',rank=10):
|
|
665
674
|
if info_type == '单位净值':
|
666
675
|
df['单位净值']=df['单位净值'].apply(lambda x: round(x,2))
|
667
676
|
df.sort_values(by=['单位净值'],ascending=False,inplace=True)
|
668
|
-
dfprint=df[['基金简称','基金代码','基金类型','单位净值','申购状态','赎回状态']]
|
677
|
+
#dfprint=df[['基金简称','基金代码','基金类型','单位净值','申购状态','赎回状态']]
|
678
|
+
dfprint=df[['基金简称','基金代码','基金类型','单位净值','累计净值']]
|
669
679
|
#print(texttranslate("\n===== 中国开放式基金排名:单位净值 ====="))
|
670
680
|
titletxt="中国开放式基金排名:单位净值"
|
671
681
|
|
672
682
|
if info_type == '累计净值':
|
673
683
|
df['累计净值']=df['累计净值'].apply(lambda x: round(x,2))
|
674
684
|
df.sort_values(by=['累计净值'],ascending=False,inplace=True)
|
675
|
-
dfprint=df[['基金简称','基金代码','基金类型','累计净值','申购状态','赎回状态']]
|
685
|
+
#dfprint=df[['基金简称','基金代码','基金类型','累计净值','申购状态','赎回状态']]
|
686
|
+
dfprint=df[['基金简称','基金代码','基金类型','累计净值','单位净值']]
|
676
687
|
#print(texttranslate("\n===== 中国开放式基金排名:累计净值 ====="))
|
677
688
|
titletxt="中国开放式基金排名:累计净值"
|
678
689
|
|
679
690
|
if info_type == '手续费':
|
680
691
|
df.sort_values(by=['手续费'],ascending=False,inplace=True)
|
681
|
-
dfprint=df[['基金简称','基金代码','基金类型','手续费','申购状态','赎回状态']]
|
692
|
+
#dfprint=df[['基金简称','基金代码','基金类型','手续费','申购状态','赎回状态']]
|
693
|
+
dfprint=df[['基金简称','基金代码','基金类型','手续费','单位净值']]
|
682
694
|
#print(texttranslate("\n===== 中国开放式基金排名:手续费 ====="))
|
683
695
|
titletxt="中国开放式基金排名:手续费"
|
684
696
|
|
685
697
|
if info_type == '增长率':
|
686
698
|
df.sort_values(by=['日增长率'],ascending=False,inplace=True)
|
687
|
-
dfprint=df[['基金简称','基金代码','基金类型','日增长率','申购状态','赎回状态']]
|
699
|
+
#dfprint=df[['基金简称','基金代码','基金类型','日增长率','申购状态','赎回状态']]
|
700
|
+
dfprint=df[['基金简称','基金代码','基金类型','日增长率','单位净值']]
|
688
701
|
#print(texttranslate("\n===== 中国开放式基金排名:增长率% ====="))
|
689
702
|
titletxt="中国开放式基金排名:增长率%"
|
690
703
|
|
@@ -701,6 +714,10 @@ def oef_rank_china(info_type='单位净值',fund_type='全部类型',rank=10):
|
|
701
714
|
dfprint.reset_index(drop=True,inplace=True)
|
702
715
|
dfprint.index=dfprint.index + 1
|
703
716
|
|
717
|
+
collist=list(dfprint)
|
718
|
+
dfprint['序号']=dfprint.index
|
719
|
+
dfprint=dfprint[['序号']+collist]
|
720
|
+
|
704
721
|
if rank >= 0:
|
705
722
|
dfprint10=dfprint.head(rank)
|
706
723
|
else:
|
@@ -739,7 +756,7 @@ def oef_rank_china(info_type='单位净值',fund_type='全部类型',rank=10):
|
|
739
756
|
footnote=footnote1+footnote2+footnote3+footnote4
|
740
757
|
|
741
758
|
df_display_CSS(dfprint10,titletxt=titletxt,footnote=footnote,facecolor='papayawhip',decimals=4, \
|
742
|
-
first_col_align='
|
759
|
+
first_col_align='center',second_col_align='left', \
|
743
760
|
last_col_align='right',other_col_align='right', \
|
744
761
|
titile_font_size='16px',heading_font_size='15px', \
|
745
762
|
data_font_size='15px')
|
@@ -788,15 +805,19 @@ if __name__=='__main__':
|
|
788
805
|
twinx=False
|
789
806
|
zeroline=False
|
790
807
|
|
791
|
-
def oef_trend_china(
|
808
|
+
def oef_trend_china(ticker,start,end='today',indicator='净值', \
|
792
809
|
power=0,twinx=False, \
|
793
|
-
|
810
|
+
average_value=True,facecolor='whitesmoke',
|
811
|
+
loc1='best',loc2='best'):
|
794
812
|
"""
|
795
813
|
功能:开放式基金业绩趋势,单位净值,累计净值,近三个月收益率,同类排名,总排名
|
796
814
|
"""
|
815
|
+
fund=ticker
|
797
816
|
fromdate,todate=start_end_preprocess(start,end)
|
817
|
+
trend_type=indicator
|
818
|
+
|
798
819
|
#检查走势类型
|
799
|
-
trendlist=["净值","收益率","排名"]
|
820
|
+
trendlist=["净值","单位净值","累计净值","收益率","排名"]
|
800
821
|
if trend_type not in trendlist:
|
801
822
|
print(" #Error(oef_trend_china): unsupported trend type:",trend_type)
|
802
823
|
print(" Supported trend types:",trendlist)
|
@@ -815,6 +836,7 @@ def oef_trend_china(fund,start,end='today',trend_type='净值', \
|
|
815
836
|
"""
|
816
837
|
print("Searching for open-ended fund (OEF) trend info in China ...")
|
817
838
|
import akshare as ak
|
839
|
+
import pandas as pd
|
818
840
|
|
819
841
|
#开放式基金-历史数据
|
820
842
|
import datetime; today = datetime.date.today()
|
@@ -824,7 +846,6 @@ def oef_trend_china(fund,start,end='today',trend_type='净值', \
|
|
824
846
|
fund_name=ticker_name(fund1,'fund')
|
825
847
|
|
826
848
|
#绘制单位/累计净值对比图
|
827
|
-
import pandas as pd
|
828
849
|
if trend_type == '净值':
|
829
850
|
df1 = ak.fund_open_fund_info_em(fund1, indicator="单位净值走势")
|
830
851
|
df1.rename(columns={'净值日期':'date','单位净值':'单位净值'}, inplace=True)
|
@@ -854,13 +875,91 @@ def oef_trend_china(fund,start,end='today',trend_type='净值', \
|
|
854
875
|
titletxt=texttranslate("开放式基金的净值趋势:")+fund_name
|
855
876
|
|
856
877
|
#footnote=source+', '+str(today)
|
857
|
-
footnote='
|
878
|
+
footnote='注意:图中为交易市场数据,存在溢价或折价,可能与基金公司公布的净值存在差异\n'+source+', '+str(today)
|
879
|
+
|
880
|
+
plot_line2(dfp,ticker1,colname1,label1, \
|
881
|
+
dfp,ticker2,colname2,label2, \
|
882
|
+
ylabeltxt,titletxt,footnote,power=power,twinx=twinx, \
|
883
|
+
facecolor=facecolor, \
|
884
|
+
loc1=loc1,loc2=loc2)
|
885
|
+
return df
|
886
|
+
|
887
|
+
#绘制单位净值图
|
888
|
+
if trend_type == '单位净值':
|
889
|
+
df1 = ak.fund_open_fund_info_em(fund1, indicator="单位净值走势")
|
890
|
+
df1.rename(columns={'净值日期':'date','单位净值':'单位净值'}, inplace=True)
|
891
|
+
df1['日期']=df1['date']
|
892
|
+
df1.set_index(['date'],inplace=True)
|
893
|
+
"""
|
894
|
+
df2 = ak.fund_open_fund_info_em(fund1, indicator="累计净值走势")
|
895
|
+
df2.rename(columns={'净值日期':'date','累计净值':'累计净值'}, inplace=True)
|
896
|
+
df2.set_index(['date'],inplace=True)
|
897
|
+
"""
|
898
|
+
#合并
|
899
|
+
#df = pd.merge(df1,df2,left_index=True,right_index=True,how='inner')
|
900
|
+
df = df1
|
901
|
+
df['日期']=df['日期'].apply(lambda x: pd.to_datetime(x))
|
902
|
+
|
903
|
+
dfp=df[(df['日期'] >= start)]
|
904
|
+
dfp=dfp[(dfp['日期'] <= end)]
|
905
|
+
if len(dfp) == 0:
|
906
|
+
print(" #Error(oef_trend_china): no info found for",fund,"in the period:",fromdate,todate)
|
907
|
+
return
|
908
|
+
|
909
|
+
#绘图
|
910
|
+
ticker1=fund1; colname1='单位净值';label1=texttranslate('单位净值')
|
911
|
+
#ticker2=fund1; colname2='累计净值';label2=texttranslate('累计净值')
|
912
|
+
#ylabeltxt='人民币元'
|
913
|
+
ylabeltxt=texttranslate('单位净值')
|
914
|
+
|
915
|
+
titletxt=texttranslate("开放式基金的净值趋势:")+fund_name
|
916
|
+
|
917
|
+
#footnote=source+', '+str(today)
|
918
|
+
footnote='图中为交易市场数据,存在溢价或折价,可能与基金公司公布的净值存在差异\n'+source+', '+str(today)
|
858
919
|
|
920
|
+
plot_line(dfp,colname1,label1,ylabeltxt,titletxt,footnote,power=power,loc=loc1, \
|
921
|
+
average_value=average_value,facecolor=facecolor)
|
922
|
+
"""
|
859
923
|
plot_line2(dfp,ticker1,colname1,label1, \
|
860
|
-
|
861
|
-
|
924
|
+
dfp,ticker2,colname2,label2, \
|
925
|
+
ylabeltxt,titletxt,footnote,power=power,twinx=twinx, \
|
926
|
+
facecolor=facecolor, \
|
862
927
|
loc1=loc1,loc2=loc2)
|
928
|
+
"""
|
863
929
|
return df
|
930
|
+
|
931
|
+
#绘制累计净值图
|
932
|
+
if trend_type == '累计净值':
|
933
|
+
df2 = ak.fund_open_fund_info_em(fund1, indicator="累计净值走势")
|
934
|
+
df2.rename(columns={'净值日期':'date','累计净值':'累计净值'}, inplace=True)
|
935
|
+
df2['日期']=df2['date']
|
936
|
+
df2.set_index(['date'],inplace=True)
|
937
|
+
|
938
|
+
#合并
|
939
|
+
df = df2
|
940
|
+
df['日期']=df['日期'].apply(lambda x: pd.to_datetime(x))
|
941
|
+
|
942
|
+
dfp=df[(df['日期'] >= start)]
|
943
|
+
dfp=dfp[(dfp['日期'] <= end)]
|
944
|
+
if len(dfp) == 0:
|
945
|
+
print(" #Error(oef_trend_china): no info found for",fund,"in the period:",fromdate,todate)
|
946
|
+
return
|
947
|
+
|
948
|
+
#绘图
|
949
|
+
ticker2=fund1; colname2='累计净值';label2=texttranslate('累计净值')
|
950
|
+
#ylabeltxt='人民币元'
|
951
|
+
ylabeltxt=texttranslate('累计净值')
|
952
|
+
|
953
|
+
titletxt=texttranslate("开放式基金的净值趋势:")+fund_name
|
954
|
+
|
955
|
+
#footnote=source+', '+str(today)
|
956
|
+
footnote='图中为交易市场数据,存在溢价或折价,可能与基金公司公布的净值存在差异\n'+source+', '+str(today)
|
957
|
+
|
958
|
+
plot_line(dfp,colname2,label2,ylabeltxt,titletxt,footnote,power=power,loc=loc1, \
|
959
|
+
average_value=average_value,facecolor=facecolor)
|
960
|
+
|
961
|
+
return df
|
962
|
+
|
864
963
|
|
865
964
|
#绘制累计收益率单线图
|
866
965
|
if trend_type == '收益率':
|
@@ -876,10 +975,11 @@ def oef_trend_china(fund,start,end='today',trend_type='净值', \
|
|
876
975
|
return
|
877
976
|
|
878
977
|
colname='累计收益率'; collabel=texttranslate('累计收益率%')
|
879
|
-
ylabeltxt=texttranslate('
|
978
|
+
ylabeltxt=texttranslate('累计收益率%')
|
880
979
|
titletxt=texttranslate("开放式基金的累计收益率趋势:")+fund_name
|
881
|
-
footnote=source+'
|
882
|
-
plot_line(dfp,colname,collabel,ylabeltxt,titletxt,footnote,power=power,loc=loc1
|
980
|
+
footnote=source+','+str(today)
|
981
|
+
plot_line(dfp,colname,collabel,ylabeltxt,titletxt,footnote,power=power,loc=loc1, \
|
982
|
+
average_value=average_value,facecolor=facecolor)
|
883
983
|
return df
|
884
984
|
|
885
985
|
#绘制同类排名图:近三个月收益率
|
@@ -923,8 +1023,9 @@ def oef_trend_china(fund,start,end='today',trend_type='净值', \
|
|
923
1023
|
dfp1=pd.DataFrame(dfp[colname1])
|
924
1024
|
dfp2=pd.DataFrame(dfp[colname2])
|
925
1025
|
plot_line2(dfp1,ticker1,colname1,label1, \
|
926
|
-
|
927
|
-
|
1026
|
+
dfp2,ticker2,colname2,label2, \
|
1027
|
+
ylabeltxt,titletxt,footnote,power=power,twinx=twinx, \
|
1028
|
+
facecolor=facecolor, \
|
928
1029
|
loc1=loc1,loc2=loc2)
|
929
1030
|
|
930
1031
|
return df
|
@@ -933,78 +1034,71 @@ def oef_trend_china(fund,start,end='today',trend_type='净值', \
|
|
933
1034
|
if __name__=='__main__':
|
934
1035
|
pass
|
935
1036
|
|
936
|
-
def mmf_rank_china(rank=
|
1037
|
+
def mmf_rank_china(indicator="7日年化%",rank=5):
|
937
1038
|
"""
|
938
1039
|
功能:中国货币型基金排名,7日年化收益率%
|
1040
|
+
货币基金的万份收益指的是基金公司每日公布的当日每万份基金单位产生的收益金额,即万份基金单位收益。
|
1041
|
+
注意:万份基金单位收益与万份基金累计收益是不一样的,投资者想要买货币基金应改看基金的万份基金单位收益。
|
1042
|
+
货币基金具体的收益计算方式是:
|
1043
|
+
货币基金收益=已确认金额/10000*当日万分收益。
|
1044
|
+
另外,货币基金每日公布一次收益,周末及节假日,通常在节后首个交易日公布周末或这节假日期间的累计收益。
|
939
1045
|
"""
|
1046
|
+
indicator_list=["万份收益","7日年化%"]
|
1047
|
+
if indicator not in indicator_list:
|
1048
|
+
print(" #Warning(mmf_rank_china): unsupported indicator",indicator,"reset to","7日年化%")
|
1049
|
+
indicator="7日年化%"
|
940
1050
|
|
941
1051
|
print("Searching for money market fund (OEF) information in China ...")
|
942
1052
|
import akshare as ak
|
1053
|
+
import pandas as pd
|
943
1054
|
|
944
1055
|
#获取货币型基金实时信息
|
945
1056
|
df = ak.fund_money_fund_daily_em()
|
946
1057
|
collist=list(df)
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
1058
|
+
nvname1=collist[2]
|
1059
|
+
nvname2=collist[3]
|
1060
|
+
if df[nvname1].eq('').all():
|
1061
|
+
nvname1=collist[5]
|
1062
|
+
nvname2=collist[6]
|
1063
|
+
nvdate=nvname1[:10]
|
1064
|
+
|
951
1065
|
#修改列名
|
952
|
-
df.rename(columns={
|
1066
|
+
df.rename(columns={nvname1:'万份收益',nvname2:'7日年化%'}, inplace=True)
|
953
1067
|
#dfa=df.drop(df[df['7日年化%']==''].index)
|
954
|
-
dfb=df[['基金代码','基金简称','7日年化%','成立日期','基金经理','手续费']]
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
pd.set_option('display.unicode.east_asian_width', True)
|
968
|
-
|
1068
|
+
dfb=df[['基金代码','基金简称','万份收益','7日年化%','成立日期','基金经理','手续费']].copy()
|
1069
|
+
dfb=dfb[dfb['7日年化%'] != '---']
|
1070
|
+
|
1071
|
+
if indicator=='7日年化%':
|
1072
|
+
dfb.sort_values(by=['7日年化%'],ascending=False,inplace=True)
|
1073
|
+
dfprint=dfb[['基金简称','基金代码','7日年化%','万份收益']].copy()
|
1074
|
+
titletxt="中国货币型基金排名:7日年化收益率"
|
1075
|
+
if indicator=='万份收益':
|
1076
|
+
dfb.sort_values(by=['万份收益'],ascending=False,inplace=True)
|
1077
|
+
dfprint=dfb[['基金简称','基金代码','万份收益','7日年化%']].copy()
|
1078
|
+
titletxt="中国货币型基金排名:万份收益金额(元)"
|
1079
|
+
|
1080
|
+
#设置打印
|
969
1081
|
dfprint.dropna(inplace=True)
|
970
1082
|
dfprint.reset_index(drop=True,inplace=True)
|
971
1083
|
dfprint.index=dfprint.index + 1
|
972
1084
|
|
973
|
-
|
1085
|
+
collist=list(dfprint)
|
1086
|
+
dfprint['序号']=dfprint.index
|
1087
|
+
dfprint=dfprint[['序号']+collist]
|
1088
|
+
|
1089
|
+
if rank >0:
|
974
1090
|
dfprint10=dfprint.head(rank)
|
975
1091
|
else:
|
976
1092
|
dfprint10=dfprint.tail(-rank)
|
977
|
-
|
978
|
-
""
|
979
|
-
|
980
|
-
"""
|
981
|
-
"""
|
982
|
-
print('') #在标题与表格之间空一行
|
983
|
-
alignlist=['right','left','center','center','center','right']
|
984
|
-
try:
|
985
|
-
print(dfprint10.to_markdown(index=True,tablefmt='plain',colalign=alignlist))
|
986
|
-
except:
|
987
|
-
#解决汉字编码gbk出错问题
|
988
|
-
print_df=dfprint10.to_markdown(index=True,tablefmt='plain',colalign=alignlist)
|
989
|
-
print_df2=print_df.encode("utf-8",errors="strict")
|
990
|
-
print(print_df2)
|
991
|
-
|
992
|
-
print('') #在表格与脚注之间空一行
|
993
|
-
print(texttranslate("共找到披露收益率信息的货币型基金数量:"),len(dfprint))
|
994
|
-
|
995
|
-
print(texttranslate("收益率日期:"),nvdate,'\b. ',end='')
|
996
|
-
import datetime
|
997
|
-
today = datetime.date.today()
|
998
|
-
print(texttranslate("数据来源:东方财富/天天基金,"),today)
|
999
|
-
"""
|
1000
|
-
footnote1="披露收益率信息的货币型基金数量:"+str(len(dfprint))+'\n'
|
1001
|
-
footnote2="收益率日期:"+str(nvdate)+','
|
1093
|
+
|
1094
|
+
footnote1="披露收益信息的货币型基金数量:"+str(len(dfprint))+','
|
1095
|
+
footnote2=str(nvdate)+'\n'
|
1002
1096
|
import datetime; todaydt = datetime.date.today()
|
1003
|
-
footnote3="数据来源:东方财富/天天基金,"+str(todaydt)
|
1097
|
+
footnote3="数据来源:东方财富/天天基金,"+str(todaydt)+"统计"
|
1004
1098
|
footnote=footnote1+footnote2+footnote3
|
1005
1099
|
|
1006
1100
|
df_display_CSS(dfprint10,titletxt=titletxt,footnote=footnote,facecolor='papayawhip',decimals=4, \
|
1007
|
-
first_col_align='
|
1101
|
+
first_col_align='center',second_col_align='left', \
|
1008
1102
|
last_col_align='right',other_col_align='right', \
|
1009
1103
|
titile_font_size='16px',heading_font_size='15px', \
|
1010
1104
|
data_font_size='15px')
|
@@ -1021,34 +1115,38 @@ if __name__=='__main__':
|
|
1021
1115
|
todate='2020-10-16'
|
1022
1116
|
power=0
|
1023
1117
|
|
1024
|
-
def mmf_trend_china(
|
1118
|
+
def mmf_trend_china(ticker,start,end='today',indicator='7日年化%',power=0, \
|
1119
|
+
average_value=True,facecolor='whitesmoke'):
|
1025
1120
|
"""
|
1026
1121
|
功能:货币型基金业绩趋势,7日年化收益率
|
1027
1122
|
"""
|
1123
|
+
fund=ticker
|
1124
|
+
|
1028
1125
|
fromdate,todate=start_end_preprocess(start,end)
|
1029
1126
|
#检查日期
|
1030
1127
|
result,start,end=check_period(fromdate,todate)
|
1031
1128
|
if not result:
|
1032
1129
|
print(" #Error(mmf_trend_china): invalid date period:",fromdate,todate)
|
1033
1130
|
return None
|
1034
|
-
import datetime
|
1131
|
+
import datetime; todaydt = datetime.date.today()
|
1035
1132
|
startdate=datetime.datetime.strftime(start,"%Y-%m-%d")
|
1036
1133
|
enddate=str(datetime.datetime.strftime(end,"%Y-%m-%d"))
|
1037
1134
|
|
1038
1135
|
print("Searching for money market fund (MMF) trend info in China ...")
|
1039
1136
|
import akshare as ak
|
1137
|
+
import pandas as pd
|
1040
1138
|
|
1041
1139
|
#基金历史数据
|
1042
|
-
import datetime; today = datetime.date.today()
|
1043
1140
|
source=texttranslate("数据来源:东方财富/天天基金")
|
1044
1141
|
|
1045
1142
|
#绘制收益率单线图
|
1046
1143
|
fund1=fund[:6]
|
1047
1144
|
df = ak.fund_money_fund_info_em(fund1)
|
1048
|
-
df.sort_values(by=['净值日期'],ascending=True,inplace=True)
|
1049
1145
|
df['7日年化%']=df['7日年化收益率'].astype("float")
|
1146
|
+
df['万份收益']=df['每万份收益'].astype("float")
|
1147
|
+
|
1148
|
+
df.sort_values(by=['净值日期'],ascending=True,inplace=True)
|
1050
1149
|
|
1051
|
-
import pandas as pd
|
1052
1150
|
df['date']=pd.to_datetime(df['净值日期'])
|
1053
1151
|
df.set_index(['date'],inplace=True)
|
1054
1152
|
|
@@ -1058,11 +1156,16 @@ def mmf_trend_china(fund,start,end='today',power=0):
|
|
1058
1156
|
print(" #Error(mmf_trend_china): no info found for",fund,"in the period:",fromdate,todate)
|
1059
1157
|
return
|
1060
1158
|
|
1061
|
-
|
1159
|
+
if indicator=='7日年化%':
|
1160
|
+
colname='7日年化%'; collabel='7日年化%'
|
1161
|
+
else:
|
1162
|
+
colname='万份收益'; collabel="万份收益(元)"
|
1163
|
+
|
1062
1164
|
ylabeltxt=''
|
1063
|
-
titletxt=
|
1064
|
-
footnote=source+', '+str(
|
1065
|
-
plot_line(dfp,colname,collabel,ylabeltxt,titletxt,footnote,power=power
|
1165
|
+
titletxt="货币型基金的收益趋势:"+get_fund_name_china2(fund)+","+collabel
|
1166
|
+
footnote=source+', '+str(todaydt)
|
1167
|
+
plot_line(dfp,colname,collabel,ylabeltxt,titletxt,footnote,power=power, \
|
1168
|
+
average_value=average_value,facecolor=facecolor)
|
1066
1169
|
|
1067
1170
|
return df
|
1068
1171
|
|
@@ -1073,10 +1176,12 @@ if __name__=='__main__':
|
|
1073
1176
|
fund_type='增长率'
|
1074
1177
|
rank=10
|
1075
1178
|
|
1076
|
-
def etf_rank_china(
|
1179
|
+
def etf_rank_china(indicator='单位净值',fund_type='全部类型',rank=5):
|
1077
1180
|
"""
|
1078
1181
|
功能:中国ETF基金排名,单位净值,累计净值,手续费
|
1079
1182
|
"""
|
1183
|
+
info_type=indicator
|
1184
|
+
|
1080
1185
|
typelist=['单位净值','累计净值','市价','增长率']
|
1081
1186
|
if info_type not in typelist:
|
1082
1187
|
print(" #Error(etf_rank_china): unsupported info type",info_type)
|
@@ -1106,7 +1211,7 @@ def etf_rank_china(info_type='单位净值',fund_type='全部类型',rank=10):
|
|
1106
1211
|
|
1107
1212
|
#修改列名
|
1108
1213
|
df3=df2.rename(columns={nvname1:'单位净值',nvname2:'累计净值'})
|
1109
|
-
df=df3[['基金简称','基金代码','类型','单位净值','累计净值','增长率','市价']]
|
1214
|
+
df=df3[['基金简称','基金代码','类型','单位净值','累计净值','增长率','市价']].copy()
|
1110
1215
|
|
1111
1216
|
# 过滤idx行
|
1112
1217
|
df=df[df.index != 'idx']
|
@@ -1136,7 +1241,7 @@ def etf_rank_china(info_type='单位净值',fund_type='全部类型',rank=10):
|
|
1136
1241
|
df=df.replace('---',0)
|
1137
1242
|
df['单位净值']=df['单位净值'].astype(float)
|
1138
1243
|
df.sort_values(by=['单位净值'],ascending=False,inplace=True)
|
1139
|
-
dfprint=df[['基金简称','基金代码','类型','单位净值','市价']]
|
1244
|
+
dfprint=df[['基金简称','基金代码','类型','单位净值','市价']].copy()
|
1140
1245
|
#print(texttranslate("\n===== 中国ETF基金排名:单位净值 ====="))
|
1141
1246
|
titletxt="中国ETF基金排名:单位净值"
|
1142
1247
|
dfprint=dfprint[dfprint['单位净值'] != 0]
|
@@ -1145,7 +1250,7 @@ def etf_rank_china(info_type='单位净值',fund_type='全部类型',rank=10):
|
|
1145
1250
|
df=df.replace('---',0)
|
1146
1251
|
df['累计净值']=df['累计净值'].astype(float)
|
1147
1252
|
df.sort_values(by=['累计净值'],ascending=False,inplace=True)
|
1148
|
-
dfprint=df[['基金简称','基金代码','类型','累计净值','单位净值']]
|
1253
|
+
dfprint=df[['基金简称','基金代码','类型','累计净值','单位净值']].copy()
|
1149
1254
|
#print(texttranslate("\n===== 中国ETF基金排名:累计净值 ====="))
|
1150
1255
|
titletxt="中国ETF基金排名:累计净值"
|
1151
1256
|
dfprint=dfprint[dfprint['累计净值'] != 0]
|
@@ -1154,7 +1259,7 @@ def etf_rank_china(info_type='单位净值',fund_type='全部类型',rank=10):
|
|
1154
1259
|
df=df.replace('---',0)
|
1155
1260
|
df['市价']=df['市价'].astype(float)
|
1156
1261
|
df.sort_values(by=['市价'],ascending=False,inplace=True)
|
1157
|
-
dfprint=df[['基金简称','基金代码','类型','市价','单位净值']]
|
1262
|
+
dfprint=df[['基金简称','基金代码','类型','市价','单位净值']].copy()
|
1158
1263
|
#print(texttranslate("\n===== 中国ETF基金排名:市价 ====="))
|
1159
1264
|
titletxt="中国ETF基金排名:市价"
|
1160
1265
|
dfprint=dfprint[dfprint['市价'] != 0]
|
@@ -1162,7 +1267,7 @@ def etf_rank_china(info_type='单位净值',fund_type='全部类型',rank=10):
|
|
1162
1267
|
if info_type == '增长率':
|
1163
1268
|
df['增长率']=df['增长率'].astype(str)
|
1164
1269
|
df.sort_values(by=['增长率'],ascending=False,inplace=True)
|
1165
|
-
dfprint=df[['基金简称','基金代码','类型','增长率','市价','单位净值']]
|
1270
|
+
dfprint=df[['基金简称','基金代码','类型','增长率','市价','单位净值']].copy()
|
1166
1271
|
#print(texttranslate("\n===== 中国ETF基金排名:增长率 ====="))
|
1167
1272
|
titletxt="中国ETF基金排名:增长率"
|
1168
1273
|
dfprint=dfprint[dfprint['增长率'] != 0]
|
@@ -1179,6 +1284,10 @@ def etf_rank_china(info_type='单位净值',fund_type='全部类型',rank=10):
|
|
1179
1284
|
dfprint.reset_index(drop=True,inplace=True)
|
1180
1285
|
dfprint.index=dfprint.index + 1
|
1181
1286
|
|
1287
|
+
collist=list(dfprint)
|
1288
|
+
dfprint['序号']=dfprint.index
|
1289
|
+
dfprint=dfprint[['序号']+collist]
|
1290
|
+
|
1182
1291
|
if rank >=0:
|
1183
1292
|
dfprint10=dfprint.head(rank)
|
1184
1293
|
else:
|
@@ -1209,13 +1318,13 @@ def etf_rank_china(info_type='单位净值',fund_type='全部类型',rank=10):
|
|
1209
1318
|
"""
|
1210
1319
|
footnote1="披露净值信息的ETF基金数量:"+str(len(dfprint))+','
|
1211
1320
|
footnote2="基金类型:"+str(fund_type)+'\n'
|
1212
|
-
footnote3="
|
1321
|
+
footnote3="披露日期:"+str(nvdate)+','
|
1213
1322
|
import datetime; todaydt = datetime.date.today()
|
1214
1323
|
footnote4="数据来源:东方财富/天天基金,"+str(todaydt)
|
1215
1324
|
footnote=footnote1+footnote2+footnote3+footnote4
|
1216
1325
|
|
1217
1326
|
df_display_CSS(dfprint10,titletxt=titletxt,footnote=footnote,facecolor='papayawhip',decimals=3, \
|
1218
|
-
first_col_align='
|
1327
|
+
first_col_align='center',second_col_align='left', \
|
1219
1328
|
last_col_align='right',other_col_align='right', \
|
1220
1329
|
titile_font_size='16px',heading_font_size='15px', \
|
1221
1330
|
data_font_size='15px')
|
@@ -1233,33 +1342,38 @@ if __name__=='__main__':
|
|
1233
1342
|
fromdate='2020-1-1'
|
1234
1343
|
todate='2020-10-16'
|
1235
1344
|
|
1236
|
-
def etf_trend_china(
|
1345
|
+
def etf_trend_china(ticker,start,end='today',indicator='净值',power=0, \
|
1346
|
+
average_value=True,facecolor='whitesmoke', \
|
1347
|
+
loc1='best',loc2='best',twinx=False,graph=True):
|
1237
1348
|
"""
|
1238
1349
|
功能:ETF基金业绩趋势,单位净值,累计净值
|
1239
1350
|
"""
|
1351
|
+
fund=ticker
|
1240
1352
|
fromdate,todate=start_end_preprocess(start,end='today')
|
1241
1353
|
|
1354
|
+
indicator_list=['净值','单位净值','累计净值']
|
1355
|
+
if indicator not in indicator_list:
|
1356
|
+
indicator='净值'
|
1357
|
+
|
1242
1358
|
#检查日期
|
1243
1359
|
result,start,end=check_period(fromdate,todate)
|
1244
1360
|
if not result:
|
1245
1361
|
print(" #Error(oef_trend_china): invalid date period:",fromdate,todate)
|
1246
1362
|
return None
|
1247
1363
|
#转换日期格式
|
1248
|
-
import datetime
|
1364
|
+
import datetime; todaydt = datetime.date.today()
|
1249
1365
|
startdate=str(datetime.datetime.strftime(start,"%Y-%m-%d"))
|
1250
1366
|
enddate=str(datetime.datetime.strftime(end,"%Y-%m-%d"))
|
1251
1367
|
|
1252
1368
|
print("Searching for exchange traded fund (ETF) trend info in China ...")
|
1253
1369
|
import akshare as ak
|
1370
|
+
import pandas as pd
|
1254
1371
|
|
1255
|
-
import datetime; today = datetime.date.today()
|
1256
1372
|
source=texttranslate("数据来源:东方财富/天天基金")
|
1257
|
-
|
1258
1373
|
|
1259
1374
|
#获取基金数据
|
1260
1375
|
fund1=fund[:6]
|
1261
1376
|
df = etf_hist_df = ak.fund_etf_fund_info_em(fund1)
|
1262
|
-
import pandas as pd
|
1263
1377
|
df['date']=pd.to_datetime(df['净值日期'])
|
1264
1378
|
df.set_index(['date'],inplace=True)
|
1265
1379
|
df['单位净值']=df['单位净值'].astype("float")
|
@@ -1276,14 +1390,25 @@ def etf_trend_china(fund,start,end='today',loc1='best',loc2='best',twinx=False,g
|
|
1276
1390
|
if graph:
|
1277
1391
|
ticker1=fund1; colname1='单位净值';label1=texttranslate('单位净值')
|
1278
1392
|
ticker2=fund1; colname2='累计净值';label2=texttranslate('累计净值')
|
1279
|
-
ylabeltxt=texttranslate('人民币元')
|
1280
1393
|
titletxt=texttranslate("ETF基金的净值趋势:")+get_fund_name_china2(fund)
|
1281
|
-
footnote=source+', '+str(
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1394
|
+
footnote=source+', '+str(todaydt)
|
1395
|
+
|
1396
|
+
if indicator=='净值':
|
1397
|
+
ylabeltxt=texttranslate('净值(元)')
|
1398
|
+
plot_line2(dfp,ticker1,colname1,label1, \
|
1399
|
+
dfp,ticker2,colname2,label2, \
|
1400
|
+
ylabeltxt,titletxt,footnote, twinx=twinx, \
|
1401
|
+
facecolor=facecolor,loc1=loc1,loc2=loc2)
|
1402
|
+
|
1403
|
+
if indicator=='单位净值':
|
1404
|
+
ylabeltxt=texttranslate('单位净值(元)')
|
1405
|
+
plot_line(dfp,colname1,label1,ylabeltxt,titletxt,footnote,power=power,loc=loc1, \
|
1406
|
+
average_value=average_value,facecolor=facecolor)
|
1407
|
+
|
1408
|
+
if indicator=='累计净值':
|
1409
|
+
ylabeltxt=texttranslate('累计净值(元)')
|
1410
|
+
plot_line(dfp,colname2,label2,ylabeltxt,titletxt,footnote,power=power,loc=loc1, \
|
1411
|
+
average_value=average_value,facecolor=facecolor)
|
1287
1412
|
|
1288
1413
|
return dfp
|
1289
1414
|
|
@@ -1292,12 +1417,12 @@ if __name__=='__main__':
|
|
1292
1417
|
|
1293
1418
|
#==============================================================================
|
1294
1419
|
|
1295
|
-
def fund_summary_china():
|
1420
|
+
def fund_summary_china(rank=10):
|
1296
1421
|
"""
|
1297
1422
|
功能:中国基金投资机构概况
|
1298
1423
|
爬虫来源地址:https://zhuanlan.zhihu.com/p/97487003
|
1299
1424
|
"""
|
1300
|
-
print("Searching for fund
|
1425
|
+
print("Searching for investment fund institutions in China ...")
|
1301
1426
|
import akshare as ak
|
1302
1427
|
|
1303
1428
|
#会员机构综合查询:
|
@@ -1309,7 +1434,7 @@ def fund_summary_china():
|
|
1309
1434
|
try:
|
1310
1435
|
amac_df = ak.amac_member_info()
|
1311
1436
|
except:
|
1312
|
-
print(" #Error(): data source tentatively inaccessible, try later")
|
1437
|
+
print(" #Error(fund_summary_china): data source tentatively inaccessible, try later")
|
1313
1438
|
return None
|
1314
1439
|
|
1315
1440
|
"""
|
@@ -1318,114 +1443,50 @@ def fund_summary_china():
|
|
1318
1443
|
'证券公司私募基金子公司','证券公司资管子公司','境外机构']
|
1319
1444
|
"""
|
1320
1445
|
typelist=list(set(list(amac_df["机构类型"])))
|
1321
|
-
"""
|
1322
|
-
maxlen=0
|
1323
|
-
for t in typelist:
|
1324
|
-
#tlen=strlen(t)
|
1325
|
-
tlen=hzlen(t)
|
1326
|
-
if tlen > maxlen: maxlen=tlen
|
1327
|
-
maxlen=maxlen+1
|
1328
|
-
"""
|
1329
1446
|
|
1330
1447
|
import pandas as pd
|
1331
|
-
|
1332
|
-
|
1333
|
-
pd.
|
1334
|
-
|
1335
|
-
"""
|
1336
|
-
print(texttranslate("\n===== 中国基金投资机构概况 ====="))
|
1337
|
-
print(texttranslate("机构(会员)数量:"),end='')
|
1338
|
-
num=len(list(set(list(amac_df["机构(会员)名称"]))))
|
1339
|
-
print("{:,}".format(num))
|
1340
|
-
|
1341
|
-
print(texttranslate("其中包括:"))
|
1342
|
-
"""
|
1343
|
-
titletxt="中国基金投资机构概况"
|
1344
|
-
num=len(list(set(list(amac_df["机构(会员)名称"]))))
|
1345
|
-
footnote1="机构(会员)数量:"+str(num)
|
1346
|
-
|
1347
|
-
amac_sum_df=pd.DataFrame(columns=['机构类型','数量','占比%'])
|
1448
|
+
titletxt="中国基金机构类型与分布(前"+str(rank)+"名)"
|
1449
|
+
|
1450
|
+
amac_sum_df=pd.DataFrame(columns=['机构类型','机构数量','数量占比%'])
|
1451
|
+
totalnum=0
|
1348
1452
|
for t in typelist:
|
1349
1453
|
df_sub=amac_df[amac_df['机构类型']==t]
|
1350
1454
|
n=len(list(set(list(df_sub['机构(会员)名称']))))
|
1351
|
-
|
1455
|
+
if n==0: continue
|
1456
|
+
totalnum=totalnum+n
|
1352
1457
|
|
1353
|
-
s=pd.Series({'机构类型':t,'
|
1458
|
+
s=pd.Series({'机构类型':t,'机构数量':n})
|
1354
1459
|
try:
|
1355
1460
|
amac_sum_df=amac_sum_df.append(s,ignore_index=True)
|
1356
1461
|
except:
|
1357
1462
|
amac_sum_df=amac_sum_df._append(s,ignore_index=True)
|
1358
|
-
"""
|
1359
|
-
tlen=hzlen(t)
|
1360
|
-
prefix=' '*4+t+'.'*(maxlen-tlen)+':'
|
1361
|
-
print(prefix,"{:,}".format(n),"\b,",round(n/num*100,2),'\b%')
|
1362
|
-
"""
|
1363
|
-
#print('{t:<{len}}\t'.format(t=t,len=maxlen-len(t.encode('GBK'))+len(t)),"{:,}".format(n),"\b,",round(n/num*100,2),'\b%')
|
1364
|
-
#print('{t:<{len}}\t'.format(t=t,len=maxlen-len(t.encode('GBK'))+len(t)),str(n).rjust(6,' '),"\t",(str(round(n/num*100,2))+'%').rjust(6,' '))
|
1365
1463
|
|
1366
|
-
amac_sum_df
|
1464
|
+
amac_sum_df['数量占比%']=amac_sum_df['机构数量'].apply(lambda x: round(x/totalnum*100,2))
|
1465
|
+
|
1466
|
+
amac_sum_df.sort_values(by=['机构数量'],ascending=False,inplace=True)
|
1367
1467
|
amac_sum_df.reset_index(drop=True,inplace=True)
|
1368
|
-
amac_sum_df.index=amac_sum_df.index + 1
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
""
|
1377
|
-
|
1378
|
-
|
1379
|
-
print(amac_sum_df.head(10).to_markdown(index=True,tablefmt='plain',colalign=alignlist))
|
1380
|
-
except:
|
1381
|
-
#解决汉字编码gbk出错问题
|
1382
|
-
print_df=amac_sum_df.head(10).to_markdown(index=True,tablefmt='plain',colalign=alignlist)
|
1383
|
-
print_df2=print_df.encode("utf-8",errors="strict")
|
1384
|
-
print(print_df2)
|
1468
|
+
amac_sum_df.index=amac_sum_df.index + 1
|
1469
|
+
|
1470
|
+
collist=list(amac_sum_df)
|
1471
|
+
amac_sum_df['序号']=amac_sum_df.index
|
1472
|
+
amac_sum_df=amac_sum_df[['序号']+collist]
|
1473
|
+
|
1474
|
+
df10=amac_sum_df.head(rank)
|
1475
|
+
|
1476
|
+
footnote1="共有"+str(len(typelist))+'个类型,'
|
1477
|
+
footnote2=str(totalnum)+'家机构;'
|
1478
|
+
footnote3="表中类型数量占比"+str(round(df10['机构数量'].sum()/totalnum*100,2))+'%\n'
|
1385
1479
|
|
1386
|
-
import datetime; today = datetime.date.today()
|
1387
|
-
source=texttranslate("\n数据来源:中国证券投资基金业协会")
|
1388
|
-
footnote=source+', '+str(today)
|
1389
|
-
print(footnote)
|
1390
|
-
"""
|
1391
1480
|
import datetime; todaydt = datetime.date.today()
|
1392
|
-
|
1393
|
-
footnote=footnote1+
|
1394
|
-
df10=amac_sum_df.head(10)
|
1481
|
+
footnote9="数据来源:中国证券投资基金业协会,"+str(todaydt)
|
1482
|
+
footnote=footnote1+footnote2+footnote3+footnote9
|
1395
1483
|
|
1396
1484
|
df_display_CSS(df10,titletxt=titletxt,footnote=footnote,facecolor='papayawhip',decimals=2, \
|
1397
|
-
first_col_align='
|
1485
|
+
first_col_align='center',second_col_align='left', \
|
1398
1486
|
last_col_align='right',other_col_align='right', \
|
1399
1487
|
titile_font_size='16px',heading_font_size='15px', \
|
1400
1488
|
data_font_size='15px')
|
1401
1489
|
|
1402
|
-
"""
|
1403
|
-
print(texttranslate("\n===== 中国基金投资机构会员代表概况 ====="))
|
1404
|
-
print(texttranslate("会员代表人数:"),end='')
|
1405
|
-
num=len(list(set(list(amac_df["会员代表"]))))
|
1406
|
-
print("{:,}".format(num))
|
1407
|
-
|
1408
|
-
print(texttranslate("其中工作在:"))
|
1409
|
-
amac_mbr_df=pd.DataFrame(columns=['机构类型','数量','占比%'])
|
1410
|
-
for t in typelist:
|
1411
|
-
df_sub=amac_df[amac_df['机构类型']==t]
|
1412
|
-
n=len(list(set(list(df_sub['会员代表']))))
|
1413
|
-
pct=round(n/num*100,2)
|
1414
|
-
|
1415
|
-
s=pd.Series({'机构类型':t,'数量':n,'占比%':pct})
|
1416
|
-
try:
|
1417
|
-
amac_mbr_df=amac_sum_df.append(s,ignore_index=True)
|
1418
|
-
except:
|
1419
|
-
amac_mbr_df=amac_mbr_df._append(s,ignore_index=True)
|
1420
|
-
|
1421
|
-
amac_mbr_df.sort_values(by=['数量'],ascending=False,inplace=True)
|
1422
|
-
amac_mbr_df.reset_index(drop=True,inplace=True)
|
1423
|
-
amac_mbr_df.index=amac_mbr_df.index + 1
|
1424
|
-
|
1425
|
-
pandas2prettytable(amac_mbr_df.head(10),titletxt='',firstColSpecial=True,leftColAlign='l',otherColAlign='c',tabborder=False)
|
1426
|
-
print(footnote)
|
1427
|
-
"""
|
1428
|
-
|
1429
1490
|
return amac_df
|
1430
1491
|
|
1431
1492
|
|
@@ -1789,7 +1850,7 @@ def pef_product_china(rank=20,facecolor='papayawhip',DEBUG=False):
|
|
1789
1850
|
dfprint=dfprint[['序号']+collist]
|
1790
1851
|
|
1791
1852
|
pctsum=round(subttl10['数量占比‰'].sum(),2)
|
1792
|
-
footnote1="找到产品"+str("{:,}".format(totalnum))+"个,上述产品合计占比"+str(pctsum)+'
|
1853
|
+
footnote1="找到产品"+str("{:,}".format(totalnum))+"个,上述产品合计占比"+str(pctsum)+'‰'+'\n'
|
1793
1854
|
footnote=footnote1+footnote9
|
1794
1855
|
|
1795
1856
|
df_display_CSS(dfprint,titletxt=titletxt,footnote=footnote,facecolor=facecolor,decimals=2, \
|
@@ -17,7 +17,7 @@ siat/capm_beta.py,sha256=cxXdRVBQBllhbfz1LeTJAIWvyRYhW54nhtNUXv4HwS0,29063
|
|
17
17
|
siat/capm_beta2.py,sha256=UOI4sCz3ld7yezlARqPHvgHzfduDiGeRqNa82dDTCZ8,25849
|
18
18
|
siat/capm_beta_test.py,sha256=ImR0c5mc4hIl714XmHztdl7qg8v1E2lycKyiqnFj6qs,1745
|
19
19
|
siat/cmat_commons.py,sha256=Nj9Kf0alywaztVoMVeVVL_EZk5jRERJy8R8kBw88_Tg,38116
|
20
|
-
siat/common.py,sha256=
|
20
|
+
siat/common.py,sha256=kGsyiuYJX-Y8VNb2mmspSp7rNc5r8eexxEt9JiKmwHM,143250
|
21
21
|
siat/compare_cross.py,sha256=3iP9TH2h3w27F2ARZc7FjKcErYCzWRc-TPiymOyoVtw,24171
|
22
22
|
siat/compare_cross_test.py,sha256=xra5XYmQGEtfIZL2h-GssdH2hLdFIhG3eoCrkDrL3gY,3473
|
23
23
|
siat/concepts_iwencai.py,sha256=m1YEDtECRT6FqtzlKm91pt2I9d3Z_XoP59BtWdRdu8I,3061
|
@@ -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=_obFT-JBjhvzX71HVyqafwFXKE3YCIMpVhsKz_Wir-4,94035
|
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
|
@@ -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.1.
|
136
|
-
siat-3.1.
|
137
|
-
siat-3.1.
|
138
|
-
siat-3.1.
|
135
|
+
siat-3.1.3.dist-info/METADATA,sha256=h-Ogl_X_X9zSfrdOjdfY0uOX4hRUPUTlOHnKoMkzS9g,1447
|
136
|
+
siat-3.1.3.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
137
|
+
siat-3.1.3.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
|
138
|
+
siat-3.1.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|