Skip to content

Commit e5ddb35

Browse files
committed
second commit
1 parent 3884d73 commit e5ddb35

File tree

15 files changed

+174
-38
lines changed

15 files changed

+174
-38
lines changed
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[[{"location":"E:\\Programming\\School\\JAVA_Application_Project\\Java_Course_Project\\Statistical_Analysis","type":"PROJECT","hints":{"PROJECT_NAME":"Statistical_Analysis"}},"ABSENT"],[{"location":"C:\\Program Files\\Java\\jre1.8.0_144","type":"JRE","hints":{"EXECUTION_ENVIRONMENT":"JavaSE-1.8"}},"jre:jre:1.8.0"]]
1+
[[{"location":"C:\\Users\\DongGoo\\Downloads\\jfreechart-1.0.19\\jfreechart-1.0.19\\lib\\jfreechart-1.0.19.jar","type":"JAR","hints":{}},"ABSENT"],[{"location":"C:\\Java_Course_Project\\Statistical_Analysis","type":"PROJECT","hints":{"PROJECT_NAME":"Statistical_Analysis"}},"ABSENT"],[{"location":"C:\\Program Files\\Java\\jre1.8.0_144","type":"JRE","hints":{"EXECUTION_ENVIRONMENT":"JavaSE-1.8"}},"jre:jre:1.8.0"]]
Binary file not shown.

Diff for: Statistical_Analysis/.classpath

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
<classpathentry kind="src" path="src"/>
55
<classpathentry kind="src" path="GUISource"/>
66
<classpathentry kind="src" path="Global_Region"/>
7-
<classpathentry kind="lib" path="E:/Programming/School/JAVA_Application_Project/Java_Course_Project/ExternalLib/Apache/commons-math3-3.6.1.jar"/>
8-
<classpathentry kind="lib" path="E:/Programming/School/JAVA_Application_Project/Java_Course_Project/ExternalLib/Apache/commons-math3-3.6.1-javadoc.jar"/>
9-
<classpathentry kind="lib" path="E:/Programming/School/JAVA_Application_Project/Java_Course_Project/ExternalLib/Apache/commons-math3-3.6.1-sources.jar"/>
7+
<classpathentry kind="lib" path="C:/Users/DongGoo/Downloads/jfreechart-1.0.19/jfreechart-1.0.19/lib/jfreechart-1.0.19.jar"/>
8+
<classpathentry kind="lib" path="C:/Users/DongGoo/Downloads/jfreechart-1.0.19/jfreechart-1.0.19/lib/jcommon-1.0.23.jar"/>
109
<classpathentry kind="output" path="bin"/>
1110
</classpath>

Diff for: Statistical_Analysis/Data/Historical/AAPL.csv

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
timestamp,open,high,low,close,adjusted_close,volume,dividend_amount,,
2-
2017-11-27,175.0500,175.0800,173.3400,174.0900,174.0900,20590163,0.0000,,
3-
2017-11-24,175.1000,175.5000,174.6500,174.9700,174.9700,14026519,0.0000,,
2+
2017-11-29,172.6300,172.9200,167.1600,169.4800,169.4800,41456722,0.0000,,
3+
2017-11-28,174.3000,174.8700,171.8600,173.0700,173.0700,25468442,0.0000,,
4+
2017-11-27,175.0500,175.0800,173.3400,174.0900,174.0900,20536313,0.0000,,
5+
2017-11-24,175.1000,175.5000,174.6459,174.9700,174.9700,14026519,0.0000,,
46
2017-11-22,173.3600,175.0000,173.0500,174.9600,174.9600,24997274,0.0000,,
57
2017-11-21,170.7800,173.7000,170.7800,173.1400,173.1400,24875471,0.0000,,
68
2017-11-20,170.2900,170.5600,169.5600,169.9800,169.9800,15974387,0.0000,,

Diff for: Statistical_Analysis/DataMeta/Availability.csv

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
AAPL,2017-11-28,2000-01-03,
1+
AAPL,2017-11-30,2000-01-03,
22
SFNC,2017-11-26,2000-01-03,
33
CPRT,2017-11-26,2000-01-03,
4-
GOOG,2017-11-27,2014-03-27,
4+
GOOG,2017-11-28,2014-03-27,
55
EDIG,2017-11-26,2000-01-03,
66
IRCP,2017-11-26,2003-11-05,
77
WAYN,2017-11-26,2000-01-03,
@@ -17,8 +17,8 @@ STX,2017-11-27,2002-12-11,
1717
XOM,2017-11-27,2000-01-03,
1818
MARA,2017-11-26,2012-05-04,
1919
AVGO,2017-11-27,2009-08-06,
20-
AAPL,2017-11-28,2000-01-03,
21-
GOOG,2017-11-27,2014-03-27,
20+
AAPL,2017-11-30,2000-01-03,
21+
GOOG,2017-11-28,2014-03-27,
2222
TSLA,2017-11-28,2010-06-29,
2323
AMZN,2017-11-27,2000-01-03,
2424
XRT,2017-11-27,2006-06-22,
@@ -29,6 +29,8 @@ XOM,2017-11-27,2000-01-03,
2929
AVGO,2017-11-27,2009-08-06,
3030
AAP,2017-11-27,2001-11-29,
3131
ABC,2017-11-27,2000-01-03,
32-
AAPL,2017-11-28,2000-01-03,
32+
AAPL,2017-11-30,2000-01-03,
3333
TSLA,2017-11-28,2010-06-29,
3434
GOOG,2017-11-28,2014-03-27,
35+
AAPL,2017-11-30,2000-01-03,
36+
AAPL,2017-11-30,2000-01-03,

Diff for: Statistical_Analysis/GUISource/generalInfoFrame/GeneralInfoFramePanel_LatestData.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
import javax.swing.*;
33

44
public class GeneralInfoFramePanel_LatestData extends JPanel{
5-
5+
66
}
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,120 @@
11
package graphFrame;
22

3+
import java.awt.BorderLayout;
4+
import java.awt.Color;
5+
import java.awt.Component;
6+
import java.awt.Dimension;
7+
import java.util.ArrayList;
8+
import java.util.Date;
9+
import java.util.Collection;
10+
import java.util.Collections;
11+
312
import javax.swing.*;
413

14+
import org.jfree.chart.*;
15+
import org.jfree.chart.axis.DateAxis;
16+
import org.jfree.chart.axis.NumberAxis;
17+
import org.jfree.chart.axis.Timeline;
18+
import org.jfree.chart.plot.PlotOrientation;
19+
import org.jfree.chart.plot.XYPlot;
20+
import org.jfree.chart.renderer.xy.CandlestickRenderer;
21+
import org.jfree.data.*;
22+
import org.jfree.data.category.DefaultCategoryDataset;
23+
import org.jfree.data.general.DatasetGroup;
24+
import org.jfree.data.time.TimeSeries;
25+
import org.jfree.data.xy.DefaultHighLowDataset;
26+
import org.jfree.data.xy.XYDataset;
27+
28+
import black.Utils;
529
import gray.Global;
630
import red.Stock;
731

832
public class GraphFramePanel_Chart extends JPanel{
9-
Stock stock;
33+
Stock stock;
34+
35+
String symbol;
36+
ArrayList<String> date;
37+
ArrayList<Double> high;
38+
ArrayList<Double> low;
39+
ArrayList<Double> open;
40+
ArrayList<Double> adj_close;
41+
ArrayList<Double> volume;
42+
43+
BorderLayout layout = new BorderLayout();
44+
45+
DefaultHighLowDataset data;
46+
47+
JFreeChart chart;
48+
ChartPanel insidepanel;
1049

11-
String[] column;
12-
String[][] data;
50+
Double y_axis_min;
51+
Double y_axis_max;
52+
1353

1454
GraphFramePanel_Chart(){
15-
stock_price_graph();
55+
renderPanel();
1656
}
1757

58+
public void renderPanel() {
59+
removeAll();
60+
setLayout(layout);
61+
62+
data = createDataset();
63+
chart = createChart(data);
64+
insidepanel = new ChartPanel(chart);
65+
add(insidepanel);
66+
67+
68+
validate();
69+
repaint();
70+
}
1871

72+
public DefaultHighLowDataset createDataset() {
73+
stock = new Stock(Global.SYMBOL);
74+
75+
symbol = stock.SYMBOL;
76+
date = stock.request("DATE", "2017-09-01", "2017-11-01");
77+
high = stock.request("HIGH", "2017-09-01", "2017-11-01");
78+
low = stock.request("LOW", "2017-09-01", "2017-11-01");
79+
open = stock.request("OPEN", "2017-09-01", "2017-11-01");
80+
adj_close = stock.request("ADJ_CLOSE", "2017-09-01", "2017-11-01");
81+
volume = stock.request("VOLUME", "2017-09-01", "2017-11-01");
82+
83+
Date[] date_list = new Date[date.size()];
84+
date_list = Utils.StringToDate(date);
85+
double[] high_list = new double[high.size()];
86+
double[] low_list = new double[low.size()];
87+
double[] open_list = new double[open.size()];
88+
double[] adj_close_list = new double[adj_close.size()];
89+
double[] volume_list = new double[volume.size()];
90+
for (int i=0; i<high_list.length; i++) {
91+
high_list[i] = high.get(i);
92+
low_list[i] = low.get(i);
93+
open_list[i] = open.get(i);
94+
adj_close_list[i] = adj_close.get(i);
95+
volume_list[i] = volume.get(i);
96+
}
97+
98+
y_axis_min = Collections.min(low);
99+
y_axis_max = Collections.max(high);
100+
101+
DefaultHighLowDataset data = null;
102+
data = new DefaultHighLowDataset(symbol, date_list, high_list, low_list, open_list, adj_close_list, volume_list);
103+
104+
return data;
105+
}
106+
107+
private JFreeChart createChart(final DefaultHighLowDataset dataset) {
108+
109+
chart = ChartFactory.createCandlestickChart("History of " + stock.SYMBOL, "Time", "Price", dataset, true);
110+
111+
XYPlot plot = chart.getXYPlot();
112+
CandlestickRenderer renderer = (CandlestickRenderer) plot.getRenderer();
113+
renderer.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST);
114+
115+
NumberAxis domain = (NumberAxis) plot.getRangeAxis();
116+
domain.setRange(y_axis_min - 1, y_axis_max + 1);
117+
118+
return chart;
119+
}
19120
}

