siat 3.10.25__py3-none-any.whl → 3.10.75__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 CHANGED
@@ -1390,7 +1390,7 @@ def oef_trend_china(ticker,start,end='today',indicator='净值', \
1390
1390
  df1['总排名']=df1['总排名'].astype('int64')
1391
1391
  df1.set_index(['date'],inplace=True)
1392
1392
 
1393
- df2 = ak.fund_open_fund_info_em(fund=fund1, indicator="同类排名百分比")
1393
+ df2 = ak.fund_open_fund_info_em(fund1, indicator="同类排名百分比")
1394
1394
  df2.rename(columns={'报告日期':'date','同类型排名-每日近3月收益排名百分比':'同类排名百分比'}, inplace=True)
1395
1395
  df2.set_index(['date'],inplace=True)
1396
1396
 
@@ -1543,7 +1543,7 @@ def mmf_trend_china(ticker,start,end='today',indicator='7日年化%',power=0, \
1543
1543
  startdate=datetime.datetime.strftime(start,"%Y-%m-%d")
1544
1544
  enddate=str(datetime.datetime.strftime(end,"%Y-%m-%d"))
1545
1545
 
1546
- print("Searching for money market fund (MMF) trend info in China ...")
1546
+ print("Searching for money market fund (MMF) info in China ...")
1547
1547
  import akshare as ak
1548
1548
  import pandas as pd
1549
1549
 
@@ -2461,14 +2461,14 @@ def fund_info_china0():
2461
2461
  wmf_df = ak.fund_financial_fund_daily_em()
2462
2462
  #理财型基金-历史数据
2463
2463
  #净值日期,7日年化收益率,申购状态,赎回状态
2464
- wmf_hist_df = ak.fund_financial_fund_info_em(fund="000134")
2464
+ wmf_hist_df = ak.fund_financial_fund_info_em("000134")
2465
2465
 
2466
2466
  ###########分级基金(结构化基金)-实时数据
2467
2467
  #基金代码,基金简称,单位净值,累计净值,市价,折价率,手续费
2468
2468
  gsf_df = ak.fund_graded_fund_daily_em()
2469
2469
  #分级基金-历史数据
2470
2470
  #净值日期,7日年化收益率,申购状态,赎回状态
2471
- gsf_hist_df = ak.fund_graded_fund_info_em(fund="150232")
2471
+ gsf_hist_df = ak.fund_graded_fund_info_em("150232")
2472
2472
 
2473
2473
  ###抓取沪深股市所有指数关联的公募基金列表(含ETF、增强、分级等)
2474
2474
  #代码来源:https://blog.csdn.net/leeleilei/article/details/106124894
@@ -2584,7 +2584,7 @@ def fund_info_china(fund):
2584
2584
 
2585
2585
  # 基金评级
2586
2586
  df6=pd.DataFrame()
2587
- titletxt6="***** 基金概况与评级"
2587
+ titletxt6="基金概况与评级"
2588
2588
  footnote6="注:评级机构为上海证券、招商证券和济安金信,数字表示星星个数,在同类基金中通常越高越好"
2589
2589
  try:
2590
2590
  dft6 = ak.fund_rating_all()
@@ -2594,13 +2594,17 @@ def fund_info_china(fund):
2594
2594
 
2595
2595
  if len(dft6t) >= 1:
2596
2596
  df6=dft6t
2597
- printInMarkdown(df6,titletxt=titletxt6,footnote=footnote6)
2597
+ #printInMarkdown(df6,titletxt=titletxt6,footnote=footnote6)
2598
+ df_display_CSS(df6,titletxt=titletxt6,footnote=footnote6,facecolor='papayawhip', \
2599
+ first_col_align='left',second_col_align='left', \
2600
+ last_col_align='center',other_col_align='center')
2601
+
2598
2602
  except:
2599
2603
  pass
2600
2604
 
2601
2605
  # 指数型基金信息
2602
2606
  df2=pd.DataFrame()
2603
- titletxt2="***** 指数型基金的相关信息"
2607
+ titletxt2="指数型基金的相关信息"
2604
2608
  footnote2="注:单位净值元,日/今年来/今年来的增长率及手续费为百分比"
2605
2609
  try:
2606
2610
  dft2 = ak.fund_info_index_em(symbol="全部", indicator="全部")
@@ -2608,13 +2612,17 @@ def fund_info_china(fund):
2608
2612
  dft2t=dft2[dft2['基金代码']==fund1]
2609
2613
 
2610
2614
  if len(dft2t) >= 1:
2611
- df2=dft2t[['基金代码','单位净值','日期','日增长率','今年来','今年来','手续费']]
2612
- printInMarkdown(df2,titletxt=titletxt2,footnote=footnote2)
2615
+ df2=dft2t[['基金代码','单位净值','日期','日增长率','今年来','手续费']]
2616
+ #printInMarkdown(df2,titletxt=titletxt2,footnote=footnote2)
2617
+ df_display_CSS(df2,titletxt=titletxt2,footnote=footnote2,facecolor='papayawhip', \
2618
+ first_col_align='left',second_col_align='left', \
2619
+ last_col_align='center',other_col_align='center')
2620
+
2613
2621
  except:
2614
2622
  pass
2615
2623
 
2616
2624
  # 基金持仓:股票
2617
- titletxt3="***** 基金持仓情况:股票"
2625
+ titletxt3="基金持仓情况:股票"
2618
2626
  footnote3="注:占净值比例为百分比,持股数为万股,(持仓)市值为万元"
2619
2627
  df3=pd.DataFrame()
2620
2628
  import datetime; today = datetime.date.today()
@@ -2626,12 +2634,16 @@ def fund_info_china(fund):
2626
2634
  if len(dft3) >= 1:
2627
2635
  df3=dft3
2628
2636
  df3['持仓类型']='股票'
2629
- printInMarkdown(df3,titletxt=titletxt3,footnote=footnote3)
2637
+ #printInMarkdown(df3,titletxt=titletxt3,footnote=footnote3)
2638
+ df_display_CSS(df3,titletxt=titletxt3,footnote=footnote3,facecolor='papayawhip', \
2639
+ first_col_align='left',second_col_align='left', \
2640
+ last_col_align='center',other_col_align='center')
2641
+
2630
2642
  except:
2631
2643
  pass
2632
2644
 
2633
2645
  # 基金持仓:债券
2634
- titletxt4="***** 基金持仓情况:债券"
2646
+ titletxt4="基金持仓情况:债券"
2635
2647
  df4=pd.DataFrame()
2636
2648
  try:
2637
2649
  dft4 = ak.fund_portfolio_bond_hold_em(symbol=fund1,date=thisYear)
@@ -2640,13 +2652,19 @@ def fund_info_china(fund):
2640
2652
  if len(dft4) >= 1:
2641
2653
  df4=dft4
2642
2654
  df4['持仓类型']='债券'
2643
- printInMarkdown(df4,titletxt=titletxt4)
2655
+ #printInMarkdown(df4,titletxt=titletxt4)
2656
+ df_display_CSS(df4,titletxt=titletxt4,footnote='',facecolor='papayawhip', \
2657
+ first_col_align='left',second_col_align='left', \
2658
+ last_col_align='center',other_col_align='center')
2659
+
2644
2660
  except:
2661
+ print('')
2662
+ print(titletxt4)
2645
2663
  print("\n #Warning(fund_info_china): unable to retrieve bond holding info for",fund,"@",thisYear)
2646
2664
 
2647
2665
 
2648
2666
  # 基金持仓:行业配置
2649
- titletxt5="***** 基金的行业配置情况"
2667
+ titletxt5="基金的行业配置情况"
2650
2668
  footnote5="注:占净值比例为百分比,市值为万元"
2651
2669
  df5=pd.DataFrame()
2652
2670
  try:
@@ -2656,12 +2674,16 @@ def fund_info_china(fund):
2656
2674
  if len(dft5) >= 1:
2657
2675
  df5=dft5
2658
2676
  df5['持仓类型']='行业配置'
2659
- printInMarkdown(df5,titletxt=titletxt5,footnote=footnote5)
2677
+ #printInMarkdown(df5,titletxt=titletxt5,footnote=footnote5)
2678
+ df_display_CSS(df5,titletxt=titletxt5,footnote=footnote5,facecolor='papayawhip', \
2679
+ first_col_align='left',second_col_align='left', \
2680
+ last_col_align='center',other_col_align='center')
2681
+
2660
2682
  except:
2661
2683
  pass
2662
2684
 
2663
2685
  # 基金经理
2664
- titletxt7="***** 基金经理的相关情况"
2686
+ titletxt7="基金经理的相关情况"
2665
2687
  source="数据来源:东方财富/天天基金"
2666
2688
  footnote7="注:从业时间为天数,现任基金资产总规模为该基金经理管辖所有基金的总规模(亿元),最佳回报为历史业绩(百分比)\n"+source+","+str(today)
2667
2689
 
@@ -2674,13 +2696,20 @@ def fund_info_china(fund):
2674
2696
  current=dft7t['现任基金'].values[0]
2675
2697
  df7=dft7t[['姓名','所属公司','累计从业时间','现任基金资产总规模','现任基金最佳回报']]
2676
2698
 
2677
- printInMarkdown(df7,titletxt=titletxt7)
2699
+ #printInMarkdown(df7,titletxt=titletxt7)
2700
+ df_display_CSS(df7,titletxt=titletxt7,footnote='',facecolor='papayawhip', \
2701
+ first_col_align='left',second_col_align='left', \
2702
+ last_col_align='center',other_col_align='center')
2703
+
2704
+
2678
2705
  print(' ')
2679
2706
  print("基金经理当前兼任情况:")
2680
2707
  num=print_long_text(current)
2681
2708
  print(' ')
2682
2709
  print(footnote7)
2683
2710
  except:
2711
+ print('')
2712
+ print(titletxt7)
2684
2713
  print("\n #Warning(fund_info_china): unable to retrieve job info for",fmanager)
2685
2714
 
2686
2715
  return
siat/future_china.py CHANGED
@@ -149,8 +149,13 @@ def future_type_china_2(df,code):
149
149
 
150
150
  contract='合约'
151
151
  print(contract+' '*(maxlen-hzlen(contract))+':',code)
152
+ import numpy as np
152
153
  for c in cols:
153
- print(c+' '*(maxlen-hzlen(c))+':',df1[c].values[0])
154
+ value=df1[c].values[0]
155
+ if value != np.nan:
156
+ print(c+' '*(maxlen-hzlen(c))+':',df1[c].values[0])
157
+ else:
158
+ continue
154
159
 
155
160
  import datetime
156
161
  today = datetime.date.today()
@@ -163,14 +168,14 @@ if __name__=='__main__':
163
168
 
164
169
  #======================================================================================
165
170
  if __name__=='__main__':
166
- code='BX2007'
167
171
  tradedate=''
168
- tradedate='2023-6-10'
172
+ tradedate='2025-6-12'
173
+
174
+ future_type_china(tradedate)
169
175
 
170
- def future_type_china(code='',tradedate=''):
176
+ def future_type_china(tradedate=''):
171
177
  """
172
- 综合程序:
173
- 合约code为空或品种symbol不存在时列示中国内盘期货的全部代码,否则列示该合约品种明细
178
+ 功能:中国内盘期货的常见品种,含合约品种明细
174
179
  """
175
180
 
176
181
  # 检查交易日期
@@ -195,36 +200,30 @@ def future_type_china(code='',tradedate=''):
195
200
  while df is None:
196
201
  today=date_adjust(today, adjust=-1)
197
202
  df=future_type_china_0(today)
198
-
199
- symbol=get_future_symbol(code)
200
- df1=df[df['代码']==symbol]
201
203
 
202
- if len(df1)==0:
203
- if not (code==''):
204
- print(" Warning(future_type_china):",code,'not found')
205
- future_type_china_1(df)
206
- return df
207
-
208
- future_type_china_2(df,code)
209
- return df1
204
+ df.drop(['调整备注','特殊合约参数调整'], axis=1, inplace=True)
205
+ titletxt="中国内盘常见期货品种"
206
+ footnote="数据来源:国泰君安, "+str(tradedate)
207
+ df_display_CSS(df,titletxt=titletxt,footnote=footnote,facecolor='papayawhip', \
208
+ first_col_align='center',second_col_align='center', \
209
+ last_col_align='center',other_col_align='center')
210
+
211
+ return df
210
212
 
211
- if __name__=='__main__':
212
- code='Bx2007'
213
- df=future_type_china(code)
214
213
 
215
214
  #======================================================================================
216
215
  if __name__=='__main__':
217
216
  code='PG'
218
- start='2023-5-1'
219
- end='2023-5-18'
220
- power=0
217
+ start='2025-5-1'
218
+ end='2025-5-30'
219
+ power=1
221
220
 
222
- def future_price_china(code,start,end,power=0):
221
+ def future_price_china(code,start,end,power=0,loc1='upper left',loc2='upper right'):
223
222
  """
224
223
  综合程序:
225
224
  绘制内盘期货交易曲线:收盘价vs结算价vs成交量
226
225
  """
227
- print("Searching for contract "+code+", it may cost great deal of time, take a break ...")
226
+ print("Searching for contract "+code+", it may take time ...")
228
227
  #日期变换
229
228
  start1=convert_date_ts(start)
230
229
  end1=convert_date_ts(end)
@@ -265,7 +264,7 @@ def future_price_china(code,start,end,power=0):
265
264
  p=ak.get_futures_daily(start_date=start1,end_date=end1,market=market)
266
265
  except:
267
266
  print(" #Warning(future_price_china): data source has no response at the moment for",code)
268
- print(" Try another type of future, or try it later")
267
+ print(" Solution: make date period shorter (e.g. within same month), and try again")
269
268
  return None
270
269
 
271
270
  if p is None:
@@ -279,7 +278,8 @@ def future_price_china(code,start,end,power=0):
279
278
  contracts=set(list(p[p['variety']==variety]['symbol']))
280
279
  contracts1=sorted(contracts)
281
280
  print("\n提示:当前可用的"+varietyname+variety+'期货合约:'+mktnamefull+', '+str(end))
282
- print(contracts1)
281
+ #print(contracts1)
282
+ printlist(contracts1,numperline=10,beforehand='',separator=' ')
283
283
  return None
284
284
 
285
285
  #转换日期格式
@@ -317,19 +317,19 @@ def future_price_china(code,start,end,power=0):
317
317
  plot_line2(p2a,acode,"close","收盘价", \
318
318
  p2b,acode,"settle","结算价", \
319
319
  '价格',titletxt,footnote, \
320
- power=power,twinx=False)
320
+ power=power,twinx=False,loc1=loc1,loc2=loc2)
321
321
  #"""
322
322
  #收盘价vs成交量
323
323
  plot_line2(p2a,acode,"close","收盘价", \
324
324
  p2c,acode,"volume","成交量", \
325
325
  '',titletxt,footnote, \
326
- power=power,twinx=True)
326
+ power=power,twinx=True,loc1=loc1,loc2=loc2)
327
327
  #"""
