-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject.c
More file actions
79 lines (68 loc) · 2.17 KB
/
Copy pathproject.c
File metadata and controls
79 lines (68 loc) · 2.17 KB
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "stock_analyzer.h"
#define APIKEY "4Z81PYCE9QHTYYBF"
// clears console to make output look better
// making it compatible with windows/linux
// might work on this project more after this class
void clearConsole(){
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
}
int main(){
int option;
char symbol[10];
while(1){
clearConsole();
printf("=====================================\n");
printf(" Stock Analyzer\n");
printf("=====================================\n");
printf("1. Get Current Stock Price\n");
printf("2. Get 100 Analysis of Stock\n");
printf("3. Get Stock Analysis within a date range\n");
printf("4. Exit\n");
printf("Select an option(1, 2, 3, or 4): ");
scanf("%d", &option);
if(option == 4){
printf("Exiting Program\n");
return 0;
}
printf("Enter stock symbol: ");
scanf("%s", symbol);
if(option == 1){
clearConsole();
// get current stock price
printf("Getting current stock price of %s\n", symbol);
getCurrentPrice(symbol);
}
else if(option == 2){
clearConsole();
// get historical stock data
printf("Getting historical stock data of %s\n", symbol);
getHistoricPrice(symbol);
}
else if(option == 3){
// get historical stock data
char startDate[11];
char endDate[11];
printf("Enter start date (YYYY-MM-DD): ");
scanf("%s", startDate);
printf("Enter end date (YYYY-MM-DD): ");
scanf("%s", endDate);
clearConsole();
printf("Getting historical stock data of %s from %s to %s\n", symbol, startDate, endDate);
getDateRangePrice(symbol, startDate, endDate);
}
else{
printf("Invalid option. Please select 1 or 2.\n");
return 1;
}
printf("\nPress Enter to go back to the menu");
getchar();
getchar();
}
}