コード例 #1
0
    /**
     * Updates this bar with last price.
     *
     * @param price Price.
     */
    public synchronized void update(double price) {
      if (open == 0) open = price;

      high = Math.max(high, price);
      low = Math.min(low, price);
      close = price;
    }
コード例 #2
0
    /**
     * Updates this bar with next bar.
     *
     * @param bar Next bar.
     */
    public synchronized void update(Bar bar) {
      if (open == 0) open = bar.open;

      high = Math.max(high, bar.high);
      low = Math.min(low, bar.low);
      close = bar.close;
    }
コード例 #3
0
 /**
  * Rounds double value to two significant signs.
  *
  * @param val value to be rounded.
  * @return rounded double value.
  */
 private static double round2(double val) {
   return Math.floor(100 * val + 0.5) / 100;
 }