siat 3.0.4__py3-none-any.whl → 3.0.10__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/allin.py +2 -1
- siat/common.py +15 -2
- siat/fama_french.py +2 -0
- siat/markowitz.py +25 -14
- siat/markowitz2.py +2422 -0
- siat/risk_adjusted_return2.py +34 -24
- siat/stock_technical.py +33 -12
- {siat-3.0.4.dist-info → siat-3.0.10.dist-info}/METADATA +1 -1
- {siat-3.0.4.dist-info → siat-3.0.10.dist-info}/RECORD +11 -10
- {siat-3.0.4.dist-info → siat-3.0.10.dist-info}/WHEEL +0 -0
- {siat-3.0.4.dist-info → siat-3.0.10.dist-info}/top_level.txt +0 -0
siat/allin.py
CHANGED
siat/common.py
CHANGED
@@ -466,7 +466,8 @@ def portfolio_name(portfolio):
|
|
466
466
|
try:
|
467
467
|
name=portfolio[keylist[0]][2]
|
468
468
|
except:
|
469
|
-
name="PF1"
|
469
|
+
#name="PF1"
|
470
|
+
e=text_lang("投资组合","Investment Portfolio")
|
470
471
|
|
471
472
|
return name
|
472
473
|
|
@@ -2384,12 +2385,24 @@ def descriptive_statistics2(df,titletxt,footnote,decimals=4,sortby='tpw_mean', \
|
|
2384
2385
|
print("\n"+footnote)
|
2385
2386
|
|
2386
2387
|
else: #style打印
|
2388
|
+
"""
|
2387
2389
|
print("\n"+titletxt)
|
2388
2390
|
dst6sd= dst6.style.set_properties(**{'text-align': 'center'})
|
2389
2391
|
from IPython.display import display
|
2390
2392
|
display(dst6sd)
|
2391
2393
|
print(footnote+"\n")
|
2392
|
-
|
2394
|
+
"""
|
2395
|
+
# 处理表格标题
|
2396
|
+
dst6sd1=dst6.style.set_caption(titletxt).set_table_styles(
|
2397
|
+
[{'selector':'caption',
|
2398
|
+
'props':[('color','black'),('font-size','16px'),('font-weight','bold')]}])
|
2399
|
+
# 列居中
|
2400
|
+
dst6sd2=dst6sd1.set_properties(**{'text-align':'center'})
|
2401
|
+
|
2402
|
+
from IPython.display import display
|
2403
|
+
display(dst6sd2)
|
2404
|
+
print(footnote+"\n")
|
2405
|
+
|
2393
2406
|
return dst5
|
2394
2407
|
|
2395
2408
|
|
siat/fama_french.py
CHANGED
siat/markowitz.py
CHANGED
@@ -225,10 +225,13 @@ def portfolio_hpr(portfolio,thedate,pastyears=1, \
|
|
225
225
|
|
226
226
|
#==============================================================================
|
227
227
|
if __name__=='__main__':
|
228
|
+
Market={'Market':('US','^GSPC')}
|
228
229
|
Market={'Market':('US','^GSPC','我的组合001')}
|
229
230
|
Stocks1={'AAPL':.3,'MSFT':.15,'AMZN':.15,'FB':.01,'GOOG':.01}
|
230
231
|
Stocks2={'XOM':.02,'JNJ':.02,'JPM':.01,'TSLA':.3,'SBUX':.03}
|
231
232
|
portfolio=dict(Market,**Stocks1,**Stocks2)
|
233
|
+
|
234
|
+
ticker_name(portfolio)
|
232
235
|
|
233
236
|
thedate='2023-2-17'
|
234
237
|
pastyears=1
|
@@ -241,7 +244,7 @@ def portfolio_cumret(portfolio,thedate,pastyears=1, \
|
|
241
244
|
rate_period='1Y',rate_type='shibor',RF=False, \
|
242
245
|
printout=True,graph=True):
|
243
246
|
"""
|
244
|
-
|
247
|
+
功能:绘制投资组合的累计收益率趋势图,并与等权和期间内交易额加权组合比较
|
245
248
|
注意:中国部分历史区段的treasury历史可能无法取得;
|
246
249
|
无论是shibor还是treasury的近期利率均可能空缺,只能以最近期的数值填补
|
247
250
|
"""
|
@@ -384,7 +387,7 @@ def portfolio_cumret(portfolio,thedate,pastyears=1, \
|
|
384
387
|
StockReturns['Portfolio_EW']=stock_return.mul(portfolio_weights_ew,axis=1).sum(axis=1)
|
385
388
|
#..........................................................................
|
386
389
|
|
387
|
-
#
|
390
|
+
# 创建交易额加权组合:按照成交金额计算期间内交易额均值
|
388
391
|
tamount=prices['Close']*prices['Volume']
|
389
392
|
tamountlist=tamount.mean(axis=0) #求列的均值
|
390
393
|
tamountlist_array = np.array(tamountlist)
|
@@ -397,7 +400,7 @@ def portfolio_cumret(portfolio,thedate,pastyears=1, \
|
|
397
400
|
if lang == 'Chinese':
|
398
401
|
title_txt="投资组合策略:业绩对比"
|
399
402
|
Portfolio_EW_txt="等权重策略"
|
400
|
-
Portfolio_LW_txt="
|
403
|
+
Portfolio_LW_txt="交易额加权策略"
|
401
404
|
else:
|
402
405
|
title_txt="Investment Portfolio Strategies: Performance Comparison"
|
403
406
|
Portfolio_EW_txt="Equal-weight"
|
@@ -443,7 +446,7 @@ if __name__=='__main__':
|
|
443
446
|
def portfolio_expret(portfolio,today,pastyears=1, \
|
444
447
|
rate_period='1Y',rate_type='shibor',RF=False,printout=True,graph=True):
|
445
448
|
"""
|
446
|
-
|
449
|
+
功能:绘制投资组合的持有期收益率趋势图,并与等权和期间内交易额加权组合比较
|
447
450
|
套壳原来的portfolio_cumret函数,以维持兼容性
|
448
451
|
expret: expanding return,以维持与前述章节名词的一致性
|
449
452
|
hpr: holding period return, 持有(期)收益率
|
@@ -994,22 +997,26 @@ def portfolio_es(pf_info,simulation=50000):
|
|
994
997
|
|
995
998
|
import datetime as dt; stoday=dt.date.today()
|
996
999
|
lang = check_language()
|
997
|
-
if lang == 'Chinese':
|
1000
|
+
if lang == 'Chinese':
|
1001
|
+
if pname == '': pname='投资组合'
|
1002
|
+
|
998
1003
|
plt.colorbar(label='收益率/标准差')
|
999
|
-
plt.title("
|
1004
|
+
plt.title(pname+": 马科维茨可行(有效)集",fontsize=title_txt_size)
|
1000
1005
|
plt.ylabel("年化收益率",fontsize=ylabel_txt_size)
|
1001
1006
|
|
1002
1007
|
footnote1="年化收益率标准差-->"
|
1003
|
-
footnote2="\n\n
|
1008
|
+
footnote2="\n\n基于给定的成份证券构造"+str(simulation)+"个投资组合"
|
1004
1009
|
footnote3="\n观察期间:"+hstart+"至"+hend
|
1005
1010
|
footnote4="\n来源: Sina/EM/stooq, "+str(stoday)
|
1006
1011
|
else:
|
1012
|
+
if pname == '': pname='Investment Portfolio'
|
1013
|
+
|
1007
1014
|
plt.colorbar(label='Return/Std')
|
1008
|
-
plt.title("
|
1015
|
+
plt.title(pname+": Efficient Set",fontsize=title_txt_size)
|
1009
1016
|
plt.ylabel("Annualized Return",fontsize=ylabel_txt_size)
|
1010
1017
|
|
1011
1018
|
footnote1="Annualized Std -->\n\n"
|
1012
|
-
footnote2="Based on
|
1019
|
+
footnote2="Based on given component securities, constructed "+str(simulation)+" portfolios\n"
|
1013
1020
|
footnote3="Period of observation: "+hstart+" to "+hend
|
1014
1021
|
footnote4="\nSource: sina/eastmoney/stooq, "+str(stoday)
|
1015
1022
|
|
@@ -1465,21 +1472,25 @@ def RandomPortfolios_plot(RandomPortfolios,col_x,col_y,colorbartxt,title_ext, \
|
|
1465
1472
|
|
1466
1473
|
lang = check_language()
|
1467
1474
|
if lang == 'Chinese':
|
1468
|
-
|
1475
|
+
if pname == '': pname='投资组合'
|
1476
|
+
|
1477
|
+
plt.title(pname+": 马科维茨有效(可行)集,基于"+title_ext,fontsize=title_txt_size)
|
1469
1478
|
plt.ylabel(ylabeltxt,fontsize=ylabel_txt_size)
|
1470
1479
|
|
1471
1480
|
import datetime as dt; stoday=dt.date.today()
|
1472
1481
|
footnote1=x_axis_name+" -->\n\n"
|
1473
|
-
footnote2="
|
1482
|
+
footnote2="基于设定的成份证券构造"+str(simulation)+"个投资组合"
|
1474
1483
|
footnote3="\n观察期间:"+hstart+"至"+hend
|
1475
1484
|
footnote4="\n来源: Sina/EM/stooq/FRED, "+str(stoday)
|
1476
1485
|
else:
|
1477
|
-
|
1486
|
+
if pname == '': pname='Investment Portfolio'
|
1487
|
+
|
1488
|
+
plt.title(pname+": Efficient Set, Based on "+title_ext,fontsize=title_txt_size)
|
1478
1489
|
plt.ylabel(ylabeltxt,fontsize=ylabel_txt_size)
|
1479
1490
|
|
1480
1491
|
import datetime as dt; stoday=dt.date.today()
|
1481
1492
|
footnote1=x_axis_name+" -->\n\n"
|
1482
|
-
footnote2="Based on
|
1493
|
+
footnote2="Based on given component securities, constructed "+str(simulation)+" portfolios"
|
1483
1494
|
footnote3="\nPeriod of observation: "+hstart+" to "+hend
|
1484
1495
|
footnote4="\nSource: sina/eastmoney/stooq/FRED, "+str(stoday)
|
1485
1496
|
|
@@ -1514,7 +1525,7 @@ def cvt_portfolio_name(pname,portfolio_returns):
|
|
1514
1525
|
|
1515
1526
|
lang=check_language()
|
1516
1527
|
if lang == "Chinese":
|
1517
|
-
pclist=[pname,'等权重组合','
|
1528
|
+
pclist=[pname,'等权重组合','交易额加权组合','MSR组合','GMVS组合','MSO组合','GML组合', \
|
1518
1529
|
'MAR组合','GMBA组合', 'MTR组合','GMBT组合']
|
1519
1530
|
else:
|
1520
1531
|
pclist=[pname,'Equal-weight','Amount-weight','MSR','GMVS','MSO','GML', \
|