siat 3.10.132__py3-none-any.whl → 3.11.1__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 (221) hide show
  1. siat/__init__.py +0 -0
  2. siat/allin.py +8 -0
  3. siat/assets_liquidity.py +0 -0
  4. siat/beta_adjustment.py +0 -0
  5. siat/beta_adjustment_china.py +0 -0
  6. siat/blockchain.py +0 -0
  7. siat/bond.py +0 -0
  8. siat/bond_base.py +0 -0
  9. siat/bond_china.py +0 -0
  10. siat/bond_zh_sina.py +0 -0
  11. siat/capm_beta.py +0 -0
  12. siat/capm_beta2.py +4 -4
  13. siat/common.py +9 -6
  14. siat/compare_cross.py +0 -0
  15. siat/copyrights.py +0 -0
  16. siat/cryptocurrency.py +0 -0
  17. siat/economy.py +0 -0
  18. siat/economy2.py +0 -0
  19. siat/esg.py +0 -0
  20. siat/event_study.py +0 -0
  21. siat/exchange_bond_china.pickle +0 -0
  22. siat/fama_french.py +0 -0
  23. siat/fin_stmt2_yahoo.py +0 -0
  24. siat/financial_base.py +0 -0
  25. siat/financial_statements.py +0 -0
  26. siat/financials.py +0 -0
  27. siat/financials2.py +0 -0
  28. siat/financials_china.py +0 -0
  29. siat/financials_china2.py +0 -0
  30. siat/fund.py +0 -0
  31. siat/fund_china.pickle +0 -0
  32. siat/fund_china.py +0 -0
  33. siat/future_china.py +0 -0
  34. siat/google_authenticator.py +0 -0
  35. siat/grafix.py +55 -4
  36. siat/holding_risk.py +0 -0
  37. siat/luchy_draw.py +0 -0
  38. siat/market_china.py +0 -0
  39. siat/markowitz.py +0 -0
  40. siat/markowitz2.py +1 -0
  41. siat/markowitz2_20250704.py +0 -0
  42. siat/markowitz2_20250705.py +0 -0
  43. siat/markowitz_simple.py +0 -0
  44. siat/ml_cases.py +0 -0
  45. siat/ml_cases_example.py +0 -0
  46. siat/option_china.py +0 -0
  47. siat/option_pricing.py +0 -0
  48. siat/other_indexes.py +0 -0
  49. siat/risk_adjusted_return.py +0 -0
  50. siat/risk_adjusted_return2.py +8 -4
  51. siat/risk_evaluation.py +0 -0
  52. siat/risk_free_rate.py +0 -0
  53. siat/save2docx.py +345 -0
  54. siat/save2pdf.py +145 -0
  55. siat/sector_china.py +0 -0
  56. siat/security_price2.py +0 -0
  57. siat/security_prices.py +168 -6
  58. siat/security_trend.py +0 -0
  59. siat/security_trend2.py +2 -2
  60. siat/stock.py +11 -1
  61. siat/stock_advice_linear.py +0 -0
  62. siat/stock_base.py +0 -0
  63. siat/stock_china.py +0 -0
  64. siat/stock_info.pickle +0 -0
  65. siat/stock_prices_kneighbors.py +0 -0
  66. siat/stock_prices_linear.py +0 -0
  67. siat/stock_profile.py +0 -0
  68. siat/stock_technical.py +0 -0
  69. siat/stooq.py +0 -0
  70. siat/transaction.py +0 -0
  71. siat/translate.py +0 -0
  72. siat/valuation.py +0 -0
  73. siat/valuation_china.py +0 -0
  74. siat/var_model_validation.py +0 -0
  75. siat/yf_name.py +0 -0
  76. {siat-3.10.132.dist-info/licenses → siat-3.11.1.dist-info}/LICENSE +0 -0
  77. {siat-3.10.132.dist-info → siat-3.11.1.dist-info}/METADATA +234 -235
  78. siat-3.11.1.dist-info/RECORD +80 -0
  79. {siat-3.10.132.dist-info → siat-3.11.1.dist-info}/WHEEL +1 -1
  80. {siat-3.10.132.dist-info → siat-3.11.1.dist-info}/top_level.txt +0 -1
  81. build/lib/build/lib/siat/__init__.py +0 -75
  82. build/lib/build/lib/siat/allin.py +0 -137
  83. build/lib/build/lib/siat/assets_liquidity.py +0 -915
  84. build/lib/build/lib/siat/beta_adjustment.py +0 -1058
  85. build/lib/build/lib/siat/beta_adjustment_china.py +0 -548
  86. build/lib/build/lib/siat/blockchain.py +0 -143
  87. build/lib/build/lib/siat/bond.py +0 -2900
  88. build/lib/build/lib/siat/bond_base.py +0 -992
  89. build/lib/build/lib/siat/bond_china.py +0 -100
  90. build/lib/build/lib/siat/bond_zh_sina.py +0 -143
  91. build/lib/build/lib/siat/capm_beta.py +0 -783
  92. build/lib/build/lib/siat/capm_beta2.py +0 -887
  93. build/lib/build/lib/siat/common.py +0 -5360
  94. build/lib/build/lib/siat/compare_cross.py +0 -642
  95. build/lib/build/lib/siat/copyrights.py +0 -18
  96. build/lib/build/lib/siat/cryptocurrency.py +0 -667
  97. build/lib/build/lib/siat/economy.py +0 -1471
  98. build/lib/build/lib/siat/economy2.py +0 -1853
  99. build/lib/build/lib/siat/esg.py +0 -536
  100. build/lib/build/lib/siat/event_study.py +0 -815
  101. build/lib/build/lib/siat/fama_french.py +0 -1521
  102. build/lib/build/lib/siat/fin_stmt2_yahoo.py +0 -982
  103. build/lib/build/lib/siat/financial_base.py +0 -1160
  104. build/lib/build/lib/siat/financial_statements.py +0 -598
  105. build/lib/build/lib/siat/financials.py +0 -2339
  106. build/lib/build/lib/siat/financials2.py +0 -1278
  107. build/lib/build/lib/siat/financials_china.py +0 -4433
  108. build/lib/build/lib/siat/financials_china2.py +0 -2212
  109. build/lib/build/lib/siat/fund.py +0 -629
  110. build/lib/build/lib/siat/fund_china.py +0 -3307
  111. build/lib/build/lib/siat/future_china.py +0 -551
  112. build/lib/build/lib/siat/google_authenticator.py +0 -47
  113. build/lib/build/lib/siat/grafix.py +0 -3636
  114. build/lib/build/lib/siat/holding_risk.py +0 -867
  115. build/lib/build/lib/siat/luchy_draw.py +0 -638
  116. build/lib/build/lib/siat/market_china.py +0 -1168
  117. build/lib/build/lib/siat/markowitz.py +0 -2363
  118. build/lib/build/lib/siat/markowitz2.py +0 -3150
  119. build/lib/build/lib/siat/markowitz2_20250704.py +0 -2969
  120. build/lib/build/lib/siat/markowitz2_20250705.py +0 -3158
  121. build/lib/build/lib/siat/markowitz_simple.py +0 -373
  122. build/lib/build/lib/siat/ml_cases.py +0 -2291
  123. build/lib/build/lib/siat/ml_cases_example.py +0 -60
  124. build/lib/build/lib/siat/option_china.py +0 -3069
  125. build/lib/build/lib/siat/option_pricing.py +0 -1925
  126. build/lib/build/lib/siat/other_indexes.py +0 -409
  127. build/lib/build/lib/siat/risk_adjusted_return.py +0 -1576
  128. build/lib/build/lib/siat/risk_adjusted_return2.py +0 -1900
  129. build/lib/build/lib/siat/risk_evaluation.py +0 -2218
  130. build/lib/build/lib/siat/risk_free_rate.py +0 -351
  131. build/lib/build/lib/siat/sector_china.py +0 -4140
  132. build/lib/build/lib/siat/security_price2.py +0 -727
  133. build/lib/build/lib/siat/security_prices.py +0 -3408
  134. build/lib/build/lib/siat/security_trend.py +0 -402
  135. build/lib/build/lib/siat/security_trend2.py +0 -646
  136. build/lib/build/lib/siat/stock.py +0 -4284
  137. build/lib/build/lib/siat/stock_advice_linear.py +0 -934
  138. build/lib/build/lib/siat/stock_base.py +0 -26
  139. build/lib/build/lib/siat/stock_china.py +0 -2095
  140. build/lib/build/lib/siat/stock_prices_kneighbors.py +0 -910
  141. build/lib/build/lib/siat/stock_prices_linear.py +0 -386
  142. build/lib/build/lib/siat/stock_profile.py +0 -707
  143. build/lib/build/lib/siat/stock_technical.py +0 -3305
  144. build/lib/build/lib/siat/stooq.py +0 -74
  145. build/lib/build/lib/siat/transaction.py +0 -347
  146. build/lib/build/lib/siat/translate.py +0 -5183
  147. build/lib/build/lib/siat/valuation.py +0 -1378
  148. build/lib/build/lib/siat/valuation_china.py +0 -2076
  149. build/lib/build/lib/siat/var_model_validation.py +0 -444
  150. build/lib/build/lib/siat/yf_name.py +0 -811
  151. build/lib/siat/__init__.py +0 -75
  152. build/lib/siat/allin.py +0 -137
  153. build/lib/siat/assets_liquidity.py +0 -915
  154. build/lib/siat/beta_adjustment.py +0 -1058
  155. build/lib/siat/beta_adjustment_china.py +0 -548
  156. build/lib/siat/blockchain.py +0 -143
  157. build/lib/siat/bond.py +0 -2900
  158. build/lib/siat/bond_base.py +0 -992
  159. build/lib/siat/bond_china.py +0 -100
  160. build/lib/siat/bond_zh_sina.py +0 -143
  161. build/lib/siat/capm_beta.py +0 -783
  162. build/lib/siat/capm_beta2.py +0 -887
  163. build/lib/siat/common.py +0 -5360
  164. build/lib/siat/compare_cross.py +0 -642
  165. build/lib/siat/copyrights.py +0 -18
  166. build/lib/siat/cryptocurrency.py +0 -667
  167. build/lib/siat/economy.py +0 -1471
  168. build/lib/siat/economy2.py +0 -1853
  169. build/lib/siat/esg.py +0 -536
  170. build/lib/siat/event_study.py +0 -815
  171. build/lib/siat/fama_french.py +0 -1521
  172. build/lib/siat/fin_stmt2_yahoo.py +0 -982
  173. build/lib/siat/financial_base.py +0 -1160
  174. build/lib/siat/financial_statements.py +0 -598
  175. build/lib/siat/financials.py +0 -2339
  176. build/lib/siat/financials2.py +0 -1278
  177. build/lib/siat/financials_china.py +0 -4433
  178. build/lib/siat/financials_china2.py +0 -2212
  179. build/lib/siat/fund.py +0 -629
  180. build/lib/siat/fund_china.py +0 -3307
  181. build/lib/siat/future_china.py +0 -551
  182. build/lib/siat/google_authenticator.py +0 -47
  183. build/lib/siat/grafix.py +0 -3636
  184. build/lib/siat/holding_risk.py +0 -867
  185. build/lib/siat/luchy_draw.py +0 -638
  186. build/lib/siat/market_china.py +0 -1168
  187. build/lib/siat/markowitz.py +0 -2363
  188. build/lib/siat/markowitz2.py +0 -3150
  189. build/lib/siat/markowitz2_20250704.py +0 -2969
  190. build/lib/siat/markowitz2_20250705.py +0 -3158
  191. build/lib/siat/markowitz_simple.py +0 -373
  192. build/lib/siat/ml_cases.py +0 -2291
  193. build/lib/siat/ml_cases_example.py +0 -60
  194. build/lib/siat/option_china.py +0 -3069
  195. build/lib/siat/option_pricing.py +0 -1925
  196. build/lib/siat/other_indexes.py +0 -409
  197. build/lib/siat/risk_adjusted_return.py +0 -1576
  198. build/lib/siat/risk_adjusted_return2.py +0 -1900
  199. build/lib/siat/risk_evaluation.py +0 -2218
  200. build/lib/siat/risk_free_rate.py +0 -351
  201. build/lib/siat/sector_china.py +0 -4140
  202. build/lib/siat/security_price2.py +0 -727
  203. build/lib/siat/security_prices.py +0 -3408
  204. build/lib/siat/security_trend.py +0 -402
  205. build/lib/siat/security_trend2.py +0 -646
  206. build/lib/siat/stock.py +0 -4284
  207. build/lib/siat/stock_advice_linear.py +0 -934
  208. build/lib/siat/stock_base.py +0 -26
  209. build/lib/siat/stock_china.py +0 -2095
  210. build/lib/siat/stock_prices_kneighbors.py +0 -910
  211. build/lib/siat/stock_prices_linear.py +0 -386
  212. build/lib/siat/stock_profile.py +0 -707
  213. build/lib/siat/stock_technical.py +0 -3305
  214. build/lib/siat/stooq.py +0 -74
  215. build/lib/siat/transaction.py +0 -347
  216. build/lib/siat/translate.py +0 -5183
  217. build/lib/siat/valuation.py +0 -1378
  218. build/lib/siat/valuation_china.py +0 -2076
  219. build/lib/siat/var_model_validation.py +0 -444
  220. build/lib/siat/yf_name.py +0 -811
  221. siat-3.10.132.dist-info/RECORD +0 -218
