Package com.github.oscerd.finnhub.client
Class FinnhubClient
java.lang.Object
com.github.oscerd.finnhub.client.FinnhubClient
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionFinnhubClient(String token) FinnhubClient(String token, com.google.gson.Gson gson) -
Method Summary
Modifier and TypeMethodDescriptionbasicFinancials(String symbol, String metric) Return company news for a specific date range of a specific stock symbolGet the Stock Candle object for a date or a range.companyNews(String symbol, String from, String to) Return company news for a specific date range of a specific stock symbolcompanyProfile(String symbol) Get the company profile for a specific symbolReturn dividends history for a specific date range of a specific stock symbolcom.google.gson.GsongetGson()org.apache.hc.client5.http.impl.classic.CloseableHttpClientgetToken()marketHoliday(String exchange) Return market holidays for a specific stock exchangemarketStatus(String exchange) Return market status for a specific stock exchangeGet the current quote for a specific symbolsearchSymbol(String query) Query for a specific stock symbolvoidsetGson(com.google.gson.Gson gson) voidsetHttpClient(org.apache.hc.client5.http.impl.classic.CloseableHttpClient httpClient) voidList the supported stocks for a specific market exchange
-
Constructor Details
-
FinnhubClient
public FinnhubClient() -
FinnhubClient
-
FinnhubClient
-
-
Method Details
-
getToken
-
setToken
-
getGson
public com.google.gson.Gson getGson() -
setGson
public void setGson(com.google.gson.Gson gson) -
getHttpClient
public org.apache.hc.client5.http.impl.classic.CloseableHttpClient getHttpClient() -
setHttpClient
public void setHttpClient(org.apache.hc.client5.http.impl.classic.CloseableHttpClient httpClient) -
quote
Get the current quote for a specific symbol- Parameters:
symbol- Ticker symbol- Returns:
- JSON object with arrays for the current price, change, percent change, high, low, open and previous close price
- Throws:
IOExceptionorg.apache.hc.core5.http.ParseException
-
candle
public StockCandles candle(String symbol, String resolution, long startEpoch, long endEpoch) throws IOException, org.apache.hc.core5.http.ParseException Get the Stock Candle object for a date or a range. Set startEpoch equal to the endEpoch for one day.- Parameters:
symbol- Ticker symbolresolution- Supported resolution includes 1, 5, 15, 30, 60, D, W, M. Some timeframes might not be available depending on the exchange.startEpoch- In seconds, not milliseconds.endEpoch- As above.- Returns:
- JSON object with arrays for the close, low, high, open, volume. status is a String.
- Throws:
IOExceptionorg.apache.hc.core5.http.ParseException
-
companyProfile
public CompanyProfile2 companyProfile(String symbol) throws IOException, org.apache.hc.core5.http.ParseException Get the company profile for a specific symbol- Parameters:
symbol- Ticker symbol- Returns:
- JSON object with information about the company
- Throws:
IOExceptionorg.apache.hc.core5.http.ParseException
-
symbols
public List<StockSymbol> symbols(String exchange) throws IOException, org.apache.hc.core5.http.ParseException List the supported stocks for a specific market exchange- Parameters:
exchange- Market exchange- Returns:
- JSON array with list of supported stocks enriched with more details
- Throws:
IOExceptionorg.apache.hc.core5.http.ParseException
-
searchSymbol
public SymbolLookup searchSymbol(String query) throws IOException, org.apache.hc.core5.http.ParseException Query for a specific stock symbol- Parameters:
query- Query text can be symbol, name, isin, or cusip.- Returns:
- JSON array with list of supported stocks enriched with more details
- Throws:
IOExceptionorg.apache.hc.core5.http.ParseException
-
marketStatus
public MarketStatus marketStatus(String exchange) throws IOException, org.apache.hc.core5.http.ParseException Return market status for a specific stock exchange- Parameters:
exchange- Exchange code- Returns:
- JSON object with market status
- Throws:
IOExceptionorg.apache.hc.core5.http.ParseException
-
marketHoliday
public MarketHoliday marketHoliday(String exchange) throws IOException, org.apache.hc.core5.http.ParseException Return market holidays for a specific stock exchange- Parameters:
exchange- Exchange code- Returns:
- JSON arrays with the holidays for the specific stock exchange
- Throws:
IOExceptionorg.apache.hc.core5.http.ParseException
-
dividends
public List<Dividends> dividends(String symbol, String from, String to) throws IOException, org.apache.hc.core5.http.ParseException Return dividends history for a specific date range of a specific stock symbol- Parameters:
symbol- Exchange codefrom- from date with format YYYY-MM-DDto- from date with format YYYY-MM-DD- Returns:
- JSON arrays with the dividends for specific date range
- Throws:
IOExceptionorg.apache.hc.core5.http.ParseException
-
companyNews
public List<CompanyNews> companyNews(String symbol, String from, String to) throws IOException, org.apache.hc.core5.http.ParseException Return company news for a specific date range of a specific stock symbol- Parameters:
symbol- Exchange codefrom- from date with format YYYY-MM-DDto- from date with format YYYY-MM-DD- Returns:
- JSON arrays with the company news for specific date range
- Throws:
IOExceptionorg.apache.hc.core5.http.ParseException
-
basicFinancials
public BasicFinancials basicFinancials(String symbol, String metric) throws IOException, org.apache.hc.core5.http.ParseException Return company news for a specific date range of a specific stock symbol- Parameters:
symbol- Exchange codemetric- the metric to return, supported value is only 'all'- Returns:
- JSON arrays with the company basic financials such as margin, P/E ratio, 52-week high/low etc.
- Throws:
IOExceptionorg.apache.hc.core5.http.ParseException
-