npm install data-source
data-source for stock data
``sh`
$ npm install data-source --save
`js
import DataSource from 'data-source'
const dataSource = new DataSource({
connection: {
host: '127.0.0.1',
user: 'root',
password: '',
database: ''
},
code: 'sz300131',
loader: Loader,
// Whether the given time of the span is trading
// - span: day, will not check hours and minutes
// -
isTrading: ({time, span}) => true
})
const span = dataSource.span('MONTH')
const {
// Number open priceNumber
open,
// the highest priceNumber
high,
// the lowest priceNumber
low,
// the close priceNumber
close,
// the volume of transactionsDate
volume,
// time
time
} = await span.get(new Date(2017, 4, 1))
console.log(sz300131 opened with ${open} at 2017-05-01)`
Gets a single datum
- time Date|Array
Returns Candlestick|null
Returns Array
- from Date the closed left of the regionDate
- to the closed right of the region
Returns Array data between a period.
- limit Number limit the number of results.
Returns Array
Sync data from from to to`, and update db, and update last-updated record.
MIT