import type { TbankCandle } from '#src/integrations/tbank/tbank.api'; import { formatDecimal } from '#src/common/decimal'; import { decimal } from '#src/integrations/tbank/decimal'; import type { SavedCandle } from '../domain/candle-coverage'; import { timestamp } from '../application/instrument-market'; function toSavedCandle(candle: TbankCandle): SavedCandle { const time = timestamp(candle.time); if (!time || !candle.close) throw new Error('Invalid candle response'); return { time, close: formatDecimal(decimal(candle.close)), isComplete: candle.isComplete === true, }; } export { toSavedCandle };