0.1.0 • Published 9 years ago
market-faker v0.1.0

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-fakerimport 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
subscribehandlers - The initial market properties are available as
market.snapshot buyprice andsellprice are a small but random distance apart. They start either side of theopeningchangeis the difference from thebuyand theopeningchangePercentageshows the change as a percentage of theopeninghighis the maximum abuyprice has beenlowis the lowest thesellprice has been- Historical data for any existing property of the market can be specified with a
historyobject. 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]
})0.1.0
9 years ago