Package com.barchart.feed.api.util

Examples of com.barchart.feed.api.util.InstrumentGUID


  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();
    for(final Long id : ids) {
      inst.componentLegs.add(new InstrumentGUID(String.valueOf(id)));
    }
   
    return inst;
  }
View Full Code Here


   
    if (overrideURL) {
      symbol = symbol + "&bats=1";
    }
   
    InstrumentGUID guid = symbolMap.get(symbol);
    if(guid != null) {
      return guid;
    }
   
    return remoteLookup(symbol);
View Full Code Here

  @Override
  public List<InstrumentGUID> search(final CharSequence symbol) {
   
    final List<InstrumentGUID> list = new ArrayList<InstrumentGUID>();
   
    final InstrumentGUID guid = lookup(symbol);
    if(guid != null) {
      list.add(guid);
    }
   
    return list;
View Full Code Here

      if(instDOM == null || instDOM.isNull()) {
        failedMap.put(symbol, "");
        return InstrumentGUID.NULL;
      }
     
      InstrumentGUID guid = new InstrumentGUID(
          instDOM.get(InstrumentField.MARKET_GUID));
     
      /* Cache symbols */
      log.debug("Caching {} for symbol {}", instDOM.get(InstrumentField.SYMBOL), symbol);
      symbolMap.put(instDOM.get(InstrumentField.SYMBOL).toString(), guid);
View Full Code Here

   
    if(symbol == null || symbol.length() == 0) {
      return Collections.emptyList();
    }
   
    InstrumentGUID guid = cache.lookup(symbol.toString().toUpperCase());
       
    if(guid.isNull()) {
      guid = remote.lookup(symbol.toString().toUpperCase());
    }
   
    if(guid.equals(InstrumentGUID.NULL)) {
      return Collections.emptyList();
    }
   
    cache.storeGUID(symbol, guid);
   
View Full Code Here

   
    if(symbol == null || symbol.length() == 0) {
      return InstrumentGUID.NULL;
    }
   
    final InstrumentGUID guid = symbolMap.get(symbol);
   
    if(guid == null) {
      return InstrumentGUID.NULL;
    } else {
      return guid;
View Full Code Here

      final Fraction fraction, final TimeInterval lifetime,
      final DDF_TimeZone zone) {
   
    final Map<Tag, Object> map = new HashMap<Tag, Object>();
   
    map.put(InstrumentField.GUID, new InstrumentGUID(guid));
    map.put(MARKET_GUID, guid);
    map.put(SECURITY_TYPE, Instrument.SecurityType.NULL_TYPE);
    map.put(BOOK_LIQUIDITY, Instrument.BookLiquidityType.NONE);
    map.put(BOOK_STRUCTURE, Instrument.BookStructureType.NONE);
    map.put(BOOK_DEPTH, ValueConst.NULL_SIZE);
View Full Code Here

TOP

Related Classes of com.barchart.feed.api.util.InstrumentGUID

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.