Namespace: Symbology

CIQ.Market. Symbology

Set of rules for identifying instrument's exchange and deriving a market definition from a symbol. This is only required if your chart will need to know the operating hours for the different exchanges. If using a 24x7 chart, this class is not needed.

Default implementation can be found in examples/markets/marketDefinitionsSample.js. Please review and override the functions in there to match the symbol format of your quotefeed or results will be unpredictable.

Since:
  • 04-2016-08

Methods


<static> factory(symbolObject)

This is a function that takes a symbolObject of form accepted by CIQ.ChartEngine#loadChart, and returns a market definition. When loading it with CIQ.ChartEngine#setMarketFactory, it will be used by the chart to dynamically change market definitions when a new instrument is activated.

Very important:
Default implementation can be found in examples/markets/marketDefinitionsSample.js. Please review and override the functions in there to match the symbol format of your quotefeed or results will be unpredictable.

See CIQ.Market for instruction on how to create a market definition.

Parameters:
Name Type Description
symbolObject object

Symbol object of form accepted by CIQ.ChartEngine#loadChart

Since:
  • 04-2016-08
Returns:

A market definition. See CIQ.Market for instructions.

Type
object
Example
// default implementation
var factory=function(symbolObject){
	var symbol=symbolObject.symbol;
	if(CIQ.Market.Symbology.isForeignSymbol(symbol)) return null; // 24 hour market definition
	if(CIQ.Market.Symbology.isFuturesSymbol(symbol)) return CIQ.Market.GLOBEX;
	if(CIQ.Market.Symbology.isForexMetal(symbol)) return CIQ.Market.METALS;
	if(CIQ.Market.Symbology.isForexSymbol(symbol)) return CIQ.Market.FOREX;
	return CIQ.Market.NYSE;
};

<static> isForeignSymbol(symbol)

Returns true if the instrument is foreign.

This is dependent on the market data feed and should be overridden accordingly.

Parameters:
Name Type Description
symbol string

The symbol

Since:
  • 04-2016-08
Returns:

True if it's a foreign symbol

Type
boolean
Example
CIQ.Market.Symbology.isForeignSymbol=function(symbol){
	if(!symbol) return false;
	return symbol.indexOf(".")!=-1;
};

<static> isForexFuturesSymbol(symbol)

Returns true if the symbol is a forex or a future

Parameters:
Name Type Description
symbol string

The symbol

Since:
  • 04-2016-08
Returns:

True if the symbol is a forex or a future

Type
boolean

<static> isForexMetal(symbol, inverse)

Returns true if the symbol is a metal/currency or currency/metal pair

This is dependent on the market data feed and should be overridden accordingly.

Parameters:
Name Type Description
symbol string

The symbol

inverse boolean

Set to true to test specifically for a currency/metal pair (e.g. EURXAU, but not XAUEUR).

Since:
  • 04-2016-08
Returns:

True if it's a metal symbol

Type
boolean
Example
CIQ.Market.Symbology.isForexMetal=function(symbol,inverse){
	var metalsSupported={
		"XAU":true, "XAG":true, "XPT":true, "XPD":true
	};
	if(!symbol) return false;
 if(!CIQ.Market.Symbology.isForexSymbol(symbol)) return false;
	if(symbol.charAt(0)!="^") symbol="^"+symbol;
	if(!metalsSupported[symbol.substring(1,4)] && metalsSupported[symbol.substring(4,7)]) return true;
	else if(!inverse && metalsSupported[symbol.substring(1,4)] && !metalsSupported[symbol.substring(4,7)]) return true;
	return false;
};

<static> isForexSymbol(symbol)

Returns true if the instrument is a forex symbol.

This is dependent on the market data feed and should be overridden accordingly.

Parameters:
Name Type Description
symbol string

The symbol

Since:
  • 04-2016-08
Returns:

True if it's a forex symbol

Type
boolean
Example
CIQ.Market.Symbology.isForexSymbol=function(symbol){
	if(!symbol) return false;
 if(CIQ.Market.Symbology.isForeignSymbol(symbol)) return false;
 if(CIQ.Market.Symbology.isFuturesSymbol(symbol)) return false;
	if(symbol.length<6 || symbol.length>7) return false;
	if(symbol.length==6 && symbol[5]=="X") return false;  // This is a fund of some sort
	if(/\^?[A-Za-z]{6}/.test(symbol)) return true;
	return false;
};

<static> isFuturesSymbol(symbol)

Returns true if the instrument is a future.

This is dependent on the market data feed and should be overridden accordingly.

Parameters:
Name Type Description
symbol string

The symbol

Since:
  • 04-2016-08
Returns:

True if it's a futures symbol

Type
boolean
Example
CIQ.Market.Symbology.isFuturesSymbol=function(symbol){
	if(!symbol) return false;
	if(symbol.indexOf("/")!==0 || symbol=="/") return false;
	return true;
};