stock-market-gen¶
Generate realistic fake stock market data plus SVG charts and standalone HTML pages. Pure JS, zero dependencies, works in Node and the browser.
A modern, more capable replacement for the old fake-stock-market-generator package.
Why this package¶
- Zero dependencies. One small package, no bundled bloat.
- Works everywhere. Node 14+, modern browsers, ESM and CommonJS.
- Reproducible. Pass a
seedand you get the same output every time, on every machine. - Realistic. Geometric Brownian Motion price model — prices stay positive, volatility scales with price level.
- Bring your own data. Supply close prices or full OHLC bars, the generator fills in whatever's missing.
- Charts included. Line, area, OHLC bar, candlestick, multi-line comparison — all return self-contained SVG strings.
- Standalone HTML. Drop a market into
renderHtmlPage()and get a self-contained dashboard with clickable cards.
At a glance¶
```js import { generateStock, renderLineChart } from 'stock-market-gen'; import { writeFileSync } from 'node:fs';
const stock = generateStock({ bars: 250, interval: '1d', seed: 'demo' }); writeFileSync('chart.svg', renderLineChart(stock)); ```
That's it. One stock, one year of daily bars, one SVG chart.
Where to next¶
-
Getting started Install the package and render your first chart.
-
Guides Step-by-step walkthroughs for every feature.
-
API reference Every function, every option.
-
Recipes Copy-paste examples for common tasks.
Install¶
bash
npm install stock-market-gen
bash
pnpm add stock-market-gen
bash
yarn add stock-market-gen
Compatibility¶
| Runtime | Status |
|---|---|
| Node 14+ | ESM and CJS |
| Modern browsers | ESM bundlers (Vite, esbuild, Rollup, webpack) |
| Deno | ESM via npm specifier |
| Bun | ESM and CJS |
License¶
MIT.