Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cm45t3r/candlestick
Candlestick patterns detection.
https://github.com/cm45t3r/candlestick
candlestick candlestick-data candlestick-pattern candlestick-pattern-detection candlestick-patterns candlestick-patterns-detection candlesticks candlesticks-pattern javascript javascript-library ohlc technical-analysis technical-analysis-indicators technical-analysis-library technical-analysis-methods technical-indicators
Last synced: about 2 months ago
JSON representation
Candlestick patterns detection.
- Host: GitHub
- URL: https://github.com/cm45t3r/candlestick
- Owner: cm45t3r
- License: mit
- Created: 2016-10-22T03:59:45.000Z (about 8 years ago)
- Default Branch: main
- Last Pushed: 2024-04-11T03:12:21.000Z (9 months ago)
- Last Synced: 2024-10-30T15:54:39.306Z (about 2 months ago)
- Topics: candlestick, candlestick-data, candlestick-pattern, candlestick-pattern-detection, candlestick-patterns, candlestick-patterns-detection, candlesticks, candlesticks-pattern, javascript, javascript-library, ohlc, technical-analysis, technical-analysis-indicators, technical-analysis-library, technical-analysis-methods, technical-indicators
- Language: JavaScript
- Homepage:
- Size: 122 KB
- Stars: 336
- Watchers: 17
- Forks: 72
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# Candlestick
![Node.js CI workflow](https://github.com/cm45t3r/candlestick/actions/workflows/node.js.yml/badge.svg)
[![npm version](https://badge.fury.io/js/candlestick.svg)](https://badge.fury.io/js/candlestick)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:
``` bash
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:
``` js
{
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:``` js
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:``` js
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
``` bash
npm test
```## Contributing
You are welcome to contribute to this library creating new [issues](https://github.com/cm45t3r/candlestick/issues) or [pull requests](https://github.com/cm45t3r/candlestick/pulls).
## License
This project is licensed under the MIT license. See the [LICENSE](https://github.com/cm45t3r/candlestick/blob/master/LICENSE) file for more info.