refactor: centralize provider projections
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import type { TbankCandle } from '../../../../integrations/tbank/tbank.api';
|
||||
import type { SavedCandle } from '../domain/candle-coverage';
|
||||
|
||||
import { formatDecimal } from '../../../../common/decimal';
|
||||
import { decimal } from '../../../../integrations/tbank/decimal';
|
||||
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 };
|
||||
Reference in New Issue
Block a user