Package com.barchart.feed.base.values.api

Examples of com.barchart.feed.base.values.api.PriceValue


    final TimeValue time = message.getTime();
    final TimeValue date = message.getTradeDay().tradeDate();

    final DDF_ParamType.Kind kind = param.kind;

    final PriceValue price;
    final SizeValue size;

    switch (kind) {
    default:
     
    case SIZE:
      price = ValueConst.NULL_PRICE;
      size = message.getAsSize();
      break;
    case PRICE:
      price = message.getAsPrice();
      size = ValueConst.NULL_SIZE;
      break;
    }

    final DDF_Session ddfSession = message.getSession();
   
    //

    final MarketBookTop top = market.get(MarketField.BOOK_TOP);
    final MarketDoBar barCurrent = market.loadBar(CURRENT.field);
    final MarketDoBar barPrevious = market.loadBar(PREVIOUS.field);

    //
    switch (param) {
   
    case TRADE_ASK_PRICE:  // NEW
     
      /* Update changed comonents */
      market.clearChanges();
      market.setChange(Component.TRADE);
     
      log.debug("Mapper saw TRADE_ASK_PRICE - Price=" + price.toString() +
          " " + message.getSession() + " " + message.getTradeDay().toString() + " "
          + message.getInstrument().symbol());
     
      market.setTrade(ddfSession.type, ddfSession.session,
          ddfSession.sequencing, price, size, time, date);

      return null;
     
    case TRADE_BID_PRICE:  // NEW
     
      /* Update changed comonents */
      market.clearChanges();
      market.setChange(Component.TRADE);
     
      log.debug("Mapper saw TRADE_BID_PRICE - Price=" + price.toString() +
          " " + message.getSession() + " " + message.getTradeDay().toString() + " "
          + message.getInstrument().symbol());
     
      market.setTrade(ddfSession.type, ddfSession.session,
          ddfSession.sequencing, price, size, time, date);
     
      return null;
   
    case TRADE_LAST_PRICE:
     
      /* Update changed comonents */
      market.clearChanges();
      market.setChange(Component.TRADE);
     
      market.setTrade(ddfSession.type, ddfSession.session,
          ddfSession.sequencing, price, size, time, date);
     
      return null;
     
    case ASK_LAST: // NEW
     
      log.debug("Mapper saw ASK_LAST - Price=" + price.toString() +
          " " + message.getSession() + " " + message.getTradeDay().toString() + " "
          + message.getInstrument().symbol());
     
    case ASK_LAST_PRICE:
     
      /* Update changed comonents */
      market.clearChanges();
      market.setChange(Component.BOOK_COMBINED);
     
      final DefBookEntry topAskPrice = new DefBookEntry(
          MODIFY, Book.Side.ASK,
          Book.Type.DEFAULT, ENTRY_TOP, price, top.side(Book.Side.ASK).sizeValue());
      applyTop(topAskPrice, time, market);
     
      return null;

    case ASK_LAST_SIZE:
     
      /* Update changed comonents */
      market.clearChanges();
      market.setChange(Component.BOOK_COMBINED);
     
      final DefBookEntry topAskSize = new DefBookEntry(
          MODIFY, Book.Side.ASK,
          Book.Type.DEFAULT, ENTRY_TOP, top.side(Book.Side.ASK).priceValue(), size);
      applyTop(topAskSize, time, market);
     
      return null;

    case BID_LAST: // NEW
      log.debug("Mapper saw BID_LAST - Price=" + price.toString() +
          " " + message.getSession() + " " + message.getTradeDay().toString() + " "
          + message.getInstrument().symbol());
     
    case BID_LAST_PRICE:
     
View Full Code Here


    market.clearChanges();
    // ### process quote

    // TODO part of instrument; should update definition?
    final TextValue symbolName = message.getSymbolName();
    final PriceValue priceStep = message.getPriceStep();
    final PriceValue pointValue = message.getPointValue();

    // TODO add more complete flag support?
    final DDF_Condition condition = message.getCondition();
    final DDF_QuoteState state = message.getState();
    final DDF_QuoteMode mode = message.getMode();
View Full Code Here

    final TimeValue time = message.getTime();

    /** Update SETTLE State */
    {

      final PriceValue priceSettle = message.getPriceSettle();

      if (isClear(priceSettle)) {
        // ",-, " : means remove old value
        //log.debug("Set State IS_SETTLED false inside visit
        //MarketSnapshot because priceSettle is clear");
        market.setState(MarketStateEntry.IS_SETTLED, false);
      } else if (isEmpty(priceSettle)) {
        // ",," : means leave alone
        // no change of current value
      } else {
        // ",12345," : means replace with new value
        //log.debug("Set State IS_SETTLED true inside visit
        //MarketSnapshot because priceSettle is not empty");
        market.setState(MarketStateEntry.IS_SETTLED, true);
      }

    }

    /** Update top of book */
    {

      /* Update changed comonents */
      market.setChange(Component.BOOK_COMBINED);
     
      final PriceValue priceBid = message.getPriceBid();
      final PriceValue priceAsk = message.getPriceAsk();

      /** XXX note: {@link MarketBook#ENTRY_TOP} */

      final MarketDoBookEntry entryBid = new DefBookEntry(
          MODIFY, Book.Side.BID,
          Book.Type.DEFAULT, ENTRY_TOP, priceBid, ValueConst.NULL_SIZE);
      final MarketDoBookEntry entryAsk = new DefBookEntry(
          MODIFY, Book.Side.ASK,
          Book.Type.DEFAULT, ENTRY_TOP, priceAsk, ValueConst.NULL_SIZE);

      applyTop(entryBid, time, market);
      applyTop(entryAsk, time, market);
     
    }

    /** Update CURRENT bar */
    {

      /* Update changed comonents */
      market.setChange(Component.DEFAULT_CURRENT);
     
      final MarketBarType type = CURRENT;

      final MarketDoBar bar = market.loadBar(type.field);

      final DDF_TradeDay tradeDay = message.getTradeDay();
      bar.set(MarketBarField.TRADE_DATE, tradeDay.tradeDate());

      final PriceValue priceOpen = message.getPriceOpen();
      final PriceValue priceHigh = message.getPriceHigh();
      final PriceValue priceLow = message.getPriceLow();
      final PriceValue priceClose = message.getPriceLast(); // XXX
      final PriceValue priceSettle = message.getPriceSettle();
      final SizeValue sizeVolume = message.getSizeVolume();

      applyBar(bar, MarketBarField.OPEN, priceOpen);
      applyBar(bar, MarketBarField.HIGH, priceHigh);
      applyBar(bar, MarketBarField.LOW, priceLow);
      applyBar(bar, MarketBarField.CLOSE, priceClose);
      applyBar(bar, MarketBarField.SETTLE, priceSettle);
      applyBar(bar, MarketBarField.VOLUME, sizeVolume);

      bar.set(MarketBarField.BAR_TIME, time);

      market.setBar(type, bar);

    }

    /** Update PREVIOUS bar */
    {

      /* Update changed comonents */
      market.setChange(Component.DEFAULT_PREVIOUS);
     
      final MarketBarType type = PREVIOUS;

      final MarketDoBar bar = market.loadBar(type.field);
      final PriceValue priceOpen = message.getPriceOpen();
      final PriceValue priceHigh = message.getPriceHigh();
      final PriceValue priceLow = message.getPriceLow();
      final PriceValue priceClose = message.getPriceLastPrevious();
      final PriceValue priceSettle = message.getPriceSettle();
      final SizeValue sizeVolume = message.getSizeVolumePrevious();
      final SizeValue sizeInterest = message.getSizeInterest(); // XXX

      applyBar(bar, MarketBarField.OPEN, priceOpen);
      applyBar(bar, MarketBarField.HIGH, priceHigh);
View Full Code Here

    bar.set(MarketBarField.TRADE_DATE, tradeDay.tradeDate());
    //

    // extract

    final PriceValue priceOpen = message.getPriceOpen();
    final PriceValue priceHigh = message.getPriceHigh();
    final PriceValue priceLow = message.getPriceLow();
    final PriceValue priceClose = message.getPriceLast(); // XXX note: LAST
    final PriceValue priceSettle = message.getPriceSettle();
    final SizeValue sizeVolume = message.getSizeVolume();
    final SizeValue sizeInterest = message.getSizeInterest();

    // apply
View Full Code Here

    switch (tradeType) {
    case TRADE: {

      // message "27" : normal trade

      PriceValue price = message.getPrice();
      SizeValue size = message.getSize();

      // TODO review contract on how to clean partial values
      if (isClear(price) || isEmpty(price)) {
        price = ValueConst.NULL_PRICE;
View Full Code Here

  protected void applyTop(/* local */MarketDoBookEntry entry,
      final TimeValue time, final MarketDo market) {

    /* ddf signals by special price values */
    final PriceValue price = entry.priceValue();

    /* ",," a.k.a comma-comma; ddf value not provided */
    if (isEmpty(price)) {
      return;
    }
View Full Code Here

   
    MarketCuvol cuvol = get(CUVOL);
   
    if (cuvol.isFrozen()) {

      final PriceValue priceStep = ValueBuilder.newPrice(
          instrument.tickSize().mantissa(),
          instrument.tickSize().exponent());

      if(priceStep.mantissa() == 0) {
        System.out.println();
      }
     
      final VarCuvol varCuvol = new VarCuvol(instrument, priceStep);
      final VarCuvolLast varCuvolLast = new VarCuvolLast(varCuvol);
View Full Code Here

      }

      final SizeValue size = LIMIT; // inst.get(BOOK_SIZE);
     
      // ValueConverter
      final PriceValue step = ValueBuilder.newPrice(
          instrument.tickSize().mantissa(),
          instrument.tickSize().exponent());

      final VarBook varBook = new VarBook(instrument, type, size, step);
      final VarBookLast varBookLast = new VarBookLast(varBook);
View Full Code Here

  }

  protected final boolean isValidPrice(final PriceValue price) {

    //TODO Value Converter
    final PriceValue priceStep = ValueBuilder.newPrice(
        instrument.tickSize().mantissa(),
        instrument.tickSize().exponent());

    if (!price.equalsScale(priceStep)) {
      log.error("not normalized");
      return false;
    }

    final long count = price.count(priceStep);

    final PriceValue priceTest = priceStep.mult(count);

    if (!price.equals(priceTest)) {
      log.error("does not fit step");
      return false;
    }
View Full Code Here

    /* value of a future contract / stock share */
    final String pricePointString = xmlStringDecode(tag, PRICE_POINT_VALUE,  XML_PASS);
    if(pricePointString == null || pricePointString.isEmpty()) {
      builder.setContractPointValue(buildDecimal(0,0));
    } else {
      PriceValue pricePoint = ValueBuilder.newPrice(Double
          .valueOf(pricePointString));
      builder.setContractPointValue(buildDecimal(
          pricePoint.mantissa(), pricePoint.exponent()));
    }
   
    /* display fraction base : decimal(10) vs binary(2), etc. */
    builder.setDisplayBase((int)frac.fraction.base());
    builder.setDisplayExponent(frac.fraction.exponent());
 
View Full Code Here

TOP

Related Classes of com.barchart.feed.base.values.api.PriceValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.