예제 #1
0
 @Cacheable(value = "KLineBuss.querySeriesByCode")
 public Series querySeriesByCode(String code, int month) {
   Futures prod = productBuss.queryFuturesByCode(code);
   if (prod == null) {
     return Series.EMPTY;
   } else {
     List<KLine> kLineList = null;
     if (month < 0) {
       kLineList = this.queryAscByCode(code);
     } else {
       Calendar cal = Calendar.getInstance();
       Date endDt = cal.getTime();
       cal.add(Calendar.MONTH, -month);
       Date startDt = cal.getTime();
       kLineList = kLineRepos.findByCodeAndDtBetweenOrderByDtAsc(code, startDt, endDt);
     }
     List<Price> prices =
         kLineList
             .stream()
             .map(
                 kLine -> {
                   return new Price(kLine.getDt(), kLine.getEndPrice());
                 })
             .collect(Collectors.toList());
     return new Series(prod.getCode(), prod.getName(), prices);
   }
 }
예제 #2
0
 public ProdDailyPrice queryProdDailyPrice(String code, int month) {
   Futures prod = productBuss.queryFuturesByCode(code);
   if (prod == null) {
     return null;
   } else {
     List<KLine> kLineList = null;
     List<ProdIndex> indexList = null;
     if (month < 0) {
       // 所有
       kLineList = kLineRepos.findByCodeOrderByDtAsc(code);
       indexList = prodIndexRepos.findByCodeOrderByDtAsc(code);
     } else {
       // 指定月数
       Calendar cal = Calendar.getInstance();
       Date endDt = cal.getTime();
       cal.add(Calendar.MONTH, -month);
       Date startDt = cal.getTime();
       kLineList = kLineRepos.findByCodeAndDtBetweenOrderByDtAsc(code, startDt, endDt);
       indexList = prodIndexRepos.findByCodeAndDtBetweenOrderByDtAsc(code, startDt, endDt);
     }
     List<Price> mainPriceList =
         kLineList
             .stream()
             .map(
                 kLine -> {
                   return new Price(kLine.getDt(), kLine.getEndPrice());
                 })
             .collect(Collectors.toList());
     List<Price> indexPriceList =
         indexList
             .stream()
             .map(
                 index -> {
                   return new Price(index.getDt(), index.getPrice());
                 })
             .collect(Collectors.toList());
     return new ProdDailyPrice(prod.getCode(), prod.getName(), mainPriceList, indexPriceList);
   }
 }
예제 #3
0
 @Cacheable(value = "KLineBuss.queryAllGroup")
 public List<KLineGroup> queryAllGroup() {
   Map<Date, Map<String, KLine>> kLineMap =
       kLineRepos
           .findAll()
           .stream()
           .collect(
               Collectors.groupingBy(
                   KLine::getDt, Collectors.toMap(KLine::getCode, kLine -> kLine)));
   List<KLineGroup> list =
       kLineMap
           .entrySet()
           .stream()
           .map(entry -> new KLineGroup(entry.getKey(), entry.getValue()))
           .sorted()
           .collect(Collectors.toList());
   return Collections.unmodifiableList(list);
 }
예제 #4
0
 @Cacheable(value = "KLineBuss.queryAscByCode")
 public List<KLine> queryAscByCode(String code) {
   return Collections.unmodifiableList(kLineRepos.findByCodeOrderByDtAsc(code));
 }