Skip to main content

Timezones

UTC

UTC option represent the UTC timezone or 00:00.

Exchange

Exchange option represent the timezone in which the instrument is traded. Exchange is dynamically updated based on the trading hours of the instrument. If the trading hours of the instrument are for example:

NewYorkUS(rt=0300;0=p04000930r09301600a16002000)

The result would be the America/New_York timezone, which is the New York timezone with an offset -04:00, or UTC-4.

Configuration

Any timezone identifier is stored in a currentTimezone config. Possible values: UTC for utc, Exchange for exchange or any other Timezones database value, for example, Asia/Bangkok:

timezones: { currentTimezone: 'UTC' },
interface TimezonesConfig {
currentTimezone: string;
listOfTimezones: Array<string>;
}
import React from 'react';
import { ChartReactApp } from '@dx-private/dxchart5-react/dist/chart/chart-react-app';
import { CREATE_MOCK_PROVIDERS } from '@dx-private/dxchart5-react-mock-providers/dist';
const timezones = {
currentTimezone: 'Pacific/Fiji',
// valid formats of timezones
listOfTimezones: ['America/Argentina/Buenos_Aires', 'Asia/Bangkok', 'CET', 'CST6CDT', 'Etc/GMT+8', 'Etc/UTC'],
};
export const YourApp = () => {
return (
<ChartReactApp
dependencies={{
...CREATE_MOCK_PROVIDERS(),
/*...rest_dependencies,*/
timezones,
}}
/>
);
};

UTC and Exchange are predefined and you cannot exclude them from the list. If you wish to have only them in the list of timezones then pass empty array to the listOfTimezones configuration:

timezones: { currentTimezone: 'UTC', listOfTimezones: [] }

If you don't want to see timezone controls at all you can disable it via dependencies:

chartReactConfig: {
timezoneControls: {
enabled: false;
}
}

Timezones and candles timestamps

To correctly display candles timestamps information on chart please make sure the source of data and CandleDataProvider send the candles timestamps which correspond to UTC timezone, or 00:00 day time.

Explanation: timezone model has a currentTzOffset function, which allows to apply the selected timezone's offset to the candles timestamp to correctly show the data according to the selected timezone.

If the period is less than a day, the offset applies to the UTC timestamp:

On the other hand, if the period is a day or more, the offset is not applied, because it's not needed anymore since candles have at least a day difference inbetween them, so candles always have UTC timezone (00:00 format):

Further reading

Timezones in dxcharts-lite

Trading sessions provider