siat 3.1.11__py3-none-any.whl → 3.1.13__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
@@ -1480,84 +1480,6 @@ if __name__=='__main__':
1480
1480
  rfd=rf_daily_china('2021-11-1','2021-11-28',rate_period='1Y',rate_type='treasury')
1481
1481
 
1482
1482
  #==============================================================================
1483
- if __name__=='__main__':
1484
- _,_,tickerlist,sharelist=decompose_portfolio(portfolio)
1485
- leading_blanks=2
1486
-
1487
- def print_tickerlist_sharelist(tickerlist,sharelist,leading_blanks=2,ticker_type='auto'):
1488
- """
1489
- 功能:纵向打印投资组合的成分股和持股比例
1490
- 输入:
1491
- tickerlist:成分股列表
1492
- sharelist:持股份额列表
1493
- leading_blanks:打印前导空格数
1494
- """
1495
- #检查成分股与持仓比例个数是否一致
1496
- if not (len(tickerlist) == len(sharelist)):
1497
- print(" #Error(): numbers of tickers and shares are not same")
1498
- return
1499
-
1500
- #计算最长的代码长度,便于对齐
1501
- max_ticker_len=0
1502
- for t in tickerlist:
1503
- tlen=len(t)
1504
- #print(t,tlen)
1505
- if tlen > max_ticker_len: #if的执行语句放在这里可能有bug
1506
- max_ticker_len=tlen
1507
-
1508
- # 将原投资组合的权重存储为numpy数组类型,为了合成投资组合计算方便
1509
- import numpy as np
1510
- sharelist_array = np.array(sharelist)
1511
- total_shares=sharelist_array.sum()
1512
- weights=sharelist_array/total_shares
1513
-
1514
- #预处理ticker_type
1515
- ticker_type_list=ticker_type_preprocess_mticker_mixed(tickerlist,ticker_type)
1516
-
1517
- import pandas as pd
1518
- df=pd.DataFrame(columns=['证券代码','证券名称','持仓比例'])
1519
- for t in tickerlist:
1520
- pos=tickerlist.index(t)
1521
- tt=ticker_type_list[pos]
1522
- tname=ticker_name(t,tt)
1523
- tweight=weights[pos]
1524
-
1525
- row=pd.Series({'证券代码':t,'证券名称':tname,'持仓比例':tweight})
1526
- try:
1527
- df=df.append(row,ignore_index=True)
1528
- except:
1529
- df=df._append(row,ignore_index=True)
1530
-
1531
- #按持仓比例降序
1532
- df.sort_values(by='持仓比例',ascending=False,inplace=True)
1533
- """
1534
- #打印对齐
1535
- pd.set_option('display.max_columns', 1000)
1536
- pd.set_option('display.width', 1000)
1537
- pd.set_option('display.max_colwidth', 1000)
1538
- pd.set_option('display.unicode.ambiguous_as_wide', True)
1539
- pd.set_option('display.unicode.east_asian_width', True)
1540
-
1541
- print(df.to_string(index=False,header=False))
1542
- """
1543
-
1544
- #打印
1545
- df.reset_index(inplace=True) #必须,不然排序不起作用
1546
- for i in range(len(df)):
1547
- rows = df.loc[[i]]
1548
- tcode=rows['证券代码'].values[0]
1549
- tname=rows['证券名称'].values[0]
1550
- tweight=rows['持仓比例'].values[0]
1551
- print(' '*leading_blanks,tcode+' '*(max_ticker_len-len(tcode))+':',tname,'\b,',round(tweight,4))
1552
- """
1553
- values = rows.to_string(index=False,header=False)
1554
- """
1555
-
1556
- return
1557
-
1558
- if __name__=='__main__':
1559
- print_tickerlist_sharelist(tickerlist,sharelist,leading_blanks=2)
1560
- #==============================================================================
1561
1483
  if __name__=='__main__':
1562
1484
  current=0
1563
1485
  total=9
Binary file
siat/fund_china.pickle CHANGED
Binary file
siat/fund_china.py CHANGED
@@ -20,18 +20,23 @@ from siat.translate import *
20
20
  from siat.grafix import *
