예제 #1
0
  /** 現在価格と判定価格をセット */
  private void setDatetimeAndPrice() {
    // 計算対象の時刻(現在時刻)と価格を取得
    nowDatetime = datetime + ".0";
    nowDatetimeLong = DatetimeAction.toLong(nowDatetime);
    nowPrice = fxPriceDao.getPrice(symbol, nowDatetime, PriceType.CLOSE);

    // 判定時刻と判定価格を取得
    judgeDatetimeLong = nowDatetimeLong + 60 * 1000 * periodMinute;
    judgeDatetime = DatetimeAction.toString(judgeDatetimeLong) + ".0";
    judgePrice = fxPriceDao.getPrice(symbol, judgeDatetime, PriceType.CLOSE);

    log.debug("nowDatetime:{}, judgeDatetime:{}", nowDatetime, judgeDatetime);
  }
예제 #2
0
  /** 陽線と陰線の割合を算出 */
  private void calcBarRate() {

    int countYousen = 0; // 陽線の数
    int countInsen = 0; // 陰線の数
    int countOther = 0; // 陽線でも陰線でもないbarの数
    long openDatetimeLong = nowDatetimeLong;
    long closeDatetimeLong = nowDatetimeLong + 60 * 1000 * timeFrame;

    while (closeDatetimeLong < judgeDatetimeLong) {

      // minuteを取得して、timeFrameの倍数なら価格を取得。
      int minute = DatetimeAction.getMinute(openDatetimeLong);
      if (minute % timeFrame == 0) {
        String openDatetime = DatetimeAction.toString(openDatetimeLong);
        String closeDatetime = DatetimeAction.toString(closeDatetimeLong);
        double openPrice = fxPriceDao.getPrice(symbol, openDatetime, PriceType.CLOSE);
        double closePrice = fxPriceDao.getPrice(symbol, closeDatetime, PriceType.CLOSE);

        // 陽線・陰線の判定
        if (closePrice - openPrice > 0) {
          countYousen = countYousen + 1;
        } else if (openPrice - closePrice > 0) {
          countInsen = countInsen + 1;
        } else {
          countOther = countOther + 1;
        }
      }

      // add 1min for next
      openDatetimeLong = openDatetimeLong + 60 * 1000;
      closeDatetimeLong = closeDatetimeLong + 60 * 1000;
    } // while end

    log.debug("陽線:{}本、陰線:{}本、他:{}本", countYousen, countInsen, countOther);
    yousenRate = (double) countYousen / (countYousen + countInsen + countOther) * 100;
    insenRate = (double) countInsen / (countYousen + countInsen + countOther) * 100;
    log.debug("陽線:{}%、陰線:{}%", yousenRate, insenRate);
  }