mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-11 02:33:51 +00:00
18 lines
340 B
TypeScript
18 lines
340 B
TypeScript
const ROUND_UP = 2;
|
|
const ROUND_DOWN = 3;
|
|
|
|
export function roundTimeframe(
|
|
timeframems: number,
|
|
timestamp: number,
|
|
direction: number = ROUND_DOWN,
|
|
) {
|
|
const offset = timestamp % timeframems;
|
|
return timestamp - offset + (direction === ROUND_UP ? timeframems : 0);
|
|
}
|
|
|
|
export default {
|
|
ROUND_UP,
|
|
ROUND_DOWN,
|
|
roundTimeframe,
|
|
};
|