export const candleToBar = ({ open, close, high, low, volume, begin }: ApiCandle): MoexChartCandle => {
const time = Math.floor(Date.parse(`${begin}Z`) / 1000);
console.log('[candleToBar]', {
begin,
time,
utc: new Date(time * 1000).toISOString(),
local: new Date(time * 1000).toString(),
});
return {
open,
close,
high,
low,
// TODO временное решение по просьбе PO обнулять volume для прайм инструментов на графике
// В котировках volume и value значения всегда null
volume: volume || 0,
time,
};
};
console.log(
'[4h convolution]',
result.slice(0, 10).map(({ time }) => ({
time,
utc: new Date(time * 1000).toISOString(),
local: new Date(time * 1000).toString(),
})),
);
console.log('[moex-chart formatDate]', {
time,
utc: new Date(time * 1000).toISOString(),
local: new Date(time * 1000).toString(),
formatted: dayjs.unix(time).format('HH:mm:ss'),
});