API Reference
Namespaces
Classes
Events
Global
Externals

Class: ExtendedHours

CIQ. ExtendedHours


new ExtendedHours(params)

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

Extended hours can be toggled using the Ctrl+Alt+X keystroke combination (see the extendedHours action in hotkeyConfig.hotkeys in js/defaultConfiguration.js).

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 extended hour 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 when params.filter is set to true, this module performs a filter of already loaded masterData when CIQ.ExtendedHours.set is invoked, rather than calling CIQ.ChartEngine#loadChart to reload the data from the server every time you enable or disable this feature. So you must always return all requested sessions on your fetch responses if this flag is set.

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#loadChart to reload the data from the server.

menuContextClass string <optional>

A CSS class name used to query the menu DOM element that contains the UI control for the extended hours add-on. In a multi-chart document, the add-on is available only on charts that have a menu DOM element with the value for menuContextClass as a class attribute.

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 reload 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.
  • 8.0.0 Added params.menuContextClass.
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.loadChart(stxx.chart.symbol, {}, 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#loadChart. 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.