siat 2.14.2__py3-none-any.whl → 3.0.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/allin.py +1 -0
- siat/assets_liquidity.py +16 -16
- siat/beta_adjustment.py +6 -6
- siat/beta_adjustment_china.py +9 -9
- siat/bond.py +71 -67
- siat/capm_beta.py +11 -11
- siat/capm_beta2.py +49 -23
- siat/common.py +427 -60
- siat/compare_cross.py +15 -82
- siat/exchange_bond_china.pickle +0 -0
- siat/fama_french.py +3 -3
- siat/financials.py +15 -15
- siat/financials2.py +8 -8
- siat/financials_china.py +20 -20
- siat/financials_china2.py +25 -25
- siat/fund_china.pickle +0 -0
- siat/fund_china.py +5 -4
- siat/grafix.py +195 -132
- siat/markowitz.py +6 -5
- siat/option_china.py +1 -1
- siat/option_pricing.py +6 -6
- siat/risk_adjusted_return.py +14 -14
- siat/risk_adjusted_return2.py +64 -42
- siat/risk_evaluation.py +32 -32
- siat/risk_free_rate.py +0 -0
- siat/sector_china.py +3 -195
- siat/security_price2.py +616 -0
- siat/security_prices.py +935 -308
- siat/security_trend2.py +28 -47
- siat/stock.py +225 -437
- siat/stock_china.py +19 -19
- siat/stock_info.pickle +0 -0
- siat/stock_technical.py +547 -144
- siat/transaction.py +3 -3
- siat/translate.py +781 -24
- siat/valuation.py +6 -6
- siat/var_model_validation.py +2 -2
- {siat-2.14.2.dist-info → siat-3.0.1.dist-info}/METADATA +1 -1
- {siat-2.14.2.dist-info → siat-3.0.1.dist-info}/RECORD +41 -40
- {siat-2.14.2.dist-info → siat-3.0.1.dist-info}/WHEEL +0 -0
- {siat-2.14.2.dist-info → siat-3.0.1.dist-info}/top_level.txt +0 -0
siat/risk_evaluation.py
CHANGED
@@ -223,7 +223,7 @@ def stock_VaR_normal_standard(ticker,shares,today, \
|
|
223
223
|
|
224
224
|
if printout == True:
|
225
225
|
print("\n=== 计算在险价值:标准正态模型 ===")
|
226
|
-
print("持有股票 :",
|
226
|
+
print("持有股票 :",ticker_name(ticker))
|
227
227
|
print("持有股数 :",format(shares,','))
|
228
228
|
print("持有日期 :",today)
|
229
229
|
print("预计持有天数:",future_days)
|
@@ -274,7 +274,7 @@ def series_VaR_normal_standard(ticker,shares,datelist, \
|
|
274
274
|
result3['VaR比例%']=round(result3['ratio']*100,2)
|
275
275
|
result3.drop(columns=['ticker','VaR','ratio'],inplace=True)
|
276
276
|
|
277
|
-
text1="= "+
|
277
|
+
text1="= "+ticker_name(ticker)+": VaR比例,持有"+str(future_days)+"天 ="
|
278
278
|
print(text1)
|
279
279
|
print(result3)
|
280
280
|
import datetime as dt; today=dt.date.today()
|
@@ -283,7 +283,7 @@ def series_VaR_normal_standard(ticker,shares,datelist, \
|
|
283
283
|
#绘图
|
284
284
|
#VaR金额绘图
|
285
285
|
plt.plot(result3['VaR金额'],c='r',lw=2)
|
286
|
-
title1=
|
286
|
+
title1=ticker_name(ticker)+": VaR金额的变化,持有"+str(future_days)+"天"
|
287
287
|
plt.title(title1)
|
288
288
|
plt.ylabel('VaR金额')
|
289
289
|
#plt.gcf().autofmt_xdate() # 优化标注(自动倾斜)
|
@@ -295,7 +295,7 @@ def series_VaR_normal_standard(ticker,shares,datelist, \
|
|
295
295
|
plt.show()
|
296
296
|
|
297
297
|
plt.plot(result3['VaR比例%'],c='r',lw=2)
|
298
|
-
title2=
|
298
|
+
title2=ticker_name(ticker)+": VaR比例的变化, 持有"+str(future_days)+"天"
|
299
299
|
plt.title(title2)
|
300
300
|
plt.ylabel('VaR比例%')
|
301
301
|
#plt.gcf().autofmt_xdate() # 优化标注(自动倾斜)
|
@@ -390,7 +390,7 @@ def compare_VaR_normal_standard(tickerlist,shares,datelist, \
|
|
390
390
|
rr['date']=rr['date'].apply(lambda x: pd.to_datetime(x))
|
391
391
|
rr.set_index(['date'],inplace=True)
|
392
392
|
|
393
|
-
plt.plot(rr['VaR amount'],label=
|
393
|
+
plt.plot(rr['VaR amount'],label=ticker_name(t),lw=2,marker=thismarker)
|
394
394
|
|
395
395
|
title1="比较VaR金额,持有"+str(future_days)+"天"
|
396
396
|
plt.title(title1)
|
@@ -422,7 +422,7 @@ def compare_VaR_normal_standard(tickerlist,shares,datelist, \
|
|
422
422
|
rr.set_index(['date'],inplace=True)
|
423
423
|
|
424
424
|
|
425
|
-
plt.plot(rr['VaR ratio %'],label=
|
425
|
+
plt.plot(rr['VaR ratio %'],label=ticker_name(t),lw=2,marker=thismarker)
|
426
426
|
|
427
427
|
title2="比较VaR比例,持有"+str(future_days)+"天"
|
428
428
|
plt.title(title2)
|
@@ -526,7 +526,7 @@ def stock_ES_normal_standard(ticker,shares,today, \
|
|
526
526
|
|
527
527
|
if printout == True:
|
528
528
|
print("\n=== 计算预期不足ES:标准正态模型 ===")
|
529
|
-
print("持有股票 :",
|
529
|
+
print("持有股票 :",ticker_name(ticker))
|
530
530
|
print("持有股数 :",format(shares,','))
|
531
531
|
print("持有日期 :",today)
|
532
532
|
print("预计持有天数:",future_days)
|
@@ -574,7 +574,7 @@ def series_ES_normal_standard(ticker,shares,datelist, \
|
|
574
574
|
result3['ES比例%']=round(result3['ratio']*100,2)
|
575
575
|
result3.drop(columns=['ticker','ES','ratio'],inplace=True)
|
576
576
|
|
577
|
-
text1="=== "+
|
577
|
+
text1="=== "+ticker_name(ticker)+": ES比例,持有"+str(future_days)+"天 ==="
|
578
578
|
print(text1)
|
579
579
|
print(result3)
|
580
580
|
import datetime as dt; today=dt.date.today()
|
@@ -583,7 +583,7 @@ def series_ES_normal_standard(ticker,shares,datelist, \
|
|
583
583
|
#绘图
|
584
584
|
#VaR金额绘图
|
585
585
|
plt.plot(result3['ES金额'],c='r',lw=2)
|
586
|
-
title1=
|
586
|
+
title1=ticker_name(ticker)+": ES金额的变化,持有"+str(future_days)+"天"
|
587
587
|
plt.title(title1)
|
588
588
|
plt.ylabel('ES金额')
|
589
589
|
plt.xticks(rotation=30)
|
@@ -591,7 +591,7 @@ def series_ES_normal_standard(ticker,shares,datelist, \
|
|
591
591
|
plt.show()
|
592
592
|
|
593
593
|
plt.plot(result3['EES比例%'],c='r',lw=2)
|
594
|
-
title2=
|
594
|
+
title2=ticker_name(ticker)+": ES比例的变化,持有"+str(future_days)+"天"
|
595
595
|
plt.title(title2)
|
596
596
|
plt.ylabel('ES比例%')
|
597
597
|
plt.xticks(rotation=30)
|
@@ -659,7 +659,7 @@ def compare_ES_normal_standard(tickerlist,shares,datelist, \
|
|
659
659
|
rr=r.copy()
|
660
660
|
rr['ES amount']=round(rr['ES'],2)
|
661
661
|
rr.drop(columns=['ticker','ES','ratio'],inplace=True)
|
662
|
-
plt.plot(rr['ES amount'],label=
|
662
|
+
plt.plot(rr['ES amount'],label=ticker_name(t),lw=2,marker=thismarker)
|
663
663
|
|
664
664
|
title1="比较ES金额,持有"+str(future_days)+"天"
|
665
665
|
plt.title(title1)
|
@@ -684,7 +684,7 @@ def compare_ES_normal_standard(tickerlist,shares,datelist, \
|
|
684
684
|
rr=r.copy()
|
685
685
|
rr['ES ratio %']=round(rr['ratio']*100,2)
|
686
686
|
rr.drop(columns=['ticker','ES','ratio'],inplace=True)
|
687
|
-
plt.plot(rr['ES ratio %'],label=
|
687
|
+
plt.plot(rr['ES ratio %'],label=ticker_name(t),lw=2,marker=thismarker)
|
688
688
|
|
689
689
|
title2="比较ES比例,持有"+str(future_days)+"天"
|
690
690
|
plt.title(title2)
|
@@ -732,7 +732,7 @@ def plot_rets_histogram(ticker,start,end,num_bins=20):
|
|
732
732
|
|
733
733
|
#绘制股票收益率直方图
|
734
734
|
plt.figure(figsize=(8,4))
|
735
|
-
n,bins,patches=plt.hist(rets,num_bins,facecolor='blue',alpha=0.5,label=
|
735
|
+
n,bins,patches=plt.hist(rets,num_bins,facecolor='blue',alpha=0.5,label=ticker_name(ticker))
|
736
736
|
|
737
737
|
#生成与直方图柱子对应的正态分布概率密度
|
738
738
|
y=normfunc(bins,mu,sigma)
|
@@ -740,7 +740,7 @@ def plot_rets_histogram(ticker,start,end,num_bins=20):
|
|
740
740
|
plt.plot(bins,y,'r--',label='正态分布',lw=2)
|
741
741
|
plt.ylabel('Frequency')
|
742
742
|
plt.xlabel('Stock return')
|
743
|
-
titletxt="正态性检验:"+
|
743
|
+
titletxt="正态性检验:"+ticker_name(ticker)+"股票收益率, "+start+"至"+end
|
744
744
|
plt.title(titletxt)
|
745
745
|
plt.legend(loc='best')
|
746
746
|
|
@@ -781,14 +781,14 @@ def plot_rets_curve(ticker,start,end):
|
|
781
781
|
#plt.figure(figsize=(8,4))
|
782
782
|
import seaborn as sns
|
783
783
|
#绘制曲线:股票收益率
|
784
|
-
sns.kdeplot(data=rets,shade=True,color='blue',legend=True,label=
|
784
|
+
sns.kdeplot(data=rets,shade=True,color='blue',legend=True,label=ticker_name(ticker),lw=2)
|
785
785
|
#绘制曲线:对应的正态分布
|
786
786
|
sns.kdeplot(data=x,shade=True,color='r',legend=True,label='正态分布',ls='--')
|
787
787
|
#设置标题、图例、坐标轴标签
|
788
788
|
plt.ylabel('',fontsize=ylabel_txt_size)
|
789
789
|
#plt.xlabel('收益率')
|
790
790
|
plt.legend(loc='best',fontsize=legend_txt_size)
|
791
|
-
titletxt="正态性检验: "+
|
791
|
+
titletxt="正态性检验: "+ticker_name(ticker)+",股票收益率, "+start+"至"+end
|
792
792
|
plt.title(titletxt,fontsize=title_txt_size)
|
793
793
|
|
794
794
|
import datetime as dt; today=dt.date.today()
|
@@ -822,7 +822,7 @@ def stock_ret_Normality_SW(ticker,start_date,end_date,siglevel=0.05):
|
|
822
822
|
(W,p_value)=stats.shapiro(ret)
|
823
823
|
|
824
824
|
print("\n= Shapiro-Wilk正态性检验: 股票收益率 =")
|
825
|
-
print("股票 :",
|
825
|
+
print("股票 :",ticker_name(ticker))
|
826
826
|
print("期间 :",start_date,"至",end_date)
|
827
827
|
print("原假设: 符合正态分布")
|
828
828
|
print("W值 :",round(W,4))
|
@@ -895,7 +895,7 @@ def stock_VaR_normal_modified(ticker,shares,today, \
|
|
895
895
|
|
896
896
|
if printout == True:
|
897
897
|
print("\n=== 在险价值VaR: 修正正态模型 ===")
|
898
|
-
print("持有股票 :",
|
898
|
+
print("持有股票 :",ticker_name(ticker))
|
899
899
|
print("持有股数 :",format(shares,','))
|
900
900
|
print("持有日期 :",today)
|
901
901
|
print("预计持有天数:",future_days)
|
@@ -940,7 +940,7 @@ def series_VaR_normal_modified(ticker,shares,datelist, \
|
|
940
940
|
result3['VaR比例%']=round(result3['ratio']*100,2)
|
941
941
|
result3.drop(columns=['ticker','VaR','ratio'],inplace=True)
|
942
942
|
|
943
|
-
text1="= "+
|
943
|
+
text1="= "+ticker_name(ticker)+": VaR比例,持有"+str(future_days)+"天 ="
|
944
944
|
print(text1)
|
945
945
|
print(result3)
|
946
946
|
import datetime as dt; today=dt.date.today()
|
@@ -949,7 +949,7 @@ def series_VaR_normal_modified(ticker,shares,datelist, \
|
|
949
949
|
#绘图
|
950
950
|
#VaR金额绘图
|
951
951
|
plt.plot(result3['VaR金额'],c='r',lw=2)
|
952
|
-
title1=
|
952
|
+
title1=ticker_name(ticker)+": VaR金额的变化,持有"+str(future_days)+"天"
|
953
953
|
plt.title(title1)
|
954
954
|
plt.ylabel('VaR金额')
|
955
955
|
plt.xticks(rotation=30)
|
@@ -959,7 +959,7 @@ def series_VaR_normal_modified(ticker,shares,datelist, \
|
|
959
959
|
plt.show()
|
960
960
|
|
961
961
|
plt.plot(result3['VaR比例%'],c='r',lw=2)
|
962
|
-
title2=
|
962
|
+
title2=ticker_name(ticker)+": VaR比例的变化,持有"+str(future_days)+"天"
|
963
963
|
plt.title(title2)
|
964
964
|
plt.ylabel('VaR比例%')
|
965
965
|
plt.xticks(rotation=30)
|
@@ -1000,7 +1000,7 @@ def compare_VaR_normal_modified(tickerlist,shares,datelist, \
|
|
1000
1000
|
rr=r.copy()
|
1001
1001
|
rr['VaR amount']=round(rr['VaR'],2)
|
1002
1002
|
rr.drop(columns=['ticker','VaR','ratio'],inplace=True)
|
1003
|
-
plt.plot(rr['VaR amount'],label=
|
1003
|
+
plt.plot(rr['VaR amount'],label=ticker_name(t),lw=2,marker=thismarker)
|
1004
1004
|
|
1005
1005
|
title1="比较VaR金额,持有"+str(future_days)+"天"
|
1006
1006
|
plt.title(title1)
|
@@ -1025,7 +1025,7 @@ def compare_VaR_normal_modified(tickerlist,shares,datelist, \
|
|
1025
1025
|
rr=r.copy()
|
1026
1026
|
rr['VaR ratio %']=round(rr['ratio']*100,2)
|
1027
1027
|
rr.drop(columns=['ticker','VaR','ratio'],inplace=True)
|
1028
|
-
plt.plot(rr['VaR ratio %'],label=
|
1028
|
+
plt.plot(rr['VaR ratio %'],label=ticker_name(t),lw=2,marker=thismarker)
|
1029
1029
|
|
1030
1030
|
title2="比较VaR比例,持有"+str(future_days)+"天"
|
1031
1031
|
plt.title(title2)
|
@@ -1091,7 +1091,7 @@ def stock_VaR_historical_1d(ticker,shares,today,alpha=0.99, \
|
|
1091
1091
|
|
1092
1092
|
if printout == True:
|
1093
1093
|
print("\n=== 计算在险价值VaR:历史模拟方法 ===")
|
1094
|
-
print("持有股票 :",
|
1094
|
+
print("持有股票 :",ticker_name(ticker))
|
1095
1095
|
print("持有股数 :",format(shares,','))
|
1096
1096
|
print("持有日期 :",today)
|
1097
1097
|
future_days=1
|
@@ -1198,7 +1198,7 @@ def stock_VaR_historical_grouping(ticker,shares,today, \
|
|
1198
1198
|
|
1199
1199
|
if printout == True:
|
1200
1200
|
print("\n=== 在险价值VaR:"+modeltxt+" ===")
|
1201
|
-
print("持有股票 :",
|
1201
|
+
print("持有股票 :",ticker_name(ticker))
|
1202
1202
|
print("持有股数 :",format(shares,','))
|
1203
1203
|
print("持有日期 :",today)
|
1204
1204
|
print("预计持有天数:",future_days)
|
@@ -1273,7 +1273,7 @@ def stock_VaR_montecarlo(ticker,shares,today,future_days=1,alpha=0.99, \
|
|
1273
1273
|
if printout == True:
|
1274
1274
|
print("\n=== 在险价值VaR:蒙特卡洛模拟法 ===")
|
1275
1275
|
print("持有日期 :",today)
|
1276
|
-
print("持有股票 :",
|
1276
|
+
print("持有股票 :",ticker_name(ticker))
|
1277
1277
|
print("持有股数 :",format(shares,','))
|
1278
1278
|
print("持有头寸 :",format(round(position,2),','))
|
1279
1279
|
print("预计持有天数:",future_days)
|
@@ -1334,7 +1334,7 @@ def calc_VaR_tlcp(ticker,today,alpha=0.99, \
|
|
1334
1334
|
if stop1==0:
|
1335
1335
|
if printout == True:
|
1336
1336
|
print("\n=== VaR的全损临界点TLCP ===")
|
1337
|
-
print("持有股票 :",
|
1337
|
+
print("持有股票 :",ticker_name(ticker))
|
1338
1338
|
print("持有日期 :",today)
|
1339
1339
|
print("使用的模型:",model)
|
1340
1340
|
print("置信度 : ",alpha*100,'%',sep='')
|
@@ -1374,7 +1374,7 @@ def calc_VaR_tlcp(ticker,today,alpha=0.99, \
|
|
1374
1374
|
|
1375
1375
|
if printout == True:
|
1376
1376
|
print("\n=== VaR的全损临界点TLCP ===")
|
1377
|
-
print("持有股票 :",
|
1377
|
+
print("持有股票 :",ticker_name(ticker))
|
1378
1378
|
print("持有日期 :",today)
|
1379
1379
|
print("使用的模型:",model)
|
1380
1380
|
print("置信度 : ",alpha*100,'%',sep='')
|
@@ -1507,12 +1507,12 @@ def plot_VaR_days_changes(ticker,shares,today,dayslist,alpha=0.99, \
|
|
1507
1507
|
if printout == True:
|
1508
1508
|
plt.figure(figsize=(8,4))
|
1509
1509
|
#绘制曲线:ratio
|
1510
|
-
plt.plot(vardf['ratio%'],color='red',lw=2,label=
|
1510
|
+
plt.plot(vardf['ratio%'],color='red',lw=2,label=ticker_name(ticker),marker=markertype)
|
1511
1511
|
#设置标题、图例、坐标轴标签
|
1512
1512
|
plt.ylabel('VaR比例%')
|
1513
1513
|
plt.legend(loc='best')
|
1514
1514
|
titlel1="持有股票期间与VaR比例的变化趋势"
|
1515
|
-
titlel2="\n"+
|
1515
|
+
titlel2="\n"+ticker_name(ticker)+", "+today+", 使用模型"+model
|
1516
1516
|
titletxt=titlel1+titlel2
|
1517
1517
|
plt.title(titletxt)
|
1518
1518
|
|
@@ -1566,7 +1566,7 @@ def compare_VaR_days_changes(tickerlist,shares,today,dayslist,alpha=0.99, \
|
|
1566
1566
|
print("Information:",t,today,pastyears,model)
|
1567
1567
|
continue
|
1568
1568
|
|
1569
|
-
plt.plot(vardf['ratio%'],lw=2,label=
|
1569
|
+
plt.plot(vardf['ratio%'],lw=2,label=ticker_name(t),marker=thismarker)
|
1570
1570
|
|
1571
1571
|
#设置标题、图例、坐标轴标签
|
1572
1572
|
plt.ylabel('VaR比例%')
|
@@ -1635,7 +1635,7 @@ def get_VaR_allmodels(ticker,shares,today, \
|
|
1635
1635
|
|
1636
1636
|
print("\n==== 不同模型下VaR的计算结果 ====")
|
1637
1637
|
print("持有日期 :",today)
|
1638
|
-
print("持有股票 :",
|
1638
|
+
print("持有股票 :",ticker_name(ticker))
|
1639
1639
|
print("持有股数 :",format(shares,','))
|
1640
1640
|
print("持有头寸 :",format(round(position,2),','))
|
1641
1641
|
print("预计持有天数:",future_days)
|
siat/risk_free_rate.py
CHANGED
Binary file
|
siat/sector_china.py
CHANGED
@@ -662,172 +662,6 @@ def invest_concept_china(num=10):
|
|
662
662
|
return finaldf
|
663
663
|
|
664
664
|
|
665
|
-
#==============================================================================
|
666
|
-
#==============================================================================
|
667
|
-
#申万行业分类:https://www.swhyresearch.com/institute_sw/allIndex/analysisIndex
|
668
|
-
#==============================================================================
|
669
|
-
#==============================================================================
|
670
|
-
def industry_sw_list():
|
671
|
-
"""
|
672
|
-
功能:输出申万指数代码df。静态
|
673
|
-
输入:
|
674
|
-
输出:df
|
675
|
-
"""
|
676
|
-
import pandas as pd
|
677
|
-
industry=pd.DataFrame([
|
678
|
-
|
679
|
-
#市场表征指数F,一级行业I,二级行业T,风格策略S
|
680
|
-
['F','801001','申万50'],['F','801002','申万中小'],['F','801003','申万A指'],
|
681
|
-
['F','801005','申万创业'],['F','801250','申万制造'],['F','801260','申万消费'],
|
682
|
-
['F','801270','申万投资'],['F','801280','申万服务'],['F','801300','申万300指数'],
|
683
|
-
['I','801010','农林牧渔'],['I','801030','基础化工'],['I','801040','钢铁'],
|
684
|
-
['I','801050','有色金属'],['I','801080','电子'],['I','801110','家用电器'],
|
685
|
-
['I','801120','食品饮料'],['I','801130','纺织服饰'],['I','801140','轻工制造'],
|
686
|
-
['I','801150','医药生物'],['I','801160','公用事业'],['I','801170','交通运输'],
|
687
|
-
['I','801180','房地产'],['I','801200','商贸零售'],['I','801210','社会服务'],
|
688
|
-
['I','801230','综合'],['I','801710','建筑材料'],['I','801720','建筑装饰'],
|
689
|
-
['I','801730','电力设备'],['I','801740','国防军工'],['I','801750','计算机'],
|
690
|
-
['I','801760','传媒'],['I','801770','通信'],['I','801780','银行'],
|
691
|
-
['I','801790','非银金融'],['I','801880','汽车'],['I','801890','机械设备'],
|
692
|
-
['I','801950','煤炭'],['I','801960','石油石化'],['I','801970','环保'],
|
693
|
-
['I','801980','美容护理'],['T','801012','农产品加工'],['T','801014','饲料'],
|
694
|
-
['T','801015','渔业'],['T','801016','种植业'],['T','801017','养殖业'],
|
695
|
-
['T','801018','动物保健Ⅱ'],['T','801032','化学纤维'],['T','801033','化学原料'],
|
696
|
-
['T','801034','化学制品'],['T','801036','塑料'],['T','801037','橡胶'],
|
697
|
-
['T','801038','农化制品'],['T','801039','非金属材料Ⅱ'],['T','801043','冶钢原料'],
|
698
|
-
['T','801044','普钢'],['T','801045','特钢Ⅱ'],['T','801051','金属新材料'],
|
699
|
-
['T','801053','贵金属'],['T','801054','小金属'],['T','801055','工业金属'],
|
700
|
-
['T','801056','能源金属'],['T','801072','通用设备'],['T','801074','专用设备'],
|
701
|
-
['T','801076','轨交设备Ⅱ'],['T','801077','工程机械'],['T','801078','自动化设备'],
|
702
|
-
['T','801081','半导体'],['T','801082','其他电子Ⅱ'],['T','801083','元件'],
|
703
|
-
['T','801084','光学光电子'],['T','801085','消费电子'],['T','801086','电子化学品Ⅱ'],
|
704
|
-
['T','801092','汽车服务'],['T','801093','汽车零部件'],['T','801095','乘用车'],
|
705
|
-
['T','801096','商用车'],['T','801101','计算机设备'],['T','801102','通信设备'],
|
706
|
-
['T','801103','IT服务Ⅱ'],['T','801104','软件开发'],['T','801111','白色家电'],
|
707
|
-
['T','801112','黑色家电'],['T','801113','小家电'],['T','801114','厨卫电器'],
|
708
|
-
['T','801115','照明设备Ⅱ'],['T','801116','家电零部件Ⅱ'],['T','801124','食品加工'],
|
709
|
-
['T','801125','白酒Ⅱ'],['T','801126','非白酒'],['T','801127','饮料乳品'],
|
710
|
-
['T','801128','休闲食品'],['T','801129','调味发酵品Ⅱ'],['T','801131','纺织制造'],
|
711
|
-
['T','801132','服装家纺'],['T','801133','饰品'],['T','801141','包装印刷'],
|
712
|
-
['T','801142','家居用品'],['T','801143','造纸'],['T','801145','文娱用品'],
|
713
|
-
['T','801151','化学制药'],['T','801152','生物制品'],['T','801153','医疗器械'],
|
714
|
-
['T','801154','医药商业'],['T','801155','中药Ⅱ'],['T','801156','医疗服务'],
|
715
|
-
['T','801161','电力'],['T','801163','燃气Ⅱ'],['T','801178','物流'],
|
716
|
-
['T','801179','铁路公路'],['T','801181','房地产开发'],['T','801183','房地产服务'],
|
717
|
-
['T','801191','多元金融'],['T','801193','证券Ⅱ'],['T','801194','保险Ⅱ'],
|
718
|
-
['T','801202','贸易Ⅱ'],['T','801203','一般零售'],['T','801204','专业连锁Ⅱ'],
|
719
|
-
['T','801206','互联网电商'],['T','801218','专业服务'],['T','801219','酒店餐饮'],
|
720
|
-
['T','801223','通信服务'],['T','801231','综合Ⅱ'],['T','801711','水泥'],
|
721
|
-
['T','801712','玻璃玻纤'],['T','801713','装修建材'],['T','801721','房屋建设Ⅱ'],
|
722
|
-
['T','801722','装修装饰Ⅱ'],['T','801723','基础建设'],['T','801724','专业工程'],
|
723
|
-
['T','801726','工程咨询服务Ⅱ'],['T','801731','电机Ⅱ'],['T','801733','其他电源设备Ⅱ'],
|
724
|
-
['T','801735','光伏设备'],['T','801736','风电设备'],['T','801737','电池'],
|
725
|
-
['T','801738','电网设备'],['T','801741','航天装备Ⅱ'],['T','801742','航空装备Ⅱ'],
|
726
|
-
['T','801743','地面兵装Ⅱ'],['T','801744','航海装备Ⅱ'],['T','801745','军工电子Ⅱ'],
|
727
|
-
['T','801764','游戏Ⅱ'],['T','801765','广告营销'],['T','801766','影视院线'],
|
728
|
-
['T','801767','数字媒体'],['T','801769','出版'],['T','801782','国有大型银行Ⅱ'],
|
729
|
-
['T','801783','股份制银行Ⅱ'],['T','801784','城商行Ⅱ'],['T','801785','农商行Ⅱ'],
|
730
|
-
['T','801881','摩托车及其他'],['T','801951','煤炭开采'],['T','801952','焦炭Ⅱ'],
|
731
|
-
['T','801962','油服工程'],['T','801963','炼化及贸易'],['T','801971','环境治理'],
|
732
|
-
['T','801972','环保设备Ⅱ'],['T','801981','个护用品'],['T','801982','化妆品'],
|
733
|
-
['T','801991','航空机场'],['T','801992','航运港口'],['T','801993','旅游及景区'],
|
734
|
-
['T','801994','教育'],['T','801995','电视广播Ⅱ'],['S','801811','大盘指数'],
|
735
|
-
['S','801812','中盘指数'],['S','801813','小盘指数'],['S','801821','高市盈率指数'],
|
736
|
-
['S','801822','中市盈率指数'],['S','801823','低市盈率指数'],['S','801831','高市净率指数'],
|
737
|
-
['S','801832','中市净率指数'],['S','801833','低市净率指数'],['S','801841','高价股指数'],
|
738
|
-
['S','801842','中价股指数'],['S','801843','低价股指数'],['S','801851','亏损股指数'],
|
739
|
-
['S','801852','微利股指数'],['S','801853','绩优股指数'],['S','801863','新股指数'],
|
740
|
-
['3','850111','种子'],['3','850113','其他种植业'],['3','850122','水产养殖'],
|
741
|
-
['3','850142','畜禽饲料'],['3','850151','果蔬加工'],['3','850152','粮油加工'],
|
742
|
-
['3','850154','其他农产品加工'],['3','850172','生猪养殖'],['3','850173','肉鸡养殖'],
|
743
|
-
['3','850181','动物保健Ⅲ'],['3','850322','氯碱'],['3','850323','无机盐'],
|
744
|
-
['3','850324','其他化学原料'],['3','850325','煤化工'],['3','850326','钛白粉'],
|
745
|
-
['3','850335','涂料油墨'],['3','850337','民爆制品'],['3','850338','纺织化学制品'],
|
746
|
-
['3','850339','其他化学制品'],['3','850382','氟化工'],['3','850372','聚氨酯'],
|
747
|
-
['3','850135','食品及饲料添加剂'],['3','850136','有机硅'],['3','850341','涤纶'],
|
748
|
-
['3','850343','粘胶'],['3','850351','其他塑料制品'],['3','850353','改性塑料'],
|
749
|
-
['3','850354','合成树脂'],['3','850355','膜材料'],['3','850362','其他橡胶制品'],
|
750
|
-
['3','850363','炭黑'],['3','850331','氮肥'],['3','850332','磷肥及磷化工'],
|
751
|
-
['3','850333','农药'],['3','850381','复合肥'],['3','850523','非金属材料Ⅲ'],
|
752
|
-
['3','850442','板材'],['3','850521','其他金属新材料'],['3','850522','磁性材料'],
|
753
|
-
['3','850551','铝'],['3','850552','铜'],['3','850553','铅锌'],
|
754
|
-
['3','850531','黄金'],['3','850544','其他小金属'],['3','850812','分立器件'],
|
755
|
-
['3','850813','半导体材料'],['3','850814','数字芯片设计'],['3','850815','模拟芯片设计'],
|
756
|
-
['3','850817','集成电路封测'],['3','850818','半导体设备'],['3','850822','印制电路板'],
|
757
|
-
['3','850823','被动元件'],['3','850831','面板'],['3','850832','LED'],
|
758
|
-
['3','850833','光学元件'],['3','850841','其他电子Ⅲ'],['3','850853','品牌消费电子'],
|
759
|
-
['3','850854','消费电子零部件及组装'],['3','850861','电子化学品Ⅲ'],['3','850922','车身附件及饰件'],
|
760
|
-
['3','850923','底盘与发动机系统'],['3','850924','轮胎轮毂'],['3','850925','其他汽车零部件'],
|
761
|
-
['3','850926','汽车电子电气系统'],['3','850232','汽车经销商'],['3','850233','汽车综合服务'],
|
762
|
-
['3','858811','其他运输设备'],['3','858812','摩托车'],['3','850952','综合乘用车'],
|
763
|
-
['3','850912','商用载货车'],['3','850913','商用载客车'],['3','851112','空调'],
|
764
|
-
['3','851116','冰洗'],['3','851122','其他黑色家电'],['3','851131','厨房小家电'],
|
765
|
-
['3','851141','厨房电器'],['3','851151','照明设备Ⅲ'],['3','851161','家电零部件Ⅲ'],
|
766
|
-
['3','851241','肉制品'],['3','851246','预加工食品'],['3','851247','保健品'],
|
767
|
-
['3','851251','白酒Ⅲ'],['3','851232','啤酒'],['3','851233','其他酒类'],
|
768
|
-
['3','851271','软饮料'],['3','851243','乳品'],['3','851281','零食'],
|
769
|
-
['3','851282','烘焙食品'],['3','851242','调味发酵品Ⅲ'],['3','851312','棉纺'],
|
770
|
-
['3','851314','印染'],['3','851315','辅料'],['3','851316','其他纺织'],
|
771
|
-
['3','851325','鞋帽及其他'],['3','851326','家纺'],['3','851329','非运动服装'],
|
772
|
-
['3','851331','钟表珠宝'],['3','851412','大宗用纸'],['3','851413','特种纸'],
|
773
|
-
['3','851422','印刷'],['3','851423','金属包装'],['3','851424','塑料包装'],
|
774
|
-
['3','851425','纸包装'],['3','851436','瓷砖地板'],['3','851437','成品家居'],
|
775
|
-
['3','851438','定制家居'],['3','851439','卫浴制品'],['3','851491','其他家居用品'],
|
776
|
-
['3','851452','娱乐用品'],['3','851511','原料药'],['3','851512','化学制剂'],
|
777
|
-
['3','851521','中药Ⅲ'],['3','851522','血液制品'],['3','851523','疫苗'],
|
778
|
-
['3','851524','其他生物制品'],['3','851542','医药流通'],['3','851543','线下药店'],
|
779
|
-
['3','851532','医疗设备'],['3','851533','医疗耗材'],['3','851534','体外诊断'],
|
780
|
-
['3','851563','医疗研发外包'],['3','851564','医院'],['3','851611','火力发电'],
|
781
|
-
['3','851612','水力发电'],['3','851614','热力服务'],['3','851616','光伏发电'],
|
782
|
-
['3','851617','风力发电'],['3','851610','电能综合服务'],['3','851631','燃气Ⅲ'],
|
783
|
-
['3','851782','原材料供应链服务'],['3','851783','中间产品及消费品供应链服务'],['3','851784','快递'],
|
784
|
-
['3','851785','跨境物流'],['3','851786','仓储物流'],['3','851787','公路货运'],
|
785
|
-
['3','851731','高速公路'],['3','851721','公交'],['3','851771','铁路运输'],
|
786
|
-
['3','851741','航空运输'],['3','851761','航运'],['3','851711','港口'],
|
787
|
-
['3','851811','住宅开发'],['3','851812','商业地产'],['3','851813','产业地产'],
|
788
|
-
['3','851831','物业管理'],['3','852021','贸易Ⅲ'],['3','852031','百货'],
|
789
|
-
['3','852032','超市'],['3','852033','多业态零售'],['3','852034','商业物业经营'],
|
790
|
-
['3','852041','专业连锁Ⅲ'],['3','852062','跨境电商'],['3','852063','电商服务'],
|
791
|
-
['3','852182','检测服务'],['3','852183','会展服务'],['3','852121','酒店'],
|
792
|
-
['3','852111','人工景区'],['3','852112','自然景区'],['3','852131','旅游综合'],
|
793
|
-
['3','859852','培训教育'],['3','857821','国有大型银行Ⅲ'],['3','857831','股份制银行Ⅲ'],
|
794
|
-
['3','857841','城商行Ⅲ'],['3','857851','农商行Ⅲ'],['3','851931','证券Ⅲ'],
|
795
|
-
['3','851941','保险Ⅲ'],['3','851922','金融控股'],['3','851927','资产管理'],
|
796
|
-
['3','852311','综合Ⅲ'],['3','857111','水泥制造'],['3','857112','水泥制品'],
|
797
|
-
['3','857121','玻璃制造'],['3','857122','玻纤制造'],['3','850615','耐火材料'],
|
798
|
-
['3','850616','管材'],['3','850614','其他建材'],['3','850623','房屋建设Ⅲ'],
|
799
|
-
['3','857221','装修装饰Ⅲ'],['3','857236','基建市政工程'],['3','857251','园林工程'],
|
800
|
-
['3','857241','钢结构'],['3','857242','化学工程'],['3','857243','国际工程'],
|
801
|
-
['3','857244','其他专业工程'],['3','857261','工程咨询服务Ⅲ'],['3','850741','电机Ⅲ'],
|
802
|
-
['3','857334','火电设备'],['3','857336','其他电源设备Ⅲ'],['3','857352','光伏电池组件'],
|
803
|
-
['3','857354','光伏辅材'],['3','857355','光伏加工设备'],['3','857362','风电零部件'],
|
804
|
-
['3','857371','锂电池'],['3','857372','电池化学品'],['3','857373','锂电专用设备'],
|
805
|
-
['3','857375','蓄电池及其他电池'],['3','857381','输变电设备'],['3','857382','配电设备'],
|
806
|
-
['3','857321','电网自动化设备'],['3','857323','电工仪器仪表'],['3','857344','线缆部件及其他'],
|
807
|
-
['3','850711','机床工具'],['3','850713','磨具磨料'],['3','850715','制冷空调设备'],
|
808
|
-
['3','850716','其他通用设备'],['3','850731','仪器仪表'],['3','850751','金属制品'],
|
809
|
-
['3','850725','能源及重型设备'],['3','850728','楼宇设备'],['3','850721','纺织服装设备'],
|
810
|
-
['3','850726','印刷包装机械'],['3','850727','其他专用设备'],['3','850936','轨交设备Ⅲ'],
|
811
|
-
['3','850771','工程机械整机'],['3','850772','工程机械器件'],['3','850781','机器人'],
|
812
|
-
['3','850782','工控设备'],['3','850783','激光设备'],['3','850784','其他自动化设备'],
|
813
|
-
['3','857411','航天装备Ⅲ'],['3','857421','航空装备Ⅲ'],['3','857431','地面兵装Ⅲ'],
|
814
|
-
['3','850935','航海装备Ⅲ'],['3','857451','军工电子Ⅲ'],['3','850702','安防设备'],
|
815
|
-
['3','850703','其他计算机设备'],['3','852226','IT服务Ⅲ'],['3','851041','垂直应用软件'],
|
816
|
-
['3','851042','横向通用软件'],['3','857641','游戏Ⅲ'],['3','857651','营销代理'],
|
817
|
-
['3','857661','影视动漫制作'],['3','857674','门户网站'],['3','857691','教育出版'],
|
818
|
-
['3','857692','大众出版'],['3','859951','电视广播Ⅲ'],['3','852213','通信工程及服务'],
|
819
|
-
['3','852214','通信应用增值服务'],['3','851024','通信网络设备及器件'],['3','851025','通信线缆及配套'],
|
820
|
-
['3','851026','通信终端及配件'],['3','851027','其他通信设备'],['3','859511','动力煤'],
|
821
|
-
['3','859512','焦煤'],['3','859521','焦炭Ⅲ'],['3','859621','油田服务'],
|
822
|
-
['3','859622','油气及炼化工程'],['3','859631','炼油化工'],['3','859632','油品石化贸易'],
|
823
|
-
['3','859633','其他石化'],['3','859711','大气治理'],['3','859712','水务及水治理'],
|
824
|
-
['3','859713','固废治理'],['3','859714','综合环境治理'],['3','859721','环保设备Ⅲ'],
|
825
|
-
['3','859811','生活用纸'],['3','859821','化妆品制造及其他'],['3','859822','品牌化妆品'],
|
826
|
-
|
827
|
-
#手工添加:可能重复
|
828
|
-
], columns=['type','code','name'])
|
829
|
-
|
830
|
-
return industry
|
831
665
|
#==============================================================================
|
832
666
|
def industry_sw_list_all():
|
833
667
|
"""
|
@@ -1031,32 +865,6 @@ def print_industry_component_sw2(icode,numberPerLine=5,colalign='left'):
|
|
1031
865
|
|
1032
866
|
return
|
1033
867
|
|
1034
|
-
#==============================================================================
|
1035
|
-
|
1036
|
-
|
1037
|
-
def industry_sw_name(icode):
|
1038
|
-
"""
|
1039
|
-
功能:将申万指数代码转换为指数名称。
|
1040
|
-
输入:指数代码
|
1041
|
-
输出:指数名称
|
1042
|
-
"""
|
1043
|
-
icode=icode.split('.')[0]
|
1044
|
-
|
1045
|
-
industry=industry_sw_list()
|
1046
|
-
|
1047
|
-
try:
|
1048
|
-
iname=industry[industry['code']==icode]['name'].values[0]
|
1049
|
-
except:
|
1050
|
-
#未查到
|
1051
|
-
if not icode.isdigit():
|
1052
|
-
print(" #Warning(industry_sw_name): industry name not found for",icode)
|
1053
|
-
iname=icode
|
1054
|
-
|
1055
|
-
return iname
|
1056
|
-
|
1057
|
-
if __name__=='__main__':
|
1058
|
-
icode='801735'
|
1059
|
-
industry_sw_name(icode)
|
1060
868
|
|
1061
869
|
#==============================================================================
|
1062
870
|
if __name__=='__main__':
|
@@ -1816,7 +1624,7 @@ def compare_mindustry_sw(industry_list,measure,start,end, \
|
|
1816
1624
|
df2=dfs1
|
1817
1625
|
dfcols=list(df2)
|
1818
1626
|
for c in dfcols:
|
1819
|
-
ccn=
|
1627
|
+
ccn=ticker_name(c)+'('+c+')'
|
1820
1628
|
df2.rename(columns={c:ccn},inplace=True)
|
1821
1629
|
|
1822
1630
|
if sortby=='tpw_mean':
|
@@ -1949,7 +1757,7 @@ def compare_mindustry_sw2(industry_list,measure,start,end, \
|
|
1949
1757
|
df2=dfs1
|
1950
1758
|
dfcols=list(df2)
|
1951
1759
|
for c in dfcols:
|
1952
|
-
cname=
|
1760
|
+
cname=ticker_name(c)
|
1953
1761
|
if cname == c:
|
1954
1762
|
ccn=c
|
1955
1763
|
else:
|
@@ -2416,7 +2224,7 @@ def rank_msecurity_performance(tickers,start,end, \
|
|
2416
2224
|
#修改列明为股票名称(股票代码)格式,以便与compare_mrar的结果一致
|
2417
2225
|
dft_new_cols=[]
|
2418
2226
|
for t in tickers:
|
2419
|
-
c=
|
2227
|
+
c=ticker_name(t)+'('+t+')'
|
2420
2228
|
dft_new_cols=dft_new_cols+[c]
|
2421
2229
|
dft.columns=dft_new_cols
|
2422
2230
|
|