mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-11 02:33:51 +00:00
18 lines
354 B
TypeScript
18 lines
354 B
TypeScript
export const ROUND_UP = 2;
|
|
export 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,
|
|
};
|