Новое в системе Wolfram
Mathematica
8: Финансовая визуализация
◄
предыдущая
|
следующая
►
Графика и визуализация
Использование статистической визуализации для анализа финансовых данных
Сочетание диаграммы "японские свечи" со статистическими визуализациями, показывающими распределение цены на момент закрытия рынка.
In[1]:=
X
data = FinancialData["MSFT", "OHLC", {{2010, 1}, {2010, 5, 31}}];
In[2]:=
X
close = data[[All, 2, 4]];
In[3]:=
X
l = (#[[-1]] - #[[1]]) &[First[HistogramList[close, {0.5}]]];
In[4]:=
X
g = Histogram[close, {0.5}, BarOrigin -> Left, Axes -> False, AspectRatio -> Full, PlotRangePadding -> None, ChartBaseStyle -> EdgeForm[Gray], ChartElementFunction -> ChartElementDataFunction["GradientScaleRectangle", "ColorScheme" -> "AvocadoColors"]];
In[5]:=
X
g2 = Graphics[ ChartElementData["SmoothDensity", "Shape" -> "SingleSided", "ColorScheme" -> "DeepSeaColors"][{{0, 1}, {0, 1}}, close], AspectRatio -> Full, PlotRangePadding -> None];
In[6]:=
X
g3 = DistributionChart[close, ChartElementFunction -> "Density", BarSpacing -> 0, Frame -> False, PlotRangePadding -> None, ChartBaseStyle -> Directive[EdgeForm[], Opacity[0.7]], ChartStyle -> ColorData[1][9], AspectRatio -> Full];
In[7]:=
X
g4 = DistributionChart[close, ChartElementFunction -> "FadingQuantile", BarSpacing -> 0, Frame -> False, PlotRangePadding -> None, ChartBaseStyle -> Directive[EdgeForm[], Opacity[0.5]], ChartStyle -> ColorData[14][6], AspectRatio -> Full];
In[8]:=
X
Grid[{{Show[{Graphics[Inset[g2, {0.5, 24}, {0.5, 24}, Length[close]]], CandlestickChart[data]}, AspectRatio -> 1, ImageSize -> 250, PlotRange -> {{0.5, Length[close] + 0.5}, {Min[data[[All, 2, 3]]], Max[data[[All, 2, 2]]]} + {-0.15, 0.1} (Max[data[[All, 2, 2]]] - Min[data[[All, 2, 3]]])}, Axes -> False, PlotLabel -> Style["Stock Price Distribuion", 20], Frame -> {Left, Top, Right}, BaseStyle -> {FontFamily -> "Helvetica"}], Show[{Graphics[Inset[g3, {0.5, 24}, {0, 24}, Length[close]]], CandlestickChart[data]}, AspectRatio -> 1, ImageSize -> 250, PlotRange -> {{0.5, Length[close] + 0.5}, {Min[data[[All, 2, 3]]], Max[data[[All, 2, 2]]]} + {-0.15, 0.1} (Max[data[[All, 2, 2]]] - Min[data[[All, 2, 3]]])}, Axes -> False, PlotLabel -> Style["Stock Price Density", 20], Frame -> {Left, Top, Right}, BaseStyle -> {FontFamily -> "Helvetica"}]}, {Show[{Graphics[ Inset[g4, {0.5, 24}, {0, 24}, {Length[close], l}]], CandlestickChart[data]}, AspectRatio -> 1, ImageSize -> 250, PlotRange -> {{0.5, Length[close] + 0.5}, {Min[data[[All, 2, 3]]], Max[data[[All, 2, 2]]]} + {-0.15, 0.1} (Max[data[[All, 2, 2]]] - Min[data[[All, 2, 3]]])}, Axes -> False, PlotLabel -> Style["Stock Price Quantile", 20], Frame -> {Left, Top, Right}, BaseStyle -> {FontFamily -> "Helvetica"}], Show[{Graphics[Inset[g, {0.5, 24}, {0, 24}, {Length[close], l}]], CandlestickChart[data]}, AspectRatio -> 1, ImageSize -> 250, PlotRange -> {{0.5, Length[close] + 0.5}, {Min[data[[All, 2, 3]]], Max[data[[All, 2, 2]]]} + {-0.15, 0.1} (Max[data[[All, 2, 2]]] - Min[data[[All, 2, 3]]])}, Axes -> False, PlotLabel -> Style["Stock Price Histogram", 20], Frame -> {Left, Top, Right}, BaseStyle -> {FontFamily -> "Helvetica"}]}}]
Out[8]=