siat 3.5.12__py3-none-any.whl → 3.6.6__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/capm_beta2.py +49 -24
- siat/grafix.py +505 -26
- siat/option_china.py +1 -1
- siat/risk_adjusted_return2.py +91 -52
- siat/security_trend2.py +71 -15
- siat/stock.py +65 -17
- siat/translate.py +1 -1
- siat/valuation.py +28 -12
- {siat-3.5.12.dist-info → siat-3.6.6.dist-info}/METADATA +1 -1
- {siat-3.5.12.dist-info → siat-3.6.6.dist-info}/RECORD +13 -13
- {siat-3.5.12.dist-info → siat-3.6.6.dist-info}/LICENSE +0 -0
- {siat-3.5.12.dist-info → siat-3.6.6.dist-info}/WHEEL +0 -0
- {siat-3.5.12.dist-info → siat-3.6.6.dist-info}/top_level.txt +0 -0
siat/option_china.py
CHANGED
@@ -2457,7 +2457,7 @@ def fin_option_maturity_risk_sse(option,exercise,trade_date, \
|
|
2457
2457
|
#label2=measure
|
2458
2458
|
#ylabeltxt="风险指标"
|
2459
2459
|
ylabeltxt=ectranslate(measure)
|
2460
|
-
titletxt='希腊值风险趋势:'+option+'
|
2460
|
+
titletxt='希腊值风险趋势:'+option+'期权,到期期限对'+ylabeltxt+"的影响"
|
2461
2461
|
|
2462
2462
|
footnote0="到期时间(不同期权)\n"
|
2463
2463
|
footnote1=option+"期权"+",行权股指点位"+str(exercise)+",交易日"+trade_date
|
siat/risk_adjusted_return2.py
CHANGED
@@ -114,7 +114,12 @@ def get_rolling_sharpe_sortino(ticker,start,end,rar_name="sharpe", \
|
|
114
114
|
RF_period=RF
|
115
115
|
|
116
116
|
#收益率减去一个常数其实不影响其标准差的数值,即std(ret-RF)=std(ret)
|
117
|
-
|
117
|
+
try:
|
118
|
+
rardf2[ret_type]=rardf2[ret_type] - RF_period
|
119
|
+
except:
|
120
|
+
print(" #Warning(get_rolling_sharpe_sortino): unsupported ret_type",ret_type)
|
121
|
+
return None
|
122
|
+
|
118
123
|
rardf3=rolling_ret_volatility(rardf2, period=ret_period)
|
119
124
|
rardf4=rolling_ret_lpsd(rardf3, period=ret_period)
|
120
125
|
|
@@ -269,7 +274,7 @@ if __name__=='__main__':
|
|
269
274
|
alpha2y=get_rolling_treynor_alpha(ticker,start,end,rar_name="alpha",ret_type="Annual Ret%",RF=0.01759)
|
270
275
|
|
271
276
|
def get_rolling_treynor_alpha(ticker,start,end,rar_name="alpha", \
|
272
|
-
ret_type="Monthly Ret%",RF=0, \
|
277
|
+
ret_type="Monthly Adj Ret%",RF=0, \
|
273
278
|
regression_period=365,mktidx='auto',source='auto',ticker_type='auto'):
|
274
279
|
"""
|
275
280
|
功能:获取一只股票的特雷诺比率或阿尔法指数,基于给定的滚动收益率类型,在指定期间内
|
@@ -804,6 +809,8 @@ if __name__=='__main__':
|
|
804
809
|
|
805
810
|
def compare_1ticker_mrar(ticker,start,end,rar=['sharpe','sortino','treynor','alpha'], \
|
806
811
|
ret_type="Annual Adj Ret%",RF=0,regression_period=365, \
|
812
|
+
attention_value='',attention_value_area='', \
|
813
|
+
attention_point='',attention_point_area='', \
|
807
814
|
graph=True,loc1='best', \
|
808
815
|
axhline_value=0,axhline_label='',facecolor='whitesmoke', \
|
809
816
|
printout=False,sortby='tpw_mean',trailing=7,trend_threshhold=0.01, \
|
@@ -904,6 +911,8 @@ def compare_1ticker_mrar(ticker,start,end,rar=['sharpe','sortino','treynor','alp
|
|
904
911
|
draw_lines(df1,y_label,x_label=footnotex, \
|
905
912
|
axhline_value=axhline_value,axhline_label=axhline_label, \
|
906
913
|
title_txt=title_txt,data_label=False, \
|
914
|
+
attention_value=attention_value,attention_value_area=attention_value_area, \
|
915
|
+
attention_point=attention_point,attention_point_area=attention_point_area, \
|
907
916
|
annotate=annotate,annotate_value=annotate, \
|
908
917
|
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
|
909
918
|
facecolor=facecolor,loc=loc1)
|
@@ -962,7 +971,9 @@ if __name__=='__main__':
|
|
962
971
|
rars=compare_mticker_1rar(ticker=["600519.SS","000858.SZ"],start="2024-1-1",end="2024-6-16",rar='sharpe',printout=True)
|
963
972
|
|
964
973
|
def compare_mticker_1rar(ticker,start,end,rar='sharpe', \
|
965
|
-
ret_type="Annual Ret%",RF=0,regression_period=365, \
|
974
|
+
ret_type="Annual Adj Ret%",RF=0,regression_period=365, \
|
975
|
+
attention_value='',attention_value_area='', \
|
976
|
+
attention_point='',attention_point_area='', \
|
966
977
|
graph=True,loc1='best', \
|
967
978
|
axhline_value=0,axhline_label='', \
|
968
979
|
printout=False,sortby='tpw_mean',trailing=7,trend_threshhold=0.01, \
|
@@ -1084,6 +1095,8 @@ def compare_mticker_1rar(ticker,start,end,rar='sharpe', \
|
|
1084
1095
|
draw_lines(df1,y_label,x_label=footnotex, \
|
1085
1096
|
axhline_value=axhline_value,axhline_label=axhline_label, \
|
1086
1097
|
title_txt=title_txt,data_label=False, \
|
1098
|
+
attention_value=attention_value,attention_value_area=attention_value_area, \
|
1099
|
+
attention_point=attention_point,attention_point_area=attention_point_area, \
|
1087
1100
|
annotate=annotate,annotate_value=annotate, \
|
1088
1101
|
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
|
1089
1102
|
facecolor=facecolor,loc=loc1)
|
@@ -1138,7 +1151,9 @@ if __name__=='__main__':
|
|
1138
1151
|
rars=compare_mticker_mrar(ticker,start,end,rar,graph=False,printout=True)
|
1139
1152
|
|
1140
1153
|
def compare_mticker_mrar(ticker,start,end,rar=['sharpe','alpha','sortino','treynor'], \
|
1141
|
-
ret_type="Annual Ret%",RF=0,regression_period=365, \
|
1154
|
+
ret_type="Annual Adj Ret%",RF=0,regression_period=365, \
|
1155
|
+
attention_value='',attention_value_area='', \
|
1156
|
+
attention_point='',attention_point_area='', \
|
1142
1157
|
graph=True,loc1='best', \
|
1143
1158
|
axhline_value=0,axhline_label='', \
|
1144
1159
|
printout=True,sortby='tpw_mean',trailing=7,trend_threshhold=0.01, \
|
@@ -1167,6 +1182,8 @@ def compare_mticker_mrar(ticker,start,end,rar=['sharpe','alpha','sortino','treyn
|
|
1167
1182
|
#with HiddenPrints(): #此项将压制所有print输出,造成表头脚注不显示
|
1168
1183
|
_,df_tmp=compare_mticker_1rar(ticker=ticker,start=start,end=end,rar=r, \
|
1169
1184
|
ret_type=ret_type,RF=RF,regression_period=regression_period, \
|
1185
|
+
attention_value=attention_value,attention_value_area=attention_value_area, \
|
1186
|
+
attention_point=attention_point,attention_point_area=attention_point_area, \
|
1170
1187
|
graph=graph,facecolor=facecolor, \
|
1171
1188
|
axhline_value=axhline_value,axhline_label=axhline_label, \
|
1172
1189
|
printout=printout,sortby=sortby, \
|
@@ -1340,8 +1357,10 @@ if __name__=='__main__':
|
|
1340
1357
|
rars=compare_1ticker_1rar_mret(ticker,start,end,rar,ret_type,printout=True)
|
1341
1358
|
|
1342
1359
|
def compare_1ticker_1rar_mret(ticker,start,end,rar='sharpe', \
|
1343
|
-
ret_type=["Annual Ret%","Monthly Ret%"], \
|
1360
|
+
ret_type=["Annual Adj Ret%","Monthly Adj Ret%"], \
|
1344
1361
|
RF=0,regression_period=365, \
|
1362
|
+
attention_value='',attention_value_area='', \
|
1363
|
+
attention_point='',attention_point_area='', \
|
1345
1364
|
graph=True,loc1='best', \
|
1346
1365
|
axhline_value=0,axhline_label='',facecolor='whitesmoke', \
|
1347
1366
|
printout=False,sortby='tpw_mean',trailing=7,trend_threshhold=0.01, \
|
@@ -1373,7 +1392,7 @@ def compare_1ticker_1rar_mret(ticker,start,end,rar='sharpe', \
|
|
1373
1392
|
RF=RF[0]
|
1374
1393
|
if isinstance(regression_period,list):
|
1375
1394
|
regression_period=regression_period[0]
|
1376
|
-
print("
|
1395
|
+
print(" Working on",rar,"for",ticker_name(ticker,ticker_type),"in different returns, please wait ......\n")
|
1377
1396
|
|
1378
1397
|
df=pd.DataFrame()
|
1379
1398
|
for t in ret_type:
|
@@ -1435,6 +1454,8 @@ def compare_1ticker_1rar_mret(ticker,start,end,rar='sharpe', \
|
|
1435
1454
|
draw_lines(df1,y_label,x_label=footnotex, \
|
1436
1455
|
axhline_value=axhline_value,axhline_label=axhline_label, \
|
1437
1456
|
title_txt=title_txt,data_label=False, \
|
1457
|
+
attention_value=attention_value,attention_value_area=attention_value_area, \
|
1458
|
+
attention_point=attention_point,attention_point_area=attention_point_area, \
|
1438
1459
|
annotate=annotate,annotate_value=annotate, \
|
1439
1460
|
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
|
1440
1461
|
facecolor=facecolor,loc=loc1)
|
@@ -1490,7 +1511,9 @@ if __name__=='__main__':
|
|
1490
1511
|
rars=compare_1ticker_1rar_1ret_mRF(ticker,start,end,rar,ret_type,RF)
|
1491
1512
|
|
1492
1513
|
def compare_1ticker_1rar_1ret_mRF(ticker,start,end,rar='sharpe', \
|
1493
|
-
ret_type="Annual Ret%",RF=[0,0.02,0.05],regression_period=365, \
|
1514
|
+
ret_type="Annual Adj Ret%",RF=[0,0.02,0.05],regression_period=365, \
|
1515
|
+
attention_value='',attention_value_area='', \
|
1516
|
+
attention_point='',attention_point_area='', \
|
1494
1517
|
graph=True,loc1='best', \
|
1495
1518
|
axhline_value=0,axhline_label='',facecolor='whitesmoke', \
|
1496
1519
|
printout=False,sortby='tpw_mean',trailing=7,trend_threshhold=0.01, \
|
@@ -1579,6 +1602,8 @@ def compare_1ticker_1rar_1ret_mRF(ticker,start,end,rar='sharpe', \
|
|
1579
1602
|
draw_lines(df1,y_label,x_label=footnotex, \
|
1580
1603
|
axhline_value=axhline_value,axhline_label=axhline_label, \
|
1581
1604
|
title_txt=title_txt,data_label=False, \
|
1605
|
+
attention_value=attention_value,attention_value_area=attention_value_area, \
|
1606
|
+
attention_point=attention_point,attention_point_area=attention_point_area, \
|
1582
1607
|
annotate=annotate,annotate_value=annotate, \
|
1583
1608
|
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
|
1584
1609
|
facecolor=facecolor,loc=loc1)
|
@@ -1652,6 +1677,8 @@ def compare_rar_security(ticker,start,end,rar='sharpe', \
|
|
1652
1677
|
ret_type="Annual Adj Ret%", \
|
1653
1678
|
RF=0, \
|
1654
1679
|
regression_period=365, \
|
1680
|
+
attention_value='',attention_value_area='', \
|
1681
|
+
attention_point='',attention_point_area='', \
|
1655
1682
|
graph=True,loc1='best', \
|
1656
1683
|
axhline_value=0,axhline_label='',facecolor='whitesmoke', \
|
1657
1684
|
printout=False,sortby='tpw_mean',trailing=7,trend_threshhold=0.05, \
|
@@ -1682,29 +1709,33 @@ def compare_rar_security(ticker,start,end,rar='sharpe', \
|
|
1682
1709
|
|
1683
1710
|
if rar_num ==1: #一个RAR
|
1684
1711
|
df=compare_mticker_1rar(ticker=ticker,start=start,end=end,rar=rar, \
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1712
|
+
ret_type=ret_type,RF=RF,regression_period=regression_period, \
|
1713
|
+
attention_value=attention_value,attention_value_area=attention_value_area, \
|
1714
|
+
attention_point=attention_point,attention_point_area=attention_point_area, \
|
1715
|
+
graph=graph,loc1=loc1, \
|
1716
|
+
axhline_value=axhline_value,axhline_label=axhline_label, \
|
1717
|
+
printout=printout, \
|
1718
|
+
sortby=sortby,trailing=trailing,trend_threshhold=trend_threshhold, \
|
1719
|
+
annotate=annotate,annotate_value=annotate, \
|
1720
|
+
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
|
1721
|
+
mktidx=mktidx,source=source, \
|
1722
|
+
ticker_type=ticker_type,facecolor=facecolor)
|
1694
1723
|
return df
|
1695
1724
|
|
1696
1725
|
if rar_num >1: #多个RAR
|
1697
1726
|
printout=True #否则无法运行descriptive_statistics2函数
|
1698
1727
|
df=compare_mticker_mrar(ticker=ticker,start=start,end=end,rar=rar, \
|
1699
|
-
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1728
|
+
ret_type=ret_type,RF=RF,regression_period=regression_period, \
|
1729
|
+
attention_value=attention_value,attention_value_area=attention_value_area, \
|
1730
|
+
attention_point=attention_point,attention_point_area=attention_point_area, \
|
1731
|
+
graph=graph,loc1=loc1, \
|
1732
|
+
axhline_value=axhline_value,axhline_label=axhline_label, \
|
1733
|
+
printout=printout, \
|
1734
|
+
sortby=sortby,trailing=trailing,trend_threshhold=trend_threshhold, \
|
1735
|
+
annotate=annotate,annotate_value=annotate, \
|
1736
|
+
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
|
1737
|
+
mktidx=mktidx,source=source, \
|
1738
|
+
ticker_type=ticker_type,facecolor=facecolor)
|
1708
1739
|
return df
|
1709
1740
|
else:
|
1710
1741
|
#实际上是单个证券
|
@@ -1719,15 +1750,17 @@ def compare_rar_security(ticker,start,end,rar='sharpe', \
|
|
1719
1750
|
RF=RF[0]
|
1720
1751
|
|
1721
1752
|
df=compare_1ticker_mrar(ticker=ticker,start=start,end=end,rar=rar, \
|
1722
|
-
|
1723
|
-
|
1724
|
-
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
1753
|
+
ret_type=ret_type,RF=RF,regression_period=regression_period, \
|
1754
|
+
attention_value=attention_value,attention_value_area=attention_value_area, \
|
1755
|
+
attention_point=attention_point,attention_point_area=attention_point_area, \
|
1756
|
+
graph=graph,loc1=loc1, \
|
1757
|
+
axhline_value=axhline_value,axhline_label=axhline_label, \
|
1758
|
+
printout=printout,facecolor=facecolor, \
|
1759
|
+
sortby=sortby,trailing=trailing,trend_threshhold=trend_threshhold, \
|
1760
|
+
annotate=annotate,annotate_value=annotate, \
|
1761
|
+
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
|
1762
|
+
mktidx=mktidx,source=source, \
|
1763
|
+
ticker_type=ticker_type)
|
1731
1764
|
return df
|
1732
1765
|
else:
|
1733
1766
|
#实际上是单个RAR
|
@@ -1740,15 +1773,17 @@ def compare_rar_security(ticker,start,end,rar='sharpe', \
|
|
1740
1773
|
RF=RF[0]
|
1741
1774
|
|
1742
1775
|
df=compare_1ticker_1rar_mret(ticker=ticker,start=start,end=end,rar=rar, \
|
1743
|
-
|
1744
|
-
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1749
|
-
|
1750
|
-
|
1751
|
-
|
1776
|
+
ret_type=ret_type,RF=RF,regression_period=regression_period, \
|
1777
|
+
attention_value=attention_value,attention_value_area=attention_value_area, \
|
1778
|
+
attention_point=attention_point,attention_point_area=attention_point_area, \
|
1779
|
+
graph=graph,loc1=loc1, \
|
1780
|
+
axhline_value=axhline_value,axhline_label=axhline_label, \
|
1781
|
+
printout=printout, \
|
1782
|
+
sortby=sortby,trailing=trailing,trend_threshhold=trend_threshhold, \
|
1783
|
+
annotate=annotate,annotate_value=annotate, \
|
1784
|
+
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
|
1785
|
+
mktidx=mktidx,source=source, \
|
1786
|
+
ticker_type=ticker_type,facecolor=facecolor)
|
1752
1787
|
return df
|
1753
1788
|
else:
|
1754
1789
|
#实际上是单个收益率类型
|
@@ -1759,15 +1794,17 @@ def compare_rar_security(ticker,start,end,rar='sharpe', \
|
|
1759
1794
|
if len(RF) > 1:
|
1760
1795
|
|
1761
1796
|
df=compare_1ticker_1rar_1ret_mRF(ticker=ticker,start=start,end=end,rar=rar, \
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
1769
|
-
|
1770
|
-
|
1797
|
+
ret_type=ret_type,RF=RF,regression_period=regression_period, \
|
1798
|
+
attention_value=attention_value,attention_value_area=attention_value_area, \
|
1799
|
+
attention_point=attention_point,attention_point_area=attention_point_area, \
|
1800
|
+
graph=graph,loc1=loc1, \
|
1801
|
+
axhline_value=axhline_value,axhline_label=axhline_label, \
|
1802
|
+
printout=printout,facecolor=facecolor, \
|
1803
|
+
sortby=sortby,trailing=trailing,trend_threshhold=trend_threshhold, \
|
1804
|
+
annotate=annotate,annotate_value=annotate, \
|
1805
|
+
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
|
1806
|
+
mktidx=mktidx,source=source, \
|
1807
|
+
ticker_type=ticker_type)
|
1771
1808
|
return df
|
1772
1809
|
else:
|
1773
1810
|
#实际上是单个RF
|
@@ -1776,6 +1813,8 @@ def compare_rar_security(ticker,start,end,rar='sharpe', \
|
|
1776
1813
|
#情形5:1只证券,1个RAR,1个收益率类型,1个RF
|
1777
1814
|
df=compare_1ticker_mrar(ticker=ticker,start=start,end=end,rar=rar, \
|
1778
1815
|
ret_type=ret_type,RF=RF,regression_period=regression_period, \
|
1816
|
+
attention_value=attention_value,attention_value_area=attention_value_area, \
|
1817
|
+
attention_point=attention_point,attention_point_area=attention_point_area, \
|
1779
1818
|
graph=graph,loc1=loc1, \
|
1780
1819
|
axhline_value=axhline_value,axhline_label=axhline_label, \
|
1781
1820
|
printout=printout,sortby=sortby, \
|
siat/security_trend2.py
CHANGED
@@ -123,21 +123,30 @@ if __name__=='__main__':
|
|
123
123
|
|
124
124
|
def security_trend(ticker,indicator='Close',adjust='', \
|
125
125
|
start='default',end='default', \
|
126
|
+
#纵轴水平线
|
127
|
+
attention_value='',attention_value_area='', \
|
128
|
+
|
129
|
+
average_value=False, \
|
130
|
+
#横轴垂直线
|
131
|
+
attention_point='',attention_point_area='', \
|
126
132
|
|
127
|
-
|
128
|
-
|
129
|
-
kline=False,kline_demo=False,mav=[5,10,20], \
|
133
|
+
kline=False,kline_demo=False,mav=[5,20], \
|
130
134
|
|
131
135
|
dividend=False,split=False, \
|
132
|
-
|
136
|
+
|
137
|
+
#计算RAR和贝塔系数的基础参数
|
133
138
|
ret_type='Annual Adj Ret%',RF=0,regression_period=365,market_index="auto", \
|
134
139
|
sortby='tpw_mean',trailing=7,trend_threshhold=0.05, \
|
135
|
-
|
140
|
+
|
141
|
+
#绘制河流图的上下边界,由变量指定
|
136
142
|
band_area='', \
|
143
|
+
|
144
|
+
|
137
145
|
graph=True,twinx=False,loc1='best',loc2='best', \
|
138
146
|
datatag=False,power=0, \
|
139
147
|
smooth=True,date_range=False,date_freq=False, \
|
140
|
-
|
148
|
+
|
149
|
+
#数据预处理
|
141
150
|
preprocess='none',scaling_option='change%', \
|
142
151
|
|
143
152
|
annotate=False,annotate_value=False, \
|
@@ -211,7 +220,9 @@ def security_trend(ticker,indicator='Close',adjust='', \
|
|
211
220
|
source参数:指定证券基础数据来源,默认由系统决定。当系统找到的数据不理想时,可手动指定。
|
212
221
|
若指定雅虎财经数据源,需要拥有访问该网站的权限。
|
213
222
|
"""
|
214
|
-
|
223
|
+
DEBUG=False
|
224
|
+
|
225
|
+
#critical_value=attention_value
|
215
226
|
|
216
227
|
portfolio_flag=False #标志:ticker中是否含有投资组合
|
217
228
|
ticker=tickers_cvt2yahoo(ticker) #支持多种形式证券代码格式
|
@@ -307,8 +318,9 @@ def security_trend(ticker,indicator='Close',adjust='', \
|
|
307
318
|
# 检查趋势指标
|
308
319
|
indicator_list1=['Open','Close','Adj Close','High','Low',
|
309
320
|
'Daily Ret','Daily Ret%','Daily Adj Ret','Daily Adj Ret%',
|
310
|
-
'log(Daily Ret)','log(Daily Adj Ret)',
|
311
|
-
'Weekly
|
321
|
+
'log(Daily Ret)','log(Daily Adj Ret)',
|
322
|
+
'Weekly Ret','Weekly Ret%','Weekly Adj Ret','Weekly Adj Ret%',
|
323
|
+
'Monthly Ret','Monthly Ret%',
|
312
324
|
'Monthly Adj Ret','Monthly Adj Ret%','Quarterly Ret','Quarterly Ret%',
|
313
325
|
'Quarterly Adj Ret','Quarterly Adj Ret%','Annual Ret','Annual Ret%',
|
314
326
|
'Annual Adj Ret','Annual Adj Ret%','Exp Ret','Exp Ret%','Exp Adj Ret',
|
@@ -327,7 +339,8 @@ def security_trend(ticker,indicator='Close',adjust='', \
|
|
327
339
|
'Annual Adj Ret Volatility', 'Annual Adj Ret Volatility%',
|
328
340
|
'Exp Ret Volatility', 'Exp Ret Volatility%', 'Exp Adj Ret Volatility',
|
329
341
|
'Exp Adj Ret Volatility%', 'Weekly Ret LPSD', 'Weekly Ret LPSD%',
|
330
|
-
'Weekly Adj Ret LPSD', 'Weekly Adj Ret LPSD%',
|
342
|
+
'Weekly Adj Ret LPSD', 'Weekly Adj Ret LPSD%',
|
343
|
+
'Monthly Ret LPSD',
|
331
344
|
'Monthly Ret LPSD%', 'Monthly Adj Ret LPSD', 'Monthly Adj Ret LPSD%',
|
332
345
|
'Quarterly Ret LPSD', 'Quarterly Ret LPSD%', 'Quarterly Adj Ret LPSD',
|
333
346
|
'Quarterly Adj Ret LPSD%', 'Annual Ret LPSD', 'Annual Ret LPSD%',
|
@@ -390,17 +403,20 @@ def security_trend(ticker,indicator='Close',adjust='', \
|
|
390
403
|
return None
|
391
404
|
"""
|
392
405
|
# 情形1:单个证券,单个普通指标===============================================
|
393
|
-
#
|
406
|
+
# 绘制零线:由绘图函数自动判断
|
394
407
|
zeroline=False
|
408
|
+
"""
|
395
409
|
if (critical_value != ''):
|
396
410
|
if isinstance(critical_value,float) or isinstance(critical_value,int):
|
397
411
|
zeroline=critical_value
|
398
|
-
|
412
|
+
"""
|
399
413
|
if ticker_num==1 and indicator_num==1 and indicator_group1:
|
400
414
|
df=security_indicator(ticker=tickers[0],indicator=measures[0],adjust=adjust, \
|
401
415
|
fromdate=fromdate,todate=todate, \
|
402
416
|
zeroline=zeroline, \
|
403
417
|
average_value=average_value, \
|
418
|
+
attention_value=attention_value,attention_value_area=attention_value_area, \
|
419
|
+
attention_point=attention_point,attention_point_area=attention_point_area, \
|
404
420
|
datatag=datatag,power=power,graph=graph, \
|
405
421
|
source=source, \
|
406
422
|
mark_top=mark_top,mark_bottom=mark_bottom, \
|
@@ -410,18 +426,32 @@ def security_trend(ticker,indicator='Close',adjust='', \
|
|
410
426
|
|
411
427
|
# 情形2:单个证券,两个普通指标,twinx==True =================================
|
412
428
|
if ticker_num==1 and indicator_num == 2 and indicator_group1 and twinx:
|
429
|
+
if DEBUG:
|
430
|
+
print("Scenario 2: ticker_num==1 and indicator_num == 2 and indicator_group1 and twinx")
|
431
|
+
print("attention_value=",attention_value)
|
432
|
+
print("attention_point=",attention_point)
|
433
|
+
|
413
434
|
df=compare_security(tickers=tickers[0],measures=measures[:2], \
|
414
435
|
adjust=adjust, \
|
415
436
|
fromdate=fromdate,todate=todate,twinx=twinx, \
|
437
|
+
attention_value=attention_value,attention_value_area=attention_value_area, \
|
438
|
+
attention_point=attention_point,attention_point_area=attention_point_area, \
|
416
439
|
loc1=loc1,loc2=loc2,graph=graph,source=source, \
|
417
440
|
ticker_type=ticker_type,facecolor=facecolor)
|
418
441
|
return df
|
419
442
|
|
420
443
|
# 情形3:单个证券,两个及以上普通指标,twinx==False ==========================
|
421
444
|
if ticker_num==1 and indicator_num >= 2 and indicator_group1 and not twinx:
|
445
|
+
if DEBUG:
|
446
|
+
print("Scenario 3: ticker_num==1 and indicator_num >= 2 and indicator_group1 and not twinx")
|
447
|
+
print("attention_value=",attention_value)
|
448
|
+
print("attention_point=",attention_point)
|
449
|
+
|
422
450
|
df=security_mindicators(ticker=tickers[0],measures=measures, \
|
423
451
|
adjust=adjust, \
|
424
452
|
fromdate=fromdate,todate=todate, \
|
453
|
+
attention_value=attention_value,attention_value_area=attention_value_area, \
|
454
|
+
attention_point=attention_point,attention_point_area=attention_point_area, \
|
425
455
|
graph=graph,smooth=smooth,band_area=band_area,loc=loc1, \
|
426
456
|
date_range=date_range,date_freq=date_freq, \
|
427
457
|
annotate=annotate,annotate_value=annotate_value, \
|
@@ -432,9 +462,16 @@ def security_trend(ticker,indicator='Close',adjust='', \
|
|
432
462
|
|
433
463
|
# 情形4:两个证券,取第一个普通指标,twinx==True =============================
|
434
464
|
if ticker_num==2 and indicator_group1 and twinx:
|
465
|
+
if DEBUG:
|
466
|
+
print("Scenario 4: ticker_num==2 and indicator_group1 and twinx")
|
467
|
+
print("attention_value=",attention_value)
|
468
|
+
print("attention_point=",attention_point)
|
469
|
+
|
435
470
|
df=compare_security(tickers=tickers,measures=measures[0], \
|
436
471
|
adjust=adjust, \
|
437
472
|
fromdate=fromdate,todate=todate,twinx=twinx, \
|
473
|
+
attention_value=attention_value,attention_value_area=attention_value_area, \
|
474
|
+
attention_point=attention_point,attention_point_area=attention_point_area, \
|
438
475
|
loc1=loc1,loc2=loc2,graph=graph,source=source, \
|
439
476
|
ticker_type=ticker_type,facecolor=facecolor)
|
440
477
|
return df
|
@@ -450,14 +487,22 @@ def security_trend(ticker,indicator='Close',adjust='', \
|
|
450
487
|
# 绘制横线
|
451
488
|
axhline_value=0
|
452
489
|
axhline_label=''
|
490
|
+
"""
|
453
491
|
if (critical_value != ''):
|
454
492
|
if isinstance(critical_value,float) or isinstance(critical_value,int):
|
455
493
|
axhline_value=critical_value
|
456
494
|
axhline_label='零线'
|
457
|
-
|
495
|
+
"""
|
458
496
|
if ((ticker_num == 2 and not twinx) or ticker_num > 2) and indicator_group1:
|
497
|
+
if DEBUG:
|
498
|
+
print("Scenario 5: ((ticker_num == 2 and not twinx) or ticker_num > 2) and indicator_group1")
|
499
|
+
print("attention_value=",attention_value)
|
500
|
+
print("attention_point=",attention_point)
|
501
|
+
|
459
502
|
df=compare_msecurity(tickers=tickers,measure=measures[0], \
|
460
503
|
start=fromdate,end=todate, \
|
504
|
+
attention_value=attention_value,attention_value_area=attention_value_area, \
|
505
|
+
attention_point=attention_point,attention_point_area=attention_point_area, \
|
461
506
|
adjust=adjust, \
|
462
507
|
axhline_value=axhline_value,axhline_label=axhline_label, \
|
463
508
|
preprocess=preprocess,linewidth=linewidth, \
|
@@ -474,8 +519,15 @@ def security_trend(ticker,indicator='Close',adjust='', \
|
|
474
519
|
# 注意:收益率类型支持滚动收益率和扩展收益率,但不建议混合使用,因为难以解释结果
|
475
520
|
# 复权价:使用ret_type为xx Adj Ret%即可
|
476
521
|
if indicator_group2:
|
522
|
+
if DEBUG:
|
523
|
+
print("Scenario 6: indicator_group2 RAR")
|
524
|
+
print("attention_value=",attention_value)
|
525
|
+
print("attention_point=",attention_point)
|
526
|
+
|
477
527
|
df=compare_rar_security(ticker=tickers,start=fromdate,end=todate,rar=measures, \
|
478
528
|
ret_type=ret_type,RF=RF,regression_period=regression_period, \
|
529
|
+
attention_value=attention_value,attention_value_area=attention_value_area, \
|
530
|
+
attention_point=attention_point,attention_point_area=attention_point_area, \
|
479
531
|
graph=graph,axhline_value=0,axhline_label='', \
|
480
532
|
loc1=loc1, \
|
481
533
|
printout=printout, \
|
@@ -491,7 +543,9 @@ def security_trend(ticker,indicator='Close',adjust='', \
|
|
491
543
|
df=compare_beta_security(ticker=tickers,start=fromdate,end=todate, \
|
492
544
|
adjust=adjust, \
|
493
545
|
RF=RF,regression_period=regression_period, \
|
494
|
-
|
546
|
+
attention_value=attention_value,attention_value_area=attention_value_area, \
|
547
|
+
attention_point=attention_point,attention_point_area=attention_point_area, \
|
548
|
+
graph=graph,facecolor=facecolor,loc=loc1, \
|
495
549
|
annotate=annotate,annotate_value=annotate_value, \
|
496
550
|
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
|
497
551
|
mktidx=market_index,source=source, \
|
@@ -506,12 +560,14 @@ def security_trend(ticker,indicator='Close',adjust='', \
|
|
506
560
|
preprocess=preprocess,scaling_option=scaling_option, \
|
507
561
|
twinx=twinx,loc1=loc1,loc2=loc2, \
|
508
562
|
graph=graph,facecolor=facecolor, \
|
563
|
+
attention_value=attention_value,attention_value_area=attention_value_area, \
|
564
|
+
attention_point=attention_point,attention_point_area=attention_point_area, \
|
509
565
|
annotate=annotate,annotate_value=annotate_value, \
|
510
566
|
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end)
|
511
567
|
return df
|
512
568
|
|
513
569
|
# 其他未预料情形
|
514
|
-
print(" #
|
570
|
+
print(" #Warning(security_trend): unexpected combination of security(ies) and indicator(s):-(")
|
515
571
|
|
516
572
|
return None
|
517
573
|
|