Gathering detailed insights and metrics for @d3fc/d3fc-random-data
Gathering detailed insights and metrics for @d3fc/d3fc-random-data
Gathering detailed insights and metrics for @d3fc/d3fc-random-data
Gathering detailed insights and metrics for @d3fc/d3fc-random-data
A collection of components that make it easy to build interactive charts with D3
npm install @d3fc/d3fc-random-data
Typescript
Module System
Node Version
NPM Version
84.5
Supply Chain
100
Quality
79.5
Maintenance
100
Vulnerability
100
License
@d3fc/d3fc-chart@5.1.9
Updated on Jul 30, 2024
@d3fc/d3fc-webgl@3.2.1
Updated on Jul 30, 2024
@d3fc/d3fc-series@6.1.3
Updated on Jul 30, 2024
@d3fc/d3fc-annotation@3.0.16
Updated on Jul 30, 2024
d3fc@15.2.13
Updated on Jul 30, 2024
d3fc@15.2.12
Updated on Jul 02, 2024
HTML (78.71%)
JavaScript (13.65%)
TypeScript (5.92%)
Shell (1.72%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
1,330 Stars
1,351 Commits
197 Forks
41 Watchers
18 Branches
55 Contributors
Updated on Jul 13, 2025
Latest Version
4.0.2
Package Id
@d3fc/d3fc-random-data@4.0.2
Unpacked Size
31.89 kB
Size
8.00 kB
File Count
13
NPM Version
lerna/8.1.2/node@v21.7.3+x64 (linux)
Node Version
21.7.3
Published on
Jun 13, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
Components for generating random data series based on stochastic processes.
1npm install @d3fc/d3fc-random-data
The random financial data generator component generates open-high-low-close-volume financial data. Prices are calculated using the geometric Brownian motion generator.
1 2import { randomFinancial, randomSkipWeekends } from 'd3fc-random-data'; 3 4const generator = randomFinancial() 5 .startDate(new Date(2016, 0, 1)) 6 .startPrice(100) 7 .filter(randomSkipWeekends); 8 9generator(4); 10 11// [ 12// { 13// date: 2016-01-01T00:00:00.000Z, 14// open: 100, 15// high: 100.37497903455065, 16// low: 99.9344064016257, 17// close: 100.13532170178823, 18// volume: 974 19// }, 20// { 21// date: 2016-01-04T00:00:00.000Z, 22// open: 100.2078374019404, 23// high: 100.55251268471399, 24// low: 99.7272105851512, 25// close: 99.7272105851512, 26// volume: 992 27// }, 28// { 29// date: 2016-01-05T00:00:00.000Z, 30// open: 99.7272105851512, 31// high: 101.06403178230532, 32// low: 99.7272105851512, 33// close: 101.00200313600685, 34// volume: 835 35// }, 36// { 37// date: 2016-01-06T00:00:00.000Z, 38// open: 101.00200313600685, 39// high: 101.41129520567128, 40// low: 100.50311227829566, 41// close: 100.5536971451326, 42// volume: 1021 43// } 44// ] 45
# fc.randomFinancial()
Constructs a new financial data generator.
# randomFinancial(points)
Run the generator. Returns an array with points number of objects with date
, open
, high
, low
, close
and volume
properties.
# randomFinancial.startDate([value])
If value is specified, sets the start date to the specified Date
object and returns this generator instance.
If value is not specified, returns the current start date, which defaults to the value of new Date()
when the generator was constructed.
# randomFinancial.startPrice([value])
If value is specified, sets the start price to the specified number and returns this generator instance.
If value is not specified, returns the current start price, which defaults to 100
.
# randomFinancial.interval([value])
If value is specified, sets the time increment to the specified d3 time interval and returns this generator instance.
If value is not specified, returns the current interval, which defaults to d3_time.timeDay
.
# randomFinancial.intervalStep([value])
If value is specified, sets the number of intervals that returned points should have dates offset by to the specified integer number and returns this generator instance.
If value is not specified, returns the current number of intervals, which defaults to 1
.
Internally, this value is supplied to the step argument of an interval's offset function.
# randomFinancial.steps([value])
Get/Set the number of steps used by the geometric Brownian motion simulation per intervalStep number of intervals. A higher number gives a slower, but higher resolution simulation.
# randomFinancial.mu([value])
Get/Set the drift used by the geometric Brownian motion simulation.
# randomFinancial.sigma([value])
Get/Set the volatility used by the geometric Brownian motion simulation.
# randomFinancial.random([value])
Get/Set the random function used by the geometric Brownian motion simulation.
# randomFinancial.unitInterval([value])
If value is specified, sets the time interval used for units of mu and sigma to the specified d3 time interval and returns this generator instance.
If value is not specified, returns the current interval, which defaults to d3_time.timeYear
.
# randomFinancial.unitIntervalStep([value])
If value is specified, sets the integer number of intervals used for units of mu and sigma to the specified number and returns this generator instance.
If value is not specified, returns the current interval, which defaults to 1
.
For example, to have trading year units of mu and sigma rather than calendar year, set unitIntervalStep to 252
and unitInterval to d3_time.timeDay
.
# randomFinancial.volume([value])
If value is specified, sets the function used return a point's volume to the specified function and returns this generator instance.
Can be specified as either a function mapping an output object to a number, or a number.
If value is not specified, returns the current volume, which defaults to a function sampling integers from a normal distribution centred around 1000
.
# randomFinancial.filter([value])
If value is specified, sets the filter function to the specified function and returns this generator instance.
Only output objects d
for which filter(d)
returns true
will be included in the output array.
If value is not specified, returns the current filter function, which defaults to (d) => true
.
To skip weekends, supply the pre-defined filter fc_random_data.skipWeekends
.
Use the streaming interface to have successive calls to generate data keep track of the latest date and price.
1 2import { randomFinancial } from 'd3fc-random-data'; 3 4const generator = randomFinancial() 5 .startDate(new Date(2016, 0, 1)) 6 .startPrice(100); 7 8const stream = generator.stream(); 9let data = []; 10 11data.push(stream.next()); 12// data.length -> 1 13 14data = data.concat(stream.take(2)); 15// data.length -> 3 16 17data = data.concat(stream.until(d => d.date > new Date(2016, 0, 10))); 18// data.length -> 10 19
# randomFinancial.stream()
Constructs a new stream from an existing financial data generator instance.
# stream.next()
Returns a single output object with date incremented from the latest returned output object's date according to the generator instance's interval and intervalStep properties, or with startDate if this is the first call.
# stream.take(number)
Returns an array of length number of output objects, each object with date incremented according to the generator instance's interval and intervalStep properties, starting with the latest returned output objects's incremented date, or with startDate if this is the first call.
# stream.until(comparison)
Returns the array of objects constructed by repeatedly generating a single output object with date incremented according to the generator instance's interval and intervalStep properties until a generated object satisfies the condition of the supplied comparison function, appending to the output array only if the condition is not satisfied.
The geometric Brownian motion component creates a series of values based on the Geometric Brownian Motion stochastic process.
1 2import { randomGeometricBrownianMotion } from 'd3fc-random-data'; 3 4const generator = randomGeometricBrownianMotion() 5 .steps(10); 6 7generator(10); 8 9// [ 10// 10, 11// 10.272847363463436, 12// 10.423881104466574, 13// 10.629316182766384, 14// 10.7209321393133, 15// 10.773722182206432, 16// 10.229636144307582, 17// 10.225282323984114, 18// 10.488138829847468, 19// 10.428118194568341, 20// 10.848822656937935 21// ] 22
# fc.randomGeometricBrownianMotion()
Constructs a new geometric Brownian motion generator.
# randomGeometricBrownianMotion(start)
Returns an array of price values following a geometric Brownian motion with the set drift and volatility, given a starting price of start. The first array value is the supplied start price, followed by steps number of values corresponding to the simulated price value at the end of each step.
# randomGeometricBrownianMotion.mu([value])
If value is specified, sets the percentage drift per period to the specified number and returns this generator instance.
If value is not specified, returns the current drift, which defaults to 0.1
.
# randomGeometricBrownianMotion.sigma([value])
If value is specified, sets the percentage volatility per period to the specified number and returns this generator instance.
If value is not specified, returns the current volatility, which defaults to 0.1
.
# randomGeometricBrownianMotion.period([value])
If value is specified, sets the interval length to the specified number of periods and returns this generator instance.
If value is not specified, returns the current interval length, which defaults to 1
.
randomGeometricBrownianMotion.steps([value])
If value is specified, sets the number of discrete steps to divide the interval into to the specified number and returns this generator instance.
If value is not specified, returns the current number of steps, which defaults to 20
.
randomGeometricBrownianMotion.random([value])
If value is specified, sets the function used for generating random numbers with a normal (Gaussian) distribution to the specified function and returns this generator instance.
If value is not specified, returns the current random function, which defaults to d3_random.randomNormal
.
No vulnerabilities found.
Reason
all changesets reviewed
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
no binaries found in the repo
Reason
dependency not pinned by hash detected -- score normalized to 5
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
16 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More