コード例 #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
 public List<Series> compareProd(Futures f1, Futures f2) {
   Series s1 = dailyPriceBuss.querySeriesByCode(f1.getCode(), -1);
   Series s2 = dailyPriceBuss.querySeriesByCode(f2.getCode(), -1);
   Formula formula =
       Formula.create()
           .putConstant(BigDecimal.ZERO)
           .putMultinomial(f1.getCode(), "1")
           .putMultinomial(f2.getCode(), "-1");
   List<Price> diffPriceList = this.calculateKLine(formula, dailyPriceBuss.queryAllGroup());
   String diffName = f1.getName() + "-" + f2.getName();
   Series diffSeries = new Series("", diffName, diffPriceList);
   return Arrays.asList(s1, s2, diffSeries);
 }