DMelt:Finance/Financial Charts
From HandWiki
Revision as of 11:12, 14 February 2021 by imported>Jworkorg
Member
Financial charts
In Sect. Visualization canvases discussed some method to visualize data. Now we show some more specific charts useful for financial market.
CandleStick chart
Market forecasting simply make use of the daily closing price. The following five pieces of information, listed here, are of particular interest to the technical analyst.
Opening Price Closing Price Day High Day Low Volume
Using more than just the daily closing price allows the analyst to capture the state of the market. Read this article about this chart. Read Candlestick chart article.
Let us consider a small Python script which generate data for CandleStick chart and show it:
from java.util import * from org.jfree.chart import ChartFactory,ChartPanel from org.jfree.data.xy import DefaultHighLowDataset from org.jfree.ui import RefineryUtilities from java.lang import Math from java.awt import * from javax.swing import * def createData(year, month, date): calendar = Calendar.getInstance() calendar.set(year, month - 1, date) return calendar.getTime() date = []; high = []; low = []; open = []; close = []; volume = [] calendar = Calendar.getInstance(); calendar.set(2008, 5, 1); for i in range(15): date.append(createData(2008, 8, i + 1)) high.append(30 + Math.round(10) + (Math.random() * 20.0)) low.append(30 + Math.round(10) + (Math.random() * 20.0)) open.append(10 + Math.round(10) + (Math.random() * 20.0)) close.append(10 + Math.round(10) + (Math.random() * 20.0)) volume.append(10.0 + (Math.random() * 20.0)) data = DefaultHighLowDataset("", date, high, low, open, close, volume) # create a chart chart = ChartFactory.createCandlestickChart( "Candlestick Demo", "Time", "Price", data, False) chartPanel = ChartPanel(chart) chartPanel.setPreferredSize(Dimension(600, 350)) # put it into a frame frame=JFrame("CandlestickChart") frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE) frame.setContentPane(chartPanel) frame.pack() RefineryUtilities.centerFrameOnScreen(frame) frame.setVisible(True)
The output will look as this: