siat 2.14.1__py3-none-any.whl → 3.0.0__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 +451 -76
- 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 +197 -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.1.dist-info → siat-3.0.0.dist-info}/METADATA +1 -1
- {siat-2.14.1.dist-info → siat-3.0.0.dist-info}/RECORD +41 -40
- {siat-2.14.1.dist-info → siat-3.0.0.dist-info}/WHEEL +0 -0
- {siat-2.14.1.dist-info → siat-3.0.0.dist-info}/top_level.txt +0 -0
siat/translate.py
CHANGED
@@ -1646,18 +1646,13 @@ def codetranslate0(code):
|
|
1646
1646
|
try:
|
1647
1647
|
codename=codedict[codedict['code']==code]['codename'].values[0]
|
1648
1648
|
except:
|
1649
|
+
"""
|
1649
1650
|
#未查到翻译词汇,查找证券字典文件,需要定期更新
|
1650
1651
|
codename=get_names(code)
|
1651
1652
|
if not (codename is None): return codename
|
1652
1653
|
|
1653
1654
|
"""
|
1654
|
-
|
1655
|
-
#不是国内股票或中文名称未查到
|
1656
|
-
try:
|
1657
|
-
codename=securities_name(code)
|
1658
|
-
except:
|
1659
|
-
pass
|
1660
|
-
"""
|
1655
|
+
return codename
|
1661
1656
|
else:
|
1662
1657
|
return codename
|
1663
1658
|
|
@@ -2316,7 +2311,7 @@ def update_fund_names_china():
|
|
2316
2311
|
功能:更新fund_china.pickle
|
2317
2312
|
注意:需要将fund_china.pickle加入文件MANIFEST.in中,不然打包不包括
|
2318
2313
|
"""
|
2319
|
-
|
2314
|
+
import akshare as ak
|
2320
2315
|
df=ak.fund_name_em()
|
2321
2316
|
df.to_pickle('S:/siat/siat/fund_china.pickle')
|
2322
2317
|
|
@@ -2334,6 +2329,7 @@ if __name__=='__main__':
|
|
2334
2329
|
get_bond_name_china("113542.SS")
|
2335
2330
|
get_bond_name_china("118034.SS")
|
2336
2331
|
get_bond_name_china("018021.SS")
|
2332
|
+
|
2337
2333
|
|
2338
2334
|
def get_bond_name_china(bond):
|
2339
2335
|
"""
|
@@ -2463,7 +2459,7 @@ def update_exchange_bond_name_china():
|
|
2463
2459
|
功能:更新exchange_bond_china.pickle
|
2464
2460
|
注意:需要将exchange_bond_china.pickle加入文件MANIFEST.in中,不然打包不包括
|
2465
2461
|
"""
|
2466
|
-
|
2462
|
+
import akshare as ak
|
2467
2463
|
df=ak.bond_zh_hs_spot()
|
2468
2464
|
df.to_pickle('S:/siat/siat/exchange_bond_china.pickle')
|
2469
2465
|
|
@@ -2614,7 +2610,7 @@ def securities_name(code):
|
|
2614
2610
|
import akshare as ak
|
2615
2611
|
suffix=code[-3:]
|
2616
2612
|
stock=code[:-3]
|
2617
|
-
if suffix in ['.SS','.SZ']:
|
2613
|
+
if suffix in ['.SS','.SZ','.BJ']:
|
2618
2614
|
try:
|
2619
2615
|
names = ak.stock_info_change_name(stock=stock)
|
2620
2616
|
if not (names is None):
|
@@ -2625,7 +2621,7 @@ def securities_name(code):
|
|
2625
2621
|
pass
|
2626
2622
|
|
2627
2623
|
#不是国内股票或中文名称未查到
|
2628
|
-
if not (suffix in ['.SS','.SZ']) or (codename==code):
|
2624
|
+
if not (suffix in ['.SS','.SZ','.BJ']) or (codename==code):
|
2629
2625
|
try:
|
2630
2626
|
import yfinance as yf
|
2631
2627
|
tp=yf.Ticker(code)
|
@@ -2992,29 +2988,790 @@ def print_tickerlist_sharelist(tickerlist,sharelist,leading_blanks=2):
|
|
2992
2988
|
if __name__=='__main__':
|
2993
2989
|
print_tickerlist_sharelist(tickerlist,sharelist,leading_blanks=2)
|
2994
2990
|
#==============================================================================
|
2991
|
+
#==============================================================================
|
2992
|
+
#==============================================================================
|
2993
|
+
#整理证券名称
|
2994
|
+
#==============================================================================
|
2995
|
+
#==============================================================================
|
2996
|
+
#==============================================================================
|
2997
|
+
def update_all_names2files():
|
2998
|
+
"""
|
2999
|
+
功能:更新股票(中港美)、基金(沪深)和债券(沪深)名称至文件中(S:/siat)
|
3000
|
+
"""
|
3001
|
+
df1=update_stock_names()
|
3002
|
+
df2=update_fund_names_china()
|
3003
|
+
df3=update_exchange_bond_name_china()
|
3004
|
+
|
3005
|
+
return
|
3006
|
+
|
3007
|
+
#==============================================================================
|
2995
3008
|
if __name__=='__main__':
|
2996
|
-
ticker='
|
2997
|
-
|
3009
|
+
ticker=''
|
3010
|
+
base='fund'
|
3011
|
+
|
3012
|
+
df_dup=check_duplicate_code(ticker='',base='fund')
|
3013
|
+
df_dup=check_duplicate_code(ticker='018003',base='fund')
|
3014
|
+
df_dup=check_duplicate_code(ticker='000001',base='fund')
|
3015
|
+
|
3016
|
+
def check_duplicate_code(ticker='',base='fund',printout=True):
|
3017
|
+
"""
|
3018
|
+
功能;查询重叠的基金/债券代码
|
3019
|
+
若ticker不为空,且在基金中找到,则只查该代码,否则查询所有交易所基金代码
|
3020
|
+
"""
|
3021
|
+
|
3022
|
+
#取出所有交易所债券代码
|
3023
|
+
df_bond=file_position(file='exchange_bond_china.pickle',package='siat',mode='read')
|
3024
|
+
df_bond['code6']=df_bond['代码'].apply(lambda x: x[-6:])
|
3025
|
+
list_bond=list(df_bond['code6'])
|
3026
|
+
|
3027
|
+
#取出所有基金代码
|
3028
|
+
df_fund=file_position(file='fund_china.pickle',package='siat',mode='read')
|
3029
|
+
list_fund=list(df_fund['基金代码'])
|
3030
|
+
|
3031
|
+
#取出所有A股港股美股代码
|
3032
|
+
df_stock=file_position(file='stock_info.pickle',package='siat',mode='read')
|
3033
|
+
df_stock['A_Code6']=df_stock['SYMBOL'].apply(lambda x: x[:6] if '.SS' in x or '.SZ' in x or '.BJ' in x else '')
|
3034
|
+
df_stock_A=df_stock[df_stock['A_Code6'] != '']
|
3035
|
+
list_stock=list(df_stock_A['A_Code6'])
|
3036
|
+
|
3037
|
+
df_dup=pd.DataFrame(columns=('code','stock code','stock name','bond code','bond name','fund code','fund name'))
|
3038
|
+
|
3039
|
+
#查找所有代码:基于基金
|
3040
|
+
if ticker == '' and base == 'fund':
|
3041
|
+
for t in list_fund:
|
3042
|
+
code_fund=df_fund[df_fund['基金代码']==t]['基金代码'].values[0]
|
3043
|
+
name_fund=df_fund[df_fund['基金代码']==t]['基金简称'].values[0]
|
3044
|
+
|
3045
|
+
#查找债券代码
|
3046
|
+
code_bond=''; name_bond=''
|
3047
|
+
if t in list_bond:
|
3048
|
+
try:
|
3049
|
+
code_bond=df_bond[df_bond['code6']==t]['代码'].values[0]
|
3050
|
+
name_bond=df_bond[df_bond['code6']==t]['名称'].values[0]
|
3051
|
+
except: pass
|
3052
|
+
|
3053
|
+
#查找股票代码
|
3054
|
+
code_stock=''; name_stock=''
|
3055
|
+
if t in list_stock:
|
3056
|
+
try:
|
3057
|
+
code_stock=df_stock_A[df_stock_A['A_Code6']==t]['SYMBOL'].values[0]
|
3058
|
+
name_stock=df_stock_A[df_stock_A['A_Code6']==t]['CNAME'].values[0]
|
3059
|
+
except: pass
|
3060
|
+
|
3061
|
+
if name_bond != '' or name_stock != '':
|
3062
|
+
row=pd.Series({'code':t,'stock code':code_stock,'stock name':name_stock,'bond code':code_bond,'bond name':name_bond,'fund code':code_fund,'fund name':name_fund})
|
3063
|
+
df_dup=df_dup._append(row,ignore_index=True)
|
3064
|
+
|
3065
|
+
print_progress_percent2(t,list_fund,steps=10,leading_blanks=4)
|
3066
|
+
|
3067
|
+
#查找单个代码
|
3068
|
+
if ticker != '':
|
3069
|
+
#截取6位数字
|
3070
|
+
prefix6=ticker[:6]; suffix6=ticker[-6:]
|
3071
|
+
if prefix6.isdigit():
|
3072
|
+
t=prefix6
|
3073
|
+
elif suffix6.isdigit():
|
3074
|
+
t=suffix6
|
3075
|
+
else:
|
3076
|
+
t=ticker
|
3077
|
+
|
3078
|
+
#查找股票代码
|
3079
|
+
code_stock=''; name_stock=''
|
3080
|
+
if t in list_stock:
|
3081
|
+
try:
|
3082
|
+
code_stock=df_stock_A[df_stock_A['A_Code6']==t]['SYMBOL'].values[0]
|
3083
|
+
name_stock=df_stock_A[df_stock_A['A_Code6']==t]['CNAME'].values[0]
|
3084
|
+
except: pass
|
3085
|
+
|
3086
|
+
#查找债券代码
|
3087
|
+
code_bond=''; name_bond=''
|
3088
|
+
if t in list_bond:
|
3089
|
+
try:
|
3090
|
+
code_bond=df_bond[df_bond['code6']==t]['代码'].values[0]
|
3091
|
+
name_bond=df_bond[df_bond['code6']==t]['名称'].values[0]
|
3092
|
+
except: pass
|
3093
|
+
|
3094
|
+
#查找基金代码
|
3095
|
+
code_fund=''; name_fund=''
|
3096
|
+
if t in list_fund:
|
3097
|
+
try:
|
3098
|
+
code_fund=df_fund[df_fund['基金代码']==t]['基金代码'].values[0]
|
3099
|
+
name_fund=df_fund[df_fund['基金代码']==t]['基金简称'].values[0]
|
3100
|
+
except: pass
|
3101
|
+
|
3102
|
+
row=pd.Series({'code':t,'stock code':code_stock,'stock name':name_stock,'bond code':code_bond,'bond name':name_bond,'fund code':code_fund,'fund name':name_fund})
|
3103
|
+
df_dup=df_dup._append(row,ignore_index=True)
|
3104
|
+
|
3105
|
+
if printout:
|
3106
|
+
print('') #空一行
|
3107
|
+
if code_stock != '':
|
3108
|
+
print(" 股票:"+code_stock+','+name_stock)
|
3109
|
+
if code_bond != '':
|
3110
|
+
print(" 债券:"+code_bond+','+name_bond)
|
3111
|
+
if code_fund != '':
|
3112
|
+
print(" 基金:"+code_fund+','+name_fund)
|
3113
|
+
|
3114
|
+
if code_stock == '' and code_bond == '' and code_fund == '':
|
3115
|
+
print(" 未找到代码为"+ticker+"的证券")
|
3116
|
+
|
3117
|
+
return df_dup
|
3118
|
+
|
3119
|
+
|
3120
|
+
#==============================================================================
|
3121
|
+
if __name__=='__main__':
|
3122
|
+
ticker='600519.SS' #股票
|
3123
|
+
ticker='159995.SZ' #基金
|
3124
|
+
ticker='010107.SS' #债券/基金重码
|
3125
|
+
ticker='sh010303' #国债/基金重码
|
3126
|
+
ticker='sh018001' #金融债
|
3127
|
+
|
3128
|
+
ticker_type='auto'
|
3129
|
+
ticker_type='bond'
|
3130
|
+
|
2998
3131
|
ticker={'Market':('US','^SPX','中概教培组合'),'EDU':0.5,'TAL':0.3,'TEDU':0.2}
|
2999
3132
|
|
3000
|
-
|
3133
|
+
ticker1_name(ticker,ticker_type)
|
3001
3134
|
|
3002
|
-
def
|
3135
|
+
def ticker1_name(ticker,ticker_type='auto'):
|
3003
3136
|
"""
|
3004
|
-
|
3137
|
+
功能:翻译单个证券名称:股票,基金,债券,投资组合
|
3005
3138
|
"""
|
3006
|
-
|
3007
|
-
|
3139
|
+
#投资组合
|
3140
|
+
if isinstance(ticker,dict):
|
3141
|
+
return portfolio_name(ticker)
|
3142
|
+
|
3143
|
+
#非字符串
|
3144
|
+
if not isinstance(ticker,str):
|
3145
|
+
return ticker
|
3146
|
+
|
3147
|
+
#快速转换
|
3148
|
+
tname=codetranslate(ticker)
|
3149
|
+
if tname != ticker: #翻译成功
|
3150
|
+
return tname
|
3151
|
+
|
3152
|
+
symbol=ticker1_cvt2yahoo(ticker)
|
3153
|
+
|
3154
|
+
#申万行业指数
|
3155
|
+
_,_,flag=split_prefix_suffix(ticker)
|
3156
|
+
if flag in ['SW']:
|
3157
|
+
swname=industry_sw_name(symbol)
|
3158
|
+
if '申万' not in swname: swname='申万' + swname
|
3159
|
+
if '指数' not in swname: swname=swname + '指数'
|
3160
|
+
tname=swname
|
3161
|
+
return tname
|
3162
|
+
|
3163
|
+
#确定查询优先顺序
|
3164
|
+
if isinstance(ticker_type,list):
|
3165
|
+
ticker_type=ticker_type[0]
|
3166
|
+
|
3167
|
+
ttlist=['stock','bond','fund']
|
3168
|
+
if ticker_type in ['fund']:
|
3169
|
+
ttlist=['fund','stock','bond']
|
3170
|
+
elif ticker_type in ['bond']:
|
3171
|
+
ttlist=['bond','stock','fund']
|
3172
|
+
|
3173
|
+
#循环查询,查到则跳出
|
3174
|
+
tname=symbol
|
3175
|
+
for tt in ttlist:
|
3176
|
+
#查找证券名称文件:优先股票
|
3177
|
+
if tt in ['stock']:
|
3178
|
+
df1=file_position(file='stock_info.pickle',package='siat',mode='read')
|
3179
|
+
try:
|
3180
|
+
tname=df1[df1['SYMBOL']==symbol]['CNAME'].values[0]
|
3181
|
+
except: pass
|
3182
|
+
if tname != symbol: break
|
3183
|
+
|
3184
|
+
#查找证券名称文件:次优先交易所债券
|
3185
|
+
if tt in ['bond']:
|
3186
|
+
df3=file_position(file='exchange_bond_china.pickle',package='siat',mode='read')
|
3187
|
+
symbolak=ticker1_cvt2ak(symbol)
|
3188
|
+
try:
|
3189
|
+
tname=df3[df3['代码']==symbolak]['名称'].values[0]
|
3190
|
+
return tname
|
3191
|
+
except: pass
|
3192
|
+
if tname != symbol: break
|
3193
|
+
|
3194
|
+
#查找证券名称文件:最后基金
|
3195
|
+
if tt in ['fund']:
|
3196
|
+
df2=file_position(file='fund_china.pickle',package='siat',mode='read')
|
3197
|
+
symbol6=symbol[:6]
|
3198
|
+
try:
|
3199
|
+
tname=df2[df2['基金代码']==symbol6]['基金简称'].values[0]
|
3200
|
+
except: pass
|
3201
|
+
if tname != symbol:
|
3202
|
+
if '基金' not in tname: tname=tname + '基金'
|
3203
|
+
break
|
3204
|
+
|
3205
|
+
return tname
|
3206
|
+
|
3207
|
+
#==============================================================================
|
3208
|
+
if __name__=='__main__':
|
3209
|
+
ticker='600519.SS' #股票
|
3210
|
+
ticker={'Market':('US','^SPX','中概教培组合'),'EDU':0.5,'TAL':0.3,'TEDU':0.2}
|
3211
|
+
pf={'Market':('US','^SPX','中概教培组合'),'EDU':0.5,'TAL':0.3,'TEDU':0.2}
|
3212
|
+
ticker=['600519.SS','sh018003',pf]
|
3213
|
+
|
3214
|
+
ticker_type='auto'
|
3215
|
+
ticker_type=['auto','bond']
|
3216
|
+
|
3217
|
+
ticker_name(ticker,ticker_type)
|
3218
|
+
|
3219
|
+
def ticker_name(ticker,ticker_type='auto'):
|
3220
|
+
"""
|
3221
|
+
功能:翻译单个或多个证券名称:股票,基金,债券,投资组合
|
3222
|
+
"""
|
3223
|
+
if isinstance(ticker,str) or isinstance(ticker,dict):
|
3224
|
+
#单只原生证券或投资组合
|
3225
|
+
tname=ticker1_name(ticker,ticker_type)
|
3008
3226
|
elif isinstance(ticker,list):
|
3227
|
+
#多只原生证券或投资组合
|
3228
|
+
if isinstance(ticker_type,str):
|
3229
|
+
ticker_type=[ticker_type] * len(ticker)
|
3230
|
+
elif isinstance(ticker_type,list):
|
3231
|
+
if len(ticker) > len(ticker_type):
|
3232
|
+
ticker_type=ticker_type + [ticker_type[-1]] * (len(ticker) - len(ticker_type))
|
3233
|
+
else:
|
3234
|
+
ticker_type=['auto'] * len(ticker)
|
3235
|
+
|
3009
3236
|
tname=[]
|
3010
3237
|
for t in ticker:
|
3011
|
-
|
3012
|
-
|
3013
|
-
|
3014
|
-
|
3015
|
-
tname=ticker
|
3016
|
-
|
3238
|
+
pos=ticker.index(t)
|
3239
|
+
tname=tname + [ticker1_name(t,ticker_type[pos])]
|
3240
|
+
else: tname=ticker
|
3241
|
+
|
3017
3242
|
return tname
|
3243
|
+
|
3244
|
+
#==============================================================================
|
3245
|
+
if __name__=='__main__':
|
3246
|
+
ticker='600519.SS'
|
3247
|
+
ticker='000858.SZ'
|
3248
|
+
|
3249
|
+
ticker='SH600519'
|
3250
|
+
ticker='sh600519'
|
3251
|
+
ticker='sz000858'
|
3252
|
+
|
3253
|
+
ticker='sz600519'
|
3254
|
+
ticker='sh000858'
|
3255
|
+
|
3256
|
+
ticker='600519.SH'
|
3257
|
+
ticker='600519.sh'
|
3258
|
+
ticker='000858.sz'
|
3259
|
+
|
3260
|
+
ticker='000858.sh'
|
3261
|
+
ticker='600519.sz'
|
3262
|
+
|
3263
|
+
ticker='600519'
|
3264
|
+
ticker='000858'
|
3265
|
+
ticker='600519.CN'
|
3266
|
+
ticker='000858.CN'
|
3267
|
+
ticker='801010.SW'
|
3268
|
+
ticker='880410.ZZ'
|
3269
|
+
|
3270
|
+
ticker='01210.HK'
|
3271
|
+
ticker='AAPL'
|
3272
|
+
ticker='6758.T'
|
3273
|
+
ticker='SONA.F'
|
3274
|
+
|
3275
|
+
ticker1_cvt2yahoo(ticker)
|
3276
|
+
|
3277
|
+
def ticker1_cvt2yahoo(ticker):
|
3278
|
+
"""
|
3279
|
+
功能:将一只股票、基金、债券代码转换为siat内部默认的yahoo格式
|
3280
|
+
情形:后缀,前缀,无后缀和前缀
|
3281
|
+
注意:中证行业代码若为沪深交易所收藏的,仍以SS/SZ为后缀,不可用ZZ后缀
|
3282
|
+
"""
|
3283
|
+
ticker1=ticker.upper() #转为大写
|
3284
|
+
|
3285
|
+
#后缀
|
3286
|
+
result,prefix,suffix=split_prefix_suffix(ticker1)
|
3287
|
+
if suffix in ['SS','SH','SZ','BJ','CN','SW','ZZ'] and len(prefix)==6:
|
3288
|
+
if suffix in ['SH']:
|
3289
|
+
suffix1='SS'
|
3290
|
+
elif suffix in ['CN']:
|
3291
|
+
suffix1,_=china_security_identify(prefix)
|
3292
|
+
else:
|
3293
|
+
suffix1=suffix
|
3294
|
+
|
3295
|
+
"""
|
3296
|
+
#检查是否搞错SS/SZ/BJ
|
3297
|
+
if suffix1 in ['SS','SZ','BJ']:
|
3298
|
+
suffix1,_=china_security_identify(prefix)
|
3299
|
+
"""
|
3300
|
+
ticker2=prefix+'.'+suffix1
|
3301
|
+
return ticker2
|
3302
|
+
|
3303
|
+
#前缀
|
3304
|
+
head2=ticker1[:2]
|
3305
|
+
rest2=ticker1[2:]
|
3306
|
+
if head2 in ['SH','SZ','BJ','SW','ZZ'] and len(rest2)==6:
|
3307
|
+
#suffix1,_=china_security_identify(rest2)
|
3308
|
+
if head2 in ['SH']:
|
3309
|
+
suffix1='SS'
|
3310
|
+
else:
|
3311
|
+
suffix1=head2
|
3312
|
+
"""
|
3313
|
+
#检查是否搞错SS/SZ/BJ
|
3314
|
+
if suffix1 in ['SS','SZ','BJ']:
|
3315
|
+
suffix1,_=china_security_identify(rest2)
|
3316
|
+
"""
|
3317
|
+
ticker2=rest2+'.'+suffix1
|
3318
|
+
return ticker2
|
3319
|
+
|
3320
|
+
#无前后缀,6位数字,默认为A股
|
3321
|
+
if is_all_digits(ticker1) and len(ticker1) == 6:
|
3322
|
+
suffix1,_=china_security_identify(ticker1)
|
3323
|
+
ticker2=ticker1+'.'+suffix1
|
3324
|
+
return ticker2
|
3325
|
+
|
3326
|
+
#其他:直接返回
|
3327
|
+
return ticker1
|
3328
|
+
|
3329
|
+
#==============================================================================
|
3330
|
+
if __name__=='__main__':
|
3331
|
+
ticker=['600519.SS','sz000858','002594.sz','aapl']
|
3332
|
+
|
3333
|
+
tickers_cvt2yahoo(ticker)
|
3334
|
+
|
3335
|
+
def tickers_cvt2yahoo(ticker):
|
3336
|
+
"""
|
3337
|
+
功能:将多只股票、基金、债券代码转换为siat内部默认的yahoo格式
|
3338
|
+
"""
|
3339
|
+
#单个字符串:返回字符串
|
3340
|
+
if isinstance(ticker,str):
|
3341
|
+
result=ticker1_cvt2yahoo(ticker)
|
3342
|
+
return result
|
3343
|
+
|
3344
|
+
#列表:返回列表
|
3345
|
+
if isinstance(ticker,list): #避免下面的循环出错
|
3346
|
+
tickerlist=[]
|
3347
|
+
for t in ticker:
|
3348
|
+
t2=ticker1_cvt2yahoo(t)
|
3349
|
+
tickerlist=tickerlist+[t2]
|
3350
|
+
|
3351
|
+
result=tickerlist
|
3352
|
+
return result
|
3353
|
+
|
3354
|
+
#其他:直接返回
|
3355
|
+
return ticker
|
3356
|
+
|
3357
|
+
#==============================================================================
|
3358
|
+
if __name__=='__main__':
|
3359
|
+
ticker='SH600519'
|
3360
|
+
ticker='sh600519'
|
3361
|
+
ticker='sz000858'
|
3362
|
+
|
3363
|
+
ticker='sz600519'
|
3364
|
+
ticker='sh000858'
|
3365
|
+
|
3366
|
+
ticker='600519.SH'
|
3367
|
+
ticker='600519.sh'
|
3368
|
+
ticker='000858.sz'
|
3369
|
+
|
3370
|
+
ticker='000858.sh'
|
3371
|
+
ticker='600519.sz'
|
3372
|
+
|
3373
|
+
ticker='600519'
|
3374
|
+
ticker='000858'
|
3375
|
+
ticker='600519.CN'
|
3376
|
+
ticker='000858.CN'
|
3377
|
+
ticker='801010.SW'
|
3378
|
+
ticker='880410.ZZ'
|
3379
|
+
|
3380
|
+
ticker='sh149996'
|
3381
|
+
|
3382
|
+
ticker='01210.HK'
|
3383
|
+
ticker='AAPL'
|
3384
|
+
ticker='6758.T'
|
3385
|
+
ticker='SONA.F'
|
3386
|
+
|
3387
|
+
ticker1_cvt2ak(ticker)
|
3388
|
+
|
3389
|
+
def ticker1_cvt2ak(ticker):
|
3390
|
+
"""
|
3391
|
+
功能:将一只股票、基金、债券代码转换为akshare格式
|
3392
|
+
情形:后缀,前缀,无后缀和前缀
|
3393
|
+
注意:中证行业代码若为沪深交易所收藏的,仍以SS/SZ为后缀,不可用ZZ后缀
|
3394
|
+
"""
|
3395
|
+
ticker1=ticker.upper() #转为大写
|
3396
|
+
|
3397
|
+
#后缀
|
3398
|
+
result,prefix,suffix=split_prefix_suffix(ticker1)
|
3399
|
+
if suffix in ['SS','SH','SZ','BJ','CN'] and len(prefix)==6:
|
3400
|
+
if suffix in ['SH','SS']: prefix1='sh'
|
3401
|
+
if suffix in ['SZ']: prefix1='sz'
|
3402
|
+
if suffix in ['BJ']: prefix1='bj'
|
3403
|
+
if suffix in ['CN']:
|
3404
|
+
suffix1,_=china_security_identify(prefix)
|
3405
|
+
prefix1='sh'
|
3406
|
+
if suffix1 in ['SS']: prefix1='sh'
|
3407
|
+
if suffix1 in ['SZ']: prefix1='sz'
|
3408
|
+
if suffix1 in ['BJ']: prefix1='bj'
|
3409
|
+
"""
|
3410
|
+
#检查是否搞错SS/SZ/BJ
|
3411
|
+
if suffix in ['SS','SH','SZ','BJ']:
|
3412
|
+
suffix1,_=china_security_identify(prefix)
|
3413
|
+
if suffix1 in ['SS','SH']: prefix1='sh'
|
3414
|
+
if suffix1 == 'SZ': prefix1='sz'
|
3415
|
+
if suffix1 == 'BJ': prefix1='bj'
|
3416
|
+
"""
|
3417
|
+
ticker2=prefix1+prefix
|
3418
|
+
return ticker2
|
3419
|
+
|
3420
|
+
#前缀
|
3421
|
+
head2=ticker1[:2]
|
3422
|
+
rest2=ticker1[2:]
|
3423
|
+
if head2 in ['SH','SS','SZ','BJ'] and len(rest2)==6:
|
3424
|
+
if head2 in ['SH','SS']: prefix1='sh'
|
3425
|
+
if head2 in ['SZ']: prefix1='sz'
|
3426
|
+
if head2 in ['BJ']: prefix1='bj'
|
3427
|
+
|
3428
|
+
"""
|
3429
|
+
#检查是否搞错SS/SZ/BJ
|
3430
|
+
if head2 in ['SH','SS','SZ','BJ']:
|
3431
|
+
suffix1,_=china_security_identify(rest2)
|
3432
|
+
if suffix1 == 'SS': prefix1='sh'
|
3433
|
+
if suffix1 == 'SZ': prefix1='sz'
|
3434
|
+
if suffix1 == 'BJ': prefix1='bj'
|
3435
|
+
"""
|
3436
|
+
ticker2=prefix1+rest2
|
3437
|
+
return ticker2
|
3438
|
+
|
3439
|
+
#无前后缀,6位数字,默认为A股
|
3440
|
+
if is_all_digits(ticker1) and len(ticker1) == 6:
|
3441
|
+
suffix1,_=china_security_identify(ticker1)
|
3442
|
+
prefix1='sh'
|
3443
|
+
if head2 in ['SH','SS']: prefix1='sh'
|
3444
|
+
if head2 in ['SZ']: prefix1='sz'
|
3445
|
+
if head2 in ['BJ']: prefix1='bj'
|
3446
|
+
|
3447
|
+
ticker2=prefix1+ticker1
|
3448
|
+
return ticker2
|
3449
|
+
|
3450
|
+
#其他:直接返回
|
3451
|
+
return ticker1
|
3452
|
+
|
3453
|
+
#==============================================================================
|
3454
|
+
if __name__=='__main__':
|
3455
|
+
ticker=['600519.SS','sz000858','002594.sz','aapl']
|
3456
|
+
|
3457
|
+
tickers_cvt2ak(ticker)
|
3458
|
+
|
3459
|
+
def tickers_cvt2ak(ticker):
|
3460
|
+
"""
|
3461
|
+
功能:将多只股票、基金、债券代码转换为akshare格式
|
3462
|
+
"""
|
3463
|
+
#单个字符串:返回字符串
|
3464
|
+
if isinstance(ticker,str):
|
3465
|
+
result=ticker1_cvt2ak(ticker)
|
3466
|
+
return result
|
3467
|
+
|
3468
|
+
#列表:返回列表
|
3469
|
+
if isinstance(ticker,list): #避免下面的循环出错
|
3470
|
+
tickerlist=[]
|
3471
|
+
for t in ticker:
|
3472
|
+
t2=ticker1_cvt2ak(t)
|
3473
|
+
tickerlist=tickerlist+[t2]
|
3474
|
+
|
3475
|
+
result=tickerlist
|
3476
|
+
return result
|
3477
|
+
|
3478
|
+
#其他:直接返回
|
3479
|
+
return ticker
|
3480
|
+
|
3481
|
+
|
3482
|
+
#==============================================================================
|
3483
|
+
if __name__=='__main__':
|
3484
|
+
s='123456'
|
3485
|
+
s='123456.'
|
3486
|
+
s='123456a'
|
3487
|
+
|
3488
|
+
is_all_digits(s)
|
3489
|
+
|
3490
|
+
def is_all_digits(s):
|
3491
|
+
"""
|
3492
|
+
功能:检查字符串s是否为全数字构成
|
3493
|
+
"""
|
3494
|
+
import re
|
3495
|
+
return bool(re.match(r'^\d+$', s))
|
3496
|
+
|
3497
|
+
#==============================================================================
|
3498
|
+
if __name__=='__main__':
|
3499
|
+
ticker6='AAPL'
|
3500
|
+
ticker6='01211'
|
3501
|
+
ticker6='600519'
|
3502
|
+
ticker6='149996'
|
3503
|
+
|
3504
|
+
china_security_identify(ticker6)
|
3505
|
+
|
3506
|
+
def china_security_identify(ticker6):
|
3507
|
+
"""
|
3508
|
+
功能:区分中国内地证券代码前缀,返回后缀SS/SZ/BJ
|
3509
|
+
情形:股票,基金,债券,指数
|
3510
|
+
注意:ticker6需为6位数字字符,目前仅限沪深京交易所,未包括期货期权交易所
|
3511
|
+
"""
|
3512
|
+
suffix='SS'
|
3513
|
+
stype='stock'
|
3514
|
+
|
3515
|
+
#检查是否为6位数字字符
|
3516
|
+
if not is_all_digits(ticker6) or len(ticker6) != 6:
|
3517
|
+
suffix=''
|
3518
|
+
stype=''
|
3519
|
+
return suffix,stype
|
3520
|
+
|
3521
|
+
head1=ticker6[:1]
|
3522
|
+
head2=ticker6[:2]
|
3523
|
+
head3=ticker6[:3]
|
3524
|
+
|
3525
|
+
#股票代码
|
3526
|
+
if head2 in ['60','68']: #上交所:60-主板,68-科创板
|
3527
|
+
suffix='SS'
|
3528
|
+
stype='stock'
|
3529
|
+
return suffix,stype
|
3530
|
+
if head2 in ['00','30']: #深交所:00-主板,30-创业板
|
3531
|
+
suffix='SZ'
|
3532
|
+
stype='stock'
|
3533
|
+
return suffix,stype
|
3534
|
+
if head1 in ['8','4']: #北交所
|
3535
|
+
suffix='BJ'
|
3536
|
+
stype='stock'
|
3537
|
+
return suffix,stype
|
3538
|
+
|
3539
|
+
#沪深基金
|
3540
|
+
if head2 in ['50','51','56','58']: #上交所:50-封闭式,51-ETF
|
3541
|
+
suffix='SS'
|
3542
|
+
stype='fund'
|
3543
|
+
return suffix,stype
|
3544
|
+
if head2 in ['15','16','18']: #深交所:15-ETF,16-LOF,18-封闭式
|
3545
|
+
suffix='SZ'
|
3546
|
+
stype='fund'
|
3547
|
+
return suffix,stype
|
3548
|
+
|
3549
|
+
#沪深债券
|
3550
|
+
if head3 in ['271','270','240','188','185','184','175','163','155','152', \
|
3551
|
+
'143','138','137','136','127','124','122','118','115','113', \
|
3552
|
+
'100','020','019','018','010']:
|
3553
|
+
suffix='SS'
|
3554
|
+
stype='bond'
|
3555
|
+
return suffix,stype
|
3556
|
+
|
3557
|
+
#有重复
|
3558
|
+
if head3 in ['149','148','133','128','127','123','114','112','111','110', \
|
3559
|
+
'108','102','101','100']:
|
3560
|
+
suffix='SZ'
|
3561
|
+
stype='bond'
|
3562
|
+
return suffix,stype
|
3563
|
+
|
3564
|
+
#沪深B股
|
3565
|
+
if head3 in ['900']:
|
3566
|
+
suffix='SS'
|
3567
|
+
stype='stockb'
|
3568
|
+
return suffix,stype
|
3569
|
+
if head3 in ['200']:
|
3570
|
+
suffix='SZ'
|
3571
|
+
stype='stockb'
|
3572
|
+
return suffix,stype
|
3573
|
+
|
3574
|
+
#其他
|
3575
|
+
return '',''
|
3576
|
+
|
3577
|
+
#==============================================================================
|
3578
|
+
#==============================================================================
|
3579
|
+
#申万行业分类:https://www.swhyresearch.com/institute_sw/allIndex/analysisIndex
|
3580
|
+
#==============================================================================
|
3581
|
+
#==============================================================================
|
3582
|
+
def industry_sw_list():
|
3583
|
+
"""
|
3584
|
+
功能:输出申万指数代码df, 静态
|
3585
|
+
输入:
|
3586
|
+
输出:df
|
3587
|
+
"""
|
3588
|
+
import pandas as pd
|
3589
|
+
industry=pd.DataFrame([
|
3590
|
+
|
3591
|
+
#市场表征指数F,一级行业I,二级行业T,风格策略S
|
3592
|
+
['F','801001','申万50'],['F','801002','申万中小'],['F','801003','申万A指'],
|
3593
|
+
['F','801005','申万创业'],['F','801250','申万制造'],['F','801260','申万消费'],
|
3594
|
+
['F','801270','申万投资'],['F','801280','申万服务'],['F','801300','申万300指数'],
|
3595
|
+
['I','801010','农林牧渔'],['I','801030','基础化工'],['I','801040','钢铁'],
|
3596
|
+
['I','801050','有色金属'],['I','801080','电子'],['I','801110','家用电器'],
|
3597
|
+
['I','801120','食品饮料'],['I','801130','纺织服饰'],['I','801140','轻工制造'],
|
3598
|
+
['I','801150','医药生物'],['I','801160','公用事业'],['I','801170','交通运输'],
|
3599
|
+
['I','801180','房地产'],['I','801200','商贸零售'],['I','801210','社会服务'],
|
3600
|
+
['I','801230','综合'],['I','801710','建筑材料'],['I','801720','建筑装饰'],
|
3601
|
+
['I','801730','电力设备'],['I','801740','国防军工'],['I','801750','计算机'],
|
3602
|
+
['I','801760','传媒'],['I','801770','通信'],['I','801780','银行'],
|
3603
|
+
['I','801790','非银金融'],['I','801880','汽车'],['I','801890','机械设备'],
|
3604
|
+
['I','801950','煤炭'],['I','801960','石油石化'],['I','801970','环保'],
|
3605
|
+
['I','801980','美容护理'],['T','801012','农产品加工'],['T','801014','饲料'],
|
3606
|
+
['T','801015','渔业'],['T','801016','种植业'],['T','801017','养殖业'],
|
3607
|
+
['T','801018','动物保健Ⅱ'],['T','801032','化学纤维'],['T','801033','化学原料'],
|
3608
|
+
['T','801034','化学制品'],['T','801036','塑料'],['T','801037','橡胶'],
|
3609
|
+
['T','801038','农化制品'],['T','801039','非金属材料Ⅱ'],['T','801043','冶钢原料'],
|
3610
|
+
['T','801044','普钢'],['T','801045','特钢Ⅱ'],['T','801051','金属新材料'],
|
3611
|
+
['T','801053','贵金属'],['T','801054','小金属'],['T','801055','工业金属'],
|
3612
|
+
['T','801056','能源金属'],['T','801072','通用设备'],['T','801074','专用设备'],
|
3613
|
+
['T','801076','轨交设备Ⅱ'],['T','801077','工程机械'],['T','801078','自动化设备'],
|
3614
|
+
['T','801081','半导体'],['T','801082','其他电子Ⅱ'],['T','801083','元件'],
|
3615
|
+
['T','801084','光学光电子'],['T','801085','消费电子'],['T','801086','电子化学品Ⅱ'],
|
3616
|
+
['T','801092','汽车服务'],['T','801093','汽车零部件'],['T','801095','乘用车'],
|
3617
|
+
['T','801096','商用车'],['T','801101','计算机设备'],['T','801102','通信设备'],
|
3618
|
+
['T','801103','IT服务Ⅱ'],['T','801104','软件开发'],['T','801111','白色家电'],
|
3619
|
+
['T','801112','黑色家电'],['T','801113','小家电'],['T','801114','厨卫电器'],
|
3620
|
+
['T','801115','照明设备Ⅱ'],['T','801116','家电零部件Ⅱ'],['T','801124','食品加工'],
|
3621
|
+
['T','801125','白酒Ⅱ'],['T','801126','非白酒'],['T','801127','饮料乳品'],
|
3622
|
+
['T','801128','休闲食品'],['T','801129','调味发酵品Ⅱ'],['T','801131','纺织制造'],
|
3623
|
+
['T','801132','服装家纺'],['T','801133','饰品'],['T','801141','包装印刷'],
|
3624
|
+
['T','801142','家居用品'],['T','801143','造纸'],['T','801145','文娱用品'],
|
3625
|
+
['T','801151','化学制药'],['T','801152','生物制品'],['T','801153','医疗器械'],
|
3626
|
+
['T','801154','医药商业'],['T','801155','中药Ⅱ'],['T','801156','医疗服务'],
|
3627
|
+
['T','801161','电力'],['T','801163','燃气Ⅱ'],['T','801178','物流'],
|
3628
|
+
['T','801179','铁路公路'],['T','801181','房地产开发'],['T','801183','房地产服务'],
|
3629
|
+
['T','801191','多元金融'],['T','801193','证券Ⅱ'],['T','801194','保险Ⅱ'],
|
3630
|
+
['T','801202','贸易Ⅱ'],['T','801203','一般零售'],['T','801204','专业连锁Ⅱ'],
|
3631
|
+
['T','801206','互联网电商'],['T','801218','专业服务'],['T','801219','酒店餐饮'],
|
3632
|
+
['T','801223','通信服务'],['T','801231','综合Ⅱ'],['T','801711','水泥'],
|
3633
|
+
['T','801712','玻璃玻纤'],['T','801713','装修建材'],['T','801721','房屋建设Ⅱ'],
|
3634
|
+
['T','801722','装修装饰Ⅱ'],['T','801723','基础建设'],['T','801724','专业工程'],
|
3635
|
+
['T','801726','工程咨询服务Ⅱ'],['T','801731','电机Ⅱ'],['T','801733','其他电源设备Ⅱ'],
|
3636
|
+
['T','801735','光伏设备'],['T','801736','风电设备'],['T','801737','电池'],
|
3637
|
+
['T','801738','电网设备'],['T','801741','航天装备Ⅱ'],['T','801742','航空装备Ⅱ'],
|
3638
|
+
['T','801743','地面兵装Ⅱ'],['T','801744','航海装备Ⅱ'],['T','801745','军工电子Ⅱ'],
|
3639
|
+
['T','801764','游戏Ⅱ'],['T','801765','广告营销'],['T','801766','影视院线'],
|
3640
|
+
['T','801767','数字媒体'],['T','801769','出版'],['T','801782','国有大型银行Ⅱ'],
|
3641
|
+
['T','801783','股份制银行Ⅱ'],['T','801784','城商行Ⅱ'],['T','801785','农商行Ⅱ'],
|
3642
|
+
['T','801881','摩托车及其他'],['T','801951','煤炭开采'],['T','801952','焦炭Ⅱ'],
|
3643
|
+
['T','801962','油服工程'],['T','801963','炼化及贸易'],['T','801971','环境治理'],
|
3644
|
+
['T','801972','环保设备Ⅱ'],['T','801981','个护用品'],['T','801982','化妆品'],
|
3645
|
+
['T','801991','航空机场'],['T','801992','航运港口'],['T','801993','旅游及景区'],
|
3646
|
+
['T','801994','教育'],['T','801995','电视广播Ⅱ'],['S','801811','大盘指数'],
|
3647
|
+
['S','801812','中盘指数'],['S','801813','小盘指数'],['S','801821','高市盈率指数'],
|
3648
|
+
['S','801822','中市盈率指数'],['S','801823','低市盈率指数'],['S','801831','高市净率指数'],
|
3649
|
+
['S','801832','中市净率指数'],['S','801833','低市净率指数'],['S','801841','高价股指数'],
|
3650
|
+
['S','801842','中价股指数'],['S','801843','低价股指数'],['S','801851','亏损股指数'],
|
3651
|
+
['S','801852','微利股指数'],['S','801853','绩优股指数'],['S','801863','新股指数'],
|
3652
|
+
['3','850111','种子'],['3','850113','其他种植业'],['3','850122','水产养殖'],
|
3653
|
+
['3','850142','畜禽饲料'],['3','850151','果蔬加工'],['3','850152','粮油加工'],
|
3654
|
+
['3','850154','其他农产品加工'],['3','850172','生猪养殖'],['3','850173','肉鸡养殖'],
|
3655
|
+
['3','850181','动物保健Ⅲ'],['3','850322','氯碱'],['3','850323','无机盐'],
|
3656
|
+
['3','850324','其他化学原料'],['3','850325','煤化工'],['3','850326','钛白粉'],
|
3657
|
+
['3','850335','涂料油墨'],['3','850337','民爆制品'],['3','850338','纺织化学制品'],
|
3658
|
+
['3','850339','其他化学制品'],['3','850382','氟化工'],['3','850372','聚氨酯'],
|
3659
|
+
['3','850135','食品及饲料添加剂'],['3','850136','有机硅'],['3','850341','涤纶'],
|
3660
|
+
['3','850343','粘胶'],['3','850351','其他塑料制品'],['3','850353','改性塑料'],
|
3661
|
+
['3','850354','合成树脂'],['3','850355','膜材料'],['3','850362','其他橡胶制品'],
|
3662
|
+
['3','850363','炭黑'],['3','850331','氮肥'],['3','850332','磷肥及磷化工'],
|
3663
|
+
['3','850333','农药'],['3','850381','复合肥'],['3','850523','非金属材料Ⅲ'],
|
3664
|
+
['3','850442','板材'],['3','850521','其他金属新材料'],['3','850522','磁性材料'],
|
3665
|
+
['3','850551','铝'],['3','850552','铜'],['3','850553','铅锌'],
|
3666
|
+
['3','850531','黄金'],['3','850544','其他小金属'],['3','850812','分立器件'],
|
3667
|
+
['3','850813','半导体材料'],['3','850814','数字芯片设计'],['3','850815','模拟芯片设计'],
|
3668
|
+
['3','850817','集成电路封测'],['3','850818','半导体设备'],['3','850822','印制电路板'],
|
3669
|
+
['3','850823','被动元件'],['3','850831','面板'],['3','850832','LED'],
|
3670
|
+
['3','850833','光学元件'],['3','850841','其他电子Ⅲ'],['3','850853','品牌消费电子'],
|
3671
|
+
['3','850854','消费电子零部件及组装'],['3','850861','电子化学品Ⅲ'],['3','850922','车身附件及饰件'],
|
3672
|
+
['3','850923','底盘与发动机系统'],['3','850924','轮胎轮毂'],['3','850925','其他汽车零部件'],
|
3673
|
+
['3','850926','汽车电子电气系统'],['3','850232','汽车经销商'],['3','850233','汽车综合服务'],
|
3674
|
+
['3','858811','其他运输设备'],['3','858812','摩托车'],['3','850952','综合乘用车'],
|
3675
|
+
['3','850912','商用载货车'],['3','850913','商用载客车'],['3','851112','空调'],
|
3676
|
+
['3','851116','冰洗'],['3','851122','其他黑色家电'],['3','851131','厨房小家电'],
|
3677
|
+
['3','851141','厨房电器'],['3','851151','照明设备Ⅲ'],['3','851161','家电零部件Ⅲ'],
|
3678
|
+
['3','851241','肉制品'],['3','851246','预加工食品'],['3','851247','保健品'],
|
3679
|
+
['3','851251','白酒Ⅲ'],['3','851232','啤酒'],['3','851233','其他酒类'],
|
3680
|
+
['3','851271','软饮料'],['3','851243','乳品'],['3','851281','零食'],
|
3681
|
+
['3','851282','烘焙食品'],['3','851242','调味发酵品Ⅲ'],['3','851312','棉纺'],
|
3682
|
+
['3','851314','印染'],['3','851315','辅料'],['3','851316','其他纺织'],
|
3683
|
+
['3','851325','鞋帽及其他'],['3','851326','家纺'],['3','851329','非运动服装'],
|
3684
|
+
['3','851331','钟表珠宝'],['3','851412','大宗用纸'],['3','851413','特种纸'],
|
3685
|
+
['3','851422','印刷'],['3','851423','金属包装'],['3','851424','塑料包装'],
|
3686
|
+
['3','851425','纸包装'],['3','851436','瓷砖地板'],['3','851437','成品家居'],
|
3687
|
+
['3','851438','定制家居'],['3','851439','卫浴制品'],['3','851491','其他家居用品'],
|
3688
|
+
['3','851452','娱乐用品'],['3','851511','原料药'],['3','851512','化学制剂'],
|
3689
|
+
['3','851521','中药Ⅲ'],['3','851522','血液制品'],['3','851523','疫苗'],
|
3690
|
+
['3','851524','其他生物制品'],['3','851542','医药流通'],['3','851543','线下药店'],
|
3691
|
+
['3','851532','医疗设备'],['3','851533','医疗耗材'],['3','851534','体外诊断'],
|
3692
|
+
['3','851563','医疗研发外包'],['3','851564','医院'],['3','851611','火力发电'],
|
3693
|
+
['3','851612','水力发电'],['3','851614','热力服务'],['3','851616','光伏发电'],
|
3694
|
+
['3','851617','风力发电'],['3','851610','电能综合服务'],['3','851631','燃气Ⅲ'],
|
3695
|
+
['3','851782','原材料供应链服务'],['3','851783','中间产品及消费品供应链服务'],['3','851784','快递'],
|
3696
|
+
['3','851785','跨境物流'],['3','851786','仓储物流'],['3','851787','公路货运'],
|
3697
|
+
['3','851731','高速公路'],['3','851721','公交'],['3','851771','铁路运输'],
|
3698
|
+
['3','851741','航空运输'],['3','851761','航运'],['3','851711','港口'],
|
3699
|
+
['3','851811','住宅开发'],['3','851812','商业地产'],['3','851813','产业地产'],
|
3700
|
+
['3','851831','物业管理'],['3','852021','贸易Ⅲ'],['3','852031','百货'],
|
3701
|
+
['3','852032','超市'],['3','852033','多业态零售'],['3','852034','商业物业经营'],
|
3702
|
+
['3','852041','专业连锁Ⅲ'],['3','852062','跨境电商'],['3','852063','电商服务'],
|
3703
|
+
['3','852182','检测服务'],['3','852183','会展服务'],['3','852121','酒店'],
|
3704
|
+
['3','852111','人工景区'],['3','852112','自然景区'],['3','852131','旅游综合'],
|
3705
|
+
['3','859852','培训教育'],['3','857821','国有大型银行Ⅲ'],['3','857831','股份制银行Ⅲ'],
|
3706
|
+
['3','857841','城商行Ⅲ'],['3','857851','农商行Ⅲ'],['3','851931','证券Ⅲ'],
|
3707
|
+
['3','851941','保险Ⅲ'],['3','851922','金融控股'],['3','851927','资产管理'],
|
3708
|
+
['3','852311','综合Ⅲ'],['3','857111','水泥制造'],['3','857112','水泥制品'],
|
3709
|
+
['3','857121','玻璃制造'],['3','857122','玻纤制造'],['3','850615','耐火材料'],
|
3710
|
+
['3','850616','管材'],['3','850614','其他建材'],['3','850623','房屋建设Ⅲ'],
|
3711
|
+
['3','857221','装修装饰Ⅲ'],['3','857236','基建市政工程'],['3','857251','园林工程'],
|
3712
|
+
['3','857241','钢结构'],['3','857242','化学工程'],['3','857243','国际工程'],
|
3713
|
+
['3','857244','其他专业工程'],['3','857261','工程咨询服务Ⅲ'],['3','850741','电机Ⅲ'],
|
3714
|
+
['3','857334','火电设备'],['3','857336','其他电源设备Ⅲ'],['3','857352','光伏电池组件'],
|
3715
|
+
['3','857354','光伏辅材'],['3','857355','光伏加工设备'],['3','857362','风电零部件'],
|
3716
|
+
['3','857371','锂电池'],['3','857372','电池化学品'],['3','857373','锂电专用设备'],
|
3717
|
+
['3','857375','蓄电池及其他电池'],['3','857381','输变电设备'],['3','857382','配电设备'],
|
3718
|
+
['3','857321','电网自动化设备'],['3','857323','电工仪器仪表'],['3','857344','线缆部件及其他'],
|
3719
|
+
['3','850711','机床工具'],['3','850713','磨具磨料'],['3','850715','制冷空调设备'],
|
3720
|
+
['3','850716','其他通用设备'],['3','850731','仪器仪表'],['3','850751','金属制品'],
|
3721
|
+
['3','850725','能源及重型设备'],['3','850728','楼宇设备'],['3','850721','纺织服装设备'],
|
3722
|
+
['3','850726','印刷包装机械'],['3','850727','其他专用设备'],['3','850936','轨交设备Ⅲ'],
|
3723
|
+
['3','850771','工程机械整机'],['3','850772','工程机械器件'],['3','850781','机器人'],
|
3724
|
+
['3','850782','工控设备'],['3','850783','激光设备'],['3','850784','其他自动化设备'],
|
3725
|
+
['3','857411','航天装备Ⅲ'],['3','857421','航空装备Ⅲ'],['3','857431','地面兵装Ⅲ'],
|
3726
|
+
['3','850935','航海装备Ⅲ'],['3','857451','军工电子Ⅲ'],['3','850702','安防设备'],
|
3727
|
+
['3','850703','其他计算机设备'],['3','852226','IT服务Ⅲ'],['3','851041','垂直应用软件'],
|
3728
|
+
['3','851042','横向通用软件'],['3','857641','游戏Ⅲ'],['3','857651','营销代理'],
|
3729
|
+
['3','857661','影视动漫制作'],['3','857674','门户网站'],['3','857691','教育出版'],
|
3730
|
+
['3','857692','大众出版'],['3','859951','电视广播Ⅲ'],['3','852213','通信工程及服务'],
|
3731
|
+
['3','852214','通信应用增值服务'],['3','851024','通信网络设备及器件'],['3','851025','通信线缆及配套'],
|
3732
|
+
['3','851026','通信终端及配件'],['3','851027','其他通信设备'],['3','859511','动力煤'],
|
3733
|
+
['3','859512','焦煤'],['3','859521','焦炭Ⅲ'],['3','859621','油田服务'],
|
3734
|
+
['3','859622','油气及炼化工程'],['3','859631','炼油化工'],['3','859632','油品石化贸易'],
|
3735
|
+
['3','859633','其他石化'],['3','859711','大气治理'],['3','859712','水务及水治理'],
|
3736
|
+
['3','859713','固废治理'],['3','859714','综合环境治理'],['3','859721','环保设备Ⅲ'],
|
3737
|
+
['3','859811','生活用纸'],['3','859821','化妆品制造及其他'],['3','859822','品牌化妆品'],
|
3738
|
+
|
3739
|
+
#手工添加:可能重复
|
3740
|
+
], columns=['type','code','name'])
|
3741
|
+
|
3742
|
+
return industry
|
3743
|
+
|
3744
|
+
#==============================================================================
|
3745
|
+
if __name__ == '__main__':
|
3746
|
+
icode='859811.SW'
|
3747
|
+
|
3748
|
+
industry_sw_name(icode)
|
3749
|
+
|
3750
|
+
def industry_sw_name(icode):
|
3751
|
+
"""
|
3752
|
+
功能:将申万指数代码转换为指数名称。
|
3753
|
+
输入:指数代码
|
3754
|
+
输出:指数名称
|
3755
|
+
"""
|
3756
|
+
icode=icode.split('.')[0]
|
3757
|
+
|
3758
|
+
industry=industry_sw_list()
|
3759
|
+
|
3760
|
+
try:
|
3761
|
+
iname=industry[industry['code']==icode]['name'].values[0]
|
3762
|
+
except:
|
3763
|
+
#未查到
|
3764
|
+
if not icode.isdigit():
|
3765
|
+
print(" #Warning(industry_sw_name): industry name not found for",icode)
|
3766
|
+
iname=icode
|
3767
|
+
|
3768
|
+
return iname
|
3769
|
+
|
3770
|
+
if __name__=='__main__':
|
3771
|
+
icode='801735'
|
3772
|
+
industry_sw_name(icode)
|
3773
|
+
|
3774
|
+
#==============================================================================
|
3018
3775
|
|
3019
3776
|
#==============================================================================
|
3020
3777
|
#==============================================================================
|