Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
ohlc-aggregator
Advanced tools
Aggregates ohlcv candle values into predictable coarse-grained intervals. The intervals should be either minutes
, hours
, or days
.
The difference between this package and other packages is that rather than simply aggregating each n
candles into a group, we create predictable interval where the start time of each interval is divisible by n
. If some candles from an interval are missing, we still create those interval.
In converting 1m
to 5m
candles, a naive implementation creates only one group for the following 5 candles:
time: 8:59am
time: 9:00am
time: 9:01am
time: 9:02am
time: 9:03am
However, this package creates two groups based on predictable timing intervals, i.e., the start of each timing interval is divisible by 5m:
8:55 to 8:59
9:00 to 9:05
We create two groups although some candles are missing from each group.
Consider these candles:
time: 8:59am
time: 9:00am
time: 9:01am
time: 9:02am
time: 9:03am
time: 9:04am
time: 9:05am
time: 9:06am
A naive implementation will create these groups:
8:59 to 9:03
, (complete candle)9:04 to 9:06
, (incomplete candle)However, a predictable grouping would be:
8:55 to 9:00
, (incomplete candle)9:00 to 9:04
, (complete candle)9:05 to 9:09
, (incomplete candle)Again, the start of each timing interval is divisible by 5m.
npm i -s ohlc-aggregator
// Converting 1m to 5m candles
let ohlc_aggregate = require("ohlc-aggregator");
var moment = require("moment");
// Converting 1m candles to 5min candles:
let result = ohlc_aggregate(
[
{
time: moment("10/15/2017 8:59", "M/D/YYYY H:mm").valueOf(), // timestamp in milliseconds
open: 1,
high: 5,
low: 1,
close: 2,
volume: 100
},
{
time: moment("10/15/2017 9:00", "M/D/YYYY H:mm").valueOf(), // timestamp in milliseconds
open: 1,
high: 5,
low: 1,
close: 2,
volume: 100
},
{
time: moment("10/15/2017 9:01", "M/D/YYYY H:mm").valueOf(), // timestamp in milliseconds
open: 3,
high: 10,
low: 0,
close: 6,
volume: 200
}
],
/*intervalRatio=*/ 5, // ration between original interval and the desired interval
/*intervalInSeconds=*/, 5 * 60 // Interval duration in seconds
/*arrayTimeCoefficient=*/ 1 // Set this to 1000 if the time values are in second
);
console.log("result: ", JSON.stringify(result, null, 1));
See test/test.js for more examples.
FAQs
Aggregates ohlcv values into coarse grain intervals
The npm package ohlc-aggregator receives a total of 9 weekly downloads. As such, ohlc-aggregator popularity was classified as not popular.
We found that ohlc-aggregator 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
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.