當前位置: 首頁>>代碼示例>>Java>>正文


Java Quote類代碼示例

本文整理匯總了Java中io.pivotal.web.domain.Quote的典型用法代碼示例。如果您正苦於以下問題:Java Quote類的具體用法?Java Quote怎麽用?Java Quote使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Quote類屬於io.pivotal.web.domain包,在下文中一共展示了Quote類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getQuotes

import io.pivotal.web.domain.Quote; //導入依賴的package包/類
private List<Quote> getQuotes(String companyName) {
	logger.debug("Fetching quotes for companies that have: " + companyName + " in name or symbol");
	List<CompanyInfo> companies = marketService.getCompanies(companyName);
	
	/*
	 * Sleuth currently doesn't work with parallelStreams
	 */
	//get distinct companyinfos and get their respective quotes in parallel.

	List<String> symbols = companies.stream().map(company -> company.getSymbol()).collect(Collectors.toList());
	logger.debug("symbols: fetching "+ symbols.size() + " quotes for following symbols: " + symbols);
	List<String> distinctsymbols = symbols.stream().distinct().collect(Collectors.toList());
	logger.debug("distinct: fetching "+ distinctsymbols.size() + " quotes for following symbols: " + distinctsymbols);
	List<Quote> quotes;
	if (distinctsymbols.size() > 0) {
		quotes = marketService.getMultipleQuotes(distinctsymbols).stream().distinct().filter(quote -> quote.getName() != null && !"".equals(quote.getName())).collect(Collectors.toList());
	} else {
		quotes = new ArrayList<>();
	}
	return quotes;
}
 
開發者ID:pivotal-bank,項目名稱:web-ui,代碼行數:22,代碼來源:TradeController.java

示例2: getQuotes

import io.pivotal.web.domain.Quote; //導入依賴的package包/類
private List<Quote> getQuotes(String companyName) {
	logger.debug("Fetching quotes for companies that have: " + companyName + " in name or symbol");
	List<CompanyInfo> companies = marketService.getCompanies(companyName);
	
	/*
	 * Sleuth currently doesn't work with parallelStreams
	 */
	//get district companyinfos and get their respective quotes in parallel.
	//List<Quote> result = companies.stream().collect(Collectors.toCollection(
	//	      () -> new TreeSet<CompanyInfo>((p1, p2) -> p1.getSymbol().compareTo(p2.getSymbol())) 
	//		)).parallelStream().map(n -> getQuote(n.getSymbol())).collect(Collectors.toList());
	List<Quote> result = companies.stream().
			collect(Collectors.toCollection(() -> new TreeSet<>((p1, p2) -> p1.getSymbol().compareTo(p2.getSymbol())))).stream().
			map(n -> getQuote(n.getSymbol()).get(0)).
               collect(Collectors.toList());
	
	List<Quote> quotes = result.parallelStream().filter(n -> n.getStatus().startsWith("SUCCESS")).collect(Collectors.toList());
	return quotes;
}
 
開發者ID:dpinto-pivotal,項目名稱:cf-SpringBootTrader,代碼行數:20,代碼來源:TradeController.java

示例3: showTrade

import io.pivotal.web.domain.Quote; //導入依賴的package包/類
@RequestMapping(value = "/trade", method = RequestMethod.POST)
public String showTrade(Model model, @ModelAttribute("search") Search search) {
	logger.debug("/trade.POST - symbol: " + search.getName());
	
	//model.addAttribute("marketSummary", marketService.getMarketSummary());
	model.addAttribute("search", search);
	
	if (search.getName() == null || search.getName().equals("") ) {
		model.addAttribute("quotes", new ArrayList<Quote>());
	} else {
		List<Quote> newQuotes = getQuotes(search.getName());
		model.addAttribute("quotes", newQuotes);
	}
	//check if user is logged in!
	Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
	if (!(authentication instanceof AnonymousAuthenticationToken)) {
	    String currentUserName = authentication.getName();
	    logger.debug("User logged in: " + currentUserName);
	    model.addAttribute("order", new Order());
	    
	    
	    //TODO: add portfolio and account summary.
	    try {
	    	model.addAttribute("portfolio",portfolioService.getPortfolio(currentUserName));
	    	model.addAttribute("accounts",accountService.getAccounts(currentUserName));
	    } catch (HttpServerErrorException e) {
	    	model.addAttribute("portfolioRetrievalError",e.getMessage());
	    }
	}
	
	return "trade";
}
 
開發者ID:pivotal-bank,項目名稱:web-ui,代碼行數:33,代碼來源:TradeController.java

示例4: getQuote

import io.pivotal.web.domain.Quote; //導入依賴的package包/類
@HystrixCommand(fallbackMethod = "getQuoteFallback")
public Quote getQuote(String symbol) {
	logger.debug("Fetching quote: " + symbol);
	List<Quote> quotes = getMultipleQuotes(symbol);
	if (quotes.size() == 1 ) {
		logger.debug("Fetched quote: " + quotes.get(0));
		return quotes.get(0);
	}
	logger.debug("exception: should only be 1 quote and got multiple or zero: " + quotes.size());
	return new Quote();
}
 
