E2E: backtesting

This commit is contained in:
Matthias 2022-04-12 20:52:48 +02:00
parent 55d8e75b03
commit f80ac13ab0
7 changed files with 140 additions and 1 deletions

View File

@ -0,0 +1,9 @@
{
"status": "running",
"running": true,
"status_msg": "Backtest started",
"step": "startup",
"progress": 0.0,
"trade_count": null,
"backtest_result": null
}

View File

@ -0,0 +1,53 @@
{
"version": "2022.2.2",
"strategy_version": null,
"api_version": 2.14,
"dry_run": true,
"trading_mode": "spot",
"short_allowed": false,
"stake_currency": "USDT",
"stake_amount": "unlimited",
"available_capital": null,
"stake_currency_decimals": 3,
"max_open_trades": 3,
"minimal_roi": {},
"stoploss": null,
"trailing_stop": null,
"trailing_stop_positive": null,
"trailing_stop_positive_offset": null,
"trailing_only_offset_is_reached": null,
"unfilledtimeout": {
"entry": 60,
"exit": 60,
"unit": "seconds",
"exit_timeout_count": 1
},
"order_types": null,
"use_custom_stoploss": null,
"timeframe": null,
"timeframe_ms": 0,
"timeframe_min": 0,
"exchange": "binance",
"strategy": null,
"force_entry_enable": true,
"exit_pricing": {
"price_side": "other",
"use_order_book": true,
"order_book_top": 1
},
"entry_pricing": {
"price_side": "other",
"use_order_book": true,
"price_last_balance": 0.0,
"order_book_top": 1,
"check_depth_of_market": {
"enabled": false,
"bids_to_ask_delta": 1
}
},
"bot_name": "TestBot123",
"state": "",
"runmode": "webserver",
"position_adjustment_enable": false,
"max_entry_position_adjustment": -1
}

View File

@ -0,0 +1,7 @@
{
"strategies": [
"AdvancedTest",
"AverageStrategy",
"SampleStrategy"
]
}

View File

@ -0,0 +1,3 @@
{
"status": "pong"
}

View File

@ -0,0 +1,61 @@
function setLoginInfo() {
localStorage.setItem(
'ftAuthLoginInfo',
JSON.stringify({
'ftbot.0': {
botName: 'TestBot',
apiUrl: 'http://localhost:3000',
accessToken: 'access_token_tesst',
refreshToken: 'refresh_test',
autoRefresh: true,
},
}),
);
localStorage.setItem('ftSelectedBot', 'ftbot.0');
}
function defaultMocks() {
cy.intercept('**/api/v1/**', {
statusCode: 200,
// eslint-disable-next-line @typescript-eslint/camelcase
headers: { 'access-control-allow-origin': '*' },
}).as('RandomAPICall');
cy.intercept('GET', '**/api/v1/ping', { fixture: 'ping.json' }).as('Ping');
cy.intercept('GET', '**/api/v1/show_config', {
fixture: 'backtest/show_config_backtest.json',
}).as('ShowConf');
cy.intercept('GET', '**/api/v1/strategies', { fixture: 'backtest/strategies.json' }).as(
'Strategies',
);
}
describe('Backtesting', () => {
it.only('Is not logged in', () => {
///
defaultMocks();
setLoginInfo();
cy.visit('/backtest');
cy.wait('@Ping');
cy.wait('@ShowConf');
// cy.wait('@Strategies');
cy.get('a').should('contain', 'Backtest');
cy.contains('Run backtest');
cy.contains('Strategy');
const strategySelect = cy.get('select[id=strategy-select]');
strategySelect.should('exist');
strategySelect.select('SampleStrategy');
cy.get('option[value=SampleStrategy]').should('exist');
cy.intercept('POST', '**/api/v1/backtest', { fixture: 'backtest/backtest_post_start.json' }).as(
'BacktestStart',
);
// cy.intercept('GET', '**/api/v1/backtest', { fixture: 'backtest/backtest_get_end.json' }).as(
// 'BacktestPoll',
// );
cy.get('button[id=start-backtest]').click();
cy.wait('@BacktestStart');
// cy.wait('@BacktestPoll');
});
});

View File

@ -1,7 +1,12 @@
<template>
<div>
<div class="w-100 d-flex">
<b-form-select v-model="locStrategy" :options="strategyList" @change="strategyChanged">
<b-form-select
id="strategy-select"
v-model="locStrategy"
:options="strategyList"
@change="strategyChanged"
>
</b-form-select>
<div class="ml-2">
<b-button @click="getStrategyList">&#x21bb;</b-button>

View File

@ -193,6 +193,7 @@
class="d-flex flex-wrap flex-md-nowrap justify-content-between justify-content-md-center"
>
<b-button
id="start-backtest"
variant="primary"
:disabled="backtestRunning || !canRunBacktest"
class="mx-1"