Class: ExtendedHours

CIQ. ExtendedHours


new ExtendedHours(params)

Use this constructor to initialize visualization styles of extended hours by the use of shading and delimitation lines.

Requires addOns.js

This visualization will only work if data for the corresponding sessions is provided from your quote feed and the market definitions have the corresponding entries. See CIQ.Market for details on how to define extended (non-default) hours.

By default all sessions are disabled unless explicitly enabled using CIQ.ExtendedHours.prepare or CIQ.ExtendedHours.set.

All possible market sessions needed to be shaded at any given time should be enabled at once with this method.

Your fetch should load the required data based on the params.stx.layout.extended and params.stx.layout.marketSessions settings. Remember that setting params.filter to true, performs a filter of masterData when CIQ.ExtendedHours.set is invoked, rather than calling CIQ.ChartEngine#newChart to reload the data from the server every time you enable or disable this feature. So you must always return all sessions on your fetch responses.

CSS info:

  • The styles for the shading of each session is determined by the corresponding CSS class in the form of "stx_market_session."+session_name (Example: stx_market_session.pre)
  • The divider line is determined by the CSS class "stx_market_session.divider".

Important: This module must be initialized before CIQ.ChartEngine#importLayout or the sessions will not be able to be restored.

Example

Parameters:
Name Type Description
params object

The constructor parameters

Properties
Name Type Argument Description
stx CIQ.ChartEngine <optional>

The chart object

filter boolean <optional>

Setting to true performs a filter of masterData when CIQ.ExtendedHours.set is invoked, rather than calling CIQ.ChartEngine#newChart to reload the data from the server.

Since:

  • • 06-2016-02
    • 3.0.0 changed argument to an object to support filter
    • 3.0.0 no longer necessary to explicitly call new Chart to re-load data. Instead call CIQ.ExtendedHours.set function.
    • 5.0.0 no longer necessary to explicitly set `stx.layout.marketSessions` or 1stx.layout.extended` to manage sessions; instead call CIQ.ExtendedHours.prepare or CIQ.ExtendedHours.set
Examples
// Call this only once to initialize the market sessions display manager.
		new CIQ.ExtendedHours({stx:stxx, filter:true});

		// By default all sessions are disabled unless explicitly enabled.
		// This forces the extended hours sessions ["pre","post"] to be enabled when the chart is initially loaded.
		stxx.extendedHours.prepare(true);

		//Now display your chart
		stxx.newChart(stxx.chart.symbol, null, null, function(){});
// once your chart is displayed, you can call this from any UI interface to turn on extended hours.
		stx.extendedHours.set(true);

		// or call this from any UI interface to turn off extended hours.
		stx.extendedHours.set(false);
// CSS entries for a session divider and sessions named "pre" and "post"
		.stx_market_session.divider {
			background-color: rgba(0,255,0,0.8);
			width: 1px;
		}
		.stx_market_session.pre {
			background-color: rgba(255,255,0,0.1);
		}
		.stx_market_session.post {
			background-color: rgba(0,0,255,0.2);
		}

Methods


prepare(enable, sessions)

Prepares the extended hours settings and classes for the session names enumerated in the arguments without actually displaying or loading the data.

This method can be used to force a particular session to load by default by calling it before CIQ.ChartEngine#newChart. Otherwise the chart will be loaded with all sessions disabled until CIQ.ExtendedHours.set is invoked.

CIQ.ChartEngine#importLayout will also call this method to ensure the sessions are restored as previously saved.

Parameters:
Name Type Description
enable boolean

Set to turn on/off the extended-hours visualization.

sessions array

The sessions to visualize when enable is true. Any sessions previously visualized will be disabled. If set to null, will default to ["pre","post"].

Since:
  • 5.0.0

set(enable, sessions, cb)

Turns on or off extended hours for the session names enumerated in the arguments.

Parameters:
Name Type Description
enable boolean

Set to turn on/off the extended-hours visualization.

sessions array

The sessions to visualize when enable is true. Any sessions previously visualized will be disabled. If set to null, will default to ["pre","post"].

cb function

Optional callback function to be invoked once chart is reloaded with extended hours data.