-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStockExample.java
More file actions
50 lines (39 loc) · 1.5 KB
/
StockExample.java
File metadata and controls
50 lines (39 loc) · 1.5 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
/*
* FCS API - Stock Example
* Get your API key at: https://fcsapi.com
*
* This example only uses the Stock module (FcsStock)
* Other modules (Forex, Crypto) are not loaded
*
* Run: javac -cp ".:../../lib/*" StockExample.java && java -cp ".:../../lib/*" StockExample
*/
package examples;
import com.fcsapi.FcsApi;
import com.fcsapi.FcsStock;
import java.util.Map;
public class StockExample {
public static void main(String[] args) {
// Initialize API - only Stock module will be used
FcsApi fcsapi = new FcsApi();
// Access only Stock module
FcsStock stock = fcsapi.getStock();
System.out.println("=== Symbols List ===\n");
Map<String, Object> result = stock.getSymbolsList("NASDAQ");
System.out.println(result);
System.out.println("\n\n=== Latest Price ===\n");
result = stock.getLatestPrice("NASDAQ:AAPL");
System.out.println(result);
System.out.println("\n\n=== Historical Data ===\n");
result = stock.getHistory("NASDAQ:AAPL", "1D", 5);
System.out.println(result);
System.out.println("\n\n=== Profile ===\n");
result = stock.getProfile("AAPL");
System.out.println(result);
System.out.println("\n\n=== Earnings ===\n");
result = stock.getEarnings("NASDAQ:AAPL");
System.out.println(result);
System.out.println("\n\n=== Indices Latest ===\n");
result = stock.getIndicesLatest("NASDAQ:NDX,SP:SPX");
System.out.println(result);
}
}