Price precision
Price precision means how many decimal numbers you will see for a particular instrument price on Y axis.
DXcharts React has a concept 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 manage priceIncrements in DXcharts React
Each instrument should have its own priceIncrements to display the price on Y axis correctly, if no priceIncrements was provided
to an instrument, it defaults to 0.01 for all price ranges.
The list of available instruments is passed via Symbol Suggest Provider.
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',
},
];
Price precision for orders and positions
Price precision for orders and positions an be set using ChartReactAPI:
If the following methods are not used, price precision is the priceIncrements for the selected instrument.
- for positions -
setPositionsPrecision - for orders (and positions if
setPositionsPrecisionis not used) -setTradingItemsPricePrecision