21
21
  from siat.bond_base import *
22
22
  #==============================================================================
23
- def compare_fund_holding_china(ticker,quarters,rank=10):
23
+ def compare_fund_holding_china(ticker,quarters,rank=10,font_size='14px'):
24
24
  """
25
25
  功能:套壳函数fund_stock_holding_compare_china
26
26
  """
27
27
  if len(quarters) < 2:
28
28
  print(" #Warning(compare_fund_holding_china): need 2 quarters to compare at",quarters)
29
29
  return None
30
+ """
30
31
  if quarters[0] >= quarters[1]:
31
32
  print(" #Warning(compare_fund_holding_china):",quarters[0],"is supposed to be earlier than",quarters[1])
32
33
  return None
33
-
34
- df=fund_stock_holding_compare_china(fund=ticker,quarter1=quarters[0],quarter2=quarters[1],rank=rank)
34
+ """
35
+ #保证较早的季度排在前面
36
+ quarters.sort()
37
+
38
+ df=fund_stock_holding_compare_china(fund=ticker,quarter1=quarters[0],quarter2=quarters[1], \
39
+ rank=rank,font_size=font_size)
35
40
 
36
41
  return df
37
42
 
@@ -43,13 +48,18 @@ if __name__=='__main__':
43
48
  df=fund_stock_holding_compare_china(fund,quarter1,quarter2,rank=10)
44
49
 
45
50
  #比较两个季度之间的基金持仓变化
46
- def fund_stock_holding_compare_china(fund,quarter1,quarter2,rank=10):
51
+ def fund_stock_holding_compare_china(fund,quarter1,quarter2,rank=10, \
52
+ font_size='14px'):
47
53
  """
48
54
  功能:基金fund在两个季度quarter1和quarter2的持仓股票对比(股数和金额),前rank名股票
49
55
  参数:
50
56
  fund,str,基金代码;
51
57
  quarter1,str,靠前的季度, 格式为 'YYYYQ1',例如: '2021Q2';
52
58
  quarter2,str,靠后的季度, 格式为 'YYYYQ1',例如: '2021Q2';
59
+
60
+ 注意:监管仅要求基金披露前十大重仓股,因此其持仓比例之和一般小于100%;若大于100%,
61
+ 则为基金以其净资产作为抵押加了杠杆融资,买进更多成份股,导致成份股总价值(基金总资产)超过了基金的净资产。
62
+ 基金总资产 = 基金负债 + 基金净资产
53
63
  """
54
64
  print("Searching fund holding info, which may take time, please wait ...\n")
55
65
 
@@ -112,6 +122,7 @@ def fund_stock_holding_compare_china(fund,quarter1,quarter2,rank=10):
112
122
 
113
123
  df1 = df1[['股票代码', '股票名称','持股数','持仓市值','占净值比例']]
114
124
  df1 = df1.rename(columns={'持股数':s1_share,'持仓市值':s1_value,'占净值比例':s1_ratio})
125
+ num1=len(df1)
115
126
 
116
127
  df2 =data[data['季度']==s2]
117
128
  if len(df2)==0:
@@ -120,6 +131,7 @@ def fund_stock_holding_compare_china(fund,quarter1,quarter2,rank=10):
120
131
 
121
132
  df2 = df2[['股票代码', '股票名称','持股数','持仓市值','占净值比例']]
122
133
  df2 = df2.rename(columns={'持股数':s2_share,'持仓市值':s2_value,'占净值比例':s2_ratio})
134
+ num2=len(df2)
123
135
 
124
136
  df_merge = pd.merge(df1,df2,on=['股票代码','股票名称'],how='outer')
125
137
 
@@ -196,16 +208,17 @@ def fund_stock_holding_compare_china(fund,quarter1,quarter2,rank=10):
196
208
  # 替换空值
197
209
  df.fillna('---')
