siat 3.3.11__py3-none-any.whl → 3.3.12__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
@@ -1571,7 +1571,7 @@ def print_progress_percent(current,total,steps=5,leading_blanks=2):
1571
1571
 
1572
1572
  if pct=="100%":
1573
1573
  #print("100% completing")
1574
- print("100%, wrapping up ...")
1574
+ print("100%, completing ...")
1575
1575
  else:
1576
1576
  print(pct,end=' ')
1577
1577
 
@@ -1620,7 +1620,7 @@ def print_progress_percent2(current,total_list,steps=5,leading_blanks=4):
1620
1620
  pct=pct_list[pos]
1621
1621
 
1622
1622
  if pct=="100%":
1623
- print("100% wrapping up ...")
1623
+ print("100%, completing ...")
1624
1624
  else:
1625
1625
  print(pct,end=' ')
1626
1626
 
siat/markowitz2.py CHANGED
@@ -165,7 +165,7 @@ def cumulative_returns_plot(retgroup,name_list="",titletxt="投资组合策略
165
165
  footnote1="观察期间: "+hstart+'至'+hend
166
166
  footnote2="\n数据来源:Sina/EM/Stooq/Yahoo,"+str(stoday)
167
167
  else:
168
- footnote1="Period of observation: "+hstart+' to '+hend
168
+ footnote1="Period of sample: "+hstart+' to '+hend
169
169
  footnote2="\nData source: Sina/EM/Stooq/Yahoo, "+str(stoday)
170
170
 
171
171
  xlabeltxt=footnote1+footnote2
@@ -743,7 +743,7 @@ def portfolio_expectation_universal(pname,member_returns,portfolio_weights,membe
743
743
  print(" Investment portfolio:",pname)
744
744
  print(" Date of analysis:",str(hend))
745
745
  print(" Value of portfolio:","about "+str(round(portfolio_value_thedate/1000,2))+"K/portfolio unit")
746
- print(" Period of observation:",hstart+' to '+hend)
746
+ print(" Period of sample:",hstart+' to '+hend)
747
747
  print(" Annualized return:",round(annual_return,4))
748
748
  print(" Annualized std of return:",round(annual_std,4))
749
749
  print(" ***Portfolio Constructing Strategy***")
@@ -953,15 +953,15 @@ def portfolio_ranks_cn(portfolio_returns,pname,facecolor='papayawhip'):
953
953
 
954
954
  prr2.rename(columns={"投资组合名称/策略":text_lang("投资组合名称/策略","Strategy"), \
955
955
  "收益排名":text_lang("收益排名","Return#"), \
956
- "年化收益率%":text_lang("年化收益率%","Annualized Return%"), \
956
+ "年化收益率%":text_lang("年化收益率%","Annual Return%"), \
957
957
  "收益率变化":text_lang("收益率变化","Return%+/-"), \
958
958
  "风险排名":text_lang("风险排名","Risk#"), \
959
- "年化标准差%":text_lang("年化标准差%","Annualized Std%"), \
959
+ "年化标准差%":text_lang("年化标准差%","Annual Std%"), \
960
960
  "标准差变化":text_lang("标准差变化","Std%+/-"), \
961
961
  "收益率/标准差":text_lang("收益率/标准差","Return/Std")}, \
962
962
  inplace=True)
963
963
 
964
- df_display_CSS(prr2,titletxt=titletxt,footnote='',facecolor='papayawhip',decimals=4, \
964
+ df_display_CSS(prr2,titletxt=titletxt,footnote='',facecolor='papayawhip',decimals=2, \
965
965
  first_col_align='left',second_col_align='center', \
966
966
  last_col_align='right',other_col_align='right', \
967
967
  titile_font_size='16px',heading_font_size='15px', \
@@ -1115,7 +1115,14 @@ if __name__=='__main__':
1115
1115
 
1116
1116
  portfolio_eset(pf_info,simulation=50000)
1117
1117
 
1118
- def portfolio_eset(pf_info,simulation=1000,convex_hull=False,facecolor='papayawhip'):
1118
+ def portfolio_feset(pf_info,simulation=50000,convex_hull=True,facecolor='papayawhip'):
1119
+
1120
+ results=portfolio_eset(pf_info,simulation=simulation,convex_hull=convex_hull,facecolor=facecolor)
1121
+
1122
+ return results
1123
+
1124
+
1125
+ def portfolio_eset(pf_info,simulation=50000,convex_hull=False,facecolor='papayawhip'):
1119
1126
  """
1120
1127
  功能:基于随机数,生成大量可能的投资组合,计算各个投资组合的年均收益率和标准差,绘制投资组合的可行集
1121
1128
  默认绘制散点图凸包:convex_hull=True
@@ -1138,7 +1145,7 @@ def portfolio_eset(pf_info,simulation=1000,convex_hull=False,facecolor='papayawh
1138
1145
  np.random.seed(RANDOM_SEED)
1139
1146
 
1140
1147
  # 循环模拟n次随机的投资组合
1141
- print(" Calculating portfolio efficient set, please wait ...")
1148
+ print(" Calculating portfolio feasible/efficient set, please wait ...")
1142
1149
  for i in range(simulation):
1143
1150
  # 生成numstocks个随机数,并归一化,得到一组随机的权重数据
1144
1151
  random9 = np.random.random(numstocks)
@@ -1243,7 +1250,7 @@ def portfolio_eset(pf_info,simulation=1000,convex_hull=False,facecolor='papayawh
1243
1250
 
1244
1251
  footnote1="Annualized Std -->\n\n"
1245
1252
  footnote2="Based on given securities, constructed "+str(simulation)+" portfolios\n"
1246
- footnote3="Period of observation: "+hstart+" to "+hend
1253
+ footnote3="Period of sample: "+hstart+" to "+hend
1247
1254
  footnote4="\nData source: Sina/EM/Stooq/Yahoo, "+str(stoday)
1248
1255
 
1249
1256
  plt.xlabel(footnote1+footnote2+footnote3+footnote4,fontsize=xlabel_txt_size)
@@ -1268,7 +1275,7 @@ if __name__=='__main__':
1268
1275
  rate_period='1Y'
1269
1276
  rate_type='treasury'
1270
1277
 
1271
- def portfolio_es_sharpe(pf_info,simulation=1000,RF=0):
1278
+ def portfolio_es_sharpe(pf_info,simulation=50000,RF=0):
1272
1279
  """
1273
1280
  功能:基于随机数,生成大量可能的投资组合,计算各个投资组合的年均风险溢价及其标准差,绘制投资组合的可行集
1274
1281
  """
@@ -1362,7 +1369,7 @@ if __name__=='__main__':
1362
1369
  rate_period='1Y'
1363
1370
  rate_type='treasury'
1364
1371
 
1365
- def portfolio_es_sortino(pf_info,simulation=1000,RF=0):
1372
+ def portfolio_es_sortino(pf_info,simulation=50000,RF=0):
1366
1373
  """
1367
1374
  功能:基于随机数,生成大量可能的投资组合,计算各个投资组合的年均风险溢价及其下偏标准差,绘制投资组合的可行集
1368
1375
  """
@@ -1462,7 +1469,7 @@ if __name__=='__main__':
1462
1469
  rate_period='1Y'
1463
1470
  rate_type='treasury'
1464
1471
 
1465
- def portfolio_es_alpha(pf_info,simulation=1000,RF=0):
1472
+ def portfolio_es_alpha(pf_info,simulation=50000,RF=0):
1466
1473
  """
1467
1474
  功能:基于随机数,生成大量可能的投资组合,计算各个投资组合的年化标准差和阿尔法指数,绘制投资组合的可行集
1468
1475
  """
@@ -1580,7 +1587,7 @@ if __name__=='__main__':
1580
1587
  rate_period='1Y'
1581
1588
  rate_type='treasury'
1582
1589
 
1583
- def portfolio_es_treynor(pf_info,simulation=1000,RF=0):
1590
+ def portfolio_es_treynor(pf_info,simulation=50000,RF=0):
1584
1591
  """
1585
1592
  功能:基于随机数,生成大量可能的投资组合,计算各个投资组合的风险溢价和贝塔系数,绘制投资组合的可行集
1586
1593
  """
@@ -1748,7 +1755,7 @@ def RandomPortfolios_plot(RandomPortfolios,col_x,col_y,colorbartxt,title_ext, \
1748
1755
  # 绘制外轮廓线
1749
1756
  for simplex in hull.simplices:
1750
1757
  plt.plot([points[simplex[0]][0], points[simplex[1]][0]],
1751
- [points[simplex[0]][1], points[simplex[1]][1]], 'k-')
1758
+ [points[simplex[0]][1], points[simplex[1]][1]], 'k-.')
1752
1759
 
1753
1760
 
1754
1761
  lang = check_language()
@@ -1772,7 +1779,7 @@ def RandomPortfolios_plot(RandomPortfolios,col_x,col_y,colorbartxt,title_ext, \
1772
1779
  import datetime as dt; stoday=dt.date.today()
1773
1780
  footnote1=x_axis_name+" -->\n\n"
1774
1781
  footnote2="Based on given securities, constructed "+str(simulation)+" portfolios"
1775
- footnote3="\nPeriod of observation: "+hstart+" to "+hend
1782
+ footnote3="\nPeriod of sample: "+hstart+" to "+hend
1776
1783
  footnote4="\nData source: Sina/EM/Stooq/Yahoo, "+str(stoday)
1777
1784
 
1778
1785
  plt.xlabel(footnote1+footnote2+footnote3+footnote4,fontsize=xlabel_txt_size)
@@ -2191,7 +2198,7 @@ if __name__=='__main__':
2191
2198
  graph=True;hirar_return=False;lorisk=True
2192
2199
  convex_hull=False
2193
2200
 
2194
- def portfolio_optimize(pf_info,ratio='sharpe',simulation=10000,RF=0, \
2201
+ def portfolio_optimize(pf_info,ratio='sharpe',simulation=50000,RF=0, \
2195
2202
  graph=True,hirar_return=False,lorisk=True, \
2196
2203
  convex_hull=False,facecolor='papayawhip'):
2197
2204
  """
@@ -2508,7 +2515,7 @@ if __name__=='__main__':
2508
2515
  def cm2inch(x,y):
2509
2516
  return x/2.54,y/2.54
2510
2517
 
2511
- def security_correlation(tickers,start,end,info_type='Close'):
2518
+ def security_correlation(tickers,start,end,info_type='Close',facecolor='papayawhip'):
2512
2519
  """
2513
2520
  功能:股票/指数收盘价之间的相关性
2514
2521
  info_type='Close': 默认Close, 还可为Open/High/Low/Volume
@@ -2567,7 +2574,8 @@ def security_correlation(tickers,start,end,info_type='Close'):
2567
2574
 
2568
2575
  im1 = sns.heatmap(df_coor,annot=True,cmap="YlGnBu"
2569
2576
  , mask=mask#构造mask,去除重复数据显示
2570
- ,vmax=1,vmin=-1
2577
+ , vmax=1,vmin=-1
2578
+ , cbar=False
2571
2579
  , fmt='.2f',ax = ax1,annot_kws={"size": 6})
2572
2580
 
2573
2581
  ax1.tick_params(axis = 'both', length=0)
@@ -2617,21 +2625,27 @@ def security_correlation(tickers,start,end,info_type='Close'):
2617
2625
  elif pv< 0.001:
2618
2626
  ax1.text(n+widthx,m+widthy,'***',ha = 'center',color = 'k',fontdict=font_dict)
2619
2627
 
2620
- plt.title("证券"+info_type_cn+"之间的相关性")
2628
+ plt.title(text_lang("证券","Security's Correlation among ")+text_lang(info_type_cn,info_type+" Prices")+text_lang("之间的相关性",''),fontsize=10)
2621
2629
  plt.tick_params(labelsize=6)
2622
2630
 
2623
- footnote1="\n显著性数值:***非常显著(<0.001),**很显著(<0.01),*显著(<0.05),其余为不显著"
2624
- footnote2="\n系数绝对值:>=0.8极强相关,0.6-0.8强相关,0.4-0.6相关,0.2-0.4弱相关,否则为极弱(不)相关"
2631
+ footnote1=text_lang("\n显著性数值:***非常显著(<0.001),**很显著(<0.01),*显著(<0.05),其余为不显著", \
2632
+ "\nSig level: *** Extremely sig(p<0.001), ** Very sig(<0.01), * Sig(<0.05), others unsig")
2633
+ footnote2=text_lang("\n系数绝对值:>=0.8极强相关,0.6-0.8强相关,0.4-0.6相关,0.2-0.4弱相关,否则为极弱(不)相关", \
2634
+ "\nCoef. abs: >=0.8 Extreme corr, 0.6-0.8 Strong corr, 0.4-0.6 Corr, <0.4 Weak or uncorr")
2625
2635
 
2626
- footnote3="\n观察期间: "+start+'至'+end
2636
+ footnote3=text_lang("\n观察期间: ","\nPeriod of sample: ")+start+text_lang('至',' to ')+end
2627
2637
  import datetime as dt; stoday=dt.date.today()
2628
- footnote4=";数据来源:Sina/EM/stooq/Yahoo,"+str(stoday)
2638
+ footnote4=text_lang(";数据来源:Sina/EM/Stooq/Yahoo,",". Data source: Sina/EM/Stooq/Yahoo, ")+str(stoday)
2629
2639
 
2630
2640
  fontxlabel={'size':6}
2631
2641
  plt.xlabel(footnote1+footnote2+footnote3+footnote4,fontxlabel)
2632
2642
  #plt.xticks(rotation=45)
2633
2643
 
2634
- plt.gca().set_facecolor('papayawhip')
2644
+ plt.gca().set_facecolor(facecolor)
2645
+
2646
+ plt.xticks(fontsize=6, rotation=90)
2647
+ plt.yticks(fontsize=6, rotation=0)
2648
+
2635
2649
  plt.show()
2636
2650
 
2637
2651
  return df_coor
siat/markowitz_simple.py CHANGED
@@ -218,7 +218,7 @@ def markowitz_sharpe(components,start,end,risk_free=0.015,simulation=25000, \
218
218
  {"fun":lambda x:(np.sum(x)-1),"type":"eq"}
219
219
  ])
220
220
  if res.success:
221
- frontier=frontier.append({"std":std,"ret":-res.fun},ignore_index=True)
221
+ frontier=frontier._append({"std":std,"ret":-res.fun},ignore_index=True)
222
222
 
223
223
  # 略微上调有效边界
224
224
  frontier2=frontier.copy()
siat/security_prices.py CHANGED
@@ -163,18 +163,18 @@ def get_prices(ticker,fromdate,todate,adj=False,source='auto', \
163
163
 
164
164
  if source in ['auto']:
165
165
  #尝试AkShare+Sina+EM(新浪,对中国内地股票、港股和美股有效,但不包括国外市场指数)
166
- print(" Trying to capture prices from sina/EM ... ...")
166
+ print(" Trying to capture prices from sina/EM for",ticker,"...")
167
167
  try:
168
168
  prices=get_prices_ak(ticker,fromdate,todate,ticker_type=ticker_type) #支持多个证券
169
169
  except:
170
- print(" #Warning(get_prices): info retrieving failed from sina/EM")
170
+ print(" #Warning(get_prices): info retrieving failed from sina/EM for",ticker)
171
171
  else:
172
172
  if prices is None:
173
- print(" #Warning(get_prices): info not found from sina/EM")
173
+ print(" #Warning(get_prices): info not found from sina/EM for",ticker)
174
174
  else:
175
175
  num=len(prices)
176
176
  if num==0:
177
- print(" #Warning(get_prices): security may suspend trading or already expired")
177
+ print(" #Warning(get_prices):",ticker,"may be suspended or delisted")
178
178
  return prices
179
179
  else:
180
180
  prices2=remove_timezone(prices)
@@ -188,14 +188,14 @@ def get_prices(ticker,fromdate,todate,adj=False,source='auto', \
188
188
  prices=get_price_stooq(ticker,fromdate,todate) #仅支持单只证券
189
189
  #prices=get_prices_stooq(ticker,fromdate,todate)?
190
190
  except:
191
- print(" #Warning(get_prices): info retrieving failed from stooq")
191
+ print(" #Warning(get_prices): info retrieving failed from stooq for",ticker)
192
192
  else:
193
193
  if prices is None:
194
- print(" #Warning(get_prices): info not found from stooq")
194
+ print(" #Warning(get_prices): info not found from stooq for",ticker)
195
195
  else:
196
196
  num=len(prices)
197
197
  if num==0:
198
- print(" #Warning(get_prices): zero record found")
198
+ print(" #Warning(get_prices): zero record found for",ticker)
199
199
  else:
200
200
  prices2=remove_timezone(prices)
201
201
  return prices2 #找到有效数据就返回,否则继续
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: siat
3
- Version: 3.3.11
3
+ Version: 3.3.12
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=Uc_BLjlp6njmGFBMSaM45fcHKgk9kjnKacFcFYljrmE,151620
21
+ siat/common.py,sha256=MjnhlSLKXHXT6TaveSZ5_-RuPNjPuUe-GC0RpzRvnnw,151619
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
@@ -69,12 +69,12 @@ siat/luchy_draw.py,sha256=8Ue-NKnvSVqINPY1eXat0NJat5MR-gex_K62aOYFdmA,20486
69
69
  siat/market_china.py,sha256=EOO-RvdnzJThTrgNHWW3TlWhx4k4rfdjbooOnQsYdQU,50299
70
70
  siat/markowitz.py,sha256=DsfS6vG9TAfdJP4GgN-CCArujPi84XjD23CWbxaA2o4,97627
71
71
  siat/markowitz2-20240620.py,sha256=irZAPnjaatFsKQmFRMENP-cO6bEUl2narYtkU5NKTWI,108019
72
- siat/markowitz2.py,sha256=IJloAP3sAotlVs1tWMUXbIu-9tX4D_Dx12pIkfFDRx4,113955
72
+ siat/markowitz2.py,sha256=y7ShcnKIaxw6LVZlwJj56PlOskiI0DRqU8PXU6f8uyM,114781
73
73
  siat/markowitz_ccb_test.py,sha256=xBkkoaNHdq9KSUrNuHGgKTdNYUvgi84kNYcf719eoyE,1593
74
74
  siat/markowitz_ef_test.py,sha256=wjNlICkgRIqnonPeSIHo4Mu2GRtb9dr21wDt2kMNEcI,4032
75
75
  siat/markowitz_old.py,sha256=Lf7O_4QWT8RsdkHiUyc_7kKY3eZjKDtFR89Fz3pwYnY,33046
76
76
  siat/markowitz_simple-20230709.py,sha256=fSzRrX_3HN3lFGJ3PntJFjfHAOc7vjEUZ6T1uQGdc64,14160
77
- siat/markowitz_simple.py,sha256=bckFmH3_OUctofdco4ZojZ412Aqci9vAT7WREiP4PGA,14285
77
+ siat/markowitz_simple.py,sha256=aJVvx669ngcCsqoQtA9kvFOQVjsuipYt2fyTc4yMItE,14286
78
78
  siat/markowitz_test.py,sha256=fDXoPp6DrKeneYjd0lbb0KfYUJj-VcOvVaPlfsIOstw,5818
79
79
  siat/markowitz_test2.py,sha256=FcVZqYU5va4567WGUVUJ7cMQdVbBGxeBAz82Y3BhCTI,2193
80
80
  siat/ml_cases.py,sha256=FYDk0O7l9hhHlbrlOVGgbH-h2DA503lhKFi9XugH1f0,86874
@@ -98,7 +98,7 @@ siat/sector_china.py,sha256=nP6kfYsnaQWZj8dK-zklwSDW8FDS-obZWp_zL0ec2Ig,118603
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=4xvc9AzRhLKJMu6AxVzIqcn1-NrHoeCF2Ao2p9nwYjU,25978
101
- siat/security_prices.py,sha256=9T4RVZNDlxAGursIb4hZqGeekjYgjBgo3uALhzhWWLw,106181
101
+ siat/security_prices.py,sha256=2aLBSyVRfcZ1-5jqF_r3N02RvlaNNqssJS9GgxGidgM,106235
102
102
  siat/security_prices_test.py,sha256=OEphoJ87NPKoNow1QA8EU_5MUYrJF-qKoWKNapVfZNI,10779
103
103
  siat/security_trend.py,sha256=o0vpWdrJkmODCP94X-Bvn-w7efHhj9HpUYBHtLl55D0,17240
104
104
  siat/security_trend2-20240620.py,sha256=QVnEcb7AyVbO77jVqfFsJffGXrX8pgJ9xCfoAKmWBPk,24854
@@ -139,7 +139,7 @@ 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=H1EM8YYXA8nQHIqsJlso0I3HKPiJLT3QujO4gRVQXWs,13945
142
- siat-3.3.11.dist-info/METADATA,sha256=r7Y7j2sf7516iGiB-pbSzLRC_a0VuYCLWJ2k6zHJOrE,7310
143
- siat-3.3.11.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
144
- siat-3.3.11.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
145
- siat-3.3.11.dist-info/RECORD,,
142
+ siat-3.3.12.dist-info/METADATA,sha256=EtLtE-RtRKITuvSR_Lx-VPuRx_GVICFYFtDe0pjtZHM,7310
143
+ siat-3.3.12.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
144
+ siat-3.3.12.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
145
+ siat-3.3.12.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.2)
2
+ Generator: bdist_wheel (0.38.4)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5