Crea un grafico di scorta Open High Low Close (OHLC)

Possibili Scenari di Utilizzo

Il grafico Open-High-Low-Close (OHLC) utilizza cinque colonne di dati, in ordine: categoria, apertura, alta, bassa e chiusura. L’intervallo di prezzi in ogni categoria è nuovamente indicato da una linea verticale, mentre l’intervallo tra apertura e chiusura è dato da una barra galleggiante più ampia; se il prezzo aumenta nella categoria (chiusura è superiore all’apertura), la barra è riempita con un colore, mentre se il prezzo diminuisce, la barra è riempita con un altro. Questo tipo di grafico è spesso chiamato grafico a candela.

todo:image_alt_text

todo:image_alt_text

Miglioramenti della visibilità nel grafico

Spesso usiamo i colori invece che il bianco e nero per indicare i prezzi in aumento e in diminuzione. Nel primo set di candele di seguito, il rosso mostra i prezzi in aumento e il verde i prezzi in diminuzione.

todo:image_alt_text

Codice di Esempio

Il codice di esempio seguente carica il file Excel di esempio e genera il file Excel di output.

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")