198
210
  """
199
- print("===== 中国基金持仓股票分析:"+name+','+s1+"对比"+s2,"(按后者持仓比例高低排列,"+order+str(rank)+"名股票) =====\n")
211
+ print("===== 中国基金持仓股票分析:"+name+','+s1+"对比"+s2,"(按后者持仓比例高低排列,"+order+str(rank)+"名重仓股) =====\n")
200
212
  print(df.to_string(index=False))
201
213
  import datetime; today = datetime.date.today()
202
214
  print("\n*** 注:持股数为万股,持仓市值为万元,持仓比例为占基金资产净值比例%,包括A股与非A股")
203
215
  print(" 数据来源:天天基金/东方财富, 期间持仓股票总计"+str(len(df_merge))+"只,",today)
204
216
  """
205
- titletxt="基金持仓转移矩阵:"+name+''+s1+"对比"+s2+"(按后者持仓比例降序排列,"+order+str(rank)+"名成份证券)"
217
+ titletxt="基金持仓转移明细:"+name+'基金,'+s1+"对比"+s2+"(按后者持仓比例降序排列,"+order+str(rank)+"名重仓股)"
206
218
 
207
- footnote1="【注】持仓数为万股,持仓市值为万元,持仓比例为占基金资产净值比例%;"
208
- footnote2="期间内(曾经)持仓证券数合计"+str(len(df_merge))+"只"+'\n'
219
+ footnote1="【注】持仓数单位为万股,持仓市值单位为万元,持仓比例为成份股价值为占基金资产净值%(以最新期间为准列示)\n"
220
+ #footnote2=s1+'/'+s2+"期末持仓证券数"+str(num1)+'/'+str(num2)+"只"+'\n'
221
+ footnote2='监管仅要求披露前十大重仓股,其持仓比例之和一般小于100%;若大于100%则为基金加了杠杆,总资产多于净资产\n'
209
222
  import datetime; todaydt = datetime.date.today()
210
223
  footnote9="数据来源:天天基金/东方财富,"+str(todaydt)+"统计"
211
224
  footnote=footnote1+footnote2+footnote9
@@ -227,21 +240,27 @@ def fund_stock_holding_compare_china(fund,quarter1,quarter2,rank=10):
227
240
  df=df[collist1]
228
241
  """
229
242
  df.replace(0,'---',inplace=True); df.replace('0','---',inplace=True)
243
+
244
+ #确定表格字体大小
245
+ titile_font_size=font_size
246
+ heading_font_size=data_font_size=str(int(font_size.replace('px',''))-2)+'px'
230
247
 
231
248
  df_display_CSS(df,titletxt=titletxt,footnote=footnote,facecolor='papayawhip',decimals=2, \
232
249
  first_col_align='center',second_col_align='left', \
233
250
  last_col_align='right',other_col_align='right', \
234
- titile_font_size='14px',heading_font_size='12px', \
235
- data_font_size='12px')
251
+ titile_font_size=titile_font_size, \
252
+ heading_font_size=heading_font_size, \
253
+ data_font_size=data_font_size)
236
254
 
237
255
  return df_merge
238
256
 
239
257
  #==============================================================================
240
- def fund_holding_china(ticker,rank=10,pastyears=2):
258
+ def fund_holding_china(ticker,rank=10,pastyears=2,reverse=False,font_size='16px'):
241
259
  """
242
260
  功能:套壳函数fund_stock_holding_rank_china
243
261
  """
244
- df,data=fund_stock_holding_rank_china(fund=ticker,rank=rank,year_num=pastyears)
262
+ df,data=fund_stock_holding_rank_china(fund=ticker,rank=rank,year_num=pastyears, \
263
+ reverse=reverse,font_size=font_size)
245
264
 
246
265
  return df,data
247
266
 
@@ -253,8 +272,10 @@ if __name__=='__main__':
253
272
  df=fund_stock_holding_rank_china(fund,year_num=2)
254
273
 
255
274
  # 获取单只基金的十大股票名称信息
256
- def fund_stock_holding_rank_china(fund,rank=10,year_num=2):
275
+ def fund_stock_holding_rank_china(fund,rank=10,year_num=2, \
276
+ reverse=False,font_size='16px'):
257
277
  """
278
+ 基金的成份股持仓转移矩阵
258
279
  比较股票型基金fund近year_num年持仓的前10大股票排名变化
