Namespace: quotefeed

quotefeed

See tutorial Data Integration : Quotefeeds for a complete overview and step by step source code for implementing a quotefeed

Interface for classes that implement a quotefeed. You define a quotefeed object and attach it to the chart using CIQ.ChartEngine#attachEngineQuoteFeed. Each member "fetch..." method is optional. The chart will call your member method if it exists, and will skip if it does not.

Methods


fetchInitialData(symbol, suggestedStartDate, suggestedEndDate, params, cb)

See Data Integration : Quotefeeds

The charting engine calls this quotefeed function whenever the chart is wiped clean and created again with new data. This typically occurs when CIQ.ChartEngine#newChart is called but can also occur from other methods such as CIQ.ChartEngine#setPeriodicity or CIQ.ChartEngine#importLayout.

Parameters:
Name Type Description
symbol string

The ticker symbol of the data being fetched

suggestedStartDate Date

A suggested starting date for the fetched data (based on how much can be displayed)

suggestedEndDate Date

A suggested starting date for the fetched data (based on how much can be displayed)

params object

Provides additional information on the data requested by the chart.

Properties
Name Type Argument Default Description
series Boolean

If true then the request is for series/comparison data (i.e. not the the main symbol)

stx CIQ.ChartEngine

The chart object requesting data

symbolObject string <optional>

