New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@debut/plugin-report

Package Overview
Dependencies
Maintainers
1
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@debut/plugin-report

Report generation for strategy backtesting in debut

latest
Source
npmnpm
Version
1.4.2
Version published
Maintainers
1
Created
Source

@debut/plugin-report

Debut Report, report plugin

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

NameTypeDescription
namestringname of curve group, not shown on the chart, serves for the creation and storage of service information about the indicator.
FiguresArray<{ 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.
levelsnumber[]array of numbers, to draw constant lines of levels on the chart
inChartbooleanway 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 nameDescription
addIndicatorsAllows you to pass the scheme for creation of indicators, it is called once at plugin initialization
disableProfitPlotWhen 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.
setXRangeSets 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.
disableOrdersDisplayDisables trade visualization when called
setManualOrderAllows you to draw on the chart any deal in the manual mode, using the passed price and time parameters.
addOpenTargetAllows you to create on the chart only the point of opening a deal in manual mode
resetOrdersClear 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;
                    },
                },
            ],
        },
    ];
};

Keywords

Debut

FAQs

Package last updated on 04 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts