 |
A candlestick chart used to describe price movements of a security, derivative, or currency.
Source code name: "candlestick_chart.py"
Programming language: Python
Topic: Finance/Plots
DMelt Version 1. Last modified: 07/06/2015. License: Pro
https://datamelt.org/code/cache/candlestick_chart_8812.py
To run this script using the DMelt IDE,
copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.
from java.util import *
from org.jfree.chart import ChartFactory
from org.jfree.data.xy import DefaultHighLowDataset
from java.lang import Math
from jhplot 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): # fill data
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)
chart=ChartFactory.createCandlestickChart("Candlestick","Time","Price",data,False)
c1=HPlotChart(chart); c1.visible()
You see the box below because you did not login.