Google Docs具有在线编辑、实时保存、历史回溯、多方编辑等优点,其中的spreadsheets类似于微软的office套件中的Excel。配合Google Finance函数可以制作包含实时和历史数据的表格。

基本语法:=GoogleFinance("symbol"; "attribute");

其中,symbol为stock代码,attribute为想要获得的数据参数。

比如,将以上表达式插入表格:

=GoogleFinance("002123"; "price")

即可获得代码为”002123”的实时价格。

另外,symbol和attribute的值也可以通过单元格定位获得,比如A2单元格的内容为”002123”,那么在B2单元格里输入下面的表达式将得到上面例子中相同的效果(见下图)。

=GoogleFinance(A2; “price”)

除了price外,Google Finance还提供了很多数据,见下表。

  • price: market price of the stock – delayed by up to 20 minutes.
  • priceopen: the opening price of the stock for the current day.
  • high: the highest price the stock traded for the current day.
  • low: the lowest price the stock traded for the current day.
  • volume: number of shares traded of this stock for the current day.
  • marketcap: the market cap of the stock.
  • tradetime: the last time the stock traded.
  • datadelay: the delay in the data presented for this stock using the googleFinance() function.
  • volumeavg: the average volume for this stock.
  • pe: the Price-to-Earnings ratio for this stock.
  • eps: the earnings-per-share for this stock.
  • high52: the 52-week high for this stock.
  • low52: the 52-week low for this stock.
  • change: the change in the price of this stock since yesterday’s market close.
  • beta: the beta value of this stock.
  • changepct: the percentage change in the price of this stock since yesterday’s close.
  • closeyest: yesterday’s closing price of this stock.
  • shares: the number of shares outstanding of this stock.
  • currency: the currency in which this stock is traded.

由此,我们可以制作类似下面这样的数据表,你也可以根据需要添加更多数据:

图中的颜色区别是通过设置颜色规则来实现的,选择菜单中的Format->Change colors with rules,即可按需设置。

获取历史数据

Google Finance现在已经支持获取历史数据,其基本语法为:

=GoogleFinance("symbol", "attribute", "start_date", "num_days|end_date", "interval")

其中前两个参数和上面所说的一样,后面的参数意义为:

“start_date”- 历史数据的起始日期

“num_days|end_date” – 历史数据日期长度或者结束日期

“interval” – 时间间隔,可设定为”daily”或”weekly”,即每日数据或每周数据。

举例,要获取沪市2009年1月的每日成交量数据:

=GoogleFinance(“SHA:000001″, “volume”, “1/1/2009″,”1/31/2009″,”DAILY”)

将得到如下结果:

Google spreadsheets还支持图表,你可以根据上面的数据,自动绘制出各种图表,使得数据更为直观。通过菜单选择Insert->Chart,设置后即可由上面的数据得到下面的图表。

后话:

Google的Docs套件就目前来说,功能算不上强大,但凭借其在线应用的特点,完全颠覆了原有的文档模式,以上即为其在线应用的一个例子。对于microsoft的office用户,可以使用offisync将本地文档保存到Google Docs以实现平台的过渡。Offisync是一个office插件,它在Office和Docs之间建立了一座桥梁,具体应用详见小众软件的文章