Digits

Returns the number of decimal places in the symbol's price.

Syntax

Digits(): number

Return Value

Returns a number representing the count of decimal places.

Description

The Digits method returns the number of decimal places used in the symbol's price quotation. This value is important for proper price formatting and calculations.

Example

// Get number of decimal places
const digits = this.api.Digits();
console.log(`Price decimal places: ${digits}`);

// Format price with correct precision
const price = 1.23456;
const formattedPrice = price.toFixed(this.api.Digits());
console.log(`Formatted price: ${formattedPrice}`);

// Use in calculations
const point = Math.pow(10, -this.api.Digits());
console.log(`One point value: ${point}`);

Last updated