siat 3.10.125__py3-none-any.whl → 3.10.126__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.
Files changed (87) hide show
  1. siat/common.py +106 -2
  2. siat/exchange_bond_china.pickle +0 -0
  3. siat/fund_china.pickle +0 -0
  4. siat/stock.py +10 -2
  5. siat/stock_info.pickle +0 -0
  6. {siat-3.10.125.dist-info → siat-3.10.126.dist-info}/METADATA +234 -226
  7. siat-3.10.126.dist-info/RECORD +76 -0
  8. {siat-3.10.125.dist-info → siat-3.10.126.dist-info}/WHEEL +1 -1
  9. {siat-3.10.125.dist-info → siat-3.10.126.dist-info/licenses}/LICENSE +0 -0
  10. {siat-3.10.125.dist-info → siat-3.10.126.dist-info}/top_level.txt +0 -0
  11. siat/__init__ -20240701.py +0 -65
  12. siat/__init__.py.backup_20250214.py +0 -73
  13. siat/alpha_vantage_test.py +0 -24
  14. siat/assets_liquidity_test.py +0 -44
  15. siat/barrons_scraping_test.py +0 -276
  16. siat/beta_adjustment_test.py +0 -77
  17. siat/bond_test.py +0 -142
  18. siat/capm_beta_test.py +0 -49
  19. siat/cmat_commons.py +0 -961
  20. siat/compare_cross_test.py +0 -117
  21. siat/concepts_iwencai.py +0 -86
  22. siat/concepts_kpl.py +0 -93
  23. siat/cryptocurrency_test.py +0 -71
  24. siat/derivative.py +0 -1111
  25. siat/economy-20230125.py +0 -1206
  26. siat/economy_test.py +0 -360
  27. siat/esg_test.py +0 -63
  28. siat/fama_french_test.py +0 -115
  29. siat/financial_statements_test.py +0 -31
  30. siat/financials2 - /321/205/320/231/320/277/321/206/320/254/320/274.py" +0 -341
  31. siat/financials_china2_test.py +0 -67
  32. siat/financials_china2_test2.py +0 -88
  33. siat/financials_china2_test3.py +0 -87
  34. siat/financials_china_test.py +0 -475
  35. siat/financials_china_test2.py +0 -197
  36. siat/financials_china_test2_fin_indicator.py +0 -197
  37. siat/financials_test.py +0 -713
  38. siat/fred_test.py +0 -40
  39. siat/fund_china_test.py +0 -175
  40. siat/fund_test.py +0 -40
  41. siat/future_china_test.py +0 -37
  42. siat/global_index_test.py +0 -66
  43. siat/grafix_test.py +0 -112
  44. siat/holding_risk_test.py +0 -13
  45. siat/local_debug_test.py +0 -100
  46. siat/markowitz2-20240620.py +0 -2614
  47. siat/markowitz_ccb_test.py +0 -37
  48. siat/markowitz_ef_test.py +0 -136
  49. siat/markowitz_old.py +0 -871
  50. siat/markowitz_simple-20230709.py +0 -370
  51. siat/markowitz_test.py +0 -164
  52. siat/markowitz_test2.py +0 -69
  53. siat/ml_cases_example1.py +0 -60
  54. siat/option_china_test.py +0 -447
  55. siat/option_pricing_test.py +0 -81
  56. siat/option_sina_api_test.py +0 -112
  57. siat/proxy_test.py +0 -84
  58. siat/quandl_test.py +0 -39
  59. siat/risk_adjusted_return_test.py +0 -81
  60. siat/risk_evaluation_test.py +0 -96
  61. siat/risk_free_rate_test.py +0 -127
  62. siat/sector_china_test.py +0 -203
  63. siat/security_price.py +0 -831
  64. siat/security_prices_test.py +0 -310
  65. siat/security_trend2-20240620.py +0 -493
  66. siat/setup.py +0 -41
  67. siat/shenwan index history test.py +0 -41
  68. siat/stock_china_test.py +0 -38
  69. siat/stock_info_test.py +0 -189
  70. siat/stock_list_china_test.py +0 -33
  71. siat/stock_technical-20240620.py +0 -2736
  72. siat/stock_test.py +0 -487
  73. siat/temp.py +0 -36
  74. siat/test2_graphviz.py +0 -484
  75. siat/test_graphviz.py +0 -411
  76. siat/test_markowitz_simple.py +0 -198
  77. siat/test_markowitz_simple_revised.py +0 -215
  78. siat/test_markowitz_simple_revised2.py +0 -218
  79. siat/transaction_test.py +0 -436
  80. siat/translate-20230125.py +0 -2107
  81. siat/translate-20230206.py +0 -2109
  82. siat/translate-20230215.py +0 -2158
  83. siat/translate_20240606.py +0 -4206
  84. siat/translate_241003_keep.py +0 -4300
  85. siat/universal_test.py +0 -100
  86. siat/valuation_market_china_test.py +0 -36
  87. siat-3.10.125.dist-info/RECORD +0 -152
