package org.knowm.xchange.dto.marketdata;

import java.math.BigDecimal;
import java.util.Date;

import org.knowm.xchange.currency.CurrencyPair;
import org.knowm.xchange.utils.DateUtils;

/**
 * <p>
 * A class encapsulating the information a "Ticker" can contain. Some fields can be empty if not provided by the exchange.
 * </p>
 * <p>
 * A ticker contains data representing the latest trade.
 * </p>
 */
public final class Ticker {

  private final CurrencyPair currencyPair;
  private final BigDecimal last;
  private final BigDecimal bid;
  private final BigDecimal ask;
  private final BigDecimal high;
  private final BigDecimal low;
  private final BigDecimal vwap;
  private final BigDecimal volume;
  /**
   * the timestamp of the ticker according to the exchange's server, null if not provided
   */
  private final Date timestamp;

  /**
   * Constructor
   *
   * @param currencyPair The tradable identifier (e.g. BTC in BTC/USD)
   * @param last Last price
   * @param bid Bid price
   * @param ask Ask price
   * @param high High price
   * @param low Low price
   * @param vwap Volume Weighted Average Price
   * @param volume 24h volume
   * @param timestamp - the timestamp of the ticker according to the exchange's server, null if not provided
   */
  private Ticker(CurrencyPair currencyPair, BigDecimal last, BigDecimal bid, BigDecimal ask, BigDecimal high, BigDecimal low, BigDecimal vwap,
      BigDecimal volume, Date timestamp) {

    this.currencyPair = currencyPair;
    this.last = last;
    this.bid = bid;
    this.ask = ask;
    this.high = high;
    this.low = low;
    this.vwap = vwap;
    this.volume = volume;
    this.timestamp = timestamp;
  }

  public CurrencyPair getCurrencyPair() {

    return currencyPair;
  }

  public BigDecimal getLast() {

    return last;
  }

  public BigDecimal getBid() {

    return bid;
  }

  public BigDecimal getAsk() {

    return ask;
  }

  public BigDecimal getHigh() {

    return high;
  }

  public BigDecimal getLow() {

    return low;
  }

  public BigDecimal getVwap() {

    return vwap;
  }

  public BigDecimal getVolume() {

    return volume;
  }

  public Date getTimestamp() {

    return timestamp;
  }

  @Override
  public String toString() {

    return "Ticker [currencyPair=" + currencyPair + ", last=" + last + ", bid=" + bid + ", ask=" + ask + ", high=" + high + ", low=" + low + ",avg="
        + vwap + ", volume=" + volume + ", timestamp=" + DateUtils.toMillisNullSafe(timestamp) + "]";
  }

  /**
   * <p>
   * Builder to provide the following to {@link Ticker}:
   * </p>
   * <ul>
   * <li>Provision of fluent chained construction interface</li>
   * </ul>
   *  
   */
  public static class Builder {

    private CurrencyPair currencyPair;
    private BigDecimal last;
    private BigDecimal bid;
    private BigDecimal ask;
    private BigDecimal high;
    private BigDecimal low;
    private BigDecimal vwap;
    private BigDecimal volume;
    private Date timestamp;

    // Prevent repeat builds
    private boolean isBuilt = false;

    public Ticker build() {

      validateState();

      Ticker ticker = new Ticker(currencyPair, last, bid, ask, high, low, vwap, volume, timestamp);

      isBuilt = true;

      return ticker;
    }

    private void validateState() {

      if (isBuilt) {
        throw new IllegalStateException("The entity has been built");
      }
    }

    public Builder currencyPair(CurrencyPair currencyPair) {

      this.currencyPair = currencyPair;
      return this;
    }

    public Builder last(BigDecimal last) {

      this.last = last;
      return this;
    }

    public Builder bid(BigDecimal bid) {

      this.bid = bid;
      return this;
    }

    public Builder ask(BigDecimal ask) {

      this.ask = ask;
      return this;
    }

    public Builder high(BigDecimal high) {

      this.high = high;
      return this;
    }

    public Builder low(BigDecimal low) {

      this.low = low;
      return this;
    }

    public Builder vwap(BigDecimal vwap) {

      this.vwap = vwap;
      return this;
    }

    public Builder volume(BigDecimal volume) {

      this.volume = volume;
      return this;
    }

    public Builder timestamp(Date timestamp) {

      this.timestamp = timestamp;
      return this;
    }

  }
}
@@ -470,16 +470,49 @@
 cyPair;%0A
+  private final BigDecimal open;%0A
   privat
@@ -536,16 +536,16 @@
 l last;%0A
-
   privat
@@ -1336,16 +1336,33 @@
 ncyPair,
+ BigDecimal open,
  BigDeci
@@ -1492,25 +1492,46 @@
 imestamp) %7B%0A
+    this.open = open;
 %0A
-
     this.cur
@@ -1814,24 +1814,79 @@
 yPair;%0A  %7D%0A%0A
+  public BigDecimal getOpen() %7B%0A%0A    return open;%0A  %7D%0A%0A
   public Big
@@ -2411,16 +2411,35 @@
 air + %22,
+ open=%22 + open + %22,
  last=%22 
@@ -2881,24 +2881,53 @@
 rrencyPair;%0A
+    private BigDecimal open;%0A
     private 
@@ -3311,16 +3311,22 @@
 ncyPair,
+ open,
  last, b
@@ -3623,24 +3623,24 @@
 ncyPair) %7B%0A%0A
-
       this.c
@@ -3685,32 +3685,126 @@
 rn this;%0A    %7D%0A%0A
+    public Builder open(BigDecimal open) %7B%0A%0A      this.open = open;%0A      return this;%0A    %7D%0A%0A
     public Build

Add 'open' field to 'Ticker'