R连接Wind数据库

本文介绍如何用R语言链接wind数据库,方便自动化更新数据

Wind客户端仅支持windows,以下内容需要在win下操作!
Wind的数据比较多,大概分为股票、债券、商品、外汇、基金、指数、新闻、宏观、资管、量化、市场,有了这些数据,就可以做很多高大上的数据分析工作了!Wind开放接口有Matlab、R、Python、VBA、C++、C#。由于平时用R,所以主要看了一下R的接口,真是简单到爆啊有木有~

安装WindR

  1. 安装R语言和Wind客户端
  2. 在Wind客户端点击“文件”->“修复R软件”->“安装成功”ORinstall.packages()来安装WindR

使用WindR接口

1
2
library(WindR)
w.start(showmenu = FALSE)

调取数据

WindR调取数据是通过指标代码来实现的,以宏观数据GDP为例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
gdp_year = w.edb("M0001395","1900",Sys.time())#列表数据
gdp_year = gdp_year$Data#取列表内元素
> gdp_year
DATETIME CLOSE
X1 1952-12-31 679.0
X2 1953-12-31 824.2
X3 1954-12-31 859.4
X4 1955-12-31 910.8
X5 1956-12-31 1029.0
X6 1957-12-31 1069.3
X7 1958-12-31 1308.2
X8 1959-12-31 1440.4
X9 1960-12-31 1457.5
X10 1961-12-31 1220.9
X11 1962-12-31 1151.2
X12 1963-12-31 1236.4
X13 1964-12-31 1455.5
X14 1965-12-31 1717.2
X15 1966-12-31 1873.1
X16 1967-12-31 1780.3
X17 1968-12-31 1730.2
X18 1969-12-31 1945.8
X19 1970-12-31 2261.3
X20 1971-12-31 2435.3
X21 1972-12-31 2530.2
X22 1973-12-31 2733.4
X23 1974-12-31 2803.7
X24 1975-12-31 3013.1
X25 1976-12-31 2961.5
X26 1977-12-31 3221.1
X27 1978-12-31 3650.2
X28 1979-12-31 4067.7
X29 1980-12-31 4551.6
X30 1981-12-31 4898.1
X31 1982-12-31 5333.0
X32 1983-12-31 5975.6
X33 1984-12-31 7226.3
X34 1985-12-31 9039.9
X35 1986-12-31 10308.8
X36 1987-12-31 12102.2
X37 1988-12-31 15101.1
X38 1989-12-31 17090.3
X39 1990-12-31 18774.3
X40 1991-12-31 21895.5
X41 1992-12-31 27068.3
X42 1993-12-31 35524.3
X43 1994-12-31 48459.6
X44 1995-12-31 61129.8
X45 1996-12-31 71572.3
X46 1997-12-31 79429.5
X47 1998-12-31 84883.7
X48 1999-12-31 90187.7
X49 2000-12-31 99776.3
X50 2001-12-31 110270.4
X51 2002-12-31 121002.0
X52 2003-12-31 136564.6
X53 2004-12-31 160714.4
X54 2005-12-31 185895.8
X55 2006-12-31 217656.6
X56 2007-12-31 268019.4
X57 2008-12-31 316751.7
X58 2009-12-31 345629.2
X59 2010-12-31 408903.0
X60 2011-12-31 484123.5
X61 2012-12-31 534123.0
X62 2013-12-31 588018.8
X63 2014-12-31 635910.2
X64 2015-12-31 676707.8
喂他一颗糖