siat 3.4.8__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/market_china.py CHANGED
@@ -268,10 +268,6 @@ def market_profile_china(market='SSE'):
268
268
 
269
269
 
270
270
 
271
-
272
-
273
-
274
-
275
271
  def market_profile_china_tmp(market='SSE'):
276
272
  """
277
273
  功能:沪深市场概况,废弃!
@@ -921,7 +917,7 @@ if __name__=='__main__':
921
917
  def market_detail_china2(category='price',
922
918
  facecolor='papayawhip',
923
919
  decimals=2,
924
- font_size='22px'):
920
+ font_size='20px'):
925
921
  """
926
922
  功能:给出中国当前最新的三大股票交易所的更多细节,合成
927
923
  输出:构造表格型数据框df,利用CSS格式输出
siat/option_pricing.py CHANGED
@@ -1330,11 +1330,13 @@ if __name__ =="__main__":
1330
1330
  lastndays=7
1331
1331
 
1332
1332
  #def predict_stock_trend_by_option(ticker,lastndays=7,power=4):
1333
- def predict_stock_trend_by_option(ticker,lastndays=7):
1333
+ def market_prospect_via_option(ticker,lastdays=7):
1334
1334
  """
1335
1335
  功能:根据股票期权行权价及交易量预测股价
1336
- 注意:本函数已废弃!
1336
+ 注意:本函数与price_prospect_via_option内容基本一致,图示方式略有不同
1337
1337
  """
1338
+ lastndays=lastdays
1339
+
1338
1340
  DEBUG=False
1339
1341
  try:
1340
1342
  datelist=option_maturity(ticker,printout=False)
@@ -1497,15 +1499,15 @@ def predict_stock_trend_by_option(ticker,lastndays=7):
1497
1499
  titletxt="Predicting Price Trend via Option Configuration: "+tname
1498
1500
  footnote1="Note:\n"
1499
1501
  footnote2="1. Recent price: "+lastprice+", "+lastdate+'\n'
1500
- footnote3="2. +(-) predicts higher(lower) price than recent, ++(--) for more likely, +/- for undetermined trend\n"
1501
- footnote4="3. Option trade period: recent "+str(lastndays)+" days. No stock splits in the period. Dates with only 1 option removed\n"
1502
+ footnote3="2. +(-) predicts higher(lower) price than recent, ++(--) more likely, +/- undetermined\n"
1503
+ footnote4="3. Period: recent "+str(lastndays)+" days. No stock splits in the period. Removed dates with 1 option only\n"
1502
1504
  footnote9=footnote1+footnote2+footnote3+footnote4+footnote
1503
1505
 
1504
1506
  df_display_CSS(df3,titletxt=titletxt,footnote=footnote9,facecolor='papayawhip',decimals=2, \
1505
1507
  first_col_align='left',second_col_align='right', \
1506
1508
  last_col_align='right',other_col_align='right', \
1507
- titile_font_size='16px',heading_font_size='15px', \
1508
- data_font_size='15px')
1509
+ titile_font_size='15px',heading_font_size='13px', \
1510
+ data_font_size='13px')
1509
1511
 
1510
1512
  return df2
1511
1513
 
@@ -1864,8 +1866,8 @@ def price_prospect_via_option(ticker,lastdays=7,cutoff=[1.1,5.0,10.0]):
1864
1866
  df_display_CSS(df3,titletxt=titletxt,footnote=footnote9,facecolor='papayawhip',decimals=2, \
1865
1867
  first_col_align='left',second_col_align='right', \
1866
1868
  last_col_align='right',other_col_align='right', \
1867
- titile_font_size='16px',heading_font_size='15px', \
1868
- data_font_size='15px')
1869
+ titile_font_size='15px',heading_font_size='13px', \
1870
+ data_font_size='13px')
1869
1871
 
1870
1872
  return df2
1871
1873
 
siat/sector_china.py CHANGED
@@ -3065,7 +3065,7 @@ if __name__=='__main__':
3065
3065
 
3066
3066
  find_industry_sw(ticker)
3067
3067
 