328
328
  #收盘价vs持仓量
329
329
  plot_line2(p2a,acode,"close","收盘价", \
330
330
  p2e,acode,"open_interest","持仓量", \
331
331
  '',titletxt,footnote, \
332
- power=power,twinx=True)
332
+ power=power,twinx=True,loc1=loc1,loc2=loc2)
333
333
  #"""
334
334
  return p2
335
335
 
@@ -444,41 +444,29 @@ if __name__=='__main__':
444
444
 
445
445
  #======================================================================================
446
446
  if __name__=='__main__':
447
- code='ZSD'
447
+
448
+ future_type_foreign()
448
449
 
449
- def future_type_foreign(code=''):
450
+ def future_type_foreign():
450
451
  """
451
- 综合程序:
452
- 合约code为空或不存在时列示中国外盘期货的所有品种,否则列示一个品种的明细条款
452
+ 功能:中国外盘期货的常见品种,含合约明细
453
453
  """
454
454
 
455
455
  df=future_type_foreign_1()
456
+ #cols=['交易代码','交易品种','上市交易所','交易单位','报价单位','合约交割月份']
457
+ cols=['交易代码','交易品种','上市交易所','交易单位','报价单位']
458
+ df1=df[cols]
459
+ df1.reset_index(drop=True,inplace=True)
456
460
 
457
- df1=df[df['交易代码']==code]
458
-
459
- if len(df1)==0:
460
- if not (code==''):
461
- print(" Warning(future_type_foreign):",code,'not found')
462
-
463
- #设置打印对齐
464
- import pandas as pd
465
- pd.set_option('display.max_columns', 1000)
466
- pd.set_option('display.width', 1000)
467
- pd.set_option('display.max_colwidth', 1000)
468
- pd.set_option('display.unicode.ambiguous_as_wide', True)
469
- pd.set_option('display.unicode.east_asian_width', True)
470
-
471
- print("\n===== 中国外盘期货品种一览表 =====\n")
472
- df2=df[['交易代码','交易品种','上市交易所']]
473
- print(df2.to_string(index=False))
474
-
475
- import datetime
476
- today = datetime.date.today()
477
- print('\n*** 数据来源:新浪财经,',today)
478
-
479
- return df
461
+ titletxt="中国外盘期货常见品种"
462
+ import datetime
463
+ todaydt = datetime.date.today()
464
+ footnote="数据来源:新浪财经, "+str(todaydt)
480
465
 
481
- future_type_foreign_2(df,symbol=code)
466
+ df_display_CSS(df1,titletxt=titletxt,footnote=footnote, \
467
+ facecolor='papayawhip', \
468
+ first_col_align='center',second_col_align='center', \
469
+ last_col_align='center',other_col_align='center')
482
470
 
483
471
  return df1
484
472
 
@@ -494,7 +482,7 @@ if __name__=='__main__':
494
482
  end='2021-9-27'
495
483
  power=0
496
484
 
497
- def future_price_foreign(code,start,end,power=0,loc1='best',loc2='best'):
485
+ def future_price_foreign(code,start,end,power=0,loc1='upper left',loc2='upper right'):
498
486
  """
499
487
  综合程序:
500
488
  绘制中国外盘期货的交易趋势:收盘价vs成交量