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

@showr/core

v1.5.0

Published

Core library for Showr

Downloads

9

Readme

@showr/core

Travis (.org) Coverage Status npm (scoped) GitHub issues npm bundle size

@showr/core is a library built with Typescript that allows you to define efficient trading strategy to gain profits during a live market. You can use and combine hundreds of technical indicators to define your strategy or you can create your own technical indicator.

Its powerful API also allows you to backtest your strategy over a historical data before putting it in action. The strongly typed Classes and API allows you to focus more on your trading strategy and worry less about the technical setup and boilerplate.

Features

  • [x] Use hundreds of in-built technical indicators or create your own.
  • [x] Define trading strategies using combination of indicators, rules and configuration.
  • [x] Backtest your trading strategy over any historical dataset.
  • [ ] Test your strategy over a live market. (In progress)

Installation

npm i --save @showr/core

or

yarn add @showr/core

Usage

You can import available classes and helpers from the main library.

import { Dataset, Indicator } from '@showr/core';
// or
const { Dataset, Indicator } = require('@showr/core');

See complete API documentation for all the available classes and methods.

API

Dataset

Dataset can be created out of any data which should in a form of an array. Dataset allows you to apply indicators over each data point and you can backtest your trading strategy over any Dataset.

import { Dataset } from '@showr/core';

const ds = new Dataset([10, 12.5, 11]);

console.log(ds.value); // [{ close: 10 }, { close: 12.5 }, { close: 11 }]

You can provide an array containing any kind of objects or numbers and that will be converted into a Dataset. Learn more about Dataset in API documentation.

Indicator

The outstanding advantage of this library is that you can create your own technical indicator and then use it for defining trading strategies.

All you need is to define a calculate function for the indicator you are creating and then you can apply it over your Dataset.

For example, you can create an indicator, let's say goldenR, that multiplies the quote value with golden ratio.

import { Dataset, Indicator } from '@showr/core';

const goldenR = new Indicator('goldenR', (ds: Dataset) => {
    const lastQuote = ds.at(-1);
    return lastQuote.value * 1.61;
});

Now create a dataset and apply the above indicator to it.

// ...
const ds = new Dataset([10, 20, 30]);
ds.apply(goldenR);

console.log(ds.quotes); // [{ close: 10, indicators: { goldenR: 16.1 }}, ... ]

// Get indicator value for the first quote
console.log(ds.at(0).getIndicator('goldenR')); // 16.1

Learn more about creating Indicators with parameters in API documentation.

Many well known indicators are provided in-built with a stand-alone library @showr/indicators and you can directly import them inside your project.

For example,

import { Dataset } from '@showr/core';
import { SMA } from '@showr/indicators';

const ds = new Dataset([10, 20, 30]);

const sma2 = new SMA('sma2', { period: 2 });
ds.apply(sma2);

// Get sma2 value for the last quote
console.log(ds.at(-1).getIndicator('sma2')); // 25