GithubHelp home page GithubHelp logo

chenycl / trading-signals Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bennycode/trading-signals

0.0 1.0 0.0 1.66 MB

Technical indicators to run technical analysis with JavaScript / TypeScript. 📈

Home Page: https://www.npmjs.com/package/trading-signals

License: MIT License

TypeScript 100.00%

trading-signals's Introduction

Trading Signals

Language Details Code Coverage License Package Version Dependency Updates

Technical indicators and overlays to run technical analysis with JavaScript / TypeScript.

Motivation

Provide a TypeScript implementation for common technical indicators with arbitrary-precision decimal arithmetic.

Features

  • Accurate. Don't rely on type number and its precision limits. Use Big.
  • Typed. Source code is 100% TypeScript. No need to install external typings.
  • Tested. Code coverage is 100%. No surprises when using it.

Supported Indicators

  1. Acceleration Bands (ABANDS)
  2. Average Directional Index (ADX)
  3. Average True Range (ATR)
  4. Bollinger Bands (BBANDS)
  5. Center of Gravity (CG)
  6. Double Exponential Moving Average (DEMA)
  7. Double Moving Average (DMA)
  8. Exponential Moving Average (EMA)
  9. Moving Average Convergence Divergence (MACD)
  10. Rate-of-Change (ROC)
  11. Relative Strength Index (RSI)
  12. Simple Moving Average (SMA)
  13. Smoothed Moving Average (SMMA)

Usage

import {SMA} from 'trading-signals';

const sma = new SMA(3);

// You can add numbers:
sma.update(40);
sma.update(30);
sma.update(20);

// You can add strings:
sma.update('10');

// You can add arbitrary-precision decimals:
import Big from 'big.js';
sma.update(new Big(30));

// You can get the result in various formats:
console.log(sma.getResult().valueOf()); // "20"
console.log(sma.getResult().toFixed(2)); // "20.00"

Good to know

This library draws attention to miscalculations by throwing errors instead of returning default values. If you call getResult(), before an indicator has received the required amount of input values, a NotEnoughDataError will be thrown.

Example:

import {SMA} from 'trading-signals';

// Our interval is 3, so we need 3 input values
const sma = new SMA(3);

// We supply 2 input values
sma.update(10);
sma.update(40);

try {
  // We will get an error, because the minimum amount of inputs is 3
  sma.getResult();
} catch (error) {
  console.log(error.constructor.name); // "NotEnoughDataError"
}

// We will supply the 3rd input value
sma.update(70);

// Now, we will receive a proper result
console.log(sma.getResult().valueOf()); // "40"

Alternatives

Maintainers

Benny Neugebauer on Stack Exchange

Contributing

Contributions, issues and feature requests are welcome!

Feel free to check the issues page.

License

This project is MIT licensed.

⭐️ Show your support ⭐️

Please leave a star if you find this project useful.

If you like this project, you might also like these related projects:

trading-signals's People

Contributors

dependabot-preview[bot] avatar bennycode avatar dependabot[bot] avatar nullobject avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.