siat 3.0.3__py3-none-any.whl → 3.0.10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- siat/allin.py +2 -1
- siat/beta_adjustment.py +7 -0
- siat/beta_adjustment_china.py +4 -0
- siat/bond.py +14 -0
- siat/bond_base.py +2 -1
- siat/capm_beta.py +4 -0
- siat/common.py +17 -2
- siat/cryptocurrency.py +4 -0
- siat/fama_french.py +20 -2
- siat/financials.py +2 -0
- siat/financials2.py +2 -0
- siat/financials_china.py +2 -0
- siat/grafix.py +23 -1
- siat/holding_risk.py +2 -0
- siat/markowitz.py +47 -20
- siat/markowitz2.py +2422 -0
- siat/option_china.py +3 -0
- siat/option_pricing.py +2 -0
- siat/risk_adjusted_return.py +7 -0
- siat/risk_adjusted_return2.py +34 -24
- siat/risk_evaluation.py +11 -1
- siat/sector_china.py +2 -0
- siat/stock.py +5 -2
- siat/stock_profile.py +25 -1
- siat/stock_technical.py +35 -10
- {siat-3.0.3.dist-info → siat-3.0.10.dist-info}/METADATA +1 -1
- {siat-3.0.3.dist-info → siat-3.0.10.dist-info}/RECORD +29 -28
- {siat-3.0.3.dist-info → siat-3.0.10.dist-info}/WHEEL +0 -0
- {siat-3.0.3.dist-info → siat-3.0.10.dist-info}/top_level.txt +0 -0
siat/option_china.py
CHANGED
@@ -2316,6 +2316,7 @@ def fin_option_risk_sse2(option,maturity,exercise,trade_date, \
|
|
2316
2316
|
#use font size 14 for the bar labels, percentages, and legend, 图例颜色
|
2317
2317
|
plt.legend(fontsize=16,loc=loc)
|
2318
2318
|
|
2319
|
+
plt.gca().set_facecolor('whitesmoke')
|
2319
2320
|
plt.show
|
2320
2321
|
|
2321
2322
|
return df9
|
@@ -2582,6 +2583,8 @@ def fin_option_exercise_risk_sse(option,maturity,trade_date, \
|
|
2582
2583
|
|
2583
2584
|
titletxt='上交所金融期权风险:'+option+'期权,股指点位对'+ylabeltxt+'的影响'
|
2584
2585
|
plt.title(titletxt,fontweight='bold',fontsize=title_txt_size)
|
2586
|
+
|
2587
|
+
plt.gca().set_facecolor('whitesmoke')
|
2585
2588
|
plt.show()
|
2586
2589
|
plt.close()
|
2587
2590
|
|
siat/option_pricing.py
CHANGED
siat/risk_adjusted_return.py
CHANGED
@@ -497,6 +497,7 @@ def draw_rar_ratio(rars,portfolio,ratio_name):
|
|
497
497
|
#plt.ylabel(ylabeltxt,fontsize=12)
|
498
498
|
#plt.xticks(rotation=45,fontsize=9)
|
499
499
|
plt.gcf().autofmt_xdate() # 优化标注(自动倾斜)
|
500
|
+
plt.gca().set_facecolor('whitesmoke')
|
500
501
|
#plt.xticks(rotation=30,fontsize=8)
|
501
502
|
plt.legend(loc='best')
|
502
503
|
|
@@ -946,7 +947,10 @@ def plot_rar_monthly(portfolio,start,end,rar_type):
|
|
946
947
|
titletxt="投资组合的风险调整收益"
|
947
948
|
plt.title(titletxt)
|
948
949
|
plt.ylabel('收益率(%)')
|
950
|
+
|
949
951
|
plt.gcf().autofmt_xdate() # 优化标注(自动倾斜)
|
952
|
+
plt.gca().set_facecolor('whitesmoke')
|
953
|
+
|
950
954
|
#plt.xticks(rotation=30)
|
951
955
|
plt.legend(loc='best')
|
952
956
|
|
@@ -1033,7 +1037,10 @@ def plot_rar_annual(portfolio,start,end,rar_type):
|
|
1033
1037
|
titletxt="投资组合的风险调整收益"
|
1034
1038
|
plt.title(titletxt)
|
1035
1039
|
plt.ylabel('收益率(%)')
|
1040
|
+
|
1036
1041
|
plt.gcf().autofmt_xdate() # 优化标注(自动倾斜)
|
1042
|
+
plt.gca().set_facecolor('whitesmoke')
|
1043
|
+
|
1037
1044
|
#plt.xticks(rotation=45)
|
1038
1045
|
plt.legend(loc='best')
|
1039
1046
|
|
siat/risk_adjusted_return2.py
CHANGED
@@ -547,7 +547,7 @@ def compare_1ticker_mrar(ticker,start,end,rar=['sharpe','sortino','treynor','alp
|
|
547
547
|
regression_period=regression_period[0]
|
548
548
|
|
549
549
|
tname=ticker_name(ticker,ticker_type)
|
550
|
-
print(" Starting to retrive and calculate different rar for",tname,"\b, please wait
|
550
|
+
print(" Starting to retrive and calculate different rar for",tname,"\b, please wait ......\n")
|
551
551
|
|
552
552
|
#预处理ticker_type
|
553
553
|
ticker_type=ticker_type_preprocess_mticker_mixed(ticker,ticker_type)
|
@@ -590,7 +590,7 @@ def compare_1ticker_mrar(ticker,start,end,rar=['sharpe','sortino','treynor','alp
|
|
590
590
|
|
591
591
|
footnote3=''
|
592
592
|
if 'treynor' in rar or 'alpha' in rar:
|
593
|
-
footnote3="
|
593
|
+
footnote3="贝塔系数回归期间"+str(regression_period)+"个自然日"
|
594
594
|
|
595
595
|
import datetime; todaydt = datetime.date.today()
|
596
596
|
footnote4="数据来源: 综合新浪/stooq/Yahoo,"+str(todaydt)+"统计"
|
@@ -628,10 +628,11 @@ def compare_1ticker_mrar(ticker,start,end,rar=['sharpe','sortino','treynor','alp
|
|
628
628
|
elif sortby=='trailing':
|
629
629
|
sortby_txt='按推荐标记+短期均值走势降序排列'
|
630
630
|
|
631
|
-
title_txt='***** 风险调整收益评估:'+tname+','+sortby_txt+' *****'
|
631
|
+
#title_txt='***** 风险调整收益评估:'+tname+','+sortby_txt+' *****'
|
632
|
+
title_txt='风险调整收益评估:'+tname+','+sortby_txt
|
632
633
|
|
633
634
|
footnote6='期间范围:'+str(start)+'至'+str(end)+";近期范围:近"+str(trailing)+"个交易日。趋势变化率阈值:"+str(trend_threshhold)+"。"
|
634
|
-
footnote7="
|
635
|
+
footnote7="近期优先趋势和星号为多项因素综合研判,最多五颗星"
|
635
636
|
footnotey=footnote6+footnote7+'\n'+footnotex
|
636
637
|
|
637
638
|
recommenddf=descriptive_statistics2(df1,title_txt,footnotey,decimals=4, \
|
@@ -690,7 +691,7 @@ def compare_mticker_1rar(ticker,start,end,rar='sharpe', \
|
|
690
691
|
RF=RF[0]
|
691
692
|
if isinstance(regression_period,list):
|
692
693
|
regression_period=regression_period[0]
|
693
|
-
print(" Starting to retrive and calculate",rar,"\b, please wait
|
694
|
+
print(" Starting to retrive and calculate",rar,"\b, please wait ......\n")
|
694
695
|
|
695
696
|
#预处理ticker_type
|
696
697
|
ticker_type_list=ticker_type_preprocess_mticker_mixed(ticker,ticker_type)
|
@@ -736,7 +737,7 @@ def compare_mticker_1rar(ticker,start,end,rar='sharpe', \
|
|
736
737
|
|
737
738
|
footnote3=''
|
738
739
|
if rar.lower() in ['treynor','alpha']:
|
739
|
-
footnote3="
|
740
|
+
footnote3="贝塔系数回归期间"+str(regression_period)+"个自然日"
|
740
741
|
|
741
742
|
import datetime; todaydt = datetime.date.today()
|
742
743
|
footnote4="数据来源: 综合新浪/stooq/Yahoo,"+str(todaydt)+"统计"
|
@@ -768,10 +769,11 @@ def compare_mticker_1rar(ticker,start,end,rar='sharpe', \
|
|
768
769
|
elif sortby=='trailing':
|
769
770
|
sortby_txt='按推荐标记+短期均值走势降序排列'
|
770
771
|
|
771
|
-
title_txt='***** 风险调整收益评估:基于'+ectranslate(rar)+','+sortby_txt+' *****'
|
772
|
+
#title_txt='***** 风险调整收益评估:基于'+ectranslate(rar)+','+sortby_txt+' *****'
|
773
|
+
title_txt='风险调整收益评估:基于'+ectranslate(rar)+','+sortby_txt
|
772
774
|
|
773
775
|
footnote6='期间范围:'+str(start)+'至'+str(end)+";近期范围:近"+str(trailing)+"个交易日。趋势变化率阈值:"+str(trend_threshhold)
|
774
|
-
footnote7="
|
776
|
+
footnote7="近期优先趋势和星号为风险调整收益指标数值加趋势等多项因素综合研判,最多五颗星"
|
775
777
|
footnotey=footnote6+'\n'+footnote7+'\n'+footnotex
|
776
778
|
|
777
779
|
#删除含有Nan的行,否则可能引起近期优先加权平均计算结果市场出现Nan
|
@@ -864,17 +866,22 @@ def compare_mticker_mrar(ticker,start,end,rar=['sharpe','alpha','sortino','treyn
|
|
864
866
|
sortby_txt='中位数值优先'
|
865
867
|
elif sortby=='trailing':
|
866
868
|
sortby_txt='短期均值走势优先'
|
867
|
-
|
868
|
-
titletxt='===风险调整收益综合对比:'+sortby_txt+'==='
|
869
|
-
print("\n"+titletxt)
|
870
869
|
|
871
870
|
df1=df.copy()
|
872
871
|
df1.reset_index(drop=True,inplace=True)
|
873
872
|
df1.index=df1.index + 1
|
874
873
|
|
875
|
-
|
874
|
+
# 处理表格标题
|
875
|
+
#titletxt='===风险调整收益综合对比:'+sortby_txt+'==='
|
876
|
+
titletxt='风险调整收益综合对比:'+sortby_txt
|
877
|
+
#print("\n"+titletxt)
|
878
|
+
df2=df1.style.set_caption(titletxt).set_table_styles(
|
879
|
+
[{'selector':'caption',
|
880
|
+
'props':[('color','black'),('font-size','16px'),('font-weight','bold')]}])
|
881
|
+
|
882
|
+
df3= df2.set_properties(**{'text-align':'center'})
|
876
883
|
from IPython.display import display
|
877
|
-
display(
|
884
|
+
display(df3)
|
878
885
|
|
879
886
|
"""
|
880
887
|
print(df1.to_string(justify='left'))
|
@@ -912,7 +919,7 @@ def compare_mticker_mrar(ticker,start,end,rar=['sharpe','alpha','sortino','treyn
|
|
912
919
|
"""
|
913
920
|
|
914
921
|
#脚注
|
915
|
-
footnote1="
|
922
|
+
footnote1="风险调整收益基于"+ectranslate(ret_type)+","
|
916
923
|
if RF !=0:
|
917
924
|
footnote2="年化无风险利率"+str(round(RF*100,4))+'%'
|
918
925
|
else:
|
@@ -920,7 +927,7 @@ def compare_mticker_mrar(ticker,start,end,rar=['sharpe','alpha','sortino','treyn
|
|
920
927
|
|
921
928
|
footnote3=''
|
922
929
|
if 'treynor' in rar or 'alpha' in rar:
|
923
|
-
footnote3="
|
930
|
+
footnote3="贝塔系数回归期间"+str(regression_period)+"个自然日"
|
924
931
|
|
925
932
|
import datetime; todaydt = datetime.date.today()
|
926
933
|
footnote4="数据来源: 综合新浪/stooq/Yahoo,"+str(todaydt)+"统计"
|
@@ -929,7 +936,8 @@ def compare_mticker_mrar(ticker,start,end,rar=['sharpe','alpha','sortino','treyn
|
|
929
936
|
else:
|
930
937
|
footnotex=footnote1+footnote2+'\n'+footnote4
|
931
938
|
|
932
|
-
print("\n"+footnotex)
|
939
|
+
#print("\n"+footnotex)
|
940
|
+
print(footnotex)
|
933
941
|
|
934
942
|
return df
|
935
943
|
|
@@ -983,7 +991,7 @@ def compare_1ticker_1rar_mret(ticker,start,end,rar='sharpe', \
|
|
983
991
|
RF=RF[0]
|
984
992
|
if isinstance(regression_period,list):
|
985
993
|
regression_period=regression_period[0]
|
986
|
-
print(" Starting to retrive and calculate",rar,"for",ticker_name(ticker,ticker_type),"on different types of return, please wait
|
994
|
+
print(" Starting to retrive and calculate",rar,"for",ticker_name(ticker,ticker_type),"on different types of return, please wait ......\n")
|
987
995
|
|
988
996
|
df=pd.DataFrame()
|
989
997
|
for t in ret_type:
|
@@ -1024,7 +1032,7 @@ def compare_1ticker_1rar_mret(ticker,start,end,rar='sharpe', \
|
|
1024
1032
|
|
1025
1033
|
footnote3=''
|
1026
1034
|
if rar.lower() in ['treynor','alpha']:
|
1027
|
-
footnote3="
|
1035
|
+
footnote3="贝塔系数回归期间"+str(regression_period)+"个自然日"
|
1028
1036
|
|
1029
1037
|
import datetime; todaydt = datetime.date.today()
|
1030
1038
|
footnote4="数据来源: 综合新浪/stooq/Yahoo,"+str(todaydt)+"统计"
|
@@ -1057,10 +1065,11 @@ def compare_1ticker_1rar_mret(ticker,start,end,rar='sharpe', \
|
|
1057
1065
|
elif sortby=='trailing':
|
1058
1066
|
sortby_txt='按推荐标记+短期均值走势降序排列'
|
1059
1067
|
|
1060
|
-
title_txt='***** 风险调整收益评估:'+'基于'+ectranslate(rar)+','+ticker_name(ticker,ticker_type)+','+sortby_txt+' *****'
|
1068
|
+
#title_txt='***** 风险调整收益评估:'+'基于'+ectranslate(rar)+','+ticker_name(ticker,ticker_type)+','+sortby_txt+' *****'
|
1069
|
+
title_txt='风险调整收益评估:'+'基于'+ectranslate(rar)+','+ticker_name(ticker,ticker_type)+','+sortby_txt
|
1061
1070
|
|
1062
1071
|
footnote6='期间范围:'+str(start)+'至'+str(end)+";近期范围:近"+str(trailing)+"个交易日。趋势变化率阈值:"+str(trend_threshhold)+"。"
|
1063
|
-
footnote7="
|
1072
|
+
footnote7="近期优先趋势和星号为多项因素综合研判,最多五颗星"
|
1064
1073
|
footnotey=footnote6+footnote7+'\n'+footnotex
|
1065
1074
|
|
1066
1075
|
#删除含有Nan的行
|
@@ -1125,7 +1134,7 @@ def compare_1ticker_1rar_1ret_mRF(ticker,start,end,rar='sharpe', \
|
|
1125
1134
|
RF=[RF]
|
1126
1135
|
if isinstance(regression_period,list):
|
1127
1136
|
regression_period=regression_period[0]
|
1128
|
-
print(" Starting to retrive and calculate",rar,"for",ticker_name(ticker,ticker_type),"on different RF, please wait
|
1137
|
+
print(" Starting to retrive and calculate",rar,"for",ticker_name(ticker,ticker_type),"on different RF, please wait ......\n")
|
1129
1138
|
|
1130
1139
|
df=pd.DataFrame()
|
1131
1140
|
for t in RF:
|
@@ -1163,7 +1172,7 @@ def compare_1ticker_1rar_1ret_mRF(ticker,start,end,rar='sharpe', \
|
|
1163
1172
|
|
1164
1173
|
footnote3=""
|
1165
1174
|
if rar.lower() in ['treynor','alpha']:
|
1166
|
-
footnote3="
|
1175
|
+
footnote3="贝塔系数回归期间"+str(regression_period)+"个自然日"
|
1167
1176
|
|
1168
1177
|
import datetime; todaydt = datetime.date.today()
|
1169
1178
|
footnote4="数据来源: 综合新浪/stooq/Yahoo,"+str(todaydt)+"统计"
|
@@ -1196,10 +1205,11 @@ def compare_1ticker_1rar_1ret_mRF(ticker,start,end,rar='sharpe', \
|
|
1196
1205
|
elif sortby=='trailing':
|
1197
1206
|
sortby_txt='按推荐标记+短期均值走势降序排列'
|
1198
1207
|
|
1199
|
-
title_txt='***** 风险调整收益评估:'+'基于'+ectranslate(rar)+','+ticker_name(ticker,ticker_type)+','+sortby_txt+' *****'
|
1208
|
+
#title_txt='***** 风险调整收益评估:'+'基于'+ectranslate(rar)+','+ticker_name(ticker,ticker_type)+','+sortby_txt+' *****'
|
1209
|
+
title_txt='风险调整收益评估:'+'基于'+ectranslate(rar)+','+ticker_name(ticker,ticker_type)+','+sortby_txt
|
1200
1210
|
|
1201
1211
|
footnote6='期间范围:'+str(start)+'至'+str(end)+";近期范围:近"+str(trailing)+"个交易日。趋势变化率阈值:"+str(trend_threshhold)+"。"
|
1202
|
-
footnote7="
|
1212
|
+
footnote7="近期优先趋势和星号为多项因素综合研判,最多五颗星"
|
1203
1213
|
footnotey=footnote6+footnote7+'\n'+footnotex
|
1204
1214
|
|
1205
1215
|
#删除含有Nan的行
|
siat/risk_evaluation.py
CHANGED
@@ -293,6 +293,8 @@ def series_VaR_normal_standard(ticker,shares,datelist, \
|
|
293
293
|
import datetime as dt; today=dt.date.today()
|
294
294
|
footnote="数据来源:新浪/stooq,"+str(today)
|
295
295
|
plt.xlabel(footnote)
|
296
|
+
|
297
|
+
plt.gca().set_facecolor('whitesmoke')
|
296
298
|
plt.show()
|
297
299
|
|
298
300
|
plt.plot(result3['VaR比例%'],c='r',lw=2)
|
@@ -302,6 +304,8 @@ def series_VaR_normal_standard(ticker,shares,datelist, \
|
|
302
304
|
#plt.gcf().autofmt_xdate() # 优化标注(自动倾斜)
|
303
305
|
plt.xticks(rotation=30)
|
304
306
|
plt.xlabel(footnote)
|
307
|
+
|
308
|
+
plt.gca().set_facecolor('whitesmoke')
|
305
309
|
plt.show()
|
306
310
|
|
307
311
|
return result2
|
@@ -404,6 +408,8 @@ def compare_VaR_normal_standard(tickerlist,shares,datelist, \
|
|
404
408
|
source="数据来源:新浪/stooq,"+str(today)
|
405
409
|
footnote=notes+'\n'+source
|
406
410
|
plt.xlabel(footnote)
|
411
|
+
|
412
|
+
plt.gca().set_facecolor('whitesmoke')
|
407
413
|
plt.show()
|
408
414
|
|
409
415
|
for t in tickerlist:
|
@@ -431,6 +437,8 @@ def compare_VaR_normal_standard(tickerlist,shares,datelist, \
|
|
431
437
|
plt.xticks(rotation=30)
|
432
438
|
plt.legend(loc='best')
|
433
439
|
plt.xlabel(footnote)
|
440
|
+
|
441
|
+
plt.gca().set_facecolor('whitesmoke')
|
434
442
|
plt.show()
|
435
443
|
|
436
444
|
return
|
@@ -589,14 +597,16 @@ def series_ES_normal_standard(ticker,shares,datelist, \
|
|
589
597
|
plt.ylabel('ES金额')
|
590
598
|
plt.xticks(rotation=30)
|
591
599
|
|
600
|
+
plt.gca().set_facecolor('whitesmoke')
|
592
601
|
plt.show()
|
593
602
|
|
594
|
-
plt.plot(result3['
|
603
|
+
plt.plot(result3['ES比例%'],c='r',lw=2)
|
595
604
|
title2=ticker_name(ticker)+": ES比例的变化,持有"+str(future_days)+"天"
|
596
605
|
plt.title(title2)
|
597
606
|
plt.ylabel('ES比例%')
|
598
607
|
plt.xticks(rotation=30)
|
599
608
|
|
609
|
+
plt.gca().set_facecolor('whitesmoke')
|
600
610
|
plt.show()
|
601
611
|
|
602
612
|
return result2
|
siat/sector_china.py
CHANGED
@@ -2426,6 +2426,8 @@ def industry_correlation_sw(df,tickers,start,end, \
|
|
2426
2426
|
|
2427
2427
|
fontxlabel={'size':corr_size}
|
2428
2428
|
plt.xlabel(footnote1+footnote2+footnote3+footnote4,fontxlabel)
|
2429
|
+
|
2430
|
+
plt.gca().set_facecolor('whitesmoke')
|
2429
2431
|
plt.show()
|
2430
2432
|
|
2431
2433
|
return df_coor
|
siat/stock.py
CHANGED
@@ -766,7 +766,8 @@ def security_mindicators(ticker,measures,fromdate,todate, \
|
|
766
766
|
date_range=False,date_freq=False, \
|
767
767
|
annotate=False,annotate_value=False, \
|
768
768
|
source='auto', \
|
769
|
-
mark_top=True,mark_bottom=True,
|
769
|
+
mark_top=True,mark_bottom=True,mark_end=True, \
|
770
|
+
ticker_type='auto'):
|
770
771
|
"""
|
771
772
|
功能:单个证券,多个指标对比
|
772
773
|
date_range=False:指定开始结束日期绘图
|
@@ -836,7 +837,7 @@ def security_mindicators(ticker,measures,fromdate,todate, \
|
|
836
837
|
data_label=False,resample_freq='6H',smooth=smooth, \
|
837
838
|
date_range=date_range,date_freq=date_freq,date_fmt='%Y-%m-%d', \
|
838
839
|
annotate=annotate,annotate_value=annotate_value, \
|
839
|
-
mark_top=mark_top,mark_bottom=mark_bottom)
|
840
|
+
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end)
|
840
841
|
|
841
842
|
return df1
|
842
843
|
|
@@ -2107,7 +2108,9 @@ def candlestick_demo(stkcd,fromdate,todate, \
|
|
2107
2108
|
|
2108
2109
|
plt.title(titletxt,fontsize=title_txt_size,fontweight='bold')
|
2109
2110
|
plt.ylabel(price_txt,fontsize=ylabel_txt_size)
|
2111
|
+
|
2110
2112
|
plt.gcf().autofmt_xdate() # 优化标注(自动倾斜)
|
2113
|
+
plt.gca().set_facecolor('whitesmoke')
|
2111
2114
|
#plt.xticks(rotation=30)
|
2112
2115
|
plt.legend(loc="best",fontsize=legend_txt_size)
|
2113
2116
|
plt.xlabel(source_txt+"sina/stooq/yahoo",fontsize=xlabel_txt_size)
|
siat/stock_profile.py
CHANGED
@@ -341,6 +341,8 @@ def ploth_sustainability(sustainability,option="ESG"):
|
|
341
341
|
graf=plt.barh(s.index,s['ESGscore'],facecolor='b',height=0.6,alpha=0.8)
|
342
342
|
else:
|
343
343
|
graf=plt.barh(s.index,s['ESGscore'],facecolor='b',alpha=0.8)
|
344
|
+
|
345
|
+
plt.gca().set_facecolor('whitesmoke')
|
344
346
|
plt.show()
|
345
347
|
|
346
348
|
if option=="EP":
|
@@ -358,6 +360,8 @@ def ploth_sustainability(sustainability,option="ESG"):
|
|
358
360
|
graf=plt.barh(s.index,s['EPscore'],facecolor='g',height=0.6,alpha=0.8)
|
359
361
|
else:
|
360
362
|
graf=plt.barh(s.index,s['EPscore'],facecolor='g',alpha=0.8)
|
363
|
+
|
364
|
+
plt.gca().set_facecolor('whitesmoke')
|
361
365
|
plt.show()
|
362
366
|
|
363
367
|
if option=="CSR":
|
@@ -375,6 +379,8 @@ def ploth_sustainability(sustainability,option="ESG"):
|
|
375
379
|
graf=plt.barh(s.index,s['CSRscore'],facecolor='tan',height=0.6,alpha=0.8)
|
376
380
|
else:
|
377
381
|
graf=plt.barh(s.index,s['CSRscore'],facecolor='tan',alpha=0.8)
|
382
|
+
|
383
|
+
plt.gca().set_facecolor('whitesmoke')
|
378
384
|
plt.show()
|
379
385
|
|
380
386
|
if option=="CG":
|
@@ -392,6 +398,8 @@ def ploth_sustainability(sustainability,option="ESG"):
|
|
392
398
|
graf=plt.barh(s.index,s['CGscore'],facecolor='y',height=0.6,alpha=0.9)
|
393
399
|
else:
|
394
400
|
graf=plt.barh(s.index,s['CGscore'],facecolor='y',alpha=0.9)
|
401
|
+
|
402
|
+
plt.gca().set_facecolor('whitesmoke')
|
395
403
|
plt.show()
|
396
404
|
|
397
405
|
#绘制分位数图
|
@@ -411,6 +419,8 @@ def ploth_sustainability(sustainability,option="ESG"):
|
|
411
419
|
graf=plt.barh(s.index,s['ESGpercentile'],facecolor='b',height=0.6,alpha=0.8)
|
412
420
|
else:
|
413
421
|
graf=plt.barh(s.index,s['ESGpercentile'],facecolor='b',alpha=0.8)
|
422
|
+
|
423
|
+
plt.gca().set_facecolor('whitesmoke')
|
414
424
|
plt.show()
|
415
425
|
|
416
426
|
if option=="EP":
|
@@ -428,6 +438,8 @@ def ploth_sustainability(sustainability,option="ESG"):
|
|
428
438
|
graf=plt.barh(s.index,s['EPpercentile'],facecolor='g',height=0.6,alpha=0.8)
|
429
439
|
else:
|
430
440
|
graf=plt.barh(s.index,s['EPpercentile'],facecolor='g',alpha=0.8)
|
441
|
+
|
442
|
+
plt.gca().set_facecolor('whitesmoke')
|
431
443
|
plt.show()
|
432
444
|
|
433
445
|
if option=="CSR":
|
@@ -445,6 +457,8 @@ def ploth_sustainability(sustainability,option="ESG"):
|
|
445
457
|
graf=plt.barh(s.index,s['CSRpercentile'],facecolor='tan',height=0.6,alpha=0.8)
|
446
458
|
else:
|
447
459
|
graf=plt.barh(s.index,s['CSRpercentile'],facecolor='tan',alpha=0.8)
|
460
|
+
|
461
|
+
plt.gca().set_facecolor('whitesmoke')
|
448
462
|
plt.show()
|
449
463
|
|
450
464
|
if option=="CG":
|
@@ -461,7 +475,9 @@ def ploth_sustainability(sustainability,option="ESG"):
|
|
461
475
|
if n < 6:
|
462
476
|
graf=plt.barh(s.index,s['CGpercentile'],facecolor='y',height=0.6,alpha=0.9)
|
463
477
|
else:
|
464
|
-
graf=plt.barh(s.index,s['CGpercentile'],facecolor='y',alpha=0.9)
|
478
|
+
graf=plt.barh(s.index,s['CGpercentile'],facecolor='y',alpha=0.9)
|
479
|
+
|
480
|
+
plt.gca().set_facecolor('whitesmoke')
|
465
481
|
plt.show()
|
466
482
|
|
467
483
|
return
|
@@ -523,6 +539,8 @@ def plot_sustainability(sustainability,option="ESG"):
|
|
523
539
|
titletxt="Corporate Sustainability Performance (ESG)"
|
524
540
|
fonttitle={'family':'Times New Roman','weight':'normal','size':24}
|
525
541
|
plt.title(titletxt,fonttitle)
|
542
|
+
|
543
|
+
plt.gca().set_facecolor('whitesmoke')
|
526
544
|
plt.show()
|
527
545
|
|
528
546
|
if option=="EP":
|
@@ -545,6 +563,8 @@ def plot_sustainability(sustainability,option="ESG"):
|
|
545
563
|
titletxt="Corporate Environment Protection Performance (EP)"
|
546
564
|
fonttitle={'family':'Times New Roman','weight':'normal','size':22}
|
547
565
|
plt.title(titletxt,fonttitle)
|
566
|
+
|
567
|
+
plt.gca().set_facecolor('whitesmoke')
|
548
568
|
plt.show()
|
549
569
|
|
550
570
|
if option=="CSR":
|
@@ -567,6 +587,8 @@ def plot_sustainability(sustainability,option="ESG"):
|
|
567
587
|
titletxt="Corporate Social Responsibility Performance (CSR)"
|
568
588
|
fonttitle={'family':'Times New Roman','weight':'normal','size':22}
|
569
589
|
plt.title(titletxt,fonttitle)
|
590
|
+
|
591
|
+
plt.gca().set_facecolor('whitesmoke')
|
570
592
|
plt.show()
|
571
593
|
|
572
594
|
if option=="CG":
|
@@ -589,6 +611,8 @@ def plot_sustainability(sustainability,option="ESG"):
|
|
589
611
|
titletxt="Corporate Governance Performance (CG)"
|
590
612
|
fonttitle={'family':'Times New Roman','weight':'normal','size':24}
|
591
613
|
plt.title(titletxt,fonttitle)
|
614
|
+
|
615
|
+
plt.gca().set_facecolor('whitesmoke')
|
592
616
|
plt.show()
|
593
617
|
|
594
618
|
return
|
siat/stock_technical.py
CHANGED
@@ -2444,11 +2444,16 @@ def security_technical2(ticker,start='default',end='default', \
|
|
2444
2444
|
technical=['MACD'],indicator='Close', \
|
2445
2445
|
graph=['ALL'],printout=False, \
|
2446
2446
|
loc1='best',loc2='best', \
|
2447
|
-
ticker_type='auto'
|
2447
|
+
ticker_type='auto', \
|
2448
|
+
|
2449
|
+
facecolor='papayawhip'):
|
2448
2450
|
"""
|
2451
|
+
|
2449
2452
|
功能:计算和绘制证券技术分析指标的简易图,仅供进一步探索使用,仅用于单个证券(股债基)
|
2450
|
-
|
2451
|
-
|
2453
|
+
支持的探索指标:仅供探索使用
|
2454
|
+
OBV、SAR、VOL、PSY、ARBR、CR、EMV、TRIX、DMA、BIAS、CCI、W%R、ROC、DMI
|
2455
|
+
支持的其他指标:不如单独的指令功能强
|
2456
|
+
MACD、RSI、KDJ、BOLL
|
2452
2457
|
"""
|
2453
2458
|
#检查证券代码
|
2454
2459
|
if not isinstance(ticker,str):
|
@@ -2496,17 +2501,32 @@ def security_technical2(ticker,start='default',end='default', \
|
|
2496
2501
|
df=calc_technical(price,fromdate,todate, \
|
2497
2502
|
RSI_days=RSI_days, \
|
2498
2503
|
OBV_days=OBV_days, \
|
2504
|
+
|
2499
2505
|
MA_days=MA_days, \
|
2500
|
-
MACD_fastperiod=MACD_fastperiod,
|
2501
|
-
|
2502
|
-
|
2503
|
-
|
2506
|
+
MACD_fastperiod=MACD_fastperiod, \
|
2507
|
+
MACD_slowperiod=MACD_slowperiod, \
|
2508
|
+
MACD_signalperiod=MACD_signalperiod, \
|
2509
|
+
|
2510
|
+
KDJ_fastk_period=KDJ_fastk_period, \
|
2511
|
+
KDJ_slowk_period=KDJ_slowk_period, \
|
2512
|
+
KDJ_slowk_matype=KDJ_slowk_matype, \
|
2513
|
+
KDJ_slowd_period=KDJ_slowd_period, \
|
2514
|
+
KDJ_slowd_matype=KDJ_slowd_matype, \
|
2515
|
+
|
2516
|
+
VOL_fastperiod=VOL_fastperiod, \
|
2517
|
+
VOL_slowperiod=VOL_slowperiod, \
|
2518
|
+
|
2504
2519
|
PSY_days=PSY_days, \
|
2505
2520
|
ARBR_days=ARBR_days, \
|
2506
2521
|
CR_day=CR_day,CR_madays=CR_madays, \
|
2507
2522
|
EMV_day=EMV_day,EMV_madays=EMV_madays, \
|
2508
|
-
|
2509
|
-
|
2523
|
+
|
2524
|
+
BULL_days=BULL_days,BULL_nbdevup=BULL_nbdevup, \
|
2525
|
+
BULL_nbdevdn=BULL_nbdevdn,BULL_matype=BULL_matype, \
|
2526
|
+
|
2527
|
+
DMA_fastperiod=DMA_fastperiod, \
|
2528
|
+
DMA_slowperiod=DMA_slowperiod,DMA_madays=DMA_madays, \
|
2529
|
+
|
2510
2530
|
TRIX_day=TRIX_day,TRIX_madays=TRIX_madays, \
|
2511
2531
|
BIAS_days=BIAS_days, \
|
2512
2532
|
CCI_days=CCI_days, \
|
@@ -2589,10 +2609,13 @@ def security_technical2(ticker,start='default',end='default', \
|
|
2589
2609
|
tech_line_collist.sort()
|
2590
2610
|
df1=df[tech_line_collist+[indicator]]
|
2591
2611
|
|
2592
|
-
|
2612
|
+
#绘图----------------------------------------------------------------------
|
2593
2613
|
import matplotlib.pyplot as plt
|
2614
|
+
|
2594
2615
|
fig = plt.figure()
|
2595
2616
|
ax = fig.add_subplot(111)
|
2617
|
+
#plt.gca().set_facecolor('whitesmoke')
|
2618
|
+
plt.gca().set_facecolor(facecolor) #放在这里生效,放尾部不生效
|
2596
2619
|
|
2597
2620
|
line0=False; line30=False; line50=False; line80=False
|
2598
2621
|
for l in tech_line_collist:
|
@@ -2631,7 +2654,9 @@ def security_technical2(ticker,start='default',end='default', \
|
|
2631
2654
|
|
2632
2655
|
titletxt=ticker_name(ticker)+': '+tech_list[technical1]+technical1
|
2633
2656
|
plt.title(titletxt,fontweight='bold',fontsize=title_txt_size)
|
2657
|
+
|
2634
2658
|
plt.gcf().autofmt_xdate()
|
2659
|
+
|
2635
2660
|
plt.show(); plt.close()
|
2636
2661
|
|
2637
2662
|
return df
|