Class: Iterator

CIQ.Market. Iterator


new Iterator(parms)

Builds an iterator instance and returns it to the requesting market when CIQ.Market#newIterator is called. Do not call this constructor directly.

Parameters:
Name Type Description
parms object
Properties
Name Type Description
begin object

A dataset element from CIQ.Chart.dataSet

market CIQ.Market

An instane of CIQ.Market

periodicity object

A valid periodicity as require by CIQ.ChartEngine#setPeriodicity

interval string

Time interval: millisecond, second, minute, hour, day, week, or month.

multiple object

How many jumps to make on each interval loop.

inZone string

Datazone to translate from

outZone string

Datazone to translate to

Since:
  • 04-2016-08
Example
var market24=new CIQ.Market();
	    var iter_parms = {
	        'begin': stxx.chart.dataSet[stxx.chart.dataSet.length-1].DT,	// last item on the dataset
	        'interval': stxx.layout.interval,
	        'periodicity': stxx.layout.periodicity,
	        'timeUnit': stxx.layout.timeUnit,
	        'inZone': stxx.dataZone,
	        'outZone': stxx.dataZone
	    };
	    var iter = market24.newIterator(iter_parms);
	    var next = iter.next();

Methods


date()

Returns the current date of the iterator without moving forwards or backwards. Takes into account display zone settings.

Since:
  • 04-2016-08
Returns:

The current date of the iterator.

Type
Date
Example
iteratorDate = iter.date();

futureTick(parms)

Calculate the number of ticks from begin date to end date taking into account market open, close, and holidays. If the end date is older than the begin date,it will work backward into the past. If the end date is newer than the begin date,it will work forward into the future. Note that the begin date is set when this instance of the iterator is created and one should NOT call previous or next before calling this function, or the 'begin' pointer will change.

Parameters:
Name Type Description
parms object

An object containing the following properties:

Properties
Name Type Argument Description
end date

An end date. Will be assumed to be inZone if one set.

sample_size integer <optional>

Default is 25. Maximum amount of time (in milliseconds) taken to count ticks. If sample size is reached before the number of ticks is found the number of ticks will be estimated mathematically. The bigger the sample size couple with the distance between begin date and end date affect how precise the return value is.

sample_rate integer <optional>

Default is 1000. Maximum number of ticks to evaluate before checking parms.sample_size.

Since:
  • 04-2016-08
Returns:

The number of ticks between begin and end.

Type
integer
Example
// find out how many ticks in the past a date is from the beginning of the dataSet
// (assumes the target date is older than the first dataSet item)
	var iter = this.standardMarketIterator(chart.dataSet[0].DT);
	var ticks=iter.futureTick({someRandomDate});

isHourAligned()

Checks if market is aligned and if iterator is intraday (daily intervals always align)

Since:
  • 04-2016-08
Returns:

true if this market is hour aligned.

Type
Boolean

isOpen()

Check and see if this Market is open now.

Since:
  • 04-2016-08
Returns:

true or false

Type
Boolean

next( [skip])

Move the iterator one interval forward

Parameters:
Name Type Argument Description
skip Integer <optional>

Default 1. Jump forward skip * periodicity at once.

Since:
  • 04-2016-08
Returns:

Next date in iterator outZone.

Type
Date
Example
now = iter.next();

previous(skip)

Move the iterator one interval backward

Parameters:
Name Type Description
skip Integer

Default is one. Move this many multiples of interval.

Since:
  • 04-2016-08
Returns:

Previous date in iterator outZone.

Type
Date
Example
now = iter.previous();