Skip to content

Commit 60a5afd

Browse files
committed
Now can use adjusted close price also
1 parent ae4c5e8 commit 60a5afd

File tree

15 files changed

+12393
-14006
lines changed

15 files changed

+12393
-14006
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[[{"location":"C:\\Program Files\\Java\\jre1.8.0_144","type":"JRE","hints":{"EXECUTION_ENVIRONMENT":"JavaSE-1.8"}},"jre:jre:1.8.0"]]
1+
{}
Binary file not shown.

Statistical_Analysis/Data/AAPL.csv

Lines changed: 4494 additions & 4493 deletions
Large diffs are not rendered by default.

Statistical_Analysis/Data/ADBE.csv

Lines changed: 0 additions & 4493 deletions
This file was deleted.

Statistical_Analysis/Data/EDIG.csv

Lines changed: 4494 additions & 0 deletions
Large diffs are not rendered by default.

Statistical_Analysis/Data/GENE.csv

Lines changed: 3068 additions & 3067 deletions
Large diffs are not rendered by default.

Statistical_Analysis/Data/TSLA.csv

Lines changed: 0 additions & 1856 deletions
This file was deleted.
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
AAPL,2017-11-07,2000-01-03
2-
TSLA,2017-11-07,2010-06-29
3-
GENE,2017-11-07,2005-09-06
4-
ADBE,2017-11-07,2000-01-03
1+
EDIG,2017-11-08,2000-01-03
2+
AAPL,2017-11-08,2000-01-03
3+
GENE,2017-11-08,2005-09-06
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
2+
/*
3+
Stock S = new Stock("TSLA");
4+
S.retrieve();
5+
//S.printClose();
6+
System.out.println(S.Close_M.get("2011-04-15"));
7+
8+
ArrayList testArr = null;
9+
ArrayList testArr2 = null;
10+
testArr = S.request("CLOSE", "2014-01-01", "2015-12-30");
11+
testArr2 = S.request("DATE", "2014-01-01", "2015-12-30");
12+
13+
for(int i = 0; i < testArr.size(); i++) {
14+
System.out.println(testArr2.get(i) + " :::: " + testArr.get(i));
15+
}
16+
System.out.println("Price at target date : " + S.Close_M.get("2015-12-30"));
17+
*/ //These tests are done. Stock class finished.
18+
19+
//SStat class test
20+
21+
/*
22+
Stock S = new Stock("AAPL");
23+
Stock S_TSLA = new Stock("TSLA");
24+
Stock S_GENE = new Stock("GENE");
25+
Stock S_ADBE = new Stock("ADBE");
26+
Stock S_EDIG = new Stock("EDIG");
27+
28+
S.retrieve();
29+
S_TSLA.retrieve();
30+
S_GENE.retrieve();
31+
S_ADBE.retrieve();
32+
S_EDIG.retrieve();
33+
34+
SStat St = new SStat(S);
35+
SStat St2 = new SStat(S_TSLA);
36+
SStat St3 = new SStat(S_GENE);
37+
SStat St4 = new SStat(S_ADBE);
38+
SStat St5 = new SStat(S_EDIG);
39+
40+
System.out.println("<<<" + S.SYMBOL + ">>>");
41+
System.out.println(St.Geometricmean("CLOSE", "2015-12-25", "2016-01-01"));
42+
ArrayList tmpArray1 = St.PercentageChange("CLOSE", 100, "2012-12-15", "2016-01-01");
43+
System.out.println(tmpArray1);
44+
ArrayList tmpArray2 = St.PercentageChange("OPEN", 300, "2012-12-15", "2016-01-01");
45+
System.out.println(tmpArray2);
46+
47+
System.out.println("<<<" + S_TSLA.SYMBOL + ">>>");
48+
System.out.println(St2.Geometricmean("CLOSE", "2015-12-25", "2016-01-01"));
49+
tmpArray1 = St2.PercentageChange("CLOSE", 100, "2012-12-15", "2016-01-01");
50+
System.out.println(tmpArray1);
51+
tmpArray2 = St2.PercentageChange("OPEN", 300, "2012-12-15", "2016-01-01");
52+
System.out.println(tmpArray2);
53+
54+
System.out.println("<<<" + S_GENE.SYMBOL + ">>>");
55+
System.out.println(St3.Geometricmean("CLOSE", "2015-12-25", "2016-01-01"));
56+
tmpArray1 = St3.PercentageChange("CLOSE", 100, "2012-12-15", "2016-01-01");
57+
System.out.println(tmpArray1);
58+
tmpArray2 = St3.PercentageChange("OPEN", 300, "2012-12-15", "2016-01-01");
59+
System.out.println(tmpArray2);
60+
61+
System.out.println("<<<" + S_ADBE.SYMBOL + ">>>");
62+
63+
System.out.println("<<<" + S_EDIG.SYMBOL + ">>>");
64+
System.out.println(St5.Geometricmean("CLOSE", "2015-12-25", "2016-01-01"));
65+
tmpArray1 = St5.PercentageChange("CLOSE", 100, "2012-12-15", "2016-01-01");
66+
System.out.println(tmpArray1);
67+
tmpArray2 = St5.PercentageChange("OPEN", 300, "2012-12-15", "2016-01-01");
68+
System.out.println(tmpArray2);
69+
70+
System.out.println("Geometric Mean Return : " + St.MeanReturnGeometric("CLOSE", 100, "2016-01-01", "2017-01-01"));
71+
*/
72+

