market-faker
v0.1.0
Published
Simulates financial markets
Downloads
4
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
yarn add market-faker
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 andsell
price are a small but random distance apart. They start either side of theopening
change
is the difference from thebuy
and theopening
changePercentage
shows the change as a percentage of theopening
high
is the maximum abuy
price has beenlow
is the lowest thesell
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:
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]
})