com.dxfeed.event.market
Class MarketEventSymbols

java.lang.Object
  extended by com.dxfeed.event.market.MarketEventSymbols

public class MarketEventSymbols
extends Object

Helper class to compose and parse symbols for market events.

Regional symbols

Regional symbol subscription receives events only from a designated exchange, marketplace, or venue instead of receiving composite events from all venues (by default). Regional symbol is composed from a base symbol, ampersand character ('&'), and an exchange code character. For example,

Symbol attributes

Market event symbols can have a number of attributes attached to then in curly braces with <key>=<value> paris separated by commas. For example, The methods in this class always maintain attribute keys in alphabetic order.


Method Summary
static String buildSpreadSymbol(Map<String,? extends Number> spread)
          Builds canonical spread symbol for specified spread components.
static String changeAttributeStringByKey(String symbol, String key, String value)
          Changes value of one attribute value while leaving exchange code and other attributes intact.
static String changeBaseSymbol(String symbol, String baseSymbol)
          Changes base symbol while leaving exchange code and attributes intact.
static String changeExchangeCode(String symbol, char exchangeCode)
          Changes exchange code of the specified symbol or removes it if new exchange code is '\0'.
static String getAttributeStringByKey(String symbol, String key)
          Returns value of the attribute with the specified key.
static String getBaseSymbol(String symbol)
          Returns base symbol without exchange code and attributes.
static char getExchangeCode(String symbol)
          Returns exchange code of the specified symbol or '\0' if none is defined.
static boolean hasAttributes(String symbol)
          Returns true if the specified symbol has any attributes.
static boolean hasExchangeCode(String symbol)
          Returns true is the specified symbol has the exchange code specification.
static String removeAttributeStringByKey(String symbol, String key)
          Removes one attribute with the specified key while leaving exchange code and other attributes intact.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

hasExchangeCode

public static boolean hasExchangeCode(String symbol)
Returns true is the specified symbol has the exchange code specification. The result is false if symbol is null.

Parameters:
symbol - symbol.
Returns:
true is the specified symbol has the exchange code specification.

getExchangeCode

public static char getExchangeCode(String symbol)
Returns exchange code of the specified symbol or '\0' if none is defined. The result is '\0' if symbol is null.

Parameters:
symbol - symbol.
Returns:
exchange code of the specified symbol or '\0' if none is defined.

changeExchangeCode

public static String changeExchangeCode(String symbol,
                                        char exchangeCode)
Changes exchange code of the specified symbol or removes it if new exchange code is '\0'. The result is null if old symbol is null.

Parameters:
symbol - old symbol.
exchangeCode - new exchange code.
Returns:
new symbol with the changed exchange code.

getBaseSymbol

public static String getBaseSymbol(String symbol)
Returns base symbol without exchange code and attributes. The result is null if symbol is null.

Parameters:
symbol - symbol.
Returns:
base symbol without exchange code and attributes.

changeBaseSymbol

public static String changeBaseSymbol(String symbol,
                                      String baseSymbol)
Changes base symbol while leaving exchange code and attributes intact. The result is null if old symbol is null.

Parameters:
symbol - old symbol.
baseSymbol - new base symbol.
Returns:
new symbol with new base symbol and old symbol's exchange code and attributes.

hasAttributes

public static boolean hasAttributes(String symbol)
Returns true if the specified symbol has any attributes.


getAttributeStringByKey

public static String getAttributeStringByKey(String symbol,
                                             String key)
Returns value of the attribute with the specified key. The result is null if attribute with the specified key is not found. The result is null if symbol is null.

Parameters:
symbol - symbol.
key - attribute key.
Returns:
value of the attribute with the specified key.
Throws:
NullPointerException - if key is null.

changeAttributeStringByKey

public static String changeAttributeStringByKey(String symbol,
                                                String key,
                                                String value)
Changes value of one attribute value while leaving exchange code and other attributes intact. The null symbol is interpreted as empty one by this method..

Parameters:
symbol - old symbol.
key - attribute key.
value - attribute value.
Returns:
new symbol with key attribute with the specified value and everything else from the old symbol.
Throws:
NullPointerException - if key is null.

removeAttributeStringByKey

public static String removeAttributeStringByKey(String symbol,
                                                String key)
Removes one attribute with the specified key while leaving exchange code and other attributes intact. The result is null if symbol is null.

Parameters:
symbol - old symbol.
key - attribute key.
Returns:
new symbol without the specified key and everything else from the old symbol.
Throws:
NullPointerException - if key is null.

buildSpreadSymbol

public static String buildSpreadSymbol(Map<String,? extends Number> spread)
Builds canonical spread symbol for specified spread components. The canonical representation uses special prefix, leg ordering and formatting.

Spread legs with zero ratio are ignored (not included in the spread symbol). If spread is empty then empty string (with zero length) is returned. If spread consists of one leg with ratio of 1 then pure leg symbol is returned.

Parameters:
spread - maps spread leg symbol to its ratio in the spread
Returns:
canonical spread symbol for specified spread components.


Copyright © 2013 Devexperts. All Rights Reserved.