npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ohlc

v2.0.4

Published

[![npm version](https://badge.fury.io/js/ohlc.svg)](https://badge.fury.io/js/ohlc) ![npm](https://img.shields.io/npm/dw/ohlc.svg) [![](https://data.jsdelivr.com/v1/package/npm/ohlc/badge)](https://www.jsdelivr.com/package/npm/ohlc) [![Build Status](https:

Downloads

1,115

Readme

ohlc

npm version npm Build Status

Major update for version 2

install

node.js

npm install ohlc
var ohlc = require('ohlc')

Browser

<script src="dist/ohlc.js"></script>

CDN

<script src="https://cdn.jsdelivr.net/npm/ohlc"></script>

<script src="https://cdn.jsdelivr.net/gh/mick-whats/[email protected]/dist/ohlc.js"></script>

sumple data

arrayData = [
  ["2017-01-04",348,350,346,350,68700],
  ["2017-01-05",350,353,349,352,59200],
  ["2017-01-06",350,358,350,356,168900]
]

toDaily()

output to daily data

ohlc(arrayData).toDaily();
/// result 
[
  ...
  {
    "Date": '2017-04-03',
    Open: 352,
    High: 352,
    Low: 348,
    Close: 348,
    Volume: 108200
  }
  ...
]

toWeekly()

output to weekly data

ohlc(arrayData).toWeekly();
/// result 
[
  ...
  {
    "Date": '2017-04-02',
    Open: 352,
    High: 352,
    Low: 338,
    Close: 339,
    Volume: 379400
  }
  ...
]

toMonthly

output to monthly data

ohlc(arrayData).toMonthly();
/// result 
[
  ...
  {
    "Date": '2017-04-01',
    Open: 352,
    High: 370,
    Low: 330,
    Close: 357,
    Volume: 1514900
  }
  ...
]

value(period)

output data


// daily
ohlc(arrayData).value()
// equal toDaily
ohlc(arrayData).toDaily()

// weekly
ohlc(arrayData).value('weekly')
// equal toWeekly
ohlc(arrayData).toWeekly()

// monthly
ohlc(arrayData).value('monthly')
// equal toMonthly
ohlc(arrayData).toMonthly()

toChartData(period)

It complies with high charts

Candlestick | Highcharts
https://www.highcharts.com/samples/data/aapl-ohlc.json

var chartData = ohlc(arrayData).sma(5, 25).toChartData();

Object.keys(chartData)
//=> ['candle', 'volume', 'sma5', 'sma25']

chartData.candle[90]
//=> [1494979200000, 370, 372, 365, 369]
chartData.volume[90]
//=> [1494979200000, 32300]
chartData.sma5[90]
//=> [1494979200000, 372]
chartData.sma25[90]
//=> [1494979200000, 359]
moment.utc(1494979200000).format('YYYY-MM-DD')
//=> '2017-05-17'

start() and end()

Set the output period

prices = ohlc(arrayData).toDaily();
/// prices.length is 101

prices = ohlc(arrayData).start('2017-04-03').toDaily();
/// prices.length is 40

prices = ohlc(arrayData).end('2017-04-10').toDaily();
/// prices.length is 67

prices = ohlc(arrayData).start('2017-04-03').end('2017-04-10').toDaily();
/// prices.length is 6

sma

This will add sma(simple MA)

ohlc(arrayData).sma(5, 25, 75).toDaily();
/// result
[
  ...
  {
    Date: '2017-05-31',
    Open: 372,
    High: 372,
    Low: 362,
    Close: 364,
    Volume: 46500,
    sma5: 373,
    sma25: 373,
    sma75: 360
  }
  ...
]