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!
Some examples about financial plots (OHLC) using matplotlib can be found here:
finance demo
Are you free to use JRuby instead of Ruby? That'd let you use JFreeChart, plus your code would still be in Ruby
This is the stock chart I draw just days ago using Matplotlib, I've posted the source too, for your reference: StockChart_Matplotlib
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).
You can use matplotlib and the the optional
bottom
parameter of matplotlib.pyplot.bar. You can then use lineplot
to indicate the opening and closing prices:For example:
creates a plot like this:
Obviously, you'd want to package this up in a function that drew the plot using
(open, close, min, max)
tuples (and you probably wouldn't want to randomly assign your opening and closing prices).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.