Package Exports
- @ldrick/trade-indicators
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@ldrick/trade-indicators) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
trade-indicators
Trade Indicators written in pure functional Typescript.
Results will be Either<Error, Big[] | BigObject> using:
🚀 fp-ts
🌟 big.js
- Average Directional Index (adx)
- Average True Range (atr)
- Double Exponential Moving Average (dema)
- Dynamic Moving Average (dma)
- Exponential Moving Average (ema)
- Moving Average Convergence / Divergence (macd)
- Simple Moving Average (sma)
- Smoothed Moving Average (smma)
- Triple Exponential Moving Average (tema)
- Weighted Moving Average (wma)
Install
npm install @ldrick/trade-indicators fp-ts
or yarn add @ldrick/trade-indicators fp-ts
Usage
In TypeScript:
import { Big } from 'big.js';
import { either as E } from 'fp-ts/lib';
import { pipe } from 'fp-ts/lib/function';
import { ema, unwrap } from '@ldrick/trade-indicators';
const prices = [3, 2.1, 3, 4, 5.3, 5, 4.8, 6, 7, 5];
const period = 3;
// possible usage to pipe the Result E.Either<Error, Big[]>
const expMovingAverage = pipe(
ema(prices, period),
E.getOrElse(() => <readonly Big[]>[]),
);
// or unwrap the Result to Promise<number[]>
unwrap(ema(prices, period)).then(
(result) => console.log(result),
(error) => console.log(error),
);