siat/economy-20230125.py DELETED
@@ -1,1206 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """
3
- 本模块功能:宏观经济基本面分析
4
- 所属工具包:证券投资分析工具SIAT
5
- SIAT:Security Investment Analysis Tool
6
- 创建日期:2020年8月31日
7
- 最新修订日期:2020年8月31日
8
- 作者:王德宏 (WANG Dehong, Peter)
9
- 作者单位:北京外国语大学国际商学院
10
- 版权所有:王德宏
11
- 用途限制:仅限研究与教学使用,不可商用!商用需要额外授权。
12
- 特别声明:作者不对使用本工具进行证券投资导致的任何损益负责!
13
- """
14
- #==============================================================================
15
- #关闭所有警告
16
- import warnings; warnings.filterwarnings('ignore')
17
- from siat.grafix import *
18
- from siat.common import *
19
- from siat.translate import *
20
- #==============================================================================
21
- if __name__=='__main__':
22
- start='2010-1-1'; end='2020-12-31'
23
- scope='China'; factor='Constant GDP'
24
-
25
-
26
- def get_econ_factors(start,end,scope='China',factor='GDP'):
27
- """
28
- 与函数get_econ_factors0的区别:
29
- 1、将GNP替换为GNI
30
- 2、将GNP Ratio替换为GNI Ration
31
- 3、新增Currency Value,货币价值,衡量货币贬值速度
32
- """
33
-
34
- #替换GNP为GNI
35
- if factor == 'GNP':
36
- factor='GNI'
37
- ds=get_econ_factors0(start,end,scope,factor)
38
- return ds
39
-
40
- #替换GNP Ratio为GNI Ratio
41
- if factor in ['GNP Ratio','GNI Ratio']:
42
- ds_gni=get_econ_factors0(start,end,scope,'GNI')
43
- if ds_gni is None:
44
- print(" #Error(get_econ_factors): info not found for",scope,'GNI')
45
- return None
46
-
47
- import pandas as pd
48
- ds_gni1=pd.DataFrame(ds_gni['VALUE'])
49
-
50
- ds_gdp=get_econ_factors0(start,end,scope,'GDP')
51
- if ds_gdp is None: return None
52
-
53
- ds_gdp1=pd.DataFrame(ds_gdp['VALUE'])
54
-
55
- ds1=pd.merge(ds_gni1,ds_gdp1,how='inner',left_index=True,right_index=True)
56
- ds1.dropna(inplace=True)
57
- ds1['VALUE']=ds1['VALUE_x']/ds1['VALUE_y']
58
- ds2=ds1.drop(['VALUE_x','VALUE_y'],axis=1)
59
-
60
- ds_gdp2=ds_gdp.drop('VALUE',axis=1)
61
- ds_gdp2['factor']='GNI Ratio'
62
- ds_gdp2['name']='GNI/GDP Ratio'
63
- ds_gdp2['symbol']='CUSTOMIZED'
64
-
65
- ds3=pd.merge(ds2,ds_gdp2,how='inner',left_index=True,right_index=True)
66
-
67
- return ds3
68
-
69
- #新增Currency Value
70
- if factor in ['Currency Value']:
71
- cv=get_econ_factors0(start,end,scope,'Constant CPI')
72
- if cv is None:
73
- print(" #Error(get_econ_factors): info not found for",scope,'Constant CPI')
74
- return None
75
-
76
- cv['CV']=(100.0/cv['VALUE'])*100.0
77
- cv1=cv.rename(columns={'VALUE':'Constant CPI'})
78
- cv2=cv1.rename(columns={'CV':'VALUE'})
79
-
80
- cv2['factor']='Currency Value'
81
- cv2['name']='Currency Purchasing Power Based on CPI'
82
-
83
- return cv2
84
-
85
- #其他正常情况
86
- df=get_econ_factors0(start,end,scope=scope,factor=factor)
87
-
88
- return df
89
-
90
- #==============================================================================
91
- def get_econ_factors0(start,end,scope='China',factor='GDP'):
92
- """
93
- 【支持的因子种类(factor)】
94
- GDP, CPI, PPI,...
95
-
96
- 【支持的国家/地区(scope)】
97
- US: 美国
98
- China: 中国
99
- Korea: 韩国
100
- Japan: 日本
101
- India: 印度
102
-
103
- 【支持的取样频率(freq)】
104
- Annual: 年
105
- Quarterly: 季度
106
- Monthly: 月
107
- """
108
- s=fred_factor_codes()
109
-
110
- #帮助1:国家列表
111
- if scope=='?':
112
- scopelist=list(set(list(s[s['factor']==factor]['scope'])))
113
- if len(scopelist)==0:
114
- print(" #Error(get_econ_factors0): no such economy factor,",factor)
115
- else:
116
- title="\n*** Supported scopes for factor, "+factor+':'
117
- print(title)
118
- linelen=0
119
- for i in range(len(scopelist)):
120
- print(scopelist[i],end='')
121
- linelen=linelen+len(scopelist[i])+2
122
- if (linelen >= len(title)-2):
123
- print(''); linelen=0
124
- else:
125
- if (i+1) < len(scopelist):
126
- print(', ',end='')
127
- else:
128
- print('')
129
- return None
130
-
131
- #帮助2:经济指标
132
- if (scope != '?') and (factor=='?'):
133
- factorlist=list(set(list(s[s['scope']==scope]['factor'])))
134
- if len(factorlist)==0:
135
- print(" #Error(get_econ_factors0): no or unavailable country/region,",scope)
136
- else:
137
- title="\n*** Supported factors for scope, "+scope+':'
138
- print(title)
139
- linelen=0
140
- for i in range(len(factorlist)):
141
- print(factorlist[i],end='')
142
- linelen=linelen+len(factorlist[i])+2
143
- if (linelen >= len(title)-2):
144
- print(''); linelen=0
145
- else:
146
- if (i+1) < len(factorlist):
147
- print(', ',end='')
148
- else:
149
- print('')
150
- return None
151
-
152
- #匹配:scope+factor+freq
153
- ss=s[s['scope'].isin([scope]) & s['factor'].isin([factor])]
154
- #如果未找到匹配的模式,显示信息后返回
155
- if len(ss)==0:
156
- print(" #Error(get_econ_factors0): info are not available for",scope,factor)
157
- return None
158
-
159
- #取出对应的关键字symbol
160
- symbol=list(ss['symbol'])[0]
161
-
162
- #按照关键字抓取数据
163
- import pandas_datareader as web
164
- try:
165
- ds=web.get_data_fred(symbol,start,end)
166
- except:
167
- print(" #Error(get_econ_factors0): connection to data source failed!")
168
- return None
169
- if len(ds)==0:
170
- print(" #Error(get_econ_factors0): server returned empty data!")
171
- return None
172
- # 结果字段统一改名
173
- ds.columns=['VALUE']
174
- ds['scope']=list(ss['scope'])[0]
175
- ds['factor']=list(ss['factor'])[0]
176
- ds['freq']=list(ss['freq'])[0]
177
- ds['name']=list(ss['name'])[0]
178
- ds['symbol']=list(ss['symbol'])[0]
179
- ds['units']=list(ss['units'])[0]
180
-
181
- return ds
182
-
183
- if __name__=='__main__':
184
- start='2010-1-1'; end='2020-8-31'
185
- scope='China'; factor='Real GDP Per Capita'
186
-
187
- ds1=get_econ_factors('2010-1-1','2020-8-31','China','GDP')
188
- ds2=get_econ_factors('2010-1-1','2020-8-31','China','Real GDP')
189
- ds3=get_econ_factors('2010-1-1','2020-8-31','India','Constant GDP')
190
- get_econ_factors('2010-1-1','2020-8-31','?','Constant GDP')
191
- get_econ_factors('2010-1-1','2020-8-31','China','?')
192
- #==============================================================================
193
- def economy_trend(start,end,scope='China',factor='GDP',datatag=False,power=3,zeroline=False):
194
- """
195
- 功能:绘制宏观经济指标,单线,有趋势线
196
- """
197
- #检查日期期间的合理性
198
- valid,_,_=check_period(start,end)
199
- if not valid:
200
- print(' Error(trend_economy): period not valid:',start,end)
201
- return
202
-
203
- #获取指标
204
- ds=get_econ_factors(start,end,scope,factor)
205
- if (ds is None):
206
- print(' #Error(economy_trend): scope/economic factor not available:',scope,'/',factor)
207
- return
208
-
209
- #绘图
210
- ylabeltxt=ectranslate(factor)
211
- titletxt=ectranslate(list(ds['name'])[0])+'的趋势:'+ectranslate(scope)
212
-
213
- import datetime
214
- today=datetime.date.today()
215
- footnote='单位: '+list(ds['units'])[0]+', '+list(ds['freq'])[0]+ \
216
- '\n数据来源: OECD|IMF|WB|FRED, '+str(today)
217
- ds.dropna(inplace=True)
218
- plot_line(ds,'VALUE',ectranslate(factor),ylabeltxt,titletxt,footnote,datatag,power=power,zeroline=zeroline)
219
-
220
- return ds
221
-
222
-
223
- if __name__=='__main__':
224
- start='2010-1-1'; end='2020-8-31'
225
- scope='USA'; factor='Real GDP Per Capita'
226
-
227
- ds=economy_trend(start,end,scope='China',factor='GDP')
228
- ds=economy_trend(start,end,scope='Japan',factor='Real GDP')
229
-
230
- #==============================================================================
231
- if __name__=='__main__':
232
- tickers=['China','USA']
233
- measures='M2 GoB'
234
- fromdate='1999-12-1'
235
- todate='2022-4-1'
236
- power=0; twinx=False; loc1='upper left'; loc2='lower right'
237
-
238
-
239
- def compare_economy(tickers,measures,fromdate,todate,power=0,twinx=False, \
240
- loc1='upper left',loc2='lower right'):
241
- """
242
- 功能:对比绘制折线图:一个国家的两种测度,或两个国家的同一个测度。
243
- 输入:
244
- 国家代码tickers,如果是一个列表且内含两个代码,则认为希望比较两个国家的
245
- 同一个测度指标。如果是一个列表但只内含一个国家代码或只是一个国家代码的字符串,
246
- 则认为希望比较一个国家的两个测度指标。
247
- 测度指标measures:如果是一个列表且内含两个测度指标,则认为希望比较一个国家的
248
- 两个测度指标。如果是一个列表但只内含一个测度指标或只是一个测度指标的字符串,
249
- 则认为希望比较两个国家的同一个测度指标。
250
- 如果两个判断互相矛盾,以第一个为准。
251
- 开始日期fromdate,结束日期todate。
252
- 输出:绘制经济指标折线图,手动指定是否使用单轴或双轴坐标。
253
- 返回:无
254
- """
255
- #检查日期期间的合理性
256
- valid,_,_=check_period(fromdate,todate)
257
- if not valid:
258
- print(' #Error(compare_economy): period not valid:',fromdate,todate)
259
- return
260
-
261
- #判断国家代码个数
262
- #如果tickers只是一个字符串
263
- security_num = 0
264
- if isinstance(tickers,str):
265
- security_num = 1
266
- ticker1 = tickers
267
- #如果tickers是一个列表
268
- if isinstance(tickers,list):
269
- security_num = len(tickers)
270
- if security_num == 0:
271
- print(" #Error(compare_economy): lack of country(s) for comparison")
272
- return
273
- if security_num >= 1: ticker1 = tickers[0]
274
- if security_num >= 2: ticker2 = tickers[1]
275
-
276
- #判断测度个数
277
- #如果measures只是一个字符串
278
- measure_num = 0
279
- if isinstance(measures,str):
280
- measure_num = 1
281
- measure1 = measures
282
- #如果measures是一个列表
283
- if isinstance(measures,list):
284
- measure_num = len(measures)
285
- if measure_num == 0:
286
- print(" #Error(compare_economy): lack of measure(s)")
287
- return
288
- if measure_num >= 1: measure1 = measures[0]
289
- if measure_num >= 2: measure2 = measures[1]
290
-
291
- import datetime; today=datetime.date.today()
292
- lang=check_language()
293
- if lang == 'English':
294
- source_txt='\nSource: OECD|IMF|WB|FRED, '
295
- addstr_txt='Starting date as benchmark 100\n'
296
- unit_txt='Notes: '
297
- else:
298
- source_txt='\n数据来源: OECD|IMF|WB|FRED, '
299
- addstr_txt='开始时点作为基数100\n'
300
- unit_txt='单位: '
301
-
302
- #是否单一国家代码+两个测度指标
303
- if (security_num == 1) and (measure_num >= 2):
304
- #国家ticker1:抓取经济指标measure1
305
- result,measure1new=separate_measure(measure1,'Constant')
306
- """
307
- df1=get_econ_factors(fromdate,todate,ticker1,measure1new)
308
- """
309
- df1=get_econ_factors(fromdate,todate,ticker1,measure1)
310
-
311
- if df1 is None: return None, None
312
-
313
- #求GoB增速指标
314
- if result:
315
- df1.rename(columns={'VALUE':'VALUE0'}, inplace = True)
316
- comparend=df1.head(1)['VALUE0'][0]
317
- df1['VALUE']=df1['VALUE0']/comparend*100
318
-
319
- #国家ticker1:抓取经济指标measure2
320
- result,measure2new=separate_measure(measure2,'Constant')
321
- """
322
- df2=get_econ_factors(fromdate,todate,ticker1,measure2new)
323
- """
324
- df2=get_econ_factors(fromdate,todate,ticker1,measure2)
325
-
326
- if df2 is None: return None, None
327
-
328
- #求GoB增速指标
329
- if result:
330
- df2.rename(columns={'VALUE':'VALUE0'}, inplace = True)
331
- comparend=df2.head(1)['VALUE0'][0]
332
- df2['VALUE']=df2['VALUE0']/comparend*100
333
-
334
- #绘制单个国家的双指标对比图
335
- ylabeltxt=''
336
- titletxt=ectranslate(measure1)+' vs '+ectranslate(measure2)+ \
337
- '\n('+ectranslate(ticker1)+')'
338
-
339
- if result:
340
- addstr=addstr_txt
341
- else:
342
- addstr=''
343
- footnote=addstr+ectranslate(measure1)+': '+list(df1['units'])[0]+', '+list(df1['freq'])[0]+ \
344
- '\n'+ectranslate(measure2)+': '+list(df2['units'])[0]+', '+list(df2['freq'])[0]+ \
345
- source_txt+str(today)
346
-
347
- if lang == 'Chinese':
348
- plot_line2(df1,ectranslate(ticker1),'VALUE',ectranslate(measure1), \
349
- df2,ectranslate(ticker1),'VALUE',ectranslate(measure2), \
350
- ylabeltxt,titletxt,footnote, \
351
- power=power,twinx=twinx,loc1=loc1,loc2=loc2)
352
- else:
353
- plot_line2(df1,ticker1,'VALUE',measure1, \
354
- df2,ticker1,'VALUE',measure2, \
355
- ylabeltxt,titletxt,footnote, \
356
- power=power,twinx=twinx,loc1=loc1,loc2=loc2)
357
-
358
- elif (security_num >= 2) and (measure_num >= 1):
359
- #双国家+单个测度指标
360
- #国家ticker1:抓取经济指标measure1
361
- result,measure1new=separate_measure(measure1,'Constant')
362
- """
363
- df1=get_econ_factors(fromdate,todate,ticker1,measure1new)
364
- """
365
- df1=get_econ_factors(fromdate,todate,ticker1,measure1)
366
-
367
- if df1 is None: return None, None
368
-
369
- #求GoB增速指标
370
- if result:
371
- df1.rename(columns={'VALUE':'VALUE0'}, inplace = True)
372
- comparend=df1.head(1)['VALUE0'][0]
373
- df1['VALUE']=df1['VALUE0']/comparend*100
374
-
375
- #国家ticker2:抓取经济指标measure1
376
- """
377
- df2=get_econ_factors(fromdate,todate,ticker2,measure1new)
378
- """
379
- df2=get_econ_factors(fromdate,todate,ticker2,measure1)
380
-
381
- if df2 is None: return None, None
382
-
383
- #求GoB增速指标
384
- if result:
385
- df2.rename(columns={'VALUE':'VALUE0'}, inplace = True)
386
- comparend=df2.head(1)['VALUE0'][0]
387
- df2['VALUE']=df2['VALUE0']/comparend*100
388
-
389
- #绘制双国家单指标对比图
390
- ylabeltxt=ectranslate(measure1)
391
- #这里的GNP指标实际上是GNP vs GDP的百分比
392
- yline=999 #默认不绘制水平线
393
- if measure1 in ['GNP Ratio','GNI Ratio']:
394
- ylabeltxt='GNP(GNI)/GDP'
395
- yline=1 #绘制y=1的水平线
396
- if measure1 in ['Currency Value','Constant CPI']:
397
- ylabeltxt=ectranslate(measure1)
398
- yline=100 #绘制y=100的水平线
399
-
400
- if lang == 'Chinese':
401
- titletxt=ectranslate(list(df1['name'])[0])+'趋势对比:'+ \
402
- '\n'+ectranslate(ticker1)+' vs '+ectranslate(ticker2)
403
- else:
404
- titletxt=list(df1['name'])[0]+', Trend Comparison'+ \
405
- '\n'+ticker1+' vs '+ticker2
406
-
407
- if result:
408
- addstr=addstr_txt
409
- else:
410
- addstr=''
411
- footnote=addstr+unit_txt+list(df1['units'])[0]+', '+list(df1['freq'])[0]+ \
412
- source_txt+str(today)
413
-
414
- if lang == 'Chinese':
415
- plot_line2(df1,ectranslate(ticker1),'VALUE',ectranslate(measure1), \
416
- df2,ectranslate(ticker2),'VALUE',ectranslate(measure1), \
417
- ylabeltxt,titletxt,footnote, \
418
- power=power,twinx=twinx,yline=yline,loc1=loc1,loc2=loc2)
419
- else:
420
- plot_line2(df1,ticker1,'VALUE',measure1, \
421
- df2,ticker2,'VALUE',measure1, \
422
- ylabeltxt,titletxt,footnote, \
423
- power=power,twinx=twinx,yline=yline,loc1=loc1,loc2=loc2)
424
-
425
- else:
426
- print(" #Error(compare_economy): no idea on what to compare")
427
- return None,None
428
-
429
- return df1,df2
430
-
431
- if __name__ =="__main__":
432
- tickers=['China','India']
433
- measures='GDP'
434
- fromdate='2010-1-1'
435
- todate='2020-8-31'
436
-
437
- df=compare_economy(tickers,measures,fromdate,todate)
438
- df=compare_economy(tickers,measures,fromdate,todate,twinx=True)
439
-
440
- df=compare_economy(tickers,'GDP Per Capita',fromdate,todate)
441
- df=compare_economy(tickers,'GDP Per Capita',fromdate,todate,twinx=True)
442
-
443
- df=compare_economy('India',['Real GDP','Real GDP Per Capita'],fromdate,todate,twinx=True)
444
- df=compare_economy('Japan',['Real GDP','Real GDP Per Capita'],fromdate,todate,twinx=True)
445
- df=compare_economy('Israel',['Real GDP','Real GDP Per Capita'],fromdate,todate,twinx=True)
446
-
447
- #==============================================================================
448
- if __name__ =="__main__":
449
- measure='M2 MoM'
450
- measure_type='MoM'
451
- separate_measure(measure,measure_type)
452
-
453
- measure='M2'
454
- measure_type='MoM'
455
- separate_measure(measure,measure_type)
456
-
457
- def separate_measure(measure,measure_type):
458
- """
459
- 功能:若measure字符串含有子串measure_type,则返回True,并分离出第一个空格前的子串返回
460
- 否则返回False和原measure
461
- 例如:对于"M2 MoM"返回True和"M2"
462
- """
463
- if measure_type in measure:
464
- pos=measure.index(' ')
465
- new_measure=measure[pos+1:]
466
- return True,new_measure
467
-
468
- return False,measure
469
-
470
-
471
- #==============================================================================
472
- def econ_fin_depth(fromdate,todate,scope,power=0,graph=True):
473
- """
474
- 功能:经济的金融化深度,一个国家
475
- """
476
- #检查日期期间的合理性
477
- valid,_,_=check_period(fromdate,todate)
478
- if not valid:
479
- print(' Error(econ_fin_depth): period not valid:',fromdate,todate)
480
- return None
481
-
482
- #获取GDP,按季度,本币
483
- gdp_qtr=get_econ_factors(fromdate,todate,scope,'Constant GDP')
484
- gdp_qtr['date']=gdp_qtr.index.date
485
- datecvt=lambda x: str(x)[0:4]
486
- gdp_qtr['date_str']=gdp_qtr['date'].apply(datecvt)
487
-
488
- import numpy as np
489
- gdp_annual=gdp_qtr.groupby(['date_str'])['VALUE'].agg(['count',np.sum])
490
- gdp_annual2=gdp_annual[gdp_annual['count']==4]
491
-
492
- #获取M2,按月,本币
493
- m2_mth=get_econ_factors(fromdate,todate,scope,'M2')
494
- m2_mth['date']=m2_mth.index.date
495
- datecvt=lambda x: str(x)[0:4]
496
- m2_mth['date_str']=m2_mth['date'].apply(datecvt)
497
-
498
- m2_annual=m2_mth.groupby(['date_str'])['VALUE'].agg(['count',np.sum])
499
- m2_annual2=m2_annual[m2_annual['count']==12]
500
-
501
- #合并
502
- import pandas as pd
503
- m2_gdp=pd.merge(m2_annual2,gdp_annual2,on='date_str')
504
- m2_gdp.dropna(inplace=True)
505
- m2_gdp['m2/gdp']=m2_gdp['sum_x']/m2_gdp['sum_y']
506
-
507
- df=m2_gdp[['m2/gdp']]
508
-
509
- #绘图
510
- if not graph: return df
511
- colname='m2/gdp'
512
- collabel="经济的金融深度"
513
- ylabeltxt="M2/GDP比例"
514
- titletxt=ectranslate(scope)+': 经济的金融深度'
515
- footnote="数据来源: OECD|IMF|WB|FRED"
516
- plot_line(df,colname,collabel,ylabeltxt,titletxt,footnote,power=power)
517
-
518
- return df
519
-
520
- if __name__=='__main__':
521
- fromdate='2000-1-1'; todate='2020-8-31'
522
- scope="China"
523
- cn=econ_fin_depth(fromdate,todate,scope,power=4)
524
- print(min(cn['m2/gdp']),max(cn['m2/gdp']))
525
- print(cn)
526
- jp=econ_fin_depth(fromdate,todate,'Japan',power=0)
527
- us=econ_fin_depth(fromdate,todate,'USA',power=0)
528
- kr=econ_fin_depth(fromdate,todate,'Korea',power=0)
529
-
530
- #==============================================================================
531
- def compare_efd(fromdate,todate,scopelist,power=0):
532
- """
533
- 功能:比较经济的金融化深度,两个国家
534
- """
535
- #检查日期期间的合理性
536
- valid,_,_=check_period(fromdate,todate)
537
- if not valid:
538
- print(' Error(econ_fin_depth): period not valid:',fromdate,todate)
539
- return None,None
540
-
541
- #检查国家列表
542
- if isinstance(scopelist,list):
543
- if len(scopelist) < 2:
544
- print(" Error(compare_efd): need a list with 2 countries",scopelist)
545
- return None,None
546
- scope1 = scopelist[0]; scope2 = scopelist[1]
547
- else:
548
- print(" Error(compare_efd): need a list with 2 countries",scopelist)
549
- return None,None
550
-
551
- #计算scope1/2的efd。美国的M2指标单位是Billions Dollars
552
- df1=econ_fin_depth(fromdate,todate,scope1,graph=False)
553
- if scope1=='USA':
554
- df1['m2/gdp']=df1['m2/gdp']*1000000000.0
555
- df2=econ_fin_depth(fromdate,todate,scope2,graph=False)
556
- if scope2=='USA':
557
- df2['m2/gdp']=df2['m2/gdp']*1000000000.0
558
-
559
- #绘图
560
- ticker1=scope1; ticker2=scope2
561
- colname1='m2/gdp'; colname2='m2/gdp'
562
- label1="M2/GDP"; label2="M2/GDP"
563
- ylabeltxt="M2/GDP比例"
564
- titletxt='经济金融深度趋势对比'+'\n'+ectranslate(scope1)+' vs '+ectranslate(scope2)
565
-
566
- import datetime
567
- today=datetime.date.today()
568
- footnote="数据来源:IMF/FRED,"+str(today)
569
- plot_line2(df1,ectranslate(ticker1),colname1,label1, \
570
- df2,ectranslate(ticker2),colname2,label2, \
571
- ylabeltxt,titletxt,footnote, \
572
- power=power)
573
- return df1,df2
574
-
575
- if __name__=='__main__':
576
- fromdate='2000-1-1'; todate='2020-8-31'
577
- scopelist=["China","Japan"]
578
- power=4
579
- cn,us=compare_efd(fromdate,todate,['China','USA'])
580
- cn,jp=compare_efd(fromdate,todate,['China','Japan'])
581
- cn,kr=compare_efd(fromdate,todate,['China','Korea'])
582
-
583
- #==============================================================================
584
- def economy_security(scope,fromdate,todate,econ_factor,sec_ticker,loc1='upper left',loc2='lower right'):
585
- """
586
- 功能:比较宏观经济与证券市场之间的关联关系
587
- scope: 国家/地区
588
- econ_factor: 例如GDP
589
- sec_ticker: 例如标普500指数、道琼斯指数、上证综合指数
590
- 输出: df
591
- """
592
- #检查日期期间的合理性
593
- valid,_,_=check_period(fromdate,todate)
594
- if not valid:
595
- print(' Error(economy_security): period not valid:',fromdate,todate)
596
- return None,None
597
-
598
- #获得econ_factor
599
- econ=get_econ_factors(fromdate,todate,scope,econ_factor)
600
- if econ is None:
601
- print(' Error(economy_security): scope/economic factor not available:',scope,econ_factor)
602
- return None,None
603
- econ_growth='Growth %'
604
- econ[econ_growth]=econ['VALUE'].pct_change()*100.0
605
-
606
- #获得sec_ticker行情
607
- import siat.security_prices as ssp
608
- sec=ssp.get_price(sec_ticker,fromdate,todate)
609
- if sec is None:
610
- print(' Error(economy_security): ticker info not available:',sec_ticker)
611
- return None,None
612
-
613
- #绘图1: 直接指标,双轴
614
- econ_min1,econ_max1=get_df_period(econ)
615
- sec_min1,sec_max1=get_df_period(sec)
616
- min1=max(econ_min1,sec_min1)
617
- max1=min(econ_max1,sec_max1)
618
- econ1=set_df_period(econ,min1,max1)
619
- sec1=set_df_period(sec,min1,max1)
620
-
621
- df1=econ1; ticker1=econ_factor; colname1='VALUE'; label1=econ_factor
622
- df2=sec1; ticker2=sec_ticker; colname2='Close'; label2=sec_ticker
623
- ylabeltxt=''
624
- titletxt=ectranslate(scope)+": 宏观经济与证券市场的关系"
625
- footnote="数据来源: FRED|Yahoo Finance"
626
- plot_line2(df1,ectranslate(ticker1),colname1,label1, \
627
- df2,ectranslate(ticker2),colname2,label2, \
628
- ylabeltxt,titletxt,footnote, \
629
- power=0,twinx=True,loc1=loc1,loc2=loc2)
630
-
631
- #绘图2: 增长指标,双轴
632
- econ2=econ.dropna()
633
- econ_min1,econ_max1=get_df_period(econ2)
634
- sec_min1,sec_max1=get_df_period(sec)
635
- min1=max(econ_min1,sec_min1)
636
- max1=min(econ_max1,sec_max1)
637
- econ3=set_df_period(econ,min1,max1)
638
- sec3=set_df_period(sec,min1,max1)
639
- df1=econ3; df2=sec3
640
-
641
- colname1=econ_growth
642
- #label1=econ_growth
643
- label1="增长率%"
644
- titletxt=ectranslate(scope)+": 经济增长与证券市场的关系"
645
- plot_line2(df1,ectranslate(ticker1),colname1,label1, \
646
- df2,ectranslate(ticker2),colname2,label2, \
647
- ylabeltxt,titletxt,footnote, \
648
- power=0,twinx=True,loc1=loc1,loc2=loc2)
649
- return econ,sec
650
-
651
- if __name__=='__main__':
652
- fromdate='2010-1-1'; todate='2019-12-31'
653
- scope='China'; econ_factor='GDP'; sec_ticker='000001.SS'
654
-
655
- df_cn1=economy_security('China','1995-1-1','2019-12-31','GDP Per Capita','000001.SS')
656
- df_cn2=economy_security('China','1995-1-1','2019-12-31','CNP GDP','000001.SS')
657
- df_us1=economy_security('USA','1980-1-1','2019-12-31','GDP','^DJI')
658
- df_us2=economy_security('USA','1980-1-1','2019-12-31','GDP','^GSPC')
659
- #==============================================================================
660
- def get_df_period(df):
661
- """
662
- 功能: 获得df中日期索引的最小最大值
663
- """
664
- df_min=min(df.index)
665
- df_max=max(df.index)
666
- return df_min,df_max
667
-
668
- if __name__=='__main__':
669
- import siat.security_prices as ssp
670
- df=ssp.get_price('AAPL','2020-1-1','2020-1-31')
671
- get_df_period(df)
672
-
673
-
674
- #==============================================================================
675
- #==============================================================================
676
- #==============================================================================
677
-
678
- def fred_factor_codes():
679
- import pandas as pd
680
- s=pd.DataFrame([
681
- # GDP:年度指标,美元现价,未经季节性调整。未扣除通胀因素,含有汇率变化因素
682
- ['China','GDP','Annual','Gross Domestic Product','MKTGDPCNA646NWDB','Current USD, Not Seasonally Adjusted'],
683
- ['USA','GDP','Annual','Gross Domestic Product','MKTGDPUSA646NWDB','Current USD, Not Seasonally Adjusted'],
684
- ['Japan','GDP','Annual','Gross Domestic Product','MKTGDPJPA646NWDB','Current USD, Not Seasonally Adjusted'],
685
- ['India','GDP','Annual','Gross Domestic Product','MKTGDPINA646NWDB','Current USD, Not Seasonally Adjusted'],
686
- ['Korea','GDP','Annual','Gross Domestic Product','MKTGDPKRA646NWDB','Current USD, Not Seasonally Adjusted'],
687
- ['Russia','GDP','Annual','Gross Domestic Product','MKTGDPRUA646NWDB','Current USD, Not Seasonally Adjusted'],
688
- ['Singapore','GDP','Annual','Gross Domestic Product','MKTGDPSGA646NWDB','Current USD, Not Seasonally Adjusted'],
689
- ['Malaysia','GDP','Annual','Gross Domestic Product','MKTGDPMYA646NWDB','Current USD, Not Seasonally Adjusted'],
690
- ['Indonesia','GDP','Annual','Gross Domestic Product','MKTGDPIDA646NWDB','Current USD, Not Seasonally Adjusted'],
691
- ['Vietnam','GDP','Annual','Gross Domestic Product','MKTGDPVNA646NWDB','Current USD, Not Seasonally Adjusted'],
692
- ['Thailand','GDP','Annual','Gross Domestic Product','MKTGDPTHA646NWDB','Current USD, Not Seasonally Adjusted'],
693
- ['Australia','GDP','Annual','Gross Domestic Product','MKTGDPAUA646NWDB','Current USD, Not Seasonally Adjusted'],
694
- ['France','GDP','Annual','Gross Domestic Product','MKTGDPFRA646NWDB','Current USD, Not Seasonally Adjusted'],
695
- ['Germany','GDP','Annual','Gross Domestic Product','MKTGDPDEA646NWDB','Current USD, Not Seasonally Adjusted'],
696
- ['UK','GDP','Annual','Gross Domestic Product','MKTGDPGBA646NWDB','Current USD, Not Seasonally Adjusted'],
697
- ['Israel','GDP','Annual','Gross Domestic Product','MKTGDPILA646NWDB','Current USD, Not Seasonally Adjusted'],
698
- ['Italy','GDP','Annual','Gross Domestic Product','MKTGDPITA646NWDB','Current USD, Not Seasonally Adjusted'],
699
- ['Cambodia','GDP','Annual','Gross Domestic Product','MKTGDPKHA646NWDB','Current USD, Not Seasonally Adjusted'],
700
-
701
- # Real GDP at Constant National Prices:不变价格GDP,年度指标,百万美元,2017年基准,未经季节性调整。扣除通胀因素,扣除汇率变化因素
702
- ['India','CNP GDP','Annual','Real GDP at Constant National Prices','RGDPNAINA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
703
- ['China','CNP GDP','Annual','Real GDP at Constant National Prices','RGDPNACNA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
704
- ['Japan','CNP GDP','Annual','Real GDP at Constant National Prices','RGDPNAJPA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
705
- ['Korea','CNP GDP','Annual','Real GDP at Constant National Prices','RGDPNAKRA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
706
- ['Thailand','CNP GDP','Annual','Real GDP at Constant National Prices','RGDPNATHA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
707
- ['Vietnam','CNP GDP','Annual','Real GDP at Constant National Prices','RGDPNAVNA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
708
- ['Cambodia','CNP GDP','Annual','Real GDP at Constant National Prices','RGDPNAKHA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
709
- ['Hong Kong','CNP GDP','Annual','Real GDP at Constant National Prices','RGDPNAHKA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
710
- ['Singapore','CNP GDP','Annual','Real GDP at Constant National Prices','RGDPNASGA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
711
- ['Malaysia','CNP GDP','Annual','Real GDP at Constant National Prices','RGDPNAMYA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
712
- ['Indonesia','CNP GDP','Annual','Real GDP at Constant National Prices','RGDPNAIDA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
713
- ['USA','CNP GDP','Annual','Real GDP at Constant National Prices','RGDPNAUSA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
714
- ['UK','CNP GDP','Annual','Real GDP at Constant National Prices','RGDPNAGBA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
715
- ['France','CNP GDP','Annual','Real GDP at Constant National Prices','RGDPNAFRA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
716
- ['Germany','CNP GDP','Annual','Real GDP at Constant National Prices','RGDPNADEA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
717
- ['Italy','CNP GDP','Annual','Real GDP at Constant National Prices','RGDPNAITA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
718
- ['Israel','CNP GDP','Annual','Real GDP at Constant National Prices','RGDPNAILA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
719
- ['Russia','CNP GDP','Annual','Real GDP at Constant National Prices','RGDPNARUA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
720
- ['Australia','CNP GDP','Annual','Real GDP at Constant National Prices','RGDPNAAUA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
721
-
722
- # Current Price GDP:季度指标,本币现价,经过季节性调整。未考虑通货膨胀因素,不受汇率变化影响
723
- ['China','Constant GDP','Quarterly','Current Price Gross Domestic Product','CHNGDPNQDSMEI','Local Currency, Seasonally Adjusted'],
724
- ['Japan','Constant GDP','Quarterly','Current Price Gross Domestic Product','JPNGDPNQDSMEI','Local Currency, Seasonally Adjusted'],
725
- ['USA','Constant GDP','Quarterly','Current Price Gross Domestic Product','USAGDPNQDSMEI','Local Currency, Seasonally Adjusted'],
726
- ['Korea','Constant GDP','Quarterly','Current Price Gross Domestic Product','KORGDPNQDSMEI','Local Currency, Seasonally Adjusted'],
727
- ['Russia','Constant GDP','Quarterly','Current Price Gross Domestic Product','RUSGDPNQDSMEI','Local Currency, Seasonally Adjusted'],
728
- ['India','Constant GDP','Quarterly','Current Price Gross Domestic Product','INDGDPNQDSMEI','Local Currency, Seasonally Adjusted'],
729
- ['France','Constant GDP','Quarterly','Current Price Gross Domestic Product','FRAGDPNQDSMEI','Local Currency, Seasonally Adjusted'],
730
- ['Germany','Constant GDP','Quarterly','Current Price Gross Domestic Product','DEUGDPNQDSMEI','Local Currency, Seasonally Adjusted'],
731
- ['UK','Constant GDP','Quarterly','Current Price Gross Domestic Product','GBRGDPNQDSMEI','Local Currency, Seasonally Adjusted'],
732
- ['Australia','Constant GDP','Quarterly','Current Price Gross Domestic Product','AUSGDPNQDSMEI','Local Currency, Seasonally Adjusted'],
733
-
734
- # Ratio of GNP to GDP:年度指标,百分比%,未经季节性调整
735
- #['China','GNP','Annual','Ratio of GNP to GDP','GNPGDPCNA156NUPN','Percent, Not Seasonally Adjusted'],
736
- #['USA','GNP','Annual','Ratio of GNP to GDP','GNPGDPUSA156NUPN','Percent, Not Seasonally Adjusted'],
737
- #['Japan','GNP','Annual','Ratio of GNP to GDP','GNPGDPJPA156NUPN','Percent, Not Seasonally Adjusted'],
738
-
739
- ['China','GNP Ratio','Annual','Ratio of GNP to GDP','GNPGDPCNA156NUPN','Percent, Not Seasonally Adjusted'],
740
- ['USA','GNP Ratio','Annual','Ratio of GNP to GDP','GNPGDPUSA156NUPN','Percent, Not Seasonally Adjusted'],
741
- ['Japan','GNP Ratio','Annual','Ratio of GNP to GDP','GNPGDPJPA156NUPN','Percent, Not Seasonally Adjusted'],
742
-
743
-
744
- # GDP Per Capita:人均GDP,年度指标,美元现价,未经季节性调整。未扣除通胀因素,受到汇率变化影响
745
- ['China','GDP Per Capita','Annual','Gross Domestic Product Per Capita','PCAGDPCNA646NWDB','Current USD, Not Seasonally Adjusted'],
746
- ['Japan','GDP Per Capita','Annual','Gross Domestic Product Per Capita','PCAGDPJPA646NWDB','Current USD, Not Seasonally Adjusted'],
747
- ['USA','GDP Per Capita','Annual','Gross Domestic Product Per Capita','PCAGDPUSA646NWDB','Current USD, Not Seasonally Adjusted'],
748
- ['Korea','GDP Per Capita','Annual','Gross Domestic Product Per Capita','PCAGDPKRA646NWDB','Current USD, Not Seasonally Adjusted'],
749
- ['India','GDP Per Capita','Annual','Gross Domestic Product Per Capita','PCAGDPINA646NWDB','Current USD, Not Seasonally Adjusted'],
750
- ['Singapore','GDP Per Capita','Annual','Gross Domestic Product Per Capita','PCAGDPSGA646NWDB','Current USD, Not Seasonally Adjusted'],
751
- ['Malaysia','GDP Per Capita','Annual','Gross Domestic Product Per Capita','PCAGDPMYA646NWDB','Current USD, Not Seasonally Adjusted'],
752
- ['Indonesia','GDP Per Capita','Annual','Gross Domestic Product Per Capita','PCAGDPIDA646NWDB','Current USD, Not Seasonally Adjusted'],
753
- ['Vietnam','GDP Per Capita','Annual','Gross Domestic Product Per Capita','PCAGDPVNA646NWDB','Current USD, Not Seasonally Adjusted'],
754
- ['Thailand','GDP Per Capita','Annual','Gross Domestic Product Per Capita','PCAGDPTHA646NWDB','Current USD, Not Seasonally Adjusted'],
755
- ['Cambodia','GDP Per Capita','Annual','Gross Domestic Product Per Capita','PCAGDPKHA646NWDB','Current USD, Not Seasonally Adjusted'],
756
-
757
- # Constant GDP per capita:不变价格人均GDP,2010年美元基准,未经季节性调整。扣除通胀因素和汇率变化因素
758
- ['China','CNP GDP Per Capita','Annual','Constant Price GDP Per Capita','NYGDPPCAPKDCHN','2010 USD, Not Seasonally Adjusted'],
759
- ['USA','CNP GDP Per Capita','Annual','Constant Price GDP Per Capita','NYGDPPCAPKDUSA','2010 USD, Not Seasonally Adjusted'],
760
- ['Japan','CNP GDP Per Capita','Annual','Constant Price GDP Per Capita','NYGDPPCAPKDJPN','2010 USD, Not Seasonally Adjusted'],
761
- ['Russia','CNP GDP Per Capita','Annual','Constant Price GDP Per Capita','NYGDPPCAPKDRUS','2010 USD, Not Seasonally Adjusted'],
762
- ['France','CNP GDP Per Capita','Annual','Constant Price GDP Per Capita','NYGDPPCAPKDFRA','2010 USD, Not Seasonally Adjusted'],
763
- ['Germany','CNP GDP Per Capita','Annual','Constant Price GDP Per Capita','NYGDPPCAPKDDEU','2010 USD, Not Seasonally Adjusted'],
764
- ['Italy','CNP GDP Per Capita','Annual','Constant Price GDP Per Capita','NYGDPPCAPKDITA','2010 USD, Not Seasonally Adjusted'],
765
- ['Singapore','CNP GDP Per Capita','Annual','Constant Price GDP Per Capita','NYGDPPCAPKDSGP','2010 USD, Not Seasonally Adjusted'],
766
- ['Malaysia','CNP GDP Per Capita','Annual','Constant Price GDP Per Capita','NYGDPPCAPKDMYS','2010 USD, Not Seasonally Adjusted'],
767
- ['Indonesia','CNP GDP Per Capita','Annual','Constant Price GDP Per Capita','NYGDPPCAPKDIDN','2010 USD, Not Seasonally Adjusted'],
768
- ['India','CNP GDP Per Capita','Annual','Constant Price GDP Per Capita','NYGDPPCAPKDIND','2010 USD, Not Seasonally Adjusted'],
769
-
770
- # CPI%:月度数据,以2015年为基准值100,未经季节性调整
771
- #['China','Constant CPI','Monthly','Consumer Price Index: All Items','CHNCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
772
- #['USA','Constant CPI','Monthly','Consumer Price Index: All Items','USACPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
773
- #['Japan','Constant CPI','Monthly','Consumer Price Index: All Items','JPNCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
774
- #['Korea','Constant CPI','Monthly','Consumer Price Index: All Items','KORCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
775
- #['India','Constant CPI','Monthly','Consumer Price Index: All Items','INDCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
776
- #['France','Constant CPI','Monthly','Consumer Price Index: All Items','FRACPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
777
- #['Germany','Constant CPI','Monthly','Consumer Price Index: All Items','DEUCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
778
- #['Australia','Constant CPI','Monthly','Consumer Price Index: All Items','AUSCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
779
- #['UK','Constant CPI','Monthly','Consumer Price Index: All Items','GBRCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
780
- #['Italy','Constant CPI','Monthly','Consumer Price Index: All Items','ITACPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
781
- #['Spain','Constant CPI','Monthly','Consumer Price Index: All Items','ESPCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
782
- #['Russia','Constant CPI','Monthly','Consumer Price Index: All Items','RUSCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
783
- #['Indonesia','Constant CPI','Monthly','Consumer Price Index: All Items','IDNCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
784
- #['Israel','Constant CPI','Monthly','Consumer Price Index: All Items','ISRCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
785
-
786
- ['China','Constant CPI','Monthly','Consumer Price Index: All Items','CHNCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
787
- ['USA','Constant CPI','Monthly','Consumer Price Index: All Items','USACPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
788
- ['Japan','Constant CPI','Monthly','Consumer Price Index: All Items','JPNCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
789
- ['Korea','Constant CPI','Monthly','Consumer Price Index: All Items','KORCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
790
- ['India','Constant CPI','Monthly','Consumer Price Index: All Items','INDCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
791
- ['France','Constant CPI','Monthly','Consumer Price Index: All Items','FRACPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
792
- ['Germany','Constant CPI','Monthly','Consumer Price Index: All Items','DEUCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
793
- ['Australia','Constant CPI','Monthly','Consumer Price Index: All Items','AUSCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
794
- ['UK','Constant CPI','Monthly','Consumer Price Index: All Items','GBRCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
795
- ['Italy','Constant CPI','Monthly','Consumer Price Index: All Items','ITACPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
796
- ['Spain','Constant CPI','Monthly','Consumer Price Index: All Items','ESPCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
797
- ['Russia','Constant CPI','Monthly','Consumer Price Index: All Items','RUSCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
798
- ['Indonesia','Constant CPI','Monthly','Consumer Price Index: All Items','IDNCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
799
- ['Israel','Constant CPI','Monthly','Consumer Price Index: All Items','ISRCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
800
-
801
-
802
- # CPI%, Growth Rate over Previous Period
803
- ['USA','MoM CPI','Monthly','Consumer Price Index: All Items Growth Rate','CPALTT01USM657N','Growth Rate Previous Period, Not Seasonally Adjusted'],
804
- ['China','MoM CPI','Monthly','Consumer Price Index: All Items Growth Rate','CPALTT01CNM657N','Growth Rate Previous Period, Not Seasonally Adjusted'],
805
- ['Japan','MoM CPI','Monthly','Consumer Price Index: All Items Growth Rate','CPALTT01USM657N','Growth Rate Previous Period, Not Seasonally Adjusted'],
806
- ['Korea','MoM CPI','Monthly','Consumer Price Index: All Items Growth Rate','CPALTT01KRM657N','Growth Rate Previous Period, Not Seasonally Adjusted'],
807
- ['Russia','MoM CPI','Monthly','Consumer Price Index: All Items Growth Rate','CPALTT01RUM657N','Growth Rate Previous Period, Not Seasonally Adjusted'],
808
- ['India','MoM CPI','Monthly','Consumer Price Index: All Items Growth Rate','CPALTT01INM657N','Growth Rate Previous Period, Not Seasonally Adjusted'],
809
- ['France','MoM CPI','Monthly','Consumer Price Index: All Items Growth Rate','CPALTT01FRM657N','Growth Rate Previous Period, Not Seasonally Adjusted'],
810
- ['Germany','MoM CPI','Monthly','Consumer Price Index: All Items Growth Rate','CPALTT01DEM657N','Growth Rate Previous Period, Not Seasonally Adjusted'],
811
- ['Canada','MoM CPI','Monthly','Consumer Price Index: All Items Growth Rate','CPALTT01CAM657N','Growth Rate Previous Period, Not Seasonally Adjusted'],
812
- ['UK','MoM CPI','Monthly','Consumer Price Index: All Items Growth Rate','CPALTT01GBM657N','Growth Rate Previous Period, Not Seasonally Adjusted'],
813
-
814
- # PPI
815
- ['Sweden','Constant PPI','Monthly','Producer Prices Index: Total Industrial Activities','PIEATI01SEM661N','Index 2015=100, Not Seasonally Adjusted'],
816
- ['Spain','Constant PPI','Monthly','Producer Prices Index: Total Industrial Activities','PIEATI01ESM661N','Index 2015=100, Not Seasonally Adjusted'],
817
- ['UK','Constant PPI','Monthly','Producer Prices Index: Total Industrial Activities','PIEATI01GBM661N','Index 2015=100, Not Seasonally Adjusted'],
818
- ['Italy','Constant PPI','Monthly','Producer Prices Index: Total Industrial Activities','PIEATI01ITM661N','Index 2015=100, Not Seasonally Adjusted'],
819
- ['Euro Area','Constant PPI','Monthly','Producer Prices Index: Total Industrial Activities','PIEATI01EZM661N','Index 2015=100, Not Seasonally Adjusted'],
820
- ['Switzerland','Constant PPI','Monthly','Producer Prices Index: Total Industrial Activities','PIEATI01CHM661N','Index 2015=100, Not Seasonally Adjusted'],
821
- ['France','Constant PPI','Monthly','Producer Prices Index: Total Industrial Activities','PIEATI01FRM661N','Index 2015=100, Not Seasonally Adjusted'],
822
- ['Germany','Constant PPI','Monthly','Producer Prices Index: Total Industrial Activities','PIEATI01DEM661N','Index 2015=100, Not Seasonally Adjusted'],
823
- ['USA','Constant PPI','Monthly','Producer Prices Index: Total Industrial Activities','PIEAMP01USM661N','Index 2015=100, Not Seasonally Adjusted'],
824
- ['Mexico','Constant PPI','Monthly','Producer Prices Index: Total Industrial Activities','PIEATI02MXM661N','Index 2015=100, Not Seasonally Adjusted'],
825
- ['Japan','Constant PPI','Monthly','Producer Prices Index: Total Industrial Activities','PIEATI02JPM661N','Index 2015=100, Not Seasonally Adjusted'],
826
- ['Korea','Constant PPI','Monthly','Producer Prices Index: Total Industrial Activities','PIEATI02KRM661N','Index 2015=100, Not Seasonally Adjusted'],
827
- ['Russia','Constant PPI','Monthly','Producer Prices Index: Total Industrial Activities','PIEATI02RUM661N','Index 2015=100, Not Seasonally Adjusted'],
828
- ['Canada','Constant PPI','Monthly','Producer Prices Index: Total Industrial Activities','PIEAMP01CAM661N','Index 2015=100, Not Seasonally Adjusted'],
829
-
830
- # PPI China, up to 2015 & Annualonly
831
- ['China','Constant PPI','Annual','Producer Prices Index: Total Industrial Activities','PIEATI01CNA661N','Index 2015=100, Not Seasonally Adjusted'],
832
-
833
- # PPI%, Growth Rate same period previous year
834
- ['China','YoY PPI','Monthly','Producer Prices Index: Industrial Activities','CHNPIEATI01GYM','Growth rate same period previous year, Not Seasonally Adjusted'],
835
- ['UK','YoY PPI','Monthly','Producer Prices Index: Industrial Activities','GBRPIEATI01GYM','Growth rate same period previous year, Not Seasonally Adjusted'],
836
- ['France','YoY PPI','Monthly','Producer Prices Index: Industrial Activities','FRAPIEATI01GYM','Growth rate same period previous year, Not Seasonally Adjusted'],
837
- ['Germany','YoY PPI','Monthly','Producer Prices Index: Industrial Activities','DEUPIEATI01GYM','Growth rate same period previous year, Not Seasonally Adjusted'],
838
- ['Japan','YoY PPI','Monthly','Producer Prices Index: Industrial Activities','JPNPIEATI02GYM','Growth rate same period previous year, Not Seasonally Adjusted'],
839
- ['Korea','YoY PPI','Monthly','Producer Prices Index: Industrial Activities','KORPIEATI02GYM','Growth rate same period previous year, Not Seasonally Adjusted'],
840
- ['Italy','YoY PPI','Monthly','Producer Prices Index: Industrial Activities','ITAPIEATI01GYM','Growth rate same period previous year, Not Seasonally Adjusted'],
841
- ['Spain','YoY PPI','Monthly','Producer Prices Index: Industrial Activities','ITAPIEATI01GYM','Growth rate same period previous year, Not Seasonally Adjusted'],
842
- ['Poland','YoY PPI','Monthly','Producer Prices Index: Industrial Activities','POLPIEATI01GYM','Growth rate same period previous year, Not Seasonally Adjusted'],
843
- ['USA','YoY PPI','Monthly','Producer Prices Index: Industrial Activities','PIEAMP02USM659N','Growth rate same period previous year, Not Seasonally Adjusted'],
844
-
845
- # Interest rate, Discount rate,中央银行的再贴现率,央行给予商业银行的短期贷款利率
846
- ['China','Discount Rate','Monthly','Central Bank Discount Rate','INTDSRCNM193N','Percent per Annum, Not Seasonally Adjusted'],
847
- ['USA','Discount Rate','Monthly','Central Bank Discount Rate','INTDSRUSM193N','Percent per Annum, Not Seasonally Adjusted'],
848
- ['India','Discount Rate','Monthly','Central Bank Discount Rate','INTDSRINM193N','Percent per Annum, Not Seasonally Adjusted'],
849
- ['Japan','Discount Rate','Monthly','Central Bank Discount Rate','INTDSRJPM193N','Percent per Annum, Not Seasonally Adjusted'],
850
- ['Korea','Discount Rate','Monthly','Central Bank Discount Rate','INTDSRKRM193N','Percent per Annum, Not Seasonally Adjusted'],
851
- ['Brazil','Discount Rate','Monthly','Central Bank Discount Rate','INTDSRBRM193N','Percent per Annum, Not Seasonally Adjusted'],
852
-
853
- # Immediate Interest rate, less than 24 hours, interbank rate
854
- ['China','Immediate Rate','Monthly','Immediate Rates: Less than 24 Hours: Interbank Rate','IRSTCI01CNM156N','Percent per Annum, Not Seasonally Adjusted'],
855
- ['USA','Immediate Rate','Monthly','Immediate Rates: Less than 24 Hours: Interbank Rate','IRSTCI01USM156N','Percent per Annum, Not Seasonally Adjusted'],
856
- ['Japan','Immediate Rate','Monthly','Immediate Rates: Less than 24 Hours: Interbank Rate','IRSTCI01JPM156N','Percent per Annum, Not Seasonally Adjusted'],
857
- ['Korea','Immediate Rate','Monthly','Immediate Rates: Less than 24 Hours: Interbank Rate','IRSTCI01KRM156N','Percent per Annum, Not Seasonally Adjusted'],
858
- ['India','Immediate Rate','Monthly','Immediate Rates: Less than 24 Hours: Interbank Rate','IRSTCI01INM156N','Percent per Annum, Not Seasonally Adjusted'],
859
- ['France','Immediate Rate','Monthly','Immediate Rates: Less than 24 Hours: Interbank Rate','IRSTCI01FRM156N','Percent per Annum, Not Seasonally Adjusted'],
860
- ['Germany','Immediate Rate','Monthly','Immediate Rates: Less than 24 Hours: Interbank Rate','IRSTCI01DEM156N','Percent per Annum, Not Seasonally Adjusted'],
861
- ['Australia','Immediate Rate','Monthly','Immediate Rates: Less than 24 Hours: Interbank Rate','IRSTCI01AUM156N','Percent per Annum, Not Seasonally Adjusted'],
862
- ['Indonesia','Immediate Rate','Monthly','Immediate Rates: Less than 24 Hours: Interbank Rate','IRSTCI01IDM156N','Percent per Annum, Not Seasonally Adjusted'],
863
- ['Russia','Immediate Rate','Monthly','Immediate Rates: Less than 24 Hours: Interbank Rate','IRSTCI01RUM156N','Percent per Annum, Not Seasonally Adjusted'],
864
-
865
- ['LIBOR','Immediate Rate','Daily','Overnight London Interbank Offered Rate, based on USD','USDONTD156N','Percent per Annum, Not Seasonally Adjusted'],
866
- ['UK','LIBOR','Daily','Overnight London Interbank Offered Rate, based on USD','USDONTD156N','Percent per Annum, Not Seasonally Adjusted'],
867
-
868
- # Foreign exchange rate, to USD
869
- ['China','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXCHUS','Chinese Yuan/1 US$, Not Seasonally Adjusted'],
870
- ['Japan','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXJPUS','Japanese Yen/1 US$, Not Seasonally Adjusted'],
871
- ['Korea','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXKOUS','South Korea Won/1 US$, Not Seasonally Adjusted'],
872
- ['Singapore','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXSIUS','Singapore Dollars/1 US$, Not Seasonally Adjusted'],
873
- ['China Hong Kong','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXHKUS','HK Dollars/1 US$, Not Seasonally Adjusted'],
874
- ['Australia','Exchange Rate','Daily','USD/Local Currency Foreign Exchange Rate','DEXUSAL','US Dollars/1 Australian Dollar, Not Seasonally Adjusted'],
875
- ['Euro','Exchange Rate','Daily','USD/Local Currency Foreign Exchange Rate','DEXUSEU','US Dollars/1 Euro, Not Seasonally Adjusted'],
876
- ['India','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXINUS','Indian Rupees/1 US$, Not Seasonally Adjusted'],
877
- ['UK','Exchange Rate','Daily','USD/Local Currency Foreign Exchange Rate','DEXUSUK','US Dollars/1 British Pound, Not Seasonally Adjusted'],
878
- ['Canada','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXCAUS','Canadian Dollars/1 US$, Not Seasonally Adjusted'],
879
- ['Mexico','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXMXUS','Mexican New Pesos/1 US$, Not Seasonally Adjusted'],
880
- ['Brazil','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXBZUS','Brazilian Reals/1 US$, Not Seasonally Adjusted'],
881
- ['Venezuela','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXVZUS','Venezuelan Bolivares/1 US$, Not Seasonally Adjusted'],
882
- ['South Africa','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXSFUS','South African Rand/1 US$, Not Seasonally Adjusted'],
883
- ['Sweden','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXSDUS','Swedish Kronor/1 US$, Not Seasonally Adjusted'],
884
- ['Thailand','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXTHUS','Thai Baht/1 US$, Not Seasonally Adjusted'],
885
- ['New Zealand','Exchange Rate','Daily','USD/Local Currency Foreign Exchange Rate','DEXUSNZ','US Dollars/1 New Zealand Dollar, Not Seasonally Adjusted'],
886
- ['China Taiwan','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXTAUS','New Taiwan Dollars/1 US$, Not Seasonally Adjusted'],
887
- ['Malaysia','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXMAUS','Malaysian Ringgit/1 US$, Not Seasonally Adjusted'],
888
- ['Denmark','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXDNUS','Danish Kroner/1 US$, Not Seasonally Adjusted'],
889
-
890
- # M0,本地货币,月度
891
- ['China','M0','Monthly','National Monetary Supply M0','MYAGM0CNM189N','National Currency, Seasonally Adjusted'],
892
-
893
- # M1,本地货币,月度
894
- ['China','M1','Monthly','National Monetary Supply M1','MANMM101CNM189S','National Currency, Seasonally Adjusted'],
895
- ['USA','M1','Monthly','National Monetary Supply M1','MANMM101USM189S','National Currency, Seasonally Adjusted'],
896
- ['Japan','M1','Monthly','National Monetary Supply M1','MANMM101JPM189S','National Currency, Seasonally Adjusted'],
897
- ['Euro Area','M1','Monthly','Euro Area Monetary Supply M1','MANMM101EZM189S','National Currency, Seasonally Adjusted'],
898
- ['Korea','M1','Monthly','National Monetary Supply M1','MANMM101KRM189S','National Currency, Seasonally Adjusted'],
899
- ['India','M1','Monthly','National Monetary Supply M1','MANMM101INM189S','National Currency, Seasonally Adjusted'],
900
-
901
- # M2,本地货币,月度
902
- ['China','M2','Monthly','National Monetary Supply M2','MYAGM2CNM189N','National Currency, Not Seasonally Adjusted'],
903
- ['Japan','M2','Monthly','National Monetary Supply M2','MYAGM2JPM189N','National Currency, Seasonally Adjusted'],
904
- ['Korea','M2','Monthly','National Monetary Supply M2','MYAGM2KRM189N','National Currency, Not Seasonally Adjusted'],
905
- ['France','M2','Monthly','National Monetary Supply M2','MYAGM2FRM189N','National Currency, Not Seasonally Adjusted'],
906
- ['Italy','M2','Monthly','National Monetary Supply M2','MYAGM2ITM189N','National Currency, Not Seasonally Adjusted'],
907
- ['Russia','M2','Monthly','National Monetary Supply M2','MYAGM2RUM189N','National Currency, Not Seasonally Adjusted'],
908
- ['Indonesia','M2','Monthly','National Monetary Supply M2','MYAGM2IDM189N','National Currency, Not Seasonally Adjusted'],
909
- ['Brazil','M2','Monthly','National Monetary Supply M2','MYAGM2BRM189N','National Currency, Not Seasonally Adjusted'],
910
- ['USA','M2','Monthly','National Monetary Supply M2','M2NS','Billions of Dollars, Not Seasonally Adjusted'],
911
-
912
- # M3,本地货币,月度
913
- ['China','M3','Monthly','National Monetary Supply M3','MABMM301CNM189S','National Currency, Seasonally Adjusted'],
914
- ['USA','M3','Monthly','National Monetary Supply M3','MABMM301USM189S','National Currency, Seasonally Adjusted'],
915
- ['Japan','M3','Monthly','National Monetary Supply M3','MABMM301JPM189S','National Currency, Seasonally Adjusted'],
916
- ['UK','M3','Monthly','National Monetary Supply M3','MABMM301GBM189S','National Currency, Seasonally Adjusted'],
917
- ['Euro Area','M3','Monthly','Euro Area Monetary Supply M3','MABMM301EZM189S','National Currency, Seasonally Adjusted'],
918
- ['Australia','M3','Monthly','National Monetary Supply M3','MABMM301AUM189S','National Currency, Seasonally Adjusted'],
919
-
920
- # Stock Market Cap to GDP
921
- ['China','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01CNA156NWDB','Percent, Not Seasonally Adjusted'],
922
- ['USA','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01USA156NWDB','Percent, Not Seasonally Adjusted'],
923
- ['Japan','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01JPA156NWDB','Percent, Not Seasonally Adjusted'],
924
- ['Korea','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01KRA156NWDB','Percent, Not Seasonally Adjusted'],
925
- ['India','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01INA156NWDB','Percent, Not Seasonally Adjusted'],
926
- ['Singapore','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01SGA156NWDB','Percent, Not Seasonally Adjusted'],
927
- ['Malaysia','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01MYA156NWDB','Percent, Not Seasonally Adjusted'],
928
- ['Indonesia','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01IDA156NWDB','Percent, Not Seasonally Adjusted'],
929
- ['Vietnam','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01VNA156NWDB','Percent, Not Seasonally Adjusted'],
930
- ['China Hong Kong','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01HKA156NWDB','Percent, Not Seasonally Adjusted'],
931
- ['France','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01FRA156NWDB','Percent, Not Seasonally Adjusted'],
932
- ['Germany','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01DEA156NWDB','Percent, Not Seasonally Adjusted'],
933
- ['UK','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01GBA156NWDB','Percent, Not Seasonally Adjusted'],
934
- ['Italy','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01ITA156NWDB','Percent, Not Seasonally Adjusted'],
935
- ['Spain','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01ESA156NWDB','Percent, Not Seasonally Adjusted'],
936
- ['Israel','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01ILA156NWDB','Percent, Not Seasonally Adjusted'],
937
- ['Canada','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01CAA156NWDB','Percent, Not Seasonally Adjusted'],
938
-
939
- # 消费者信心综合指数:OECD
940
- ['China','Consumer Confidence','Monthly','Consumer Confidence Composite Indicator by OECD','CSCICP03CNM665S','Normalised (Normal=100), Seasonally Adjusted'],
941
- ['USA','Consumer Confidence','Monthly','Consumer Confidence Composite Indicator by OECD','CSCICP03USM665S','Normalised (Normal=100), Seasonally Adjusted'],
942
- ['Japan','Consumer Confidence','Monthly','Consumer Confidence Composite Indicator by OECD','CSCICP03JPM665S','Normalised (Normal=100), Seasonally Adjusted'],
943
- ['Korea','Consumer Confidence','Monthly','Consumer Confidence Composite Indicator by OECD','CSCICP03KRM665S','Normalised (Normal=100), Seasonally Adjusted'],
944
- ['Indonesia','Consumer Confidence','Monthly','Consumer Confidence Composite Indicator by OECD','CSCICP03IDM665S','Normalised (Normal=100), Seasonally Adjusted'],
945
- ['France','Consumer Confidence','Monthly','Consumer Confidence Composite Indicator by OECD','CSCICP03FRM665S','Normalised (Normal=100), Seasonally Adjusted'],
946
- ['Germany','Consumer Confidence','Monthly','Consumer Confidence Composite Indicator by OECD','CSCICP03DEM665S','Normalised (Normal=100), Seasonally Adjusted'],
947
- ['Italy','Consumer Confidence','Monthly','Consumer Confidence Composite Indicator by OECD','CSCICP03ITM665S','Normalised (Normal=100), Seasonally Adjusted'],
948
- ['Spain','Consumer Confidence','Monthly','Consumer Confidence Composite Indicator by OECD','CSCICP03ESM665S','Normalised (Normal=100), Seasonally Adjusted'],
949
-
950
- # 粗出生率;又称为出生率。指1年内平均每千人中出生人数的比率。它反映一定时期内人口的出生水平。
951
- ['China','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTINCHN','Births per 1,000 People, Not Seasonally Adjusted'],
952
- ['USA','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTINUSA','Births per 1,000 People, Not Seasonally Adjusted'],
953
- ['Japan','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTINJPN','Births per 1,000 People, Not Seasonally Adjusted'],
954
- ['Korea','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTINKOR','Births per 1,000 People, Not Seasonally Adjusted'],
955
- ['France','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTINFRA','Births per 1,000 People, Not Seasonally Adjusted'],
956
- ['Germany','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTINDEU','Births per 1,000 People, Not Seasonally Adjusted'],
957
- ['India','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTININD','Births per 1,000 People, Not Seasonally Adjusted'],
958
- ['Indonesia','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTINIDN','Births per 1,000 People, Not Seasonally Adjusted'],
959
- ['Singapore','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTINSGP','Births per 1,000 People, Not Seasonally Adjusted'],
960
- ['Vietnam','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTINVNM','Births per 1,000 People, Not Seasonally Adjusted'],
961
- ['Pakistan','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTINPAK','Births per 1,000 People, Not Seasonally Adjusted'],
962
- ['Cambodia','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTINKHM','Births per 1,000 People, Not Seasonally Adjusted'],
963
- ['Malaysia','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTINMYS','Births per 1,000 People, Not Seasonally Adjusted'],
964
- ['Australia','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTINAUS','Births per 1,000 People, Not Seasonally Adjusted'],
965
- ['Italy','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTINITA','Births per 1,000 People, Not Seasonally Adjusted'],
966
- ['Spain','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTINESP','Births per 1,000 People, Not Seasonally Adjusted'],
967
-
968
- # 人口增长率;出生率-死亡率。
969
- #Annual population growth rate for year t is the exponential rate of growth of midyear population from year t-1 to t,
970
- #expressed as a percentage.
971
- ['China','Population Growth','Annual','Population Growth by WB','SPPOPGROWCHN','Percent Change at Annual Rate, NSA'],
972
- ['USA','Population Growth','Annual','Population Growth by WB','SPPOPGROWUSA','Percent Change at Annual Rate, NSA'],
973
- ['Japan','Population Growth','Annual','Population Growth by WB','SPPOPGROWJPN','Percent Change at Annual Rate, NSA'],
974
- ['Korea','Population Growth','Annual','Population Growth by WB','SPPOPGROWKOR','Percent Change at Annual Rate, NSA'],
975
- ['India','Population Growth','Annual','Population Growth by WB','SPPOPGROWIND','Percent Change at Annual Rate, NSA'],
976
-
977
- # 青年人失业率:WB
978
- ['China','Youth Unemployment','Annual','Youth Unemployment Rate by WB','SLUEM1524ZSCHN','Percent(Age 15-24, seeking employment), NSA'],
979
- ['USA','Youth Unemployment','Annual','Youth Unemployment Rate by WB','SLUEM1524ZSUSA','Percent(Age 15-24, seeking employment), NSA'],
980
- ['Japan','Youth Unemployment','Annual','Youth Unemployment Rate by WB','SLUEM1524ZSJPN','Percent(Age 15-24, seeking employment), NSA'],
981
- ['Korea','Youth Unemployment','Annual','Youth Unemployment Rate by WB','SLUEM1524ZSKOR','Percent(Age 15-24, seeking employment), NSA'],
982
- ['India','Youth Unemployment','Annual','Youth Unemployment Rate by WB','SLUEM1524ZSIND','Percent(Age 15-24, seeking employment), NSA'],
983
-
984
- # GNI: Gross National Income
985
- ['China','GNI','Annual','Gross National Income','MKTGNICNA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
986
- ['USA','GNI','Annual','Gross National Income','MKTGNIUSA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
987
- ['Japan','GNI','Annual','Gross National Income','MKTGNIJPA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
988
- ['Korea','GNI','Annual','Gross National Income','MKTGNIKRA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
989
- ['India','GNI','Annual','Gross National Income','MKTGNIINA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
990
- ['Vietnam','GNI','Annual','Gross National Income','MKTGNIVNA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
991
- ['Thailand','GNI','Annual','Gross National Income','MKTGNITHA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
992
- ['Cambodia','GNI','Annual','Gross National Income','MKTGNIKHA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
993
- ['China Hong Kong','GNI','Annual','Gross National Income','MKTGNIHKA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
994
- ['Malaysia','GNI','Annual','Gross National Income','MKTGNIMYA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
995
- ['Singapore','GNI','Annual','Gross National Income','MKTGNISGA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
996
- ['Indonesia','GNI','Annual','Gross National Income','MKTGNIIDA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
997
- ['Australia','GNI','Annual','Gross National Income','MKTGNIAUA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
998
- ['New Zealand','GNI','Annual','Gross National Income','MKTGNINZA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
999
- ['UK','GNI','Annual','Gross National Income','MKTGNIGBA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
1000
- ['Germany','GNI','Annual','Gross National Income','MKTGNIDEA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
1001
- ['France','GNI','Annual','Gross National Income','MKTGNIFRA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
1002
- ['Spain','GNI','Annual','Gross National Income','MKTGNIESA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
1003
-
1004
- # 出口对进口的比例
1005
- ['China','Exports to Imports','Monthly','Ratio of Exports to Imports','XTEITT01CNM156S','Percent, Seasonally Adjusted'],
1006
- ['India','Exports to Imports','Monthly','Ratio of Exports to Imports','XTEITT01INM156N','Percent, Seasonally Adjusted'],
1007
- ['Brazil','Exports to Imports','Monthly','Ratio of Exports to Imports','XTEITT01BRM156S','Percent, Seasonally Adjusted'],
1008
- ['Russia','Exports to Imports','Monthly','Ratio of Exports to Imports','XTEITT01RUM156S','Percent, Seasonally Adjusted'],
1009
- ['Indonesia','Exports to Imports','Monthly','Ratio of Exports to Imports','XTEITT01IDM156S','Percent, Seasonally Adjusted'],
1010
-
1011
- # 人口雇佣比例
1012
- ['China','Employment to Population','Annual','Employment to Population Ratio by WB','SLEMPTOTLSPZSCHN','Percent, Not Seasonally Adjusted'],
1013
- ['USA','Employment to Population','Annual','Employment to Population Ratio by WB','SLEMPTOTLSPZSUSA','Percent, Not Seasonally Adjusted'],
1014
- ['Japan','Employment to Population','Annual','Employment to Population Ratio by WB','SLEMPTOTLSPZSJPN','Percent, Not Seasonally Adjusted'],
1015
- ['Korea','Employment to Population','Annual','Employment to Population Ratio by WB','SLEMPTOTLSPZSKOR','Percent, Not Seasonally Adjusted'],
1016
- ['India','Employment to Population','Annual','Employment to Population Ratio by WB','SLEMPTOTLSPZSIND','Percent, Not Seasonally Adjusted'],
1017
-
1018
- # 人口总数
1019
- ['China','Population','Annual','Total Population','POPTOTCNA647NWDB','Persons, Not Seasonally Adjusted'],
1020
- ['USA','Population','Annual','Total Population','POPTOTUSA647NWDB','Persons, Not Seasonally Adjusted'],
1021
- ['Japan','Population','Annual','Total Population','POPTOTJPA647NWDB','Persons, Not Seasonally Adjusted'],
1022
- ['Korea','Population','Annual','Total Population','POPTOTKRA647NWDB','Persons, Not Seasonally Adjusted'],
1023
- ['India','Population','Annual','Total Population','POPTOTINA647NWDB','Persons, Not Seasonally Adjusted'],
1024
-
1025
- # 其他
1026
- ], columns=['scope','factor','freq','name','symbol','units'])
1027
-
1028
- return s
1029
-
1030
-
1031
- #==============================================================================
1032
- #==============================================================================
1033
- #==============================================================================
1034
- #==============================================================================
1035
- if __name__ =="__main__":
1036
- fromdate='2020-1-5'
1037
- todate='2020-10-1'
1038
-
1039
- def pmi_china(fromdate,todate,loc='lower left'):
1040
- """
1041
- 功能:绘制中国的PMI指数制造业/非制造业单线图
1042
- """
1043
- #检查日期期间的合理性
1044
- valid,start,end=check_period(fromdate,todate)
1045
- if not valid:
1046
- print(' Error(pmi_china): period not valid:',fromdate,todate)
1047
- return None
1048
-
1049
- #日期变换,将日都重置为每月的第一日
1050
- year=start.year
1051
- month=start.month
1052
- fromdate1=str(year)+'-'+str(month)+'-'+'1'
1053
-
1054
- year=end.year
1055
- month=end.month
1056
- todate1=str(year)+'-'+str(month)+'-'+'1'
1057
- _,start,end=check_period(fromdate1,todate1)
1058
-
1059
- #获取PMI数据
1060
- import akshare as ak
1061
- df = ak.macro_china_pmi()
1062
-
1063
- #截取日期区间数据
1064
- import pandas as pd
1065
- df['date']=pd.to_datetime(df['月份'])
1066
- df.set_index('date',inplace=True)
1067
- df1=df[df.index >= start]
1068
- df2=df1[df1.index <= end]
1069
-
1070
- #形成水平50线
1071
- df2['benchmark']=50
1072
-
1073
- #将字符串表示的数值转换为数值型,否则绘图很乱
1074
- df2['制造业PMI']=df2['制造业-指数'].astype('float')
1075
- df2['非制造业PMI']=df2['非制造业-指数'].astype('float')
1076
-
1077
- #绘图:制造业
1078
- ticker1=ticker2='PMI'
1079
- colname2="benchmark"
1080
- label2="景气/衰退分界线"
1081
- ylabeltxt=''
1082
-
1083
- import datetime
1084
- today=datetime.date.today()
1085
- footnote="数据来源:东方财富,"+str(today)
1086
-
1087
- colname1="制造业PMI"
1088
- label1="制造业"
1089
- titletxt="中国采购经理人指数PMI:制造业"
1090
- plot_line2(df2,ticker1,colname1,label1, \
1091
- df2,ticker2,colname2,label2, \
1092
- ylabeltxt,titletxt,footnote,loc1=loc)
1093
-
1094
- #绘图:非制造业
1095
- colname1="非制造业PMI"
1096
- label1="非制造业"
1097
- titletxt="中国采购经理人指数PMI:非制造业"
1098
- plot_line2(df2,ticker1,colname1,label1, \
1099
- df2,ticker2,colname2,label2, \
1100
- ylabeltxt,titletxt,footnote,loc1=loc)
1101
- #返回数据
1102
- return df2
1103
-
1104
- #==============================================================================
1105
- #==============================================================================
1106
- #==============================================================================
1107
- if __name__ =="__main__":
1108
- fieldlist=['VALUE','scope','factor','freq','name','units']
1109
-
1110
- def internal_growth_rate_df(df0,fieldlist=['VALUE','scope','factor','freq','name','units']):
1111
- """
1112
- 功能:计算内部增长率IRR
1113
- rdf的结构:VALUE为具体的数值,scope为国家或地区,factor为指标,freq为频度。
1114
- """
1115
- if df0 is None:
1116
- print(" #Error(internal_growth_rate_df): no data provided")
1117
- return
1118
-
1119
- df=df0.copy()
1120
- df.dropna(inplace=True)
1121
-
1122
- fld_value=fieldlist[0]
1123
- fld_scope=fieldlist[1]
1124
- scope=df[fld_scope][0]
1125
-
1126
- fld_factor=fieldlist[2]
1127
- factor=df[fld_factor][0]
1128
-
1129
- fld_freq=fieldlist[3]
1130
- freq=df[fld_freq][0]
1131
-
1132
- fld_name=fieldlist[4]
1133
- fld_units=fieldlist[5]
1134
-
1135
- #开始值和结束值
1136
- value0=df[fld_value][0]
1137
- value1=df[fld_value][-1]
1138
- num=len(df)
1139
- item_gr=pow(value1/value0,1/num)-1.0
1140
-
1141
- annual_gr=item_gr
1142
- if freq == 'Daily':
1143
- annual_gr=pow(1+item_gr,365)-1.0
1144
- if freq == 'Monthly':
1145
- annual_gr=pow(1+item_gr,12)-1.0
1146
- if freq == 'Quarterly':
1147
- annual_gr=pow(1+item_gr,4)-1.0
1148
-
1149
- #计算期间
1150
- date0=str(df.index[0].year)
1151
- date1=str(df.index[-1].year)
1152
-
1153
- if freq in ['Monthly','Daily']:
1154
- date0=date0+'-'+str(df.index[0].month)+''
1155
- date1=date1+'-'+str(df.index[-1].month)+''
1156
-
1157
- if freq in ['Daily']:
1158
- date0=date0+'-'+str(df.index[0].day)+'日'
1159
- date1=date1+'-'+str(df.index[-1].day)+'日'
1160
-
1161
- #显示增长率
1162
- lang=check_language()
1163
- #print('\n')
1164
- if lang == 'Chinese':
1165
- print('从'+date0+'至'+date1+':')
1166
- if freq != 'Annual':
1167
- print(' '+ectranslate(scope)+ectranslate(factor)+'的'+ectranslate(freq)+'均环比增长率:',round(item_gr*100.0,4),'\b%')
1168
- print(' '+ectranslate(scope)+ectranslate(factor)+'的年均增长率:',round(annual_gr*100.0,4),'\b%')
1169
- else:
1170
- print('From '+date0+' to '+date1+':')
1171
- if freq != 'Annual':
1172
- print(' '+scope+', '+factor+' mom growth rate:',round(item_gr*100.0,4),'\b%')
1173
- print(' '+scope+', '+factor+' yoy growth rate:',round(annual_gr*100.0,4),'\b%')
1174
-
1175
- return
1176
-
1177
- if __name__ =="__main__":
1178
- internal_growth_rate_df(df)
1179
-
1180
-
1181
- def internal_growth_rate(rvar,fieldlist=['VALUE','scope','factor','freq','name','units']):
1182
- """
1183
- 功能:计算内部增长率IRR
1184
- rvar:可能为df或dict。若为dict,里面的元素为两个df。
1185
- 每个df的结构:VALUE为具体的数值,scope为国家或地区,factor为指标,freq为频度。
1186
- """
1187
- print('')
1188
- import pandas as pd
1189
- if isinstance(rvar,pd.DataFrame):
1190
- internal_growth_rate_df(rvar,fieldlist=['VALUE','scope','factor','freq','name','units'])
1191
- return
1192
-
1193
- if isinstance(rvar,tuple):
1194
- for k in rvar:
1195
- internal_growth_rate_df(k,fieldlist=['VALUE','scope','factor','freq','name','units'])
1196
- return
1197
-
1198
- return
1199
-
1200
- if __name__ =="__main__":
1201
- internal_growth_rate(df)
1202
- #==============================================================================
1203
- #==============================================================================
1204
- #==============================================================================
1205
-
1206
-