com.webull.openapi.example.quotes.QuotesGrpcApi Maven / Gradle / Ivy
package com.webull.openapi.example.quotes;
import com.webull.openapi.common.dict.Category;
import com.webull.openapi.common.dict.Timespan;
import com.webull.openapi.example.config.Env;
import com.webull.openapi.execption.ClientException;
import com.webull.openapi.execption.ServerException;
import com.webull.openapi.logger.Logger;
import com.webull.openapi.logger.LoggerFactory;
import com.webull.openapi.quotes.api.QuotesApiClient;
import com.webull.openapi.quotes.domain.Bar;
import com.webull.openapi.quotes.domain.Instrument;
import com.webull.openapi.quotes.domain.Quote;
import com.webull.openapi.quotes.domain.Snapshot;
import com.webull.openapi.quotes.domain.Tick;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class QuotesGrpcApi {
private static final Logger logger = LoggerFactory.getLogger(QuotesGrpcApi.class);
public static void main(String[] args) {
String symbol = "AAPL";
try (QuotesApiClient quotesApiClient = QuotesApiClient.builder()
.appKey(Env.APP_KEY)
.appSecret(Env.APP_SECRET)
.regionId(Env.REGION_ID)
.build()) {
// get instruments
Set symbols = new HashSet<>();
symbols.add(symbol);
List instruments = quotesApiClient.getInstruments(symbols, Category.US_STOCK.name());
logger.info("Instruments: {}", instruments);
// get bars
List bars = quotesApiClient.getBars(symbol, Category.US_STOCK.name(), Timespan.D.name(), 10);
logger.info("Bars: {}", bars);
// get quote
Quote quote = quotesApiClient.getQuote(symbol, Category.US_STOCK.name());
logger.info("Quote: {}", quote);
// get snapshots
List snapshots = quotesApiClient.getSnapshots(symbols, Category.US_STOCK.name());
logger.info("Snapshots: {}", snapshots);
// get ticks
List ticks = quotesApiClient.getTicks(symbol, Category.US_STOCK.name(), 10);
logger.info("Ticks: {}", ticks);
} catch (ClientException ex) {
logger.error("Client error", ex);
} catch (ServerException ex) {
logger.error("Sever error", ex);
} catch (Exception ex) {
logger.error("Unknown error", ex);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy