
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
candles-align
Advanced tools
align 2 or more sets of OHLCV candles by date string or unix epoch seconds; discard candles without a matching partner
Aligns 2 or more sets of OHLCV candles by iso date string or unix epoch seconds; discards candles without a matching "partner".
Experimental, use at your own risk.
npm i candles-align
var {alignCandlesFlat, alignCandlesObjsTime, alignCandlesObjsDate, alignCandlesMultiDate, alignCandlesMultiTime} = require('candles-align');
var candlesA = [
{ date: "2023-05-28T09:58:00.000Z", open: 10, high: 12, low: 9, close: 11, volume: 100 },
{ date: "2023-05-28T10:01:00.000Z", open: 11, high: 13, low: 10, close: 12, volume: 150 },
{ date: "2023-05-28T10:03:00.000Z", open: 12, high: 14, low: 11, close: 13, volume: 120 },
{ date: "2023-05-28T10:08:00.000Z", open: 13, high: 15, low: 12, close: 14, volume: 180 },
{ date: "2023-05-28T10:14:00.000Z", open: 14, high: 16, low: 13, close: 15, volume: 200 },
];
var candlesB = [
{ date: "2023-05-28T10:01:00.000Z", open: 11, high: 13, low: 10, close: 12, volume: 150 },
{ date: "2023-05-28T10:03:00.000Z", open: 12, high: 14, low: 11, close: 13, volume: 120 },
{ date: "2023-05-28T10:08:00.000Z", open: 13, high: 15, low: 12, close: 14, volume: 180 },
{ date: "2023-05-28T10:14:00.000Z", open: 14, high: 16, low: 13, close: 15, volume: 200 },
{ date: "2023-05-28T10:17:00.000Z", open: 15, high: 17, low: 14, close: 16, volume: 140 }
];
//newer interface [any number of symbols]
var alignedMulti = alignCandlesMultiDate({AAPL: candlesA, TSLA: candlesA});
//alignCandlesMultiTime is similar but uses .time and returns .validTimes
console.log(alignedMulti);
// {
// validDates: [
// '2023-05-28T09:58:00.000Z',
// '2023-05-28T10:01:00.000Z',
// '2023-05-28T10:03:00.000Z',
// '2023-05-28T10:08:00.000Z',
// '2023-05-28T10:14:00.000Z'
// ],
// alignedCandles: {
// AAPL: [ [Object], [Object], [Object], [Object], [Object] ],
// TSLA: [ [Object], [Object], [Object], [Object], [Object] ]
// }
// }
//older way of doing it... [align 1 pair of series only]
//alignCandlesObjsDate(candlesA, candlesB, roundToMinute = true)
var doRoundToMinute = true; //round times/dates to nearest minute
var candlesAligned = alignCandlesObjsDate(candlesA, candlesB, doRoundToMinute);
console.log(candlesAligned);
// {
// alignedCandles: { //2 arrays of candles where a[i] is parallel with b[i]
// a: [ [Object], [Object], [Object], [Object] ],
// b: [ [Object], [Object], [Object], [Object] ]
// },
// alignedCandlePairs: [ //"collated" version
// [ [Object], [Object] ],
// [ [Object], [Object] ],
// [ [Object], [Object] ],
// [ [Object], [Object] ]
// ]
// }
//alignCandlesObjsTime has same inputs but expects candles like this
// { time: 1622217720, open: 11, high: 13, low: 10, close: 12, volume: 150 }
//alignCandlesFlat same but expects each candle to be a flat array like this
// [1622217720, open, high, low, close, volume ],
FAQs
align 2 or more sets of OHLCV candles by date string or unix epoch seconds; discard candles without a matching partner
We found that candles-align demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.