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

@debut/plugin-report

v1.4.2

Published

Report generation for strategy backtesting in debut

Downloads

202

Readme

@debut/plugin-report

Debut plugin, for setting targets and stops in manual mode. Allows you to set or change the stop and take prices for open positions at any time, using their identifier. It also allows you to optionally make additions instead of closing unprofitable positions. By default, the plugin draws balance changes and the used margin (if the strategy has more than 1 trade at a time). It has some API to customize it.

Install

npm install @debut/plugin-report --save

Settings

Creation of indicators

During initialization, you can pass an array of data to the plugin to build a chart of indicators. To do this, create a method, for example getIndicators that returns the indicators plotting scheme IndicatorsSchema

import { ReportPluginAPI, IndicatorsSchema } from '@debut/plugin-report';
// ...

// In Debut context.
public getIndicators = (): IndicatorsSchema => {
    return [{
        // Indicator name
        name: 'cci',
        // array of lines
        lines: [{
            name: 'cci',
            getValue: () => {
                return this.cciValue;
            },
        }],
        // levels
        levels: [-100, 100],
    }];

Initialize plugin

In the create method in the meta file of the strategy, add to the tester environment for initialization

// ...
async create(transport: BaseTransport, cfg: MyStrategyNameOptions, env: WorkingEnv) {
    const bot = new MyStrategyName(transport, cfg);
    // ...
    // environment-specific plugins
    if (env === WorkingEnv.tester) {
        // Plugin registration
        bot.registerPlugins([reportPlugin()]);

        // installing the indicators
        bot.plugins.report.addIndicators(bot.getIndicators());
    }

    // ...
    return bot;
},

Web server for viewing statistics

The server is started with the command npm run serve to do this, add the appropriate command to the scripts section in the package.json file.

// ...
"scripts": {
    "serve": 'report-serve',
    // ...
}

Description of indicator circuit `Indicator

| Name | Type | Description | |-----------|------------|------------| name | string | name of curve group, not shown on the chart, serves for the creation and storage of service information about the indicator. Figures | Array<{ name: string; getValue: () => number; fill: boolean; type: FigureType; }> | array of lines, the name field - describes the line name on the chart, the getValue method - returns the current indicator value at this time, fill - allows to fill by FillType either to axis or to line below, FigureType supports line and bar. levels | number[] | array of numbers, to draw constant lines of levels on the chart inChart | boolean | way of placing the indicator. If true the indicator will be drawn on a candlestick chart, on top of the candlesticks. If false, the indicator is drawn separately from the price chart. For example, the SMA or Bollinger Bands indicators are drawn in inChart: true mode.

API description

All API is available through the call this.plugins.report.method_name, you can read more about how the API works in the documentation.

| Method name | Description | |------------------------|------------| addIndicators | Allows you to pass the scheme for creation of indicators, it is called once at plugin initialization disableProfitPlot | When called, disables profit drawing on the chart. It is mainly used for convenience, when there is not enough space on the chart to draw indicators or candlesticks. setXRange | Sets the range of values for the X-axis, allows you to cut off the beginning and end. It takes values from and to what time to cut off. disableOrdersDisplay | Disables trade visualization when called setManualOrder | Allows you to draw on the chart any deal in the manual mode, using the passed price and time parameters. addOpenTarget | Allows you to create on the chart only the point of opening a deal in manual mode resetOrders | Clear trades on the chart

Example MACD indicator

public getIndicators = (): IndicatorsSchema => {
    return [
        {
            name: `MACD Indicator',
            shapes: [
                {
                    name: 'signal',
                    fill: FillType.tozeroy,
                    getValue: () => {
                        return this.macdValue.signal;
                    },
                    color: 'red',
                    fillcolor: 'rgba(255, 0, 0, 0.2)',
                },
                {
                    name: 'macd',
                    fill: FillType.tozeroy,
                    getValue: () => {
                        return this.macdValue.macd;
                    },
                },
                {
                    name: 'histogram',
                    type: FigureType.bar,
                    getValue: () => {
                        return this.macdValue.histogram;
                    },
                },
            ],
        },
    ];
};