siat 3.4.27__py3-none-any.whl → 3.4.32__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
@@ -2461,7 +2461,7 @@ if __name__=='__main__':
2461
2461
  alist=['NIO','LI','XPEV','TSLA']
2462
2462
  print_list(alist)
2463
2463
 
2464
- def print_list(alist,leading_blanks=1):
2464
+ def print_list(alist,leading_blanks=1,end='\n'):
2465
2465
  """
2466
2466
  功能:打印一个字符串列表,不带引号,节省空间
2467
2467
  """
@@ -2469,7 +2469,7 @@ def print_list(alist,leading_blanks=1):
2469
2469
 
2470
2470
  for i in alist:
2471
2471
  print(i,end=' ')
2472
- print('\n')
2472
+ print(end,end='')
2473
2473
 
2474
2474
  return
2475
2475
 
siat/grafix.py CHANGED
@@ -128,7 +128,8 @@ def plot_line(df0,colname,collabel,ylabeltxt,titletxt,footnote,datatag=False, \
128
128
  mark_top,mark_bottom:是否标记最高最低点
129
129
  输出:折线图
130
130
  返回值:无
131
- 注意:需要日期类型作为df索引
131
+ 注意1:需要日期类型作为df索引
132
+ 注意2:date_freq不为False时,必须设置date_range=True,否则无法完成日期设置!
132
133
  """
133
134
 
134
135
  #空值判断
siat/sector_china.py CHANGED
@@ -151,13 +151,24 @@ def sector_list_china(indicator="新浪行业"):
151
151
  #==============================================================================
152
152
  if __name__=='__main__':
153
153
  sector_name="房地产"
154
+ sector_name="房"
155
+ sector_name="煤炭"
156
+ sector_name="华为"
157
+
158
+ indicator='新浪行业'
154
159
  indicator="启明星行业"
155
160
  indicator="地域"
156
161
  indicator="行业"
157
162
 
158
- sector_name="煤炭"
159
163
  sector_code_china(sector_name)
160
164
 
165
+ def sector_code_sina(sector_name):
166
+ """
167
+ 功能:套壳sector_code_china
168
+ """
169
+ sector_code_china(sector_name)
170
+ return
171
+
161
172
  def sector_code_china(sector_name):
162
173
  """
163
174
  功能:查找行业、板块名称对应的板块代码
@@ -175,26 +186,45 @@ def sector_code_china(sector_name):
175
186
  dfi['label']=dfi['label'].apply(lambda x: x.strip())
176
187
 
177
188
  try:
178
- sector_code=list(dfi[dfi['板块']==sector_name]['label'])[0]
189
+ #sector_code=list(dfi[dfi['板块']==sector_name]['label'])[0]
190
+ dfi['match']=dfi['板块'].apply(lambda x: 1 if sector_name in x else 0)
191
+ found=found+dfi['match'].sum()
192
+
193
+ sector_code=list(dfi[dfi['match']==1]['label'])
194
+ sector_name1=list(dfi[dfi['match']==1]['板块'])
195
+
179
196
  #记录找到的板块分类
180
197
  indicator=i
181
- #记录找到的板块概述
182
- dff=dfi[dfi['板块']==sector_name]
183
198
 
184
- if found > 0: print(" ")
199
+ #if found > 0: print(" ")
185
200
  if indicator == "行业": indicator = "证监会行业"
186
- print("行业/板块名称:"+sector_name)
187
- print("行业/板块代码:"+sector_code,end='')
188
- print(", "+indicator+"分类")
189
- found=found+1
201
+
202
+ if len(sector_code)>0:
203
+ """
204
+ print("行业/板块名称:",sector_name1)
205
+ #print_list(sector_name1,leading_blanks=1)
206
+
207
+ print("行业/板块代码:",sector_code,end='')
208
+ #print_list(sector_code,leading_blanks=1)
209
+
210
+ print("("+indicator+"分类)\n")
211
+ """
212
+ print("行业/板块名称:",end='')
213
+ print_list(sector_name1,leading_blanks=1)
214
+
215
+ print("行业/板块代码:",end='')
216
+ print_list(sector_code,leading_blanks=1,end='')
217
+ print("("+indicator+"分类)\n")
218
+
219
+
190
220
  except:
191
221
  # 无意义,仅为调试
192
- x=1
222
+ pass
193
223
  continue
194
224
 
195
225
  #未找到板块代码
196
226
  if found==0:
197
- print(" #Error(sector_code_china): unsupported sector name",sector_name)
227
+ print("*** Sorry, no sector name found for",sector_name)
198
228
  return
199
229
 
200
230
  return
@@ -220,6 +250,13 @@ if __name__=='__main__':
220
250
  indicator="行业"
221
251
  num=10
222
252
 
253
+ def sector_rank_sina(indicator="涨跌幅",category="新浪行业",rank=5):
254
+ """
255
+ 功能:套壳sector_rank_china
256
+ """
257
+ df=sector_rank_china(comp=indicator,indicator=category,num=rank)
258
+ return df
259
+
223
260
  def sector_rank_china(comp="涨跌幅",indicator="新浪行业",num=10):
224
261
  """
225
262
  功能:按照比较指标降序排列
@@ -233,14 +270,14 @@ def sector_rank_china(comp="涨跌幅",indicator="新浪行业",num=10):
233
270
  #complist=["涨跌幅","成交量","平均价格","公司家数"]
234
271
  complist=["涨跌幅","平均价格","公司家数"]
235
272
  if comp not in complist:
236
- print("#Error(sector_rank_china): unsupported measurement",comp)
237
- print("Supported measurements:",complist)
273
+ print(" #Warning(sector_rank_china): unsupported measurement",comp)
274
+ print(" Supported measurements:",complist)
238
275
  return None
239
276
 
240
277
  indicatorlist=["新浪行业","概念","地域","启明星行业","行业"]
241
278
  if indicator not in indicatorlist:
242
- print("#Error(sector_list_china): unsupported sectoring method",indicator)
243
- print("Supported sectoring method:",indicatorlist)
279
+ print(" #Warning(sector_list_china): unsupported sectoring method",indicator)
280
+ print(" Supported sectoring method:",indicatorlist)
244
281
  return None
245
282
 
246
283
  import akshare as ak
@@ -252,9 +289,9 @@ def sector_rank_china(comp="涨跌幅",indicator="新浪行业",num=10):
252
289
  df['label']=df['label'].apply(lambda x: x.strip())
253
290
 
254
291
  except:
255
- print("#Error(sector_rank_china): data source tentatively unavailable for",indicator)
256
- print("Possible reason: data source is self-updating.")
257
- print("Solution: have a breath of fresh air and try later.")
292
+ print(" #Warning(sector_rank_china): data source tentatively unavailable for",indicator)
293
+ print(" Possible reason: data source is self-updating.")
294
+ print(" Solution: have a breath of fresh air and try later.")
258
295
  return None
259
296
 
260
297
  df.dropna(inplace=True)
@@ -322,12 +359,18 @@ def sector_rank_china(comp="涨跌幅",indicator="新浪行业",num=10):
322
359
 
323
360
  #处理空记录
324
361
  if len(df3) == 0:
325
- print("#Error(sector_rank_china):data source tentatively unavailable for",comp,indicator)
326
- print("Possible reason: data source is self-updating.")
327
- print("Solution: have a breath of fresh air and try later.")
362
+ print(" #Warning(sector_rank_china):data source tentatively unavailable for",comp,indicator)
363
+ print(" Possible reason: data source is self-updating.")
364
+ print(" Solution: have a breath of fresh air and try later.")
328
365
  return
329
366
 
330
367
  df3.index=df3.index + 1
368
+
369
+ df3_collist=list(df3)
370
+ df3['序号']=df3.index
371
+ df3=df3[['序号']+df3_collist]
372
+
373
+ """
331
374
  print("\n===== 中国股票市场:板块"+comp+"排行榜(按照"+indtag+"分类) =====")
332
375
  if num > 0:
333
376
  print(df3.head(num))
@@ -339,6 +382,23 @@ def sector_rank_china(comp="涨跌幅",indicator="新浪行业",num=10):
339
382
  footnote1="*注:代表个股是指板块中涨幅最高或跌幅最低的股票"
340
383
  print(footnote1)
341
384
  print(" 板块数:",len(df),"\b, 数据来源:新浪财经,",today,"\b(信息为上个交易日)")
385
+ """
386
+ if num > 0:
387
+ df4=df3.head(num)
388
+ else:
389
+ df4=df3.tail(-num)
390
+
391
+ titletxt="中国股票市场:板块"+comp+"排行榜(按照"+indtag+"分类)"
392
+ import datetime; stoday = datetime.date.today()
393
+ footnote1="注:代表个股是指板块中涨幅最高或跌幅最低的股票\n"
394
+ footnote2="板块总数"+str(len(df))+",数据来源:新浪财经,"+str(stoday)+"(截至昨日)"
395
+ footnote=footnote1+footnote2
396
+
397
+ df_display_CSS(df4,titletxt=titletxt,footnote=footnote,facecolor='papayawhip',decimals=2, \
398
+ first_col_align='center',second_col_align='left', \
399
+ last_col_align='left',other_col_align='right', \
400
+ titile_font_size='16px',heading_font_size='15px', \
401
+ data_font_size='15px')
342
402
 
343
403
  return df3
344
404
 
@@ -349,6 +409,14 @@ if __name__=='__main__':
349
409
 
350
410
  num=10
351
411
 
412
+ def sector_detail_sina(sector="new_dlhy",indicator="涨跌幅",rank=5):
413
+ """
414
+ 功能:套壳sector_detail_china
415
+ """
416
+ df=sector_detail_china(sector=sector,comp=indicator,num=rank)
417
+ return df
418
+
419
+
352
420
  def sector_detail_china(sector="new_dlhy",comp="涨跌幅",num=10):
353
421
  """
354
422
  功能:按照板块内部股票的比较指标降序排列
@@ -458,6 +526,11 @@ def sector_detail_china(sector="new_dlhy",comp="涨跌幅",num=10):
458
526
  pd.set_option('display.unicode.east_asian_width', True)
459
527
 
460
528
  df3.index=df3.index + 1
529
+
530
+ df3_collist=list(df3)
531
+ df3['序号']=df3.index
532
+ df3=df3[['序号']+df3_collist]
533
+ """
461
534
  print("\n=== 中国股票市场:"+sector_name+"板块,成份股排行榜(按照"+comp+") ===\n")
462
535
  if num > 0:
463
536
  print(df3.head(num))
@@ -469,7 +542,29 @@ def sector_detail_china(sector="new_dlhy",comp="涨跌幅",num=10):
469
542
  footnote1="\n 注:市值的单位是亿元人民币, "
470
543
  print(footnote1+"板块内成份股个数:",len(df))
471
544
  print(" 数据来源:新浪财经,",today,"\b(信息为上个交易日)")
472
-
545
+ """
546
+ if num > 0:
547
+ df4=df3.head(num)
548
+ else:
549
+ df4=df3.tail(-num)
550
+
551
+ titletxt="中国股票市场:"+sector_name+"板块,成份股排行榜(基于"+comp+")"
552
+
553
+ import datetime; stoday = datetime.date.today()
554
+ if "流通市值" in df3_collist:
555
+ footnote1="市值单位:亿元,板块成份股:"+str(len(df))+'\n'
556
+ footnote2="数据来源:新浪财经,"+str(stoday)+"(截至昨日)"
557
+ else:
558
+ footnote1="板块成份股:"+str(len(df))+','
559
+ footnote2="数据来源:新浪财经,"+str(stoday)+"(截至昨日)"
560
+ footnote=footnote1+footnote2
561
+
562
+ df_display_CSS(df4,titletxt=titletxt,footnote=footnote,facecolor='papayawhip',decimals=2, \
563
+ first_col_align='center',second_col_align='left', \
564
+ last_col_align='right',other_col_align='right', \
565
+ titile_font_size='16px',heading_font_size='15px', \
566
+ data_font_size='15px')
567
+
473
568
  return df2
474
569
 
475
570
  #==============================================================================
@@ -481,6 +576,13 @@ if __name__=='__main__':
481
576
  sector="yysw"
482
577
  sector="xyz"
483
578
 
579
+ def sector_position_sina(ticker,sector="new_dlhy"):
580
+ """
581
+ 功能:套壳sector_position_china
582
+ """
583
+ df=sector_position_china(ticker=ticker,sector=sector)
584
+ return df
585
+
484
586
  def sector_position_china(ticker,sector="new_dlhy"):
485
587
  """
486
588
  功能:查找一只股票在板块内的百分数位置
@@ -547,7 +649,10 @@ def sector_position_china(ticker,sector="new_dlhy"):
547
649
  #确定比较范围
548
650
  complist=['changepercent','turnoverratio','settlement','per','pb','nmc','mktcap']
549
651
  compnames=['涨跌幅%','换手率%','收盘价(元)','市盈率','市净率','流通市值(亿元)','总市值(亿元)']
550
- compdf=pd.DataFrame(columns=['指标名称','指标数值','板块百分位数%','板块中位数','板块最小值','板块最大值'])
652
+ compdf=pd.DataFrame(columns=['指标名称','指标数值','板块分位数%','板块中位数','板块最小值','板块最大值'])
653
+
654
+ from scipy.stats import percentileofscore
655
+
551
656
  for c in complist:
552
657
  v=list(sdf[c])[0]
553
658
  vlist=list(set(list(df[c])))
@@ -557,10 +662,11 @@ def sector_position_china(ticker,sector="new_dlhy"):
557
662
  vmedian=round(np.median(vlist),2)
558
663
 
559
664
  pos=vlist.index(v)
560
- pct=round((pos+1)/len(vlist)*100,2)
665
+ #pct=round((pos+1)/len(vlist)*100,2)
666
+ pct=percentileofscore(vlist,v)
561
667
 
562
668
  s=pd.Series({'指标名称':compnames[complist.index(c)], \
563
- '指标数值':v,'板块百分位数%':pct,'板块中位数':vmedian, \
669
+ '指标数值':v,'板块分位数%':pct,'板块中位数':vmedian, \
564
670
  '板块最小值':vmin,'板块最大值':vmax})
565
671
  try:
566
672
  compdf=compdf.append(s,ignore_index=True)
@@ -568,7 +674,7 @@ def sector_position_china(ticker,sector="new_dlhy"):
568
674
  compdf=compdf._append(s,ignore_index=True)
569
675
 
570
676
  compdf.reset_index(drop=True,inplace=True)
571
-
677
+ """
572
678
  print("\n======= 股票在所属行业/板块的位置分析 =======")
573
679
  print("股票: "+sname+" ("+ticker+")")
574
680
  print("所属行业/板块:"+sector_name+" ("+sector+", "+indicator+"分类)")
@@ -586,7 +692,23 @@ def sector_position_china(ticker,sector="new_dlhy"):
586
692
  today = datetime.date.today()
587
693
  print('') #空一行
588
694
  print("注:板块内成份股个数:",len(df),"\b, 数据来源:新浪财经,",today,"\b(信息为上个交易日)")
589
-
695
+ """
696
+ if indicator=="行业": indicator="证监会行业"
697
+
698
+ titletxt="上市公司地位分析:"+sname+","+sector_name+"行业/板块("+indicator+"分类)"
699
+ import datetime; stoday = datetime.date.today()
700
+ footnote1=""
701
+ footnote2="成分股总数:"+str(len(df))+",数据来源:新浪财经,"+str(stoday)+"(截至昨日)"
702
+ footnote=footnote1+footnote2
703
+
704
+ print("") #空一行
705
+ df_display_CSS(compdf,titletxt=titletxt,footnote=footnote,facecolor='papayawhip',decimals=2, \
706
+ first_col_align='left',second_col_align='right', \
707
+ last_col_align='right',other_col_align='right', \
708
+ titile_font_size='16px',heading_font_size='15px', \
709
+ data_font_size='15px')
710
+
711
+
590
712
  return df,compdf
591
713
 
592
714
 
@@ -3564,7 +3686,11 @@ def stock_peers_sw(ticker):
3564
3686
  try:
3565
3687
  print_industry_component_sw(iname=hangye)
3566
3688
  except:
3567
- print(" #Warning(stock_peers_sw): failed to search peers for",ticker)
3689
+ print("\n #Warning(stock_peers_sw): failed to search peers for",ticker)
3690
+ print(" Possible solutions:")
3691
+ print(" 1. If siat is outdated, uninstall and then reinstall")
3692
+ print(" 2. Try upgrade pandas and akshare if outdated")
3693
+ print(" 3. If anaconda is outdated, uninstall and install a newer one")
3568
3694
 
3569
3695
  return
3570
3696
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: siat
3
- Version: 3.4.27
3
+ Version: 3.4.32
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
@@ -18,7 +18,7 @@ siat/capm_beta.py,sha256=cxXdRVBQBllhbfz1LeTJAIWvyRYhW54nhtNUXv4HwS0,29063
18
18
  siat/capm_beta2.py,sha256=lUuCPVSxebkA2yye1PXu1V2Jd2UKEwD_kIA25DCIDTs,29750
19
19
  siat/capm_beta_test.py,sha256=ImR0c5mc4hIl714XmHztdl7qg8v1E2lycKyiqnFj6qs,1745
20
20
  siat/cmat_commons.py,sha256=Nj9Kf0alywaztVoMVeVVL_EZk5jRERJy8R8kBw88_Tg,38116
21
- siat/common.py,sha256=hRRYWfmxAz1gSz2DJBoY8z8li0cbDMw-EiJIvThuhZY,151708
21
+ siat/common.py,sha256=O9-IYeP7z1KHO2YFr-auc_HzBf78nPb-1LY3byb5Avo,151723
22
22
  siat/compare_cross.py,sha256=3iP9TH2h3w27F2ARZc7FjKcErYCzWRc-TPiymOyoVtw,24171
23
23
  siat/compare_cross_test.py,sha256=xra5XYmQGEtfIZL2h-GssdH2hLdFIhG3eoCrkDrL3gY,3473
24
24
  siat/concepts_iwencai.py,sha256=m1YEDtECRT6FqtzlKm91pt2I9d3Z_XoP59BtWdRdu8I,3061
@@ -60,7 +60,7 @@ siat/future_china.py,sha256=F-HsIf2Op8Z22RzTjet1g8COzldgnMjFNSXsAkeGyWo,17595
60
60
  siat/future_china_test.py,sha256=BrSzmDVaOHki6rntOtosmRn-6dkfOBuLulJNqh7MOpc,1163
61
61
  siat/global_index_test.py,sha256=hnFp3wqqzzL-kAP8mgxDZ54Bd5Ijf6ENi5YJlGBgcXw,2402
62
62
  siat/google_authenticator.py,sha256=ZUbZR8OW0IAKDbcYtlqGqIpZdERpFor9NccFELxg9yI,1637
63
- siat/grafix.py,sha256=4e8_w2QT8cJo0uoKyICvod9b5a-L4-qFHnlr4YVnPwg,87359
63
+ siat/grafix.py,sha256=HwtDRINvpfiWcrXsR5h6Ghvspitww5xRvP2eS4UfDFw,87465
64
64
  siat/grafix_test.py,sha256=kXvcpLgQNO7wd30g_bWljLj5UH7bIVI0_dUtXbfiKR0,3150
65
65
  siat/holding_risk.py,sha256=G3wpaewAKF9CwEqRpr4khyuDu9SU2EGyQUHdk7cmHOA,30693
66
66
  siat/holding_risk_test.py,sha256=FRlw_9wFG98BYcg_cSj95HX5WZ1TvkGaOUdXD7-V86s,474
@@ -94,7 +94,7 @@ siat/risk_evaluation.py,sha256=I6B3gty-t--AkDCO0tKF-291YfpnF-IkXcFjqNKCt9I,76286
94
94
  siat/risk_evaluation_test.py,sha256=YEXM96gKzTfwN4U61AS4Rr1tV7KgUvn4rRC6f3iMw9s,3731
95
95
  siat/risk_free_rate.py,sha256=ZMr4cHikPvXvywr54gGqiI3Nvb69am6tq3zj2hwzANE,12384
96
96
  siat/risk_free_rate_test.py,sha256=CpmhUf8aEAEZeNu4gvWP2Mz2dLoIgBX5bI41vfUBEr8,4285
97
- siat/sector_china.py,sha256=_-NgVSI2AMRCZw3U85ov6CgU5riii4Y9oY-rfUrfVSk,132551
97
+ siat/sector_china.py,sha256=A2252BymgpV1LEdZ4DU6SJue7ZMrW4GU8fBfhuqp09w,137485
98
98
  siat/sector_china_test.py,sha256=1wq7ef8Bb_L8F0h0W6FvyBrIcBTEbrTV7hljtpj49U4,5843
99
99
  siat/security_price.py,sha256=2oHskgiw41KMGfqtnA0i2YjNNV6cYgtlUK0j3YeuXWs,29185
100
100
  siat/security_price2.py,sha256=Y4suVC-4koUSI_n8kY0l0y4lo_CTcoeM_kwTHiIFzyM,26291
@@ -139,8 +139,8 @@ siat/valuation_china.py,sha256=EkZQaVkoBjM0c4MCNbaX-bMnlG0e3FXeaWczZDnkptU,67784
139
139
  siat/valuation_market_china_test.py,sha256=gbJ0ioauuo4koTPH6WKUkqcXiQPafnbhU5eKJ6lpdLA,1571
140
140
  siat/var_model_validation.py,sha256=R0caWnuZarrRg9939hxh3vJIIpIyPfvelYmzFNZtPbo,14910
141
141
  siat/yf_name.py,sha256=9U_XfEeMlS3TrCrO3Bww21nuFgghbnO-cqDJMhQWqew,16193
142
- siat-3.4.27.dist-info/LICENSE,sha256=NTEMMROY9_4U1szoKC3N2BLHcDd_o5uTgqdVH8tbApw,1071
143
- siat-3.4.27.dist-info/METADATA,sha256=q5-qoM2N-gp0-nDdPBTIigtYlPFAQldahmL6euBi0a0,8010
144
- siat-3.4.27.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
145
- siat-3.4.27.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
146
- siat-3.4.27.dist-info/RECORD,,
142
+ siat-3.4.32.dist-info/LICENSE,sha256=NTEMMROY9_4U1szoKC3N2BLHcDd_o5uTgqdVH8tbApw,1071
143
+ siat-3.4.32.dist-info/METADATA,sha256=-WEvTLN8wDtXLa77mhBGt9tMIXvoxwAfku48zsdom0s,8010
144
+ siat-3.4.32.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
145
+ siat-3.4.32.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
146
+ siat-3.4.32.dist-info/RECORD,,
File without changes
File without changes