siat 3.3.10__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 +2 -2
- siat/markowitz2.py +54 -40
- siat/markowitz_simple.py +1 -1
- siat/security_prices.py +7 -7
- {siat-3.3.10.dist-info → siat-3.3.12.dist-info}/METADATA +1 -1
- {siat-3.3.10.dist-info → siat-3.3.12.dist-info}/RECORD +8 -8
- {siat-3.3.10.dist-info → siat-3.3.12.dist-info}/WHEEL +0 -0
- {siat-3.3.10.dist-info → siat-3.3.12.dist-info}/top_level.txt +0 -0
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%,
|
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
|
1623
|
+
print("100%, completing ...")
|
1624
1624
|
else:
|
1625
1625
|
print(pct,end=' ')
|
1626
1626
|
|
siat/markowitz2.py
CHANGED
@@ -46,7 +46,7 @@ plt.rcParams['axes.grid']=True
|
|
46
46
|
#plt.rcParams['grid.color']='steelblue'
|
47
47
|
#plt.rcParams['grid.linestyle']='dashed'
|
48
48
|
#plt.rcParams['grid.linewidth']=0.5
|
49
|
-
#plt.rcParams['axes.facecolor']='
|
49
|
+
#plt.rcParams['axes.facecolor']='papayawhip'
|
50
50
|
|
51
51
|
#处理绘图汉字乱码问题
|
52
52
|
import sys; czxt=sys.platform
|
@@ -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
|
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
|
@@ -290,7 +290,7 @@ def portfolio_cumret(portfolio,thedate,pastyears=1, \
|
|
290
290
|
def portfolio_build(portfolio,thedate='default',pastyears=1, \
|
291
291
|
indicator='Adj Close', \
|
292
292
|
adjust='qfq',source='auto',ticker_type='auto', \
|
293
|
-
printout=
|
293
|
+
printout=False,graph=False,facecolor='papayawhip'):
|
294
294
|
"""
|
295
295
|
功能:收集投资组合成份股数据,绘制收益率趋势图,并与等权和期间内交易额加权策略组合比较
|
296
296
|
注意:此处无需RF,待到优化策略时再指定
|
@@ -611,7 +611,7 @@ def portfolio_correlate(pf_info):
|
|
611
611
|
plt.xlabel(footnote1+footnote2)
|
612
612
|
plt.xticks(rotation=90); plt.yticks(rotation=0)
|
613
613
|
|
614
|
-
plt.gca().set_facecolor('
|
614
|
+
plt.gca().set_facecolor('papayawhip')
|
615
615
|
plt.show()
|
616
616
|
|
617
617
|
return
|
@@ -656,7 +656,7 @@ def portfolio_covar(pf_info):
|
|
656
656
|
plt.xticks(rotation=90)
|
657
657
|
plt.yticks(rotation=0)
|
658
658
|
|
659
|
-
plt.gca().set_facecolor('
|
659
|
+
plt.gca().set_facecolor('papayawhip')
|
660
660
|
plt.show()
|
661
661
|
|
662
662
|
return
|
@@ -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
|
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***")
|
@@ -795,7 +795,7 @@ if __name__=='__main__':
|
|
795
795
|
#==============================================================================
|
796
796
|
|
797
797
|
|
798
|
-
def portfolio_ranks(portfolio_returns,pname,facecolor='
|
798
|
+
def portfolio_ranks(portfolio_returns,pname,facecolor='papayawhip'):
|
799
799
|
"""
|
800
800
|
功能:区分中英文
|
801
801
|
"""
|
@@ -812,7 +812,7 @@ def portfolio_ranks(portfolio_returns,pname,facecolor='whitesmoke'):
|
|
812
812
|
|
813
813
|
#==============================================================================
|
814
814
|
|
815
|
-
def portfolio_ranks_cn(portfolio_returns,pname,facecolor='
|
815
|
+
def portfolio_ranks_cn(portfolio_returns,pname,facecolor='papayawhip'):
|
816
816
|
"""
|
817
817
|
功能:打印现有投资组合的收益率、标准差排名,收益率降序,标准差升序,中文/英文
|
818
818
|
"""
|
@@ -953,15 +953,15 @@ def portfolio_ranks_cn(portfolio_returns,pname,facecolor='whitesmoke'):
|
|
953
953
|
|
954
954
|
prr2.rename(columns={"投资组合名称/策略":text_lang("投资组合名称/策略","Strategy"), \
|
955
955
|
"收益排名":text_lang("收益排名","Return#"), \
|
956
|
-
"年化收益率%":text_lang("年化收益率%","
|
956
|
+
"年化收益率%":text_lang("年化收益率%","Annual Return%"), \
|
957
957
|
"收益率变化":text_lang("收益率变化","Return%+/-"), \
|
958
958
|
"风险排名":text_lang("风险排名","Risk#"), \
|
959
|
-
"年化标准差%":text_lang("年化标准差%","
|
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=
|
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', \
|
@@ -986,7 +986,7 @@ def portfolio_ranks_cn(portfolio_returns,pname,facecolor='whitesmoke'):
|
|
986
986
|
dispf2=dispf.set_properties(**{'background-color':facecolor,'color':'black'})
|
987
987
|
except:
|
988
988
|
print(" #Warning(portfolio_ranks_cn): color",facecolor,"is unsupported, changed to default setting")
|
989
|
-
dispf2=dispf.set_properties(**{'background-color':'
|
989
|
+
dispf2=dispf.set_properties(**{'background-color':'papayawhip','color':'black'})
|
990
990
|
|
991
991
|
from IPython.display import display
|
992
992
|
display(dispf2)
|
@@ -1115,7 +1115,14 @@ if __name__=='__main__':
|
|
1115
1115
|
|
1116
1116
|
portfolio_eset(pf_info,simulation=50000)
|
1117
1117
|
|
1118
|
-
def
|
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):
|
|
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,12 +1250,12 @@ def portfolio_eset(pf_info,simulation=1000,convex_hull=False):
|
|
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
|
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)
|
1250
1257
|
|
1251
|
-
plt.gca().set_facecolor(
|
1258
|
+
plt.gca().set_facecolor(facecolor)
|
1252
1259
|
plt.show()
|
1253
1260
|
|
1254
1261
|
return [pf_info,RandomPortfolios]
|
@@ -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=
|
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=
|
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=
|
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=
|
1590
|
+
def portfolio_es_treynor(pf_info,simulation=50000,RF=0):
|
1584
1591
|
"""
|
1585
1592
|
功能:基于随机数,生成大量可能的投资组合,计算各个投资组合的风险溢价和贝塔系数,绘制投资组合的可行集
|
1586
1593
|
"""
|
@@ -1692,7 +1699,7 @@ if __name__=='__main__':
|
|
1692
1699
|
def RandomPortfolios_plot(RandomPortfolios,col_x,col_y,colorbartxt,title_ext, \
|
1693
1700
|
ylabeltxt,x_axis_name,pname,simulation,hstart,hend, \
|
1694
1701
|
hiret_point,lorisk_point,convex_hull=True, \
|
1695
|
-
facecolor="
|
1702
|
+
facecolor="papayawhip"):
|
1696
1703
|
"""
|
1697
1704
|
功能:将生成的马科维茨可行集RandomPortfolios绘制成彩色散点图
|
1698
1705
|
"""
|
@@ -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
|
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)
|
@@ -1866,7 +1873,7 @@ def cvt_portfolio_name(pname,portfolio_returns):
|
|
1866
1873
|
|
1867
1874
|
#==============================================================================
|
1868
1875
|
|
1869
|
-
def portfolio_optimize_sharpe(es_info,graph=True,convex_hull=False,facecolor='
|
1876
|
+
def portfolio_optimize_sharpe(es_info,graph=True,convex_hull=False,facecolor='papayawhip'):
|
1870
1877
|
"""
|
1871
1878
|
功能:计算投资组合的最高夏普比率组合,并绘图
|
1872
1879
|
MSR: Maximium Sharpe Rate, 最高夏普指数方案
|
@@ -1943,7 +1950,7 @@ if __name__=='__main__':
|
|
1943
1950
|
|
1944
1951
|
#==============================================================================
|
1945
1952
|
|
1946
|
-
def portfolio_optimize_sortino(es_info,graph=True,convex_hull=False,facecolor="
|
1953
|
+
def portfolio_optimize_sortino(es_info,graph=True,convex_hull=False,facecolor="papayawhip"):
|
1947
1954
|
"""
|
1948
1955
|
功能:计算投资组合的最高索替诺比率组合,并绘图
|
1949
1956
|
MSO: Maximium Sortino ratio, 最高索替诺比率方案
|
@@ -1994,7 +2001,7 @@ if __name__=='__main__':
|
|
1994
2001
|
if __name__=='__main__':
|
1995
2002
|
graph=True; convex_hull=False
|
1996
2003
|
|
1997
|
-
def portfolio_optimize_alpha(es_info,graph=True,convex_hull=False,facecolor='
|
2004
|
+
def portfolio_optimize_alpha(es_info,graph=True,convex_hull=False,facecolor='papayawhip'):
|
1998
2005
|
"""
|
1999
2006
|
功能:计算投资组合的最高詹森阿尔法组合,并绘图
|
2000
2007
|
MAR: Maximium Alpha Ratio, 最高阿尔法指数方案
|
@@ -2041,7 +2048,7 @@ if __name__=='__main__':
|
|
2041
2048
|
|
2042
2049
|
#==============================================================================
|
2043
2050
|
|
2044
|
-
def portfolio_optimize_treynor(es_info,graph=True,convex_hull=False,facecolor='
|
2051
|
+
def portfolio_optimize_treynor(es_info,graph=True,convex_hull=False,facecolor='papayawhip'):
|
2045
2052
|
"""
|
2046
2053
|
功能:计算投资组合的最高特雷诺比率组合,并绘图
|
2047
2054
|
MTR: Maximium Treynor Ratio, 最高特雷诺指数方案
|
@@ -2081,7 +2088,7 @@ if __name__=='__main__':
|
|
2081
2088
|
|
2082
2089
|
def portfolio_optimize_rar(es_info,col_ratio,col_y,col_x,name_hiret,name_lorisk, \
|
2083
2090
|
colorbartxt,title_ext,ylabeltxt,x_axis_name,graph=True, \
|
2084
|
-
convex_hull=False,facecolor='
|
2091
|
+
convex_hull=False,facecolor='papayawhip'):
|
2085
2092
|
"""
|
2086
2093
|
功能:提供rar比率优化的共同处理部分
|
2087
2094
|
基于RandomPortfolios中的随机投资组合,计算相应的指数,寻找最大指数点和风险最小点,并绘图标注两个点
|
@@ -2191,9 +2198,9 @@ 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=
|
2201
|
+
def portfolio_optimize(pf_info,ratio='sharpe',simulation=50000,RF=0, \
|
2195
2202
|
graph=True,hirar_return=False,lorisk=True, \
|
2196
|
-
convex_hull=False,facecolor='
|
2203
|
+
convex_hull=False,facecolor='papayawhip'):
|
2197
2204
|
"""
|
2198
2205
|
功能:集成式投资组合优化策略
|
2199
2206
|
注意:实验发现RF较小时对于结果的影响极其微小难以观察,默认设为不使用无风险利率调整收益
|
@@ -2402,7 +2409,7 @@ def portfolio_ef_0(stocks,fromdate,todate):
|
|
2402
2409
|
plt.figtext(x_left,y_left-0.1,'观察期间:'+str(fromdate)+'至'+str(todate))
|
2403
2410
|
plt.plot(out_std,out_mean,color='r',ls=':',lw=4)
|
2404
2411
|
|
2405
|
-
plt.gca().set_facecolor('
|
2412
|
+
plt.gca().set_facecolor('papayawhip')
|
2406
2413
|
plt.show()
|
2407
2414
|
|
2408
2415
|
return
|
@@ -2486,7 +2493,7 @@ def portfolio_ef(stocks,fromdate,todate):
|
|
2486
2493
|
plt.plot(out_std_min,out_mean_min,'g*-',markersize=16,label='风险最低点')
|
2487
2494
|
|
2488
2495
|
plt.legend(loc='best')
|
2489
|
-
plt.gca().set_facecolor('
|
2496
|
+
plt.gca().set_facecolor('papayawhip')
|
2490
2497
|
plt.show()
|
2491
2498
|
|
2492
2499
|
return
|
@@ -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
|
-
|
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/
|
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(
|
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.
|
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):
|
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 #找到有效数据就返回,否则继续
|
@@ -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=
|
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=
|
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=
|
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=
|
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.
|
143
|
-
siat-3.3.
|
144
|
-
siat-3.3.
|
145
|
-
siat-3.3.
|
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,,
|
File without changes
|
File without changes
|