siat 3.2.10__py3-none-any.whl → 3.2.16__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/__init__.py +14 -8
- siat/assets_liquidity.py +8 -8
- siat/capm_beta2.py +1 -1
- siat/common.py +91 -20
- siat/esg.py +2 -2
- siat/grafix.py +1 -1
- siat/holding_risk.py +5 -5
- siat/markowitz.py +10 -10
- siat/markowitz2.py +73 -46
- siat/risk_adjusted_return.py +13 -13
- siat/security_price2.py +2 -2
- siat/security_prices.py +7 -7
- siat/stock.py +1 -1
- siat/translate.py +1 -1
- siat/var_model_validation.py +1 -1
- siat-3.2.16.dist-info/METADATA +125 -0
- {siat-3.2.10.dist-info → siat-3.2.16.dist-info}/RECORD +19 -19
- siat-3.2.10.dist-info/METADATA +0 -40
- {siat-3.2.10.dist-info → siat-3.2.16.dist-info}/WHEEL +0 -0
- {siat-3.2.10.dist-info → siat-3.2.16.dist-info}/top_level.txt +0 -0
siat/__init__.py
CHANGED
@@ -28,15 +28,12 @@ try:
|
|
28
28
|
latest_list=latest_version.split('.')
|
29
29
|
|
30
30
|
newest=True
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
elif current_list[2] < latest_list[2]:
|
36
|
-
newest=False
|
37
|
-
else:
|
38
|
-
pass
|
31
|
+
for i in range(3):
|
32
|
+
#print(i)
|
33
|
+
if int(current_list[i]) < int(latest_list[i]):
|
34
|
+
newest=False
|
39
35
|
|
36
|
+
"""
|
40
37
|
if not newest:
|
41
38
|
print("The latest version of siat is",latest_version,'\n')
|
42
39
|
print("*** If you expect to upgrade siat in Anaconda Prompt, use the instruction below:")
|
@@ -52,6 +49,15 @@ try:
|
|
52
49
|
|
53
50
|
print("If you have done any of the above, restart the Python (eg. restarting the kernel)")
|
54
51
|
print("Provided you still need additional help, please contact wdehong2000@163.com")
|
52
|
+
"""
|
53
|
+
if not newest:
|
54
|
+
#print("The latest version of siat is",latest_version,'\n')
|
55
|
+
print("Now there is a newer version of siat",latest_version,'\n')
|
56
|
+
print("*** How to upgrade siat?")
|
57
|
+
print("Upgrade directly from official source? use command: upgrade_siat()")
|
58
|
+
print("Upgrade from Tsinghua? use command: upgrade_siat(alternative='tsinghua')")
|
59
|
+
print("Upgrade from Alibaba? use command: upgrade_siat(alternative='alibaba')")
|
60
|
+
|
55
61
|
except:
|
56
62
|
pass
|
57
63
|
|
siat/assets_liquidity.py
CHANGED
@@ -111,7 +111,7 @@ def roll_spread_portfolio(portfolio,start,end,printout=True):
|
|
111
111
|
'-'+str(sp.index[-1].day)
|
112
112
|
print("\n===== 投资组合的流动性风险 =====")
|
113
113
|
|
114
|
-
_,_,tickerlist,sharelist=decompose_portfolio(portfolio)
|
114
|
+
_,_,tickerlist,sharelist,ticker_type=decompose_portfolio(portfolio)
|
115
115
|
if len(tickerlist)==1:
|
116
116
|
product=str(ticker_name(tickerlist,'bond'))
|
117
117
|
else:
|
@@ -192,7 +192,7 @@ def amihud_illiquidity_portfolio(portfolio,start,end,printout=True):
|
|
192
192
|
'-'+str(sp.index[-1].day)
|
193
193
|
print("\n===== 投资组合的流动性风险 =====")
|
194
194
|
|
195
|
-
_,_,tickerlist,sharelist=decompose_portfolio(portfolio)
|
195
|
+
_,_,tickerlist,sharelist,ticker_type=decompose_portfolio(portfolio)
|
196
196
|
if len(tickerlist)==1:
|
197
197
|
product=str(ticker_name(tickerlist,'bond'))
|
198
198
|
else:
|
@@ -338,7 +338,7 @@ def ps_liquidity_portfolio(portfolio,start,end,printout=True):
|
|
338
338
|
'-'+str(sp.index[-1].day)
|
339
339
|
print("\n===== 投资组合的流动性风险 =====")
|
340
340
|
|
341
|
-
_,_,tickerlist,sharelist=decompose_portfolio(portfolio)
|
341
|
+
_,_,tickerlist,sharelist,ticker_type=decompose_portfolio(portfolio)
|
342
342
|
if len(tickerlist)==1:
|
343
343
|
product=str(ticker_name(tickerlist,'bond'))
|
344
344
|
else:
|
@@ -423,7 +423,7 @@ def plot_liquidity_monthly(portfolio,start,end,liquidity_type):
|
|
423
423
|
ylabeltxt=ectranslate(liquidity_type)
|
424
424
|
titletxt="证券流动性风险的月度指标"
|
425
425
|
|
426
|
-
_,_,tickerlist,sharelist=decompose_portfolio(portfolio)
|
426
|
+
_,_,tickerlist,sharelist,ticker_type=decompose_portfolio(portfolio)
|
427
427
|
if len(tickerlist)==1:
|
428
428
|
product=str(ticker_name(tickerlist,'bond'))
|
429
429
|
else:
|
@@ -521,7 +521,7 @@ def plot_liquidity_annual(portfolio,start,end,liquidity_type):
|
|
521
521
|
ylabeltxt=ectranslate(liquidity_type)
|
522
522
|
titletxt="证券流动性风险的年度指标"
|
523
523
|
|
524
|
-
_,_,tickerlist,sharelist=decompose_portfolio(portfolio)
|
524
|
+
_,_,tickerlist,sharelist,ticker_type=decompose_portfolio(portfolio)
|
525
525
|
if len(tickerlist)==1:
|
526
526
|
product=str(ticker_name(tickerlist,'bond'))
|
527
527
|
else:
|
@@ -565,7 +565,7 @@ def draw_liquidity(liqs):
|
|
565
565
|
ylabeltxt=ectranslate(liqs['Type'][0])
|
566
566
|
titletxt="证券流动性风险的滚动趋势"
|
567
567
|
|
568
|
-
_,_,tickerlist,sharelist=decompose_portfolio(portfolio)
|
568
|
+
_,_,tickerlist,sharelist,ticker_type=decompose_portfolio(portfolio)
|
569
569
|
if len(tickerlist)==1:
|
570
570
|
product=str(ticker_name(tickerlist))
|
571
571
|
else:
|
@@ -721,12 +721,12 @@ def compare_liquidity_rolling(portfolio1,portfolio2,start,end,liquidity_type,win
|
|
721
721
|
ylabeltxt=ectranslate(liquidity_type)
|
722
722
|
titletxt="证券流动性风险走势比较"
|
723
723
|
|
724
|
-
_,_,tickerlist1,sharelist1=decompose_portfolio(portfolio1)
|
724
|
+
_,_,tickerlist1,sharelist1,ticker_type1=decompose_portfolio(portfolio1)
|
725
725
|
if len(tickerlist1)==1:
|
726
726
|
product1=str(ticker_name(tickerlist1,'bond'))
|
727
727
|
else:
|
728
728
|
product1=str(ticker_name(tickerlist1,'bond'))+',持仓'+str(sharelist1)
|
729
|
-
_,_,tickerlist2,sharelist2=decompose_portfolio(portfolio2)
|
729
|
+
_,_,tickerlist2,sharelist2,ticker_type2=decompose_portfolio(portfolio2)
|
730
730
|
if len(tickerlist2)==1:
|
731
731
|
product2=str(ticker_name(tickerlist2,'bond'))
|
732
732
|
else:
|
siat/capm_beta2.py
CHANGED
@@ -119,7 +119,7 @@ def regression_capm(ticker,start2,end, \
|
|
119
119
|
mktidx=get_market_index_code(ticker)
|
120
120
|
"""
|
121
121
|
if isinstance(ticker,dict):
|
122
|
-
_,mktidx,pftickerlist,_=decompose_portfolio(ticker)
|
122
|
+
_,mktidx,pftickerlist,_,ticker_type=decompose_portfolio(ticker)
|
123
123
|
if 'auto' in mktidx.lower():
|
124
124
|
mktidx=get_market_index_code(pftickerlist[0])
|
125
125
|
else:
|
siat/common.py
CHANGED
@@ -432,6 +432,15 @@ if __name__ =="__main__":
|
|
432
432
|
portfolio={'Market':('US','^GSPC'),'EDU':0.4,'TAL':0.3,'TEDU':0.2}
|
433
433
|
|
434
434
|
portfolio={'Market':('China','000001.SS','股债基组合'),'600519.SS':50,'sh010504':150,'sh010504':300}
|
435
|
+
|
436
|
+
Market={'Market':('China','000300.SS','股债基组合')}
|
437
|
+
Stocks={'600519.SS':0.4,#股票:贵州茅台
|
438
|
+
'sh010504':[0.3,'bond'],#05国债⑷
|
439
|
+
'010504':('fund',0.2),#招商稳兴混合C基金
|
440
|
+
}
|
441
|
+
portfolio=dict(Market,**Stocks)
|
442
|
+
|
443
|
+
decompose_portfolio(portfolio)
|
435
444
|
|
436
445
|
def decompose_portfolio(portfolio):
|
437
446
|
"""
|
@@ -439,6 +448,9 @@ def decompose_portfolio(portfolio):
|
|
439
448
|
投资组合的结构:{'Market':('US','^GSPC'),'AAPL':0.5,'MSFT':0.3,'IBM':0.2}
|
440
449
|
输入:投资组合
|
441
450
|
输出:市场,市场指数,股票代码列表和份额列表
|
451
|
+
|
452
|
+
注意:字典中相同的键会被合并为一个
|
453
|
+
新功能:分辨股票、债券和基金
|
442
454
|
"""
|
443
455
|
#从字典中提取信息
|
444
456
|
keylist=list(portfolio.keys()) #注意:字典中相同的键会被合并为一个
|
@@ -452,13 +464,49 @@ def decompose_portfolio(portfolio):
|
|
452
464
|
plist=plist+[value]
|
453
465
|
stocklist=slist[1:]
|
454
466
|
portionlist=plist[1:]
|
467
|
+
|
468
|
+
#识别证券类别
|
469
|
+
stype_list=['auto','stock','bond','fund']
|
470
|
+
ticker_type=[]
|
471
|
+
new_portionlist=[]
|
472
|
+
for p in portionlist:
|
473
|
+
if isinstance(p,int) or isinstance(p,float):
|
474
|
+
ticker_type=ticker_type+['auto']
|
475
|
+
new_portionlist=new_portionlist+[p]
|
476
|
+
elif isinstance(p,list) or isinstance(p,tuple):
|
477
|
+
ptype=False; pportion=False
|
478
|
+
p0=p[0]; p1=p[1]
|
479
|
+
|
480
|
+
if isinstance(p0,int) or isinstance(p0,float):
|
481
|
+
pportion=True
|
482
|
+
new_portionlist=new_portionlist+[p0]
|
483
|
+
elif isinstance(p0,str):
|
484
|
+
ptype=True
|
485
|
+
if p0 not in stype_list:
|
486
|
+
p0='auto'
|
487
|
+
ticker_type=ticker_type+[p0]
|
488
|
+
|
489
|
+
if isinstance(p1,int) or isinstance(p1,float):
|
490
|
+
pportion=True
|
491
|
+
new_portionlist=new_portionlist+[p1]
|
492
|
+
elif isinstance(p1,str):
|
493
|
+
ptype=True
|
494
|
+
if p1 not in stype_list:
|
495
|
+
p1='auto'
|
496
|
+
ticker_type=ticker_type+[p1]
|
497
|
+
|
498
|
+
#未能确定
|
499
|
+
if ptype==False:
|
500
|
+
ticker_type=ticker_type+['auto']
|
501
|
+
if pportion==False:
|
502
|
+
new_portionlist=new_portionlist+[0]
|
503
|
+
|
455
504
|
|
456
|
-
return scope,mktidx,stocklist,
|
505
|
+
return scope,mktidx,stocklist,new_portionlist,ticker_type
|
457
506
|
|
458
507
|
if __name__=='__main__':
|
459
508
|
portfolio1={'Market':('US','^GSPC'),'EDU':0.4,'TAL':0.3,'TEDU':0.2}
|
460
|
-
|
461
|
-
_,_,tickerlist,sharelist=decompose_portfolio(portfolio1)
|
509
|
+
decompose_portfolio(portfolio1)
|
462
510
|
|
463
511
|
def portfolio_name(portfolio):
|
464
512
|
"""
|
@@ -497,7 +545,7 @@ def isinstance_portfolio(portfolio):
|
|
497
545
|
result=True
|
498
546
|
|
499
547
|
try:
|
500
|
-
scope,mktidx,tickerlist,sharelist=decompose_portfolio(portfolio)
|
548
|
+
scope,mktidx,tickerlist,sharelist,ticker_type=decompose_portfolio(portfolio)
|
501
549
|
except:
|
502
550
|
result=False
|
503
551
|
|
@@ -634,7 +682,7 @@ def sample_selection(df,start,end):
|
|
634
682
|
|
635
683
|
if __name__=='__main__':
|
636
684
|
portfolio={'Market':('US','^GSPC'),'AAPL':1.0}
|
637
|
-
market,mktidx,tickerlist,sharelist=decompose_portfolio(portfolio)
|
685
|
+
market,mktidx,tickerlist,sharelist,_=decompose_portfolio(portfolio)
|
638
686
|
start='2020-1-1'; end='2020-3-31'
|
639
687
|
pfdf=get_portfolio_prices(tickerlist,sharelist,start,end)
|
640
688
|
start2='2020-1-10'; end2='2020-3-18'
|
@@ -3560,7 +3608,7 @@ def ticker_type_preprocess_1portfolio(ticker,ticker_type='auto'):
|
|
3560
3608
|
功能:根据ticker情况(单个投资组合)处理ticker_type,使之与ticker对应
|
3561
3609
|
"""
|
3562
3610
|
if isinstance(ticker,dict):
|
3563
|
-
_,_,tickerlist,_=decompose_portfolio(ticker)
|
3611
|
+
_,_,tickerlist,_,ticker_type=decompose_portfolio(ticker)
|
3564
3612
|
if len(tickerlist)==1:
|
3565
3613
|
ticker_type9=ticker_type_preprocess_1str(tickerlist[0],ticker_type)
|
3566
3614
|
else:
|
@@ -3718,7 +3766,7 @@ if __name__=='__main__':
|
|
3718
3766
|
|
3719
3767
|
def upgrade_siat(module_list=['siat','akshare','pandas','pandas_datareader', \
|
3720
3768
|
'yfinance','yahooquery','urllib3','tabulate','twine','mplfinance','openpyxl'], \
|
3721
|
-
pipcmd="pip install --upgrade"):
|
3769
|
+
pipcmd="pip install --upgrade",alternative=""):
|
3722
3770
|
"""
|
3723
3771
|
功能:一次性升级siat及其相关插件
|
3724
3772
|
|
@@ -3727,7 +3775,8 @@ def upgrade_siat(module_list=['siat','akshare','pandas','pandas_datareader', \
|
|
3727
3775
|
或python -m pip install --upgrade pip
|
3728
3776
|
如果上述方法不适用,您可能需要重新安装Python,并确保在安装过程中选中了“Add Python to PATH”
|
3729
3777
|
"""
|
3730
|
-
print("
|
3778
|
+
print("Upgrading siat and related modules, please wait ... ...")
|
3779
|
+
|
3731
3780
|
#获取系统目录
|
3732
3781
|
import sys
|
3733
3782
|
syspath=sys.path
|
@@ -3757,34 +3806,56 @@ def upgrade_siat(module_list=['siat','akshare','pandas','pandas_datareader', \
|
|
3757
3806
|
#生成pip命令字符串前半段,仅缺插件名
|
3758
3807
|
cmdstr=sp+sep_flag+'Scripts'+sep_flag+pipcmd+' '
|
3759
3808
|
|
3809
|
+
#检查是否使用镜像源
|
3810
|
+
if alternative == "":
|
3811
|
+
alter_source=''
|
3812
|
+
elif alternative == "tsinghua":
|
3813
|
+
alter_source="-i https://pypi.tuna.tsinghua.edu.cn/simple/"
|
3814
|
+
elif alternative in ["alibaba","ali","aliyun"]:
|
3815
|
+
alter_source="-i https://mirrors.aliyun.com/pypi/simple/"
|
3816
|
+
elif alternative == "bfsu":
|
3817
|
+
alter_source="-i https://mirrors.bfsu.edu.cn/pypi/"
|
3818
|
+
elif alternative == "baidu":
|
3819
|
+
alter_source="-i https://mirror.baidu.com/pypi/simple/"
|
3820
|
+
elif alternative == "tencent":
|
3821
|
+
alter_source="-i https://mirrors.cloud.tencent.com/pypi/simple/"
|
3822
|
+
else:
|
3823
|
+
alter_source="-i https://mirrors.aliyun.com/pypi/simple/"
|
3824
|
+
|
3760
3825
|
#逐个升级插件
|
3761
3826
|
import subprocess
|
3762
3827
|
fail_list=[]
|
3763
|
-
|
3828
|
+
|
3829
|
+
"""
|
3830
|
+
tqdm进度条:
|
3831
|
+
100%|██████████| 9/11 [02:18<02:30, 12.59s/it]
|
3832
|
+
9/11:一共11项,正在进行第9项
|
3833
|
+
02:18<02:30:已经花费时间02:18,预计花费时间02:30
|
3834
|
+
12.59s/it:平均每项花费时间12.59秒
|
3835
|
+
"""
|
3836
|
+
from tqdm import tqdm
|
3837
|
+
for m in tqdm(module_list):
|
3764
3838
|
#print("Upgrading",m,"... ...",end='')
|
3765
|
-
print_progress_percent2(m,module_list,steps=5,leading_blanks=2)
|
3839
|
+
#print_progress_percent2(m,module_list,steps=5,leading_blanks=2)
|
3766
3840
|
|
3767
|
-
|
3841
|
+
if alternative == "":
|
3842
|
+
cmdstr1=cmdstr+m
|
3843
|
+
else:
|
3844
|
+
cmdstr1=cmdstr+m+' '+alter_source
|
3768
3845
|
#print(cmdstr1)
|
3846
|
+
|
3769
3847
|
#proc=subprocess.run(cmdstr1.split(' '),stdout=subprocess.PIPE)
|
3770
3848
|
proc=subprocess.run(cmdstr1.split(' '))
|
3771
3849
|
rcode=proc.returncode
|
3772
3850
|
if rcode !=0: fail_list=fail_list+[m]
|
3773
|
-
|
3774
|
-
"""
|
3775
|
-
if rcode==0: result='done✓'
|
3776
|
-
else: result='FAILed❌, try again manually'
|
3777
|
-
print(result)
|
3778
|
-
"""
|
3779
3851
|
|
3780
3852
|
if len(fail_list) == 0:
|
3781
|
-
print("
|
3853
|
+
print("All specified modules are successfully upgraded!")
|
3782
3854
|
else:
|
3783
|
-
print("
|
3855
|
+
print("All specified modules are successfully upgraded except",end='')
|
3784
3856
|
print_list(fail_list,leading_blanks=1)
|
3785
3857
|
|
3786
3858
|
return
|
3787
|
-
#==============================================================================
|
3788
3859
|
|
3789
3860
|
def df_index_timezone_remove(df):
|
3790
3861
|
"""
|
siat/esg.py
CHANGED
@@ -297,7 +297,7 @@ def portfolio_esg(portfolio):
|
|
297
297
|
企业最新的可持续性发展数据,数据框
|
298
298
|
"""
|
299
299
|
#解构投资组合
|
300
|
-
_,_,stocklist,_=decompose_portfolio(portfolio)
|
300
|
+
_,_,stocklist,_,ticker_type=decompose_portfolio(portfolio)
|
301
301
|
|
302
302
|
#抓取数据
|
303
303
|
try:
|
@@ -439,7 +439,7 @@ def portfolio_esg2(portfolio):
|
|
439
439
|
企业最新的可持续性发展数据,数据框
|
440
440
|
"""
|
441
441
|
#解构投资组合
|
442
|
-
_,_,stocklist,_=decompose_portfolio(portfolio)
|
442
|
+
_,_,stocklist,_,ticker_type=decompose_portfolio(portfolio)
|
443
443
|
|
444
444
|
#抓取数据
|
445
445
|
try:
|
siat/grafix.py
CHANGED
@@ -1121,7 +1121,7 @@ def draw_lines(df0,y_label,x_label,axhline_value,axhline_label,title_txt, \
|
|
1121
1121
|
|
1122
1122
|
#插值平滑
|
1123
1123
|
if smooth:
|
1124
|
-
print(" Rendering graphics ...")
|
1124
|
+
#print(" Rendering graphics ...")
|
1125
1125
|
try:
|
1126
1126
|
df=df_smooth_manual(df0,resample_freq=resample_freq)
|
1127
1127
|
except:
|
siat/holding_risk.py
CHANGED
@@ -87,7 +87,7 @@ def get_portfolio_prices0(portfolio,fromdate,todate):
|
|
87
87
|
"""
|
88
88
|
|
89
89
|
#解构投资组合
|
90
|
-
_,mktidx,tickerlist,sharelist=decompose_portfolio(portfolio)
|
90
|
+
_,mktidx,tickerlist,sharelist,ticker_type=decompose_portfolio(portfolio)
|
91
91
|
|
92
92
|
#检查股票列表个数与份额列表个数是否一致
|
93
93
|
if len(tickerlist) != len(sharelist):
|
@@ -562,7 +562,7 @@ def get_VaR_portfolio(portfolio,today,future_days=1,alpha=0.99, \
|
|
562
562
|
|
563
563
|
#输出VaR金额和比率
|
564
564
|
print("\n===== 投资组合的在险价值VaR =====")
|
565
|
-
_,_,tickerlist,sharelist=decompose_portfolio(portfolio)
|
565
|
+
_,_,tickerlist,sharelist,ticker_type=decompose_portfolio(portfolio)
|
566
566
|
print("成分股列表 :",tickerlist)
|
567
567
|
print("成分股的配置:",sharelist)
|
568
568
|
print("当前日期 :",today)
|
@@ -686,7 +686,7 @@ def get_ES_portfolio(portfolio,today,future_days=1,alpha=0.99, \
|
|
686
686
|
|
687
687
|
#输出ES金额和比率
|
688
688
|
print("\n===== 投资组合的预期不足ES =====")
|
689
|
-
_,_,tickerlist,sharelist=decompose_portfolio(portfolio)
|
689
|
+
_,_,tickerlist,sharelist,ticker_type=decompose_portfolio(portfolio)
|
690
690
|
print("成分股列表 :",tickerlist)
|
691
691
|
print("成分股配置 :",sharelist)
|
692
692
|
print("当前日期 :",today)
|
@@ -770,7 +770,7 @@ def portfolio_ret_Normality_SW(portfolio,fromdate,todate, \
|
|
770
770
|
|
771
771
|
if not printout: return W,p_value,S,K
|
772
772
|
|
773
|
-
_,_,tickerlist,sharelist=decompose_portfolio(portfolio)
|
773
|
+
_,_,tickerlist,sharelist,ticker_type=decompose_portfolio(portfolio)
|
774
774
|
print("*** Shapiro-Wilk Normality Test ***")
|
775
775
|
print(" Stock(s):",tickerlist)
|
776
776
|
print(" Holding proportion:",sharelist)
|
@@ -812,7 +812,7 @@ def portfolio_rets_curve(portfolio,fromdate,todate):
|
|
812
812
|
num=len(prices)
|
813
813
|
rets=prices['Ret']
|
814
814
|
W,p_value,S,K=ret_Normality_SW(rets)
|
815
|
-
_,_,tickerlist,sharelist=decompose_portfolio(portfolio)
|
815
|
+
_,_,tickerlist,sharelist,ticker_type=decompose_portfolio(portfolio)
|
816
816
|
#计算收益率的均值和标准差
|
817
817
|
mu=rets.mean()
|
818
818
|
sigma=rets.std()
|
siat/markowitz.py
CHANGED
@@ -250,7 +250,7 @@ def portfolio_cumret(portfolio,thedate,pastyears=1, \
|
|
250
250
|
"""
|
251
251
|
print("\n Searching for portfolio info, which may take time ...")
|
252
252
|
# 解构投资组合
|
253
|
-
scope,_,tickerlist,sharelist0=decompose_portfolio(portfolio)
|
253
|
+
scope,_,tickerlist,sharelist0,ticker_type=decompose_portfolio(portfolio)
|
254
254
|
pname=portfolio_name(portfolio)
|
255
255
|
|
256
256
|
#如果持仓份额总数不为1,则将其转换为总份额为1
|
@@ -934,7 +934,7 @@ def portfolio_es(pf_info,simulation=50000):
|
|
934
934
|
"""
|
935
935
|
[[portfolio,thedate,stock_return,_,_],_]=pf_info
|
936
936
|
pname=portfolio_name(portfolio)
|
937
|
-
_,_,tickerlist,_=decompose_portfolio(portfolio)
|
937
|
+
_,_,tickerlist,_,ticker_type=decompose_portfolio(portfolio)
|
938
938
|
|
939
939
|
#取出观察期
|
940
940
|
hstart0=stock_return.index[0]; hstart=str(hstart0.date())
|
@@ -1050,7 +1050,7 @@ def portfolio_es_sharpe(pf_info,simulation=1000,rate_period='1Y',rate_type='trea
|
|
1050
1050
|
|
1051
1051
|
[[portfolio,thedate,stock_return0,rf_df,_],_]=pf_info
|
1052
1052
|
pname=portfolio_name(portfolio)
|
1053
|
-
scope,_,tickerlist,_=decompose_portfolio(portfolio)
|
1053
|
+
scope,_,tickerlist,_,ticker_type=decompose_portfolio(portfolio)
|
1054
1054
|
|
1055
1055
|
#取出观察期
|
1056
1056
|
hstart0=stock_return0.index[0]; hstart=str(hstart0.date())
|
@@ -1137,7 +1137,7 @@ def portfolio_es_sortino(pf_info,simulation=1000,rate_period='1Y',rate_type='tre
|
|
1137
1137
|
|
1138
1138
|
[[portfolio,thedate,stock_return0,rf_df,_],_]=pf_info
|
1139
1139
|
pname=portfolio_name(portfolio)
|
1140
|
-
scope,_,tickerlist,_=decompose_portfolio(portfolio)
|
1140
|
+
scope,_,tickerlist,_,ticker_type=decompose_portfolio(portfolio)
|
1141
1141
|
|
1142
1142
|
#取出观察期
|
1143
1143
|
hstart0=stock_return0.index[0]; hstart=str(hstart0.date())
|
@@ -1230,7 +1230,7 @@ def portfolio_es_alpha(pf_info,simulation=1000,rate_period='1Y',rate_type='treas
|
|
1230
1230
|
|
1231
1231
|
[[portfolio,thedate,stock_return0,rf_df,_],_]=pf_info
|
1232
1232
|
pname=portfolio_name(portfolio)
|
1233
|
-
scope,mktidx,tickerlist,_=decompose_portfolio(portfolio)
|
1233
|
+
scope,mktidx,tickerlist,_,ticker_type=decompose_portfolio(portfolio)
|
1234
1234
|
|
1235
1235
|
#取出观察期
|
1236
1236
|
hstart0=stock_return0.index[0]; hstart=str(hstart0.date())
|
@@ -1338,7 +1338,7 @@ def portfolio_es_treynor(pf_info,simulation=1000,rate_period='1Y',rate_type='tre
|
|
1338
1338
|
|
1339
1339
|
[[portfolio,_,stock_return0,rf_df,_],_]=pf_info
|
1340
1340
|
pname=portfolio_name(portfolio)
|
1341
|
-
scope,mktidx,tickerlist,_=decompose_portfolio(portfolio)
|
1341
|
+
scope,mktidx,tickerlist,_,ticker_type=decompose_portfolio(portfolio)
|
1342
1342
|
|
1343
1343
|
#取出观察期
|
1344
1344
|
hstart0=stock_return0.index[0]; hstart=str(hstart0.date())
|
@@ -1754,7 +1754,7 @@ def portfolio_optimize_rar(es_info,col_ratio,col_y,col_x,name_hiret,name_lorisk,
|
|
1754
1754
|
"""
|
1755
1755
|
#解析传入的数据
|
1756
1756
|
[[[portfolio,thedate,stock_return,_,_],[StockReturns,_,_,_]],RandomPortfolios]=es_info
|
1757
|
-
_,_,tickerlist,_=decompose_portfolio(portfolio)
|
1757
|
+
_,_,tickerlist,_,ticker_type=decompose_portfolio(portfolio)
|
1758
1758
|
numstocks=len(tickerlist)
|
1759
1759
|
pname=portfolio_name(portfolio)
|
1760
1760
|
|
@@ -1887,7 +1887,7 @@ def portfolio_optimize_strategy(pf_info,ratio='sharpe',simulation=50000,RF=False
|
|
1887
1887
|
portfolio_expectation(hi_name,pf_info,hiret_weights)
|
1888
1888
|
|
1889
1889
|
if MSR_return:
|
1890
|
-
scope,mktidx,tickerlist,_=decompose_portfolio(portfolio)
|
1890
|
+
scope,mktidx,tickerlist,_,ticker_type=decompose_portfolio(portfolio)
|
1891
1891
|
hwdf=pd.DataFrame(hiret_weights)
|
1892
1892
|
hwdft=hwdf.T
|
1893
1893
|
hwdft.columns=tickerlist
|
@@ -2289,7 +2289,7 @@ def describe_portfolio(portfolio):
|
|
2289
2289
|
输出:市场,市场指数,股票代码列表和份额列表
|
2290
2290
|
"""
|
2291
2291
|
|
2292
|
-
scope,mktidx,tickerlist,sharelist=decompose_portfolio(portfolio)
|
2292
|
+
scope,mktidx,tickerlist,sharelist,ticker_type=decompose_portfolio(portfolio)
|
2293
2293
|
pname=portfolio_name(portfolio)
|
2294
2294
|
|
2295
2295
|
print("*** 投资组合信息:",pname)
|
@@ -2321,7 +2321,7 @@ def portfolio_drop(portfolio,last=0,droplist=[],new_name=''):
|
|
2321
2321
|
"""
|
2322
2322
|
功能:删除最后几个成分股
|
2323
2323
|
"""
|
2324
|
-
scope,mktidx,tickerlist,sharelist=decompose_portfolio(portfolio)
|
2324
|
+
scope,mktidx,tickerlist,sharelist,ticker_type=decompose_portfolio(portfolio)
|
2325
2325
|
pname=portfolio_name(portfolio)
|
2326
2326
|
|
2327
2327
|
if not (last ==0):
|
siat/markowitz2.py
CHANGED
@@ -247,24 +247,35 @@ if __name__=='__main__':
|
|
247
247
|
}
|
248
248
|
portfolio=dict(Market,**porkbig,**porksmall)
|
249
249
|
|
250
|
-
thedate='2024-5-30'
|
251
|
-
pastyears=1
|
252
|
-
printout=True
|
253
|
-
graph=False
|
254
|
-
|
255
250
|
#测试3
|
256
|
-
Market={'Market':('China','000300.SS','
|
257
|
-
Stocks={'
|
258
|
-
'
|
259
|
-
'
|
260
|
-
'300207.SZ':0.1,#欣旺达
|
251
|
+
Market={'Market':('China','000300.SS','股债基组合')}
|
252
|
+
Stocks={'600519.SS':0.3,#股票:贵州茅台
|
253
|
+
'sh010504':[0.5,'bond'],#05国债⑷
|
254
|
+
'010504.SS':('fund',0.2),#招商稳兴混合C基金
|
261
255
|
}
|
262
256
|
portfolio=dict(Market,**Stocks)
|
263
257
|
|
258
|
+
printout=True
|
259
|
+
graph=False
|
260
|
+
|
264
261
|
indicator='Adj Close'
|
265
262
|
adjust='qfq'; source='auto'; ticker_type='bond'
|
266
263
|
thedate='2024-6-19'
|
267
264
|
pastyears=2
|
265
|
+
|
266
|
+
|
267
|
+
#测试3
|
268
|
+
Market={'Market':('China','000300.SS','股债基组合')}
|
269
|
+
Stocks={'600519.SS':0.3,#股票:贵州茅台
|
270
|
+
'sh010504':[0.5,'bond'],#05国债⑷
|
271
|
+
'010504.SS':('fund',0.2),#招商稳兴混合C基金
|
272
|
+
}
|
273
|
+
portfolio=dict(Market,**Stocks)
|
274
|
+
|
275
|
+
indicator='Close'
|
276
|
+
adjust=''; source='auto'; ticker_type='auto'
|
277
|
+
thedate='2024-6-19'
|
278
|
+
pastyears=1
|
268
279
|
printout=True
|
269
280
|
graph=False
|
270
281
|
|
@@ -312,7 +323,7 @@ def portfolio_build(portfolio,thedate='default',pastyears=1, \
|
|
312
323
|
|
313
324
|
print("\n Searching for portfolio info, which may take time ...")
|
314
325
|
# 解构投资组合
|
315
|
-
scope,_,tickerlist,sharelist0=decompose_portfolio(portfolio)
|
326
|
+
scope,_,tickerlist,sharelist0,ticker_type=decompose_portfolio(portfolio)
|
316
327
|
pname=portfolio_name(portfolio)
|
317
328
|
|
318
329
|
#如果持仓份额总数不为1,则将其转换为总份额为1
|
@@ -440,7 +451,7 @@ def portfolio_build(portfolio,thedate='default',pastyears=1, \
|
|
440
451
|
|
441
452
|
title_txt=text_lang("投资组合: 日收益率的变化趋势","Investment Portfolio: Daily Return")
|
442
453
|
ylabel_txt=text_lang("日收益率","Daily Return")
|
443
|
-
source_txt=text_lang("来源:
|
454
|
+
source_txt=text_lang("来源: 综合新浪/东方财富/stooq/雅虎等, ","Source: sina/eastmoney/stooq, ")
|
444
455
|
|
445
456
|
plt.title(title_txt)
|
446
457
|
plt.ylabel(ylabel_txt)
|
@@ -460,7 +471,7 @@ def portfolio_build(portfolio,thedate='default',pastyears=1, \
|
|
460
471
|
|
461
472
|
titletxt=text_lang("投资组合: 持有收益率的变化趋势","Investment Portfolio: Holding Return")
|
462
473
|
ylabeltxt=text_lang("持有收益率","Holding Return")
|
463
|
-
xlabeltxt1=text_lang("来源:
|
474
|
+
xlabeltxt1=text_lang("来源: 综合新浪/东方财富/stooq/雅虎等, ","Source: sina/eastmoney/stooq, ")
|
464
475
|
xlabeltxt=xlabeltxt1+str(stoday)
|
465
476
|
|
466
477
|
#绘制持有收益率曲线
|
@@ -476,22 +487,29 @@ def portfolio_build(portfolio,thedate='default',pastyears=1, \
|
|
476
487
|
StockReturns['Portfolio_EW']=stock_return.mul(portfolio_weights_ew,axis=1).sum(axis=1)
|
477
488
|
#..........................................................................
|
478
489
|
|
479
|
-
#
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
490
|
+
# 创建交易额加权组合:按照成交金额计算期间内交易额均值。债券和基金信息中无交易量!
|
491
|
+
if ('bond' not in ticker_type) and ('fund' not in ticker_type):
|
492
|
+
tamount=prices['Close']*prices['Volume']
|
493
|
+
tamountlist=tamount.mean(axis=0) #求列的均值
|
494
|
+
tamountlist_array = np.array(tamountlist)
|
495
|
+
# 计算成交金额权重
|
496
|
+
portfolio_weights_lw = tamountlist_array / np.sum(tamountlist_array)
|
497
|
+
# 计算成交金额加权的组合收益
|
498
|
+
StockReturns['Portfolio_LW'] = stock_return.mul(portfolio_weights_lw, axis=1).sum(axis=1)
|
487
499
|
|
488
500
|
#绘制累计收益率对比曲线
|
489
501
|
title_txt=text_lang("投资组合策略:业绩对比","Portfolio Strategies: Performance Comparison")
|
490
502
|
Portfolio_EW_txt=text_lang("等权重策略","Equal-weight")
|
491
|
-
|
503
|
+
if ('bond' not in ticker_type) and ('fund' not in ticker_type):
|
504
|
+
Portfolio_LW_txt=text_lang("交易额加权策略","Amount-weight")
|
492
505
|
|
493
|
-
|
494
|
-
|
506
|
+
name_list=['Portfolio', 'Portfolio_EW', 'Portfolio_LW']
|
507
|
+
label_list=[pname, Portfolio_EW_txt, Portfolio_LW_txt]
|
508
|
+
else:
|
509
|
+
name_list=['Portfolio', 'Portfolio_EW']
|
510
|
+
label_list=[pname, Portfolio_EW_txt]
|
511
|
+
|
512
|
+
|
495
513
|
titletxt=title_txt
|
496
514
|
|
497
515
|
#绘制各个投资组合的持有收益率曲线
|
@@ -501,9 +519,11 @@ def portfolio_build(portfolio,thedate='default',pastyears=1, \
|
|
501
519
|
#打印各个投资组合的持股比例
|
502
520
|
member_returns=stock_return
|
503
521
|
if printout:
|
504
|
-
portfolio_expectation_universal(pname,member_returns,portfolio_weights,member_prices)
|
505
|
-
portfolio_expectation_universal(Portfolio_EW_txt,member_returns,portfolio_weights_ew,member_prices)
|
506
|
-
|
522
|
+
portfolio_expectation_universal(pname,member_returns,portfolio_weights,member_prices,ticker_type)
|
523
|
+
portfolio_expectation_universal(Portfolio_EW_txt,member_returns,portfolio_weights_ew,member_prices,ticker_type)
|
524
|
+
|
525
|
+
if ('bond' not in ticker_type) and ('fund' not in ticker_type):
|
526
|
+
portfolio_expectation_universal(Portfolio_LW_txt,member_returns,portfolio_weights_lw,member_prices,ticker_type)
|
507
527
|
|
508
528
|
#返回投资组合的综合信息
|
509
529
|
member_returns=stock_return
|
@@ -516,8 +536,14 @@ def portfolio_build(portfolio,thedate='default',pastyears=1, \
|
|
516
536
|
if printout:
|
517
537
|
portfolio_ranks(portfolio_returns,pname)
|
518
538
|
|
519
|
-
|
520
|
-
|
539
|
+
#
|
540
|
+
if ('bond' not in ticker_type) and ('fund' not in ticker_type):
|
541
|
+
return [[portfolio,thedate,member_returns,rf_df,member_prices], \
|
542
|
+
[portfolio_returns,portfolio_weights,portfolio_weights_ew,portfolio_weights_lw]]
|
543
|
+
else:
|
544
|
+
return [[portfolio,thedate,member_returns,rf_df,member_prices], \
|
545
|
+
[portfolio_returns,portfolio_weights,portfolio_weights_ew,None]]
|
546
|
+
|
521
547
|
|
522
548
|
if __name__=='__main__':
|
523
549
|
X=portfolio_build(portfolio,'2021-9-30')
|
@@ -656,10 +682,10 @@ if __name__=='__main__':
|
|
656
682
|
portfolio=dict(Market,**Stocks1,**Stocks2)
|
657
683
|
pf_info=portfolio_expret(portfolio,'2019-12-31')
|
658
684
|
|
659
|
-
|
685
|
+
portfolio_expectation_original(pf_info)
|
660
686
|
|
661
687
|
#==============================================================================
|
662
|
-
def portfolio_expectation_universal(pname,member_returns,portfolio_weights,member_prices):
|
688
|
+
def portfolio_expectation_universal(pname,member_returns,portfolio_weights,member_prices,ticker_type):
|
663
689
|
"""
|
664
690
|
功能:计算给定成份股收益率和持股权重的投资组合年均收益率和标准差
|
665
691
|
输入:投资组合名称,成份股历史收益率数据表,投资组合权重series
|
@@ -704,12 +730,12 @@ def portfolio_expectation_universal(pname,member_returns,portfolio_weights,membe
|
|
704
730
|
print(" 投资组合:",pname)
|
705
731
|
print(" 分析日期:",str(hend))
|
706
732
|
# 投资组合中即使持股比例最低的股票每次交易最少也需要1手(100股)
|
707
|
-
print("
|
733
|
+
print(" 1手组合单位价值:","约"+str(round(portfolio_value_thedate/10000*100,2))+"万")
|
708
734
|
print(" 观察期间:",hstart+'至'+hend)
|
709
735
|
print(" 年化收益率:",round(annual_return,4))
|
710
736
|
print(" 年化标准差:",round(annual_std,4))
|
711
737
|
print(" ***投资组合持仓策略***")
|
712
|
-
print_tickerlist_sharelist(tickerlist,portfolio_weights,leading_blanks=4,ticker_type=
|
738
|
+
print_tickerlist_sharelist(tickerlist,portfolio_weights,leading_blanks=4,ticker_type=ticker_type)
|
713
739
|
|
714
740
|
print(" *来源:Sina/EM/stooq,"+str(stoday)+"统计")
|
715
741
|
else:
|
@@ -740,7 +766,7 @@ if __name__=='__main__':
|
|
740
766
|
portfolio_expectation2(pname,member_returns, portfolio_weights)
|
741
767
|
|
742
768
|
#==============================================================================
|
743
|
-
def portfolio_expectation(pname,pf_info,portfolio_weights):
|
769
|
+
def portfolio_expectation(pname,pf_info,portfolio_weights,ticker_type):
|
744
770
|
"""
|
745
771
|
功能:计算给定pf_info和持仓权重的投资组合年均收益率和标准差
|
746
772
|
输入:投资组合名称,pf_info,投资组合权重series
|
@@ -749,7 +775,7 @@ def portfolio_expectation(pname,pf_info,portfolio_weights):
|
|
749
775
|
"""
|
750
776
|
[[_,_,member_returns,_,member_prices],_]=pf_info
|
751
777
|
|
752
|
-
portfolio_expectation_universal(pname,member_returns,portfolio_weights,member_prices)
|
778
|
+
portfolio_expectation_universal(pname,member_returns,portfolio_weights,member_prices,ticker_type)
|
753
779
|
|
754
780
|
return
|
755
781
|
|
@@ -1080,7 +1106,7 @@ def portfolio_eset(pf_info,simulation=1000,convex_hull=False):
|
|
1080
1106
|
"""
|
1081
1107
|
[[portfolio,thedate,stock_return,_,_],_]=pf_info
|
1082
1108
|
pname=portfolio_name(portfolio)
|
1083
|
-
_,_,tickerlist,_=decompose_portfolio(portfolio)
|
1109
|
+
_,_,tickerlist,_,ticker_type=decompose_portfolio(portfolio)
|
1084
1110
|
|
1085
1111
|
#取出观察期
|
1086
1112
|
hstart0=stock_return.index[0]; hstart=str(hstart0.strftime("%Y-%m-%d"))
|
@@ -1233,7 +1259,7 @@ def portfolio_es_sharpe(pf_info,simulation=1000,RF=0):
|
|
1233
1259
|
|
1234
1260
|
[[portfolio,thedate,stock_return0,rf_df,_],_]=pf_info
|
1235
1261
|
pname=portfolio_name(portfolio)
|
1236
|
-
scope,_,tickerlist,_=decompose_portfolio(portfolio)
|
1262
|
+
scope,_,tickerlist,_,ticker_type=decompose_portfolio(portfolio)
|
1237
1263
|
|
1238
1264
|
#取出观察期
|
1239
1265
|
hstart0=stock_return0.index[0]; hstart=str(hstart0.strftime("%Y-%m-%d"))
|
@@ -1327,7 +1353,7 @@ def portfolio_es_sortino(pf_info,simulation=1000,RF=0):
|
|
1327
1353
|
|
1328
1354
|
[[portfolio,thedate,stock_return0,rf_df,_],_]=pf_info
|
1329
1355
|
pname=portfolio_name(portfolio)
|
1330
|
-
scope,_,tickerlist,_=decompose_portfolio(portfolio)
|
1356
|
+
scope,_,tickerlist,_,ticker_type=decompose_portfolio(portfolio)
|
1331
1357
|
|
1332
1358
|
#取出观察期
|
1333
1359
|
hstart0=stock_return0.index[0]; hstart=str(hstart0.strftime("%Y-%m-%d"))
|
@@ -1427,7 +1453,7 @@ def portfolio_es_alpha(pf_info,simulation=1000,RF=0):
|
|
1427
1453
|
|
1428
1454
|
[[portfolio,thedate,stock_return0,rf_df,_],_]=pf_info
|
1429
1455
|
pname=portfolio_name(portfolio)
|
1430
|
-
scope,mktidx,tickerlist,_=decompose_portfolio(portfolio)
|
1456
|
+
scope,mktidx,tickerlist,_,ticker_type=decompose_portfolio(portfolio)
|
1431
1457
|
|
1432
1458
|
#取出观察期
|
1433
1459
|
hstart0=stock_return0.index[0]; hstart=str(hstart0.strftime("%Y-%m-%d"))
|
@@ -1545,7 +1571,7 @@ def portfolio_es_treynor(pf_info,simulation=1000,RF=0):
|
|
1545
1571
|
|
1546
1572
|
[[portfolio,_,stock_return0,rf_df,_],_]=pf_info
|
1547
1573
|
pname=portfolio_name(portfolio)
|
1548
|
-
scope,mktidx,tickerlist,_=decompose_portfolio(portfolio)
|
1574
|
+
scope,mktidx,tickerlist,_,ticker_type=decompose_portfolio(portfolio)
|
1549
1575
|
|
1550
1576
|
#取出观察期
|
1551
1577
|
hstart0=stock_return0.index[0]; hstart=str(hstart0.strftime("%Y-%m-%d"))
|
@@ -2049,7 +2075,7 @@ def portfolio_optimize_rar(es_info,col_ratio,col_y,col_x,name_hiret,name_lorisk,
|
|
2049
2075
|
"""
|
2050
2076
|
#解析传入的数据
|
2051
2077
|
[[[portfolio,thedate,stock_return,_,_],[StockReturns,_,_,_]],RandomPortfolios]=es_info
|
2052
|
-
_,_,tickerlist,_=decompose_portfolio(portfolio)
|
2078
|
+
_,_,tickerlist,_,ticker_type=decompose_portfolio(portfolio)
|
2053
2079
|
numstocks=len(tickerlist)
|
2054
2080
|
pname=portfolio_name(portfolio)
|
2055
2081
|
|
@@ -2158,6 +2184,7 @@ def portfolio_optimize(pf_info,ratio='sharpe',simulation=10000,RF=0, \
|
|
2158
2184
|
|
2159
2185
|
[[portfolio,_,_,_,_],_]=pf_info
|
2160
2186
|
pname=portfolio_name(portfolio)
|
2187
|
+
_,_,_,_,ticker_type=decompose_portfolio(portfolio)
|
2161
2188
|
|
2162
2189
|
#观察马科维茨可行集:风险溢价-标准差,用于夏普比率优化
|
2163
2190
|
func_es="portfolio_es_"+ratio
|
@@ -2189,10 +2216,10 @@ def portfolio_optimize(pf_info,ratio='sharpe',simulation=10000,RF=0, \
|
|
2189
2216
|
#打印投资组合构造和业绩表现
|
2190
2217
|
hi_name=modify_portfolio_name(name_hiret+zhuhe_txt)
|
2191
2218
|
lo_name=modify_portfolio_name(name_lorisk+zhuhe_txt)
|
2192
|
-
portfolio_expectation(hi_name,pf_info,hiret_weights)
|
2219
|
+
portfolio_expectation(hi_name,pf_info,hiret_weights,ticker_type)
|
2193
2220
|
|
2194
2221
|
if hirar_return:
|
2195
|
-
scope,mktidx,tickerlist,_=decompose_portfolio(portfolio)
|
2222
|
+
scope,mktidx,tickerlist,_,ticker_type=decompose_portfolio(portfolio)
|
2196
2223
|
hwdf=pd.DataFrame(hiret_weights)
|
2197
2224
|
hwdft=hwdf.T
|
2198
2225
|
hwdft.columns=tickerlist
|
@@ -2207,7 +2234,7 @@ def portfolio_optimize(pf_info,ratio='sharpe',simulation=10000,RF=0, \
|
|
2207
2234
|
portfolio_new=dict(Market,**stocks_new)
|
2208
2235
|
|
2209
2236
|
if lorisk:
|
2210
|
-
portfolio_expectation(lo_name,pf_info,lorisk_weights)
|
2237
|
+
portfolio_expectation(lo_name,pf_info,lorisk_weights,ticker_type)
|
2211
2238
|
|
2212
2239
|
#现有投资组合的排名
|
2213
2240
|
ranks=portfolio_ranks(portfolio_returns,pname)
|
@@ -2594,7 +2621,7 @@ def describe_portfolio(portfolio):
|
|
2594
2621
|
输出:市场,市场指数,股票代码列表和份额列表
|
2595
2622
|
"""
|
2596
2623
|
|
2597
|
-
scope,mktidx,tickerlist,sharelist=decompose_portfolio(portfolio)
|
2624
|
+
scope,mktidx,tickerlist,sharelist,ticker_type=decompose_portfolio(portfolio)
|
2598
2625
|
pname=portfolio_name(portfolio)
|
2599
2626
|
|
2600
2627
|
print("*** 投资组合信息:",pname)
|
@@ -2626,7 +2653,7 @@ def portfolio_drop(portfolio,last=0,droplist=[],new_name=''):
|
|
2626
2653
|
"""
|
2627
2654
|
功能:删除最后几个成分股
|
2628
2655
|
"""
|
2629
|
-
scope,mktidx,tickerlist,sharelist=decompose_portfolio(portfolio)
|
2656
|
+
scope,mktidx,tickerlist,sharelist,ticker_type=decompose_portfolio(portfolio)
|
2630
2657
|
pname=portfolio_name(portfolio)
|
2631
2658
|
|
2632
2659
|
if not (last ==0):
|
siat/risk_adjusted_return.py
CHANGED
@@ -143,7 +143,7 @@ def print_rar_ratio(regdf,portfolio,ret_mean,ratio_name,ratio):
|
|
143
143
|
"""
|
144
144
|
|
145
145
|
#从字典中提取信息
|
146
|
-
scope,mktidx,stocklist,portionlist=decompose_portfolio(portfolio)
|
146
|
+
scope,mktidx,stocklist,portionlist,ticker_type=decompose_portfolio(portfolio)
|
147
147
|
stocklist1,_=cvt_yftickerlist(stocklist)
|
148
148
|
|
149
149
|
date_start=str(regdf.index[0].year)+'-'+str(regdf.index[0].month)+ \
|
@@ -199,7 +199,7 @@ def treynor_ratio_portfolio(portfolio,start,end,RF=True,printout=True):
|
|
199
199
|
return None,None
|
200
200
|
|
201
201
|
#从字典中提取信息
|
202
|
-
scope,mktidx,stocklist,portionlist=decompose_portfolio(portfolio)
|
202
|
+
scope,mktidx,stocklist,portionlist,ticker_type=decompose_portfolio(portfolio)
|
203
203
|
|
204
204
|
#第2步:计算投资组合的日收益率序列
|
205
205
|
#抓取日投资组合价格
|
@@ -280,7 +280,7 @@ def rar_ratio_portfolio(portfolio,start,end,ratio_name='treynor',RF=True,printou
|
|
280
280
|
return None,None
|
281
281
|
|
282
282
|
#从字典中提取信息
|
283
|
-
scope,mktidx,stocklist,portionlist=decompose_portfolio(portfolio)
|
283
|
+
scope,mktidx,stocklist,portionlist,ticker_type=decompose_portfolio(portfolio)
|
284
284
|
|
285
285
|
#第2步:计算投资组合的日收益率序列
|
286
286
|
#抓取日投资组合价格
|
@@ -373,7 +373,7 @@ def rar_ratio_rolling(portfolio,start,end,ratio_name='treynor',RF=True, \
|
|
373
373
|
startdate1=date_adjust(startdate, adjust=-startdate_delta)
|
374
374
|
|
375
375
|
#从字典中提取信息
|
376
|
-
scope,mktidx,stocklist,portionlist=decompose_portfolio(portfolio)
|
376
|
+
scope,mktidx,stocklist,portionlist,ticker_type=decompose_portfolio(portfolio)
|
377
377
|
|
378
378
|
#第2步:计算投资组合的日收益率序列
|
379
379
|
#抓取日投资组合价格
|
@@ -465,7 +465,7 @@ def draw_rar_ratio(rars,portfolio,ratio_name):
|
|
465
465
|
输入:滚动数据df,投资组合,指数名称
|
466
466
|
"""
|
467
467
|
|
468
|
-
scope,mktidx,stocklist,portionlist=decompose_portfolio(portfolio)
|
468
|
+
scope,mktidx,stocklist,portionlist,ticker_type=decompose_portfolio(portfolio)
|
469
469
|
stocklist1,_=cvt_yftickerlist(stocklist)
|
470
470
|
|
471
471
|
"""
|
@@ -545,7 +545,7 @@ def sharpe_ratio_portfolio(portfolio,start,end,RF=True,printout=True):
|
|
545
545
|
return None,None
|
546
546
|
|
547
547
|
#从字典中提取信息
|
548
|
-
scope,mktidx,stocklist,portionlist=decompose_portfolio(portfolio)
|
548
|
+
scope,mktidx,stocklist,portionlist,ticker_type=decompose_portfolio(portfolio)
|
549
549
|
|
550
550
|
#检查份额配比是否合理
|
551
551
|
"""
|
@@ -597,7 +597,7 @@ def sharpe_ratio_portfolio(portfolio,start,end,RF=True,printout=True):
|
|
597
597
|
'-'+str(reg.index[-1].day)
|
598
598
|
print("\n===== 风险调整收益率 =====")
|
599
599
|
|
600
|
-
_,_,tickerlist,sharelist=decompose_portfolio(portfolio)
|
600
|
+
_,_,tickerlist,sharelist,ticker_type=decompose_portfolio(portfolio)
|
601
601
|
if len(tickerlist)==1:
|
602
602
|
product=str(ticker_name(tickerlist,'bond'))
|
603
603
|
else:
|
@@ -640,7 +640,7 @@ def sortino_ratio_portfolio(portfolio,start,end,RF=True,printout=True):
|
|
640
640
|
return None,None
|
641
641
|
|
642
642
|
#从字典中提取信息
|
643
|
-
scope,mktidx,stocklist,portionlist=decompose_portfolio(portfolio)
|
643
|
+
scope,mktidx,stocklist,portionlist,ticker_type=decompose_portfolio(portfolio)
|
644
644
|
|
645
645
|
#检查份额配比是否合理
|
646
646
|
"""
|
@@ -693,7 +693,7 @@ def sortino_ratio_portfolio(portfolio,start,end,RF=True,printout=True):
|
|
693
693
|
'-'+str(reg.index[-1].day)
|
694
694
|
print("\n===== 风险调整收益率 =====")
|
695
695
|
|
696
|
-
_,_,tickerlist,sharelist=decompose_portfolio(portfolio)
|
696
|
+
_,_,tickerlist,sharelist,ticker_type=decompose_portfolio(portfolio)
|
697
697
|
if len(tickerlist)==1:
|
698
698
|
product=str(ticker_name(tickerlist,'bond'))
|
699
699
|
else:
|
@@ -738,7 +738,7 @@ def jensen_alpha_portfolio(portfolio,start,end,RF=True,printout=True):
|
|
738
738
|
return None,None
|
739
739
|
|
740
740
|
#从字典中提取信息
|
741
|
-
scope,mktidx,stocklist,portionlist=decompose_portfolio(portfolio)
|
741
|
+
scope,mktidx,stocklist,portionlist,ticker_type=decompose_portfolio(portfolio)
|
742
742
|
#检查份额配比是否合理
|
743
743
|
"""
|
744
744
|
if round(sum(portionlist),1) != 1.0:
|
@@ -798,7 +798,7 @@ def jensen_alpha_portfolio(portfolio,start,end,RF=True,printout=True):
|
|
798
798
|
'-'+str(reg.index[-1].day)
|
799
799
|
print("\n===== 风险调整收益率 =====")
|
800
800
|
|
801
|
-
_,_,tickerlist,sharelist=decompose_portfolio(portfolio)
|
801
|
+
_,_,tickerlist,sharelist,ticker_type=decompose_portfolio(portfolio)
|
802
802
|
if len(tickerlist)==1:
|
803
803
|
product=str(ticker_name(tickerlist,'bond'))
|
804
804
|
else:
|
@@ -1120,14 +1120,14 @@ def compare_rar_portfolio(portfolio1,portfolio2,start,end,ratio_name='sharpe', \
|
|
1120
1120
|
ylabeltxt=label1
|
1121
1121
|
titletxt="证券风险调整收益的滚动趋势对比"
|
1122
1122
|
|
1123
|
-
_,_,tickers1,shares1=decompose_portfolio(portfolio1)
|
1123
|
+
_,_,tickers1,shares1,ticker_type=decompose_portfolio(portfolio1)
|
1124
1124
|
if len(tickers1) == 1:
|
1125
1125
|
ticker1=tickers1[0]
|
1126
1126
|
pf1str=tickers1[0]
|
1127
1127
|
else:
|
1128
1128
|
pf1str=ticker1+':成分'+str(tickers1)+',比例'+str(shares1)
|
1129
1129
|
|
1130
|
-
_,_,tickers2,shares2=decompose_portfolio(portfolio2)
|
1130
|
+
_,_,tickers2,shares2,ticker_type=decompose_portfolio(portfolio2)
|
1131
1131
|
if len(tickers2) == 1:
|
1132
1132
|
ticker2=tickers2[0]
|
1133
1133
|
pf2str=tickers2[0]
|
siat/security_price2.py
CHANGED
@@ -364,13 +364,13 @@ def get_price_1portfolio(ticker,fromdate,todate, \
|
|
364
364
|
return df,found
|
365
365
|
|
366
366
|
#拆分投资组合为成份股列表和份额列表
|
367
|
-
_,_,tickerlist,sharelist=decompose_portfolio(ticker)
|
367
|
+
_,_,tickerlist,sharelist,ticker_type=decompose_portfolio(ticker)
|
368
368
|
|
369
369
|
#处理份额列表,确保其和为1
|
370
370
|
share_sum=sum(sharelist)
|
371
371
|
sharelist1=[x / share_sum for x in sharelist]
|
372
372
|
|
373
|
-
#预处理ticker_type
|
373
|
+
#预处理ticker_type,是否还需要?
|
374
374
|
ticker_type=ticker_type_preprocess_1portfolio(ticker,ticker_type)
|
375
375
|
|
376
376
|
#抓取各个成份股的价格信息
|
siat/security_prices.py
CHANGED
@@ -78,9 +78,9 @@ def get_prices_all(ticker,fromdate,todate,adj=False,source='auto',ticker_type='a
|
|
78
78
|
|
79
79
|
#投资组合
|
80
80
|
if isinstance(ticker_list[0],dict):
|
81
|
-
_,_,tickerlist,sharelist=decompose_portfolio(ticker_list[0])
|
81
|
+
_,_,tickerlist,sharelist,ticker_type=decompose_portfolio(ticker_list[0])
|
82
82
|
df=get_price_portfolio(tickerlist,sharelist,fromdate,todate,adj=adj, \
|
83
|
-
source=source,ticker_type=
|
83
|
+
source=source,ticker_type=ticker_type)
|
84
84
|
return df
|
85
85
|
|
86
86
|
#多个证券
|
@@ -95,9 +95,9 @@ def get_prices_all(ticker,fromdate,todate,adj=False,source='auto',ticker_type='a
|
|
95
95
|
|
96
96
|
#投资组合
|
97
97
|
if isinstance(t,dict):
|
98
|
-
_,_,tickerlist,sharelist=decompose_portfolio(t)
|
98
|
+
_,_,tickerlist,sharelist,ticker_type=decompose_portfolio(t)
|
99
99
|
dft=get_price_portfolio(tickerlist,sharelist,fromdate,todate,adj=adj, \
|
100
|
-
source=source,ticker_type=
|
100
|
+
source=source,ticker_type=ticker_type)
|
101
101
|
t=portfolio_name(t)
|
102
102
|
|
103
103
|
columns=create_tuple_for_columns(dft,t)
|
@@ -1522,7 +1522,7 @@ if __name__=='__main__':
|
|
1522
1522
|
ticker_type='auto'
|
1523
1523
|
|
1524
1524
|
ticker={'Market':('China','000001.SS','白酒组合'),'600519.SS':0.4,'000858.SZ':0.6}
|
1525
|
-
_,_,tickerlist,sharelist=decompose_portfolio(ticker)
|
1525
|
+
_,_,tickerlist,sharelist,ticker_type=decompose_portfolio(ticker)
|
1526
1526
|
|
1527
1527
|
p=get_prices_portfolio(tickerlist,sharelist,fromdate,todate,source='auto')
|
1528
1528
|
|
@@ -2176,7 +2176,7 @@ def get_portfolio_prices(portfolio,fromdate,todate,adj=False,source='auto'):
|
|
2176
2176
|
"""
|
2177
2177
|
|
2178
2178
|
#解构投资组合
|
2179
|
-
_,mktidx,tickerlist,sharelist=decompose_portfolio(portfolio)
|
2179
|
+
_,mktidx,tickerlist,sharelist,ticker_type=decompose_portfolio(portfolio)
|
2180
2180
|
|
2181
2181
|
#检查股票列表个数与份额列表个数是否一致
|
2182
2182
|
if len(tickerlist) != len(sharelist):
|
@@ -2424,7 +2424,7 @@ def get_price_security(security,start,end,source='auto'):
|
|
2424
2424
|
"""
|
2425
2425
|
|
2426
2426
|
if isinstance(security,dict): #投资组合
|
2427
|
-
scope,mktidx,tickerlist,sharelist=decompose_portfolio(security)
|
2427
|
+
scope,mktidx,tickerlist,sharelist,ticker_type=decompose_portfolio(security)
|
2428
2428
|
prices=get_price_portfolio(tickerlist,sharelist,start,end,source=source)
|
2429
2429
|
|
2430
2430
|
pname=portfolio_name(security)
|
siat/stock.py
CHANGED
siat/translate.py
CHANGED
@@ -2988,7 +2988,7 @@ if __name__=='__main__':
|
|
2988
2988
|
|
2989
2989
|
#==============================================================================
|
2990
2990
|
if __name__=='__main__':
|
2991
|
-
_,_,tickerlist,sharelist=decompose_portfolio(portfolio)
|
2991
|
+
_,_,tickerlist,sharelist,ticker_type=decompose_portfolio(portfolio)
|
2992
2992
|
leading_blanks=2
|
2993
2993
|
|
2994
2994
|
def print_tickerlist_sharelist(tickerlist,sharelist,leading_blanks=2,ticker_type='auto'):
|
siat/var_model_validation.py
CHANGED
@@ -313,7 +313,7 @@ def backtest_VaR_portfolio(portfolio,today,future_days=1, \
|
|
313
313
|
if not check_date(today): return
|
314
314
|
|
315
315
|
#解构投资组合
|
316
|
-
_,_,tickerlist,sharelist=decompose_portfolio(portfolio)
|
316
|
+
_,_,tickerlist,sharelist,ticker_type=decompose_portfolio(portfolio)
|
317
317
|
|
318
318
|
#计算开始日期
|
319
319
|
startdate=get_start_date(today,pastyears)
|
@@ -0,0 +1,125 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: siat
|
3
|
+
Version: 3.2.16
|
4
|
+
Summary: Securities Investment Analysis Tools (siat)
|
5
|
+
Home-page: https://pypi.org/project/siat/
|
6
|
+
Author: Prof. WANG Dehong, International Business School, Beijing Foreign Studies University
|
7
|
+
Author-email: wdehong2000@163.com
|
8
|
+
License: Copyright (C) WANG Dehong, 2024. For educational purpose only!
|
9
|
+
Description-Content-Type: text/markdown
|
10
|
+
Requires-Dist: pandas-datareader
|
11
|
+
Requires-Dist: yfinance
|
12
|
+
Requires-Dist: tqdm
|
13
|
+
Requires-Dist: plotly-express
|
14
|
+
Requires-Dist: akshare
|
15
|
+
Requires-Dist: urllib3
|
16
|
+
Requires-Dist: mplfinance
|
17
|
+
Requires-Dist: statsmodels
|
18
|
+
Requires-Dist: yahoo-earnings-calendar
|
19
|
+
Requires-Dist: yahooquery
|
20
|
+
Requires-Dist: pypinyin
|
21
|
+
Requires-Dist: seaborn
|
22
|
+
Requires-Dist: numpy
|
23
|
+
Requires-Dist: scipy
|
24
|
+
Requires-Dist: pandas
|
25
|
+
Requires-Dist: scikit-learn
|
26
|
+
Requires-Dist: baostock
|
27
|
+
Requires-Dist: pyproject.toml
|
28
|
+
Requires-Dist: pathlib
|
29
|
+
Requires-Dist: ruamel-yaml
|
30
|
+
Requires-Dist: prettytable
|
31
|
+
Requires-Dist: graphviz
|
32
|
+
Requires-Dist: luddite
|
33
|
+
Requires-Dist: pendulum
|
34
|
+
|
35
|
+
=== Notes on the Upgrade of siat ===
|
36
|
+
|
37
|
+
*** What is siat? ***
|
38
|
+
siat is a Python plug-in, which stands for security investment analysis toolkit. It is specially designed for teaching and learning purposes on security investment in universities for undergraduate and postgraduate programs.
|
39
|
+
|
40
|
+
*** What sort of securities does siat support?
|
41
|
+
1. Public company profile: world-wide
|
42
|
+
2. Stock & stock market index: world-wide
|
43
|
+
3. Stock valuation: primarily in China (mainland and HK) and the U.S.
|
44
|
+
4. Stock option chain: primarily in the U.S.
|
45
|
+
5. Bond: primarily in China and the U.S.
|
46
|
+
6. Markowitz portfolio: with all the supported stocks and bonds
|
47
|
+
7. Fund: primarily in China and the U.S.
|
48
|
+
8. Futures: primarily in China and the U.S.
|
49
|
+
9. Options: primarily in China and the U.S.
|
50
|
+
10. Digital currency: world-wide (some may be restricted by data sources)
|
51
|
+
11. Balance sheet: in China (full function) and world-wide (basic function)
|
52
|
+
12. Income statement: in China mainland (full function) and world-wide (basic function)
|
53
|
+
13. Cash flow statement: in China mainland (full function) and world-wide (basic function)
|
54
|
+
14. Du Pont Identity: world-wide
|
55
|
+
15. Sector trend and valuation: primarily in China
|
56
|
+
|
57
|
+
*** What sort of analysis does siat support?
|
58
|
+
1. Trend analysis
|
59
|
+
2. Panel comparation
|
60
|
+
3. Return analysis: rolling returns, holding period returns
|
61
|
+
4. Risk analysis: rolling volatility, holding period volatility, LPSD
|
62
|
+
5. Technical analysis: more than 15 indicators
|
63
|
+
6. Risk-adjusted return: sharpe, sortino, treynor, Jensen alpha
|
64
|
+
7. Portfolio optimization: four risk-adjusted returns
|
65
|
+
8. CAPM beta trend
|
66
|
+
9. Beta adjustments: simple adjustment, Scholes-Williams, Dimson
|
67
|
+
10. Beta leverage: Hamada Model
|
68
|
+
11. Fama-French three-factor model
|
69
|
+
12. Fama-French-Carhart four-factor model
|
70
|
+
13. Fama-French five-factor model
|
71
|
+
14. Future pricing
|
72
|
+
15. Option pricing: European style, American style, with/without dividends
|
73
|
+
16. VaR & ES: variance-covariance, historic simulation, Monte Carlo, multiple periods
|
74
|
+
17. Liquidity risk: Roll spread, Amihud, Pastor-Stambaugh
|
75
|
+
18. ESG: basic function
|
76
|
+
|
77
|
+
*** Do I have to download data first before using siat?
|
78
|
+
NO
|
79
|
+
siat will search the internet data sources for all the required data during analysis.
|
80
|
+
The main data sources siat uses:
|
81
|
+
1. Yahoo Finance
|
82
|
+
2. Sina Finance
|
83
|
+
3. East Money
|
84
|
+
4. Stooq (Polish)
|
85
|
+
5. FRED
|
86
|
+
6. OECD
|
87
|
+
7. IMF
|
88
|
+
8. Shanghai Stock Exchange
|
89
|
+
9. Shenzhen Stock Exchange
|
90
|
+
10. Tokyo Stock Exchange
|
91
|
+
11. HKEX
|
92
|
+
12. Sustainalytics
|
93
|
+
|
94
|
+
Thanks the above websites for their valuable data supply!
|
95
|
+
|
96
|
+
*** How is siat version numbered? ***
|
97
|
+
siat version format: X.Y.Z
|
98
|
+
X is the major version number.
|
99
|
+
If the major number X changes, it means a primary upgrade, usually there are some big changes in the architecure. However, user's habits will remain for most of the cases.
|
100
|
+
|
101
|
+
Y is the revision number.
|
102
|
+
If the revision number Y changes, it usually indicates some new functions have been compiled into the package.
|
103
|
+
|
104
|
+
Z is the build number.
|
105
|
+
A build number Z change usually reveals a new compilation over the package for the purpose of debug only.
|
106
|
+
|
107
|
+
*** When to upgrade siat? ***
|
108
|
+
If you have been using the existing copy very well, there is no need to follow up the newest version. However, if you do find
|
109
|
+
some bugs in using siat, most of the time it is a quick solution to upgrade siat as well as the dependent modules that siat relies on.
|
110
|
+
|
111
|
+
*** How to upgrade siat? ***
|
112
|
+
It is strongly recommended to use siat in Jupyter Notebook or Jupyter Lab. In Jupyter, there is an easy way to directly upgrade siat and its relevent modules together in the following command:
|
113
|
+
upgrade_siat()
|
114
|
+
|
115
|
+
If Jupyter prompts that pip command not found during the upgrade, it usually means that you need tick the checkbox
|
116
|
+
"Add Python to your path" or something like this during Anaconda installation. If you forget to tick the checkbox, you may need to remedy the situation case by case. In some of the situations, the following command may work in Anaconda Prompt, but not for all the cases:
|
117
|
+
python -m ensurepip
|
118
|
+
|
119
|
+
*** Are there detailed case studies on using siat? ***
|
120
|
+
YES, hundreds of video case studies in the author's channel (most in Chinese, some in English).
|
121
|
+
https://space.bilibili.com/284812153
|
122
|
+
Welcome to follow the channel!
|
123
|
+
|
124
|
+
*** How to report a bug and look for help? ***
|
125
|
+
Write to the author, Prof. WANG Dehong, wdehong2000@163.com
|
@@ -1,7 +1,7 @@
|
|
1
|
-
siat/__init__.py,sha256=
|
1
|
+
siat/__init__.py,sha256=gP5uajXnJesnH5SL0ZPwq_Qhv59AG1bs4qwZv26Fo2Y,2894
|
2
2
|
siat/allin.py,sha256=f1VWxZLvPLR57ilk9GOziZMWjyAYOYLXbvQI4z38r50,2708
|
3
3
|
siat/alpha_vantage_test.py,sha256=tKr-vmuFH3CZAqwmISz6jzjPHzV1JJl3sPfZdz8aTfM,747
|
4
|
-
siat/assets_liquidity.py,sha256=
|
4
|
+
siat/assets_liquidity.py,sha256=o_UZdLs693uNWPEQB2OzxDH0mdWimOmq4qe_vx1pue0,28987
|
5
5
|
siat/assets_liquidity_test.py,sha256=UWk6HIUlizU7LQZ890fGx8LwU1jMMrIZswg8cFUJWZ8,1285
|
6
6
|
siat/barrons_scraping_test.py,sha256=jSRVPxyYylcgG3fAsuqE-9WH3sDfJ3CdZUcU8VBVdoU,10110
|
7
7
|
siat/beta_adjustment.py,sha256=LZWrEWP-yw7spQjeSldLXpmZu7pFqF5jR3EHym7wNys,37286
|
@@ -14,10 +14,10 @@ siat/bond_china.py,sha256=eYv-nMoWSS5fZ4VxnuJ29QFY9GUS6meGiIc0Xjm1fQI,3038
|
|
14
14
|
siat/bond_test.py,sha256=yUOFw7ddGU-kb1rJdnsjkJWziDNgUR7OLDA7F7Ub91A,5246
|
15
15
|
siat/bond_zh_sina.py,sha256=26BohGcS120utwqg9dJvdGm5OkuNpNu5bco80uOuQpU,4423
|
16
16
|
siat/capm_beta.py,sha256=cxXdRVBQBllhbfz1LeTJAIWvyRYhW54nhtNUXv4HwS0,29063
|
17
|
-
siat/capm_beta2.py,sha256=
|
17
|
+
siat/capm_beta2.py,sha256=07y3q4nJdkM-anpZepj4gK0gvTKj-BB0ppDDI5-TCcY,26904
|
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=
|
20
|
+
siat/common.py,sha256=bybxwy6m7KHvObW_tqmNIIFO_hqu-DQ1KJYYh9E1tm0,144843
|
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
|
@@ -29,7 +29,7 @@ siat/derivative.py,sha256=qV8n09799eqLc26ojR6vN5n_X-xd7rGwdYjgq-wBih8,41483
|
|
29
29
|
siat/economy-20230125.py,sha256=vxZZlPnLkh7SpGMVEPLwxjt0yYLSVmdZrO-s2NYLyoM,73848
|
30
30
|
siat/economy.py,sha256=J0-xBtp6gg6CNP9N-UvpKLJ-0Tw5O_DKaDvEq1R35Fw,73853
|
31
31
|
siat/economy_test.py,sha256=6vjNlPz7W125pJb7simCddobSEp3jmLIMvVkLRZ7zW8,13339
|
32
|
-
siat/esg.py,sha256=
|
32
|
+
siat/esg.py,sha256=GMhaonIKtvOK83rhpQUH5aJt2OL3HQBSVfD__Yw-0oo,19040
|
33
33
|
siat/esg_test.py,sha256=Z9m6GUt8O7oHZSEG9aDYpGdvvrv2AiRJdHTiU6jqmZ0,2944
|
34
34
|
siat/exchange_bond_china.pickle,sha256=zDqdPrFacQ0nqjP_SuF6Yy87EgijIRsFvFroW7FAYYY,1265092
|
35
35
|
siat/fama_french.py,sha256=aUTC-67t_CEPbLk4u79woW_zfZ7OCP6Fo4z5EdWCSkQ,48051
|
@@ -59,15 +59,15 @@ siat/future_china.py,sha256=F-HsIf2Op8Z22RzTjet1g8COzldgnMjFNSXsAkeGyWo,17595
|
|
59
59
|
siat/future_china_test.py,sha256=BrSzmDVaOHki6rntOtosmRn-6dkfOBuLulJNqh7MOpc,1163
|
60
60
|
siat/global_index_test.py,sha256=hnFp3wqqzzL-kAP8mgxDZ54Bd5Ijf6ENi5YJlGBgcXw,2402
|
61
61
|
siat/google_authenticator.py,sha256=ZUbZR8OW0IAKDbcYtlqGqIpZdERpFor9NccFELxg9yI,1637
|
62
|
-
siat/grafix.py,sha256=
|
62
|
+
siat/grafix.py,sha256=afR5QAJvPVCxuIx_UQPXj3FJRuW5GZBVjdBnRhQQpWE,85009
|
63
63
|
siat/grafix_test.py,sha256=kXvcpLgQNO7wd30g_bWljLj5UH7bIVI0_dUtXbfiKR0,3150
|
64
|
-
siat/holding_risk.py,sha256=
|
64
|
+
siat/holding_risk.py,sha256=G3wpaewAKF9CwEqRpr4khyuDu9SU2EGyQUHdk7cmHOA,30693
|
65
65
|
siat/holding_risk_test.py,sha256=FRlw_9wFG98BYcg_cSj95HX5WZ1TvkGaOUdXD7-V86s,474
|
66
66
|
siat/local_debug_test.py,sha256=CDAOffW1Rvs-TcNN5giWVvHMlch1w4dp-w5SIV9jXL0,3936
|
67
67
|
siat/market_china.py,sha256=nabx24qm7N51OafTrwUw542pNeFJ3JaQ1wqyv-nLN5I,37883
|
68
|
-
siat/markowitz.py,sha256=
|
68
|
+
siat/markowitz.py,sha256=glHikhabFAF6Hb6df1pYfhkxid2IZXBYAVQng5wd9Wk,97526
|
69
69
|
siat/markowitz2-20240620.py,sha256=irZAPnjaatFsKQmFRMENP-cO6bEUl2narYtkU5NKTWI,108019
|
70
|
-
siat/markowitz2.py,sha256=
|
70
|
+
siat/markowitz2.py,sha256=csHIjqTbIsHMYQ_LEur9K0Jg8pOm8deEVdQfAGCOG5o,111461
|
71
71
|
siat/markowitz_ccb_test.py,sha256=xBkkoaNHdq9KSUrNuHGgKTdNYUvgi84kNYcf719eoyE,1593
|
72
72
|
siat/markowitz_ef_test.py,sha256=wjNlICkgRIqnonPeSIHo4Mu2GRtb9dr21wDt2kMNEcI,4032
|
73
73
|
siat/markowitz_old.py,sha256=Lf7O_4QWT8RsdkHiUyc_7kKY3eZjKDtFR89Fz3pwYnY,33046
|
@@ -85,7 +85,7 @@ siat/option_pricing_test.py,sha256=eeorV5Ja5vjlRXnP6fWJHetGU5Vb8SnLopkC6RV3GfA,2
|
|
85
85
|
siat/option_sina_api_test.py,sha256=dn-k_wrQnAaNKHoROvWJEc7lqlU0bwiV2Aa4usWAFGM,5908
|
86
86
|
siat/proxy_test.py,sha256=erQJrmGs2X46z8Gb1h-7GYQ0rTUcaR8dxHExWoBz2eM,2610
|
87
87
|
siat/quandl_test.py,sha256=EcPoXnLuqzPl5dKyVEZi3j3PJZFpsnU_iNPhLWC9p-A,1552
|
88
|
-
siat/risk_adjusted_return.py,sha256=
|
88
|
+
siat/risk_adjusted_return.py,sha256=dWVrCDnoxvMmI6cVtrL_FC18QZFrGb6-k9lOoyy5JGE,55085
|
89
89
|
siat/risk_adjusted_return2.py,sha256=mI2ynVICzSIHV4_-jZyZ4vbwI1-zen7Byug31lzViS4,65957
|
90
90
|
siat/risk_adjusted_return_test.py,sha256=m_VHL5AtT74cJv5i7taTeTfnkX48y0AFJk5phawyYWg,3416
|
91
91
|
siat/risk_evaluation.py,sha256=I6B3gty-t--AkDCO0tKF-291YfpnF-IkXcFjqNKCt9I,76286
|
@@ -95,15 +95,15 @@ siat/risk_free_rate_test.py,sha256=CpmhUf8aEAEZeNu4gvWP2Mz2dLoIgBX5bI41vfUBEr8,4
|
|
95
95
|
siat/sector_china.py,sha256=nP6kfYsnaQWZj8dK-zklwSDW8FDS-obZWp_zL0ec2Ig,118603
|
96
96
|
siat/sector_china_test.py,sha256=1wq7ef8Bb_L8F0h0W6FvyBrIcBTEbrTV7hljtpj49U4,5843
|
97
97
|
siat/security_price.py,sha256=2oHskgiw41KMGfqtnA0i2YjNNV6cYgtlUK0j3YeuXWs,29185
|
98
|
-
siat/security_price2.py,sha256=
|
99
|
-
siat/security_prices.py,sha256=
|
98
|
+
siat/security_price2.py,sha256=NKlk5VRA-WeSK8dU960PRfWUOzj4BQ4HbUw3t4j9cv8,25955
|
99
|
+
siat/security_prices.py,sha256=ChiVcubRiPzUvYm8a5X5qjxWtawRQdYHFQXLIevGFC4,105328
|
100
100
|
siat/security_prices_test.py,sha256=OEphoJ87NPKoNow1QA8EU_5MUYrJF-qKoWKNapVfZNI,10779
|
101
101
|
siat/security_trend.py,sha256=o0vpWdrJkmODCP94X-Bvn-w7efHhj9HpUYBHtLl55D0,17240
|
102
102
|
siat/security_trend2-20240620.py,sha256=QVnEcb7AyVbO77jVqfFsJffGXrX8pgJ9xCfoAKmWBPk,24854
|
103
103
|
siat/security_trend2.py,sha256=kCFi8NW4uOkSnl4MkWZB5_rfvDqUiQlVH8tGsvUluEY,25219
|
104
104
|
siat/setup.py,sha256=up65rQGLmTBkhtaMLowjoQXYmIsnycnm4g1SYmeQS6o,1335
|
105
105
|
siat/shenwan index history test.py,sha256=JCVAzOSEldHalhSFa3pqD8JI_8_djPMQOxpkuYU-Esg,1418
|
106
|
-
siat/stock.py,sha256=
|
106
|
+
siat/stock.py,sha256=tHGEI4yuceM6ZcfQ52y500KU8Bauy70-932nfWhM5Ko,142353
|
107
107
|
siat/stock_advice_linear.py,sha256=-twT7IGP-NEplkL1WPSACcNJjggRB2j4mlAQCkzOAuo,31655
|
108
108
|
siat/stock_base.py,sha256=uISvbRyOGy8p9QREA96CVydgflBkn5L3OXOGKl8oanc,1312
|
109
109
|
siat/stock_china.py,sha256=zyUyghIrkkkYWlHRRP7Hoblxzfp-jrck60pTJpwMahg,91553
|
@@ -129,14 +129,14 @@ siat/transaction_test.py,sha256=Z8g1LJCN4-mnUByXMUMoFmN0t105cbmsz2QmvSuIkbU,1858
|
|
129
129
|
siat/translate-20230125.py,sha256=NPPSXhT38s5t9fzMvl_fvi4ckSB73ThLmZetVI-xGdU,117953
|
130
130
|
siat/translate-20230206.py,sha256=-vtI125WyaJhmPotOpDAmclt_XnYVaWU9ByLWZ6FyYE,118133
|
131
131
|
siat/translate-20230215.py,sha256=TJgtPE3n8IjljmZ4Pefy8dmHoNdFF-1zpML6BhA9FKE,121657
|
132
|
-
siat/translate.py,sha256=
|
132
|
+
siat/translate.py,sha256=d-qS-LsOmeeweaJKgc52EpApGxeym9ax9KjvItWslh8,215292
|
133
133
|
siat/translate_20240606.py,sha256=63IyHWEU3Uz9mjwyuAX3fqY4nUMdwh0ICQAgmgPXP7Y,215121
|
134
134
|
siat/universal_test.py,sha256=CDAOffW1Rvs-TcNN5giWVvHMlch1w4dp-w5SIV9jXL0,3936
|
135
135
|
siat/valuation.py,sha256=NKfeZMdDJOW42oLVHob6eSVBXUqlN1OCnnzwyGAst8c,48855
|
136
136
|
siat/valuation_china.py,sha256=EkZQaVkoBjM0c4MCNbaX-bMnlG0e3FXeaWczZDnkptU,67784
|
137
137
|
siat/valuation_market_china_test.py,sha256=gbJ0ioauuo4koTPH6WKUkqcXiQPafnbhU5eKJ6lpdLA,1571
|
138
|
-
siat/var_model_validation.py,sha256=
|
139
|
-
siat-3.2.
|
140
|
-
siat-3.2.
|
141
|
-
siat-3.2.
|
142
|
-
siat-3.2.
|
138
|
+
siat/var_model_validation.py,sha256=R0caWnuZarrRg9939hxh3vJIIpIyPfvelYmzFNZtPbo,14910
|
139
|
+
siat-3.2.16.dist-info/METADATA,sha256=AYKaInQ92nqx-lpb--Om1h_2MGJ7Nr-6khzgnvIjWJ4,5407
|
140
|
+
siat-3.2.16.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
141
|
+
siat-3.2.16.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
|
142
|
+
siat-3.2.16.dist-info/RECORD,,
|
siat-3.2.10.dist-info/METADATA
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.1
|
2
|
-
Name: siat
|
3
|
-
Version: 3.2.10
|
4
|
-
Summary: Securities Investment Analysis Tools (siat)
|
5
|
-
Home-page: https://pypi.org/project/siat/
|
6
|
-
Author: Prof. WANG Dehong, International Business School, Beijing Foreign Studies University
|
7
|
-
Author-email: wdehong2000@163.com
|
8
|
-
License: Copyright (C) WANG Dehong, 2024. For educational purpose only!
|
9
|
-
Requires-Dist: pandas-datareader
|
10
|
-
Requires-Dist: yfinance
|
11
|
-
Requires-Dist: plotly-express
|
12
|
-
Requires-Dist: akshare
|
13
|
-
Requires-Dist: urllib3
|
14
|
-
Requires-Dist: mplfinance
|
15
|
-
Requires-Dist: statsmodels
|
16
|
-
Requires-Dist: yahoo-earnings-calendar
|
17
|
-
Requires-Dist: yahooquery
|
18
|
-
Requires-Dist: pypinyin
|
19
|
-
Requires-Dist: seaborn
|
20
|
-
Requires-Dist: numpy
|
21
|
-
Requires-Dist: scipy
|
22
|
-
Requires-Dist: pandas
|
23
|
-
Requires-Dist: scikit-learn
|
24
|
-
Requires-Dist: baostock
|
25
|
-
Requires-Dist: pyproject.toml
|
26
|
-
Requires-Dist: pathlib
|
27
|
-
Requires-Dist: ruamel-yaml
|
28
|
-
Requires-Dist: prettytable
|
29
|
-
Requires-Dist: graphviz
|
30
|
-
Requires-Dist: luddite
|
31
|
-
Requires-Dist: pendulum
|
32
|
-
|
33
|
-
|
34
|
-
Security Investment Analysis Toolkit (siat) is designed to use for making case studies in learning security investment,
|
35
|
-
where cases can be replayed, updated and re-created in different securities,
|
36
|
-
different time lines and different measurements.
|
37
|
-
The plug-in is only licensed for teaching and learning purposes, not for commercial use.
|
38
|
-
The author is not responsible for any results of applying this plug-in in real
|
39
|
-
investment activities.
|
40
|
-
|
File without changes
|
File without changes
|