Package org.springframework.nanotrader.service.domain

Examples of org.springframework.nanotrader.service.domain.CollectionResult


        return holdingResponse;
    }
   
   
    public CollectionResult findHoldingsByAccountId(Integer accountId, Integer page, Integer pageSize) {
        CollectionResult  collectionResults = new CollectionResult();
       
       
        if (log.isDebugEnabled()) {
            log.debug("TradingServiceFacade.findHoldingsByAccount: id=" + accountId);
        }
       
       
        List<Holding> holdingResponse = new ArrayList<Holding>();
        collectionResults.setTotalRecords(tradingService.findCountOfHoldingsByAccountId(accountId));
        List<org.springframework.nanotrader.data.domain.Holding> holdings = tradingService.findHoldingsByAccountId(accountId, getPage(page), getPageSize(pageSize));
   
        if (holdings != null  &&  holdings.size() > 0) {         
            Set<String> symbols = new HashSet<String>();
            for (org.springframework.nanotrader.data.domain.Holding h: holdings) {
                //get unique quotes symbols
                symbols.add(h.getQuoteSymbol());
            }
           
            Map<String, Quote> currentQuotes = getCurrentQuotes(symbols);
            for(org.springframework.nanotrader.data.domain.Holding h: holdings) {
                Holding holding = new Holding();
                mapper.map(h, holding, HOLDING_MAPPING);
                holding.setQuote(currentQuotes.get(h.getQuoteSymbol()));
                holdingResponse.add(holding);
            }
        }
        if (log.isDebugEnabled()) {
            log.debug("TradingServiceFacade.findHoldingsByAccountId completed");
        }
        collectionResults.setPage(getPage(page));
        collectionResults.setPageSize(getPageSize(pageSize));
        collectionResults.setResults(holdingResponse);
     
       
     
        return collectionResults;
    }
View Full Code Here


        mapper.map(orderRequest, order, ORDER_MAPPING);
        tradingService.updateOrder(order);
    }

    public CollectionResult findOrders(Integer accountId, String status, Integer page, Integer pageSize) {
      CollectionResult  collectionResults = new CollectionResult();
        if (log.isDebugEnabled()) {
            log.debug("OrderController.findOrders: accountId=" + accountId + " status" + status);
        }
        List<org.springframework.nanotrader.data.domain.Order> orders = null;
       
        collectionResults.setTotalRecords(tradingService.findCountOfOrders(accountId, status));
        if (status != null) {
            orders = tradingService.findOrdersByStatus(accountId, status, getPage(page), getPageSize(pageSize)); //get by status
        } else {
            orders = tradingService.findOrders(accountId, getPage(page), getPageSize(pageSize)); //get all orders
        }
       
      
        List<Order> responseOrders = new ArrayList<Order>();
        if (orders != null && orders.size() > 0 ) {
           
       
            for(org.springframework.nanotrader.data.domain.Order o: orders) {
                Order order = new Order();
                mapper.map(o, order, ORDER_MAPPING);
                responseOrders.add(order);
            }
        }
       
        collectionResults.setPage(getPage(page));
        collectionResults.setPageSize(getPageSize(pageSize));
        collectionResults.setResults(responseOrders);
       
        return collectionResults;
    }
View Full Code Here

   
    public CollectionResult findQuotes() {
        if (log.isDebugEnabled()) {
            log.debug("TradingServiceFacade: findQuotes");
        }
        CollectionResult  collectionResults = new CollectionResult();
        List<org.springframework.nanotrader.data.domain.Quote> quotes = null;
        Long totalRecords = new Long(tradingService.findAllQuotes().size());
        collectionResults.setTotalRecords(totalRecords);
        quotes = tradingService.findAllQuotes(); //get all quotes
        List<Quote> responseQuotes = new ArrayList<Quote>();
        if (quotes != null && quotes.size() > 0 ) {
            for(org.springframework.nanotrader.data.domain.Quote o: quotes) {
                Quote quote = new Quote();
                mapper.map(o, quote, QUOTE_MAPPING);
                responseQuotes.add(quote);
            }
        }
        collectionResults.setResults(responseQuotes);
        return collectionResults;
    }
View Full Code Here

TOP

Related Classes of org.springframework.nanotrader.service.domain.CollectionResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.