Diff for: Statistical_Analysis/GUISource/graphFrame/GraphFramePanel_Mother.java

+10-1
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,23 @@
44

55
public class GraphFramePanel_Mother extends JPanel{
66
GraphFramePanel_Chart chart;
7+
GraphFramePanel_Search search;
78

89
GraphFramePanel_Mother() {
10+
renderpanel();
11+
}
12+
13+
public void renderpanel() {
914
setLayout(null);
1015

1116
chart = new GraphFramePanel_Chart();
12-
chart.setBounds(0,0,200,100);
17+
chart.setBounds(0, 0, 800, 500);
18+
19+
search = new GraphFramePanel_Search();
20+
search.setBounds(820, 20, 200, 50);
1321

1422
add(chart);
23+
add(search);
1524
}
1625

1726
}

Diff for: Statistical_Analysis/GUISource/graphFrame/GraphFrame_Mother.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
package graphFrame;
2+
import java.awt.BorderLayout;
3+
24
import javax.swing.*;
35

46
public class GraphFrame_Mother extends JInternalFrame{
57
GraphFramePanel_Mother motherpanel;
68

9+
BorderLayout layout = new BorderLayout();
710
public GraphFrame_Mother() {
811
super("Stock Data Graph", true, true, true, true);
9-
setSize(1100,600);
12+
setLayout(layout);
13+
setSize(1050,600);
1014
setLocation(500,0);
1115

1216
motherpanel = new GraphFramePanel_Mother();

Diff for: Statistical_Analysis/GUISource/white/GUIMain.java

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package white;
22

3-
import java.awt.Font;
4-
import java.awt.GraphicsEnvironment;
53

64
import gray.Global;
75

Diff for: Statistical_Analysis/GUISource/white/MotherFrame.java

+11-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class MotherFrame extends JFrame{
2727

2828
JMenuItem menuitem_gate;
2929

30-
JMenuItem graphpanelMI1;
30+
JMenuItem pricegraph;
3131
JMenuItem graphpanelMI2;
3232

3333
JMenuItem generalinfoMI1;
@@ -53,6 +53,7 @@ public MotherFrame() {
5353
private void createDefaultInternalFrames() {
5454
jdpDesktop.add(new GateFrame_Mother());
5555
jdpDesktop.add(new GeneralInfoFrame_Mother());
56+
jdpDesktop.add(new GraphFrame_Mother());
5657
}
5758

5859
private void setInternalFramework() {
@@ -66,7 +67,7 @@ private void setMotherFrame() {
6667
borderlayout = new BorderLayout();
6768
setLayout(borderlayout);
6869
setSize(1024, 768);
69-
this.setBounds(0, 0, 1600, 900);
70+
this.setBounds(0, 0, 1600, 1000);
7071
this.setVisible(true);
7172
}
7273

@@ -94,7 +95,13 @@ public void actionPerformed(ActionEvent e) {
9495
});
9596

9697

97-
graphpanelMI1 = new JMenuItem("graphpanelMI1");
98+
pricegraph = new JMenuItem("pricegraph");
99+
pricegraph.addActionListener(new ActionListener() {
100+
public void actionPerformed(ActionEvent e) {
101+
System.out.println("Creating Price Graph");
102+
jdpDesktop.add(new GraphFrame_Mother());
103+
}
104+
});
98105
graphpanelMI2 = new JMenuItem("graphpanelMI2");
99106

100107
generalinfoMI1 = new JMenuItem("General Stock Information");
@@ -112,7 +119,7 @@ public void actionPerformed(ActionEvent e) {
112119

113120
mainpanelmothermenu.add(menuitem_gate);
114121

115-
graphpanelmothermenu.add(graphpanelMI1);
122+
graphpanelmothermenu.add(pricegraph);
116123
graphpanelmothermenu.add(graphpanelMI2);
117124

118125
generalinfomothermenu.add(generalinfoMI1);

Diff for: Statistical_Analysis/src/black/DataRetriever.java

+10-11
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ public void retrieve(String SYMBOL) {
130130
list.add(tmpList[2]); //High
131131
list.add(tmpList[3]); //Low
132132
list.add(tmpList[4]); //Close
133-
list.add(tmpList[5]); //Volume
134-
list.add(tmpList[6]); //Adjusted Close
135-
list.add(tmpList[7]); //stock split event
133+
list.add(tmpList[5]);
134+
list.add(tmpList[6]);
135+
list.add(tmpList[7]);
136136

137137
if(u != 0) {
138138
Close_M.put(tmpList[0], Double.valueOf(tmpList[4]));
@@ -201,16 +201,15 @@ else if(UpdateControl.CheckValidationData(SYMBOL)) {
201201
System.out.println("Bad Data!");
202202
break;
203203
}
204-
205-
list.add(tmpList[0]);
206-
list.add(tmpList[1]);
207-
list.add(tmpList[2]);
208-
list.add(tmpList[3]);
209-
list.add(tmpList[4]);
204+
205+
list.add(tmpList[0]); //Time
206+
list.add(tmpList[1]); //Open
207+
list.add(tmpList[2]); //High
208+
list.add(tmpList[3]); //Low
209+
list.add(tmpList[4]); //Close
210210
list.add(tmpList[5]); //Adj Close
211211
list.add(tmpList[6]); //Volume
212-
list.add(tmpList[7]); //stock split event
213-
212+
list.add(tmpList[7]); //Dividend
214213
if(u != 0) {
215214
Close_M.put(tmpList[0], Double.valueOf(tmpList[4]));
216215
Open_M.put(tmpList[0], Double.valueOf(tmpList[1]));

Diff for: Statistical_Analysis/src/black/Utils.java

+17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package black;
22

33
import java.util.*;
4+
5+
import javax.swing.text.DateFormatter;
6+
47
import java.io.*;
58
import java.time.*;
69
import java.time.format.*;
@@ -196,4 +199,18 @@ public final static String[][] ArrayListToPlain(ArrayList A1, int colsize) {
196199

197200
return retList;
198201
}
202+
203+
public final static Date[] StringToDate(ArrayList A1) {
204+
Date[] retarr = new Date[A1.size()];
205+
DateFormatter format;
206+
207+
for(int i = 0; i < retarr.length; i++) {
208+
LocalDate d ;
209+
d = LocalDate.parse(A1.get(i).toString());
210+
Date date = Date.from(d.atStartOfDay(ZoneId.systemDefault()).toInstant());
211+
212+
retarr[i] = date;
213+
}
214+
return retarr;
215+
}
199216
}

Diff for: Statistical_Analysis/src/red/Portfolio.java

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package red;
22

33
import java.util.*;
4-
import org.apache.commons.math3.*;
5-
import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
64
import black.*;
75
import blue.*;
86

Diff for: Statistical_Analysis/src/red/Stock.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public Stock(String SYMBOL) {
5050
this.Close = DR.Close;
5151
this.Date = DR.Date;
5252
this.Open = DR.Open;
53-
this.Volume = DR.Open;
53+
this.Volume = DR.Volume;
5454
this.High = DR.High;
5555
this.Low = DR.Low;
5656
this.Adj_Close = DR.Adj_Close;

0 commit comments

Comments
 (0)