259
280
  """
260
281
  print("Searching fund stock holding info, which takes time, please wait ...\n")
@@ -373,21 +394,27 @@ def fund_stock_holding_rank_china(fund,rank=10,year_num=2):
373
394
  name=get_fund_name_china2(fund)
374
395
 
375
396
  #print("=== 基金持仓股票排行分析:"+name+",按照占净值比例高低排列 ===\n")
376
- titletxt="基金持仓转移详情:"+name+",按照占净值比例降序排列,前"+str(rank)+"名成份证券"
397
+ titletxt="基金持仓转移矩阵:"+name+"基金,按照占净值比例降序排列,前"+str(rank)+"名重仓股"
377
398
  import datetime; todaydt = datetime.date.today()
378
399
  #print("\n*** 注:包括A股与非A股。持股结构:股票简称(占净值比例%,持股数万股),",str(todaydt))
379
400
  footnote="【注】持仓结构:证券简称(占净值比例%,持仓数万股),"+str(todaydt)+"统计"
380
401
 
381
- #最新的日期方前面
382
- collist=list(df)
383
- collist.sort(reverse=True)
384
- df=df[collist]
402
+ if reverse:
403
+ #最新的日期放前面
404
+ collist=list(df)
405
+ collist.sort(reverse=True)
406
+ df=df[collist]
407
+
408
+ #确定表格字体大小
409
+ titile_font_size=font_size
410
+ heading_font_size=data_font_size=str(int(font_size.replace('px',''))-1)+'px'
385
411
 
386
412
  df_display_CSS(df,titletxt=titletxt,footnote=footnote,facecolor='papayawhip',decimals=3, \
387
413
  first_col_align='center',second_col_align='left', \
388
414
  last_col_align='left',other_col_align='left', \
389
- titile_font_size='16px',heading_font_size='15px', \
390
- data_font_size='15px')
415
+ titile_font_size=titile_font_size, \
416
+ heading_font_size=heading_font_size, \
417
+ data_font_size=data_font_size)
391
418
 
392
419
  """
393
420
  alignlist=['center']+['left']*(len(list(df))-1)
@@ -412,7 +439,7 @@ def reits_jsl_china(fund='',rank=10):
412
439
  df1 = ak.reits_info_jsl()
413
440
  df2 = ak.reits_realtime_em()
414
441
  except:
415
- print(" #Error(reits_jsl_china): sorry, data source currently unavailable")
442
+ print(" #Error(reits_jsl_china): sorry, data source has rejected access")
416
443
  return None
417
444
 
418
445
  #合成基金类型信息
@@ -469,7 +496,7 @@ def reits_jsl_china(fund='',rank=10):
469
496
  return dfb
470
497
 
471
498
  #==============================================================================
472
- def reit_rank_china(indicator='最新价',rank=10):
499
+ def reit_rank_china(indicator='最新价',rank=5):
473
500
  """
474
501
  功能:套壳函数reits_list_china
475
502
  """
@@ -484,20 +511,24 @@ if __name__=='__main__':
484
511
 
485
512
  df=reits_list_china(rank=10)
486
513
 
487
- def reits_list_china(indicator='最新价',rank=10):
514
+ def reits_list_china(indicator='最新价',rank=5):
488
515
  """
489
516
  功能:REITs基金信息概述和列表
490
517
  目前能正常工作
491
518
  """
492
519
  import akshare as ak
520
+ import math
493
521
  try:
494
522
  df2 = ak.reits_realtime_em()
495
523
  except:
496
524
  print(" #Error(reits_profile_china): akshare does not work properly now")
497
525
  return None
498
526
  df2.drop('序号', axis=1, inplace=True)
527
+ #使用-999标记空缺值,避免后续处理出错,同时避免与真正的0混淆
528
+ df2.fillna(-999,inplace=True)
529
+ #df2['成交额']=df2['成交额'].apply(lambda x: int(x) if not math.isnan(x) else x)
499
530
  df2['成交额']=df2['成交额'].apply(lambda x: int(x))
500
- df2.fillna("---",inplace=True)
531
+ df2['成交量']=df2['成交量'].apply(lambda x: int(x))
501
532
 
502
533
  df2=df_swap_columns(df2, col1='代码', col2='名称')
503
534
  num=len(df2)
@@ -510,7 +541,12 @@ def reits_list_china(indicator='最新价',rank=10):
510
541
 
511
542
  #df2.indicator_values(by=['昨收'],ascending=False,inplace=True)
512
543
  df2.sort_values(by=[indicator],ascending=False,inplace=True)
544
+ df2.replace(-999,"---",inplace=True)
545
+
513
546
  df2.reset_index(drop=True,inplace=True)
547
+ df2=df2[df2[indicator] != "---"]
548
+ num1=len(df2)
549
+
514
550
  collist=list(df2)
515
551
 
516
552
  for i in ['名称','代码',indicator]:
@@ -553,7 +589,10 @@ def reits_list_china(indicator='最新价',rank=10):
553
589
  """
554
590
  import datetime; todaydt = datetime.date.today()
555
591
  #print("\n*** 数据来源:东方财富, 总计"+str(num)+"只REITs基金,",today)
556
- footnote="数据来源:东方财富,共找到"+str(num)+"只REITs基金,"+str(todaydt)
592
+ if num == num1 or order=='前':
593
+ footnote="数据来源:新浪财经/天天基金,共找到"+str(num)+"只REITs基金,"+str(todaydt)
594
+ else:
595
+ footnote="数据来源:新浪财经/天天基金,共找到"+str(num)+"只REITs基金(其中"+str(num-num1)+"只没有"+indicator+"信息),"+str(todaydt)
557
596
 
558
597
  df_display_CSS(dfb,titletxt=titletxt,footnote=footnote,facecolor='papayawhip',decimals=3, \
559
598
  first_col_align='center',second_col_align='left', \
@@ -663,8 +702,15 @@ if __name__=='__main__':
663
702
 
664
703
  #==============================================================================
665
704
  if __name__=='__main__':
666
- info_type='单位净值'
705
+ indicator='单位净值'
706
+
667
707
  fund_type='股票型'
708
+ fund_type='FOF'
709
+ fund_type='LOF'
710
+ fund_type='FOF-LOF'
711
+
712
+ rank=5
713
+
668
714
 
669
715
  def oef_rank_china(indicator='单位净值',fund_type='全部类型',rank=5):
670
716
  """
@@ -682,7 +728,12 @@ def oef_rank_china(indicator='单位净值',fund_type='全部类型',rank=5):
682
728
  import akshare as ak
683
729
 
684
730
  #获取开放式基金实时信息
685
- df1 = ak.fund_open_fund_daily_em()
731
+ try:
732
+ df1 = ak.fund_open_fund_daily_em()
733
+ except:
734
+ print(" #Error(oef_rank_china): data source tentatively busy or unavailable, try later")
735
+ return None
736
+
686
737
  collist=list(df1)
687
738
  nvname1=collist[2]
688
739
  nvname2=collist[3]
@@ -727,29 +778,49 @@ def oef_rank_china(indicator='单位净值',fund_type='全部类型',rank=5):
727
778
  #过滤基金类型
728
779
  if fund_type != '全部类型':
729
780
  fundtypelist=list(set(list(df['基金类型'])))
