Sunday, January 22, 2012

How to generate google stock trend chart in 3 lines...

Using janalyse-series scala API, it becomes very simple to generate a trend chart, 3 lines are enough in order to download, parse CSV data and then generate the chart.
#!/bin/sh
exec java -jar jaseries.jar -nocompdaemon -usejavacp -savecompiled "$0" "$@"
!#

import fr.janalyse.series.CSV2Series
import fr.janalyse.series.view.Chart

val allSeries = CSV2Series.fromURL("http://ichart.finance.yahoo.com/table.csv?s=GOOG")
val closeSeries = allSeries("Close").rename("Google stock value")    
Chart(closeSeries).toJpgFile(new java.io.File("googleStockTrend.jpg"), 800, 400)
The following chart is created.

No comments:

Post a Comment