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
-
encodeTermStructureInstrumentSymbol(entity, instrument)
-
Encodes the string identifier for a specific instrument in a term structure chart. This function is called when a time series chart is opened for a term structure instrument. See CIQ.UI.CurveEdit.launchTimeSeries.
Typically, the implementation of this function concatenates the term structure entity with the instrument name to fully identify the instrument on the time series chart (see example).
Override this function to specify whatever encoding you need for your use case.
Parameters:
Name Type Description entity
string The symbol/entity for the curve; for example, "US-T BENCHMARK".
instrument
string An individual instrument; for example, "20 YR".
- Since:
-
7.4.0
Returns:
The symbol for the individual instrument; for example, "US-T BENCHMARK 20 YR".
- Type
- string
Example
CIQ.Market.Symbology.encodeTermStructureInstrumentSymbol = function(entity, instrument) { // Remove leading % sign. if (entity[0] === "%") entity = entity.slice(1); return entity + " " + instrument; };
-
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 CIQ.Market.GENERIC_5DAY; if (CIQ.Market.Symbology.isFuturesSymbol(symbol)) return CIQ.Market.GLOBEX; if (CIQ.Market.Symbology.isForexCrypto(symbol)) return null; // 24 hour market definition 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.
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; };
-
isForexCrypto(symbol)
-
Returns true if the symbol is a cryptocurrency pair
This is dependent on the market data feed and should be overridden accordingly.
Parameters:
Name Type Description symbol
string The symbol
- Since:
-
8.4.0
Returns:
True if it's a crypto symbol
- Type
- boolean
Example
CIQ.Market.Symbology.isForexCrypto = function (symbol) { const cryptosSupported = {BTC: true, ETH: true, XLM: true, LTC: true, ETC: true, XRP: true, ADA: true, BNB: true}; if (!symbol) return false; if (!CIQ.Market.Symbology.isForexSymbol(symbol)) return false; if (symbol.charAt(0) != "^") symbol = "^" + symbol; return (cryptosSupported[symbol.substring(1, 4)] || cryptosSupported[symbol.substring(4, 7)]); };
-
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
-
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; };
-
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; };
-
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; };
-
isRateSymbol(symbol)
-
Determines whether an instrument is a rate.
Note: This function is dependent on the market data feed and should be overridden accordingly.
Parameters:
Name Type Description symbol
string The symbol.
- Since:
-
7.4.0
Returns:
By default, false. Override this function to return true if the symbol is a rate family or rate.
- Type
- boolean
Example
CIQ.Market.Symbology.isRateSymbol=function(symbol){ if(!symbol) return false; if(symbol.indexOf("%")!==0 || symbol=="%") return false; return true; };