781
+ try: fundtypelist.remove('0')
782
+ except: pass
783
+
784
+ fundtypelist=fundtypelist+['LOF','FOF-LOF']
730
785
  """
731
786
  while np.nan in fundtypelist:
732
787
  fundtypelist.remove(np.nan)
733
788
  while 0 in fundtypelist:
734
789
  fundtypelist.remove(0)
735
- """
790
+ """
791
+ #检查基金类型是否存在
736
792
  found=False
737
793
  for ft in fundtypelist:
738
794
  if ft==0: continue
739
795
  if fund_type in ft:
740
796
  found=True
741
797
  break
798
+
799
+ #未找到基金类型
742
800
  if not found:
743
801
  print(" #Error(oef_rank_china): unsupported fund type",fund_type)
744
802
  print(" Supported fund types:",fundtypelist)
745
803
  return None
746
- fund_filter=lambda x: fund_type in x
804
+
747
805
  df.dropna(inplace=True)
806
+ fund_filter=lambda x: fund_type in x
748
807
  df['基金类型s']=df['基金类型'].apply(fund_filter)
749
808
 
750
809
  if fund_type == 'QDII':
751
810
  df['基金类型s']=df.apply(lambda x: False if '不含' in x['基金类型'] else x['基金类型s'],axis=1)
752
811
 
812
+ if fund_type == 'FOF':
813
+ df['基金类型s']=df.apply(lambda x: True if (fund_type in x['基金类型'] or fund_type in x['基金简称']) else x['基金类型s'],axis=1)
814
+ df['基金类型s']=df.apply(lambda x: False if ('LOF' in x['基金类型'] or 'LOF' in x['基金简称']) else x['基金类型s'],axis=1)
815
+
816
+ if fund_type == 'LOF':
817
+ df['基金类型s']=df.apply(lambda x: True if (fund_type in x['基金类型'] or fund_type in x['基金简称']) else x['基金类型s'],axis=1)
818
+ df['基金类型s']=df.apply(lambda x: False if ('FOF' in x['基金类型'] or 'FOF' in x['基金简称']) else x['基金类型s'],axis=1)
819
+
820
+ if fund_type == 'FOF-LOF':
821
+ df['基金类型s']=df.apply(lambda x: True if (fund_type in x['基金类型'] or fund_type in x['基金简称']) else x['基金类型s'],axis=1)
822
+
823
+
753
824
  df=df[df['基金类型s']==True]
754
825
 
755
826
  if info_type == '单位净值':
@@ -801,8 +872,11 @@ def oef_rank_china(indicator='单位净值',fund_type='全部类型',rank=5):
801
872
 
802
873
  if rank >= 0:
803
874
  dfprint10=dfprint.head(rank)
875
+ order="前"
804
876
  else:
805
877
  dfprint10=dfprint.tail(-rank)
878
+ order="后"
879
+ titletxt=titletxt+"("+order+str(abs(rank))+"名,降序排列)"
806
880
  #print(dfprint10.to_string(index=False))
807
881
  """
808
882
  print(dfprint10)
@@ -833,7 +907,8 @@ def oef_rank_china(indicator='单位净值',fund_type='全部类型',rank=5):
833
907
  footnote2="基金类型:"+str(fund_type)+'\n'
834
908
  footnote3="净值日期:"+str(nvdate)+','
835
909
  import datetime; todaydt = datetime.date.today()
836
- footnote4="数据来源:东方财富/天天基金,"+str(todaydt)
910
+ #footnote4="数据来源:东方财富/天天基金,"+str(todaydt)
911
+ footnote4="数据来源:新浪财经/天天基金"
837
912
  footnote=footnote1+footnote2+footnote3+footnote4
838
913
 
