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

candlestick

v0.0.7

Published

JavaScript library for candlestick patterns detection.

Downloads

99

Readme

Candlestick

Node.js CI workflow npm version

A JavaScript library for candlestick pattern detection. Easy to use and solves the need for node-gyp builds.

Installation

To use the most recent release in your project:

npm install --save candlestick

Available functions

Boolean pattern detection

  • isHammer(candlestick)
  • isInvertedHammer(candlestick)
  • isBullishHammer(candlestick)
  • isBearishHammer(candlestick)
  • isBullishInvertedHammer(candlestick)
  • isBearishInvertedHammer(candlestick)
  • isHangingMan(previous, current)
  • isShootingStar(previous, current)
  • isBullishEngulfing(previous, current)
  • isBearishEngulfing(previous, current)
  • isBullishHarami(previous, current)
  • isBearishHarami(previous, current)
  • isBullishKicker(previous, current)
  • isBearishKicker(previous, current)

Search patterns in arrays

  • hammer(dataArray)
  • invertedHammer(dataArray)
  • bullishHammer(dataArray)
  • bearishHammer(dataArray)
  • bullishInvertedHammer(dataArray)
  • bearishInvertedHammer(dataArray)
  • hangingMan(dataArray)
  • shootingStar(dataArray)
  • bullishEngulfing(dataArray)
  • bearishEngulfing(dataArray)
  • bullishHarami(dataArray)
  • bearishHarami(dataArray)
  • bullishKicker(dataArray)
  • bearishKicker(dataArray)

candlestick, previous and current are OHLC (Open, High, Low, Close) objects:

{
  open: number,   // security's opening price
  high: number,   // security's highest price
  low: number,    // security's lowest price
  close: number   // security's closing price
}

dataArray is an array of OHLC objects like previous or current.

Note: OHLC objects can have more fields and does not affect the final result.

=== :warning: BREAKING CHANGE WARNING ON VERSIONS >= 0.0.6 ===

Before: search pattern functions returned the last OHLC object conforming the pattern. After: they return the first index of the candle conforming the pattern. It helps locating candlestick in dataArray more easily. So before upgrading to version 0.0.6, please be aware of changing your code.

Examples

Boolean detection

Use two OHLCs to assess the pattern:

const { isBullishKicker, isBearishKicker } = require('candlestick');

// Market data: previous and current ticks
const prev = {
  security: 'ORCL',
  date: '2016-09-15',
  open: 40.18,
  high: 41.03,
  low: 40.09,
  close: 40.86
};

const curr = {
  security: 'ORCL',
  date: '2016-09-16',
  open: 39.61,
  high: 39.35,
  low: 38.71,
  close: 38.92
};

console.log(isBullishKicker(prev, curr)); // false
console.log(isBearishKicker(prev, curr)); // true

Finding patterns in series

Find the points in a dataset where the pattern occurs:

const { shootingStar } = require('candlestick');

// Market data: array of ticks
const data = [
  {
    security: 'GE',
    date: '2016-02-01',
    open: 29.01,
    high: 29.03,
    low: 28.56,
    close: 28.64
  },
  { ... },
  { ... },
  ...
  { ... }
];

console.log(shootingStar(data));
// result: [{ security: 'GE', date: '2016-02-10', ... }, { security: 'GE', date: '2016-07-11', ... }]

Running tests

npm test

Contributing

You are welcome to contribute to this library creating new issues or pull requests.

License

This project is licensed under the MIT license. See the LICENSE file for more info.