-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAPIInterface.java
More file actions
75 lines (66 loc) · 2.44 KB
/
APIInterface.java
File metadata and controls
75 lines (66 loc) · 2.44 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
package model;
import java.net.URL;
import java.time.LocalDate;
import java.util.List;
import java.util.TreeMap;
/**
* Interface for interacting with financial data APIs such as Alpha Vantage.
* This interface provides methods to construct URLs for API calls, fetch and process stock data,
* and manage CSV files containing stock ticker information.
*/
public interface APIInterface {
/**
* Creates a URL for accessing Alpha Vantage API data.
*
* @param function the function type for the API call (e.g., "TIME_SERIES_DAILY")
* @param stockSymbol the stock ticker symbol
* @return a URL object pointing to the Alpha Vantage API endpoint for the given function and
* stock symbol
*/
URL urlMaker(String function, String stockSymbol);
/**
* Retrieves data from the Alpha Vantage API or any similar financial data API using
* the provided URL.
*
* @param url The URL pointing to the API endpoint from which data is to be fetched.
* @return A string representation of the data retrieved from the API.
*/
String returnData(URL url);
/**
* Creates a URL for accessing Alpha Vantage API data.
*
* @param function the function type for the API call (e.g., "TIME_SERIES_DAILY")
* @param ticker the stock ticker symbol
* @return a URL object pointing to the Alpha Vantage API endpoint for the given function
* and stock symbol
*/
String makeCSVFile(String function, String ticker);
/**
* Fetches historical stock prices from a CSV file and returns them as a TreeMap.
*
* @param fileName the name of the CSV file containing stock data
* @return a TreeMap with dates as keys and closing prices as values
*/
TreeMap<LocalDate, Double> fetchStockHistory(String fileName);
/**
* Converts a CSV file of tickers into a list of strings.
*
* @return a list of tickers from the CSV file
*/
List<String> tickerCSVToList();
/**
* Creates a model.Stock object by fetching historical data for the given ticker.
*
* @param ticker the stock ticker symbol
* @return a model.Stock object containing the ticker and its historical prices
* @throws IllegalArgumentException if there is an issue with the API or no data is found
*/
Stock makeStock(String ticker);
/**
* Creates a CSV file containing all American tickers from Alpha Vantage and returns the
* filename.
*
* @return the filename of the CSV file created
*/
String makeAllTickerCSVFile();
}