839
914
  df_display_CSS(dfprint10,titletxt=titletxt,footnote=footnote,facecolor='papayawhip',decimals=4, \
@@ -1113,7 +1188,8 @@ def oef_trend_china(ticker,start,end='today',indicator='净值', \
1113
1188
 
1114
1189
  #==============================================================================
1115
1190
  if __name__=='__main__':
1116
- pass
1191
+ indicator="万份收益"
1192
+ rank=5
1117
1193
 
1118
1194
  def mmf_rank_china(indicator="7日年化%",rank=5):
1119
1195
  """
@@ -1126,7 +1202,7 @@ def mmf_rank_china(indicator="7日年化%",rank=5):
1126
1202
  """
1127
1203
  indicator_list=["万份收益","7日年化%"]
1128
1204
  if indicator not in indicator_list:
1129
- print(" #Warning(mmf_rank_china): unsupported indicator",indicator,"reset to","7日年化%")
1205
+ print(" #Warning(mmf_rank_china): unsupported indicator",indicator)
1130
1206
  print(" Supported indicators:",indicator_list)
1131
1207
  #indicator="7日年化%"
1132
1208
  return None
@@ -1140,9 +1216,10 @@ def mmf_rank_china(indicator="7日年化%",rank=5):
1140
1216
  collist=list(df)
1141
1217
  nvname1=collist[2]
1142
1218
  nvname2=collist[3]
1143
- if df[nvname1].eq('').all():
1219
+ if df[nvname1].eq('').all() or df[nvname1].eq('---').all():
1144
1220
  nvname1=collist[5]
1145
1221
  nvname2=collist[6]
1222
+
1146
1223
  nvdate=nvname1[:10]
1147
1224
 
1148
1225
  #修改列名
@@ -1158,7 +1235,11 @@ def mmf_rank_china(indicator="7日年化%",rank=5):
1158
1235
  if indicator=='万份收益':
1159
1236
  dfb.sort_values(by=['万份收益'],ascending=False,inplace=True)
1160
1237
  dfprint=dfb[['基金简称','基金代码','万份收益','7日年化%']].copy()
1161
- titletxt="中国货币型基金排名:万份收益金额(元)"
1238
+ titletxt="中国货币型基金排名:万份收益金额(元)"
1239
+
1240
+ if len(dfprint)==0:
1241
+ print(" #Warning(mmf_rank_china): zero records found for",indicator)
1242
+ return None
1162
1243
 
1163
1244
  #设置打印
1164
1245
  dfprint.dropna(inplace=True)
@@ -1171,13 +1252,16 @@ def mmf_rank_china(indicator="7日年化%",rank=5):
1171
1252
 
1172
1253
  if rank >0:
1173
1254
  dfprint10=dfprint.head(rank)
1255
+ order="前"
1174
1256
  else:
1175
1257
  dfprint10=dfprint.tail(-rank)
1258
+ order="后"
1259
+ titletxt=titletxt+"("+order+str(abs(rank))+"名,降序)"
1176
1260
 
1177
- footnote1="披露收益信息的货币型基金数量:"+str(len(dfprint))+','
1261
+ footnote1="披露信息的货币型基金数量:"+str(len(dfprint))+','
1178
1262
  footnote2=str(nvdate)+'\n'
1179
1263
  import datetime; todaydt = datetime.date.today()
1180
- footnote3="数据来源:东方财富/天天基金,"+str(todaydt)+"统计"
1264
+ footnote3="数据来源:新浪财经/天天基金,"+str(todaydt)+"统计"
1181
1265
  footnote=footnote1+footnote2+footnote3
1182
1266
 
1183
1267
  df_display_CSS(dfprint10,titletxt=titletxt,footnote=footnote,facecolor='papayawhip',decimals=4, \
@@ -1319,6 +1403,7 @@ def etf_rank_china(indicator='单位净值',fund_type='全部类型',rank=5):
1319
1403
 
1320
1404
  df=df[df['基金类型s']==True]
1321
1405
 
1406
+
1322
1407
  #df=df.replace('---',0)
1323
1408
  if info_type == '单位净值':
1324
1409
  df=df.replace('---',0)
@@ -1373,8 +1458,12 @@ def etf_rank_china(indicator='单位净值',fund_type='全部类型',rank=5):
1373
1458
 
1374
1459
  if rank >=0:
1375
1460
  dfprint10=dfprint.head(rank)
1461
+ order="前"
1376
1462
  else:
1377
1463
  dfprint10=dfprint.tail(-rank)
1464
+ order="后"
1465
+ titletxt=titletxt+"("+order+str(abs(rank))+"名,降序排列)"
1466
+
1378
1467
  #print(dfprint10.to_string(index=False))
1379
1468
  """
1380
1469
  print(dfprint10)
@@ -1881,12 +1970,12 @@ def pef_product_china(rank=20,facecolor='papayawhip',DEBUG=False):
1881
1970
  titletxt="中国私募基金管理人的产品运营状态"
1882
1971
  typelist=list(set(list(product_df['运行状态'])))
1883
1972
  dfprint=pd.DataFrame(columns=['运营状态','产品数量','数量占比%'])
1884
- totalnum=0
1973
+ #totalnum=0
1885
1974
  for t in typelist:
1886
1975
  df_sub=product_df[product_df['运行状态']==t]
1887
1976
  n=len(list(set(list(df_sub['基金名称']))))
1888
1977
  if n==0: continue
1889
- totalnum=totalnum+n
1978
+ #totalnum=totalnum+n
1890
1979
 
1891
1980
  s=pd.Series({'运营状态':t,'产品数量':n})
1892
1981
  try: