siat 3.1.4__py3-none-any.whl → 3.1.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
siat/common.py CHANGED
@@ -399,7 +399,13 @@ def date_adjust2(basedate,adjust_year=0,adjust_month=0,adjust_day=0, \
399
399
  new_year=new_year + 1
400
400
 
401
401
  #合成中间日期:新年份,新月份,原日期
402
- ndym=datetime(new_year,new_month,bd_day)
402
+ while True:
403
+ try:
404
+ ndym=datetime(new_year,new_month,bd_day)
405
+ break
406
+ except:
407
+ bd_day=bd_day - 1
408
+ continue
403
409
 
404
410
  #调整日期
405
411
  nd=ndym + timedelta(days=adjust_day)
siat/financials_china.py CHANGED
@@ -54,6 +54,8 @@ if __name__=='__main__':
54
54
 
55
55
  ticker='000002.SZ'
56
56
  ticker='601398.SS'
57
+ ticker='600791.SS'
58
+
57
59
  akfs=get_fin_stmt_ak(ticker)
58
60
 
59
61
  def get_fin_stmt_ak(ticker):
@@ -72,6 +74,7 @@ def get_fin_stmt_ak(ticker):
72
74
  return None
73
75
 
74
76
  #抓取三大报表
77
+ import akshare as ak
75
78
  import time
76
79
  try:
77
80
  fbs = ak.stock_financial_report_sina(stock=prefix, symbol="资产负债表")
@@ -263,7 +266,7 @@ def get_fin_stmt_ak(ticker):
263
266
  #现金分析比率
264
267
  if not ('销售现金比率%' in fslist):
265
268
  #fs4['销售现金比率%']=round((fs4['经营活动现金流入'] / fs4['营业总收入'])*100,2)
266
- fs4['销售现金比率%']=fs4.apply(lambda x: round((x['经营活动现金流入'] / x['营业总收入'])*100,2),axis=1)
269
+ fs4['销售现金比率%']=fs4.apply(lambda x: round((x['经营活动现金流入'] / x['营业总收入'])*100,2) if x['营业总收入'] !=0 else np.nan,axis=1)
267
270
 
268
271
  if not ('现金购销比率%' in fslist):
269
272
  #fs4['现金购销比率%']=round((fs4['经营活动现金流出'] / fs4['经营活动现金流入'])*100,2)
@@ -271,19 +274,19 @@ def get_fin_stmt_ak(ticker):
271
274
 
272
275
  if not ('营业现金回笼率%' in fslist):
273
276
  #fs4['营业现金回笼率%']=round((fs4['经营活动现金流入'] / fs4['营业总收入'])*100,2)
274
- fs4['营业现金回笼率%']=fs4.apply(lambda x: round((x['经营活动现金流入'] / x['营业总收入'])*100,2),axis=1)
277
+ fs4['营业现金回笼率%']=fs4.apply(lambda x: round((x['经营活动现金流入'] / x['营业总收入'])*100,2) if x['营业总收入'] !=0 else np.nan,axis=1)
275
278
 
276
279
  if not ('短期现金偿债能力%' in fslist):
277
280
  #fs4['短期现金偿债能力%']=round((fs4['经营活动现金流净额'] / fs4['流动负债合计'])*100,2)
278
281
  try:
279
- fs4['短期现金偿债能力%']=fs4.apply(lambda x: round((x['经营活动现金流净额'] / x['流动负债合计'])*100,2),axis=1)
282
+ fs4['短期现金偿债能力%']=fs4.apply(lambda x: round((x['经营活动现金流净额'] / x['流动负债合计'])*100,2) if x['流动负债合计'] !=0 else np.nan,axis=1)
280
283
  except:
281
284
  fs4['短期现金偿债能力%']=np.nan
282
285
 
283
286
  if not ('长期现金偿债能力%' in fslist):
284
287
  #fs4['长期现金偿债能力%']=round((fs4['经营活动现金流净额'] / fs4['负债合计'])*100,2)
285
288
  try:
286
- fs4['长期现金偿债能力%']=fs4.apply(lambda x: round((x['经营活动现金流净额'] / x['负债合计'])*100,2),axis=1)
289
+ fs4['长期现金偿债能力%']=fs4.apply(lambda x: round((x['经营活动现金流净额'] / x['负债合计'])*100,2) if x['负债合计'] !=0 else np.nan,axis=1)
287
290
  except:
288
291
  fs4['长期现金偿债能力%']==np.nan
289
292
 
@@ -320,7 +323,7 @@ def get_fin_stmt_ak(ticker):
320
323
 
321
324
  if not ('盈利现金比率%' in fslist):
322
325
  #fs4['盈利现金比率%']=round((fs4['经营活动现金流净额'] / fs4['净利润'])*100,2)
323
- fs4['盈利现金比率%']=fs4.apply(lambda x: round((x['经营活动现金流净额'] / x['净利润'])*100,2),axis=1)
326
+ fs4['盈利现金比率%']=fs4.apply(lambda x: round((x['经营活动现金流净额'] / x['净利润'])*100,2) if x['净利润'] !=0 else np.nan,axis=1)
324
327
 
325
328
  if not ('现金流入流出比率%' in fslist):
326
329
  #fs4['现金流入流出比率%']=round((fs4['经营活动现金流入'] / fs4['经营活动现金流出'])*100,2)
@@ -328,7 +331,7 @@ def get_fin_stmt_ak(ticker):
328
331
 
329
332
  if not ('资产现金回收率%' in fslist):
330
333
  #fs4['资产现金回收率%']=round((fs4['经营活动现金流净额'] / fs4['资产总计'])*100,2)
331
- fs4['资产现金回收率%']=fs4.apply(lambda x: round((x['经营活动现金流净额'] / x['资产总计'])*100,2),axis=1)
334
+ fs4['资产现金回收率%']=fs4.apply(lambda x: round((x['经营活动现金流净额'] / x['资产总计'])*100,2) if x['资产总计'] !=0 else np.nan,axis=1)
332
335
 
333
336
 
334
337
  return fs4
siat/financials_china2.py CHANGED
@@ -2158,6 +2158,7 @@ def fs_analysis_china(tickers,fsdates=[],analysis_type='balance sheet', \
2158
2158
 
2159
2159
  else:
2160
2160
  print(" #Warning(fs_analysis_china): sorry, no idea on what to do for",analysis_type)
2161
+
2161
2162
  return
2162
2163
 
2163
2164
 
siat/fund_china.py CHANGED
@@ -202,7 +202,7 @@ def fund_stock_holding_compare_china(fund,quarter1,quarter2,rank=10):
202
202
  print("\n*** 注:持股数为万股,持仓市值为万元,持仓比例为占基金资产净值比例%,包括A股与非A股")
203
203
  print(" 数据来源:天天基金/东方财富, 期间持仓股票总计"+str(len(df_merge))+"只,",today)
204
204
  """
205
- titletxt="基金持仓分析:"+name+','+s1+"对比"+s2+"(按后者持仓比例降序排列,"+order+str(rank)+"名成份证券)"
205
+ titletxt="基金持仓转移矩阵:"+name+','+s1+"对比"+s2+"(按后者持仓比例降序排列,"+order+str(rank)+"名成份证券)"
206
206
 
207
207
  footnote1="【注】持仓数为万股,持仓市值为万元,持仓比例为占基金资产净值比例%;"
208
208
  footnote2="期间内(曾经)持仓证券数合计"+str(len(df_merge))+"只"+'\n'
@@ -373,7 +373,7 @@ def fund_stock_holding_rank_china(fund,rank=10,year_num=2):
373
373
  name=get_fund_name_china2(fund)
374
374
 
375
375
  #print("=== 基金持仓股票排行分析:"+name+",按照占净值比例高低排列 ===\n")
376
- titletxt="基金持仓分析:"+name+",按照占净值比例降序排列,前"+str(rank)+"名成份证券"
376
+ titletxt="基金持仓转移详情:"+name+",按照占净值比例降序排列,前"+str(rank)+"名成份证券"
377
377
  import datetime; todaydt = datetime.date.today()
378
378
  #print("\n*** 注:包括A股与非A股。持股结构:股票简称(占净值比例%,持股数万股),",str(todaydt))
379
379
  footnote="【注】持仓结构:证券简称(占净值比例%,持仓数万股),"+str(todaydt)+"统计"
siat/sector_china.py CHANGED
@@ -851,7 +851,11 @@ def print_industry_component_sw2(icode,numberPerLine=5,colalign='left'):
851
851
 
852
852
  iname=industry_sw_name(icode)
853
853
 
854
- clist,cdf=industry_stock_sw(icode,top=1000)
854
+ clist,cdf=industry_stock_sw(icode,top=1000)
855
+ if cdf is None:
856
+ print(" Error(print_industry_component_sw2): Shenwan industry component info tentatively inaccessible")
857
+ print(" Try later, or change to another computer and try again")
858
+ return
855
859
 
856
860
  #cdf['icode']=cdf['证券代码'].apply(lambda x: x+'.SS' if x[:1] in ['6'] else (x+'.SZ' if x[:1] in ['0','3'] else x+'.BJ' ))
857
861
  cdf['icode']=cdf['证券代码']
@@ -2070,7 +2074,10 @@ def rank_industry_sw_sharpe(idfall,base_return='Exp Ret%',graph=True,axisamp=0.8
2070
2074
  if __name__=='__main__':
2071
2075
  industry='850831.SW'
2072
2076
  industry='801193.SW'
2077
+ industry='851811.SW'
2078
+ industry='801181.SW'
2073
2079
  top=5
2080
+ df=industry_stock_sw(industry)
2074
2081
 
2075
2082
  def industry_stock_sw(industry='801270.SW',top=5,printout=False):
2076
2083
  """
@@ -2092,7 +2099,7 @@ def industry_stock_sw(industry='801270.SW',top=5,printout=False):
2092
2099
  cdf = ak.index_component_sw(industry)
2093
2100
  except:
2094
2101
  print(" #Warning(industry_stock_sw): internal failure on component stocks for Shenwan industry",industry)
2095
- print(" Possible solution: upgrade akshare and then try again (expecting good luck but no guarantee)")
2102
+ print(" Possible solution: upgrade akshare and then try again (good luck but no guarantee)")
2096
2103
  return None,None
2097
2104
 
2098
2105
  # 删除'证券名称'为None的行
@@ -2122,10 +2129,18 @@ def industry_stock_sw(industry='801270.SW',top=5,printout=False):
2122
2129
  clist1=clist1+[c+'.SZ']
2123
2130
  """
2124
2131
  if printout:
2125
- title_txt="申万行业成分股:"+industry_sw_name(industry)+'('+industry+'.SW)'
2126
- import datetime as dt; today=str(dt.date.today())
2127
- footnote="成分股总数:"+str(cdf_total)+",数据来源:申万宏源,"+str(today)
2128
- df_directprint(cdf1,title_txt,footnote)
2132
+ if '.SW' not in industry:
2133
+ industry=industry+'.SW'
2134
+ titletxt="申万行业指数成分股:"+industry_sw_name(industry)+'('+industry+')'
2135
+ import datetime as dt; todaydt=str(dt.date.today())
2136
+ footnote="成分股总数:"+str(cdf_total)+",数据来源:申万宏源,"+str(todaydt)
2137
+
2138
+ #df_directprint(cdf1,title_txt,footnote)
2139
+ df_display_CSS(cdf1,titletxt=titletxt,footnote=footnote,facecolor='papayawhip',decimals=3, \
2140
+ first_col_align='center',second_col_align='left', \
2141
+ last_col_align='left',other_col_align='right', \
2142
+ titile_font_size='16px',heading_font_size='15px', \
2143
+ data_font_size='15px')
2129
2144
 
2130
2145
  #return clist1,cdf1
2131
2146
  return clist,cdf1
@@ -3018,7 +3033,38 @@ def industry_scan_china(sw_level='F', \
3018
3033
 
3019
3034
  return df2
3020
3035
 
3036
+ #==============================================================================
3037
+ if __name__=='__main__':
3038
+ ticker='600791.SS'
3039
+ find_industry_sw(ticker)
3040
+
3041
+ def find_industry_sw(ticker):
3042
+ """
3043
+ 功能:寻找一只股票所属的申万行业,细分行业
3044
+ """
3045
+ ticker6=ticker[:6]
3021
3046
 
3047
+ import akshare as ak
3048
+ #df3 = ak.sw_index_third_info()
3049
+ df2 = ak.sw_index_second_info()
3050
+ df2['industry_code']=df2['行业代码'].apply(lambda x: x[:6])
3051
+ industry_list=list(df2['industry_code'])
3052
+
3053
+ for i in industry_list:
3054
+ cdf = ak.index_component_sw(i)
3055
+ component_list=list(cdf)
3056
+
3057
+ if ticker6 in component_list:
3058
+ stock_name=cdf[cdf["证券代码"]==ticker6]['证券名称'].values[0]
3059
+ print("股票:",ticker,",",stock_name)
3060
+
3061
+ isi=i+'.SI'
3062
+ industry_name=df3[df3[行业代码]==isi]['行业名称'].values[0]
3063
+ print("申万三级行业代码:",i+".SW",",",industry_name)
3064
+
3065
+ break
3066
+
3067
+ return
3022
3068
  #==============================================================================
3023
3069
  #==============================================================================
3024
3070
  #==============================================================================
siat/stock.py CHANGED
@@ -1645,7 +1645,7 @@ def compare_msecurity(tickers,measure,start,end, \
1645
1645
  if (len(tickersplit) > 1) and (measure == 'Close'):
1646
1646
  if tickersplit[1].upper() in ['M','B']:
1647
1647
  #y_label='指标'
1648
- y_label=''
1648
+ y_label='指标对比'
1649
1649
 
1650
1650
  x_label1cn="数据来源: 综合新浪/东方财富/stooq/yahoo等,"
1651
1651
  x_label1en="Source: integrating sina/stooq/yahoo, "
@@ -1653,12 +1653,18 @@ def compare_msecurity(tickers,measure,start,end, \
1653
1653
  import datetime; todaydt = datetime.date.today()
1654
1654
  x_label=x_label1+str(todaydt)
1655
1655
 
1656
- title_txt1=text_lang("证券趋势分析:","Trend Analysis: ")
1657
- title_txt=title_txt1+y_label
1656
+ title_txt1=text_lang("证券趋势对比分析","Trend Comparative Analysis")
1657
+ if y_label != '':
1658
+ title_txt=title_txt1+": "+y_label
1659
+ else:
1660
+ title_txt=title_txt1
1661
+
1658
1662
  if preprocess == 'scaling' and scaling_option == 'change%':
1659
- title_txt2=text_lang(",涨跌幅度",", Changes")
1660
- title_txt=title_txt+title_txt2
1661
-
1663
+ title_txt2=text_lang("涨跌幅度","Changes")
1664
+ if ':' in title_txt:
1665
+ title_txt=title_txt+', '+title_txt2
1666
+ else:
1667
+ title_txt=title_txt+': '+title_txt2
1662
1668
 
1663
1669
  # 标准化处理
1664
1670
  dfs2,axhline_label,x_label,y_label,plus_sign=df_preprocess(dfs,measure, \
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: siat
3
- Version: 3.1.4
3
+ Version: 3.1.6
4
4
  Summary: Securities Investment Analysis Tools (siat)
5
5
  Home-page: https://pypi.org/project/siat/
6
6
  Author: Prof. WANG Dehong, International Business School, Beijing Foreign Studies University
@@ -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=kGsyiuYJX-Y8VNb2mmspSp7rNc5r8eexxEt9JiKmwHM,143250
20
+ siat/common.py,sha256=Jjr8Fozk8JpHRMxOuK_a_BXMetV5O8QrmBNFQuGAJZA,143378
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
@@ -40,8 +40,8 @@ siat/financial_statements_test.py,sha256=FLhx8JD-tVVWSBGux6AMz1jioXX4U4bp9DmgFHY
40
40
  siat/financials.py,sha256=mbEZSNeHMMFcnPUryQWvdmNlWQvpnOG9eItgS7IVw3k,80458
41
41
  siat/financials2 - 副本.py,sha256=dKlNjIfKeoSy055fQ6E6TUj9HEoO5Ney9grD84J5kfk,14389
42
42
  siat/financials2.py,sha256=7mnsTncKsgwFu8PP4refh5C5iMIO9P0KOMSF87ZyncY,45736
43
- siat/financials_china.py,sha256=HdX6YKI4tUC7VnPCTAjtdC3JxGgGepu07wdrpyykxbE,190119
44
- siat/financials_china2.py,sha256=mFwWtzwPbantjmXkGsr4CTEj9VRdZe5yITG3VwlJC9E,92655
43
+ siat/financials_china.py,sha256=CJHMZAWwE0dTYqCL_ffgpbt_UkuJ26InAM0j7CpLGUg,190406
44
+ siat/financials_china2.py,sha256=8qOHl617G_54GlqVJIUfXCitJy0pkEDRil30tpkuHJ0,92665
45
45
  siat/financials_china2_test.py,sha256=Erz5k4LyOplBBvYls2MypuqHpVNJ3daiLdyeJezNPu0,2722
46
46
  siat/financials_china2_test2.py,sha256=C8CuYTMHN4Mhp-sTu-Bmg0zMXRCaYV6ezGDoYartRYQ,3507
47
47
  siat/financials_china2_test3.py,sha256=UXYSA80DNSPRhHpovc2MA9JkpILWMAQaRatbWCHBNPs,3118
@@ -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=uO2RexvO0ldclJwKAtbmdmaP9UvfkHq_uQDKOEVG5Sc,97516
55
+ siat/fund_china.py,sha256=Sa9_s1A_dTT_sBu_pYYw2WaNZF0MIrNy-5X2FO4Lm00,97528
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
@@ -91,7 +91,7 @@ siat/risk_evaluation.py,sha256=I6B3gty-t--AkDCO0tKF-291YfpnF-IkXcFjqNKCt9I,76286
91
91
  siat/risk_evaluation_test.py,sha256=YEXM96gKzTfwN4U61AS4Rr1tV7KgUvn4rRC6f3iMw9s,3731
92
92
  siat/risk_free_rate.py,sha256=ZMr4cHikPvXvywr54gGqiI3Nvb69am6tq3zj2hwzANE,12384
93
93
  siat/risk_free_rate_test.py,sha256=CpmhUf8aEAEZeNu4gvWP2Mz2dLoIgBX5bI41vfUBEr8,4285
94
- siat/sector_china.py,sha256=QSNJclhzT6V9NidziMwwAs-Kk6f7nzdK6PiPGkKrBCk,111617
94
+ siat/sector_china.py,sha256=zbN8MdQJi84femJFB9vxu1XgfPPCWGH7SPV44EjZCNI,113475
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
@@ -101,7 +101,7 @@ siat/security_trend.py,sha256=o0vpWdrJkmODCP94X-Bvn-w7efHhj9HpUYBHtLl55D0,17240
101
101
  siat/security_trend2.py,sha256=4yBY3ve0Kddu95JemS02gfLbrHVN2_gl_irr5pA4F6w,24626
102
102
  siat/setup.py,sha256=up65rQGLmTBkhtaMLowjoQXYmIsnycnm4g1SYmeQS6o,1335
103
103
  siat/shenwan index history test.py,sha256=JCVAzOSEldHalhSFa3pqD8JI_8_djPMQOxpkuYU-Esg,1418
104
- siat/stock.py,sha256=9w7LzOZzt-gAzfdVfYB8nd73DrG73wLmFpIolJKUCBc,139188
104
+ siat/stock.py,sha256=GkGRY06uIKFuXg0Rw2rhUPFw2LY0VHIV-FMQYcpEP9Q,139380
105
105
  siat/stock_advice_linear.py,sha256=-twT7IGP-NEplkL1WPSACcNJjggRB2j4mlAQCkzOAuo,31655
106
106
  siat/stock_base.py,sha256=uISvbRyOGy8p9QREA96CVydgflBkn5L3OXOGKl8oanc,1312
107
107
  siat/stock_china.py,sha256=zyUyghIrkkkYWlHRRP7Hoblxzfp-jrck60pTJpwMahg,91553
@@ -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.4.dist-info/METADATA,sha256=GjZl5T5oguZg8fcFxvDskZKFVJizNcgQEU-IxlH0RSI,1447
136
- siat-3.1.4.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
137
- siat-3.1.4.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
138
- siat-3.1.4.dist-info/RECORD,,
135
+ siat-3.1.6.dist-info/METADATA,sha256=7I1oTuPz1RUF3cmw1c0t_zAdexvckE9P8x9U5sCp16c,1447
136
+ siat-3.1.6.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
137
+ siat-3.1.6.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
138
+ siat-3.1.6.dist-info/RECORD,,
File without changes