OHLC(始値 高値 安値 終値)株価チャートの作成

可能な使用シナリオ

Open-High-Low-Close(OHLC)チャートは、カテゴリ、オープン、ハイ、ロー、クローズのデータを使用し、価格の範囲は垂直線で示され、オープンからクローズまでの範囲はより広い浮動バーで示されます。カテゴリ内で価格が上昇する場合(クローズがオープンより高い場合)、バーは1つの色で塗りつぶされ、価格が下落する場合は別の色で塗りつぶされます。この種のチャートは、ローソク足チャートと呼ばれることがよくあります。

todo:image_alt_text

todo:image_alt_text

チャートの可視性の改善

価格の増減を示す際に、通常は白黒の代わりに色を使用します。最初のローソク足チャートでは、赤が増加を示し、緑が減少を示します。

todo:image_alt_text

サンプルコード

サンプルExcelファイルを読み込み、出力Excelファイルを生成するサンプルコードは、以下の通りです。

from aspose.cells import Workbook
from aspose.cells.charts import ChartType, LegendPositionType
from aspose.cells.drawing import FillType
from aspose.pydrawing import Color
# Create an instance of Workbook
workbook = Workbook("Open-High-Low-Close.xlsx")
# Access the first worksheet.
worksheet = workbook.worksheets[0]
# Create High-Low-Close-Stock Chart
pieIdx = worksheet.charts.add(ChartType.STOCK_OPEN_HIGH_LOW_CLOSE, 5, 6, 20, 12)
# Retrieve the Chart object
chart = worksheet.charts[pieIdx]
# Set the legend can be showed
chart.show_legend = True
# Set the chart title name
chart.title.text = "OPen-High-Low-Close Stock"
# Set the Legend at the bottom of the chart area
chart.legend.position = LegendPositionType.BOTTOM
# Set data range
chart.set_chart_data_range("A1:E9", True)
# Set category data
chart.n_series.category_data = "A2:A9"
# Set the DownBars and UpBars with different color
chart.n_series[0].down_bars.area.foreground_color = Color.green
chart.n_series[0].up_bars.area.foreground_color = Color.red
# Fill the PlotArea area with nothing
chart.plot_area.area.fill_format.fill_type = FillType.NONE
# Save the Excel file
workbook.save("out.xlsx")