com.quotemedia.streamer.client.impl.JsonMessageMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of streamerclient-java-core Show documentation
Show all versions of streamerclient-java-core Show documentation
Java streaming client that provides easy-to-use client APIs to connect and subscribe to QuoteMedia's market data streaming services. https://quotemedia.com/
The newest version!
package com.quotemedia.streamer.client.impl;
import com.quotemedia.datacache.data.QMLongDecimal;
import com.quotemedia.streamer.client.mapper.*;
import com.quotemedia.streamer.messages.market.BookOrder;
import com.quotemedia.streamer.messages.market.DataMessage;
import com.quotemedia.streamer.messages.market.ImbalanceType;
import com.quotemedia.streamer.messages.market.InstrumentType;
import com.quotemedia.streamer.messages.market.impl.*;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
public class JsonMessageMapper {
private final Map, Mapping, ? extends DataMessage>> mappings;
public JsonMessageMapper() {
final DataMessageMapping datamessage = new DataMessageMapping();
final PriceMapping price = new PriceMapping();
final QMDecimalMapping qmDecimal = new QMDecimalMapping();
final QMLongDecimalMapping qmLongDecimal = new QMLongDecimalMapping();
this.mappings = new HashMap<>();
this.mappings.putIfAbsent(PurgeBookImpl.class, new PurgeBookMapping(datamessage));
this.mappings.putIfAbsent(BookDeleteImpl.class, new BookDeleteMapping(datamessage));
this.mappings.putIfAbsent(QuoteMsgImpl.class, new QuoteMapping(price, qmDecimal));
this.mappings.putIfAbsent(IntervalMsgImpl.class, new IntervalMapping(price, qmLongDecimal));
this.mappings.putIfAbsent(MMQuoteMsgImpl.class, new MMQuoteMapping(price, qmDecimal));
this.mappings.putIfAbsent(BookOrderMsgImpl.class, new BookOrderMapping(price));
this.mappings.putIfAbsent(PriceDataMsgImpl.class, new PriceDataMapping(price, qmDecimal, qmLongDecimal));
this.mappings.putIfAbsent(NethousePositionMsgImpl.class, new NethousePositionMapping(price));
this.mappings.putIfAbsent(TradeMsgImpl.class, new TradeMapping(price, qmDecimal, qmLongDecimal));
this.mappings.putIfAbsent(SymbolInfoMsgImpl.class, new SymbolInfoMapping());
this.mappings.putIfAbsent(SymbolStatusMsgImpl.class, new SymbolStatusMapping(price));
this.mappings.putIfAbsent(DerivativeInfoMsgImpl.class, new DerivativeInfoMapping(price));
this.mappings.putIfAbsent(LastSaleMsgImpl.class, new LastSaleMapping(price, qmLongDecimal));
this.mappings.putIfAbsent(LimitUpLimitDownMsgImpl.class, new LimitUpLimitDownMapping(price));
this.mappings.putIfAbsent(IVGreeksMsgImpl.class, new IVGreeksMapping());
this.mappings.putIfAbsent(ImbalanceStatusMsgImpl.class, new ImbalanceStatusMapping(price));
this.mappings.putIfAbsent(AlertMsgImpl.class, new AlertMapping());
this.mappings.putIfAbsent(NewsMsgImpl.class, new NewsMapping());
this.mappings.putIfAbsent(DividendMsgImpl.class, new DividendMapping());
this.mappings.putIfAbsent(EarningsMsgImpl.class, new EarningsMapping());
this.mappings.putIfAbsent(SymbolChangedMsgImpl.class, new SymbolChangedMapping());
this.mappings.putIfAbsent(SplitMsgImpl.class, new SplitMapping());
}
/**
* Maps an instance of {@link com.quotemedia.datacache.messaging.GenericDataMessage} and its state
* to an instance of {@link com.quotemedia.streamer.messages.market.DataMessage}.
* If no mapping is defined for {@code object} {@code null} is returned. This makes backward compatibility
* maintenance easier.
* Additional messages sent from server to client will simply be ignored.
*
* @param in the message to be mapped.
* @return the mapped message.
*/
public final DataMessage map(final Object in) {
if (in == null) {
return null;
}
final Mapping m = this.mappings.get(in.getClass());
if (m == null) {
return null;
}
return m.map(in, m.newimpl());
}
/**
* Implementations of this interface define the mapping between an instance of {@link I} to an instance of {@link O}.
*/
private interface Mapping {
/**
* Called when a new instace of {@link O} is required.
*
* @return the new instance.
*/
O newimpl();
/**
* Maps an instance of {@link I} an its state to an instance of of {@link O}.
*
* @param in the instance to map.
* @param out the instance to map to.
* @return the mapped instance.
*/
DataMessage map(final I in, final O out);
}
private static final class PurgeBookMapping implements Mapping {
private final DataMessageMapping datamessage;
public PurgeBookMapping(final DataMessageMapping datamessage) {
this.datamessage = datamessage;
}
@Override
public final PurgeBookImpl newimpl() {
return new PurgeBookImpl();
}
@Override
public DataMessage map(final PurgeBookImpl in, final PurgeBookImpl out) {
this.datamessage.map(in, out);
out.setSymbol(in.getSymbol());
return out;
}
}
private static final class BookDeleteMapping implements Mapping {
private final DataMessageMapping datamessage;
public BookDeleteMapping(final DataMessageMapping datamessage) {
this.datamessage = datamessage;
}
@Override
public BookDeleteImpl newimpl() {
return new BookDeleteImpl();
}
@Override
public DataMessageImpl map(final BookDeleteImpl in, final BookDeleteImpl out) {
this.datamessage.map(in, out);
out.setSymbol(in.getSymbol());
out.setOrderReference(in.getOrderReference());
out.setTimestamp(in.getTimestamp());
return out;
}
}
private static final class QuoteMapping implements Mapping {
private final PriceMapping price;
private final QMDecimalMapping qmDecimal;
public QuoteMapping(final PriceMapping price, final QMDecimalMapping qmDecimal) {
this.price = price;
this.qmDecimal = qmDecimal;
}
@Override
public QuoteImpl newimpl() {
return new QuoteImpl();
}
@Override
public DataMessageImpl map(final QuoteMsgImpl in, final QuoteImpl out) {
out.setSymbol(in.getSymbol());
out.setLocateCode(in.getLocateCode());
out.setTimestamp(in.getTimestamp());
out.setAskCondition(in.getAskCondition());
out.setAskExcode(in.getAskExcode());
out.setAskPrice(price.map(in.getAskPrice()));
out.setAskSize(this.qmDecimal.map(in.getAskSize()));
out.setBidCondition(in.getBidCondition());
out.setBidExcode(in.getBidExcode());
out.setBidPrice(this.price.map(in.getBidPrice()));
out.setBidSize(this.qmDecimal.map(in.getBidSize()));
out.setIndicator(in.getIndicator());
out.setSharesPerSizeUnit(in.getSharesPerSizeUnit());
return out;
}
}
private static final class IntervalMapping implements Mapping {
private final PriceMapping price;
private final QMLongDecimalMapping qmLongDecimal;
public IntervalMapping(final PriceMapping price, final QMLongDecimalMapping qmLongDecimal) {
this.price = price;
this.qmLongDecimal = qmLongDecimal;
}
@Override
public IntervalImpl newimpl() {
return new IntervalImpl();
}
@Override
public DataMessageImpl map(final IntervalMsgImpl in, final IntervalImpl out) {
out.setSymbol(in.getSymbol());
out.setLocateCode(in.getLocateCode());
out.setTimestamp(in.getTimestamp());
out.setHigh(price.map(in.getHigh()));
out.setLast(price.map(in.getLast()));
out.setLastTime(in.getLastTime());
out.setLow(price.map(in.getLow()));
out.setOpen(price.map(in.getOpen()));
out.setOpenTime(in.getOpenTime());
out.setStartTime(in.getStartTime());
out.setTradeValue(in.getTradeValue());
out.setVolume(this.qmLongDecimal.map(in.getVolume()));
out.setVWAP(price.map(in.getVWAP()));
out.setPeriodMs(in.getPeriodMs());
return out;
}
}
private static final class MMQuoteMapping implements Mapping {
private final PriceMapping price;
private final QMDecimalMapping qmDecimal;
public MMQuoteMapping(final PriceMapping price, final QMDecimalMapping qmDecimal) {
this.price = price;
this.qmDecimal = qmDecimal;
}
@Override
public MMQuoteImpl newimpl() {
return new MMQuoteImpl();
}
@Override
public DataMessageImpl map(final MMQuoteMsgImpl in, final MMQuoteImpl out) {
out.setSymbol(in.getSymbol());
out.setLocateCode(in.getLocateCode());
out.setTimestamp(in.getTimestamp());
out.setAskChange(this.price.map(in.getAskChange()));
out.setAskPrice(this.price.map(in.getAskPrice()));
out.setAskSize(this.qmDecimal.map(in.getAskSize()));
out.setBidChange(this.price.map(in.getBidChange()));
out.setBidPrice(this.price.map(in.getBidPrice()));
out.setBidSize(this.qmDecimal.map(in.getBidSize()));
out.setIndicator(in.getIndicator());
out.setMarketMakerId(in.getMarketMakerID());
out.setSharesPerSizeUnit(in.getSharesPerSizeUnit());
return out;
}
}
private static final class BookOrderMapping implements Mapping {
private final PriceMapping price;
public BookOrderMapping(final PriceMapping price) {
this.price = price;
}
@Override
public BookOrderImpl newimpl() {
return new BookOrderImpl();
}
@Override
public DataMessageImpl map(final BookOrderMsgImpl in, final BookOrderImpl out) {
out.setSymbol(in.getSymbol());
out.setExcode(in.getExcode());
out.setLocateCode(in.getLocateCode());
out.setTimestamp(in.getTimestamp());
out.setFlags(in.getFlags());
out.setLastUpdate(in.getLastUpdate());
out.setMarketMakerId(in.getMarketMakerID());
out.setOrderId(in.getOrderID());
out.setOrderReference(in.getOrderReference());
out.setOrderSide(OrderSideMapping.map(in.getOrderSide()));
out.setPrice(this.price.map(in.getPrice()));
out.setSize(in.getSize());
out.setDisplay(in.getDisplay());
out.setOrderChangeType(BookOrderChangeTypeMapping.map(in.getOrderChangeType()));
return out;
}
}
private static final class PriceDataMapping implements Mapping {
private final PriceMapping price;
private final QMDecimalMapping qmDecimal;
private final QMLongDecimalMapping qmLongDecimal;
public PriceDataMapping(final PriceMapping price, final QMDecimalMapping qmDecimal, final QMLongDecimalMapping qmLongDecimal) {
this.price = price;
this.qmDecimal = qmDecimal;
this.qmLongDecimal = qmLongDecimal;
}
@Override
public PriceDataImpl newimpl() {
return new PriceDataImpl();
}
@Override
public DataMessageImpl map(final PriceDataMsgImpl in, final PriceDataImpl out) {
out.setSymbol(in.getSymbol());
out.setLocateCode(in.getLocateCode());
out.setTimestamp(in.getTimestamp());
out.setAccumulatedPrice(this.price.map(in.getAccumulatedPrice()));
out.setAccumulatedTradeValue(this.price.map(in.getAccumulatedTradeValue()));
out.setAccumulatedVolume(this.qmLongDecimal.map(in.getAccumulatedVolume()));
out.setChange(this.price.map(in.getChange()));
out.setClose(this.price.map(in.getClose()));
out.setHigh(this.price.map(in.getHigh()));
out.setLast(this.price.map(in.getLast()));
out.setLastTradeSize(this.qmDecimal.map(in.getLastTradeSize()));
out.setLastTradeTime(in.getLastTradeTime());
out.setLow(this.price.map(in.getLow()));
out.setOpen(this.price.map(in.getOpen()));
out.setPercentChange(in.getPercentChange());
out.setPreviousClose(this.price.map(in.getPreviousClose()));
out.setTick(TickMapping.map(in.getTick()));
out.setTradeCount(in.getTradeCount());
out.setTWAP(this.price.map(in.getTWAP()));
out.setVWAP(this.price.map(in.getVWAP()));
out.setVwapVolume(this.qmLongDecimal.map(in.getVwapVolume()));
out.setAnnualHigh(in.getAnnualHigh());
out.setAnnualLow(in.getAnnualLow());
out.setPreMarketTradeTime(in.getPreMarketTradeTime());
out.setPreMarketLast(this.price.map(in.getPreMarketLast()));
out.setPreMarketVolume(this.qmLongDecimal.map(in.getPreMarketVolume()));
out.setPreMarketChange(this.price.map(in.getPreMarketChange()));
out.setPreMarketPercentChange(in.getPreMarketPercentChange());
out.setPostMarketTradeTime(in.getPostMarketTradeTime());
out.setPostMarketLast(this.price.map(in.getPostMarketLast()));
out.setPostMarketVolume(this.qmLongDecimal.map(in.getPostMarketVolume()));
out.setPostMarketChange(this.price.map(in.getPostMarketChange()));
out.setPostMarketPercentChange(in.getPostMarketPercentChange());
out.setLastTradeExcode(in.getLastTradeExcode());
out.setCurrencyID(in.getCurrencyID());
return out;
}
}
private static final class NethousePositionMapping implements Mapping {
private final PriceMapping price;
public NethousePositionMapping(final PriceMapping price) {
this.price = price;
}
@Override
public NethousePositionImpl newimpl() {
return new NethousePositionImpl();
}
@Override
public DataMessageImpl map(final NethousePositionMsgImpl in, final NethousePositionImpl out) {
out.setSymbol(in.getSymbol());
out.setLocateCode(in.getLocateCode());
out.setTimestamp(in.getTimestamp());
out.setBuyBlockTransactions(in.getBuyBlockTransactions());
out.setBuyBlockValue(this.price.map(in.getBuyBlockValue()));
out.setBuyBlockVolume(in.getBuyBlockVolume());
out.setBuyTransactions(in.getBuyTransactions());
out.setBuyValue(this.price.map(in.getBuyValue()));
out.setBuyVolume(in.getBuyVolume());
out.setMarketMakerId(in.getMarketMakerID());
out.setSellBlockTransactions(in.getSellBlockTransactions());
out.setSellBlockValue(this.price.map(in.getSellBlockValue()));
out.setSellBlockVolume(in.getSellBlockVolume());
out.setSellTransactions(in.getSellTransactions());
out.setSellValue(this.price.map(in.getSellValue()));
out.setSellVolume(in.getSellVolume());
return out;
}
}
private static final class TradeMapping implements Mapping {
private final PriceMapping price;
private final QMDecimalMapping qmDecimal;
private final QMLongDecimalMapping qmLongDecimal;
public TradeMapping(final PriceMapping price, final QMDecimalMapping qmDecimal, final QMLongDecimalMapping qmLongDecimal) {
this.price = price;
this.qmDecimal = qmDecimal;
this.qmLongDecimal = qmLongDecimal;
}
@Override
public TradeImpl newimpl() {
return new TradeImpl();
}
@Override
public DataMessageImpl map(final TradeMsgImpl in, final TradeImpl out) {
out.setSymbol(in.getSymbol());
out.setExcode(in.getExcode());
out.setLocateCode(in.getLocateCode());
out.setTimestamp(in.getTimestamp());
out.setAccumumlatedVolume(this.qmLongDecimal.map(in.getAccumulatedVolume()));
out.setBuyerId(in.getBuyerID());
out.setFlags(in.getFlags());
out.setIndicator(in.getIndicator());
out.setMatchId(in.getMatchID());
out.setPrice(this.price.map(in.getPrice()));
out.setRangeIndicator(RangeIndicatorMapping.map(in.getRangeIndicator()));
out.setSellerId(in.getSellerID());
out.setSequenceNumber(in.getSequenceNumber());
out.setSize(this.qmDecimal.map(in.getSize()));
out.setTick(TickMapping.map(in.getTick()));
out.setVWAP(this.price.map(in.getVwap()));
return out;
}
}
private static final class SymbolInfoMapping implements Mapping {
@Override
public SymbolInfoImpl newimpl() {
return new SymbolInfoImpl();
}
@Override
public DataMessage map(final SymbolInfoMsgImpl in, final SymbolInfoImpl out) {
out.setSymbol(in.getSymbol());
out.setExcode(in.getExcode());
out.setLocateCode(in.getLocateCode());
out.setInstrumenttype(InstrumentTypeMapping.map(in.getInstrumentType()));
out.setCurrendyId(in.getCurrencyId());
out.setHaltStatus(in.getHaltStatus());
out.setHaltIndicator(in.getHaltIndicator());
out.setRegSHOStatus(in.getRegSHOStatus());
out.setPqe(in.getPqe());
out.setCaveatEmptor(in.getCaveatEmptor());
out.setBoardLotSize(in.getBoardLotSize());
return out;
}
}
private static final class SymbolStatusMapping implements Mapping {
private final PriceMapping price;
public SymbolStatusMapping(PriceMapping price) {
this.price = price;
}
@Override
public SymbolStatusImpl newimpl() {
return new SymbolStatusImpl();
}
@Override
public DataMessage map(final SymbolStatusMsgImpl in, final SymbolStatusImpl out) {
out.setSymbol(in.getSymbol());
out.setHaltIndicator(in.getHaltIndicator());
out.setHaltStatus(in.getHaltStatus());
out.setRegSHOStatus(in.getRegSHOStatus());
out.setClosingCalculatedPrice(this.price.map(in.getClosingCalculatedPrice()));
out.setEffectiveTime(in.getEffectiveTime());
out.setOpeningTime(in.getOpeningTime());
out.setNote(in.getNote());
return out;
}
}
private static final class DerivativeInfoMapping implements Mapping {
private final PriceMapping price;
public DerivativeInfoMapping(final PriceMapping price) {
this.price = price;
}
@Override
public DerivativeInfoImpl newimpl() {
return new DerivativeInfoImpl();
}
@Override
public DataMessage map(final DerivativeInfoMsgImpl in, final DerivativeInfoImpl out) {
out.setSymbol(in.getSymbol());
out.setLocateCode(in.getLocateCode());
out.setRootSymbol(in.getRootSymbol());
out.setExpiration(in.getExpiration());
out.setDelivery(in.getDelivery());
out.setOpenInterest(in.getOpenInterest());
out.setContractSize(in.getContractSize());
out.setCallPutIndicator(in.getCallPutIndicator());
out.setMinTickSize(this.price.map(in.getMinTickSize()));
return out;
}
}
private static final class LastSaleMapping implements Mapping {
private final PriceMapping price;
private final QMLongDecimalMapping qmLongDecimal;
public LastSaleMapping(final PriceMapping price, final QMLongDecimalMapping qmLongDecimal) {
this.price = price;
this.qmLongDecimal = qmLongDecimal;
}
@Override
public LastSaleImpl newimpl() {
return new LastSaleImpl();
}
@Override
public DataMessage map(final LastSaleMsgImpl in, final LastSaleImpl out) {
out.setTimestamp(in.getTimestamp());
out.setSymbol(in.getSymbol());
out.setLocateCode(in.getLocateCode());
out.setLast(this.price.map(in.getLast()));
out.setPreviousClose(this.price.map(in.getPreviousClose()));
out.setAccumulatedVolume(this.qmLongDecimal.map(in.getAccumulatedVolume()));
out.setChange(this.price.map(in.getChange()));
out.setPercentChange(in.getPercentChange());
out.setTick(TickMapping.map(in.getTick()));
out.setLastTradeExcode(in.getLastTradeExcode());
return out;
}
}
private static final class LimitUpLimitDownMapping implements Mapping {
private final PriceMapping price;
private LimitUpLimitDownMapping(final PriceMapping price) {
this.price = price;
}
@Override
public LimitUpLimitDownImpl newimpl() {
return new LimitUpLimitDownImpl();
}
@Override
public DataMessage map(final LimitUpLimitDownMsgImpl in, final LimitUpLimitDownImpl out) {
out.setSymbol(in.getSymbol());
out.setLocateCode(in.getLocateCode());
out.setEffectiveTime(in.getEffectiveTime());
out.setLowerLimit(price.map(in.getLowerLimit()));
out.setUpperLimit(price.map(in.getUpperLimit()));
return out;
}
}
private static final class IVGreeksMapping implements Mapping {
@Override
public IVGreeksImpl newimpl() {
return new IVGreeksImpl();
}
@Override
public DataMessage map(IVGreeksMsgImpl in, IVGreeksImpl out) {
out.setSymbol(in.getSymbol());
out.setLastCalculation(new Date(in.getLastCalculation()));
out.setDelta(in.getDelta());
out.setGamma(in.getGamma());
out.setVega(in.getVega());
out.setRho(in.getRho());
out.setTheta(in.getTheta());
out.setImpliedVolatility(in.getMidIV());
out.setImpliedVolatilityChange(in.getMidIVChange());
out.setBidImpliedVolatility(in.getBidIV());
out.setAskImpliedVolatility(in.getAskIV());
out.setMark(in.getMark());
out.setIntrinsicValue(in.getIntrinsicValue());
out.setExtrinsicValue(in.getExtrinsicValue());
return out;
}
}
private static final class ImbalanceStatusMapping implements Mapping {
private final PriceMapping price;
private ImbalanceStatusMapping(final PriceMapping price) {
this.price = price;
}
@Override
public ImbalanceStatusImpl newimpl() {
return new ImbalanceStatusImpl();
}
@Override
public DataMessage map(ImbalanceStatusMsgImpl in, ImbalanceStatusImpl out) {
out.setSymbol(in.getSymbol());
out.setLocateCode(in.getLocateCode());
out.setTimestamp(in.getTimestamp());
out.setImbalanceType(ImbalanceTypeMapping.map(in.getImbalanceType()));
out.setSide(OrderSideMapping.map(in.getSide()));
out.setReferencePrice(price.map(in.getReferencePrice()));
out.setSize(in.getSize());
out.setPairedVolume(in.getPairedVolume());
out.setNearIndicativePrice(price.map(in.getNearIndicativePrice()));
out.setFarIndicativePrice(price.map((in.getFarIndicativePrice())));
out.setPriceVariation(in.getPriceVariation());
return out;
}
}
private static final class AlertMapping implements Mapping {
@Override
public AlertImpl newimpl() {
return new AlertImpl();
}
@Override
public DataMessageImpl map(final AlertMsgImpl in, final AlertImpl out) {
out.setSymbol(in.getSymbol());
out.setLocateCode(in.getLocateCode());
out.setTimestamp(in.getTimestamp());
out.setInstrumenttype(InstrumentTypeMapping.map(in.getInstrumentType()));
out.setAlertId(in.getAlertId());
out.setTriggerValue(in.getTriggerValue());
return out;
}
}
private static final class DividendMapping implements Mapping {
@Override
public DividendImpl newimpl() {
return new DividendImpl();
}
@Override
public DataMessageImpl map(final DividendMsgImpl in, final DividendImpl out) {
out.setOccuredOn(in.getOccuredOn());
out.setSymbolId(in.getSymbolId());
out.setSymbol(in.getSymbol());
out.setAmount(in.getAmount());
out.setDeclarationDate(in.getDeclarationDate());
out.setExecutionDate(in.getExecutionDate());
out.setRecordDate(in.getRecordDate());
out.setPaymentDate(in.getPaymentDate());
out.setPaymentType(in.getPaymentType());
out.setFrequency(in.getFrequency());
return out;
}
}
private static final class EarningsMapping implements Mapping {
@Override
public EarningsImpl newimpl() {
return new EarningsImpl();
}
@Override
public DataMessageImpl map(final EarningsMsgImpl in, final EarningsImpl out) {
out.setOccuredOn(in.getOccuredOn());
out.setSymbolId(in.getSymbolId());
out.setSymbol(in.getSymbol());
out.setFiscalYear(in.getFiscalYear());
out.setQuarter(in.getQuarter());
out.setEarningsPerShare(in.getEarningsPerShare());
out.setAnnouncementDate(in.getAnnouncementDate());
out.setAnnouncementTimeOfDay(in.getAnnouncementTimeOfDay());
out.setAnnouncementUrl(in.getAnnouncementUrl());
return out;
}
}
private static final class SplitMapping implements Mapping {
@Override
public SplitImpl newimpl() {
return new SplitImpl();
}
@Override
public DataMessageImpl map(final SplitMsgImpl in, final SplitImpl out) {
out.setOccuredOn(in.getOccuredOn());
out.setSymbolId(in.getSymbolId());
out.setSymbol(in.getSymbol());
out.setExecutionDate(in.getExecutionDate());
out.setDeclarationDate(in.getDeclarationDate());
out.setRecordDate(in.getRecordDate());
out.setPaymentDate(in.getPaymentDate());
out.setRatio(in.getRatio());
out.setRatioNumerator(in.getRatioNumerator());
out.setRatioDenominator(in.getRatioDenominator());
return out;
}
}
private static final class SymbolChangedMapping implements Mapping {
@Override
public SymbolChangedImpl newimpl() {
return new SymbolChangedImpl();
}
@Override
public DataMessageImpl map(final SymbolChangedMsgImpl in, final SymbolChangedImpl out) {
out.setSymbolId(in.getSymbolId());
out.setSymbol(in.getSymbol());
out.setOldSymbol(in.getOldSymbol());
out.setNewSymbol(in.getNewSymbol());
out.setDay(in.getDay());
return out;
}
}
private static final class NewsMapping implements Mapping {
@Override
public final NewsImpl newimpl() {
return new NewsImpl();
}
@Override
public final DataMessageImpl map(final NewsMsgImpl in, final NewsImpl out) {
//TODO
return out;
}
}
private static final class DataMessageMapping {
private DataMessageImpl map(final DataMessage in, final DataMessageImpl out) {
return out;
}
}
private abstract static class InstrumentTypeMapping {
public static final InstrumentType map(final InstrumentType in) {
if (in == null) {
return null;
}
switch (in) {
case BOND:
return InstrumentType.BOND;
case CASH:
return InstrumentType.CASH;
case COMPOSITE:
return InstrumentType.COMPOSITE;
case FUTURE:
return InstrumentType.FUTURE;
case FUTURE_OPTION:
return InstrumentType.FUTURE_OPTION;
case FOREX:
return InstrumentType.FOREX;
case INDEX:
return InstrumentType.INDEX;
case MUTUAL_FUND:
return InstrumentType.MUTUAL_FUND;
case MONEY_MARKET_FUND:
return InstrumentType.MONEY_MARKET_FUND;
case MARKET_STAT:
return InstrumentType.MARKET_STAT;
case EQUITY:
return InstrumentType.EQUITY;
case EQUITY_OPTION:
return InstrumentType.EQUITY_OPTION;
case GOVT_BOND:
return InstrumentType.GOVT_BOND;
case MUNI_BOND:
return InstrumentType.MUNI_BOND;
case CORP_BOND:
return InstrumentType.CORP_BOND;
case ETF:
return InstrumentType.ETF;
case FUTURE_SPREAD:
return InstrumentType.FUTURE_SPREAD;
case OPTION_ROOT:
return InstrumentType.OPTION_ROOT;
case UNKNOWN:
return InstrumentType.UNKNOWN;
case RATE:
return InstrumentType.RATE;
default:
return null;
}
}
}
private abstract static class ImbalanceTypeMapping {
public static final ImbalanceType map(final com.quotemedia.datacache.data.ImbalanceType in) {
if (in == null) {
return null;
}
switch (in) {
case None:
return ImbalanceType.NONE;
case Market:
return ImbalanceType.MARKET;
case MOC:
return ImbalanceType.MOC;
case Regulatory:
return ImbalanceType.REGULATORY_IMBALANCE;
case Opening:
return ImbalanceType.OPENING_IMBALANCE;
case Unknown:
return ImbalanceType.UNKNOWN;
case IPO:
return ImbalanceType.IPO_IMBALANCE;
case Halt:
return ImbalanceType.HALT_IMBALANCE;
case Equilibrium:
return ImbalanceType.EQUILIBRIUM;
default:
return null;
}
}
}
private abstract static class OrderSideMapping {
public static final com.quotemedia.streamer.messages.market.OrderSide map(final OrderSide in) {
if (OrderSide.BUYSIDE == in) {
return com.quotemedia.streamer.messages.market.OrderSide.BUYSIDE;
} else if (OrderSide.SELLSIDE == in) {
return com.quotemedia.streamer.messages.market.OrderSide.SELLSIDE;
} else {
return null;
}
}
}
private static final class PriceMapping {
public final Double map(final com.quotemedia.datacache.data.Price in) {
return in != null ? in.doubleValue() : null;
}
}
private static final class QMDecimalMapping {
public final Double map(final com.quotemedia.datacache.data.QMDecimal in) {
return in != null ? in.doubleValue() : null;
}
}
private static final class QMLongDecimalMapping {
public final Double map(final com.quotemedia.datacache.data.QMLongDecimal in) {
return in != null ? in.doubleValue() : null;
}
}
private abstract static class TickMapping {
public static final com.quotemedia.streamer.messages.market.Tick map(final Tick in) {
if (Tick.DOWN == in) {
return com.quotemedia.streamer.messages.market.Tick.DOWN;
} else if (Tick.NONE == in) {
return com.quotemedia.streamer.messages.market.Tick.NONE;
} else if (Tick.UP == in) {
return com.quotemedia.streamer.messages.market.Tick.UP;
} else {
return null;
}
}
}
private abstract static class BookOrderChangeTypeMapping {
public static com.quotemedia.streamer.messages.market.BookOrder.ChangeType map(final BookOrder.ChangeType in) {
switch (in) {
case ADD:
return com.quotemedia.streamer.messages.market.BookOrder.ChangeType.ADD;
case CANCEL:
return com.quotemedia.streamer.messages.market.BookOrder.ChangeType.CANCEL;
case EXECUTE:
return com.quotemedia.streamer.messages.market.BookOrder.ChangeType.EXECUTE;
case MODIFY:
return com.quotemedia.streamer.messages.market.BookOrder.ChangeType.MODIFY;
default:
return null;
}
}
}
private static abstract class RangeIndicatorMapping {
public static final com.quotemedia.streamer.messages.market.Trade.RangeIndicator map(final RangeIndicator in) {
if (RangeIndicator.BUYSIDE == in) {
return com.quotemedia.streamer.messages.market.Trade.RangeIndicator.BUYSIDE;
} else if (RangeIndicator.SELLSIDE == in) {
return com.quotemedia.streamer.messages.market.Trade.RangeIndicator.SELLSIDE;
} else if (RangeIndicator.INRANGE == in) {
return com.quotemedia.streamer.messages.market.Trade.RangeIndicator.INRANGE;
} else if (RangeIndicator.UNKNOWN == in) {
return com.quotemedia.streamer.messages.market.Trade.RangeIndicator.UNKNOWN;
} else {
return null;
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy