refactor: replace ignored numeric literals with constants

This commit is contained in:
2026-09-28 16:37:01 +03:00
committed by ksv741
parent a970eaaf7a
commit b78c215ff1
60 changed files with 510 additions and 283 deletions
@@ -7,6 +7,7 @@ import {
multiply,
subtract,
} from '../../../../../common/decimal';
import { ISO_DATE_LENGTH, ISO_DATE_START } from '../../../../../common/time';
import { decimal } from '../../../../../integrations/tbank/decimal';
import { CandleService } from '../../application/candle.service';
import {
@@ -20,6 +21,8 @@ import {
StockQuoteResourceDto,
} from '../presentation/stock.dto';
const ZERO_AMOUNT = 0n;
const CHANGE_PERCENT_DECIMAL_PLACES = 6;
@Injectable()
export class StockMarketService {
@@ -90,7 +93,7 @@ export function stockQuote(
price,
priceAt,
tradingStatus,
previousCloseDate: timestamp(previous?.time)?.slice(0, 10) ?? null,
previousCloseDate: timestamp(previous?.time)?.slice(ISO_DATE_START, ISO_DATE_LENGTH) ?? null,
previousClose: previousPrice,
change:
difference && currency ?
@@ -99,7 +102,7 @@ export function stockQuote(
changePercent:
difference &&
previousPrice &&
decimalFromString(previousPrice.value).value > 0n ?
decimalFromString(previousPrice.value).value > ZERO_AMOUNT ?
formatDecimal(
divide(
multiply(difference, decimalFromString('100')),