当前位置: 首页>>代码示例>>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;未经允许,请勿转载。