Customized Financial Data Visualizations
Create a volume-price bubble chart with open-close price distribution and a date-close density plot annotated on the sides.
data = FinancialData["AAPL", "OHLCV", {{2012, 1, 1}, {2012, 7, 27}}];date = AbsoluteTime /@ data[[All, 1]];ndata = data[[All, 2]];{open, high, low, close, v} = Transpose@ndata;{mind, maxd} = Through[{Min, Max}[date]];{mind, maxd} = {mind, maxd} + {-0.1, 0.1}(maxd - mind);{minh, maxh} = Through[{Min, Max}[high]];
{minh, maxh} = {minh, maxh} + {-0.1, 0.1}(maxh - minh);{mino, maxo} = Through[{Min, Max}[open]];
{mino, maxo} = {mino, maxo} + {-0.1, 0.1}(maxo - mino);{minl, maxl} = Through[{Min, Max}[low]];
{minl, maxl} = {minl, maxl} + {-0.1, 0.1}(maxl - minl);{minc, maxc} = Through[{Min, Max}[close]];
{minc, maxc} = {minc, maxc} + {-0.1, 0.1}(maxc - minc);g = BubbleChart3D[Transpose@{open, close, date, v}, BubbleSizes -> {0.02, 0.08}, AxesLabel -> {"Open", "Close", "Date"}, FaceGrids -> None, ChartStyle -> 14];openclose = SmoothDensityHistogram[Transpose[{open, close}], Frame -> False, PlotRangePadding -> None, ColorFunction -> "SunsetColors"];highlow = SmoothDensityHistogram[Transpose[{high, low}], Frame -> False, PlotRangePadding -> None, ColorFunction -> "SunsetColors"];highclose = SmoothDensityHistogram[Transpose[{high, close}], Frame -> False, PlotRangePadding -> None, ColorFunction -> "SunsetColors"];lowclose = SmoothDensityHistogram[Transpose[{low, close}], Frame -> False,
PlotRangePadding -> None, ColorFunction -> "SunsetColors"];ztickspos = Quantile[date, {0, 1 / 5, 2 / 5, 3 / 5, 4 / 5, 1}];ticks = DateString[#, "DateShort"]& /@ ztickspos;zticks = Transpose[{ztickspos, ticks}];line = DateListPlot[Transpose[{date, close}], Axes -> False, Frame -> False, ImageSize -> 500, GridLines -> None, AspectRatio -> 1, PlotRangePadding -> None, Joined -> True, PlotStyle -> Thickness[0.01]];Show[{
Graphics3D[{Texture[openclose], Polygon[{{mino, minc, mind}, {maxo, minc, mind}, {maxo, maxc, mind}, {mino, maxc, mind}}, VertexTextureCoordinates -> {{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}}]}],
Graphics3D[{Texture[line], Polygon[{{mino, minc, mind}, {mino, minc, maxd}, {mino, maxc, maxd}, {mino, maxc, mind}}, VertexTextureCoordinates -> {{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}}]}], g}, FaceGrids -> None, PlotRangePadding -> None, Boxed -> {Bottom, Left}, Lighting -> "Neutral", Axes -> True, AxesLabel -> {"Open", "Close"}, BoxRatios -> {1, 1, 1}, ImageSize -> 500, PlotLabel -> Style["Stock Price and Volume Bubble", 20],
AxesEdge -> {{-1, -1}, {1, -1}, {-1, -1}}, Ticks -> {Automatic, Automatic, zticks}, BaseStyle -> {FontFamily -> "Helvetica"}]