開發者ID:pivotal-bank,項目名稱:web-ui,代碼行數:12,代碼來源:QuotesService.java

示例5: getQuoteFallback

import io.pivotal.web.domain.Quote; //導入依賴的package包/類
private Quote getQuoteFallback(String symbol) {
	logger.debug("Fetching fallback quote for: " + symbol);
	Quote quote = new Quote();
	quote.setSymbol(symbol);
	quote.setStatus("FAILED");
	return quote;
}
 
開發者ID:pivotal-bank,項目名稱:web-ui,代碼行數:8,代碼來源:QuotesService.java

示例6: getMultipleQuotes

import io.pivotal.web.domain.Quote; //導入依賴的package包/類
/**
 * Retrieve multiple quotes.
 * 
 * @param symbols comma separated list of symbols.
 * @return
 */
public List<Quote> getMultipleQuotes(String symbols) {
	logger.debug("retrieving multiple quotes: " + symbols);
	Quote[] quotesArr = restTemplate.getForObject("http://" + quotesService + "/v1/quotes?q={symbols}", Quote[].class, symbols);
	List<Quote> quotes = Arrays.asList(quotesArr);
	logger.debug("Received quotes: {}",quotes);
	return quotes;
	
}
 
開發者ID:pivotal-bank,項目名稱:web-ui,代碼行數:15,代碼來源:QuotesService.java

示例7: getTopThree

import io.pivotal.web.domain.Quote; //導入依賴的package包/類
/**
 * Retrieve the list of top winners/losers.
 * Currently retrieving list of 3 random.
 */
private List<Quote> getTopThree(String symbols) {
	StringBuilder builder = new StringBuilder();
	for(Iterator<String> i = pickRandomThree(Arrays.asList(symbols.split(","))).iterator(); i.hasNext();) {
		builder.append(i.next());
		if (i.hasNext()) {
			builder.append(",");
		}
	}
	return marketService.getMultipleQuotes(builder.toString());
}
 
開發者ID:pivotal-bank,項目名稱:web-ui,代碼行數:15,代碼來源:MarketSummaryService.java

示例8: showTrade

import io.pivotal.web.domain.Quote; //導入依賴的package包/類
@RequestMapping(value = "/trade", method = RequestMethod.POST)
public String showTrade(Model model, @ModelAttribute("search") Search search) {
	logger.debug("/trade.POST - symbol: " + search.getName());
	
	//model.addAttribute("marketSummary", marketService.getMarketSummary());
	model.addAttribute("search", search);
	
	if (search.getName() == null || search.getName().equals("") ) {
		model.addAttribute("quotes", new ArrayList<Quote>());
	} else {
		List<Quote> newQuotes = getQuotes(search.getName());
		model.addAttribute("quotes", newQuotes);
	}
	//check if user is logged in!
	Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
	if (!(authentication instanceof AnonymousAuthenticationToken)) {
	    String currentUserName = authentication.getName();
	    logger.debug("User logged in: " + currentUserName);
	    model.addAttribute("order", new Order());
	    //TODO: add portfolio and account summary.
	    try {
	    	model.addAttribute("portfolio",marketService.getPortfolio(currentUserName));
	    } catch (HttpServerErrorException e) {
	    	model.addAttribute("portfolioRetrievalError",e.getMessage());
	    }
	}
	
	return "trade";
}
 
開發者ID:trujillano,項目名稱:springBootTrader-aos,代碼行數:30,代碼來源:TradeController.java

示例9: getQuotes

import io.pivotal.web.domain.Quote; //導入依賴的package包/類
private List<Quote> getQuotes(String companyName) {
	logger.debug("Fetching quotes for companies that have: " + companyName + " in name or symbol");
	List<CompanyInfo> companies = marketService.getCompanies(companyName);
	
	//get district companyinfos and get their respective quotes in parallel.
	List<Quote> result = companies.stream().collect(Collectors.toCollection(
		      () -> new TreeSet<CompanyInfo>((p1, p2) -> p1.getSymbol().compareTo(p2.getSymbol())) 
			)).parallelStream().map(n -> getQuote(n.getSymbol())).collect(Collectors.toList());
	
	List<Quote> quotes = result.parallelStream().filter(n -> n.getStatus().startsWith("SUCCESS")).collect(Collectors.toList());
	return quotes;
}
 
開發者ID:trujillano,項目名稱:springBootTrader-aos,代碼行數:13,代碼來源:TradeController.java

示例10: getQuoteFallback