Statistical_Analysis/src/gui/GUIMain.java

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ public class GUIMain extends JPanel {
2727
private int labelPadding = 25;
2828
private Color lineColor = new Color(44, 102, 230, 180);
2929
private Color pointColor = new Color(100, 100, 100, 180);
30+
//private Color pointColor = new Color(44, 102, 230, 180);
3031
private Color gridColor = new Color(200, 200, 200, 200);
3132
private static final Stroke GRAPH_STROKE = new BasicStroke(2f);
32-
private int pointWidth = 4;
33-
private int numberYDivisions = 10;
33+
private int pointWidth = 2;
34+
private int numberYDivisions = 25;
3435
private List<Double> scores;
3536

3637
public GUIMain(List<Double> scores) {
@@ -45,7 +46,7 @@ protected void paintComponent(Graphics g) {
4546

4647
double xScale = ((double) getWidth() - (2 * padding) - labelPadding) / (scores.size() - 1);
4748
double yScale = ((double) getHeight() - 2 * padding - labelPadding) / (getMaxScore() - getMinScore());
48-
49+
4950
List<Point> graphPoints = new ArrayList<>();
5051
for (int i = 0; i < scores.size(); i++) {
5152
int x1 = (int) (i * xScale + padding + labelPadding);
@@ -68,7 +69,7 @@ protected void paintComponent(Graphics g) {
6869
g2.setColor(gridColor);
6970
g2.drawLine(padding + labelPadding + 1 + pointWidth, y0, getWidth() - padding, y1);
7071
g2.setColor(Color.BLACK);
71-
String yLabel = ((int) ((getMinScore() + (getMaxScore() - getMinScore()) * ((i * 1.0) / numberYDivisions)) * 100)) / 100.0 + "";
72+
String yLabel = ((int) ((getMinScore() + (getMaxScore() - getMinScore()) * ((i * 10.0) / numberYDivisions)) * 100f)) / 100.0 + "";
7273
FontMetrics metrics = g2.getFontMetrics();
7374
int labelWidth = metrics.stringWidth(yLabel);
7475
g2.drawString(yLabel, x0 - labelWidth - 5, y0 + (metrics.getHeight() / 2) - 3);
@@ -131,15 +132,15 @@ private double getMinScore() {
131132
for (Double score : scores) {
132133
minScore = Math.min(minScore, score);
133134
}
134-
return minScore;
135+
return minScore - (minScore / 50);
135136
}
136137

137138
private double getMaxScore() {
138139
double maxScore = Double.MIN_VALUE;
139140
for (Double score : scores) {
140141
maxScore = Math.max(maxScore, score);
141142
}
142-
return maxScore;
143+
return maxScore + (maxScore / 50);
143144
}
144145

145146
public void setScores(List<Double> scores) {
@@ -153,11 +154,18 @@ public List<Double> getScores() {
153154
}
154155

155156
private static void createAndShowGui() {
156-
Stock S_AAPL = new Stock("AAPL");
157+
Stock S_AAPL = new Stock("EDIG");
157158
S_AAPL.retrieve();
158-
ArrayList AAPL_A = S_AAPL.request("CLOSE", "2015-01-01", "2017-05-16");
159-
160-
GUIMain mainPanel = new GUIMain(AAPL_A);
159+
ArrayList P = S_AAPL.request("ADJ_CLOSE", "2017-05-08", "2017-11-08");
160+
//ArrayList AAPL_A = S_AAPL.request("CLOSE", "2012-01-01", "2017-01-01");
161+
162+
SStat EDIG_S = new SStat(S_AAPL);
163+
ArrayList AL = EDIG_S.PercentageChange("CLOSE", 30, "2012-01-01", "2017-01-01");
164+
ArrayList AL2 = EDIG_S.ReturnVariance("CLOSE", 30, "2012-01-01", "2017-01-01");
165+
System.out.println(AL);
166+
System.out.println(AL2);
167+
168+
GUIMain mainPanel = new GUIMain(P);
161169
mainPanel.setPreferredSize(new Dimension(800, 600));
162170
JFrame frame = new JFrame("DrawGraph");
163171
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

0 commit comments

Comments
 (0)