@@ -1,1471 +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
- ds_gdp=get_econ_factors0(start,end,scope,'Current GDP')
52
- if ds_gdp is None: return None
53
-
54
- ds_gdp1=pd.DataFrame(ds_gdp['VALUE'])
55
-
56
- ds1=pd.merge(ds_gni1,ds_gdp1,how='inner',left_index=True,right_index=True)
57
- ds1.dropna(inplace=True)
58
- ds1['VALUE']=ds1['VALUE_x']/ds1['VALUE_y']
59
- ds2=ds1.drop(['VALUE_x','VALUE_y'],axis=1)
60
-
61
- ds_gdp2=ds_gdp.drop('VALUE',axis=1)
62
- ds_gdp2['factor']='GNI Ratio'
63
- ds_gdp2['name']='GNI/GDP Ratio'
64
- ds_gdp2['symbol']='CUSTOMIZED'
65
-
66
- ds3=pd.merge(ds2,ds_gdp2,how='inner',left_index=True,right_index=True)
67
-
68
- return ds3
69
-
70
- #新增Currency Value
71
- if factor in ['Currency Value']:
72
- cv=get_econ_factors0(start,end,scope,'Constant CPI')
73
- if cv is None:
74
- print(" #Error(get_econ_factors): info not found for",scope,'Constant CPI')
75
- return None
76
-
77
- cv['CV']=(100.0/cv['VALUE'])*100.0
78
- cv1=cv.rename(columns={'VALUE':'Constant CPI'})
79
- cv2=cv1.rename(columns={'CV':'VALUE'})
80
-
81
- cv2['factor']='Currency Value'
82
- cv2['name']='Currency Purchasing Power Based on CPI'
83
-
84
- return cv2
85
-
86
- #其他正常情况
87
- df=get_econ_factors0(start,end,scope=scope,factor=factor)
88
-
89
- return df
90
-
91
- #==============================================================================
92
- def get_econ_factors0(start,end,scope='China',factor='GDP'):
93
- """
94
- 【支持的因子种类(factor)】
95
- GDP, CPI, PPI,...
96
-
97
- 【支持的国家/地区(scope)】
98
- US: 美国
99
- China: 中国
100
- Korea: 韩国
101
- Japan: 日本
102
- India: 印度
103
-
104
- 【支持的取样频率(freq)】
105
- Annual: 年
106
- Quarterly: 季度
107
- Monthly: 月
108
- """
109
- s=fred_factor_codes()
110
-
111
- #帮助1:国家列表
112
- if scope=='?':
113
- scopelist=list(set(list(s[s['factor']==factor]['scope'])))
114
- if len(scopelist)==0:
115
- print(" #Error(get_econ_factors0): no such economy factor,",factor)
116
- else:
117
- title="\n*** Supported scopes for factor, "+factor+':'
118
- print(title)
119
- linelen=0
120
- for i in range(len(scopelist)):
121
- print(scopelist[i],end='')
122
- linelen=linelen+len(scopelist[i])+2
123
- if (linelen >= len(title)-2):
124
- print(''); linelen=0
125
- else:
126
- if (i+1) < len(scopelist):
127
- print(', ',end='')
128
- else:
129
- print('')
130
- return None
131
-
132
- #帮助2:经济指标
133
- if (scope != '?') and (factor=='?'):
134
- factorlist=list(set(list(s[s['scope']==scope]['factor'])))
135
- if len(factorlist)==0:
136
- print(" #Error(get_econ_factors0): no or unavailable country/region,",scope)
137
- else:
138
- title="\n*** Supported factors for scope, "+scope+':'
139
- print(title)
140
- linelen=0
141
- for i in range(len(factorlist)):
142
- print(factorlist[i],end='')
143
- linelen=linelen+len(factorlist[i])+2
144
- if (linelen >= len(title)-2):
145
- print(''); linelen=0
146
- else:
147
- if (i+1) < len(factorlist):
148
- print(', ',end='')
149
- else:
150
- print('')
151
- return None
152
-
153
- #匹配:scope+factor+freq
154
- ss=s[s['scope'].isin([scope]) & s['factor'].isin([factor])]
155
- #如果未找到匹配的模式,显示信息后返回
156
- if len(ss)==0:
157
- print(" #Error(get_econ_factors0): info are not available for",scope,factor)
158
- return None
159
-
160
- #取出对应的关键字symbol
161
- symbol=list(ss['symbol'])[0]
162
-
163
- #按照关键字抓取数据
164
- import pandas_datareader as web
165
- try:
166
- ds=web.get_data_fred(symbol,start,end)
167
- except:
168
- print(" #Error(get_econ_factors0): connection to data source failed!")
169
- return None
170
- if len(ds)==0:
171
- print(" #Error(get_econ_factors0): server returned empty data!")
172
- return None
173
- # 结果字段统一改名
174
- ds.columns=['VALUE']
175
- ds['scope']=list(ss['scope'])[0]
176
- ds['factor']=list(ss['factor'])[0]
177
- ds['freq']=list(ss['freq'])[0]
178
- ds['name']=list(ss['name'])[0]
179
- ds['symbol']=list(ss['symbol'])[0]
180
- ds['units']=list(ss['units'])[0]
181
-
182
- return ds
183
-
184
- if __name__=='__main__':
185
- start='2010-1-1'; end='2020-8-31'
186
- scope='China'; factor='Real GDP Per Capita'
187
-
188
- ds1=get_econ_factors('2010-1-1','2020-8-31','China','GDP')
189
- ds2=get_econ_factors('2010-1-1','2020-8-31','China','Real GDP')
190
- ds3=get_econ_factors('2010-1-1','2020-8-31','India','Constant GDP')
191
- get_econ_factors('2010-1-1','2020-8-31','?','Constant GDP')
192
- get_econ_factors('2010-1-1','2020-8-31','China','?')
193
- #==============================================================================
194
- if __name__=='__main__':
195
- start='2010-1-1'; end='2022-12-31'
196
- scope='China'; factor='GDP'
197
-
198
-
199
-
200
- def economy_trend0(ticker='China',start='L10Y',end='today',indicator='GDP', \
201
- datatag=False,power=0, \
202
- zeroline=False,yline=999,facecolor='papayawhip'):
203
- """
204
- ===========================================================================
205
- 功能:绘制宏观经济指标,单线,可添加趋势线。
206
- 主要参数:
207
- start:开始日期,格式YYYY-MM-DD
208
- end:结束日期
209
- scope:经济体名称,默认'China',仅支持一部分经济体
210
- factor:经济指标,默认'GDP'
211
- datatag:是否在曲线上标记数据,默认False
212
- power:绘制趋势线的多项式阶数,默认0阶不绘制
213
- zeroline:是否绘制水平零线:默认False
214
- yline:绘制竖线的数值,默认999不绘制
215
- facecolor:背景颜色,默认小麦黄'papayawhip'
216
-
217
- 若需比较两个经济体的同一个指标,或同意经济体的两个指标,可用compare_economy
218
- """
219
-
220
- start,end=start_end_preprocess(start,end)
221
- #检查日期期间的合理性
222
- valid,_,_=check_period(start,end)
223
- if not valid:
224
- print(' Error(trend_economy): period not valid:',start,end)
225
- return
226
-
227
- scope=ticker; factor=indicator
228
-
229
- #获取指标
230
- ds=get_econ_factors(start,end,scope,factor)
231
- if (ds is None):
232
- print(' #Error(economy_trend): scope/economic factor not available:',scope,'/',factor)
233
- return
234
-
235
- #绘图
236
- ylabeltxt=ectranslate(factor)
237
- titletxt=ectranslate(list(ds['name'])[0])+'走势:'+ectranslate(scope)
238
-
239
- import datetime
240
- today=datetime.date.today()
241
- footnote='单位: '+list(ds['units'])[0]+', '+list(ds['freq'])[0]+ \
242
- '\n数据来源: OECD|IMF|WB|FRED, '+str(today)
243
- ds.dropna(inplace=True)
244
-
245
- if factor in ['GNP Ratio','GNI Ratio']:
246
- ylabeltxt='GNP(GNI)/GDP'
247
- if yline==999:
248
- yline=1 #绘制y=1的水平线
249
- if factor in ['Currency Value','Constant CPI']:
250
- ylabeltxt=ectranslate(factor)
251
- if yline==999:
252
- yline=100 #绘制y=100的水平线
253
-
254
- if yline !=999:
255
- zeroline=yline
256
- if power==0:
257
- power=3
258
-
259
- plot_line(ds,'VALUE',ectranslate(factor), \
260
- ylabeltxt=ylabeltxt,titletxt=titletxt,footnote=footnote,datatag=datatag, \
261
- power=power,zeroline=zeroline, \
262
- mark_top=False,mark_bottom=False,mark_end=False, \
263
- facecolor=facecolor)
264
-
265
- return ds
266
-
267
-
268
- if __name__=='__main__':
269
- start='2010-1-1'; end='2020-8-31'
270
- scope='USA'; factor='Real GDP Per Capita'
271
-
272
- ds=economy_trend(start,end,scope='China',factor='GDP')
273
- ds=economy_trend(start,end,scope='Japan',factor='Real GDP')
274
-
275
- #==============================================================================
276
- if __name__=='__main__':
277
- #测试1
278
- tickers=['China','USA']
279
- measures='M2 GoB'
280
- measures='GNI'
281
-
282
- #测试2
283
- tickers=['China','USA']
284
- measures='Constant CPI'
285
- measures='Currency Value'
286
-
287
-
288
-
289
- fromdate='1999-12-1'
290
- todate='2022-4-1'
291
- power=0; twinx=False; loc1='upper left'; loc2='lower right'
292
-
293
-
294
- def compare_economy(ticker,indicator='GDP',start='L10Y',end='today', \
295
- power=0,twinx=False, \
296
- yline=999, \
297
- loc1='upper left',loc2='lower right',facecolor='papayawhip'):
298
- """
299
- ===========================================================================
300
- 功能:对比绘制折线图:一个国家的两种测度,或两个国家的同一个测度。
301
- 主要参数:
302
- tickers:经济体代码。如果是一个列表且内含两个代码,则认为希望比较两个国家的
303
- 同一个测度指标。如果是一个列表但只内含一个国家代码或只是一个国家代码的字符串,
304
- 则认为希望比较一个国家的两个测度指标。
305
- measures:经济指标。如果是一个列表且内含两个测度指标,则认为希望比较一个国家的
306
- 两个测度指标。如果是一个列表但只内含一个测度指标或只是一个测度指标的字符串,
307
- 则认为希望比较两个国家的同一个测度指标。
308
- 如果两个判断互相矛盾,以第一个为准。
309
- start:开始日期,格式YYYY-MM-DD;end:结束日期。
310
-
311
- twinx:是否使用双轴绘图法,默认False
312
- yline:绘制纵轴竖线的数值,默认999不绘制
313
- loc1:图例1的位置,默认左上角'upper left'
314
- loc2:图例2的位置,默认右下角'lower right'
315
- facecolor:背景颜色,默认'papayawhip'
316
- """
317
- start,end=start_end_preprocess(start,end)
318
- fromdate=start; todate=end
319
- tickers=ticker; measures=indicator
320
-
321
- DEBUG=False
322
- if DEBUG:
323
- print("DEBUG: tickers =",tickers,"\b, measures =",measures)
324
-
325
- #检查日期期间的合理性
326
- valid,_,_=check_period(fromdate,todate)
327
- if not valid:
328
- print(' #Error(compare_economy): period not valid:',fromdate,todate)
329
- return
330
-
331
- #判断国家代码个数
332
- #如果tickers只是一个字符串
333
- security_num = 0
334
- if isinstance(tickers,str):
335
- security_num = 1
336
- ticker1 = tickers
337
- #如果tickers是一个列表
338
- if isinstance(tickers,list):
339
- security_num = len(tickers)
340
- if security_num == 0:
341
- print(" #Error(compare_economy): lack of country(s) for comparison")
342
- return
343
- if security_num >= 1: ticker1 = tickers[0]
344
- if security_num >= 2: ticker2 = tickers[1]
345
-
346
- #判断测度个数
347
- #如果measures只是一个字符串
348
- measure_num = 0
349
- if isinstance(measures,str):
350
- measure_num = 1
351
- measure1 = measures
352
- #如果measures是一个列表
353
- if isinstance(measures,list):
354
- measure_num = len(measures)
355
- if measure_num == 0:
356
- print(" #Error(compare_economy): lack of measure(s)")
357
- return
358
- if measure_num >= 1: measure1 = measures[0]
359
- if measure_num >= 2: measure2 = measures[1]
360
-
361
- import datetime; today=datetime.date.today()
362
- lang=check_language()
363
- if lang == 'English':
364
- source_txt='\nSource: OECD|IMF|WB|FRED, '
365
- addstr_txt='Starting date as benchmark 100\n'
366
- unit_txt='Notes: '
367
- else:
368
- source_txt='\n数据来源: OECD|IMF|WB|FRED, '
369
- #addstr_txt='开始时点作为基数100\n'
370
- addstr_txt=''
371
- unit_txt='单位: '
372
-
373
- #是否单一国家代码+两个测度指标
374
- if (security_num == 1) and (measure_num >= 2):
375
- #国家ticker1:抓取经济指标measure1
376
- result,measure1new=separate_measure(measure1,'Constant')
377
- """
378
- df1=get_econ_factors(fromdate,todate,ticker1,measure1new)
379
- """
380
- df1=get_econ_factors(fromdate,todate,ticker1,measure1)
381
-
382
- if df1 is None: return None, None
383
-
384
- #求GoB增速指标
385
- if result:
386
- df1.rename(columns={'VALUE':'VALUE0'}, inplace = True)
387
- comparend=df1.head(1)['VALUE0'][0]
388
- df1['VALUE']=df1['VALUE0']/comparend*100
389
-
390
- #国家ticker1:抓取经济指标measure2
391
- result,measure2new=separate_measure(measure2,'Constant')
392
- """
393
- df2=get_econ_factors(fromdate,todate,ticker1,measure2new)
394
- """
395
- df2=get_econ_factors(fromdate,todate,ticker1,measure2)
396
-
397
- if df2 is None: return None, None
398
-
399
- #求GoB增速指标
400
- if result:
401
- df2.rename(columns={'VALUE':'VALUE0'}, inplace = True)
402
- comparend=df2.head(1)['VALUE0'][0]
403
- df2['VALUE']=df2['VALUE0']/comparend*100
404
-
405
- #绘制单个国家的双指标对比图
406
- ylabeltxt=''
407
- titletxt=ectranslate(measure1)+' vs '+ectranslate(measure2)+ \
408
- '\n('+ectranslate(ticker1)+')'
409
-
410
- if result:
411
- addstr=addstr_txt
412
- else:
413
- addstr=''
414
- footnote=addstr+ectranslate(measure1)+': '+list(df1['units'])[0]+', '+list(df1['freq'])[0]+ \
415
- '\n'+ectranslate(measure2)+': '+list(df2['units'])[0]+', '+list(df2['freq'])[0]+ \
416
- source_txt+str(today)
417
-
418
- if lang == 'Chinese':
419
- """
420
- plot_line2(df1,ectranslate(ticker1),'VALUE',ectranslate(measure1), \
421
- df2,ectranslate(ticker1),'VALUE',ectranslate(measure2), \
422
- ylabeltxt,titletxt,footnote, \
423
- power=power,twinx=twinx,loc1=loc1,loc2=loc2)
424
- """
425
- plot_line2(df1,ticker1,'VALUE',ectranslate(measure1), \
426
- df2,ticker1,'VALUE',ectranslate(measure2), \
427
- ylabeltxt,titletxt,footnote, \
428
- power=power,twinx=twinx,loc1=loc1,loc2=loc2,facecolor=facecolor)
429
- else:
430
- plot_line2(df1,ticker1,'VALUE',measure1, \
431
- df2,ticker1,'VALUE',measure2, \
432
- ylabeltxt,titletxt,footnote, \
433
- power=power,twinx=twinx,loc1=loc1,loc2=loc2,facecolor=facecolor)
434
-
435
- elif (security_num >= 2) and (measure_num >= 1):
436
- #双国家+单个测度指标
437
- #国家ticker1:抓取经济指标measure1
438
- result,measure1new=separate_measure(measure1,'Constant')
439
- """
440
- df1=get_econ_factors(fromdate,todate,ticker1,measure1new)
441
- """
442
- df1=get_econ_factors(fromdate,todate,ticker1,measure1)
443
-
444
- if df1 is None: return None, None
445
-
446
- #求GoB增速指标
447
- """
448
- if result:
449
- df1.rename(columns={'VALUE':'VALUE0'}, inplace = True)
450
- comparend=df1.head(1)['VALUE0'][0]
451
- df1['VALUE']=df1['VALUE0']/comparend*100
452
- """
453
-
454
- #国家ticker2:抓取经济指标measure1
455
- """
456
- df2=get_econ_factors(fromdate,todate,ticker2,measure1new)
457
- """
458
- df2=get_econ_factors(fromdate,todate,ticker2,measure1)
459
-
460
- if df2 is None: return None, None
461
-
462
- #求GoB增速指标
463
- """
464
- if result:
465
- df2.rename(columns={'VALUE':'VALUE0'}, inplace = True)
466
- comparend=df2.head(1)['VALUE0'][0]
467
- df2['VALUE']=df2['VALUE0']/comparend*100
468
- """
469
-
470
- #绘制双国家单指标对比图
471
- ylabeltxt=ectranslate(measure1)
472
- #这里的GNP指标实际上是GNP vs GDP的百分比
473
- #yline=999 #默认不绘制水平线
474
- if measure1 in ['GNP Ratio','GNI Ratio']:
475
- ylabeltxt='GNP(GNI)/GDP'
476
- if yline==999:
477
- yline=1 #绘制y=1的水平线
478
- if measure1 in ['Currency Value','Constant CPI']:
479
- ylabeltxt=ectranslate(measure1)
480
- if yline==999:
481
- yline=100 #绘制y=100的水平线
482
-
483
- if lang == 'Chinese':
484
- titletxt=ectranslate(list(df1['name'])[0])+'走势对比:'+ \
485
- '\n'+ectranslate(ticker1)+' vs '+ectranslate(ticker2)
486
- else:
487
- titletxt=list(df1['name'])[0]+', Trend Comparison'+ \
488
- '\n'+ticker1+' vs '+ticker2
489
-
490
- if result:
491
- addstr=addstr_txt
492
- else:
493
- addstr=''
494
- footnote=addstr+unit_txt+list(df1['units'])[0]+', '+list(df1['freq'])[0]+ \
495
- source_txt+str(today)
496
-
497
- if lang == 'Chinese':
498
- """
499
- plot_line2(df1,ectranslate(ticker1),'VALUE',ectranslate(measure1), \
500
- df2,ectranslate(ticker2),'VALUE',ectranslate(measure1), \
501
- ylabeltxt,titletxt,footnote, \
502
- power=power,twinx=twinx,yline=yline,loc1=loc1,loc2=loc2)
503
- """
504
- plot_line2(df1,ticker1,'VALUE',measure1, \
505
- df2,ticker2,'VALUE',measure1, \
506
- ylabeltxt,titletxt,footnote, \
507
- power=power,twinx=twinx,yline=yline,loc1=loc1,loc2=loc2,facecolor=facecolor)
508
- else:
509
- plot_line2(df1,ticker1,'VALUE',measure1, \
510
- df2,ticker2,'VALUE',measure1, \
511
- ylabeltxt,titletxt,footnote, \
512
- power=power,twinx=twinx,yline=yline,loc1=loc1,loc2=loc2,facecolor=facecolor)
513
-
514
- else:
515
- print(" #Error(compare_economy): no idea on what to compare")
516
- return None,None
517
-
518
- return df1,df2
519
-
520
- if __name__ =="__main__":
521
- tickers=['China','India']
522
- measures='GDP'
523
- fromdate='2010-1-1'
524
- todate='2020-8-31'
525
-
526
- df=compare_economy(tickers,measures,fromdate,todate)
527
- df=compare_economy(tickers,measures,fromdate,todate,twinx=True)
528
-
529
- df=compare_economy(tickers,'GDP Per Capita',fromdate,todate)
530
- df=compare_economy(tickers,'GDP Per Capita',fromdate,todate,twinx=True)
531
-
532
- df=compare_economy('India',['Real GDP','Real GDP Per Capita'],fromdate,todate,twinx=True)
533
- df=compare_economy('Japan',['Real GDP','Real GDP Per Capita'],fromdate,todate,twinx=True)
534
- df=compare_economy('Israel',['Real GDP','Real GDP Per Capita'],fromdate,todate,twinx=True)
535
-
536
- #==============================================================================
537
-
538
- def economy_trend(ticker='China',indicator='GDP',start='L10Y',end='today', \
539
- power=0,twinx=False, \
540
- attention_value=999,datatag=False,zeroline=False, \
541
- loc1='upper left',loc2='lower right',facecolor='papayawhip'):
542
- """
543
- ===========================================================================
544
- 功能:宏观经济指标趋势分析,支持单个国家单指标、单个国家双指标、两个国家单指标。
545
- 主要参数:
546
- ticker:经济体名称,默认'China'。如果是列表且内含两个经济体名称,则比较两个国家的
547
- 同一个指标
548
- indicator:宏观经济指标,默认'GDP'。如果ticker为一个经济体,而indicator为列表且
549
- 有两个指标,则比较一个国家的两个指标。如果两个判断互相矛盾,以第一个为准
550
- start:开始日期,格式YYYY-MM-DD,支持简易格式,默认'L10Y;;end:结束日期
551
- power:趋势线的多项式阶数,默认0不绘制
552
- twinx:是否使用双轴绘图法,默认False,仅在两个国家或两个指标时有效
553
- yline:绘制纵轴水平线的数值,默认999不绘制。相当于attention_value,但仅一个数值
554
- datatag:是否绘制折线各点数值,默认False
555
- zeroline:是否绘制水平零线,默认False
556
- loc1:图例1的位置,默认左上角'upper left',仅用于双国家或双指标情形
557
- loc2:图例2的位置,默认右下角'lower right',仅用于双国家或双指标情形
558
- facecolor:背景颜色,默认'papayawhip'
559
-
560
- 套壳函数:,economy_trend0
561
- """
562
- # 判断经济体个数:优先
563
- ticker_num=1
564
- if isinstance(ticker,list) and len(ticker)>=2:
565
- ticker_num=2
566
-
567
- # 判断指标个数:次优先
568
- indicator_num=1
569
- if isinstance(indicator,list) and len(indicator)>=2:
570
- indicator_num=2
571
-
572
- if ticker_num==2 or indicator_num==2:
573
- df=compare_economy(ticker=ticker,indicator=indicator, \
574
- start=start,end=end, \
575
- power=power,twinx=twinx, \
576
- yline=attention_value, \
577
- loc1=loc1,loc2=loc2,facecolor=facecolor)
578
- else:
579
- df=economy_trend0(ticker=ticker,start=start,end=end, \
580
- indicator=indicator, \
581
- datatag=datatag,power=power, \
582
- zeroline=zeroline,yline=attention_value, \
583
- facecolor=facecolor)
584
-
585
- return df
586
-
587
- #==============================================================================
588
- if __name__ =="__main__":
589
- measure='M2 MoM'
590
- measure_type='MoM'
591
- separate_measure(measure,measure_type)
592
-
593
- measure='M2'
594
- measure_type='MoM'
595
- separate_measure(measure,measure_type)
596
-
597
- def separate_measure(measure,measure_type):
598
- """
599
- 功能:若measure字符串含有子串measure_type,则返回True,并分离出第一个空格前的子串返回
600
- 否则返回False和原measure
601
- 例如:对于"M2 MoM"返回True和"M2"
602
- """
603
- if measure_type in measure:
604
- pos=measure.index(' ')
605
- new_measure=measure[pos+1:]
606
- return True,new_measure
607
-
608
- return False,measure
609
-
610
-
611
- #==============================================================================
612
- def econ_fin_depth(fromdate,todate,scope,power=0,graph=True):
613
- """
614
- 功能:经济的金融化深度,一个国家
615
- """
616
- #检查日期期间的合理性
617
- valid,_,_=check_period(fromdate,todate)
618
- if not valid:
619
- print(' #Error(econ_fin_depth): period not valid:',fromdate,todate)
620
- return None
621
-
622
- #获取GDP,按季度,本币
623
- gdp_qtr=get_econ_factors(fromdate,todate,scope,'GDP')
624
- if gdp_qtr is None:
625
- print(f" #Error(econ_fin_depth): no GDP info found for {scope}")
626
- return None
627
-
628
- gdp_qtr['date']=gdp_qtr.index.date
629
- datecvt=lambda x: str(x)[0:4]
630
- gdp_qtr['date_str']=gdp_qtr['date'].apply(datecvt)
631
-
632
- import numpy as np
633
- gdp_annual=gdp_qtr.groupby(['date_str'])['VALUE'].agg(['count',np.sum])
634
- gdp_annual2=gdp_annual[gdp_annual['count']==4]
635
-
636
- #获取M2,按月,本币
637
- m2_mth=get_econ_factors(fromdate,todate,scope,'M2')
638
- if m2_mth is None:
639
- print(f" #Error(econ_fin_depth): no M2 info found for {scope}")
640
- return None
641
-
642
- m2_mth['date']=m2_mth.index.date
643
- datecvt=lambda x: str(x)[0:4]
644
- m2_mth['date_str']=m2_mth['date'].apply(datecvt)
645
-
646
- m2_annual=m2_mth.groupby(['date_str'])['VALUE'].agg(['count',np.sum])
647
- m2_annual2=m2_annual[m2_annual['count']==12]
648
-
649
- #合并
650
- import pandas as pd
651
- m2_gdp=pd.merge(m2_annual2,gdp_annual2,on='date_str')
652
- m2_gdp.dropna(inplace=True)
653
- m2_gdp['m2/gdp']=m2_gdp['sum_x']/m2_gdp['sum_y']
654
-
655
- df=m2_gdp[['m2/gdp']]
656
-
657
- #绘图
658
- if not graph: return df
659
- colname='m2/gdp'
660
- collabel="经济的金融深度"
661
- ylabeltxt="M2/GDP比例"
662
- titletxt='经济金融深度走势:'+ectranslate(scope)
663
- footnote="数据来源: OECD|IMF|WB|FRED"
664
- plot_line(df,colname,collabel,ylabeltxt,titletxt,footnote,power=power)
665
-
666
- return df
667
-
668
- if __name__=='__main__':
669
- fromdate='2000-1-1'; todate='2020-8-31'
670
- scope="China"
671
- cn=econ_fin_depth(fromdate,todate,scope,power=4)
672
- print(min(cn['m2/gdp']),max(cn['m2/gdp']))
673
- print(cn)
674
- jp=econ_fin_depth(fromdate,todate,'Japan',power=0)
675
- us=econ_fin_depth(fromdate,todate,'USA',power=0)
676
- kr=econ_fin_depth(fromdate,todate,'Korea',power=0)
677
-
678
- #==============================================================================
679
- def compare_efd(fromdate,todate,scopelist,power=0):
680
- """
681
- 功能:比较经济的金融化深度,两个国家
682
- """
683
- #检查日期期间的合理性
684
- valid,_,_=check_period(fromdate,todate)
685
- if not valid:
686
- print(' #Error(econ_fin_depth): period not valid:',fromdate,todate)
687
- return None,None
688
-
689
- #检查国家列表
690
- if isinstance(scopelist,list):
691
- if len(scopelist) < 2:
692
- print(" #Error(compare_efd): need a list with 2 countries",scopelist)
693
- return None,None
694
- scope1 = scopelist[0]; scope2 = scopelist[1]
695
- else:
696
- print(" #Error(compare_efd): need a list with 2 countries",scopelist)
697
- return None,None
698
-
699
- #计算scope1/2的efd。美国的M2指标单位是Billions Dollars
700
- df1=econ_fin_depth(fromdate,todate,scope1,graph=False)
701
- if df1 is None:
702
- print(f" #Error(compare_efd): no M2/GDP info found for {scope1}")
703
- return None,None
704
-
705
- if scope1=='USA':
706
- df1['m2/gdp']=df1['m2/gdp']*1000000000.0
707
-
708
- df2=econ_fin_depth(fromdate,todate,scope2,graph=False)
709
- if df2 is None:
710
- print(f" #Error(compare_efd): no M2/GDP info found for {scope2}")
711
- return None,None
712
-
713
- if scope2=='USA':
714
- df2['m2/gdp']=df2['m2/gdp']*1000000000.0
715
-
716
- #绘图
717
- ticker1=scope1; ticker2=scope2
718
- colname1='m2/gdp'; colname2='m2/gdp'
719
- label1="M2/GDP"; label2="M2/GDP"
720
- ylabeltxt="M2/GDP比例"
721
- titletxt='经济金融深度对比:'+ectranslate(scope1)+' vs '+ectranslate(scope2)
722
-
723
- import datetime
724
- today=datetime.date.today()
725
- footnote="数据来源:IMF/FRED,"+str(today)
726
- plot_line2(df1,ectranslate(ticker1),colname1,label1, \
727
- df2,ectranslate(ticker2),colname2,label2, \
728
- ylabeltxt,titletxt,footnote, \
729
- power=power)
730
-
731
- return df1,df2
732
-
733
- if __name__=='__main__':
734
- fromdate='2000-1-1'; todate='2020-8-31'
735
- scopelist=["China","Japan"]
736
- power=4
737
- cn,us=compare_efd(fromdate,todate,['China','USA'])
738
- cn,jp=compare_efd(fromdate,todate,['China','Japan'])
739
- cn,kr=compare_efd(fromdate,todate,['China','Korea'])
740
-
741
- #==============================================================================
742
-
743
- def efd_trend(ticker='China',start='L30Y',end='today',power=0):
744
- """
745
- ===========================================================================
746
- 功能:基于M2/GDP比例分析经济的金融化深度,支持单个经济体和双经济体对比
747
- 参数:
748
- ticker:经济体名称,默认'China',可为双经济体列表
749
- start:开始日期,格式YYYY-MM-DD,支持简易格式,默认'L30Y'
750
- end:截止日期,默认'today'
751
- power:趋势线的多项式阶数,默认0不绘制
752
- """
753
- # 处理日期
754
- fromdate,todate=start_end_preprocess(start,end)
755
-
756
- ticker_num=1
757
- if isinstance(ticker,list) and len(ticker) >= 2:
758
- ticker_num=2
759
-
760
- if ticker_num==1:
761
- df=econ_fin_depth(fromdate=fromdate,todate=todate,scope=ticker,power=power)
762
- else:
763
- df=compare_efd(fromdate=fromdate,todate=todate,scopelist=ticker,power=power)
764
-
765
- return df
766
-
767
-
768
- #==============================================================================
769
-
770
- def economy_security(scope,fromdate,todate,econ_factor,sec_ticker,loc1='upper left',loc2='lower right'):
771
- """
772
- 功能:比较宏观经济与证券市场之间的关联关系
773
- scope: 国家/地区
774
- econ_factor: 例如GDP
775
- sec_ticker: 例如标普500指数、道琼斯指数、上证综合指数
776
- 输出: df
777
- """
778
- #检查日期期间的合理性
779
- valid,_,_=check_period(fromdate,todate)
780
- if not valid:
781
- print(' Error(economy_security): period not valid:',fromdate,todate)
782
- return None,None
783
-
784
- #获得econ_factor
785
- econ=get_econ_factors(fromdate,todate,scope,econ_factor)
786
- if econ is None:
787
- print(' Error(economy_security): scope/economic factor not available:',scope,econ_factor)
788
- return None,None
789
- econ_growth='Growth %'
790
- econ[econ_growth]=econ['VALUE'].pct_change()*100.0
791
-
792
- #获得sec_ticker行情
793
- import siat.security_prices as ssp
794
- sec=ssp.get_price(sec_ticker,fromdate,todate)
795
- if sec is None:
796
- print(' Error(economy_security): ticker info not available:',sec_ticker)
797
- return None,None
798
-
799
- #绘图1: 直接指标,双轴
800
- econ_min1,econ_max1=get_df_period(econ)
801
- sec_min1,sec_max1=get_df_period(sec)
802
- min1=max(econ_min1,sec_min1)
803
- max1=min(econ_max1,sec_max1)
804
- econ1=set_df_period(econ,min1,max1)
805
- sec1=set_df_period(sec,min1,max1)
806
-
807
- df1=econ1; ticker1=econ_factor; colname1='VALUE'; label1=econ_factor
808
- df2=sec1; ticker2=sec_ticker; colname2='Close'; label2=sec_ticker
809
- ylabeltxt=''
810
- titletxt=ectranslate(scope)+": 宏观经济与证券市场的关系"
811
- footnote="数据来源: FRED|Yahoo Finance"
812
- plot_line2(df1,ectranslate(ticker1),colname1,label1, \
813
- df2,ectranslate(ticker2),colname2,label2, \
814
- ylabeltxt,titletxt,footnote, \
815
- power=0,twinx=True,loc1=loc1,loc2=loc2)
816
-
817
- #绘图2: 增长指标,双轴
818
- econ2=econ.dropna()
819
- econ_min1,econ_max1=get_df_period(econ2)
820
- sec_min1,sec_max1=get_df_period(sec)
821
- min1=max(econ_min1,sec_min1)
822
- max1=min(econ_max1,sec_max1)
823
- econ3=set_df_period(econ,min1,max1)
824
- sec3=set_df_period(sec,min1,max1)
825
- df1=econ3; df2=sec3
826
-
827
- colname1=econ_growth
828
- #label1=econ_growth
829
- label1="增长率%"
830
- titletxt=ectranslate(scope)+": 经济增长与证券市场的关系"
831
- plot_line2(df1,ectranslate(ticker1),colname1,label1, \
832
- df2,ectranslate(ticker2),colname2,label2, \
833
- ylabeltxt,titletxt,footnote, \
834
- power=0,twinx=True,loc1=loc1,loc2=loc2)
835
- return econ,sec
836
-
837
- if __name__=='__main__':
838
- fromdate='2010-1-1'; todate='2019-12-31'
839
- scope='China'; econ_factor='GDP'; sec_ticker='000001.SS'
840
-
841
- df_cn1=economy_security('China','1995-1-1','2019-12-31','GDP Per Capita','000001.SS')
842
- df_cn2=economy_security('China','1995-1-1','2019-12-31','Constant Price GDP','000001.SS')
843
- df_us1=economy_security('USA','1980-1-1','2019-12-31','GDP','^DJI')
844
- df_us2=economy_security('USA','1980-1-1','2019-12-31','GDP','^GSPC')
845
- #==============================================================================
846
- def get_df_period(df):
847
- """
848
- 功能: 获得df中日期索引的最小最大值
849
- """
850
- df_min=min(df.index)
851
- df_max=max(df.index)
852
- return df_min,df_max
853
-
854
- if __name__=='__main__':
855
- import siat.security_prices as ssp
856
- df=ssp.get_price('AAPL','2020-1-1','2020-1-31')
857
- get_df_period(df)
858
-
859
-
860
- #==============================================================================
861
- #==============================================================================
862
- #==============================================================================
863
-
864
- def fred_factor_codes():
865
- import pandas as pd
866
- s=pd.DataFrame([
867
- # GDP:年度指标,美元现价,未经季节性调整。未扣除通胀因素,含有汇率变化因素
868
- ['China','Current GDP','Annual','Gross Domestic Product','MKTGDPCNA646NWDB','Current USD, Not Seasonally Adjusted'],
869
- ['USA','Current GDP','Annual','Gross Domestic Product','MKTGDPUSA646NWDB','Current USD, Not Seasonally Adjusted'],
870
- ['Japan','Current GDP','Annual','Gross Domestic Product','MKTGDPJPA646NWDB','Current USD, Not Seasonally Adjusted'],
871
- ['India','Current GDP','Annual','Gross Domestic Product','MKTGDPINA646NWDB','Current USD, Not Seasonally Adjusted'],
872
- ['Korea','Current GDP','Annual','Gross Domestic Product','MKTGDPKRA646NWDB','Current USD, Not Seasonally Adjusted'],
873
- ['Russia','Current GDP','Annual','Gross Domestic Product','MKTGDPRUA646NWDB','Current USD, Not Seasonally Adjusted'],
874
- ['Singapore','Current GDP','Annual','Gross Domestic Product','MKTGDPSGA646NWDB','Current USD, Not Seasonally Adjusted'],
875
- ['Malaysia','Current GDP','Annual','Gross Domestic Product','MKTGDPMYA646NWDB','Current USD, Not Seasonally Adjusted'],
876
- ['Indonesia','Current GDP','Annual','Gross Domestic Product','MKTGDPIDA646NWDB','Current USD, Not Seasonally Adjusted'],
877
- ['Vietnam','Current GDP','Annual','Gross Domestic Product','MKTGDPVNA646NWDB','Current USD, Not Seasonally Adjusted'],
878
- ['Thailand','Current GDP','Annual','Gross Domestic Product','MKTGDPTHA646NWDB','Current USD, Not Seasonally Adjusted'],
879
- ['Australia','Current GDP','Annual','Gross Domestic Product','MKTGDPAUA646NWDB','Current USD, Not Seasonally Adjusted'],
880
- ['France','Current GDP','Annual','Gross Domestic Product','MKTGDPFRA646NWDB','Current USD, Not Seasonally Adjusted'],
881
- ['Germany','Current GDP','Annual','Gross Domestic Product','MKTGDPDEA646NWDB','Current USD, Not Seasonally Adjusted'],
882
- ['UK','Current GDP','Annual','Gross Domestic Product','MKTGDPGBA646NWDB','Current USD, Not Seasonally Adjusted'],
883
- ['Israel','Current GDP','Annual','Gross Domestic Product','MKTGDPILA646NWDB','Current USD, Not Seasonally Adjusted'],
884
- ['Italy','Current GDP','Annual','Gross Domestic Product','MKTGDPITA646NWDB','Current USD, Not Seasonally Adjusted'],
885
- ['Cambodia','Current GDP','Annual','Gross Domestic Product','MKTGDPKHA646NWDB','Current USD, Not Seasonally Adjusted'],
886
-
887
- # Real GDP at Constant National Prices:不变价格GDP,年度指标,百万元,2017年基准,未经季节性调整。扣除通胀因素,扣除汇率变化因素
888
- ['India','Constant GDP','Annual','Real GDP at Constant National Prices','RGDPNAINA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
889
- ['China','Constant GDP','Annual','Real GDP at Constant National Prices','RGDPNACNA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
890
- ['Japan','Constant GDP','Annual','Real GDP at Constant National Prices','RGDPNAJPA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
891
- ['Korea','Constant GDP','Annual','Real GDP at Constant National Prices','RGDPNAKRA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
892
- ['Thailand','Constant GDP','Annual','Real GDP at Constant National Prices','RGDPNATHA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
893
- ['Vietnam','Constant GDP','Annual','Real GDP at Constant National Prices','RGDPNAVNA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
894
- ['Cambodia','Constant GDP','Annual','Real GDP at Constant National Prices','RGDPNAKHA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
895
- ['Hong Kong','Constant GDP','Annual','Real GDP at Constant National Prices','RGDPNAHKA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
896
- ['Singapore','Constant GDP','Annual','Real GDP at Constant National Prices','RGDPNASGA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
897
- ['Malaysia','Constant GDP','Annual','Real GDP at Constant National Prices','RGDPNAMYA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
898
- ['Indonesia','Constant GDP','Annual','Real GDP at Constant National Prices','RGDPNAIDA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
899
- ['USA','Constant GDP','Annual','Real GDP at Constant National Prices','RGDPNAUSA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
900
- ['UK','Constant GDP','Annual','Real GDP at Constant National Prices','RGDPNAGBA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
901
- ['France','Constant GDP','Annual','Real GDP at Constant National Prices','RGDPNAFRA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
902
- ['Germany','Constant GDP','Annual','Real GDP at Constant National Prices','RGDPNADEA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
903
- ['Italy','Constant GDP','Annual','Real GDP at Constant National Prices','RGDPNAITA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
904
- ['Israel','Constant GDP','Annual','Real GDP at Constant National Prices','RGDPNAILA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
905
- ['Russia','Constant GDP','Annual','Real GDP at Constant National Prices','RGDPNARUA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
906
- ['Australia','Constant GDP','Annual','Real GDP at Constant National Prices','RGDPNAAUA666NRUG','2017 USD Millions, Not Seasonally Adjusted'],
907
-
908
- # Current Price GDP:季度指标,本币现价,经过季节性调整。未考虑通货膨胀因素,不受汇率变化影响
909
- # 美国的季节性调整调整方法:X-12 Arima
910
- # 季节性调整调整的思路:从当前的变化综扣除过去数年的平均变动,为了回答问题:目前的变化是纯粹的季节性现象,还是说明目前的变化是不寻常的。
911
- ['China','GDP','Quarterly','Current Price Gross Domestic Product','CHNGDPNQDSMEI','Local Currency, Seasonally Adjusted'],
912
- ['Japan','GDP','Quarterly','Current Price Gross Domestic Product','JPNGDPNQDSMEI','Local Currency, Seasonally Adjusted'],
913
- ['USA','GDP','Quarterly','Current Price Gross Domestic Product','USAGDPNQDSMEI','Local Currency, Seasonally Adjusted'],
914
- ['Korea','GDP','Quarterly','Current Price Gross Domestic Product','KORGDPNQDSMEI','Local Currency, Seasonally Adjusted'],
915
- ['Russia','GDP','Quarterly','Current Price Gross Domestic Product','RUSGDPNQDSMEI','Local Currency, Seasonally Adjusted'],
916
- ['India','GDP','Quarterly','Current Price Gross Domestic Product','INDGDPNQDSMEI','Local Currency, Seasonally Adjusted'],
917
- ['France','GDP','Quarterly','Current Price Gross Domestic Product','FRAGDPNQDSMEI','Local Currency, Seasonally Adjusted'],
918
- ['Germany','GDP','Quarterly','Current Price Gross Domestic Product','DEUGDPNQDSMEI','Local Currency, Seasonally Adjusted'],
919
- ['UK','GDP','Quarterly','Current Price Gross Domestic Product','GBRGDPNQDSMEI','Local Currency, Seasonally Adjusted'],
920
- ['Australia','GDP','Quarterly','Current Price Gross Domestic Product','AUSGDPNQDSMEI','Local Currency, Seasonally Adjusted'],
921
-
922
- # Ratio of GNP to GDP:年度指标,百分比%,未经季节性调整
923
- ['China','GNP Ratio','Annual','Ratio of GNP to GDP','GNPGDPCNA156NUPN','Percent, Not Seasonally Adjusted'],
924
- ['USA','GNP Ratio','Annual','Ratio of GNP to GDP','GNPGDPUSA156NUPN','Percent, Not Seasonally Adjusted'],
925
- ['Japan','GNP Ratio','Annual','Ratio of GNP to GDP','GNPGDPJPA156NUPN','Percent, Not Seasonally Adjusted'],
926
-
927
- # GDP Per Capita:人均GDP,年度指标,美元现价,未经季节性调整。未扣除通胀因素,受到汇率变化影响
928
- ['China','GDP Per Capita','Annual','Gross Domestic Product Per Capita','PCAGDPCNA646NWDB','Current USD, Not Seasonally Adjusted'],
929
- ['Japan','GDP Per Capita','Annual','Gross Domestic Product Per Capita','PCAGDPJPA646NWDB','Current USD, Not Seasonally Adjusted'],
930
- ['USA','GDP Per Capita','Annual','Gross Domestic Product Per Capita','PCAGDPUSA646NWDB','Current USD, Not Seasonally Adjusted'],
931
- ['Korea','GDP Per Capita','Annual','Gross Domestic Product Per Capita','PCAGDPKRA646NWDB','Current USD, Not Seasonally Adjusted'],
932
- ['India','GDP Per Capita','Annual','Gross Domestic Product Per Capita','PCAGDPINA646NWDB','Current USD, Not Seasonally Adjusted'],
933
- ['Singapore','GDP Per Capita','Annual','Gross Domestic Product Per Capita','PCAGDPSGA646NWDB','Current USD, Not Seasonally Adjusted'],
934
- ['Malaysia','GDP Per Capita','Annual','Gross Domestic Product Per Capita','PCAGDPMYA646NWDB','Current USD, Not Seasonally Adjusted'],
935
- ['Indonesia','GDP Per Capita','Annual','Gross Domestic Product Per Capita','PCAGDPIDA646NWDB','Current USD, Not Seasonally Adjusted'],
936
- ['Vietnam','GDP Per Capita','Annual','Gross Domestic Product Per Capita','PCAGDPVNA646NWDB','Current USD, Not Seasonally Adjusted'],
937
- ['Thailand','GDP Per Capita','Annual','Gross Domestic Product Per Capita','PCAGDPTHA646NWDB','Current USD, Not Seasonally Adjusted'],
938
- ['Cambodia','GDP Per Capita','Annual','Gross Domestic Product Per Capita','PCAGDPKHA646NWDB','Current USD, Not Seasonally Adjusted'],
939
-
940
- # Constant GDP per capita:不变价格人均GDP,2010年美元基准,未经季节性调整。扣除通胀因素和汇率变化因素
941
- ['China','Constant Price GDP Per Capita','Annual','Constant Price GDP Per Capita','NYGDPPCAPKDCHN','2010 USD, Not Seasonally Adjusted'],
942
- ['USA','Constant Price GDP Per Capita','Annual','Constant Price GDP Per Capita','NYGDPPCAPKDUSA','2010 USD, Not Seasonally Adjusted'],
943
- ['Japan','Constant Price GDP Per Capita','Annual','Constant Price GDP Per Capita','NYGDPPCAPKDJPN','2010 USD, Not Seasonally Adjusted'],
944
- ['Russia','Constant Price GDP Per Capita','Annual','Constant Price GDP Per Capita','NYGDPPCAPKDRUS','2010 USD, Not Seasonally Adjusted'],
945
- ['France','Constant Price GDP Per Capita','Annual','Constant Price GDP Per Capita','NYGDPPCAPKDFRA','2010 USD, Not Seasonally Adjusted'],
946
- ['Germany','Constant Price GDP Per Capita','Annual','Constant Price GDP Per Capita','NYGDPPCAPKDDEU','2010 USD, Not Seasonally Adjusted'],
947
- ['Italy','Constant Price GDP Per Capita','Annual','Constant Price GDP Per Capita','NYGDPPCAPKDITA','2010 USD, Not Seasonally Adjusted'],
948
- ['Singapore','Constant Price GDP Per Capita','Annual','Constant Price GDP Per Capita','NYGDPPCAPKDSGP','2010 USD, Not Seasonally Adjusted'],
949
- ['Malaysia','Constant Price GDP Per Capita','Annual','Constant Price GDP Per Capita','NYGDPPCAPKDMYS','2010 USD, Not Seasonally Adjusted'],
950
- ['Indonesia','Constant Price GDP Per Capita','Annual','Constant Price GDP Per Capita','NYGDPPCAPKDIDN','2010 USD, Not Seasonally Adjusted'],
951
- ['India','Constant Price GDP Per Capita','Annual','Constant Price GDP Per Capita','NYGDPPCAPKDIND','2010 USD, Not Seasonally Adjusted'],
952
-
953
- # CPI相对值%:月度数据,以2015年为基准值100,未经季节性调整
954
- ['China','Constant CPI','Monthly','Consumer Price Index: All Items','CHNCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
955
- ['USA','Constant CPI','Monthly','Consumer Price Index: All Items','USACPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
956
- ['Japan','Constant CPI','Monthly','Consumer Price Index: All Items','JPNCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
957
- ['Korea','Constant CPI','Monthly','Consumer Price Index: All Items','KORCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
958
- ['India','Constant CPI','Monthly','Consumer Price Index: All Items','INDCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
959
- ['France','Constant CPI','Monthly','Consumer Price Index: All Items','FRACPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
960
- ['Germany','Constant CPI','Monthly','Consumer Price Index: All Items','DEUCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
961
- ['Australia','Constant CPI','Monthly','Consumer Price Index: All Items','AUSCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
962
- ['UK','Constant CPI','Monthly','Consumer Price Index: All Items','GBRCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
963
- ['Italy','Constant CPI','Monthly','Consumer Price Index: All Items','ITACPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
964
- ['Spain','Constant CPI','Monthly','Consumer Price Index: All Items','ESPCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
965
- ['Russia','Constant CPI','Monthly','Consumer Price Index: All Items','RUSCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
966
- ['Indonesia','Constant CPI','Monthly','Consumer Price Index: All Items','IDNCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
967
- ['Israel','Constant CPI','Monthly','Consumer Price Index: All Items','ISRCPIALLMINMEI','Index 2015=100, Not Seasonally Adjusted'],
968
-
969
-
970
- # CPI环比%:月度数据,未经季节性调整
971
- ['USA','MoM CPI','Monthly','Consumer Price Index: All Items Growth Rate','CPALTT01USM657N','Growth Rate Previous Period, Not Seasonally Adjusted'],
972
- ['China','MoM CPI','Monthly','Consumer Price Index: All Items Growth Rate','CPALTT01CNM657N','Growth Rate Previous Period, Not Seasonally Adjusted'],
973
- ['Japan','MoM CPI','Monthly','Consumer Price Index: All Items Growth Rate','CPALTT01USM657N','Growth Rate Previous Period, Not Seasonally Adjusted'],
974
- ['Korea','MoM CPI','Monthly','Consumer Price Index: All Items Growth Rate','CPALTT01KRM657N','Growth Rate Previous Period, Not Seasonally Adjusted'],
975
- ['Russia','MoM CPI','Monthly','Consumer Price Index: All Items Growth Rate','CPALTT01RUM657N','Growth Rate Previous Period, Not Seasonally Adjusted'],
976
- ['India','MoM CPI','Monthly','Consumer Price Index: All Items Growth Rate','CPALTT01INM657N','Growth Rate Previous Period, Not Seasonally Adjusted'],
977
- ['France','MoM CPI','Monthly','Consumer Price Index: All Items Growth Rate','CPALTT01FRM657N','Growth Rate Previous Period, Not Seasonally Adjusted'],
978
- ['Germany','MoM CPI','Monthly','Consumer Price Index: All Items Growth Rate','CPALTT01DEM657N','Growth Rate Previous Period, Not Seasonally Adjusted'],
979
- ['Canada','MoM CPI','Monthly','Consumer Price Index: All Items Growth Rate','CPALTT01CAM657N','Growth Rate Previous Period, Not Seasonally Adjusted'],
980
- ['UK','MoM CPI','Monthly','Consumer Price Index: All Items Growth Rate','CPALTT01GBM657N','Growth Rate Previous Period, Not Seasonally Adjusted'],
981
-
982
- # PPI相对值%:月度数据,以2015年为基准,未经季节性调整
983
- ['Sweden','Constant PPI','Monthly','Producer Prices Index: Total Industrial Activities','PIEATI01SEM661N','Index 2015=100, Not Seasonally Adjusted'],
984
- ['Spain','Constant PPI','Monthly','Producer Prices Index: Total Industrial Activities','PIEATI01ESM661N','Index 2015=100, Not Seasonally Adjusted'],
985
- ['UK','Constant PPI','Monthly','Producer Prices Index: Total Industrial Activities','PIEATI01GBM661N','Index 2015=100, Not Seasonally Adjusted'],
986
- ['Italy','Constant PPI','Monthly','Producer Prices Index: Total Industrial Activities','PIEATI01ITM661N','Index 2015=100, Not Seasonally Adjusted'],
987
- ['Euro Area','Constant PPI','Monthly','Producer Prices Index: Total Industrial Activities','PIEATI01EZM661N','Index 2015=100, Not Seasonally Adjusted'],
988
- ['Switzerland','Constant PPI','Monthly','Producer Prices Index: Total Industrial Activities','PIEATI01CHM661N','Index 2015=100, Not Seasonally Adjusted'],
989
- ['France','Constant PPI','Monthly','Producer Prices Index: Total Industrial Activities','PIEATI01FRM661N','Index 2015=100, Not Seasonally Adjusted'],
990
- ['Germany','Constant PPI','Monthly','Producer Prices Index: Total Industrial Activities','PIEATI01DEM661N','Index 2015=100, Not Seasonally Adjusted'],
991
- ['USA','Constant PPI','Monthly','Producer Prices Index: Total Industrial Activities','PIEAMP01USM661N','Index 2015=100, Not Seasonally Adjusted'],
992
- ['Mexico','Constant PPI','Monthly','Producer Prices Index: Total Industrial Activities','PIEATI02MXM661N','Index 2015=100, Not Seasonally Adjusted'],
993
- ['Japan','Constant PPI','Monthly','Producer Prices Index: Total Industrial Activities','PIEATI02JPM661N','Index 2015=100, Not Seasonally Adjusted'],
994
- ['Korea','Constant PPI','Monthly','Producer Prices Index: Total Industrial Activities','PIEATI02KRM661N','Index 2015=100, Not Seasonally Adjusted'],
995
- ['Russia','Constant PPI','Monthly','Producer Prices Index: Total Industrial Activities','PIEATI02RUM661N','Index 2015=100, Not Seasonally Adjusted'],
996
- ['Canada','Constant PPI','Monthly','Producer Prices Index: Total Industrial Activities','PIEAMP01CAM661N','Index 2015=100, Not Seasonally Adjusted'],
997
-
998
- # PPI China相对值%, up to 2015 & Annual only
999
- ['China','Constant PPI','Annual','Producer Prices Index: Total Industrial Activities','PIEATI01CNA661N','Index 2015=100, Not Seasonally Adjusted'],
1000
-
1001
- # PPI同比%:月度数据,未经季节性调整
1002
- ['China','YoY PPI','Monthly','Producer Prices Index: Industrial Activities','CHNPIEATI01GYM','Growth rate same period previous year, Not Seasonally Adjusted'],
1003
- ['UK','YoY PPI','Monthly','Producer Prices Index: Industrial Activities','GBRPIEATI01GYM','Growth rate same period previous year, Not Seasonally Adjusted'],
1004
- ['France','YoY PPI','Monthly','Producer Prices Index: Industrial Activities','FRAPIEATI01GYM','Growth rate same period previous year, Not Seasonally Adjusted'],
1005
- ['Germany','YoY PPI','Monthly','Producer Prices Index: Industrial Activities','DEUPIEATI01GYM','Growth rate same period previous year, Not Seasonally Adjusted'],
1006
- ['Japan','YoY PPI','Monthly','Producer Prices Index: Industrial Activities','JPNPIEATI02GYM','Growth rate same period previous year, Not Seasonally Adjusted'],
1007
- ['Korea','YoY PPI','Monthly','Producer Prices Index: Industrial Activities','KORPIEATI02GYM','Growth rate same period previous year, Not Seasonally Adjusted'],
1008
- ['Italy','YoY PPI','Monthly','Producer Prices Index: Industrial Activities','ITAPIEATI01GYM','Growth rate same period previous year, Not Seasonally Adjusted'],
1009
- ['Spain','YoY PPI','Monthly','Producer Prices Index: Industrial Activities','ITAPIEATI01GYM','Growth rate same period previous year, Not Seasonally Adjusted'],
1010
- ['Poland','YoY PPI','Monthly','Producer Prices Index: Industrial Activities','POLPIEATI01GYM','Growth rate same period previous year, Not Seasonally Adjusted'],
1011
- ['USA','YoY PPI','Monthly','Producer Prices Index: Industrial Activities','PIEAMP02USM659N','Growth rate same period previous year, Not Seasonally Adjusted'],
1012
-
1013
- # Interest rate, Discount rate:中央银行贴现率,央行给予商业银行的短期贷款利率。月度数据,年华利率%,未经季节性调整
1014
- ['China','Discount Rate','Monthly','Central Bank Discount Rate','INTDSRCNM193N','Percent per Annum, Not Seasonally Adjusted'],
1015
- ['USA','Discount Rate','Monthly','Central Bank Discount Rate','INTDSRUSM193N','Percent per Annum, Not Seasonally Adjusted'],
1016
- ['India','Discount Rate','Monthly','Central Bank Discount Rate','INTDSRINM193N','Percent per Annum, Not Seasonally Adjusted'],
1017
- ['Japan','Discount Rate','Monthly','Central Bank Discount Rate','INTDSRJPM193N','Percent per Annum, Not Seasonally Adjusted'],
1018
- ['Korea','Discount Rate','Monthly','Central Bank Discount Rate','INTDSRKRM193N','Percent per Annum, Not Seasonally Adjusted'],
1019
- ['Brazil','Discount Rate','Monthly','Central Bank Discount Rate','INTDSRBRM193N','Percent per Annum, Not Seasonally Adjusted'],
1020
-
1021
- # Immediate Interest rate, less than 24 hours, interbank rate:即期利率%,银行间同业拆借利率,隔夜利率。月度数据,未经季节性调整
1022
- ['China','Immediate Rate','Monthly','Immediate Rates: Less than 24 Hours: Interbank Rate','IRSTCI01CNM156N','Percent per Annum, Not Seasonally Adjusted'],
1023
- ['USA','Immediate Rate','Monthly','Immediate Rates: Less than 24 Hours: Interbank Rate','IRSTCI01USM156N','Percent per Annum, Not Seasonally Adjusted'],
1024
- ['Japan','Immediate Rate','Monthly','Immediate Rates: Less than 24 Hours: Interbank Rate','IRSTCI01JPM156N','Percent per Annum, Not Seasonally Adjusted'],
1025
- ['Korea','Immediate Rate','Monthly','Immediate Rates: Less than 24 Hours: Interbank Rate','IRSTCI01KRM156N','Percent per Annum, Not Seasonally Adjusted'],
1026
- ['India','Immediate Rate','Monthly','Immediate Rates: Less than 24 Hours: Interbank Rate','IRSTCI01INM156N','Percent per Annum, Not Seasonally Adjusted'],
1027
- ['France','Immediate Rate','Monthly','Immediate Rates: Less than 24 Hours: Interbank Rate','IRSTCI01FRM156N','Percent per Annum, Not Seasonally Adjusted'],
1028
- ['Germany','Immediate Rate','Monthly','Immediate Rates: Less than 24 Hours: Interbank Rate','IRSTCI01DEM156N','Percent per Annum, Not Seasonally Adjusted'],
1029
- ['Australia','Immediate Rate','Monthly','Immediate Rates: Less than 24 Hours: Interbank Rate','IRSTCI01AUM156N','Percent per Annum, Not Seasonally Adjusted'],
1030
- ['Indonesia','Immediate Rate','Monthly','Immediate Rates: Less than 24 Hours: Interbank Rate','IRSTCI01IDM156N','Percent per Annum, Not Seasonally Adjusted'],
1031
- ['Russia','Immediate Rate','Monthly','Immediate Rates: Less than 24 Hours: Interbank Rate','IRSTCI01RUM156N','Percent per Annum, Not Seasonally Adjusted'],
1032
-
1033
- ['LIBOR','Immediate Rate','Daily','Overnight London Interbank Offered Rate, based on USD','USDONTD156N','Percent per Annum, Not Seasonally Adjusted'],
1034
- ['UK','LIBOR','Daily','Overnight London Interbank Offered Rate, based on USD','USDONTD156N','Percent per Annum, Not Seasonally Adjusted'],
1035
-
1036
- # Spot Exchange Rate:即期汇率,本币/1USD。每日数据,未经季节性调整
1037
- ['China','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXCHUS','Chinese Yuan/1 US$, Not Seasonally Adjusted'],
1038
- ['Japan','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXJPUS','Japanese Yen/1 US$, Not Seasonally Adjusted'],
1039
- ['Korea','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXKOUS','South Korea Won/1 US$, Not Seasonally Adjusted'],
1040
- ['Singapore','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXSIUS','Singapore Dollars/1 US$, Not Seasonally Adjusted'],
1041
- ['China Hong Kong','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXHKUS','HK Dollars/1 US$, Not Seasonally Adjusted'],
1042
- ['Australia','Exchange Rate','Daily','USD/Local Currency Foreign Exchange Rate','DEXUSAL','US Dollars/1 Australian Dollar, Not Seasonally Adjusted'],
1043
- ['Euro','Exchange Rate','Daily','USD/Local Currency Foreign Exchange Rate','DEXUSEU','US Dollars/1 Euro, Not Seasonally Adjusted'],
1044
- ['India','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXINUS','Indian Rupees/1 US$, Not Seasonally Adjusted'],
1045
- ['UK','Exchange Rate','Daily','USD/Local Currency Foreign Exchange Rate','DEXUSUK','US Dollars/1 British Pound, Not Seasonally Adjusted'],
1046
- ['Canada','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXCAUS','Canadian Dollars/1 US$, Not Seasonally Adjusted'],
1047
- ['Mexico','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXMXUS','Mexican New Pesos/1 US$, Not Seasonally Adjusted'],
1048
- ['Brazil','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXBZUS','Brazilian Reals/1 US$, Not Seasonally Adjusted'],
1049
- ['Venezuela','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXVZUS','Venezuelan Bolivares/1 US$, Not Seasonally Adjusted'],
1050
- ['South Africa','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXSFUS','South African Rand/1 US$, Not Seasonally Adjusted'],
1051
- ['Sweden','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXSDUS','Swedish Kronor/1 US$, Not Seasonally Adjusted'],
1052
- ['Thailand','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXTHUS','Thai Baht/1 US$, Not Seasonally Adjusted'],
1053
- ['New Zealand','Exchange Rate','Daily','USD/Local Currency Foreign Exchange Rate','DEXUSNZ','US Dollars/1 New Zealand Dollar, Not Seasonally Adjusted'],
1054
- ['China Taiwan','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXTAUS','New Taiwan Dollars/1 US$, Not Seasonally Adjusted'],
1055
- ['Malaysia','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXMAUS','Malaysian Ringgit/1 US$, Not Seasonally Adjusted'],
1056
- ['Denmark','Exchange Rate','Daily','Local Currency/USD Foreign Exchange Rate','DEXDNUS','Danish Kroner/1 US$, Not Seasonally Adjusted'],
1057
-
1058
- # M0,本币,月度数据,未经季节性调整,discontinued
1059
- ['China','M0','Monthly','National Monetary Supply M0','MYAGM0CNM189N','National Currency, Seasonally Adjusted'],
1060
-
1061
- # M1,本币,月度数据,经季节性调整,discontinued
1062
- ['China','M1','Monthly','National Monetary Supply M1','MANMM101CNM189S','National Currency, Seasonally Adjusted'],
1063
- ['USA','M1','Monthly','National Monetary Supply M1','MANMM101USM189S','National Currency, Seasonally Adjusted'],
1064
- ['Japan','M1','Monthly','National Monetary Supply M1','MANMM101JPM189S','National Currency, Seasonally Adjusted'],
1065
- ['Euro Area','M1','Monthly','Euro Area Monetary Supply M1','MANMM101EZM189S','National Currency, Seasonally Adjusted'],
1066
- ['Korea','M1','Monthly','National Monetary Supply M1','MANMM101KRM189S','National Currency, Seasonally Adjusted'],
1067
- ['India','M1','Monthly','National Monetary Supply M1','MANMM101INM189S','National Currency, Seasonally Adjusted'],
1068
-
1069
- # M2,本币,月度数据,未经季节性调整,discontinued
1070
- ['China','M2','Monthly','National Monetary Supply M2','MYAGM2CNM189N','National Currency, Not Seasonally Adjusted'],
1071
- ['Japan','M2','Monthly','National Monetary Supply M2','MYAGM2JPM189N','National Currency, Seasonally Adjusted'],
1072
- ['Korea','M2','Monthly','National Monetary Supply M2','MYAGM2KRM189N','National Currency, Not Seasonally Adjusted'],
1073
- ['France','M2','Monthly','National Monetary Supply M2','MYAGM2FRM189N','National Currency, Not Seasonally Adjusted'],
1074
- ['Italy','M2','Monthly','National Monetary Supply M2','MYAGM2ITM189N','National Currency, Not Seasonally Adjusted'],
1075
- ['Russia','M2','Monthly','National Monetary Supply M2','MYAGM2RUM189N','National Currency, Not Seasonally Adjusted'],
1076
- ['Indonesia','M2','Monthly','National Monetary Supply M2','MYAGM2IDM189N','National Currency, Not Seasonally Adjusted'],
1077
- ['Brazil','M2','Monthly','National Monetary Supply M2','MYAGM2BRM189N','National Currency, Not Seasonally Adjusted'],
1078
- ['USA','M2','Monthly','National Monetary Supply M2','M2NS','Billions of Dollars, Not Seasonally Adjusted'],
1079
-
1080
- # M3,本币,月度数据,经季节性调整,discontinued
1081
- ['China','M3','Monthly','National Monetary Supply M3','MABMM301CNM189S','National Currency, Seasonally Adjusted'],
1082
- ['USA','M3','Monthly','National Monetary Supply M3','MABMM301USM189S','National Currency, Seasonally Adjusted'],
1083
- ['Japan','M3','Monthly','National Monetary Supply M3','MABMM301JPM189S','National Currency, Seasonally Adjusted'],
1084
- ['UK','M3','Monthly','National Monetary Supply M3','MABMM301GBM189S','National Currency, Seasonally Adjusted'],
1085
- ['Euro Area','M3','Monthly','Euro Area Monetary Supply M3','MABMM301EZM189S','National Currency, Seasonally Adjusted'],
1086
- ['Australia','M3','Monthly','National Monetary Supply M3','MABMM301AUM189S','National Currency, Seasonally Adjusted'],
1087
-
1088
- # Stock Market Cap to GDP:股票市场市值对GDP比率%,年度数据,未经季节性调整,discontinued
1089
- ['China','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01CNA156NWDB','Percent, Not Seasonally Adjusted'],
1090
- ['USA','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01USA156NWDB','Percent, Not Seasonally Adjusted'],
1091
- ['Japan','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01JPA156NWDB','Percent, Not Seasonally Adjusted'],
1092
- ['Korea','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01KRA156NWDB','Percent, Not Seasonally Adjusted'],
1093
- ['India','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01INA156NWDB','Percent, Not Seasonally Adjusted'],
1094
- ['Singapore','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01SGA156NWDB','Percent, Not Seasonally Adjusted'],
1095
- ['Malaysia','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01MYA156NWDB','Percent, Not Seasonally Adjusted'],
1096
- ['Indonesia','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01IDA156NWDB','Percent, Not Seasonally Adjusted'],
1097
- ['Vietnam','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01VNA156NWDB','Percent, Not Seasonally Adjusted'],
1098
- ['China Hong Kong','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01HKA156NWDB','Percent, Not Seasonally Adjusted'],
1099
- ['France','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01FRA156NWDB','Percent, Not Seasonally Adjusted'],
1100
- ['Germany','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01DEA156NWDB','Percent, Not Seasonally Adjusted'],
1101
- ['UK','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01GBA156NWDB','Percent, Not Seasonally Adjusted'],
1102
- ['Italy','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01ITA156NWDB','Percent, Not Seasonally Adjusted'],
1103
- ['Spain','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01ESA156NWDB','Percent, Not Seasonally Adjusted'],
1104
- ['Israel','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01ILA156NWDB','Percent, Not Seasonally Adjusted'],
1105
- ['Canada','SMC to GDP','Annual','Stock Market Capitalization to GDP','DDDM01CAA156NWDB','Percent, Not Seasonally Adjusted'],
1106
-
1107
- # 消费者信心综合指数:OECD。月度数据,基准=100,经季节性调整
1108
- ['China','Consumer Confidence','Monthly','Consumer Confidence Composite Indicator by OECD','CSCICP03CNM665S','Normalised (Normal=100), Seasonally Adjusted'],
1109
- ['USA','Consumer Confidence','Monthly','Consumer Confidence Composite Indicator by OECD','CSCICP03USM665S','Normalised (Normal=100), Seasonally Adjusted'],
1110
- ['Japan','Consumer Confidence','Monthly','Consumer Confidence Composite Indicator by OECD','CSCICP03JPM665S','Normalised (Normal=100), Seasonally Adjusted'],
1111
- ['Korea','Consumer Confidence','Monthly','Consumer Confidence Composite Indicator by OECD','CSCICP03KRM665S','Normalised (Normal=100), Seasonally Adjusted'],
1112
- ['Indonesia','Consumer Confidence','Monthly','Consumer Confidence Composite Indicator by OECD','CSCICP03IDM665S','Normalised (Normal=100), Seasonally Adjusted'],
1113
- ['France','Consumer Confidence','Monthly','Consumer Confidence Composite Indicator by OECD','CSCICP03FRM665S','Normalised (Normal=100), Seasonally Adjusted'],
1114
- ['Germany','Consumer Confidence','Monthly','Consumer Confidence Composite Indicator by OECD','CSCICP03DEM665S','Normalised (Normal=100), Seasonally Adjusted'],
1115
- ['Italy','Consumer Confidence','Monthly','Consumer Confidence Composite Indicator by OECD','CSCICP03ITM665S','Normalised (Normal=100), Seasonally Adjusted'],
1116
- ['Spain','Consumer Confidence','Monthly','Consumer Confidence Composite Indicator by OECD','CSCICP03ESM665S','Normalised (Normal=100), Seasonally Adjusted'],
1117
-
1118
- # Crude Birth Rate粗出生率;又称出生率。指1年内平均每千人的出生人数。它反映一定时期内人口的出生水平。年度数据,未经季节性调整
1119
- ['China','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTINCHN','Births per 1,000 People, Not Seasonally Adjusted'],
1120
- ['USA','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTINUSA','Births per 1,000 People, Not Seasonally Adjusted'],
1121
- ['Japan','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTINJPN','Births per 1,000 People, Not Seasonally Adjusted'],
1122
- ['Korea','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTINKOR','Births per 1,000 People, Not Seasonally Adjusted'],
1123
- ['France','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTINFRA','Births per 1,000 People, Not Seasonally Adjusted'],
1124
- ['Germany','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTINDEU','Births per 1,000 People, Not Seasonally Adjusted'],
1125
- ['India','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTININD','Births per 1,000 People, Not Seasonally Adjusted'],
1126
- ['Indonesia','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTINIDN','Births per 1,000 People, Not Seasonally Adjusted'],
1127
- ['Singapore','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTINSGP','Births per 1,000 People, Not Seasonally Adjusted'],
1128
- ['Vietnam','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTINVNM','Births per 1,000 People, Not Seasonally Adjusted'],
1129
- ['Pakistan','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTINPAK','Births per 1,000 People, Not Seasonally Adjusted'],
1130
- ['Cambodia','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTINKHM','Births per 1,000 People, Not Seasonally Adjusted'],
1131
- ['Malaysia','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTINMYS','Births per 1,000 People, Not Seasonally Adjusted'],
1132
- ['Australia','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTINAUS','Births per 1,000 People, Not Seasonally Adjusted'],
1133
- ['Italy','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTINITA','Births per 1,000 People, Not Seasonally Adjusted'],
1134
- ['Spain','Birth Rate','Annual','Crude Birth Rate','SPDYNCBRTINESP','Births per 1,000 People, Not Seasonally Adjusted'],
1135
-
1136
- # Population Growth人口增长率;年出生率的变化率%。年度数据,未经季节性调整
1137
- ['China','Population Growth','Annual','Population Growth by WB','SPPOPGROWCHN','Percent Change at Annual Rate, NSA'],
1138
- ['USA','Population Growth','Annual','Population Growth by WB','SPPOPGROWUSA','Percent Change at Annual Rate, NSA'],
1139
- ['Japan','Population Growth','Annual','Population Growth by WB','SPPOPGROWJPN','Percent Change at Annual Rate, NSA'],
1140
- ['Korea','Population Growth','Annual','Population Growth by WB','SPPOPGROWKOR','Percent Change at Annual Rate, NSA'],
1141
- ['India','Population Growth','Annual','Population Growth by WB','SPPOPGROWIND','Percent Change at Annual Rate, NSA'],
1142
-
1143
- # 青年人失业率%:WB。年度数据,未经季节性调整
1144
- ['China','Youth Unemployment','Annual','Youth Unemployment Rate by WB','SLUEM1524ZSCHN','Percent(Age 15-24, seeking employment), NSA'],
1145
- ['USA','Youth Unemployment','Annual','Youth Unemployment Rate by WB','SLUEM1524ZSUSA','Percent(Age 15-24, seeking employment), NSA'],
1146
- ['Japan','Youth Unemployment','Annual','Youth Unemployment Rate by WB','SLUEM1524ZSJPN','Percent(Age 15-24, seeking employment), NSA'],
1147
- ['Korea','Youth Unemployment','Annual','Youth Unemployment Rate by WB','SLUEM1524ZSKOR','Percent(Age 15-24, seeking employment), NSA'],
1148
- ['India','Youth Unemployment','Annual','Youth Unemployment Rate by WB','SLUEM1524ZSIND','Percent(Age 15-24, seeking employment), NSA'],
1149
-
1150
- # 国民总收入GNI: Gross National Income。美元现价,年度数据,未经季节性调整
1151
- ['China','GNI','Annual','Gross National Income','MKTGNICNA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
1152
- ['USA','GNI','Annual','Gross National Income','MKTGNIUSA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
1153
- ['Japan','GNI','Annual','Gross National Income','MKTGNIJPA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
1154
- ['Korea','GNI','Annual','Gross National Income','MKTGNIKRA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
1155
- ['India','GNI','Annual','Gross National Income','MKTGNIINA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
1156
- ['Vietnam','GNI','Annual','Gross National Income','MKTGNIVNA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
1157
- ['Thailand','GNI','Annual','Gross National Income','MKTGNITHA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
1158
- ['Cambodia','GNI','Annual','Gross National Income','MKTGNIKHA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
1159
- ['China Hong Kong','GNI','Annual','Gross National Income','MKTGNIHKA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
1160
- ['Malaysia','GNI','Annual','Gross National Income','MKTGNIMYA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
1161
- ['Singapore','GNI','Annual','Gross National Income','MKTGNISGA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
1162
- ['Indonesia','GNI','Annual','Gross National Income','MKTGNIIDA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
1163
- ['Australia','GNI','Annual','Gross National Income','MKTGNIAUA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
1164
- ['New Zealand','GNI','Annual','Gross National Income','MKTGNINZA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
1165
- ['UK','GNI','Annual','Gross National Income','MKTGNIGBA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
1166
- ['Germany','GNI','Annual','Gross National Income','MKTGNIDEA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
1167
- ['France','GNI','Annual','Gross National Income','MKTGNIFRA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
1168
- ['Spain','GNI','Annual','Gross National Income','MKTGNIESA646NWDB','Current U.S. Dollars, Not Seasonally Adjusted'],
1169
-
1170
- # 出口对进口的比例Exports to Imports%:月度数据,经季节性调整。美国的季节性调整调整方法:X-12 Arima
1171
- # 季节性调整调整的思路:从目前的变化综扣除过去数年的平均变动,为了回答问题:目前的变化是纯粹的季节性现象,还是说明目前的变化是不寻常的。
1172
- ['China','Exports to Imports','Monthly','Ratio of Exports to Imports','XTEITT01CNM156S','Percent, Seasonally Adjusted'],
1173
- ['India','Exports to Imports','Monthly','Ratio of Exports to Imports','XTEITT01INM156N','Percent, Seasonally Adjusted'],
1174
- ['Brazil','Exports to Imports','Monthly','Ratio of Exports to Imports','XTEITT01BRM156S','Percent, Seasonally Adjusted'],
1175
- ['Russia','Exports to Imports','Monthly','Ratio of Exports to Imports','XTEITT01RUM156S','Percent, Seasonally Adjusted'],
1176
- ['Indonesia','Exports to Imports','Monthly','Ratio of Exports to Imports','XTEITT01IDM156S','Percent, Seasonally Adjusted'],
1177
-
1178
- # 人口受雇比例:就业比率%,年度数据,未经季节性调整
1179
- ['China','Employment to Population','Annual','Employment to Population Ratio by WB','SLEMPTOTLSPZSCHN','Percent, Not Seasonally Adjusted'],
1180
- ['USA','Employment to Population','Annual','Employment to Population Ratio by WB','SLEMPTOTLSPZSUSA','Percent, Not Seasonally Adjusted'],
1181
- ['Japan','Employment to Population','Annual','Employment to Population Ratio by WB','SLEMPTOTLSPZSJPN','Percent, Not Seasonally Adjusted'],
1182
- ['Korea','Employment to Population','Annual','Employment to Population Ratio by WB','SLEMPTOTLSPZSKOR','Percent, Not Seasonally Adjusted'],
1183
- ['India','Employment to Population','Annual','Employment to Population Ratio by WB','SLEMPTOTLSPZSIND','Percent, Not Seasonally Adjusted'],
1184
-
1185
- # 人口总数Population:年度数据,未经季节性调整
1186
- ['China','Population','Annual','Total Population','POPTOTCNA647NWDB','Persons, Not Seasonally Adjusted'],
1187
- ['USA','Population','Annual','Total Population','POPTOTUSA647NWDB','Persons, Not Seasonally Adjusted'],
1188
- ['Japan','Population','Annual','Total Population','POPTOTJPA647NWDB','Persons, Not Seasonally Adjusted'],
1189
- ['Korea','Population','Annual','Total Population','POPTOTKRA647NWDB','Persons, Not Seasonally Adjusted'],
1190
- ['India','Population','Annual','Total Population','POPTOTINA647NWDB','Persons, Not Seasonally Adjusted'],
1191
-
1192
- # 其他
1193
- ], columns=['scope','factor','freq','name','symbol','units'])
1194
-
1195
- return s
1196
-
1197
-
1198
- #==============================================================================
1199
- #==============================================================================
1200
- #==============================================================================
1201
- #==============================================================================
1202
- if __name__ =="__main__":
1203
- fromdate='2024-1-1'
1204
- todate='2024-8-31'
1205
- df=pmi_china(fromdate,todate)
1206
- loc='best'; facecolor='papayawhip'
1207
-
1208
- def pmi_china(fromdate,todate,date_range=True,loc='best',facecolor='papayawhip'):
1209
- """
1210
- 功能:绘制中国的PMI指数制造业/非制造业单线图
1211
- """
1212
- #检查日期期间的合理性
1213
- valid,start,end=check_period(fromdate,todate)
1214
- if not valid:
1215
- print(' Error(pmi_china): period not valid:',fromdate,todate)
1216
- return None
1217
-
1218
- #日期变换,将日都重置为每月的第一日
1219
- year=start.year
1220
- month=start.month
1221
- fromdate1=str(year)+'-'+str(month)+'-'+'1'
1222
-
1223
- year=end.year
1224
- month=end.month
1225
- todate1=str(year)+'-'+str(month)+'-'+'1'
1226
- _,start,end=check_period(fromdate1,todate1)
1227
-
1228
- #获取PMI数据
1229
- import akshare as ak
1230
- df = ak.macro_china_pmi()
1231
-
1232
- #截取日期区间数据
1233
- import pandas as pd
1234
- df['date']=pd.to_datetime(df['月份'],format='%Y年%m月份')
1235
- from datetime import timedelta
1236
- df['date']=df['date'].apply(lambda x:x+timedelta(days=15))
1237
-
1238
- df.set_index('date',inplace=True)
1239
- df1=df[df.index >= start]
1240
- df2=df1[df1.index <= end]
1241
-
1242
- #形成水平50线
1243
- df2['benchmark']=50
1244
-
1245
- #将字符串表示的数值转换为数值型,否则绘图很乱
1246
- df2['制造业PMI']=df2['制造业-指数'].astype('float')
1247
- df2['非制造业PMI']=df2['非制造业-指数'].astype('float')
1248
-
1249
- """
1250
- #绘图:制造业
1251
- ticker1=ticker2='PMI'
1252
- colname2="benchmark"
1253
- label2="景气/衰退分界线"
1254
- ylabeltxt=''
1255
-
1256
- import datetime
1257
- today=datetime.date.today()
1258
- footnote="数据来源:东方财富,"+str(today)
1259
-
1260
- colname1="制造业PMI"
1261
- label1="制造业"
1262
- titletxt="中国采购经理人指数PMI:制造业"
1263
- plot_line2(df2,ticker1,colname1,label1, \
1264
- df2,ticker2,colname2,label2, \
1265
- ylabeltxt,titletxt,footnote,loc1=loc,facecolor=facecolor)
1266
-
1267
- #绘图:非制造业
1268
- colname1="非制造业PMI"
1269
- label1="非制造业"
1270
- titletxt="中国采购经理人指数PMI:非制造业"
1271
- plot_line2(df2,ticker1,colname1,label1, \
1272
- df2,ticker2,colname2,label2, \
1273
- ylabeltxt,titletxt,footnote,loc1=loc,facecolor=facecolor)
1274
- """
1275
- titletxt="中国采购经理人指数PMI"
1276
- ticker1=ticker2='PMI'
1277
- colname1="制造业PMI"; label1="制造业"
1278
- colname2="非制造业PMI"; label2="非制造业"
1279
- ylabeltxt=''
1280
-
1281
- import datetime
1282
- today=datetime.date.today()
1283
- footnote="数据来源:东方财富,"+str(today)
1284
-
1285
- plot2_line2(df2,ticker1,colname1,label1, \
1286
- df2,ticker2,colname2,label2, \
1287
- yline=50, \
1288
- ylabeltxt=ylabeltxt,titletxt=titletxt,footnote=footnote,loc1=loc, \
1289
- date_range=date_range,date_fmt='%Y-%m',facecolor=facecolor)
1290
-
1291
- #返回数据
1292
- return df2
1293
-
1294
- #==============================================================================
1295
- #==============================================================================
1296
- #==============================================================================
1297
- if __name__ =="__main__":
1298
- fieldlist=['VALUE','scope','factor','freq','name','units']
1299
-
1300
- def internal_growth_rate_df(df0,fieldlist=['VALUE','scope','factor','freq','name','units']):
1301
- """
1302
- 功能:计算内部增长率IRR
1303
- rdf的结构:VALUE为具体的数值,scope为国家或地区,factor为指标,freq为频度。
1304
- """
1305
- if df0 is None:
1306
- print(" #Error(internal_growth_rate_df): no data provided")
1307
- return
1308
-
1309
- df=df0.copy()
1310
- df.dropna(inplace=True)
1311
-
1312
- fld_value=fieldlist[0]
1313
- fld_scope=fieldlist[1]
1314
- scope=df[fld_scope][0]
1315
-
1316
- fld_factor=fieldlist[2]
1317
- factor=df[fld_factor][0]
1318
-
1319
- fld_freq=fieldlist[3]
1320
- freq=df[fld_freq][0]
1321
-
1322
- fld_name=fieldlist[4]
1323
- fld_units=fieldlist[5]
1324
-
1325
- #开始值和结束值
1326
- value0=df[fld_value][0]
1327
- value1=df[fld_value][-1]
1328
- num=len(df)
1329
- item_gr=pow(value1/value0,1/num)-1.0
1330
-
1331
- annual_gr=item_gr
1332
- if freq == 'Daily':
1333
- annual_gr=pow(1+item_gr,365)-1.0
1334
- if freq == 'Monthly':
1335
- annual_gr=pow(1+item_gr,12)-1.0
1336
- if freq == 'Quarterly':
1337
- annual_gr=pow(1+item_gr,4)-1.0
1338
-
1339
- #计算期间
1340
- date0=str(df.index[0].year)
1341
- date1=str(df.index[-1].year)
1342
-
1343
- if freq in ['Monthly','Daily']:
1344
- date0=date0+'-'+str(df.index[0].month)+''
1345
- date1=date1+'-'+str(df.index[-1].month)+''
1346
-
1347
- if freq in ['Daily']:
1348
- date0=date0+'-'+str(df.index[0].day)+'日'
1349
- date1=date1+'-'+str(df.index[-1].day)+'日'
1350
-
1351
- #显示增长率
1352
- lang=check_language()
1353
- #print('\n')
1354
- if lang == 'Chinese':
1355
- print('从'+date0+'至'+date1+':')
1356
- if freq != 'Annual':
1357
- print(' '+ectranslate(scope)+ectranslate(factor)+'的'+ectranslate(freq)+'均环比复合增长率:',round(item_gr*100.0,4),'\b%')
1358
- print(' '+ectranslate(scope)+ectranslate(factor)+'的年均复合增长率:',round(annual_gr*100.0,4),'\b%')
1359
- else:
1360
- print('From '+date0+' to '+date1+':')
1361
- if freq != 'Annual':
1362
- print(' '+scope+', '+factor+' mom compound growth rate:',round(item_gr*100.0,4),'\b%')
1363
- print(' '+scope+', '+factor+' yoy compound growth rate:',round(annual_gr*100.0,4),'\b%')
1364
-
1365
- return
1366
-
1367
- if __name__ =="__main__":
1368
- internal_growth_rate_df(df)
1369
-
1370
-
1371
- def internal_growth_rate(rvar,fieldlist=['VALUE','scope','factor','freq','name','units']):
1372
- """
1373
- 功能:计算内部增长率IRR
1374
- rvar:可能为df或dict。若为dict,里面的元素为两个df。
1375
- 每个df的结构:VALUE为具体的数值,scope为国家或地区,factor为指标,freq为频度。
1376
- """
1377
- print('')
1378
- import pandas as pd
1379
- if isinstance(rvar,pd.DataFrame):
1380
- internal_growth_rate_df(rvar,fieldlist=['VALUE','scope','factor','freq','name','units'])
1381
- return
1382
-
1383
- if isinstance(rvar,tuple):
1384
- for k in rvar:
1385
- internal_growth_rate_df(k,fieldlist=['VALUE','scope','factor','freq','name','units'])
1386
- return
1387
-
1388
- return
1389
-
1390
- if __name__ =="__main__":
1391
- internal_growth_rate(df)
1392
- #==============================================================================
1393
- if __name__ =="__main__":
1394
- ticker='China'
1395
- indicator='GDP'
1396
-
1397
-
1398
- def macro_trend(ticker,indicator,start='L10Y',end='today', \
1399
- power=0,twinx=False,attention_value=999,zeroline=False, \
1400
- datatag=False,date_range=False, \
1401
- loc1='best',loc2='best',facecolor='papayawhip'):
1402
- """
1403
- 功能:套壳函数,compare_economy, economy_trend
1404
- """
1405
-
1406
- # 处理日期
1407
- fromdate,todate=start_end_preprocess(start,end)
1408
-
1409
- # 判断ticker个数
1410
- if isinstance(ticker,str):
1411
- ticker_num=1
1412
- if isinstance(ticker,list):
1413
- ticker_num=len(ticker)
1414
- if ticker_num==1:
1415
- ticker=ticker[0]
1416
-
1417
- # 判断indicator个数
1418
- if isinstance(indicator,str):
1419
- indicator_num=1
1420
- if isinstance(indicator,list):
1421
- indicator_num=len(indicator)
1422
- if indicator_num==1:
1423
- indicator=indicator[0]
1424
-
1425
- # 是否PMI
1426
- if ticker_num==1 and indicator_num==1:
1427
- if indicator.upper()=='PMI' and ticker.title()=='China':
1428
- df=pmi_china(fromdate=fromdate,todate=todate, \
1429
- date_range=date_range,loc=loc1,facecolor=facecolor)
1430
-
1431
- return df
1432
-
1433
- # 双ticker或者双indicator
1434
- if ticker_num>=2 or indicator_num>=2:
1435
- if 'YoY PPI' in indicator:
1436
- attention_value=0
1437
-
1438
- df=compare_economy(ticker=ticker,indicator=indicator, \
1439
- start=fromdate,end=todate, \
1440
- power=power,twinx=twinx, \
1441
- yline=attention_value, \
1442
- loc1=loc1,loc2=loc2,facecolor=facecolor)
1443
- # 计算增长率
1444
- # 有inf/nan错误,未找出原因,先避开
1445
- if not 'YoY PPI' in indicator:
1446
- internal_growth_rate(df)
1447
- return df
1448
-
1449
- # 单ticker且单indicator
1450
- if ticker_num==1 and indicator_num==1:
1451
- if 'YoY PPI' in indicator:
1452
- attention_value=0
1453
-
1454
- df=economy_trend0(start=fromdate,end=todate,ticker=ticker,indicator=indicator, \
1455
- datatag=datatag,power=power, \
1456
- zeroline=zeroline,yline=attention_value,facecolor=facecolor)
1457
- # 计算增长率
1458
- # 有inf/nan错误,未找出原因,先避开
1459
- if not 'YoY PPI' in indicator:
1460
- internal_growth_rate(df)
1461
-
1462
- return df
1463
-
1464
- print(" #Warning(macro_trend): puzzled on what to for",ticker,"with",indicator)
1465
- return None
1466
-
1467
-
1468
- #==============================================================================
1469
- #==============================================================================
1470
-
1471
-