The symbol to fetch in object format; if a symbolObject is initialized ( see CIQ.ChartEngine#newChart, CIQ.ChartEngine#addSeries, CIQ.Comparison.add )

period number

The timeframe each returned object represents. For example, if using interval "minute", a period of 30 means your feed must return ticks (objects) with dates 30 minutes apart; where each tick represents the aggregated activity for that 30 minute period. Note that this will not always be the same as the period set in CIQ.ChartEngine#setPeriodicity, since it represents the aggregation of the raw data to be returned by the feed server, rather than the final data to be displayed.

interval string

The type of data your feed will need to provide. Allowable values: "millisecond,"second","minute","day","week","month". (This is not how much data you want the chart to show on the screen; for that you can use CIQ.ChartEngine#setRange or CIQ.ChartEngine#setSpan)

fetchMaximumBars Boolean <optional>

If set to true, the chart requires as much historical data as is available from the feed (params.ticks may also be set to 20,000 to set a safety max), regardless of start date. This is needed for some chart types since they aggregate data (kagi,renko, or linebreak, for example). Developers implementing fetch, should override params.tick and use a smaller number if their feed can't support that much data being sent back. The engine will then make multiple smaller calls to get enough data to fill the screen.

ticks number

The suggested number of data points to return. This is calculated as twice the number of bars displayed on the chart. This can be used as an alternative to suggestedStartDate.

timeout number <optional>
10000

This may be used to set the timeout in msec of the remote server request.

cb quotefeed~dataCallback

Call this function with the results (or error) of your data request.

Since:
  • 4.1.2 Added timeout parameter.

fetchPaginationData(symbol, suggestedStartDate, endDate, params, cb)

See Data Integration : Quotefeeds

The charting engine calls this quotefeed function whenever the chart requires older data. Usually this is because a user has scrolled or zoomed past the end of the data. Note: This method may be called during initial load if your fetchInitialData didn't provide enough data to fill the visible chart.

Parameters:
Name Type Description
symbol string

The ticker symbol of the data being fetched

suggestedStartDate Date

A suggested starting data for the fetched data (based on how much can be displayed)

endDate Date

The date of the last data point currently available in the chart. You should return data from this point and then backward in time.

params object

Provides additional information on the data requested by the chart.

Properties
Name Type Argument Default Description
stx CIQ.ChartEngine

The chart object requesting data

symbolObject string <optional>

The symbol to fetch in object format; if a symbolObject is initialized ( see CIQ.ChartEngine#newChart, CIQ.ChartEngine#addSeries, CIQ.Comparison.add )

period number

The timeframe each returned object represents. For example, if using interval "minute", a period of 30 means your feed must return ticks (objects) with dates 30 minutes apart; where each tick represents the aggregated activity for that 30 minute period. Note that this will not always be the same as the period set in CIQ.ChartEngine#setPeriodicity, since it represents the aggregation of the raw data to be returned by the feed server, rather than the final data to be displayed.

interval string

The type of data your feed will need to provide. Allowable values: "millisecond,"second","minute","day","week","month". (This is not how much data you want the chart to show on the screen; for that you can use CIQ.ChartEngine#setRange or CIQ.ChartEngine#setSpan)

fetchMaximumBars Boolean <optional>

If set to true, the chart requires as much historical data as is available from the feed (params.ticks may also be set to 20,000 to set a safety max), regardless of start date. This is needed for some chart types since they aggregate data (kagi,renko, or linebreak, for example). Developers implementing fetch, should override params.tick and use a smaller number if their feed can't support that much data being sent back. The engine will then make multiple smaller calls to get enough data to fill the screen.

ticks number

The suggested number of data points to return. This is calculated as twice the number of bars displayed on the chart. This can be used as an alternative to suggestedStartDate.

timeout number <optional>
10000

This may be used to set the timeout in msec of the remote server request.

cb quotefeed~dataCallback

Call this function with the results (or error) of your data request.

Since:
  • 4.1.2 Added timeout parameter.

fetchUpdateData(symbol, startDate, params, cb)

See Data Integration : Quotefeeds

The charting engine calls this quotefeed function periodically (poll) to request updated data. The polling frequency is determined by the refreshInterval that you provided when you called CIQ.ChartEngine#attachQuoteFeed.

Parameters:
Name Type Description
symbol string

The ticker symbol of the data being fetched

startDate Date

The starting date for the fetched data (based on how much can be displayed)

params object

Provides additional information on the data requested by the chart.

Properties
Name Type Argument Default Description
series Boolean

If true then the request is for series/comparison data (i.e. not the main symbol)

stx CIQ.ChartEngine

The chart object requesting data

symbolObject string <optional>

The symbol to fetch in object format; if a symbolObject is initialized ( see CIQ.ChartEngine#newChart, CIQ.ChartEngine#addSeries, CIQ.Comparison.add )

period number

The timeframe each returned object represents. For example, if using interval "minute", a period of 30 means your feed must return ticks (objects) with dates 30 minutes apart; where each tick represents the aggregated activity for that 30 minute period. Note that this will not always be the same as the period set in CIQ.ChartEngine#setPeriodicity, since it represents the aggregation of the raw data to be returned by the feed server, rather than the final data to be displayed.

interval string

The type of data your feed will need to provide. Allowable values: "millisecond,"second","minute","day","week","month". (This is not how much data you want the chart to show on the screen; for that you can use CIQ.ChartEngine#setRange or CIQ.ChartEngine#setSpan)

timeout number <optional>
10000

This may be used to set the timeout in msec of the remote server request.

cb quotefeed~dataCallback

Call this function with the results (or error) of your data request.

Since:
  • 4.1.2 Added timeout parameter.

subscribe(params)

See Data Integration : Advanced

Although not a core quotefeed function, the charting engine calls this optional function each time the chart encounters a new symbol or a particular periodicity for that symbol. This could happen when a user changes periodcity, changes a symbol, adds a comparison symbol, or a new study is added that requires an underlying symbol.

Use this along with unsubscribe() to keep track of symbols on the chart. Use cases include: maintaining legends, lists of securities, or adding/removing subscriptions to streaming connections.

If using a push stream, subscribe and then have the push streamer push updates using CIQ.ChartEngine#appendMasterData.

Parameters:
Name Type Description
params object

Provides additional information on the data requested by the chart.

Properties
Name Type Description
stx CIQ.ChartEngine

The chart object requesting data

symbol string

The symbol being added

symbolObject string

The symbol being added in object form

period number

The timeframe each returned object represents. For example, if using interval "minute", a period of 30 means your feed must return ticks (objects) with dates 30 minutes apart; where each tick represents the aggregated activity for that 30 minute period. Note that this will not always be the same as the period set in CIQ.ChartEngine#setPeriodicity, since it represents the aggregation of the raw data to be returned by the feed server, rather than the final data to be displayed.

interval string

The type of data your feed will need to provide. Allowable values: "millisecond,"second","minute","day","week","month". (This is not how much data you want the chart to show on the screen; for that you can use CIQ.ChartEngine#setRange or CIQ.ChartEngine#setSpan)

Since:
  • 4.0.0 Changes to periodicity (period/interval) will now also cause subscribe calls

unsubscribe(params)

See Data Integration : Advanced

Although not a core quotefeed function, the charting engine calls this optional function each time the chart no longer requires a symbol or a particular periodicity for that symbol.

Parameters:
Name Type Description
params object

Provides additional information on the data requested by the chart.

Properties
Name Type Description
stx CIQ.ChartEngine

The chart object requesting data

symbol string

The symbol being removed

symbolObject string

The symbol being removed in object form

period number

The timeframe each returned object represents. For example, if using interval "minute", a period of 30 means your feed must return ticks (objects) with dates 30 minutes apart; where each tick represents the aggregated activity for that 30 minute period. Note that this will not always be the same as the period set in CIQ.ChartEngine#setPeriodicity, since it represents the aggregation of the raw data to be returned by the feed server, rather than the final data to be displayed.

interval string

The type of data your feed will need to provide. Allowable values: "millisecond,"second","minute","day","week","month". (This is not how much data you want the chart to show on the screen; for that you can use CIQ.ChartEngine#setRange or CIQ.ChartEngine#setSpan)

Since:
  • 4.0.0 Changes to periodicity (period/interval) will now also cause unsubscribe calls

Type Definitions


dataCallback(response)

Each of your quotefeed's "fetch..."" methods must call this callback to return data results to the chart.

Parameters:
Name Type Description
response
Properties
Name Type Argument Description
error string <optional>

An error message, if one occurred.

quotes array <optional>

An array of Quotes in required JSON format.

moreAvailable boolean <optional>

Set this to false if you know that no older data is available (to stop pagination requests).

attribution object <optional>

This object will be assigned to stx.chart.attribution. Your UI can use this to display attribution messages. See example.

Examples

Returning quotes in the dataCallback object

cb({quotes:[--array of quote elements here--]});

Returning an error in the dataCallback object

cb({error:"Your error message here"});

Setting attribution through the dataCallback object

// Set up a callback to be called whenever fetchInitialData is called
 stxx.attachQuoteFeed(yourQuoteFeed, {callback: showAttribution});

// after very data call, the attribution function will be called and you can then use it to display any message regarding the quote feed
		function showAttribution(params){
			var message=params.stx.chart.attribution.message;
			// add your code here to display the message on your screen.
		}

// In your quotefeed's fetchInitialData method, set the attribution object
cb({quotes:[--array of quote elements here--], attribution:{message:"Data is delayed by 15 minutes"}});