Skip to main content

newOptionChainWidget

newOptionChainWidget is a constructor function for creating the Option Chain widget.

Widget Constructor

Call newOptionChainWidget to create a widget instance inside a browser DOM element.

import { newOptionChainWidget } from '@dxfeed-widgets/option-chain'

const domNode = document.getElementById('widget-container')
const dataProviders = {
ipfPath: '/your-path/ipf',
ipfAuthHeader: 'your-header',
feedPath: 'wss://your-path/feed',
feedAuthHeader: 'your-header',
schedulePath: '/api/schedule'
}
const widget = newOptionChainWidget({
element: domNode,
providers: dataProviders,
})

Signature

newOptionChainWidget(props: WidgetConstructorProps): WidgetAPI

Returns

An WidgetAPI object.

WidgetConstructorProps

NameTypeDescription
elementHTMLElementA DOM element where the widget should be attached.
providersProvidersAn object with configuration for data providers. Refer to the Data Providers section for details
config optionalConfigInitial configuration of the widget
state optionalStateInitial state of the widget
theme optionalThemeName | ThemeInitial theme of the widget. Refer to the Styling section for details

Widget API

getConfig

Gets the current widget config.

Signature

getConfig(): Config

Returns

Config


setConfig

Sets widget config.

Signature

setConfig(config: Config): void

Parameters

NameTypeDescription
configConfigConfiguration object. Omitted or undefined properties will be set to default

getState

Gets the current widget state.

Signature

getState(): State

Returns

State


updateState

Updates widget state.

Signature

updateState(state: Partial<State>): void

Parameters

NameTypeDescription
statePartial<State>State object. Merges with the previous state object.

addStateListener

Sets up a function that will be called whenever the state or specified field is changed.

Signature

addStateListener(stateChangeCallback: (state: State) => void): void
addStateListener(field: keyof State, fieldChangeCallback: (field: State[keyof State]) => void): void

Parameters

NameTypeDescription
stateChangeCallback(state: State) => voidFunction that will be called whenever the state is changed.

Or

NameTypeDescription
fieldkeyof StateThe state field to listen for.
fieldChangeCallback(value: State[keyof State]) => voidFunction that will be called whenever the specified field is changed.

removeStateListener

Removes an state listener previously registered with addStateListener

Signature

removeStateListener(stateChangeCallback: (state: State) => void): void
removeStateListener(field: keyof State, fieldChangeCallback: (field: State[keyof State]) => void): void

Parameters

NameTypeDescription
stateChangeCallback(state: State) => voidListener that will be removed.

Or

NameTypeDescription
fieldkeyof StateThe state field for which to remove a listener.
fieldChangeCallback(value: State[keyof State]) => voidListener that will be removed.

setSlot

Inserts custom markup into widget UI. Refer to the Extend widget UI section for details.

Signature

setSlot(slot: Slot, element: HTMLElement): void

Parameters

NameTypeDescription
slotSlotThe place where a provided element is inserted.
elementHTMLElementAn element that is inserted.

setTheme

Sets widget theme.

Signature

setTheme(theme: Theme | ThemeName): void

unmount

Destroys the widget.

Signature

unmount(): void

Data Providers

The Data Providers object supplies an information about the endpoints required by the widget, such as the path to the endpoint and the authorization key.

interface OptionChainWidgetDataProviders {
ipfPath: string
ipfAuthHeader: string
feedPath: string
feedAuthHeader: string
schedulePath: string
}

Properties

NameTypeDescription
ipfPathstringA string containing the path to the endpoint.
ipfAuthHeaderstringA string containing the authentication header for the endpoint.
feedPathstringA string containing the path to the endpoint.
feedAuthHeaderstringA string containing the authentication header for the endpoint.
schedulePathstringA string containing the path to the endpoint.

Configuration

Configuration is an object that defines the basic behavior of a widget and allows enabling or disabling widget features that cannot be configured within the widget's user interface.

Type

interface OptionChainWidgetConfig {
  symbolSearchTypes?: OptionChainWidgetSymbolSearchType[],
  symbolSearchViewMode?: SymbolSearchViewMode,
  showChart?: boolean,
  seriesSelectorViewMode?: ToolbarSelectorViewMode,
  strikesSelectorViewMode?: ToolbarSelectorViewMode,
  extendedCheckboxEnabled?: boolean,
  resizable?: boolean,
  columnSelectMenuEnabled?: boolean,
  delayNotificationEnabled?: boolean,
  symbolScheduleStatusEnabled?: boolean,
  locale?: LocaleSettings,
}

Properties

