5.3.2 • Published 6 years ago
data-source v5.3.2
data-source
data-source for stock data
Install
$ npm install data-source --save
Usage
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 price
open,
// `Number` the highest price
high,
// `Number` the lowest price
low,
// `Number` the close price
close,
// `Number` the volume of transactions
volume,
// `Date` time
time
} = await span.get(new Date(2017, 4, 1))
console.log(`sz300131 opened with ${open} at 2017-05-01`)
span.get(time)
Gets a single datum
- time
Date|Array<Date>
Returns Candlestick|null
span.get(...times)
Returns Array<Candlestick>
span.between(from, to)
- from
Date
the closed left of the region - to
Date
the closed right of the region
Returns Array<Candlestick>
data between a period.
span.latest(limit)
- limit
Number
limit the number of results.
Returns Array<Candlestick>
span.sync(from, to)
Sync data from from
to to
, and update db, and update last-updated record.
License
MIT
5.3.2
6 years ago
5.3.1
6 years ago
5.3.0
6 years ago
5.2.0
6 years ago
5.1.3
6 years ago
5.1.2
6 years ago
5.1.1
6 years ago
5.1.0
6 years ago
5.0.13
6 years ago
5.0.12
6 years ago
5.0.11
6 years ago
5.0.10
6 years ago
5.0.9
6 years ago
5.0.8
6 years ago
5.0.7
6 years ago
5.0.6
6 years ago
5.0.5
6 years ago
5.0.4
6 years ago
5.0.3
6 years ago
5.0.2
6 years ago
5.0.1
6 years ago
5.0.0
6 years ago
4.0.8
6 years ago
4.0.7
6 years ago
4.0.2
6 years ago
4.0.0
7 years ago
3.3.4
7 years ago
3.3.3
7 years ago
3.3.2
7 years ago
3.3.1
7 years ago
3.3.0
7 years ago
3.1.0
7 years ago
3.0.0
7 years ago
2.0.0
7 years ago
1.2.0
7 years ago
1.1.1
7 years ago
1.1.0
7 years ago
1.0.1
7 years ago
1.0.0
7 years ago
0.1.0
8 years ago
0.0.5
8 years ago
0.0.0
8 years ago
0.0.1
11 years ago