siat 3.8.1__py3-none-any.whl → 3.8.2__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/economy2.py +69 -7
- siat/sector_china.py +50 -19
- {siat-3.8.1.dist-info → siat-3.8.2.dist-info}/METADATA +1 -1
- {siat-3.8.1.dist-info → siat-3.8.2.dist-info}/RECORD +7 -7
- {siat-3.8.1.dist-info → siat-3.8.2.dist-info}/LICENSE +0 -0
- {siat-3.8.1.dist-info → siat-3.8.2.dist-info}/WHEEL +0 -0
- {siat-3.8.1.dist-info → siat-3.8.2.dist-info}/top_level.txt +0 -0
siat/economy2.py
CHANGED
@@ -53,7 +53,7 @@ def find_economic_indicator(key_words='GDP',top=10, \
|
|
53
53
|
def indicator_wb(key_words='GDP',top=20,note=False,translate=False):
|
54
54
|
"""
|
55
55
|
============================================================================
|
56
|
-
|
56
|
+
功能:在WB/IMF/FRED数据库中查找宏观经济指标的代码
|
57
57
|
参数:
|
58
58
|
key_words:可包括多个关键词,使用空格隔开,不区分大小写
|
59
59
|
top:输出相似度最高的,默认5个
|
@@ -73,7 +73,7 @@ def indicator_wb(key_words='GDP',top=20,note=False,translate=False):
|
|
73
73
|
try:
|
74
74
|
df_tmp=wb.search(word)
|
75
75
|
except:
|
76
|
-
print(" Sorry,
|
76
|
+
print(" Sorry, data source rejected connection, try again later")
|
77
77
|
return None
|
78
78
|
|
79
79
|
# 合并
|
@@ -94,6 +94,10 @@ def indicator_wb(key_words='GDP',top=20,note=False,translate=False):
|
|
94
94
|
df2=fuzzy_search_wb(df,key_words=key_words,column='name2',top=top)
|
95
95
|
|
96
96
|
# 遍历输出
|
97
|
+
if len(df2)==0:
|
98
|
+
print(f"Sorry, no indicator found with key words: {key_words}")
|
99
|
+
return None
|
100
|
+
|
97
101
|
#print('') #空一行
|
98
102
|
for row in df2.itertuples():
|
99
103
|
|
@@ -189,6 +193,50 @@ def indicator_name_wb(indicator='NY.GDP.MKTP.KN'):
|
|
189
193
|
return indicator_name
|
190
194
|
|
191
195
|
|
196
|
+
#==============================================================================
|
197
|
+
if __name__ =="__main__":
|
198
|
+
ticker='CN'; show_name=True
|
199
|
+
check_country_code('ZWE',show_name=True)
|
200
|
+
check_country_code('ZAF',show_name=True)
|
201
|
+
check_country_code('cn',show_name=True)
|
202
|
+
|
203
|
+
def check_country_code(ticker='CN',show_name=False):
|
204
|
+
"""
|
205
|
+
===========================================================================
|
206
|
+
功能:检查国家代码是否支持
|
207
|
+
ticker:国家代码
|
208
|
+
show_name:是否显示国家名称,默认否False
|
209
|
+
|
210
|
+
返回值:若国家代码在列表中,True;否则,False
|
211
|
+
"""
|
212
|
+
country_codes=wb.country_codes
|
213
|
+
|
214
|
+
elements_to_remove = ['all','ALL','All']
|
215
|
+
country_code_list = [x for x in country_codes if x not in elements_to_remove]
|
216
|
+
|
217
|
+
result=False
|
218
|
+
if ticker in country_code_list:
|
219
|
+
result=True
|
220
|
+
|
221
|
+
if show_name:
|
222
|
+
if result:
|
223
|
+
indicator='NY.GDP.MKTP.KN'
|
224
|
+
df=economy_indicator_wb(ticker=ticker,indicator=indicator, \
|
225
|
+
start='2000',graph=False)
|
226
|
+
if not (df is None):
|
227
|
+
if len(df) >= 1:
|
228
|
+
country_name=df['country'].values[0]
|
229
|
+
print(f"Country code {ticker} refers to {country_name}")
|
230
|
+
else:
|
231
|
+
print(f"Country code {ticker} found, but its name not found")
|
232
|
+
else:
|
233
|
+
print(f"Found country code {ticker}, but its name not found")
|
234
|
+
else:
|
235
|
+
print(f"Country code {ticker} not found")
|
236
|
+
|
237
|
+
return result
|
238
|
+
|
239
|
+
|
192
240
|
#==============================================================================
|
193
241
|
if __name__ =="__main__":
|
194
242
|
ticker='CN'
|
@@ -318,7 +366,7 @@ def economy_indicator_wb(ticker='CN',indicator='NY.GDP.MKTP.KN', \
|
|
318
366
|
titletxt=titletxt+', '+unit
|
319
367
|
|
320
368
|
import datetime; todaydt = datetime.date.today()
|
321
|
-
sourcetxt=text_lang("
|
369
|
+
sourcetxt=text_lang("数据来源:WB/IMF/FRED","Data source: World Bank")
|
322
370
|
footnote=sourcetxt+', '+str(todaydt)
|
323
371
|
collabel=indicator_name
|
324
372
|
|
@@ -486,7 +534,7 @@ def economy_mindicators_wb(ticker='CN',indicator=['NY.GDP.MKTP.CN','NY.GDP.MKTP.
|
|
486
534
|
|
487
535
|
y_label=text_lang('经济指标',"Economic Indicator")
|
488
536
|
import datetime; todaydt = datetime.date.today()
|
489
|
-
footnote2=text_lang("
|
537
|
+
footnote2=text_lang("数据来源:WB/IMF/FRED","Data source: World Bank")+', '+str(todaydt)
|
490
538
|
|
491
539
|
one_unit=False
|
492
540
|
if len(set(unit_list)) == 1: one_unit=True
|
@@ -696,7 +744,7 @@ def economy_mtickers_wb(ticker=['CN','US','JP'],indicator='NY.GDP.MKTP.PP.CD', \
|
|
696
744
|
y_label=indicator_name
|
697
745
|
|
698
746
|
import datetime; todaydt = datetime.date.today()
|
699
|
-
footnote2=text_lang("
|
747
|
+
footnote2=text_lang("数据来源:WB/IMF/FRED","Data source: World Bank")+', '+str(todaydt)
|
700
748
|
|
701
749
|
one_unit=False
|
702
750
|
if len(set(unit_list)) == 1: one_unit=True
|
@@ -789,7 +837,7 @@ def economy_trend2(ticker='CN',indicator='NY.GDP.MKTP.KN', \
|
|
789
837
|
"""
|
790
838
|
功能:分析宏观经济指标,支持单国家单指标、多国家单指标、单国家多指标
|
791
839
|
主要公共参数:
|
792
|
-
ticker
|
840
|
+
ticker:国家编码,两位或三位ISO编码,默认'CN'
|
793
841
|
indicator:宏观经济指标,默认GDP (constant LCU),即本币不变价格GDP
|
794
842
|
start:开始日期,默认近十年
|
795
843
|
end:结束日期,默认当前日期
|
@@ -831,8 +879,22 @@ def economy_trend2(ticker='CN',indicator='NY.GDP.MKTP.KN', \
|
|
831
879
|
"""
|
832
880
|
# 判断ticker个数
|
833
881
|
ticker_num=0
|
834
|
-
if isinstance(ticker,str):
|
882
|
+
if isinstance(ticker,str):
|
883
|
+
ticker_num=1
|
884
|
+
ticker=ticker.upper()
|
885
|
+
if not check_country_code(ticker=ticker,show_name=False):
|
886
|
+
print(f" #Warning(economy_trend2): country code {ticker} not found")
|
887
|
+
return None
|
888
|
+
|
835
889
|
if isinstance(ticker,list):
|
890
|
+
ticker=[x.upper() for x in ticker]
|
891
|
+
for t in ticker:
|
892
|
+
if not check_country_code(ticker=t,show_name=False):
|
893
|
+
ticker.remove(t)
|
894
|
+
print(f" #Warning(economy_trend2): country code {t} not found")
|
895
|
+
if len(ticker)==0:
|
896
|
+
return None
|
897
|
+
|
836
898
|
if len(ticker)==1:
|
837
899
|
ticker_num=1
|
838
900
|
ticker=ticker[0]
|
siat/sector_china.py
CHANGED
@@ -889,9 +889,17 @@ def display_industry_sw(sw_level='1',numberPerLine=4,colalign='left'):
|
|
889
889
|
"""
|
890
890
|
按照类别打印申万行业列表,名称(代码),每行5个, 套壳函数
|
891
891
|
"""
|
892
|
-
itype_list=['1','2','3','F','S','B','C']
|
893
|
-
|
894
|
-
|
892
|
+
#itype_list=['1','2','3','F','S','B','C']
|
893
|
+
itype_list=['1','2','3','F','S','B']
|
894
|
+
#sw_level_list=['1','2','3','F','S','B','C']
|
895
|
+
sw_level_list=['1','2','3','F','S','B']
|
896
|
+
|
897
|
+
try:
|
898
|
+
pos=sw_level_list.index(sw_level)
|
899
|
+
except:
|
900
|
+
print(f" #Warning(display_industry_sw): no such level in Shenwan system {sw_level}")
|
901
|
+
print(f" Supported Shenwan system: {sw_level_list}")
|
902
|
+
|
895
903
|
itype=itype_list[pos]
|
896
904
|
|
897
905
|
print_industry_sw(itype=itype,numberPerLine=numberPerLine,colalign=colalign)
|
@@ -2884,6 +2892,7 @@ if __name__=='__main__':
|
|
2884
2892
|
|
2885
2893
|
def find_peers_china(industry='',top=20,rank=20,sw_level='2'):
|
2886
2894
|
"""
|
2895
|
+
===========================================================================
|
2887
2896
|
功能:找出一个申万行业的上市公司排名
|
2888
2897
|
主要参数:
|
2889
2898
|
industry:申万行业名称。当industry = '',显示的内容由sw_level控制。申万二级行业分类
|
@@ -3489,10 +3498,13 @@ if __name__=='__main__':
|
|
3489
3498
|
|
3490
3499
|
def find_industry_sw(ticker,level='1',ticker_order=True,max_sleep=30):
|
3491
3500
|
"""
|
3501
|
+
===========================================================================
|
3492
3502
|
功能:寻找一只或一组股票所属的申万行业,支持股票代码和股票名称。
|
3493
|
-
level='1':默认只查找申万1
|
3494
|
-
ticker_order=True:默认输出结果按照ticker
|
3495
|
-
max_sleep
|
3503
|
+
level='1':默认只查找申万1级行业;查找2/3级行业时间较久,可能触发反爬虫机制。
|
3504
|
+
ticker_order=True:默认输出结果按照ticker中的顺序,而非按照所属行业排序。
|
3505
|
+
max_sleep:为防止触发反爬虫机制,默认每次爬虫后睡眠最多30秒钟。
|
3506
|
+
|
3507
|
+
返回值:查找结果df。
|
3496
3508
|
"""
|
3497
3509
|
print(" Searching shenwan industries for securities ... ...")
|
3498
3510
|
|
@@ -3621,21 +3633,24 @@ if __name__=='__main__':
|
|
3621
3633
|
|
3622
3634
|
peers=stock_industry_peer_em(ticker,indicator="市盈率",rank=10)
|
3623
3635
|
|
3624
|
-
def stock_peers_em(ticker='',indicator='',rank=10, \
|
3636
|
+
def stock_peers_em(ticker='',indicator='市盈率',rank=10, \
|
3625
3637
|
force_show_stock=True, \
|
3626
3638
|
font_size="16px",facecolor="papayawhip", \
|
3627
3639
|
numberPerLine=5):
|
3628
3640
|
"""
|
3629
|
-
|
3630
|
-
|
3641
|
+
===========================================================================
|
3642
|
+
功能:基于东方财富行业分类,查找股票所属的行业板块以及主要同行排名。
|
3643
|
+
特点:行业分类较粗糙,略胜于无。
|
3631
3644
|
主要参数:
|
3632
|
-
ticker:股票代码,默认''
|
3633
|
-
indicator:排名指标,默认''。例如:"股价"、"流动性"、"市净率"、"市盈率"
|
3634
|
-
rank:排名数量,默认10
|
3635
|
-
force_show_stock:是否显示股票信息,默认False
|
3636
|
-
font_size:表格字体大小,默认"16px"
|
3637
|
-
facecolor:输出表格的背景颜色,默认"papayawhip"
|
3638
|
-
numberPerLine:输出表格中的每行显示个数,默认5
|
3645
|
+
ticker:股票代码,默认''显示所有板块名称。
|
3646
|
+
indicator:排名指标,默认''。例如:"股价"、"流动性"、"市净率"、"市盈率"。
|
3647
|
+
rank:排名数量,默认10前十名。
|
3648
|
+
force_show_stock:是否显示股票信息,默认False。
|
3649
|
+
font_size:表格字体大小,默认"16px"。
|
3650
|
+
facecolor:输出表格的背景颜色,默认"papayawhip"。
|
3651
|
+
numberPerLine:输出表格中的每行显示个数,默认5。
|
3652
|
+
|
3653
|
+
注意:若结果异常,可尝试升级插件akshare。
|
3639
3654
|
|
3640
3655
|
示例:
|
3641
3656
|
industries=stock_peers_em() # 显示东方财富所有行业板块分类
|
@@ -3663,6 +3678,7 @@ def stock_peers_em(ticker='',indicator='',rank=10, \
|
|
3663
3678
|
except:
|
3664
3679
|
if not ticker=='':
|
3665
3680
|
print(" #Warning(stock_peer_em): stock info not found for",ticker)
|
3681
|
+
print(" Solution: if stock code is correct, upgrade akshare and try again")
|
3666
3682
|
|
3667
3683
|
df_em=ak.stock_board_industry_name_em()
|
3668
3684
|
#df_em.sort_values(by="板块名称",ascending=True,inplace=True)
|
@@ -3725,7 +3741,8 @@ def stock_peers_em(ticker='',indicator='',rank=10, \
|
|
3725
3741
|
df_disp=cfg[collist].tail(abs(rank))
|
3726
3742
|
|
3727
3743
|
#强制显示所选股票
|
3728
|
-
if force_show_stock and rank != 10:
|
3744
|
+
#if force_show_stock and rank != 10:
|
3745
|
+
if force_show_stock:
|
3729
3746
|
#所选股票是否在其中?
|
3730
3747
|
if not ticker[:6] in list(df_disp["代码"]):
|
3731
3748
|
ticker_seq=cfg[cfg["代码"]==ticker[:6]]["序号"].values[0]
|
@@ -3780,8 +3797,22 @@ def concept_stocks_em(concept='',ticker='',indicator="市盈率",rank=10, \
|
|
3780
3797
|
force_show_stock=False, \
|
3781
3798
|
font_size="16px",facecolor="papayawhip",numberPerLine=5):
|
3782
3799
|
"""
|
3783
|
-
|
3784
|
-
|
3800
|
+
===========================================================================
|
3801
|
+
功能:基于东方财富概念板块,查找关键字相关概念以及股票业绩。
|
3802
|
+
特点:概念板块划分细致,同一股票可能分属多个板块,与行业分类不同。
|
3803
|
+
参数:
|
3804
|
+
concept:概念板块名称,或名称中的关键字,默认''输出所有概念板块名称;
|
3805
|
+
若查找到多个名称,则优先输出查找到的名称;
|
3806
|
+
若仅仅找到一个板块,则按indicator输出该板块的股票排行。
|
3807
|
+
ticker:股票代码,默认''
|
3808
|
+
indicator:指标名称,默认"市盈率",还支持:股价,市净率,涨跌幅,流动性,换手率。
|
3809
|
+
rank:排名,支持正负数,默认10。
|
3810
|
+
force_show_stock:若ticker不为空,且不在rank范围内,是否强制显示该股票,默认False。
|
3811
|
+
font_size:显示字体大小,默认"16px"。
|
3812
|
+
facecolor:表格背景颜色,默认"papayawhip"。
|
3813
|
+
numberPerLine:当显示板块名称时,每行显示个数,默认5。
|
3814
|
+
|
3815
|
+
返回值:df
|
3785
3816
|
"""
|
3786
3817
|
if indicator in ["股价","股票价格","价格","收盘价","价位"]:
|
3787
3818
|
indicator="最新价"
|
@@ -30,7 +30,7 @@ siat/cryptocurrency_test.py,sha256=3AikTNJ7j-HwLGLIYEfyXZ3bLVuLeru9mwiwHQi2SdA,2
|
|
30
30
|
siat/derivative.py,sha256=qV8n09799eqLc26ojR6vN5n_X-xd7rGwdYjgq-wBih8,41483
|
31
31
|
siat/economy-20230125.py,sha256=vxZZlPnLkh7SpGMVEPLwxjt0yYLSVmdZrO-s2NYLyoM,73848
|
32
32
|
siat/economy.py,sha256=BFVQDxOTbuizyumpCgpZIauH6sqnwUXebpqRMmQCzys,84198
|
33
|
-
siat/economy2.py,sha256=
|
33
|
+
siat/economy2.py,sha256=q9Sx_6l7jP0qkruIwdzF24O7ngAsP5EKDg928pkFGl4,39791
|
34
34
|
siat/economy_test.py,sha256=6vjNlPz7W125pJb7simCddobSEp3jmLIMvVkLRZ7zW8,13339
|
35
35
|
siat/esg.py,sha256=GMhaonIKtvOK83rhpQUH5aJt2OL3HQBSVfD__Yw-0oo,19040
|
36
36
|
siat/esg_test.py,sha256=Z9m6GUt8O7oHZSEG9aDYpGdvvrv2AiRJdHTiU6jqmZ0,2944
|
@@ -98,7 +98,7 @@ siat/risk_evaluation.py,sha256=I6B3gty-t--AkDCO0tKF-291YfpnF-IkXcFjqNKCt9I,76286
|
|
98
98
|
siat/risk_evaluation_test.py,sha256=YEXM96gKzTfwN4U61AS4Rr1tV7KgUvn4rRC6f3iMw9s,3731
|
99
99
|
siat/risk_free_rate.py,sha256=IBuRqA2kppdZsW4D4fapW7vnM5HMEXOn95A5r9Pkwlo,12384
|
100
100
|
siat/risk_free_rate_test.py,sha256=CpmhUf8aEAEZeNu4gvWP2Mz2dLoIgBX5bI41vfUBEr8,4285
|
101
|
-
siat/sector_china.py,sha256=
|
101
|
+
siat/sector_china.py,sha256=jTzHeeMjQNN-VyKZy1Sk6FwMSERKpScbgySHi5PY0QY,157031
|
102
102
|
siat/sector_china_test.py,sha256=1wq7ef8Bb_L8F0h0W6FvyBrIcBTEbrTV7hljtpj49U4,5843
|
103
103
|
siat/security_price.py,sha256=2oHskgiw41KMGfqtnA0i2YjNNV6cYgtlUK0j3YeuXWs,29185
|
104
104
|
siat/security_price2.py,sha256=dYwvz9H-uWp-Gyc1g_MId9k8cITS6ZHmjW-Fc2ypp-0,26587
|
@@ -144,8 +144,8 @@ siat/valuation_china.py,sha256=CVp1IwIsF3Om0J29RGkyxZLt4n9Ug-ua_RKhLwL9fUQ,69624
|
|
144
144
|
siat/valuation_market_china_test.py,sha256=gbJ0ioauuo4koTPH6WKUkqcXiQPafnbhU5eKJ6lpdLA,1571
|
145
145
|
siat/var_model_validation.py,sha256=R0caWnuZarrRg9939hxh3vJIIpIyPfvelYmzFNZtPbo,14910
|
146
146
|
siat/yf_name.py,sha256=laNKMTZ9hdenGX3IZ7G0a2RLBKEWtUQJFY9CWuk_fp8,24058
|
147
|
-
siat-3.8.
|
148
|
-
siat-3.8.
|
149
|
-
siat-3.8.
|
150
|
-
siat-3.8.
|
151
|
-
siat-3.8.
|
147
|
+
siat-3.8.2.dist-info/LICENSE,sha256=NTEMMROY9_4U1szoKC3N2BLHcDd_o5uTgqdVH8tbApw,1071
|
148
|
+
siat-3.8.2.dist-info/METADATA,sha256=GIZ_8Xueq4_MIj358C_7qVYbopqyujXD5ru_AFO63ik,8320
|
149
|
+
siat-3.8.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
150
|
+
siat-3.8.2.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
|
151
|
+
siat-3.8.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|