-
Notifications
You must be signed in to change notification settings - Fork 1
/
Terminal.java
136 lines (111 loc) · 5.59 KB
/
Terminal.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import java.io.IOException;
import java.util.Scanner;
import financialdata.*;
import handwritingrecognition.*;
public class Terminal {
private static final String helpText = "You can try the following commands: \n equity<GO> opens an applet to search for S&P 500 component stocks \n handwriting recognition<GO> launches the handwriting applet to verify neural network performance \n GUI<GO> launches the WIP GUI";
public static void main(String[] args){
System.out.println("Welcome to the neural network price stock prediction system. Type help<GO> for more information. Type exit<GO> to quit or exit current mode.");
boolean run = true;
while (run == true){
Scanner terminalInput = new Scanner(System.in);
String input = terminalInput.nextLine();
if (input.equals("exit")) run = false;
if (input.equals("help")) System.out.println(helpText);
if (input.equals("equity")) {
// String ticker;
System.out.println();
System.out.println("You are now in equity mode.\n list stocks<GO> to see the list of tickers you can inquire about\n neural network<GO> brings up the stock price predictor \n exit<GO> will exit this mode.");
terminalInput = new Scanner(System.in);
input = terminalInput.nextLine();
Datafeed.loadStocks();
boolean runApplet = true;
boolean fund = false;
while (runApplet == true) {
if (input.equals("exit")) runApplet = false;
else if (input.equals("list stocks")) {
System.out.println(Datafeed.getTickerList());
terminalInput = new Scanner(System.in);
input = terminalInput.nextLine();
}
else if (input.equals("neural network")) {
System.out.println();
System.out.println("(WARNING: network make take multiple hours to run)");
System.out.println("The network has to be trained before predictions can be made.");
System.out.println("Input network width");
terminalInput = new Scanner(System.in);
int width = Integer.parseInt(terminalInput.nextLine());
System.out.println("Input network depth");
terminalInput = new Scanner(System.in);
int depth = Integer.parseInt(terminalInput.nextLine());
System.out.println("Input number of iterations");
terminalInput = new Scanner(System.in);
int iters = Integer.parseInt(terminalInput.nextLine());
System.out.println("Initializing network...");
DriverV2 network = new DriverV2(width,depth,iters);
network.writeMasterData();
network.feedAll();
System.out.println("Training complete.");
boolean runNetwork = true;
while (runNetwork) {
System.out.println("Ask the network which direction it thinks the price would move towards by providing it with a ticker. Else exit.");
terminalInput = new Scanner(System.in);
String askTicker = terminalInput.nextLine();
if (askTicker.equals("exit")) {
runNetwork = false;
terminalInput = new Scanner(System.in);
input = terminalInput.nextLine();
}
else System.out.println(network.giveRecommendation(askTicker));
}
}
else{
// Scanner tickerInput = new Scanner(System.in);
// ticker = tickerInput.nextLine();
if (fund) {
System.out.println();
System.out.println("Enter another ticker");
}
if (!fund) {
System.out.println();
System.out.println(Datafeed.nameFromTicker(input));
System.out.println(Datafeed.sectorFromTicker(input));
System.out.println("The newest price is $" + Datafeed.getNewestPrice(input));
System.out.println();
System.out.println("Type fundementals to get more information or enter another ticker");
}
terminalInput = new Scanner(System.in);
String input2 = terminalInput.nextLine();
if (input2.equals("exit")) runApplet = false;
else if (input2.equals("fundementals")) {
fund = true;
System.out.println();
Datafeed.printFundementals(input);
}
else input = input2;
}
}
}
if (input.equals("handwriting recognition")) {
String[] arguments = new String[1];
HandwritingNeuralNetwork.main(arguments);
terminalInput = new Scanner(System.in);
input = terminalInput.nextLine();
}
if (input.equals("GUI")) {
System.out.println("GUI is under construction.");
GUI theGUI = new GUI();
}
}
// if(ticker.equals("train")){
// DriverV2 network = new DriverV2(60,1,100);
// network.writeMasterData();
// System.out.println("got it");
// System.out.println(Datafeed.getNewestPrice(Datafeed.getTickerList().get(0))/1000);
// System.out.println(network.createInputs(Datafeed.getTickerList().get(0)).length);
// for (double i : network.createInputs(Datafeed.getTickerList().get(0))){
// System.out.println(i);
// }
// network.feedAll();
}
}