Q4Widgets API Documentation

q4.historicalRange

Retrieves price and volume information for a stock quote historical range.

Recent Version Updates:
2.2.3 - Added "findPriorPrice" and "maxPriorDays" options to allow looking through previous dates before returning "no data" message
2.2.2 - Added beforeRender before checking if data is empty
Script link
q4.historical-range.2.2.3.min.js
Source file
q4.historical-range.js, line 2
Requires

Options

url string
The base URL to use for API calls. By default, calls go to the current domain, so this option is usually unnecessary.
stock Array.<string>
The Stock Exchange the corresponding `symbol` belongs to, in the following format: 'Exchange:Symbol'. If a custom name should be used visibly on the site, list this after the value. This will load the data using the first string, but allow you to control the appearance of the exchange/symbol text that is rendered using the second string. If no value is provided for this array, the widget will attempt to use an entry from the indices lookup list. More info under `lookupIndex` option.
Example
stock: ['NYSE:GDDY']
Example
stock: ['NYSE:GDDY', 'CoolExchangeName:CoolSymbolName']
lookupIndex interger
If no symbol or exchange are provided in the `stock` option, the widget will fall back to using the indices lookup list. The `lookupIndex` option will allow you to target which lookup entry you wish to use for this widget, based on it's index number. The default value is 1, meaning it will load the first lookup entry (ie. the one at the top of the list).
Default value
1
loadingMessage string
A message or HTML string to display while first loading the widget.
Default value
<p class="module_loader"><i class="q4-icon_spinner"></i><span class="sr-only">Loading historical data...</span></p>
itemNotFoundMessage string
A message or HTML string to display in the container if no items are found.
Default value
<p><i class="q4-icon_warning-line"></i> There is no data for the selected date.</p>
range boolean
Whether to show a single date selection or a date range selection.
Default value
false
maxItems interger
The Number of items the API should return. -1 is all.
Default value
-1
loadItems interger
The Number of items the API should return
Default value
1
findPriorPrice boolean
Whether to search for a prior day with data if selected date(s) return no data
Default value
false
maxPriorDays interger
The number of prior days the widget should check before presenting the itemNotFoundMessage message
Default value
8
dateFormat string
A date format string, which can be used in the template as `{{date}}`. By default, dates are formatted using jQuery UI's datepicker.
Default value
mm/dd/yy
Example
'MM d, yy'
selects Object
Options and templates for each of the selects. Most of these options should not be changed. Note that the option 'btnCls' needs to have classes separated by space.
Example
{
    startYear: new Date().getFullYear() - 10,
    btnCls: 'module_options-submit button--inverted'
}
stockTableClass string
The class for the element containing the table. Do not include periods!
Example
'stock-table-container'
rangeTpl function
The template for the date selection when using the date range setup.
Parameters
month string
Month select HTML
day string
Day select HTML
year string
Year select HTML
moduleTpl function
The template for the date selection when using the single date setup.
Parameters
month string
Month select HTML
day string
Day select HTML
year string
Year select HTML
stockHeader string
The HTML template structure for the table header, if desired.
stockTpl string
The template for the table content. Variable options:
Parameters
'{{day}}' string
The date, displayed in the format specified by the 'dateFormat' option.
'{{open}}' string
The opening price.
'{{last}}' string
The last close price.
'{{high}}' string
The high.
'{{low}}' string
The low.
'{{volume}}' string
The volume.
onDataLoad function
A callback that fires each time the data is loaded.
Parameters
e Event
The event object.
data Object
Historical data.
onFirstLoad function
A callback that fires when the widget first renders the selects from the template.
onSelectUpdate function
A callback that fires when the month or year selects have changed (this does not mean a lookup has been triggered).
onWidgetLoad function
A callback that fires when the widget is first created. It is run after 'onFirstLoad'.
beforeRender function
A callback that fires after the entire widget is rendered.
Parameters
event Event
The event object.
complete function
A callback that fires before the full widget is rendered.
Parameters
event Event
The event object.
stockData Object
The complete template data.