siat 3.4.9__py3-none-any.whl → 3.4.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/sector_china.py
CHANGED
@@ -3197,13 +3197,14 @@ if __name__=='__main__':
|
|
3197
3197
|
|
3198
3198
|
font_size="16px"; facecolor="papayawhip"
|
3199
3199
|
|
3200
|
-
peers=
|
3200
|
+
peers=stock_industry_peer_em(ticker,indicator="市盈率",rank=10)
|
3201
3201
|
|
3202
|
-
def
|
3203
|
-
font_size="16px",facecolor="papayawhip"
|
3202
|
+
def stock_peers_em(ticker,indicator="市盈率",rank=10, \
|
3203
|
+
font_size="16px",facecolor="papayawhip", \
|
3204
|
+
numberPerLine=7):
|
3204
3205
|
"""
|
3205
|
-
|
3206
|
-
|
3206
|
+
功能:基于东方财富行业分类,查找股票所属的行业以及主要同行
|
3207
|
+
特点:行业分类较粗糙,略胜于无
|
3207
3208
|
"""
|
3208
3209
|
if indicator in ["股价","股票价格","价格","收盘价","价位"]:
|
3209
3210
|
indicator="最新价"
|
@@ -3219,14 +3220,16 @@ def stock_peer_em(ticker,indicator="市盈率",rank=10, \
|
|
3219
3220
|
try:
|
3220
3221
|
info=ak.stock_individual_info_em(symbol=ticker[:6])
|
3221
3222
|
except:
|
3222
|
-
|
3223
|
+
if not ticker=='':
|
3224
|
+
print(" #Warning(stock_peer_em): stock info not found for",ticker)
|
3225
|
+
|
3223
3226
|
df_em=ak.stock_board_industry_name_em()
|
3224
3227
|
#df_em.sort_values(by="板块名称",ascending=True,inplace=True)
|
3225
3228
|
#industry_names_em=sorted(list(df_em["板块名称"]),reverse=True)
|
3226
3229
|
industry_names_em=list(df_em["板块名称"])
|
3227
|
-
print(" List of
|
3228
|
-
printlist(industry_names_em,numperline=7,beforehand=' ')
|
3229
|
-
|
3230
|
+
print(" List of stock industries in East Money:",len(df_em),end='')
|
3231
|
+
#printlist(industry_names_em,numperline=7,beforehand=' ')
|
3232
|
+
printInLine_md(industry_names_em,numberPerLine=numberPerLine,colalign="center")
|
3230
3233
|
return None
|
3231
3234
|
|
3232
3235
|
#东方财富板块名称
|
@@ -3240,6 +3243,8 @@ def stock_peer_em(ticker,indicator="市盈率",rank=10, \
|
|
3240
3243
|
for i in cfg_col_list:
|
3241
3244
|
if indicator in i:
|
3242
3245
|
indicator_col=i
|
3246
|
+
break
|
3247
|
+
|
3243
3248
|
if indicator_col=='':
|
3244
3249
|
print(" #Warning(stock_peer_em): unsupported indicator",indicator)
|
3245
3250
|
|
@@ -3254,7 +3259,8 @@ def stock_peer_em(ticker,indicator="市盈率",rank=10, \
|
|
3254
3259
|
collist=collist+[indicator_col]
|
3255
3260
|
|
3256
3261
|
#重新排序
|
3257
|
-
cfg.sort_values(by=indicator_col,ascending=False,inplace=True)
|
3262
|
+
#cfg.sort_values(by=indicator_col,ascending=False,inplace=True)
|
3263
|
+
cfg.sort_values(by=[indicator_col]+["代码"],ascending=[False,True],inplace=True)
|
3258
3264
|
cfg.reset_index(drop=True,inplace=True)
|
3259
3265
|
cfg['序号']=cfg.index+1
|
3260
3266
|
|
@@ -3281,7 +3287,7 @@ def stock_peer_em(ticker,indicator="市盈率",rank=10, \
|
|
3281
3287
|
titletxt="行业板块及其上市公司排名:"+hangye+","+indicator_col+"("+rank_flag+str(abs(rank))+"名)"
|
3282
3288
|
|
3283
3289
|
footnote1="全行业的"+indicator_col+"状况:均值"+str(round(indicator_mean,2))+",中位数"+str(round(indicator_median,2))+"\n"
|
3284
|
-
footnote2=tname+"的"+indicator_col+":"+str(round(indicator_value,2))+",行业排名"+str(indicator_seq)+"/"+str(indicator_total)+"
|
3290
|
+
footnote2=tname+"的"+indicator_col+":"+str(round(indicator_value,2))+",行业排名"+str(indicator_seq)+"/"+str(indicator_total)+",分位"+str(round(indicator_pct,2))+"%\n"
|
3285
3291
|
import datetime; stoday = datetime.date.today()
|
3286
3292
|
footnote3="*** 信息来源:东方财富,"+str(stoday)
|
3287
3293
|
footnote=footnote1+footnote2+footnote3
|
@@ -3297,6 +3303,160 @@ def stock_peer_em(ticker,indicator="市盈率",rank=10, \
|
|
3297
3303
|
|
3298
3304
|
return cfg
|
3299
3305
|
|
3306
|
+
#==============================================================================
|
3307
|
+
if __name__=='__main__':
|
3308
|
+
concept='酒'
|
3309
|
+
concept='股'
|
3310
|
+
concept='白酒'
|
3311
|
+
|
3312
|
+
ticker="600519.SS"
|
3313
|
+
indicator="市盈率"
|
3314
|
+
rank=40
|
3315
|
+
|
3316
|
+
font_size="16px"; facecolor="papayawhip"; numberPerLine=7
|
3317
|
+
|
3318
|
+
|
3319
|
+
def concept_stocks_em(concept='',ticker='',indicator="市盈率",rank=10, \
|
3320
|
+
font_size="16px",facecolor="papayawhip",numberPerLine=7):
|
3321
|
+
"""
|
3322
|
+
功能:基于东方财富概念板块,查找关键字相关概念以及股票业绩
|
3323
|
+
特点:概念板块划分细致,同一股票可能分属多个板块,与行业分类不同
|
3324
|
+
"""
|
3325
|
+
if indicator in ["股价","股票价格","价格","收盘价","价位"]:
|
3326
|
+
indicator="最新价"
|
3327
|
+
if indicator in ["流动性","热门","活跃"]:
|
3328
|
+
indicator="换手率"
|
3329
|
+
|
3330
|
+
if rank==0:
|
3331
|
+
rank=5
|
3332
|
+
|
3333
|
+
import akshare as ak
|
3334
|
+
|
3335
|
+
#获取所有板块信息
|
3336
|
+
try:
|
3337
|
+
concept_df = ak.stock_board_concept_name_em()
|
3338
|
+
except:
|
3339
|
+
print(" #Warning(concept_stocks_em): data source is unaccessible, check network")
|
3340
|
+
return None
|
3341
|
+
|
3342
|
+
concept_list=list(concept_df["板块名称"])
|
3343
|
+
concept_list2 = [x for x in concept_list if "昨日" not in x]
|
3344
|
+
concept_list_tmp = [x for x in concept_list2 if concept in x]
|
3345
|
+
|
3346
|
+
#未找到
|
3347
|
+
if len(concept_list_tmp)==0 or concept=='':
|
3348
|
+
if concept!='':
|
3349
|
+
print(" #Warning(concept_stocks_em): concept not found with",concept)
|
3350
|
+
print(" Available concepts in East Money:",len(concept_list2),end='')
|
3351
|
+
printInLine_md(concept_list2,numberPerLine=numberPerLine,colalign="center")
|
3352
|
+
#print(" Tips: you can use one of the concepts above to re-run the command")
|
3353
|
+
|
3354
|
+
return None
|
3355
|
+
|
3356
|
+
#找到多个概念板块
|
3357
|
+
if len(concept_list_tmp)>1 and len(concept_list_tmp)<numberPerLine:
|
3358
|
+
print(" Concepts found in East Money:",end='')
|
3359
|
+
print_list(concept_list_tmp,leading_blanks=2)
|
3360
|
+
#print(" Tips: you can use one of the concepts above to re-run the command")
|
3361
|
+
|
3362
|
+
return None
|
3363
|
+
|
3364
|
+
if len(concept_list_tmp)>numberPerLine and concept!='':
|
3365
|
+
print(" Concepts found in East Money:",len(concept_list_tmp),end='')
|
3366
|
+
printInLine_md(concept_list_tmp,numberPerLine=numberPerLine,colalign="center")
|
3367
|
+
#print(" Tips: you can use one of the concepts above to re-run the command")
|
3368
|
+
|
3369
|
+
return None
|
3370
|
+
|
3371
|
+
#找到一个概念板块,详细处理
|
3372
|
+
#if len(concept_list_tmp)==1:
|
3373
|
+
concept=concept_list_tmp[0]
|
3374
|
+
|
3375
|
+
#东方财富概念板块成分股
|
3376
|
+
cfg=ak.stock_board_concept_cons_em(concept)
|
3377
|
+
|
3378
|
+
cfg_col_list=list(cfg)
|
3379
|
+
indicator_col=''
|
3380
|
+
for i in cfg_col_list:
|
3381
|
+
if indicator in i:
|
3382
|
+
indicator_col=i
|
3383
|
+
break
|
3384
|
+
|
3385
|
+
if indicator_col=='':
|
3386
|
+
print(" #Warning(concept_stocks_em): unsupported indicator",indicator)
|
3387
|
+
|
3388
|
+
remove_list=["序号","代码","名称"]
|
3389
|
+
cfg_col_list_tmp = [x for x in cfg_col_list if x not in remove_list]
|
3390
|
+
print(" Supported indicators:",)
|
3391
|
+
print_list(cfg_col_list_tmp,leading_blanks=2)
|
3392
|
+
|
3393
|
+
return None
|
3394
|
+
|
3395
|
+
collist=['序号','名称','代码','市盈率-动态','市净率','最新价','涨跌幅','换手率']
|
3396
|
+
if not indicator_col in collist:
|
3397
|
+
collist=collist+[indicator_col]
|
3398
|
+
|
3399
|
+
#重新排序
|
3400
|
+
cfg.sort_values(by=[indicator_col]+["代码"],ascending=[False,True],inplace=True)
|
3401
|
+
cfg.reset_index(drop=True,inplace=True)
|
3402
|
+
cfg['序号']=cfg.index+1
|
3403
|
+
|
3404
|
+
#行业均值与中位数
|
3405
|
+
indicator_mean=cfg[indicator_col].mean()
|
3406
|
+
indicator_median=cfg[indicator_col].median()
|
3407
|
+
indicator_total=cfg["代码"].count()
|
3408
|
+
|
3409
|
+
found_stock=False
|
3410
|
+
stock_list=list(cfg['代码'])
|
3411
|
+
if ticker[:6] in stock_list:
|
3412
|
+
found_stock=True
|
3413
|
+
else:
|
3414
|
+
if not ticker=='':
|
3415
|
+
print(" #Warning(concept_stocks_em): stock not found for",ticker)
|
3416
|
+
|
3417
|
+
if found_stock:
|
3418
|
+
indicator_value=cfg[cfg['代码']==ticker[:6]][indicator_col].values[0]
|
3419
|
+
indicator_seq=cfg[cfg['代码']==ticker[:6]]["序号"].values[0]
|
3420
|
+
from scipy.stats import percentileofscore
|
3421
|
+
indicator_pct=percentileofscore(cfg[indicator_col],indicator_value)
|
3422
|
+
|
3423
|
+
#筛选
|
3424
|
+
if rank > 0:
|
3425
|
+
rank_flag="前"
|
3426
|
+
df_disp=cfg[collist].head(rank)
|
3427
|
+
else:
|
3428
|
+
rank_flag="后"
|
3429
|
+
df_disp=cfg[collist].tail(abs(rank))
|
3430
|
+
|
3431
|
+
#制表
|
3432
|
+
titletxt="概念板块及其上市公司排名:"+concept+","+indicator_col+"("+rank_flag+str(abs(rank))+"名)"
|
3433
|
+
|
3434
|
+
footnote1="概念板块的"+indicator_col+"整体状况:均值"+str(round(indicator_mean,2))+",中位数"+str(round(indicator_median,2))+"\n"
|
3435
|
+
footnote2=''
|
3436
|
+
if found_stock:
|
3437
|
+
tname=ticker_name(ticker)
|
3438
|
+
footnote2=tname+"的"+indicator_col+":"+str(round(indicator_value,2))+",板块排名"+str(indicator_seq)+"/"+str(indicator_total)+",分位"+str(round(indicator_pct,2))+"%\n"
|
3439
|
+
else:
|
3440
|
+
footnote2="概念板块:"+concept+",成分股数量"+str(len(cfg))+'\n'
|
3441
|
+
|
3442
|
+
import datetime; stoday = datetime.date.today()
|
3443
|
+
footnote3="*** 信息来源:东方财富,"+str(stoday)
|
3444
|
+
if found_stock:
|
3445
|
+
footnote=footnote1+footnote2+footnote3
|
3446
|
+
else:
|
3447
|
+
footnote=footnote2+footnote1+footnote3
|
3448
|
+
|
3449
|
+
#确定表格字体大小
|
3450
|
+
titile_font_size=font_size
|
3451
|
+
heading_font_size=data_font_size=str(int(font_size.replace('px',''))-1)+'px'
|
3452
|
+
|
3453
|
+
df_display_CSS(df_disp,titletxt=titletxt,footnote=footnote,facecolor=facecolor, \
|
3454
|
+
first_col_align='center',second_col_align='left', \
|
3455
|
+
titile_font_size=titile_font_size,heading_font_size=heading_font_size, \
|
3456
|
+
data_font_size=data_font_size)
|
3457
|
+
|
3458
|
+
return cfg
|
3459
|
+
|
3300
3460
|
|
3301
3461
|
|
3302
3462
|
|
@@ -94,7 +94,7 @@ siat/risk_evaluation.py,sha256=I6B3gty-t--AkDCO0tKF-291YfpnF-IkXcFjqNKCt9I,76286
|
|
94
94
|
siat/risk_evaluation_test.py,sha256=YEXM96gKzTfwN4U61AS4Rr1tV7KgUvn4rRC6f3iMw9s,3731
|
95
95
|
siat/risk_free_rate.py,sha256=ZMr4cHikPvXvywr54gGqiI3Nvb69am6tq3zj2hwzANE,12384
|
96
96
|
siat/risk_free_rate_test.py,sha256=CpmhUf8aEAEZeNu4gvWP2Mz2dLoIgBX5bI41vfUBEr8,4285
|
97
|
-
siat/sector_china.py,sha256=
|
97
|
+
siat/sector_china.py,sha256=ASAIwlysX9HbS4C30gd6Uh7d1dWAQdRGQvUgJhtexm0,129147
|
98
98
|
siat/sector_china_test.py,sha256=1wq7ef8Bb_L8F0h0W6FvyBrIcBTEbrTV7hljtpj49U4,5843
|
99
99
|
siat/security_price.py,sha256=2oHskgiw41KMGfqtnA0i2YjNNV6cYgtlUK0j3YeuXWs,29185
|
100
100
|
siat/security_price2.py,sha256=65s64L68aRZdVVK3V8UYxdPd_JHMqgJ2FBJJX5MSW-Q,26174
|
@@ -139,7 +139,7 @@ siat/valuation_china.py,sha256=EkZQaVkoBjM0c4MCNbaX-bMnlG0e3FXeaWczZDnkptU,67784
|
|
139
139
|
siat/valuation_market_china_test.py,sha256=gbJ0ioauuo4koTPH6WKUkqcXiQPafnbhU5eKJ6lpdLA,1571
|
140
140
|
siat/var_model_validation.py,sha256=R0caWnuZarrRg9939hxh3vJIIpIyPfvelYmzFNZtPbo,14910
|
141
141
|
siat/yf_name.py,sha256=H1EM8YYXA8nQHIqsJlso0I3HKPiJLT3QujO4gRVQXWs,13945
|
142
|
-
siat-3.4.
|
143
|
-
siat-3.4.
|
144
|
-
siat-3.4.
|
145
|
-
siat-3.4.
|
142
|
+
siat-3.4.10.dist-info/METADATA,sha256=gTlCZesag1aR19iTEb2e5ORaiOiAO2uJku9vpyRI7z8,7683
|
143
|
+
siat-3.4.10.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
144
|
+
siat-3.4.10.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
|
145
|
+
siat-3.4.10.dist-info/RECORD,,
|
File without changes
|
File without changes
|