Report generation for strategy backtesting in debut
npm install @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.
```
npm install @debut/plugin-report --save
that returns the indicators plotting scheme IndicatorsSchema`javascript
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],
}];
`$3
In the
create method in the meta file of the strategy, add to the tester environment for initialization`javascript
// ...
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;
},
`$3
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.`json
// ...
"scripts": {
"serve": 'report-serve',
// ...
}
`$3
| 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.$3
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
$3
`javascript
public getIndicators = (): IndicatorsSchema => {
return [
{
name: MACD Indicator',