views:

2647

answers:

6

What are my best options for creating a financial open-high-low-close (OHLC) chart in a high level language like Ruby or Python? While there seem to be a lot of options for graphing, I haven't seen any gems or eggs with this kind of chart.

http://en.wikipedia.org/wiki/Open-high-low-close_chart (but I don't need the moving average or Bollinger bands)

JFreeChart can do this in Java, but I'd like to make my codebase as small and simple as possible.

Thanks!

+3  A: 

Have you considered using R and the quantmod package? It likely provides exactly what you need.

David Locke
This looks promising! I'll check it out ASAP. Thanks!
Eric the Red
+3  A: 

You can use Pylab (matplotlib.finance) with Python. Here are some examples: http://matplotlib.sourceforge.net/examples/pylab_examples/plotfile_demo.html . There is some good material specifically on this problem in Beginning Python Visualization.

Update: I think you can use matplotlib.finance.candlestick for the Japanese candlestick effect.

bvmou
Unfortunately none of these is the type of graph I'm looking for.
Eric the Red
See if the update gets you closer
bvmou
+1  A: 

Are you free to use JRuby instead of Ruby? That'd let you use JFreeChart, plus your code would still be in Ruby

the same applies for jython, if you're more inclined to use python.
Autoplectic
What's the advantage of using jython over python in this situation?
Eric the Red
Eric: same thing as Ruby - using Jython would give him access to Java classes, so he could use JFreeChart
+11  A: 
Aaron Maenpaa
This kind of chart doesn't include the open or close.
Eric the Red
@Eric I added code to draw the ticks for the opening and closing prices. I didn't see them when I looked at the chart on the wikipedia page (... and had no idea they were supposed to be there because I'm not a financial guy :).
Aaron Maenpaa
@Aaron - Nice! Thanks!
Eric the Red
A: 

Please look at the Open Flash Chart embedding for WHIFF http://aaron.oirt.rutgers.edu/myapp/docs/W1100_1600.openFlashCharts An example of a candle chart is right at the top. This would be especially good for embedding in web pages.

Aaron Watters
A: 

Open Flash Chart is nice choice if you like the look of examples. I've moved to JavaScript/Canvas library like Flot for HTML embedded charts, as it is more customizable and I get desired effect without much hacking (http://itprolife.worona.eu/2009/08/scatter-chart-library-moving-to-flot.html).

Tomasz Worona