Package com.barchart.missive.api

Examples of com.barchart.missive.api.TagMapSafe


    return builder.build();
  }

  public static Instrument buildInstrument(final InstrumentDefinition instDef) {

    final TagMapSafe map = new HashTagMapSafe(FIELDS);

    if (instDef.hasMarketId()) {
      map.set(GUID, new InstrumentGUID(String.valueOf(instDef.getMarketId())));
      map.set(MARKET_GUID, newText(String.valueOf(instDef.getMarketId())));
    } else {
      log.warn("Inst def had no market id, returning null instrument: \n{}", instDef.toString());
      return Instrument.NULL;
    }

    if (instDef.hasInstrumentType()) {
      map.set(SECURITY_TYPE,
          secTypeMap.getKey(instDef.getInstrumentType()));
    }

    if (instDef.hasBookLiquidity()) {
      map.set(BOOK_LIQUIDITY,
          liqidityTypeMap.getKey(instDef.getBookLiquidity()));
    }

    if (instDef.hasBookStructure()) {
      map.set(BOOK_STRUCTURE,
          structTypeMap.getKey(instDef.getBookStructure()));
    }

    if (instDef.hasBookDepth()) {
      map.set(BOOK_DEPTH, newSize(instDef.getBookDepth()));
    }

    if (instDef.hasVendorId()) {
      map.set(VENDOR, newText(instDef.getVendorId()));
    }

    if (instDef.hasSymbol()) {
      map.set(SYMBOL, newText(instDef.getSymbol()));
    }

    if (instDef.hasDescription()) {
      map.set(DESCRIPTION, newText(instDef.getDescription()));
    }

    if (instDef.hasCfiCode()) {
      map.set(CFI_CODE, newText(instDef.getCfiCode()));
    }

    if (instDef.hasExchangeCode()) {
      map.set(EXCHANGE, Exchanges.fromCode(instDef.getExchangeCode()));
      map.set(EXCHANGE_CODE, newText(instDef.getExchangeCode()));
    } else {
      map.set(EXCHANGE, Exchange.NULL);
      map.set(EXCHANGE_CODE, newText(Exchanges.NULL_CODE));
    }

    if (instDef.hasMinimumPriceIncrement()) {
      map.set(TICK_SIZE,
          priceFromDecimal(instDef.getMinimumPriceIncrement()));
    }

    if (instDef.hasContractPointValue()) {
      map.set(POINT_VALUE,
          priceFromDecimal(instDef.getContractPointValue()));
    }

    if (instDef.hasDisplayBase() && instDef.hasDisplayExponent()) {
      map.set(DISPLAY_FRACTION,
          factory.newFraction(instDef.getDisplayBase(),
              instDef.getDisplayExponent()));
    }

    if (instDef.hasCalendar()) {
      final Interval i = instDef.getCalendar().getLifeTime();
     
      if(i.getTimeFinish() > 0) {
        map.set(LIFETIME, factory.newTimeInterval(i.getTimeStart(), i.getTimeFinish()));
      } else {
        map.set(LIFETIME, TimeInterval.NULL);
      }
     
      final List<Interval> ints = instDef.getCalendar()
          .getMarketHoursList();
      final TimeInterval[] tints = new TimeInterval[ints.size()];
      for (int n = 0; n < ints.size(); n++) {
        tints[n] = factory.newTimeInterval(
            ints.get(n).getTimeStart(), ints.get(n).getTimeFinish());
      }
      map.set(MARKET_HOURS, factory.newSchedule(tints));
    }

    if (instDef.hasTimeZoneOffset()) {
      map.set(TIME_ZONE_OFFSET, newSize(instDef.getTimeZoneOffset()));
    }

    if (instDef.hasTimeZoneName()) {
      map.set(TIME_ZONE_NAME, newText(instDef.getTimeZoneName()));
    }
   
    InstrumentImpl inst = ObjectMapFactory.build(InstrumentImpl.class, map);
   
    final List<Long> ids = instDef.getComponentIdList();
View Full Code Here


    return builder.build();
  }

  public static Instrument buildInstrument(final InstrumentDefinition instDef) {

    final TagMapSafe map = new HashTagMapSafe(FIELDS);

    if (instDef.hasMarketId()) {
      map.set(GUID, new InstrumentGUID(String.valueOf(instDef.getMarketId())));
      map.set(MARKET_GUID, newText(String.valueOf(instDef.getMarketId())));
    } else {
      log.warn("Inst def had no market id, returning null instrument: \n{}", instDef.toString());
      return Instrument.NULL;
    }

    if (instDef.hasInstrumentType()) {
      map.set(SECURITY_TYPE,
          secTypeMap.getKey(instDef.getInstrumentType()));
    }

    if (instDef.hasBookLiquidity()) {
      map.set(BOOK_LIQUIDITY,
          liqidityTypeMap.getKey(instDef.getBookLiquidity()));
    }

    if (instDef.hasBookStructure()) {
      map.set(BOOK_STRUCTURE,
          structTypeMap.getKey(instDef.getBookStructure()));
    }

    if (instDef.hasBookDepth()) {
      map.set(BOOK_DEPTH, newSize(instDef.getBookDepth()));
    }

    if (instDef.hasVendorId()) {
      map.set(VENDOR, newText(instDef.getVendorId()));
    }

    if (instDef.hasSymbol()) {
      map.set(SYMBOL, newText(instDef.getSymbol()));
    }

    if (instDef.hasDescription()) {
      map.set(DESCRIPTION, newText(instDef.getDescription()));
    }

    if (instDef.hasCfiCode()) {
      map.set(CFI_CODE, newText(instDef.getCfiCode()));
    }

    if (instDef.hasExchangeCode()) {
      map.set(EXCHANGE_CODE, newText(instDef.getExchangeCode()));
    }

    if (instDef.hasMinimumPriceIncrement()) {
      map.set(TICK_SIZE,
          priceFromDecimal(instDef.getMinimumPriceIncrement()));
    }

    if (instDef.hasContractPointValue()) {
      map.set(POINT_VALUE,
          priceFromDecimal(instDef.getContractPointValue()));
    }

    if (instDef.hasDisplayBase() && instDef.hasDisplayExponent()) {
      map.set(DISPLAY_FRACTION,
          factory.newFraction(instDef.getDisplayBase(),
              instDef.getDisplayExponent()));
    }

    if (instDef.hasCalendar()) {
      final Interval i = instDef.getCalendar().getLifeTime();
     
      if(i.getTimeFinish() > 0) {
        map.set(LIFETIME, factory.newTimeInterval(i.getTimeStart(), i.getTimeFinish()));
      } else {
        map.set(LIFETIME, TimeInterval.NULL);
      }
     
      final List<Interval> ints = instDef.getCalendar()
          .getMarketHoursList();
      final TimeInterval[] tints = new TimeInterval[ints.size()];
      for (int n = 0; n < ints.size(); n++) {
        tints[n] = factory.newTimeInterval(
            ints.get(n).getTimeStart(), ints.get(n).getTimeFinish());
      }
      map.set(MARKET_HOURS, factory.newSchedule(tints));
    }

    if (instDef.hasTimeZoneOffset()) {
      map.set(TIME_ZONE_OFFSET, newSize(instDef.getTimeZoneOffset()));
    }

    if (instDef.hasTimeZoneName()) {
      map.set(TIME_ZONE_NAME, newText(instDef.getTimeZoneName()));
    }
   
    InstrumentImpl inst = ObjectMapFactory.build(InstrumentImpl.class, map);
   
    final List<Long> ids = instDef.getComponentIdList();
View Full Code Here

TOP

Related Classes of com.barchart.missive.api.TagMapSafe

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.