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.

Before using, please review and override every CIQ.Market.Symbology function to match the symbol format of your quote Feed or results will be unpredictable.

Since:
  • 04-2016-08

Methods


factory(symbolObject)

This is a function that takes a symbolObject of form accepted by CIQ.ChartEngine#newChart, 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:
This default implementation leverages the use of the CIQ.Market.Symbology checks (isForeignSymbol, isForexFuturesSymbol, isForexMetal, isForexSymbol, isFuturesSymbol), which are used to determine the market for the symbol being loaded. As such it is crucial you review and override every CIQ.Market.Symbology function to match the symbol format of your quote Feed 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#newChart

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;
};

isForeignSymbol(symbol)

Returns true if the instrument is foreign.

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

Currently if the instrument contains a period (.) it will be considered foreign (non US). (e.g. .XXXX)

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;
};

isForexFuturesSymbol(symbol)

Returns true if the symbol is a forex or 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 the symbol is a forex or a future

Type
boolean
Example
CIQ.Market.Symbology.isForexFuturesSymbol=function(symbol){
	if(CIQ.Market.Symbology.isForexSymbol(symbol)) return true;
	if(CIQ.Market.Symbology.isFuturesSymbol(symbol)) return true;
	return false;
};

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.

Currently it must be a forex for a precious metal. (e.g. ^XAUUSD - looks for XAU,XPD,XPT,XAG only)

Parameters:
Name Type Description
symbol string

The symbol

inverse boolean

Set to true to test specifically for a currency/metal pair.

Since:
  • 04-2016-08
Returns:

True if it's a metal symbol

Type
boolean
Example
CIQ.Market.Symbology.isForexMetal=function(symbol,inverse){
	if(!symbol) return false;
	if(!CIQ.Market.Symbology.isForexSymbol(symbol)) return false;
	if(symbol.charAt(0)!="^") symbol="^"+symbol;
	if(",XAU,XPD,XPT,XAG,".indexOf(","+symbol.substr(4,3)+",")!=-1) return true;
	else if(!inverse && ",XAU,XPD,XPT,XAG,".indexOf(","+symbol.substr(1,3)+",")!=-1) return true;
	return false;
};

isForexSymbol(symbol)

Returns true if the instrument is a forex symbol.

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

Currently if the symbol begins with ^ and is followed by 6 alpha characters, or just 6 alpha characters long without a '^', it will be considered forex.(e.g. ^EURUSD)

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;
	if(/\^?[A-Za-z]{6}/.test(symbol)) return true;
	return false;
};

isFuturesSymbol(symbol)

Returns true if the instrument is a futures.

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

Currently if the symbol begins with / it will be considered a future. (e.g. /C)

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;
};