https://github.com/joeegan/market-faker
Simulates financial market data
https://github.com/joeegan/market-faker
fake-data financial-data javascript streaming-api
Last synced: 4 months ago
JSON representation
Simulates financial market data
- Host: GitHub
- URL: https://github.com/joeegan/market-faker
- Owner: joeegan
- Created: 2016-02-09T22:27:39.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2022-12-07T01:05:09.000Z (over 3 years ago)
- Last Synced: 2025-09-28T01:16:23.187Z (8 months ago)
- Topics: fake-data, financial-data, javascript, streaming-api
- Language: JavaScript
- Homepage:
- Size: 798 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 23
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

market-faker provides simulated financial market data.
## Motivation
Legitimate external sources for financial instruments can incur problems related to API key expiry, restrictive hours of availability, data limits, service downtime, and fees.
## Usage
```bash
yarn add market-faker
```
```javascript
import market from 'market-faker'
const foo = market({
name: 'Foobar PLC',
opening: 1271.1,
})
console.log(foo.snapshot.sell)
// -> 1271.2
foo.subscribe(market => {
console.log(market.sell)
// -> 1270.6
})
```
# Characteristics of a Market
* Prices tick at random intervals
* Only the properties that have changed come back in the `subscribe` handlers
* The initial market properties are available as `market.snapshot`
* `buy` price and `sell` price are a small but random distance apart. They start either side of the `opening`
* `change` is the difference from the `buy` and the `opening`
* `changePercentage` shows the change as a percentage of the `opening`
* `high` is the maximum a `buy` price has been
* `low` is the lowest the `sell` price has been
* Historical data for any existing property of the market can be specified with a `history` object. e.g. The following would include the last 3 buy prices in the subscribable data:
```javascript
const foo = market({
name: 'Foobar PLC',
opening: 1271.1,
history: {
buy: 3,
},
})
foo.subscribe(market => {
console.log(market.history.buy)
// -> [1270.6, 1271.1, 1269.3]
})
```