NameTypeDefaultDescription
symbolSearchTypes
Optional
OptionChainWidgetSymbolSearchType[]
[
 'STOCK',
 'FUTURE',
 'ETF',
 'INDEX'
]
A list of instrument types uses for symbols search.
symbolSearchViewMode
Optional
SymbolSearchViewMode
'available'
View mode of the symbol search in the toolbar.
showChart
Optional
boolean
true
A flag that controls the chart visibility in the information panel under the toolbar.
seriesSelectorViewMode
Optional
ToolbarSelectorViewMode
'available'
View mode of the series menu in the toolbar.
strikesSelectorViewMode
Optional
ToolbarSelectorViewMode
'available'
View mode of the strikes select in the toolbar.
extendedCheckboxEnabled
Optional
boolean
true
A flag that controls the extended checkbox visibility in the toolbar.
resizable
Optional
boolean
true
A flag that controls the column resizing feature.
columnSelectMenuEnabled
Optional
boolean
true
A flag that controls the column select menu feature visibility. Disabling this feature will lead to inability to change columns.
delayNotificationEnabled
Optional
boolean
false
A flag that controls a visibility of an data delay notification.
symbolScheduleStatusEnabled
Optional
boolean
false
A flag that controls a visibility of symbol schedule status in widget toolbar
locale
Optional
LocaleSettings
{
  language: 'en',
  dateLocale: 'en-GB'
}
An object that defines the language and regional settings of the widget.

State

State is an object that represents the state of the widget.

Type

interface OptionChainWidgetState {
  columns: OptionChainComlumn[],
  symbol?: string,
  columnSizes: OptionChainColumnSizes,
  isExtended: boolean,
  focusedSeriesName?: string,
  expandedSeriesNames: string[],
  strikeAmount: StrikeAmount,
}

Properties

NameTypeDefaultDescription
columnsOptionChainComlumn[]
[]
A list of column identifiers that are added to the table.
symbol
Optional
string
undefined
A string containing a selected symbol.
columnSizesOptionChainColumnSizes
{}
An object that specifies column sizes where key is a column identificator and value is a column width in pixels. If the object does not contain a column width, then default width is used.
isExtendedboolean
false
A flag that controls the visibility of additional information in the panel below the widget's toolbar.
focusedSeriesName
Optional
string
undefined
A string containing a series name. It is set when user selects a series from the "series" dropdown menu in the toolbar.
expandedSeriesNamesstring[]
[]
A list of the series names that is expanded in the table.
strikeAmountStrikeAmount
4
call\put pairs in option series.

Type Reference

Slot

Type

'header'

StrikeAmount

Type

2 | 4 | 6 | 8 | 'all'

OptionChainComlumn

List of supported columns:

  • symbol: Symbol
  • opol: OPOL
  • symbolDescription: Description
  • currency: Trading Currency
  • expDate: Expiration Date
  • strike: Strike
  • bidPrice: Bid Price
  • bidSize: Bid Size
  • bidTime: Bid Time
  • askPrice: Ask Price
  • askSize: Ask Size
  • askTime: Ask Time
  • spread: Spread
  • spreadPercent: Spread, %
  • midPrice: Mid Price
  • lastPrice: Last Price
  • dayVwap: Volume-Weighted Average Price
  • dayVolume: Volume
  • lastUpdateTime: Last Update Time
  • dayBidVolume: Volume Bid
  • dayAskVolume: Volume Ask
  • openInterest: Open Interest
  • prevDayClosePrice: Previous day closing price
  • changePrevDayClosePrice: Change Previous Day
  • changePrevDayClosePricePercent: Change Previous Day, %
  • dayOpenPrice: Open
  • changeCurDayOpenPrice: Change from Open
  • changeCurDayOpenPricePercent: Change from Open, %
  • gapDay: Gap
  • gapDayPercent: Gap, %
  • dayHighPrice: High
  • dayLowPrice: Low
  • rangeDay: Day range
  • positionInRangeDayPercentage: Position in Day Range, %
  • markPrice: Mark Price
  • markChange: Mark Change
  • optTheoPriceTime: Option Analytics Calculation Time
  • optTheoPrice: Option Theoretical Price
  • optUnderlyingPrice: Option Underlying Price
  • optExpDivRate: Option Implied Exponential Dividend Rate
  • optImpVol: Option Implied Volatility
  • optDelta: Option Delta
  • optGamma: Option Gamma
  • optTheta: Option Theta
  • optRho: Option Rho
  • optVega: Option Vega
  • optGreeksTime: Option Greeks Calculation Time
  • tradingStatus: Trading status
  • priceType: Price Type
  • sessionEndTime: Current trading session end time

Type

string

OptionChainWidgetSymbolSearchType

Type

'STOCK' | 'FUTURE' | 'ETF' | 'INDEX'

SymbolSearchViewMode

Type

'available' | 'hidden' | 'value-only'

ToolbarSelectorViewMode

Type

'available' | 'hidden'

OptionChainColumnSizes

Type

Partial<Record<stringnumber>>

LocaleSettings

An object that defines the language and regional settings of the widget.

Type

{
  language: Language,
  dateLocale: string,
}

Language

Type

'en' | 'de' | 'ar'