siat 3.5.11__py3-none-any.whl → 3.6.1__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 +39 -11
- siat/common.py +14 -7
- siat/grafix.py +285 -29
- siat/option_china.py +1 -1
- siat/risk_adjusted_return2.py +55 -7
- siat/security_prices.py +2 -0
- siat/security_trend2.py +70 -14
- siat/stock.py +94 -18
- siat/stooq.py +2 -1
- siat/translate.py +5 -3
- siat/valuation.py +29 -12
- siat/yf_name.py +127 -3
- {siat-3.5.11.dist-info → siat-3.6.1.dist-info}/METADATA +1 -1
- {siat-3.5.11.dist-info → siat-3.6.1.dist-info}/RECORD +17 -17
- {siat-3.5.11.dist-info → siat-3.6.1.dist-info}/LICENSE +0 -0
- {siat-3.5.11.dist-info → siat-3.6.1.dist-info}/WHEEL +0 -0
- {siat-3.5.11.dist-info → siat-3.6.1.dist-info}/top_level.txt +0 -0
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,9 @@ 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='', \
|
813
|
+
attention_point='', \
|
814
|
+
|
807
815
|
graph=True,loc1='best', \
|
808
816
|
axhline_value=0,axhline_label='',facecolor='whitesmoke', \
|
809
817
|
printout=False,sortby='tpw_mean',trailing=7,trend_threshhold=0.01, \
|
@@ -904,6 +912,9 @@ def compare_1ticker_mrar(ticker,start,end,rar=['sharpe','sortino','treynor','alp
|
|
904
912
|
draw_lines(df1,y_label,x_label=footnotex, \
|
905
913
|
axhline_value=axhline_value,axhline_label=axhline_label, \
|
906
914
|
title_txt=title_txt,data_label=False, \
|
915
|
+
attention_value=attention_value, \
|
916
|
+
attention_point=attention_point, \
|
917
|
+
|
907
918
|
annotate=annotate,annotate_value=annotate, \
|
908
919
|
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
|
909
920
|
facecolor=facecolor,loc=loc1)
|
@@ -962,7 +973,9 @@ if __name__=='__main__':
|
|
962
973
|
rars=compare_mticker_1rar(ticker=["600519.SS","000858.SZ"],start="2024-1-1",end="2024-6-16",rar='sharpe',printout=True)
|
963
974
|
|
964
975
|
def compare_mticker_1rar(ticker,start,end,rar='sharpe', \
|
965
|
-
ret_type="Annual Ret%",RF=0,regression_period=365, \
|
976
|
+
ret_type="Annual Adj Ret%",RF=0,regression_period=365, \
|
977
|
+
attention_value='', \
|
978
|
+
attention_point='', \
|
966
979
|
graph=True,loc1='best', \
|
967
980
|
axhline_value=0,axhline_label='', \
|
968
981
|
printout=False,sortby='tpw_mean',trailing=7,trend_threshhold=0.01, \
|
@@ -1084,6 +1097,9 @@ def compare_mticker_1rar(ticker,start,end,rar='sharpe', \
|
|
1084
1097
|
draw_lines(df1,y_label,x_label=footnotex, \
|
1085
1098
|
axhline_value=axhline_value,axhline_label=axhline_label, \
|
1086
1099
|
title_txt=title_txt,data_label=False, \
|
1100
|
+
attention_value=attention_value, \
|
1101
|
+
attention_point=attention_point, \
|
1102
|
+
|
1087
1103
|
annotate=annotate,annotate_value=annotate, \
|
1088
1104
|
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
|
1089
1105
|
facecolor=facecolor,loc=loc1)
|
@@ -1138,7 +1154,9 @@ if __name__=='__main__':
|
|
1138
1154
|
rars=compare_mticker_mrar(ticker,start,end,rar,graph=False,printout=True)
|
1139
1155
|
|
1140
1156
|
def compare_mticker_mrar(ticker,start,end,rar=['sharpe','alpha','sortino','treynor'], \
|
1141
|
-
ret_type="Annual Ret%",RF=0,regression_period=365, \
|
1157
|
+
ret_type="Annual Adj Ret%",RF=0,regression_period=365, \
|
1158
|
+
attention_value='', \
|
1159
|
+
attention_point='', \
|
1142
1160
|
graph=True,loc1='best', \
|
1143
1161
|
axhline_value=0,axhline_label='', \
|
1144
1162
|
printout=True,sortby='tpw_mean',trailing=7,trend_threshhold=0.01, \
|
@@ -1167,6 +1185,8 @@ def compare_mticker_mrar(ticker,start,end,rar=['sharpe','alpha','sortino','treyn
|
|
1167
1185
|
#with HiddenPrints(): #此项将压制所有print输出,造成表头脚注不显示
|
1168
1186
|
_,df_tmp=compare_mticker_1rar(ticker=ticker,start=start,end=end,rar=r, \
|
1169
1187
|
ret_type=ret_type,RF=RF,regression_period=regression_period, \
|
1188
|
+
attention_value=attention_value, \
|
1189
|
+
attention_point=attention_point, \
|
1170
1190
|
graph=graph,facecolor=facecolor, \
|
1171
1191
|
axhline_value=axhline_value,axhline_label=axhline_label, \
|
1172
1192
|
printout=printout,sortby=sortby, \
|
@@ -1340,8 +1360,10 @@ if __name__=='__main__':
|
|
1340
1360
|
rars=compare_1ticker_1rar_mret(ticker,start,end,rar,ret_type,printout=True)
|
1341
1361
|
|
1342
1362
|
def compare_1ticker_1rar_mret(ticker,start,end,rar='sharpe', \
|
1343
|
-
ret_type=["Annual Ret%","Monthly Ret%"], \
|
1363
|
+
ret_type=["Annual Adj Ret%","Monthly Adj Ret%"], \
|
1344
1364
|
RF=0,regression_period=365, \
|
1365
|
+
attention_value='', \
|
1366
|
+
attention_point='', \
|
1345
1367
|
graph=True,loc1='best', \
|
1346
1368
|
axhline_value=0,axhline_label='',facecolor='whitesmoke', \
|
1347
1369
|
printout=False,sortby='tpw_mean',trailing=7,trend_threshhold=0.01, \
|
@@ -1373,7 +1395,7 @@ def compare_1ticker_1rar_mret(ticker,start,end,rar='sharpe', \
|
|
1373
1395
|
RF=RF[0]
|
1374
1396
|
if isinstance(regression_period,list):
|
1375
1397
|
regression_period=regression_period[0]
|
1376
|
-
print("
|
1398
|
+
print(" Working on",rar,"for",ticker_name(ticker,ticker_type),"in different returns, please wait ......\n")
|
1377
1399
|
|
1378
1400
|
df=pd.DataFrame()
|
1379
1401
|
for t in ret_type:
|
@@ -1435,6 +1457,8 @@ def compare_1ticker_1rar_mret(ticker,start,end,rar='sharpe', \
|
|
1435
1457
|
draw_lines(df1,y_label,x_label=footnotex, \
|
1436
1458
|
axhline_value=axhline_value,axhline_label=axhline_label, \
|
1437
1459
|
title_txt=title_txt,data_label=False, \
|
1460
|
+
attention_value=attention_value, \
|
1461
|
+
attention_point=attention_point, \
|
1438
1462
|
annotate=annotate,annotate_value=annotate, \
|
1439
1463
|
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
|
1440
1464
|
facecolor=facecolor,loc=loc1)
|
@@ -1490,7 +1514,9 @@ if __name__=='__main__':
|
|
1490
1514
|
rars=compare_1ticker_1rar_1ret_mRF(ticker,start,end,rar,ret_type,RF)
|
1491
1515
|
|
1492
1516
|
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, \
|
1517
|
+
ret_type="Annual Adj Ret%",RF=[0,0.02,0.05],regression_period=365, \
|
1518
|
+
attention_value='', \
|
1519
|
+
attention_point='', \
|
1494
1520
|
graph=True,loc1='best', \
|
1495
1521
|
axhline_value=0,axhline_label='',facecolor='whitesmoke', \
|
1496
1522
|
printout=False,sortby='tpw_mean',trailing=7,trend_threshhold=0.01, \
|
@@ -1579,6 +1605,8 @@ def compare_1ticker_1rar_1ret_mRF(ticker,start,end,rar='sharpe', \
|
|
1579
1605
|
draw_lines(df1,y_label,x_label=footnotex, \
|
1580
1606
|
axhline_value=axhline_value,axhline_label=axhline_label, \
|
1581
1607
|
title_txt=title_txt,data_label=False, \
|
1608
|
+
attention_value=attention_value, \
|
1609
|
+
attention_point=attention_point, \
|
1582
1610
|
annotate=annotate,annotate_value=annotate, \
|
1583
1611
|
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
|
1584
1612
|
facecolor=facecolor,loc=loc1)
|
@@ -1652,6 +1680,8 @@ def compare_rar_security(ticker,start,end,rar='sharpe', \
|
|
1652
1680
|
ret_type="Annual Adj Ret%", \
|
1653
1681
|
RF=0, \
|
1654
1682
|
regression_period=365, \
|
1683
|
+
attention_value='', \
|
1684
|
+
attention_point='', \
|
1655
1685
|
graph=True,loc1='best', \
|
1656
1686
|
axhline_value=0,axhline_label='',facecolor='whitesmoke', \
|
1657
1687
|
printout=False,sortby='tpw_mean',trailing=7,trend_threshhold=0.05, \
|
@@ -1683,6 +1713,9 @@ def compare_rar_security(ticker,start,end,rar='sharpe', \
|
|
1683
1713
|
if rar_num ==1: #一个RAR
|
1684
1714
|
df=compare_mticker_1rar(ticker=ticker,start=start,end=end,rar=rar, \
|
1685
1715
|
ret_type=ret_type,RF=RF,regression_period=regression_period, \
|
1716
|
+
attention_value=attention_value, \
|
1717
|
+
attention_point=attention_point, \
|
1718
|
+
|
1686
1719
|
graph=graph,loc1=loc1, \
|
1687
1720
|
axhline_value=axhline_value,axhline_label=axhline_label, \
|
1688
1721
|
printout=printout, \
|
@@ -1697,6 +1730,9 @@ def compare_rar_security(ticker,start,end,rar='sharpe', \
|
|
1697
1730
|
printout=True #否则无法运行descriptive_statistics2函数
|
1698
1731
|
df=compare_mticker_mrar(ticker=ticker,start=start,end=end,rar=rar, \
|
1699
1732
|
ret_type=ret_type,RF=RF,regression_period=regression_period, \
|
1733
|
+
attention_value=attention_value, \
|
1734
|
+
attention_point=attention_point, \
|
1735
|
+
|
1700
1736
|
graph=graph,loc1=loc1, \
|
1701
1737
|
axhline_value=axhline_value,axhline_label=axhline_label, \
|
1702
1738
|
printout=printout, \
|
@@ -1720,6 +1756,9 @@ def compare_rar_security(ticker,start,end,rar='sharpe', \
|
|
1720
1756
|
|
1721
1757
|
df=compare_1ticker_mrar(ticker=ticker,start=start,end=end,rar=rar, \
|
1722
1758
|
ret_type=ret_type,RF=RF,regression_period=regression_period, \
|
1759
|
+
attention_value=attention_value, \
|
1760
|
+
attention_point=attention_point, \
|
1761
|
+
|
1723
1762
|
graph=graph,loc1=loc1, \
|
1724
1763
|
axhline_value=axhline_value,axhline_label=axhline_label, \
|
1725
1764
|
printout=printout,facecolor=facecolor, \
|
@@ -1741,6 +1780,9 @@ def compare_rar_security(ticker,start,end,rar='sharpe', \
|
|
1741
1780
|
|
1742
1781
|
df=compare_1ticker_1rar_mret(ticker=ticker,start=start,end=end,rar=rar, \
|
1743
1782
|
ret_type=ret_type,RF=RF,regression_period=regression_period, \
|
1783
|
+
attention_value=attention_value, \
|
1784
|
+
attention_point=attention_point, \
|
1785
|
+
|
1744
1786
|
graph=graph,loc1=loc1, \
|
1745
1787
|
axhline_value=axhline_value,axhline_label=axhline_label, \
|
1746
1788
|
printout=printout, \
|
@@ -1760,6 +1802,9 @@ def compare_rar_security(ticker,start,end,rar='sharpe', \
|
|
1760
1802
|
|
1761
1803
|
df=compare_1ticker_1rar_1ret_mRF(ticker=ticker,start=start,end=end,rar=rar, \
|
1762
1804
|
ret_type=ret_type,RF=RF,regression_period=regression_period, \
|
1805
|
+
attention_value=attention_value, \
|
1806
|
+
attention_point=attention_point, \
|
1807
|
+
|
1763
1808
|
graph=graph,loc1=loc1, \
|
1764
1809
|
axhline_value=axhline_value,axhline_label=axhline_label, \
|
1765
1810
|
printout=printout,facecolor=facecolor, \
|
@@ -1776,6 +1821,9 @@ def compare_rar_security(ticker,start,end,rar='sharpe', \
|
|
1776
1821
|
#情形5:1只证券,1个RAR,1个收益率类型,1个RF
|
1777
1822
|
df=compare_1ticker_mrar(ticker=ticker,start=start,end=end,rar=rar, \
|
1778
1823
|
ret_type=ret_type,RF=RF,regression_period=regression_period, \
|
1824
|
+
attention_value=attention_value, \
|
1825
|
+
attention_point=attention_point, \
|
1826
|
+
|
1779
1827
|
graph=graph,loc1=loc1, \
|
1780
1828
|
axhline_value=axhline_value,axhline_label=axhline_label, \
|
1781
1829
|
printout=printout,sortby=sortby, \
|
siat/security_prices.py
CHANGED
@@ -2850,6 +2850,7 @@ def fetch_price_swindex(ticker,start,end,info_types=['Close','Volume'],adjust=-2
|
|
2850
2850
|
info_types:信息测度,默认['Close'],还可以为['Close','Open','High','Low',
|
2851
2851
|
'Volume','Adj Close']
|
2852
2852
|
特点:为compare_indicator使用,包括指数名称
|
2853
|
+
|
2853
2854
|
"""
|
2854
2855
|
df=None
|
2855
2856
|
|
@@ -2867,6 +2868,7 @@ def fetch_price_swindex(ticker,start,end,info_types=['Close','Volume'],adjust=-2
|
|
2867
2868
|
ticker=ticker+'.SW'
|
2868
2869
|
ticker6=ticker[:6]
|
2869
2870
|
try:
|
2871
|
+
# 注意:如果失败,尝试升级akshare
|
2870
2872
|
prices= ak.index_hist_sw(symbol=ticker6,period="day")
|
2871
2873
|
except:
|
2872
2874
|
try:
|
siat/security_trend2.py
CHANGED
@@ -123,21 +123,28 @@ if __name__=='__main__':
|
|
123
123
|
|
124
124
|
def security_trend(ticker,indicator='Close',adjust='', \
|
125
125
|
start='default',end='default', \
|
126
|
-
|
126
|
+
#纵轴水平线
|
127
127
|
attention_value='',average_value=False, \
|
128
|
+
#横轴垂直线
|
129
|
+
attention_point='', \
|
128
130
|
|
129
|
-
kline=False,kline_demo=False,mav=[5,
|
131
|
+
kline=False,kline_demo=False,mav=[5,20], \
|
130
132
|
|
131
133
|
dividend=False,split=False, \
|
132
|
-
|
134
|
+
|
135
|
+
#计算RAR和贝塔系数的基础参数
|
133
136
|
ret_type='Annual Adj Ret%',RF=0,regression_period=365,market_index="auto", \
|
134
137
|
sortby='tpw_mean',trailing=7,trend_threshhold=0.05, \
|
135
|
-
|
138
|
+
|
139
|
+
#绘制河流图的上下边界
|
136
140
|
band_area='', \
|
141
|
+
|
142
|
+
|
137
143
|
graph=True,twinx=False,loc1='best',loc2='best', \
|
138
144
|
datatag=False,power=0, \
|
139
145
|
smooth=True,date_range=False,date_freq=False, \
|
140
|
-
|
146
|
+
|
147
|
+
#数据预处理
|
141
148
|
preprocess='none',scaling_option='change%', \
|
142
149
|
|
143
150
|
annotate=False,annotate_value=False, \
|
@@ -211,7 +218,9 @@ def security_trend(ticker,indicator='Close',adjust='', \
|
|
211
218
|
source参数:指定证券基础数据来源,默认由系统决定。当系统找到的数据不理想时,可手动指定。
|
212
219
|
若指定雅虎财经数据源,需要拥有访问该网站的权限。
|
213
220
|
"""
|
214
|
-
|
221
|
+
DEBUG=False
|
222
|
+
|
223
|
+
#critical_value=attention_value
|
215
224
|
|
216
225
|
portfolio_flag=False #标志:ticker中是否含有投资组合
|
217
226
|
ticker=tickers_cvt2yahoo(ticker) #支持多种形式证券代码格式
|
@@ -307,8 +316,9 @@ def security_trend(ticker,indicator='Close',adjust='', \
|
|
307
316
|
# 检查趋势指标
|
308
317
|
indicator_list1=['Open','Close','Adj Close','High','Low',
|
309
318
|
'Daily Ret','Daily Ret%','Daily Adj Ret','Daily Adj Ret%',
|
310
|
-
'log(Daily Ret)','log(Daily Adj Ret)',
|
311
|
-
'Weekly
|
319
|
+
'log(Daily Ret)','log(Daily Adj Ret)',
|
320
|
+
'Weekly Ret','Weekly Ret%','Weekly Adj Ret','Weekly Adj Ret%',
|
321
|
+
'Monthly Ret','Monthly Ret%',
|
312
322
|
'Monthly Adj Ret','Monthly Adj Ret%','Quarterly Ret','Quarterly Ret%',
|
313
323
|
'Quarterly Adj Ret','Quarterly Adj Ret%','Annual Ret','Annual Ret%',
|
314
324
|
'Annual Adj Ret','Annual Adj Ret%','Exp Ret','Exp Ret%','Exp Adj Ret',
|
@@ -327,7 +337,8 @@ def security_trend(ticker,indicator='Close',adjust='', \
|
|
327
337
|
'Annual Adj Ret Volatility', 'Annual Adj Ret Volatility%',
|
328
338
|
'Exp Ret Volatility', 'Exp Ret Volatility%', 'Exp Adj Ret Volatility',
|
329
339
|
'Exp Adj Ret Volatility%', 'Weekly Ret LPSD', 'Weekly Ret LPSD%',
|
330
|
-
'Weekly Adj Ret LPSD', 'Weekly Adj Ret LPSD%',
|
340
|
+
'Weekly Adj Ret LPSD', 'Weekly Adj Ret LPSD%',
|
341
|
+
'Monthly Ret LPSD',
|
331
342
|
'Monthly Ret LPSD%', 'Monthly Adj Ret LPSD', 'Monthly Adj Ret LPSD%',
|
332
343
|
'Quarterly Ret LPSD', 'Quarterly Ret LPSD%', 'Quarterly Adj Ret LPSD',
|
333
344
|
'Quarterly Adj Ret LPSD%', 'Annual Ret LPSD', 'Annual Ret LPSD%',
|
@@ -390,17 +401,20 @@ def security_trend(ticker,indicator='Close',adjust='', \
|
|
390
401
|
return None
|
391
402
|
"""
|
392
403
|
# 情形1:单个证券,单个普通指标===============================================
|
393
|
-
#
|
404
|
+
# 绘制零线:由绘图函数自动判断
|
394
405
|
zeroline=False
|
406
|
+
"""
|
395
407
|
if (critical_value != ''):
|
396
408
|
if isinstance(critical_value,float) or isinstance(critical_value,int):
|
397
409
|
zeroline=critical_value
|
398
|
-
|
410
|
+
"""
|
399
411
|
if ticker_num==1 and indicator_num==1 and indicator_group1:
|
400
412
|
df=security_indicator(ticker=tickers[0],indicator=measures[0],adjust=adjust, \
|
401
413
|
fromdate=fromdate,todate=todate, \
|
402
414
|
zeroline=zeroline, \
|
415
|
+
attention_value=attention_value, \
|
403
416
|
average_value=average_value, \
|
417
|
+
attention_point=attention_point, \
|
404
418
|
datatag=datatag,power=power,graph=graph, \
|
405
419
|
source=source, \
|
406
420
|
mark_top=mark_top,mark_bottom=mark_bottom, \
|
@@ -410,18 +424,32 @@ def security_trend(ticker,indicator='Close',adjust='', \
|
|
410
424
|
|
411
425
|
# 情形2:单个证券,两个普通指标,twinx==True =================================
|
412
426
|
if ticker_num==1 and indicator_num == 2 and indicator_group1 and twinx:
|
427
|
+
if DEBUG:
|
428
|
+
print("Scenario 2: ticker_num==1 and indicator_num == 2 and indicator_group1 and twinx")
|
429
|
+
print("attention_value=",attention_value)
|
430
|
+
print("attention_point=",attention_point)
|
431
|
+
|
413
432
|
df=compare_security(tickers=tickers[0],measures=measures[:2], \
|
414
433
|
adjust=adjust, \
|
415
434
|
fromdate=fromdate,todate=todate,twinx=twinx, \
|
435
|
+
attention_value=attention_value, \
|
436
|
+
attention_point=attention_point, \
|
416
437
|
loc1=loc1,loc2=loc2,graph=graph,source=source, \
|
417
438
|
ticker_type=ticker_type,facecolor=facecolor)
|
418
439
|
return df
|
419
440
|
|
420
441
|
# 情形3:单个证券,两个及以上普通指标,twinx==False ==========================
|
421
442
|
if ticker_num==1 and indicator_num >= 2 and indicator_group1 and not twinx:
|
443
|
+
if DEBUG:
|
444
|
+
print("Scenario 3: ticker_num==1 and indicator_num >= 2 and indicator_group1 and not twinx")
|
445
|
+
print("attention_value=",attention_value)
|
446
|
+
print("attention_point=",attention_point)
|
447
|
+
|
422
448
|
df=security_mindicators(ticker=tickers[0],measures=measures, \
|
423
449
|
adjust=adjust, \
|
424
450
|
fromdate=fromdate,todate=todate, \
|
451
|
+
attention_value=attention_value, \
|
452
|
+
attention_point=attention_point, \
|
425
453
|
graph=graph,smooth=smooth,band_area=band_area,loc=loc1, \
|
426
454
|
date_range=date_range,date_freq=date_freq, \
|
427
455
|
annotate=annotate,annotate_value=annotate_value, \
|
@@ -432,9 +460,16 @@ def security_trend(ticker,indicator='Close',adjust='', \
|
|
432
460
|
|
433
461
|
# 情形4:两个证券,取第一个普通指标,twinx==True =============================
|
434
462
|
if ticker_num==2 and indicator_group1 and twinx:
|
463
|
+
if DEBUG:
|
464
|
+
print("Scenario 4: ticker_num==2 and indicator_group1 and twinx")
|
465
|
+
print("attention_value=",attention_value)
|
466
|
+
print("attention_point=",attention_point)
|
467
|
+
|
435
468
|
df=compare_security(tickers=tickers,measures=measures[0], \
|
436
469
|
adjust=adjust, \
|
437
470
|
fromdate=fromdate,todate=todate,twinx=twinx, \
|
471
|
+
attention_value=attention_value, \
|
472
|
+
attention_point=attention_point, \
|
438
473
|
loc1=loc1,loc2=loc2,graph=graph,source=source, \
|
439
474
|
ticker_type=ticker_type,facecolor=facecolor)
|
440
475
|
return df
|
@@ -450,14 +485,22 @@ def security_trend(ticker,indicator='Close',adjust='', \
|
|
450
485
|
# 绘制横线
|
451
486
|
axhline_value=0
|
452
487
|
axhline_label=''
|
488
|
+
"""
|
453
489
|
if (critical_value != ''):
|
454
490
|
if isinstance(critical_value,float) or isinstance(critical_value,int):
|
455
491
|
axhline_value=critical_value
|
456
492
|
axhline_label='零线'
|
457
|
-
|
493
|
+
"""
|
458
494
|
if ((ticker_num == 2 and not twinx) or ticker_num > 2) and indicator_group1:
|
495
|
+
if DEBUG:
|
496
|
+
print("Scenario 5: ((ticker_num == 2 and not twinx) or ticker_num > 2) and indicator_group1")
|
497
|
+
print("attention_value=",attention_value)
|
498
|
+
print("attention_point=",attention_point)
|
499
|
+
|
459
500
|
df=compare_msecurity(tickers=tickers,measure=measures[0], \
|
460
501
|
start=fromdate,end=todate, \
|
502
|
+
attention_value=attention_value, \
|
503
|
+
attention_point=attention_point, \
|
461
504
|
adjust=adjust, \
|
462
505
|
axhline_value=axhline_value,axhline_label=axhline_label, \
|
463
506
|
preprocess=preprocess,linewidth=linewidth, \
|
@@ -474,8 +517,15 @@ def security_trend(ticker,indicator='Close',adjust='', \
|
|
474
517
|
# 注意:收益率类型支持滚动收益率和扩展收益率,但不建议混合使用,因为难以解释结果
|
475
518
|
# 复权价:使用ret_type为xx Adj Ret%即可
|
476
519
|
if indicator_group2:
|
520
|
+
if DEBUG:
|
521
|
+
print("Scenario 6: indicator_group2 RAR")
|
522
|
+
print("attention_value=",attention_value)
|
523
|
+
print("attention_point=",attention_point)
|
524
|
+
|
477
525
|
df=compare_rar_security(ticker=tickers,start=fromdate,end=todate,rar=measures, \
|
478
526
|
ret_type=ret_type,RF=RF,regression_period=regression_period, \
|
527
|
+
attention_value=attention_value, \
|
528
|
+
attention_point=attention_point, \
|
479
529
|
graph=graph,axhline_value=0,axhline_label='', \
|
480
530
|
loc1=loc1, \
|
481
531
|
printout=printout, \
|
@@ -491,7 +541,10 @@ def security_trend(ticker,indicator='Close',adjust='', \
|
|
491
541
|
df=compare_beta_security(ticker=tickers,start=fromdate,end=todate, \
|
492
542
|
adjust=adjust, \
|
493
543
|
RF=RF,regression_period=regression_period, \
|
494
|
-
|
544
|
+
attention_value=attention_value, \
|
545
|
+
attention_point=attention_point, \
|
546
|
+
|
547
|
+
graph=graph,facecolor=facecolor,loc=loc1, \
|
495
548
|
annotate=annotate,annotate_value=annotate_value, \
|
496
549
|
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
|
497
550
|
mktidx=market_index,source=source, \
|
@@ -506,12 +559,15 @@ def security_trend(ticker,indicator='Close',adjust='', \
|
|
506
559
|
preprocess=preprocess,scaling_option=scaling_option, \
|
507
560
|
twinx=twinx,loc1=loc1,loc2=loc2, \
|
508
561
|
graph=graph,facecolor=facecolor, \
|
562
|
+
attention_value=attention_value, \
|
563
|
+
attention_point=attention_point, \
|
564
|
+
|
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
|
|