0
# Market Indices
1
2
AKShare provides comprehensive market index data with 95 functions covering domestic Chinese indices, international market indices, commodity indices, and volatility indicators. This includes major stock market benchmarks, sector indices, commodity price indices, and market sentiment indicators.
3
4
## Chinese Market Indices
5
6
### Major Stock Market Indices
7
8
#### Shanghai and Shenzhen Exchange Indices
9
```python { .api }
10
import akshare as ak
11
12
def stock_zh_index_spot_em() -> pd.DataFrame:
13
"""
14
Real-time Chinese market index quotes from East Money
15
16
Returns:
17
pd.DataFrame: Index real-time data with columns:
18
- 序号 (Index): Row number
19
- 代码 (Code): Index code
20
- 名称 (Name): Index name
21
- 最新价 (Latest): Current value
22
- 涨跌额 (Change): Point change
23
- 涨跌幅 (Pct_change): Percentage change
24
- 成交量 (Volume): Trading volume
25
- 成交额 (Amount): Trading amount
26
- 换手率 (Turnover): Turnover rate
27
- 最高 (High): Highest value
28
- 最低 (Low): Lowest value
29
- 今开 (Open): Opening value
30
- 昨收 (Prev_close): Previous close
31
"""
32
33
# Get real-time index data
34
index_realtime = ak.stock_zh_index_spot_em()
35
print(index_realtime.head())
36
# 序号 代码 名称 最新价 涨跌额 涨跌幅 成交量 成交额
37
# 0 1 000001 上证指数 3234.56 12.45 0.39 456789012 1234567890123
38
# 1 2 399001 深证成指 10567.89 23.78 0.23 234567890 876543210987
39
# 2 3 399006 创业板指 2134.56 -5.67 -0.27 123456789 543210987654
40
```
41
42
#### Historical Index Data
43
```python { .api }
44
import akshare as ak
45
46
def stock_zh_index_daily(symbol: str = "000001",
47
start_date: str = "19700101",
48
end_date: str = "20500101") -> pd.DataFrame:
49
"""
50
Chinese market index historical data
51
52
Parameters:
53
symbol: Index code (e.g., "000001" for Shanghai Composite)
54
start_date: Start date in YYYYMMDD format
55
end_date: End date in YYYYMMDD format
56
57
Returns:
58
pd.DataFrame: Historical index data with columns:
59
- 日期 (Date): Trading date
60
- 开盘 (Open): Opening value
61
- 收盘 (Close): Closing value
62
- 最高 (High): Highest value
63
- 最低 (Low): Lowest value
64
- 成交量 (Volume): Trading volume
65
- 成交额 (Amount): Trading amount
66
"""
67
68
# Get Shanghai Composite historical data
69
sh_composite = ak.stock_zh_index_daily(
70
symbol="000001",
71
start_date="20240101",
72
end_date="20241201"
73
)
74
print(sh_composite.head())
75
# 日期 开盘 收盘 最高 最低 成交量 成交额
76
# 0 2024-01-02 2987.45 3034.56 3045.12 2978.34 456789012 234567890123
77
# 1 2024-01-03 3034.56 3021.78 3056.89 3012.45 398765432 198765432109
78
```
79
80
### Sector and Thematic Indices
81
82
#### Industry Sector Indices
83
```python { .api }
84
import akshare as ak
85
86
def stock_board_industry_index_em() -> pd.DataFrame:
87
"""
88
Industry sector index data
89
90
Returns:
91
pd.DataFrame: Industry sector performance with columns:
92
- 排名 (Rank): Sector ranking
93
- 板块名称 (Sector): Industry sector name
94
- 板块代码 (Code): Sector code
95
- 最新价 (Price): Current index value
96
- 涨跌额 (Change): Point change
97
- 涨跌幅 (Pct_change): Percentage change
98
- 总市值 (Market_cap): Total market capitalization
99
- 换手率 (Turnover): Average turnover rate
100
"""
101
102
# Get industry sector indices
103
industry_indices = ak.stock_board_industry_index_em()
104
print(industry_indices.head())
105
# 排名 板块名称 板块代码 最新价 涨跌额 涨跌幅 总市值 换手率
106
# 0 1 电子信息 BK0727 1234.56 23.45 1.94 987654321 2.45
107
# 1 2 生物医药 BK0456 2345.67 -12.34 -0.52 876543210 1.87
108
```
109
110
#### Concept Theme Indices
111
```python { .api }
112
import akshare as ak
113
114
def stock_board_concept_index_em() -> pd.DataFrame:
115
"""
116
Concept theme index data
117
118
Returns:
119
pd.DataFrame: Concept theme performance
120
"""
121
122
# Get concept theme indices
123
concept_indices = ak.stock_board_concept_index_em()
124
```
125
126
### Market Size Indices
127
128
#### Small and Mid-Cap Indices
129
```python { .api }
130
import akshare as ak
131
132
def index_zh_a_hist(symbol: str = "000852", period: str = "daily",
133
start_date: str = "19700101",
134
end_date: str = "20500101") -> pd.DataFrame:
135
"""
136
A-share market cap segment indices
137
138
Parameters:
139
symbol: Index code (e.g., "000852" for CSI 1000)
140
period: Data frequency ("daily", "weekly", "monthly")
141
start_date: Start date
142
end_date: End date
143
144
Returns:
145
pd.DataFrame: Market cap index data
146
"""
147
148
# Get CSI 1000 (small cap) historical data
149
csi1000 = ak.index_zh_a_hist(
150
symbol="000852", # CSI 1000
151
start_date="20240101"
152
)
153
154
# Get CSI 300 (large cap) historical data
155
csi300 = ak.index_zh_a_hist(
156
symbol="000300", # CSI 300
157
start_date="20240101"
158
)
159
```
160
161
## Global Market Indices
162
163
### International Stock Indices
164
165
#### Major Global Indices
166
```python { .api }
167
import akshare as ak
168
169
def index_investing_global(country: str = "美国",
170
indicator: str = "道琼斯") -> pd.DataFrame:
171
"""
172
Global market indices from Investing.com
173
174
Parameters:
175
country: Country/region name
176
indicator: Index name
177
178
Returns:
179
pd.DataFrame: International index data with columns:
180
- 日期 (Date): Date
181
- 收盘 (Close): Closing value
182
- 开盘 (Open): Opening value
183
- 高 (High): High value
184
- 低 (Low): Low value
185
- 交易量 (Volume): Volume
186
- 涨跌幅 (Change): Percentage change
187
"""
188
189
# Get Dow Jones historical data
190
dow_jones = ak.index_investing_global(country="美国", indicator="道琼斯")
191
192
# Get S&P 500 data
193
sp500 = ak.index_investing_global(country="美国", indicator="标普500")
194
195
# Get NASDAQ data
196
nasdaq = ak.index_investing_global(country="美国", indicator="纳斯达克")
197
198
print(dow_jones.head())
199
# 日期 收盘 开盘 高 低 交易量 涨跌幅
200
# 0 2024-12-01 35234.56 35123.45 35345.67 35098.76 123456789 0.34
201
# 1 2024-11-29 35112.34 35087.65 35187.98 35034.21 109876543 -0.12
202
```
203
204
#### European Market Indices
205
```python { .api }
206
import akshare as ak
207
208
def index_investing_global_country_name() -> list:
209
"""
210
Available countries for global index data
211
212
Returns:
213
list: List of available countries/regions
214
"""
215
216
def index_investing_global_indicator_name(country: str) -> list:
217
"""
218
Available indices for specific country
219
220
Parameters:
221
country: Country name
222
223
Returns:
224
list: List of available indices
225
"""
226
227
# Get available countries
228
countries = ak.index_investing_global_country_name()
229
230
# Get European indices
231
dax = ak.index_investing_global(country="德国", indicator="德国DAX30")
232
ftse = ak.index_investing_global(country="英国", indicator="英国富时100")
233
cac = ak.index_investing_global(country="法国", indicator="法国CAC40")
234
```
235
236
#### Asian-Pacific Indices
237
```python { .api }
238
import akshare as ak
239
240
# Get major Asian indices
241
nikkei = ak.index_investing_global(country="日本", indicator="日经225")
242
hang_seng = ak.index_investing_global(country="香港", indicator="恒生指数")
243
kospi = ak.index_investing_global(country="韩国", indicator="韩国KOSPI")
244
asx = ak.index_investing_global(country="澳大利亚", indicator="澳洲标普200")
245
```
246
247
## Commodity and Economic Indices
248
249
### Commodity Price Indices
250
251
#### Comprehensive Commodity Data
252
```python { .api }
253
import akshare as ak
254
255
def index_cx_commodity() -> pd.DataFrame:
256
"""
257
Commodity price indices from cx.com
258
259
Returns:
260
pd.DataFrame: Commodity index data with columns:
261
- 指数名称 (Index_name): Commodity index name
262
- 最新价 (Latest): Current value
263
- 涨跌 (Change): Point change
264
- 涨跌幅 (Pct_change): Percentage change
265
- 昨收 (Prev_close): Previous close
266
- 今开 (Open): Opening value
267
- 最高 (High): Highest value
268
- 最低 (Low): Lowest value
269
"""
270
271
def index_cx_energy() -> pd.DataFrame:
272
"""
273
Energy commodity indices
274
275
Returns:
276
pd.DataFrame: Energy price indices
277
"""
278
279
def index_cx_metal() -> pd.DataFrame:
280
"""
281
Metal commodity indices
282
283
Returns:
284
pd.DataFrame: Metal price indices
285
"""
286
287
# Get comprehensive commodity data
288
commodity_indices = ak.index_cx_commodity()
289
energy_indices = ak.index_cx_energy()
290
metal_indices = ak.index_cx_metal()
291
292
print(commodity_indices.head())
293
# 指数名称 最新价 涨跌 涨跌幅 昨收 今开 最高 最低
294
# 0 原油指数 234.56 2.34 1.01 232.22 232.45 235.67 231.89
295
# 1 黄金指数 1987.65 -5.43 -0.27 1993.08 1992.34 1995.21 1985.76
296
```
297
298
#### Agricultural Commodity Indices
299
```python { .api }
300
import akshare as ak
301
302
def index_cx_agriculture() -> pd.DataFrame:
303
"""
304
Agricultural commodity price indices
305
306
Returns:
307
pd.DataFrame: Agricultural price data
308
"""
309
310
# Get agricultural commodity indices
311
agri_indices = ak.index_cx_agriculture()
312
```
313
314
### Economic Composite Indices
315
316
#### Economic Health Indicators
317
```python { .api }
318
import akshare as ak
319
320
def index_economic_leading() -> pd.DataFrame:
321
"""
322
Economic leading indicators index
323
324
Returns:
325
pd.DataFrame: Leading economic indicators
326
"""
327
328
def index_economic_coincident() -> pd.DataFrame:
329
"""
330
Economic coincident indicators
331
332
Returns:
333
pd.DataFrame: Coincident economic measures
334
"""
335
336
# Get economic indicator indices
337
leading_indicators = ak.index_economic_leading()
338
coincident_indicators = ak.index_economic_coincident()
339
```
340
341
## Volatility and Market Sentiment Indices
342
343
### Volatility Indices
344
345
#### VIX and Global Volatility
346
```python { .api }
347
import akshare as ak
348
349
def index_vix() -> pd.DataFrame:
350
"""
351
VIX (CBOE Volatility Index) historical data
352
353
Returns:
354
pd.DataFrame: VIX data with columns:
355
- 日期 (Date): Date
356
- 收盘价 (Close): Closing VIX value
357
- 开盘价 (Open): Opening VIX value
358
- 最高价 (High): Highest VIX value
359
- 最低价 (Low): Lowest VIX value
360
- 成交量 (Volume): Trading volume
361
"""
362
363
def index_vix_hist(start_date: str = "19700101",
364
end_date: str = "20500101") -> pd.DataFrame:
365
"""
366
Historical VIX data with date range
367
368
Parameters:
369
start_date: Start date (YYYYMMDD)
370
end_date: End date (YYYYMMDD)
371
372
Returns:
373
pd.DataFrame: VIX historical data
374
"""
375
376
# Get VIX data
377
vix_data = ak.index_vix()
378
vix_hist = ak.index_vix_hist(start_date="20240101")
379
380
print(vix_data.head())
381
# 日期 收盘价 开盘价 最高价 最低价 成交量
382
# 0 2024-12-01 18.45 18.23 18.87 18.12 1234567
383
# 1 2024-11-29 17.89 18.01 18.34 17.76 1098765
384
```
385
386
#### China Volatility Index
387
```python { .api }
388
import akshare as ak
389
390
def index_option_qvix(trade_date: str) -> pd.DataFrame:
391
"""
392
Chinese volatility index (iVIX equivalent)
393
394
Parameters:
395
trade_date: Trading date (YYYY-MM-DD)
396
397
Returns:
398
pd.DataFrame: Chinese market volatility data
399
"""
400
401
# Get Chinese volatility index
402
china_vix = ak.index_option_qvix(trade_date="2024-12-01")
403
```
404
405
### Market Breadth Indicators
406
407
#### Advance-Decline Indices
408
```python { .api }
409
import akshare as ak
410
411
def index_market_breadth() -> pd.DataFrame:
412
"""
413
Market breadth indicators and statistics
414
415
Returns:
416
pd.DataFrame: Market breadth data including:
417
- 上涨家数 (Advancing): Number of advancing stocks
418
- 下跌家数 (Declining): Number of declining stocks
419
- 平盘家数 (Unchanged): Number of unchanged stocks
420
- 涨停家数 (Limit_up): Number of limit-up stocks
421
- 跌停家数 (Limit_down): Number of limit-down stocks
422
"""
423
424
# Get market breadth data
425
market_breadth = ak.index_market_breadth()
426
```
427
428
## Specialized Index Categories
429
430
### ESG and Thematic Indices
431
432
#### Environmental and Social Indices
433
```python { .api }
434
import akshare as ak
435
436
def index_esg_em() -> pd.DataFrame:
437
"""
438
ESG (Environmental, Social, Governance) indices
439
440
Returns:
441
pd.DataFrame: ESG index performance data
442
"""
443
444
def index_green_energy() -> pd.DataFrame:
445
"""
446
Green energy and renewable sector indices
447
448
Returns:
449
pd.DataFrame: Clean energy index data
450
"""
451
452
# Get ESG and thematic indices
453
esg_indices = ak.index_esg_em()
454
green_indices = ak.index_green_energy()
455
```
456
457
### Smart Beta and Factor Indices
458
459
#### Factor-based Indices
460
```python { .api }
461
import akshare as ak
462
463
def index_factor_value() -> pd.DataFrame:
464
"""
465
Value factor index performance
466
467
Returns:
468
pd.DataFrame: Value-based index data
469
"""
470
471
def index_factor_growth() -> pd.DataFrame:
472
"""
473
Growth factor index performance
474
475
Returns:
476
pd.DataFrame: Growth-based index data
477
"""
478
479
def index_factor_momentum() -> pd.DataFrame:
480
"""
481
Momentum factor index data
482
483
Returns:
484
pd.DataFrame: Momentum-based indices
485
"""
486
487
# Get factor indices
488
value_indices = ak.index_factor_value()
489
growth_indices = ak.index_factor_growth()
490
momentum_indices = ak.index_factor_momentum()
491
```
492
493
## Index Analysis and Applications
494
495
### Cross-Market Analysis
496
```python { .api }
497
import akshare as ak
498
import pandas as pd
499
500
def create_global_index_dashboard() -> dict:
501
"""Create comprehensive global index monitoring dashboard"""
502
503
dashboard = {
504
# Chinese indices
505
'china_major': ak.stock_zh_index_spot_em(),
506
'china_sectors': ak.stock_board_industry_index_em(),
507
508
# US indices
509
'us_dow': ak.index_investing_global(country="美国", indicator="道琼斯"),
510
'us_sp500': ak.index_investing_global(country="美国", indicator="标普500"),
511
'us_nasdaq': ak.index_investing_global(country="美国", indicator="纳斯达克"),
512
513
# Volatility
514
'vix': ak.index_vix(),
515
516
# Commodities
517
'commodities': ak.index_cx_commodity()
518
}
519
520
return dashboard
521
522
def analyze_market_correlation() -> pd.DataFrame:
523
"""Analyze correlations between different market indices"""
524
525
# Get multiple index data
526
sh_composite = ak.stock_zh_index_daily(symbol="000001", start_date="20240101")
527
sp500 = ak.index_investing_global(country="美国", indicator="标普500")
528
529
# Correlation analysis would be performed here
530
return correlation_matrix
531
532
# Usage
533
global_dashboard = create_global_index_dashboard()
534
correlation_data = analyze_market_correlation()
535
```
536
537
### Risk and Performance Analytics
538
```python { .api }
539
import akshare as ak
540
541
def monitor_market_risk() -> dict:
542
"""Comprehensive market risk monitoring using indices"""
543
544
risk_metrics = {}
545
546
# Market level risk (VIX)
547
vix_data = ak.index_vix()
548
risk_metrics['volatility'] = vix_data
549
550
# Sector concentration risk
551
sector_data = ak.stock_board_industry_index_em()
552
risk_metrics['sector_performance'] = sector_data
553
554
# International correlation risk
555
global_indices = {
556
'us_sp500': ak.index_investing_global(country="美国", indicator="标普500"),
557
'eu_dax': ak.index_investing_global(country="德国", indicator="德国DAX30"),
558
'asia_nikkei': ak.index_investing_global(country="日本", indicator="日经225")
559
}
560
risk_metrics['global_indices'] = global_indices
561
562
# Commodity risk
563
commodity_data = ak.index_cx_commodity()
564
risk_metrics['commodities'] = commodity_data
565
566
return risk_metrics
567
568
def benchmark_performance(portfolio_returns: pd.Series,
569
benchmark_symbol: str = "000300") -> dict:
570
"""Benchmark portfolio performance against market indices"""
571
572
# Get benchmark data
573
benchmark_data = ak.stock_zh_index_daily(
574
symbol=benchmark_symbol,
575
start_date="20240101"
576
)
577
578
# Performance comparison analysis
579
performance_metrics = {
580
'benchmark_returns': benchmark_data,
581
'tracking_error': None, # Would calculate tracking error
582
'information_ratio': None, # Would calculate information ratio
583
'beta': None, # Would calculate portfolio beta
584
'alpha': None # Would calculate portfolio alpha
585
}
586
587
return performance_metrics
588
589
# Usage
590
market_risk = monitor_market_risk()
591
# benchmark_perf = benchmark_performance(portfolio_returns, "000300")
592
```
593
594
## Data Characteristics
595
596
### Update Frequencies
597
- **Real-time indices**: Updated during trading hours for major markets
598
- **Daily indices**: End-of-day values for all covered indices
599
- **Weekly/Monthly**: Available for most major indices with aggregation options
600
601
### Coverage Scope
602
- **Domestic**: Complete coverage of Chinese market indices (95 functions)
603
- **International**: Major global developed and emerging market indices
604
- **Sectors**: Industry and thematic classification indices
605
- **Factors**: Smart beta and quantitative factor indices
606
- **Volatility**: Market sentiment and risk indicators
607
608
### Common Applications
609
1. **Market Timing**: Using volatility indices for entry/exit decisions
610
2. **Sector Rotation**: Industry index analysis for sector allocation
611
3. **International Diversification**: Global index correlation analysis
612
4. **Risk Management**: Volatility and breadth indicators for risk control
613
5. **Benchmarking**: Performance comparison against relevant indices
614
6. **Factor Investing**: Smart beta and factor-based investment strategies
615
616
The market index capabilities in AKShare provide comprehensive tools for market analysis, benchmarking, and risk management across domestic and international markets.