3068
- def find_industry_sw(ticker,level='1',ticker_order=True,max_sleep=8):
3068
+ def find_industry_sw(ticker,level='1',ticker_order=True,max_sleep=10):
3069
3069
  """
3070
3070
  功能:寻找一只或一组股票所属的申万行业,支持股票代码和股票名称。
3071
3071
  level='1':默认只查找申万1级行业,以便节省时间
@@ -3188,8 +3188,275 @@ def find_industry_sw(ticker,level='1',ticker_order=True,max_sleep=8):
3188
3188
  return result
3189
3189
 
3190
3190
  #==============================================================================
3191
+ #东方财富板块分类:查找股票所属行业与主要同行
3191
3192
  #==============================================================================
3193
+ if __name__=='__main__':
3194
+ ticker='600519.SS'
3195
+ indicator="市盈率"
3196
+ rank=40
3197
+
3198
+ font_size="16px"; facecolor="papayawhip"
3199
+
3200
+ peers=stock_industry_peer_em(ticker,indicator="市盈率",rank=10)
3201
+
3202
+ def stock_peers_em(ticker,indicator="市盈率",rank=10, \
3203
+ font_size="16px",facecolor="papayawhip", \
3204
+ numberPerLine=7):
3205
+ """
3206
+ 功能:基于东方财富行业分类,查找股票所属的行业以及主要同行
3207
+ 特点:行业分类较粗糙,略胜于无
3208
+ """
3209
+ if indicator in ["股价","股票价格","价格","收盘价","价位"]:
3210
+ indicator="最新价"
3211
+ if indicator in ["流动性","热门","活跃"]:
3212
+ indicator="换手率"
3213
+
3214
+ if rank==0:
3215
+ rank=5
3216
+
3217
+ import akshare as ak
3218
+
3219
+ #股票基本信息
3220
+ try:
3221
+ info=ak.stock_individual_info_em(symbol=ticker[:6])
3222
+ except:
3223
+ if not ticker=='':
3224
+ print(" #Warning(stock_peer_em): stock info not found for",ticker)
3225
+
3226
+ df_em=ak.stock_board_industry_name_em()
3227
+ #df_em.sort_values(by="板块名称",ascending=True,inplace=True)
3228
+ #industry_names_em=sorted(list(df_em["板块名称"]),reverse=True)
3229
+ industry_names_em=list(df_em["板块名称"])
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")
3233
+ return None
3234
+
3235
+ #东方财富板块名称
3236
+ hangye=info[info['item']=='行业']['value'].values[0]
3237
+
3238
+ #东方财富板块成分股
3239
+ cfg=ak.stock_board_industry_cons_em(symbol=hangye)
3240
+
3241
+ cfg_col_list=list(cfg)
3242
+ indicator_col=''
3243
+ for i in cfg_col_list:
3244
+ if indicator in i:
3245
+ indicator_col=i
3246
+ break
3247
+
3248
+ if indicator_col=='':
3249
+ print(" #Warning(stock_peer_em): unsupported indicator",indicator)
3250
+
3251
+ remove_list=["序号","代码","名称"]
3252
+ cfg_col_list_tmp = [x for x in cfg_col_list if x not in remove_list]
3253
+ print(" Supported indicators:",)
3254
+ print_list(cfg_col_list_tmp,leading_blanks=2)
3255
+ return None
3256
+
3257
+ collist=['序号','名称','代码','市盈率-动态','市净率','最新价','涨跌幅','换手率']
3258
+ if not indicator_col in collist:
3259
+ collist=collist+[indicator_col]
3260
+
3261
+ #重新排序
3262
+ #cfg.sort_values(by=indicator_col,ascending=False,inplace=True)
3263
+ cfg.sort_values(by=[indicator_col]+["代码"],ascending=[False,True],inplace=True)
3264
+ cfg.reset_index(drop=True,inplace=True)
3265
+ cfg['序号']=cfg.index+1
3266
+
3267
+ #行业均值与中位数
3268
+ indicator_mean=cfg[indicator_col].mean()
3269
+ indicator_median=cfg[indicator_col].median()
3270
+ indicator_total=cfg["代码"].count()
3271
+
3272
+ indicator_value=cfg[cfg['代码']==ticker[:6]][indicator_col].values[0]
3273
+ indicator_seq=cfg[cfg['代码']==ticker[:6]]["序号"].values[0]
3274
+ from scipy.stats import percentileofscore
3275
+ indicator_pct=percentileofscore(cfg[indicator_col],indicator_value)
3276
+
3277
+ #筛选
3278
+ if rank > 0:
3279
+ rank_flag="前"
3280
+ df_disp=cfg[collist].head(rank)
3281
+ else:
3282
+ rank_flag="后"
3283
+ df_disp=cfg[collist].tail(abs(rank))
3284
+
3285
+ #制表
3286
+ tname=ticker_name(ticker)
3287
+ titletxt="行业板块及其上市公司排名:"+hangye+","+indicator_col+"("+rank_flag+str(abs(rank))+"名)"
3288
+
3289
+ footnote1="全行业的"+indicator_col+"状况:均值"+str(round(indicator_mean,2))+",中位数"+str(round(indicator_median,2))+"\n"
3290
+ footnote2=tname+"的"+indicator_col+":"+str(round(indicator_value,2))+",行业排名"+str(indicator_seq)+"/"+str(indicator_total)+",分位"+str(round(indicator_pct,2))+"%\n"
3291
+ import datetime; stoday = datetime.date.today()
3292
+ footnote3="*** 信息来源:东方财富,"+str(stoday)
3293
+ footnote=footnote1+footnote2+footnote3
3294
+
3295
+ #确定表格字体大小
3296
+ titile_font_size=font_size
3297
+ heading_font_size=data_font_size=str(int(font_size.replace('px',''))-1)+'px'
3298
+
3299
+ df_display_CSS(df_disp,titletxt=titletxt,footnote=footnote,facecolor=facecolor, \
3300
+ first_col_align='center',second_col_align='left', \
3301
+ titile_font_size=titile_font_size,heading_font_size=heading_font_size, \
3302
+ data_font_size=data_font_size)
3303
+
3304
+ return cfg
3305
+
3192
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
+
3193
3460
 
3194
3461
 
3195
3462
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: siat
3
- Version: 3.4.8
3
+ Version: 3.4.10
4
4
  Summary: Securities Investment Analysis Tools (siat)
5
5
  Home-page: https://pypi.org/project/siat/
6
6
  Author: Prof. WANG Dehong, International Business School, Beijing Foreign Studies University
@@ -66,7 +66,7 @@ siat/holding_risk.py,sha256=G3wpaewAKF9CwEqRpr4khyuDu9SU2EGyQUHdk7cmHOA,30693
66
66
  siat/holding_risk_test.py,sha256=FRlw_9wFG98BYcg_cSj95HX5WZ1TvkGaOUdXD7-V86s,474
67
67
  siat/local_debug_test.py,sha256=CDAOffW1Rvs-TcNN5giWVvHMlch1w4dp-w5SIV9jXL0,3936
68
68
  siat/luchy_draw.py,sha256=8Ue-NKnvSVqINPY1eXat0NJat5MR-gex_K62aOYFdmA,20486
69
- siat/market_china.py,sha256=W39wwOG9qr0-NQuOXH8gIKEyA6OiThiju8KHOV-G73o,50732
69
+ siat/market_china.py,sha256=fQjAFyu4JAqtVA8I1QYfzv0fmYhLP3zoNe5Ftk63qgM,50724
70
70
  siat/markowitz.py,sha256=DsfS6vG9TAfdJP4GgN-CCArujPi84XjD23CWbxaA2o4,97627
71
71
  siat/markowitz2-20240620.py,sha256=irZAPnjaatFsKQmFRMENP-cO6bEUl2narYtkU5NKTWI,108019
72
72
  siat/markowitz2.py,sha256=LK2pDEtE5PUmBtCHmCcRs8FlPqZKmhFXiuLIL4JeQa8,121991
@@ -82,7 +82,7 @@ siat/ml_cases_example.py,sha256=xRGb3YTQEDTOnaWNzZN_myU5umQnA2RdMNiPrxTmn9c,1673
82
82
  siat/ml_cases_example1.py,sha256=xRGb3YTQEDTOnaWNzZN_myU5umQnA2RdMNiPrxTmn9c,1673
83
83
  siat/option_china.py,sha256=0eIWy5-0L8fECVwakVoA8EUO-_5u5jGW66dVLRi1_PY,120954
84
84
  siat/option_china_test.py,sha256=UQ-YUHUjoGBQyanLcM-yzqeEIUQP_gCQIeT0W6rnUnA,16355
85
- siat/option_pricing.py,sha256=8uGzCNcSmLu_99w8qx99oqxvUHUNOZq5LObPffrdtxk,73177
85
+ siat/option_pricing.py,sha256=VEqe7VbPkdWX8lS7fJaL1GF9cQx2HRe3UBI2XZJouBQ,73237
86
86
  siat/option_pricing_test.py,sha256=eeorV5Ja5vjlRXnP6fWJHetGU5Vb8SnLopkC6RV3GfA,2203
87
87
  siat/option_sina_api_test.py,sha256=dn-k_wrQnAaNKHoROvWJEc7lqlU0bwiV2Aa4usWAFGM,5908
88
88
  siat/proxy_test.py,sha256=erQJrmGs2X46z8Gb1h-7GYQ0rTUcaR8dxHExWoBz2eM,2610
@@ -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=nP6kfYsnaQWZj8dK-zklwSDW8FDS-obZWp_zL0ec2Ig,118603
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.8.dist-info/METADATA,sha256=za1tq7AU9BmJbNQUSZICpzAQvfJZc4_ThYOCqwcGN2s,7682
143
- siat-3.4.8.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
144
- siat-3.4.8.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
145
- siat-3.4.8.dist-info/RECORD,,
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,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: bdist_wheel (0.38.4)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5