data-source

5.3.2 • Public • Published

Build Status

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

Readme

Keywords

Package Sidebar

Install

npm i data-source

Weekly Downloads

72

Version

5.3.2

License

MIT

Last publish

Collaborators

  • kael