siat 3.8.25__py3-none-any.whl → 3.8.26__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 +85 -57
- {siat-3.8.25.dist-info → siat-3.8.26.dist-info}/METADATA +1 -1
- {siat-3.8.25.dist-info → siat-3.8.26.dist-info}/RECORD +6 -6
- {siat-3.8.25.dist-info → siat-3.8.26.dist-info}/LICENSE +0 -0
- {siat-3.8.25.dist-info → siat-3.8.26.dist-info}/WHEEL +0 -0
- {siat-3.8.25.dist-info → siat-3.8.26.dist-info}/top_level.txt +0 -0
siat/economy2.py
CHANGED
@@ -329,10 +329,15 @@ def economy_indicator_wb(ticker='CN',indicator='NY.GDP.MKTP.KN', \
|
|
329
329
|
pricedf.sort_index(inplace=True)
|
330
330
|
#pricedf.drop(columns='country',inplace=True)
|
331
331
|
|
332
|
+
# 若不绘图则直接返回数据,不进行数量单位变换,否则后期对比可能产生数量级不一致问题
|
333
|
+
if not graph:
|
334
|
+
return pricedf
|
335
|
+
|
332
336
|
erdf3=pricedf
|
333
337
|
|
334
338
|
# 换算数量单位
|
335
|
-
ind_max=erdf3[indicator_name].max()
|
339
|
+
ind_max=erdf3[indicator_name].max()
|
340
|
+
ind_min=erdf3[indicator_name].min()
|
336
341
|
ind_median=erdf3[indicator_name].median()
|
337
342
|
|
338
343
|
kilo=1000; million=kilo * 1000; billion=million * 1000
|
@@ -351,15 +356,16 @@ def economy_indicator_wb(ticker='CN',indicator='NY.GDP.MKTP.KN', \
|
|
351
356
|
else:
|
352
357
|
unit=''; unit_amount=1
|
353
358
|
|
354
|
-
erdf3['unit']=unit
|
359
|
+
erdf3['unit']=unit; erdf3['unit_amount']=unit_amount
|
355
360
|
|
356
361
|
if unit != '':
|
357
362
|
erdf3[indicator_name]=erdf3[indicator_name].apply(lambda x: round(x/unit_amount,2))
|
358
363
|
|
359
364
|
# 绘图
|
365
|
+
"""
|
360
366
|
if not graph:
|
361
367
|
return erdf3
|
362
|
-
|
368
|
+
"""
|
363
369
|
# 判断是否绘制零线
|
364
370
|
if ind_max * ind_min <0:
|
365
371
|
zeroline=True
|
@@ -395,12 +401,12 @@ def economy_indicator_wb(ticker='CN',indicator='NY.GDP.MKTP.KN', \
|
|
395
401
|
facecolor=facecolor,loc=loc,maxticks=30,translate=translate)
|
396
402
|
except Exception as e:
|
397
403
|
# 捕获所有异常
|
398
|
-
print(f"Error:{e}")
|
399
|
-
print("Details:")
|
404
|
+
print(f" #Error(economy_indicator_wb):{e}")
|
405
|
+
print(" Details:")
|
400
406
|
import traceback
|
401
407
|
traceback.print_exc()
|
402
408
|
|
403
|
-
return
|
409
|
+
return pricedf
|
404
410
|
|
405
411
|
|
406
412
|
#==============================================================
|
@@ -492,7 +498,7 @@ def economy_mindicators_wb(ticker='CN',indicator=['NY.GDP.MKTP.CN','NY.GDP.MKTP.
|
|
492
498
|
sys.stdout = self._original_stdout
|
493
499
|
|
494
500
|
df=pd.DataFrame(); have_data=False
|
495
|
-
indicator_list=[]
|
501
|
+
indicator_list=[]
|
496
502
|
for m in measures:
|
497
503
|
print(f" Searching indicator {m} ... ...")
|
498
504
|
|
@@ -512,9 +518,7 @@ def economy_mindicators_wb(ticker='CN',indicator=['NY.GDP.MKTP.CN','NY.GDP.MKTP.
|
|
512
518
|
have_data=True
|
513
519
|
|
514
520
|
country=dftmp['country'].values[0]
|
515
|
-
|
516
|
-
unit_list=unit_list+[unit]
|
517
|
-
dftmp.drop(columns=['country','unit'],inplace=True)
|
521
|
+
dftmp.drop(columns=['country'],inplace=True)
|
518
522
|
indicator_name=list(dftmp)[0]
|
519
523
|
|
520
524
|
if m in band_area:
|
@@ -527,7 +531,9 @@ def economy_mindicators_wb(ticker='CN',indicator=['NY.GDP.MKTP.CN','NY.GDP.MKTP.
|
|
527
531
|
else:
|
528
532
|
df=pd.merge(df,dftmp,left_index=True,right_index=True)
|
529
533
|
|
530
|
-
|
534
|
+
# 若不绘图则直接返回数据
|
535
|
+
pricedf=df.copy()
|
536
|
+
if not graph: return pricedf
|
531
537
|
|
532
538
|
if not have_data:
|
533
539
|
#print(f" #Error(economy_mindicators_wb): no record found on {indicator} for {ticker}")
|
@@ -540,25 +546,38 @@ def economy_mindicators_wb(ticker='CN',indicator=['NY.GDP.MKTP.CN','NY.GDP.MKTP.
|
|
540
546
|
import datetime; todaydt = datetime.date.today()
|
541
547
|
footnote2=text_lang("数据来源:WB/IMF/FRED","Data source: World Bank")+', '+str(todaydt)
|
542
548
|
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
if
|
548
|
-
|
549
|
+
# 处理数量级问题
|
550
|
+
max_val=min_val=0
|
551
|
+
for c in list(df):
|
552
|
+
max_tmp=df[c].max(); min_tmp=df[c].min()
|
553
|
+
if max_val < max_tmp: max_val = max_tmp
|
554
|
+
if min_val > min_tmp: min_val = min_tmp
|
555
|
+
ind_median=(max_val + min_val) / 2
|
556
|
+
|
557
|
+
kilo=1000; million=kilo * 1000; billion=million * 1000
|
558
|
+
trillion=billion * 1000; quadrillion=trillion * 1000
|
559
|
+
|
560
|
+
if ind_median > quadrillion:
|
561
|
+
unit=text_lang('单位:千万亿','in Quadrillions'); unit_amount=quadrillion
|
562
|
+
elif ind_median > trillion:
|
563
|
+
unit=text_lang('单位:万亿','in Trillions'); unit_amount=trillion
|
564
|
+
elif ind_median > billion:
|
565
|
+
unit=text_lang('单位:十亿','in Billions'); unit_amount=billion
|
566
|
+
elif ind_median > million:
|
567
|
+
unit=text_lang('单位:百万','in Millions'); unit_amount=million
|
568
|
+
elif ind_median > kilo:
|
569
|
+
unit=text_lang('单位:千','in Thousands'); unit_amount=kilo
|
549
570
|
else:
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
else:
|
559
|
-
footnote1=footnote1+'\n'
|
571
|
+
unit=''; unit_amount=1
|
572
|
+
|
573
|
+
for c in list(df):
|
574
|
+
df[c]=df[c].apply(lambda x: round(x/unit_amount,2) if x >= unit_amount else round(x/unit_amount,4))
|
575
|
+
|
576
|
+
x_label=footnote2
|
577
|
+
if unit != '':
|
578
|
+
titletxt=titletxt+', '+unit
|
560
579
|
|
561
|
-
|
580
|
+
x_label=footnote2
|
562
581
|
|
563
582
|
axhline_value=0; axhline_label=''
|
564
583
|
above_zero=0; below_zero=0
|
@@ -591,7 +610,7 @@ def economy_mindicators_wb(ticker='CN',indicator=['NY.GDP.MKTP.CN','NY.GDP.MKTP.
|
|
591
610
|
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end,facecolor=facecolor, \
|
592
611
|
band_area=band_area,loc=loc,maxticks=maxticks,translate=translate)
|
593
612
|
|
594
|
-
return
|
613
|
+
return pricedf
|
595
614
|
|
596
615
|
|
597
616
|
#==============================================================================
|
@@ -701,7 +720,7 @@ def economy_mtickers_wb(ticker=['CN','US','JP'],indicator='NY.GDP.MKTP.PP.CD', \
|
|
701
720
|
#from functools import reduce
|
702
721
|
|
703
722
|
dfs=pd.DataFrame(); have_data=False
|
704
|
-
country_list=[]
|
723
|
+
country_list=[]
|
705
724
|
for t in tickers:
|
706
725
|
print(f" Looking for {measure} info in {t} ... ...")
|
707
726
|
with HiddenPrints():
|
@@ -718,9 +737,7 @@ def economy_mtickers_wb(ticker=['CN','US','JP'],indicator='NY.GDP.MKTP.PP.CD', \
|
|
718
737
|
|
719
738
|
country=df_tmp['country'].values[0]
|
720
739
|
country_list=country_list+[country]
|
721
|
-
|
722
|
-
unit_list=unit_list+[unit]
|
723
|
-
df_tmp.drop(columns=['country','unit'],inplace=True)
|
740
|
+
df_tmp.drop(columns=['country'],inplace=True)
|
724
741
|
indicator_name=list(df_tmp)[0]
|
725
742
|
|
726
743
|
if DEBUG:
|
@@ -747,7 +764,8 @@ def economy_mtickers_wb(ticker=['CN','US','JP'],indicator='NY.GDP.MKTP.PP.CD', \
|
|
747
764
|
return None
|
748
765
|
|
749
766
|
# 若不绘图则返回原始数据
|
750
|
-
|
767
|
+
pricedf=dfs.copy()
|
768
|
+
if not graph: return pricedf
|
751
769
|
|
752
770
|
if not have_data:
|
753
771
|
#print(f" #Error(economy_mticker_wb): no record found on {indicator} for {ticker}")
|
@@ -761,22 +779,34 @@ def economy_mtickers_wb(ticker=['CN','US','JP'],indicator='NY.GDP.MKTP.PP.CD', \
|
|
761
779
|
import datetime; todaydt = datetime.date.today()
|
762
780
|
footnote2=text_lang("数据来源:WB/IMF/FRED","Data source: WB/IMF/FRED")+', '+str(todaydt)
|
763
781
|
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
782
|
+
# 处理数量级问题
|
783
|
+
max_val=min_val=0
|
784
|
+
for c in list(dfs):
|
785
|
+
max_tmp=dfs[c].max(); min_tmp=dfs[c].min()
|
786
|
+
if max_val < max_tmp: max_val = max_tmp
|
787
|
+
if min_val > min_tmp: min_val = min_tmp
|
788
|
+
ind_median=(max_val + min_val) / 2
|
789
|
+
|
790
|
+
kilo=1000; million=kilo * 1000; billion=million * 1000
|
791
|
+
trillion=billion * 1000; quadrillion=trillion * 1000
|
792
|
+
|
793
|
+
if ind_median > quadrillion:
|
794
|
+
unit=text_lang('单位:千万亿','in Quadrillions'); unit_amount=quadrillion
|
795
|
+
elif ind_median > trillion:
|
796
|
+
unit=text_lang('单位:万亿','in Trillions'); unit_amount=trillion
|
797
|
+
elif ind_median > billion:
|
798
|
+
unit=text_lang('单位:十亿','in Billions'); unit_amount=billion
|
799
|
+
elif ind_median > million:
|
800
|
+
unit=text_lang('单位:百万','in Millions'); unit_amount=million
|
801
|
+
elif ind_median > kilo:
|
802
|
+
unit=text_lang('单位:千','in Thousands'); unit_amount=kilo
|
768
803
|
else:
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
footnote1=footnote1+', '
|
776
|
-
else:
|
777
|
-
footnote1=footnote1+'\n'
|
778
|
-
|
779
|
-
x_label=footnote1+'\n'+footnote2
|
804
|
+
unit=''; unit_amount=1
|
805
|
+
|
806
|
+
for c in list(dfs):
|
807
|
+
dfs[c]=dfs[c].apply(lambda x: round(x/unit_amount,2) if x >= unit_amount else round(x/unit_amount,4))
|
808
|
+
|
809
|
+
x_label=footnote2
|
780
810
|
|
781
811
|
if preprocess == 'scaling' and scaling_option == 'change%':
|
782
812
|
title_txt2=text_lang("增减幅度%","Change%")
|
@@ -784,7 +814,7 @@ def economy_mtickers_wb(ticker=['CN','US','JP'],indicator='NY.GDP.MKTP.PP.CD', \
|
|
784
814
|
axhline_value=0
|
785
815
|
axhline_label="零线"
|
786
816
|
else:
|
787
|
-
if
|
817
|
+
if unit != '' and preprocess == 'none':
|
788
818
|
titletxt=titletxt+', '+unit
|
789
819
|
|
790
820
|
# 为避免出错,对空值进行插值
|
@@ -830,7 +860,7 @@ def economy_mtickers_wb(ticker=['CN','US','JP'],indicator='NY.GDP.MKTP.PP.CD', \
|
|
830
860
|
maxticks_enable=False,maxticks=10, \
|
831
861
|
translate=translate)
|
832
862
|
|
833
|
-
return
|
863
|
+
return pricedf
|
834
864
|
|
835
865
|
#==============================================================================
|
836
866
|
|
@@ -1129,24 +1159,22 @@ def country_translate(country):
|
|
1129
1159
|
|
1130
1160
|
['France','法国','FR','FRA'],
|
1131
1161
|
['United Kingdom','英国','GB','GBR'],
|
1132
|
-
['
|
1162
|
+
['Russian Federation','俄罗斯','RU','RUS'],
|
1133
1163
|
['Canada','加拿大','CA','CAN'],
|
1134
1164
|
['Australia','澳大利亚','AU','AUS'],
|
1135
|
-
['
|
1165
|
+
['Korea, Rep.','韩国','KR','KOR'],
|
1136
1166
|
|
1137
1167
|
['Italy','意大利','IT','ITA'],
|
1138
1168
|
['Mexico','墨西哥','MX','MEX'],
|
1139
1169
|
['South Africa','南非','ZA','ZAF'],
|
1140
1170
|
['Saudi Arabia','沙特阿拉伯','SA','SAU'],
|
1141
1171
|
['Indonesia','印度尼西亚','ID','IDN'],
|
1142
|
-
['
|
1172
|
+
['Turkiye','土耳其','TR','TUR'],
|
1143
1173
|
|
1144
1174
|
['Argentina','阿根廷','AR','ARG'],
|
1145
1175
|
['Egypt','埃及','EG','EGY'],
|
1146
1176
|
['European Union','欧盟','EU','EUU'],
|
1147
|
-
['Hong Kong','中国香港','HK','HKG'],
|
1148
|
-
['Hong Kong, China','中国香港','HK','HKG'],
|
1149
|
-
['Taiwan','中国台湾','TW','TWN'],
|
1177
|
+
['Hong Kong SAR, China','中国香港','HK','HKG'],
|
1150
1178
|
['Taiwan, China','中国台湾','TW','TWN'],
|
1151
1179
|
['World','全球','1W','WLD'],
|
1152
1180
|
|
@@ -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=N0Ak2SqTggA7IqgBX2_6KMhmAzTIbgwhHuYDwRKxg8c,49422
|
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
|
@@ -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.26.dist-info/LICENSE,sha256=NTEMMROY9_4U1szoKC3N2BLHcDd_o5uTgqdVH8tbApw,1071
|
148
|
+
siat-3.8.26.dist-info/METADATA,sha256=CUxAmvmU5B0Ey8GnKHmRZ1FSRk8gtKT8XsVATp9muws,8144
|
149
|
+
siat-3.8.26.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
150
|
+
siat-3.8.26.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
|
151
|
+
siat-3.8.26.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|