Price Precision
Price precision in other words means how many decimal numbers you will see for a particular instrument price on Y Axis.
In dxchart5-react
we have a special concept for this called priceIncrements
. priceIncrements
is an array of numbers that represent the price steps for an instrument on Y-Axis in the next format:
[(priceIncrement, price)*, incrementForOtherPrices]
Example
Let's take a look on the example for better understanding:
const priceIncrements = [0.01, 1, 0.1, 10, 1];
Here we can see three increments:
- (for the price less than 1, the price step is 0.01)
- (for the price less than 10, the price step is 0.1)`
- and (for any other price, the price step is 1).
This means that for the price less than 1, the price will be shown with 2 decimal numbers, for the price less than 10, the price will be shown with 1 decimal number, and for any other price, the price will be shown without decimal numbers.
NOTE: there are some requirements for priceIncrements
array:
- minimum length is 3.
- number of elements in the array should be odd.
How to control priceIncrements
in dxchart5-react
Each instrument should have its own priceIncrements
to display the price on Y-Axis correctly, if no priceIncrements
was provided
to Instrument
it defaults to 0.01
for all price ranges.
In dxchart5-react
the list of available Instrument
s is passed via SymbolSuggestProvider
(reference).
Each Instrument
has a priceIncrements
property that you can use to control the price precision.
const instruments = [
{
description: '"Advanced Micro Devices, Inc. - Common Stock"',
priceIncrements: [0.0001, 1, 0.01],
symbol: 'AMD',
type: 'STOCK',
},
];