import io.pivotal.web.domain.Quote; //導入依賴的package包/類
private Quote getQuoteFallback(String symbol) {
	logger.debug("Fetching fallback quote for: " + symbol);
	//Quote quote = restTemplate.getForObject("http://quotes/quote/{symbol}", Quote.class, symbol);
	Quote quote = new Quote();
	quote.setSymbol(symbol);
	quote.setStatus("FAILED");
	return quote;
}
 
開發者ID:trujillano,項目名稱:springBootTrader-aos,代碼行數:9,代碼來源:MarketService.java

示例11: retrieveMarketSummary

import io.pivotal.web.domain.Quote; //導入依賴的package包/類
@Scheduled(fixedRate = REFRESH_PERIOD)
protected void retrieveMarketSummary() {
	logger.debug("Scheduled retrieval of Market Summary");
	List<Quote> quotesIT = pickRandomThree(symbolsIT).parallelStream().map(symbol -> getQuote(symbol)).collect(Collectors.toList());
	List<Quote> quotesFS = pickRandomThree(symbolsFS).parallelStream().map(symbol -> getQuote(symbol)).collect(Collectors.toList());
	summary.setTopGainers(quotesIT);
	summary.setTopLosers(quotesFS);
}
 
開發者ID:trujillano,項目名稱:springBootTrader-aos,代碼行數:9,代碼來源:MarketService.java

示例12: showTrade

import io.pivotal.web.domain.Quote; //導入依賴的package包/類
@RequestMapping(value = "/trade", method = RequestMethod.POST)
public String showTrade(Model model, @ModelAttribute("search") Search search) {
	logger.debug("/trade.POST - symbol: " + search.getName());
	
	model.addAttribute("search", search);
	
	if (search.getName() == null || search.getName().equals("") ) {
		model.addAttribute("quotes", new ArrayList<Quote>());
	} else {
		List<Quote> newQuotes = getQuotes(search.getName());
		model.addAttribute("quotes", newQuotes);
	}
	//check if user is logged in!
	Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
	if (!(authentication instanceof AnonymousAuthenticationToken)) {
	    String currentUserName = authentication.getName();
	    logger.debug("User logged in: " + currentUserName);
	    model.addAttribute("order", new Order());
	    //TODO: add portfolio and account summary.
	    try {
	    	model.addAttribute("portfolio",marketService.getPortfolio(currentUserName));
	    } catch (HttpServerErrorException e) {
	    	model.addAttribute("portfolioRetrievalError",e.getMessage());
	    }
	}
	
	return "trade";
}
 
開發者ID:dpinto-pivotal,項目名稱:cf-SpringBootTrader,代碼行數:29,代碼來源:TradeController.java

示例13: getQuotes

import io.pivotal.web.domain.Quote; //導入依賴的package包/類
/**
 * Retrieve multiple quotes.
 * 
 * @param symbols comma separated list of symbols.
 * @return
 */
   @HystrixCommand(fallbackMethod = "getQuotesFallback",
           commandProperties = {@HystrixProperty(name="execution.timeout.enabled", value="false")})
public List<Quote> getQuotes(String symbols) {
	logger.debug("retrieving multiple quotes: " + symbols);
	Quote[] quotesArr = restTemplate.getForObject("http://" + quotesService + "/quotes?q={symbols}", Quote[].class, symbols);
	List<Quote> quotes = Arrays.asList(quotesArr);
	logger.debug("Received quotes: {}",quotes);
	return quotes;
}
 
開發者ID:dpinto-pivotal,項目名稱:cf-SpringBootTrader,代碼行數:16,代碼來源:MarketService.java

示例14: getQuotesFallback

import io.pivotal.web.domain.Quote; //導入依賴的package包/類
@SuppressWarnings("unused")
private List<Quote> getQuotesFallback(String symbols) {
    List<Quote> result = new ArrayList<>();
    String[] splitSymbols = symbols.split(",");

    for (String symbol : splitSymbols) {
        Quote quote = new Quote();
        quote.setSymbol(symbol);
        quote.setStatus("FAILED");
        result.add( quote );
    }
    return result;
}
 
開發者ID:dpinto-pivotal,項目名稱:cf-SpringBootTrader,代碼行數:14,代碼來源:MarketService.java

示例15: getTopThree

import io.pivotal.web.domain.Quote; //導入依賴的package包/類
/**
 * Retrieve the list of top winners/losers.
 * Currently retrieving list of 3 random.
 */
private List<Quote> getTopThree(String symbols) {
	StringBuilder builder = new StringBuilder();
	for(Iterator<String> i = pickRandomThree(Arrays.asList(symbols.split(","))).iterator(); i.hasNext();) {
		builder.append(i.next());
		if (i.hasNext()) {
			builder.append(",");
		}
	}
	return marketService.getQuotes(builder.toString());
}
 
開發者ID:dpinto-pivotal,項目名稱:cf-SpringBootTrader,代碼行數:15,代碼來源:MarketSummaryService.java


注:本文中的io.pivotal.web.domain.Quote類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。