siat 3.4.9__py3-none-any.whl → 3.4.12__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=5):
|
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,8 +3243,11 @@ 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
|
3243
|
-
|
3244
|
-
|
3246
|
+
break
|
3247
|
+
|
3248
|
+
if indicator_col=='' or indicator=='':
|
3249
|
+
if indicator!='':
|
3250
|
+
print(" #Warning(stock_peer_em): unsupported indicator",indicator)
|
3245
3251
|
|
3246
3252
|
remove_list=["序号","代码","名称"]
|
3247
3253
|
cfg_col_list_tmp = [x for x in cfg_col_list if x not in remove_list]
|
@@ -3254,7 +3260,8 @@ def stock_peer_em(ticker,indicator="市盈率",rank=10, \
|
|
3254
3260
|
collist=collist+[indicator_col]
|
3255
3261
|
|
3256
3262
|
#重新排序
|
3257
|
-
cfg.sort_values(by=indicator_col,ascending=False,inplace=True)
|
3263
|
+
#cfg.sort_values(by=indicator_col,ascending=False,inplace=True)
|
3264
|
+
cfg.sort_values(by=[indicator_col]+["代码"],ascending=[False,True],inplace=True)
|
3258
3265
|
cfg.reset_index(drop=True,inplace=True)
|
3259
3266
|
cfg['序号']=cfg.index+1
|
3260
3267
|
|
@@ -3276,12 +3283,28 @@ def stock_peer_em(ticker,indicator="市盈率",rank=10, \
|
|
3276
3283
|
rank_flag="后"
|
3277
3284
|
df_disp=cfg[collist].tail(abs(rank))
|
3278
3285
|
|
3286
|
+
#强制显示所选股票
|
3287
|
+
if force_show_stock:
|
3288
|
+
#所选股票是否在其中?
|
3289
|
+
if not ticker[:6] in list(df_disp["代码"]):
|
3290
|
+
ticker_seq=cfg[cfg["代码"]==ticker[:6]]["序号"].values[0]
|
3291
|
+
seq1=ticker_seq-4; seq2=ticker_seq+5
|
3292
|
+
#如果超出开头
|
3293
|
+
if seq1 <=0:
|
3294
|
+
seq1=1; seq2=10
|
3295
|
+
#如果超出结尾
|
3296
|
+
if seq2 > len(cfg):
|
3297
|
+
seq2=len(cfg); seq1=len(cfg)-9
|
3298
|
+
|
3299
|
+
#注意:此处的&不能换为and
|
3300
|
+
df_disp=cfg[(cfg["序号"]>=seq1) & (cfg["序号"]<=seq2)][collist]
|
3301
|
+
|
3279
3302
|
#制表
|
3280
3303
|
tname=ticker_name(ticker)
|
3281
3304
|
titletxt="行业板块及其上市公司排名:"+hangye+","+indicator_col+"("+rank_flag+str(abs(rank))+"名)"
|
3282
3305
|
|
3283
3306
|
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)+"
|
3307
|
+
footnote2=tname+"的"+indicator_col+":"+str(round(indicator_value,2))+",行业排名"+str(indicator_seq)+"/"+str(indicator_total)+",分位"+str(round(indicator_pct,2))+"%\n"
|
3285
3308
|
import datetime; stoday = datetime.date.today()
|
3286
3309
|
footnote3="*** 信息来源:东方财富,"+str(stoday)
|
3287
3310
|
footnote=footnote1+footnote2+footnote3
|
@@ -3297,6 +3320,180 @@ def stock_peer_em(ticker,indicator="市盈率",rank=10, \
|
|
3297
3320
|
|
3298
3321
|
return cfg
|
3299
3322
|
|
3323
|
+
#==============================================================================
|
3324
|
+
if __name__=='__main__':
|
3325
|
+
concept='酒'
|
3326
|
+
concept='股'
|
3327
|
+
concept='白酒'
|
3328
|
+
|
3329
|
+
ticker="600519.SS"
|
3330
|
+
indicator="市盈率"
|
3331
|
+
rank=11
|
3332
|
+
|
3333
|
+
force_show_stock=True
|
3334
|
+
|
3335
|
+
font_size="16px"; facecolor="papayawhip"; numberPerLine=7
|
3336
|
+
|
3337
|
+
|
3338
|
+
def concept_stocks_em(concept='',ticker='',indicator="市盈率",rank=10, \
|
3339
|
+
force_show_stock=False, \
|
3340
|
+
font_size="16px",facecolor="papayawhip",numberPerLine=5):
|
3341
|
+
"""
|
3342
|
+
功能:基于东方财富概念板块,查找关键字相关概念以及股票业绩
|
3343
|
+
特点:概念板块划分细致,同一股票可能分属多个板块,与行业分类不同
|
3344
|
+
"""
|
3345
|
+
if indicator in ["股价","股票价格","价格","收盘价","价位"]:
|
3346
|
+
indicator="最新价"
|
3347
|
+
if indicator in ["流动性","热门","活跃"]:
|
3348
|
+
indicator="换手率"
|
3349
|
+
|
3350
|
+
if rank==0:
|
3351
|
+
rank=5
|
3352
|
+
|
3353
|
+
import akshare as ak
|
3354
|
+
|
3355
|
+
#获取所有板块信息
|
3356
|
+
try:
|
3357
|
+
concept_df = ak.stock_board_concept_name_em()
|
3358
|
+
except:
|
3359
|
+
print(" #Warning(concept_stocks_em): data source is unaccessible, check network")
|
3360
|
+
return None
|
3361
|
+
|
3362
|
+
concept_list=list(concept_df["板块名称"])
|
3363
|
+
concept_list2 = [x for x in concept_list if "昨日" not in x]
|
3364
|
+
concept_list_tmp = [x for x in concept_list2 if concept in x]
|
3365
|
+
|
3366
|
+
#未找到
|
3367
|
+
if len(concept_list_tmp)==0 or concept=='':
|
3368
|
+
if concept!='':
|
3369
|
+
print(" #Warning(concept_stocks_em): concept not found with",concept)
|
3370
|
+
print(" Available concepts in East Money:",len(concept_list2),end='')
|
3371
|
+
printInLine_md(concept_list2,numberPerLine=numberPerLine,colalign="center")
|
3372
|
+
#print(" Tips: you can use one of the concepts above to re-run the command")
|
3373
|
+
|
3374
|
+
return None
|
3375
|
+
|
3376
|
+
#找到多个概念板块
|
3377
|
+
if len(concept_list_tmp)>1 and len(concept_list_tmp)<numberPerLine:
|
3378
|
+
print(" Concepts found in East Money:",end='')
|
3379
|
+
print_list(concept_list_tmp,leading_blanks=2)
|
3380
|
+
#print(" Tips: you can use one of the concepts above to re-run the command")
|
3381
|
+
|
3382
|
+
return None
|
3383
|
+
|
3384
|
+
if len(concept_list_tmp)>numberPerLine and concept!='':
|
3385
|
+
print(" Concepts found in East Money:",len(concept_list_tmp),end='')
|
3386
|
+
printInLine_md(concept_list_tmp,numberPerLine=numberPerLine,colalign="center")
|
3387
|
+
#print(" Tips: you can use one of the concepts above to re-run the command")
|
3388
|
+
|
3389
|
+
return None
|
3390
|
+
|
3391
|
+
#找到一个概念板块,详细处理
|
3392
|
+
#if len(concept_list_tmp)==1:
|
3393
|
+
concept=concept_list_tmp[0]
|
3394
|
+
|
3395
|
+
#东方财富概念板块成分股
|
3396
|
+
cfg=ak.stock_board_concept_cons_em(concept)
|
3397
|
+
|
3398
|
+
cfg_col_list=list(cfg)
|
3399
|
+
indicator_col=''
|
3400
|
+
for i in cfg_col_list:
|
3401
|
+
if indicator in i:
|
3402
|
+
indicator_col=i
|
3403
|
+
break
|
3404
|
+
|
3405
|
+
if indicator_col=='':
|
3406
|
+
print(" #Warning(concept_stocks_em): unsupported indicator",indicator)
|
3407
|
+
|
3408
|
+
remove_list=["序号","代码","名称"]
|
3409
|
+
cfg_col_list_tmp = [x for x in cfg_col_list if x not in remove_list]
|
3410
|
+
print(" Supported indicators:",)
|
3411
|
+
print_list(cfg_col_list_tmp,leading_blanks=2)
|
3412
|
+
|
3413
|
+
return None
|
3414
|
+
|
3415
|
+
collist=['序号','名称','代码','市盈率-动态','市净率','最新价','涨跌幅','换手率']
|
3416
|
+
if not indicator_col in collist:
|
3417
|
+
collist=collist+[indicator_col]
|
3418
|
+
|
3419
|
+
#重新排序
|
3420
|
+
cfg.sort_values(by=[indicator_col]+["代码"],ascending=[False,True],inplace=True)
|
3421
|
+
cfg.reset_index(drop=True,inplace=True)
|
3422
|
+
cfg['序号']=cfg.index+1
|
3423
|
+
|
3424
|
+
#行业均值与中位数
|
3425
|
+
indicator_mean=cfg[indicator_col].mean()
|
3426
|
+
indicator_median=cfg[indicator_col].median()
|
3427
|
+
indicator_total=cfg["代码"].count()
|
3428
|
+
|
3429
|
+
found_stock=False
|
3430
|
+
stock_list=list(cfg['代码'])
|
3431
|
+
if ticker[:6] in stock_list:
|
3432
|
+
found_stock=True
|
3433
|
+
else:
|
3434
|
+
if not ticker=='':
|
3435
|
+
print(" #Warning(concept_stocks_em): stock not found for",ticker)
|
3436
|
+
|
3437
|
+
if found_stock:
|
3438
|
+
indicator_value=cfg[cfg['代码']==ticker[:6]][indicator_col].values[0]
|
3439
|
+
indicator_seq=cfg[cfg['代码']==ticker[:6]]["序号"].values[0]
|
3440
|
+
from scipy.stats import percentileofscore
|
3441
|
+
indicator_pct=percentileofscore(cfg[indicator_col],indicator_value)
|
3442
|
+
|
3443
|
+
#筛选
|
3444
|
+
if rank > 0:
|
3445
|
+
rank_flag="前"
|
3446
|
+
df_disp=cfg[collist].head(rank)
|
3447
|
+
else:
|
3448
|
+
rank_flag="后"
|
3449
|
+
df_disp=cfg[collist].tail(abs(rank))
|
3450
|
+
|
3451
|
+
#强制显示所选股票
|
3452
|
+
if force_show_stock:
|
3453
|
+
#所选股票是否在其中?
|
3454
|
+
if not ticker[:6] in list(df_disp["代码"]):
|
3455
|
+
ticker_seq=cfg[cfg["代码"]==ticker[:6]]["序号"].values[0]
|
3456
|
+
seq1=ticker_seq-4; seq2=ticker_seq+5
|
3457
|
+
#如果超出开头
|
3458
|
+
if seq1 <=0:
|
3459
|
+
seq1=1; seq2=10
|
3460
|
+
#如果超出结尾
|
3461
|
+
if seq2 > len(cfg):
|
3462
|
+
seq2=len(cfg); seq1=len(cfg)-9
|
3463
|
+
|
3464
|
+
#注意:此处的&不能换为and
|
3465
|
+
df_disp=cfg[(cfg["序号"]>=seq1) & (cfg["序号"]<=seq2)][collist]
|
3466
|
+
|
3467
|
+
|
3468
|
+
#制表
|
3469
|
+
titletxt="概念板块及其上市公司排名:"+concept+","+indicator_col+"("+rank_flag+str(abs(rank))+"名)"
|
3470
|
+
|
3471
|
+
footnote1="概念板块的"+indicator_col+"整体状况:均值"+str(round(indicator_mean,2))+",中位数"+str(round(indicator_median,2))+"\n"
|
3472
|
+
footnote2=''
|
3473
|
+
if found_stock:
|
3474
|
+
tname=ticker_name(ticker)
|
3475
|
+
footnote2=tname+"的"+indicator_col+":"+str(round(indicator_value,2))+",板块排名"+str(indicator_seq)+"/"+str(indicator_total)+",分位"+str(round(indicator_pct,2))+"%\n"
|
3476
|
+
else:
|
3477
|
+
footnote2="概念板块:"+concept+",成分股数量"+str(len(cfg))+'\n'
|
3478
|
+
|
3479
|
+
import datetime; stoday = datetime.date.today()
|
3480
|
+
footnote3="*** 信息来源:东方财富,"+str(stoday)
|
3481
|
+
if found_stock:
|
3482
|
+
footnote=footnote1+footnote2+footnote3
|
3483
|
+
else:
|
3484
|
+
footnote=footnote2+footnote1+footnote3
|
3485
|
+
|
3486
|
+
#确定表格字体大小
|
3487
|
+
titile_font_size=font_size
|
3488
|
+
heading_font_size=data_font_size=str(int(font_size.replace('px',''))-1)+'px'
|
3489
|
+
|
3490
|
+
df_display_CSS(df_disp,titletxt=titletxt,footnote=footnote,facecolor=facecolor, \
|
3491
|
+
first_col_align='center',second_col_align='left', \
|
3492
|
+
titile_font_size=titile_font_size,heading_font_size=heading_font_size, \
|
3493
|
+
data_font_size=data_font_size)
|
3494
|
+
|
3495
|
+
return cfg
|
3496
|
+
|
3300
3497
|
|
3301
3498
|
|
3302
3499
|
|
@@ -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=dCBzhFUbCKZytRmtMcPCmrq6ktmXJ50FH6g48SMXlt8,130573
|
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.12.dist-info/METADATA,sha256=4x-7hEFgcIpc91o197nqMAM8kxqCckIONyb5qWMpdO8,7683
|
143
|
+
siat-3.4.12.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
144
|
+
siat-3.4.12.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
|
145
|
+
siat-3.4.12.dist-info/RECORD,,
|
File without changes
|