mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-10 10:21:55 +00:00
E2E: backtesting
This commit is contained in:
parent
55d8e75b03
commit
f80ac13ab0
9
cypress/fixtures/backtest/backtest_post_start.json
Normal file
9
cypress/fixtures/backtest/backtest_post_start.json
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"status": "running",
|
||||
"running": true,
|
||||
"status_msg": "Backtest started",
|
||||
"step": "startup",
|
||||
"progress": 0.0,
|
||||
"trade_count": null,
|
||||
"backtest_result": null
|
||||
}
|
53
cypress/fixtures/backtest/show_config_backtest.json
Normal file
53
cypress/fixtures/backtest/show_config_backtest.json
Normal 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
|
||||
}
|
7
cypress/fixtures/backtest/strategies.json
Normal file
7
cypress/fixtures/backtest/strategies.json
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"strategies": [
|
||||
"AdvancedTest",
|
||||
"AverageStrategy",
|
||||
"SampleStrategy"
|
||||
]
|
||||
}
|
3
cypress/fixtures/ping.json
Normal file
3
cypress/fixtures/ping.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"status": "pong"
|
||||
}
|
61
cypress/integration/backtesting.spec.ts
Normal file
61
cypress/integration/backtesting.spec.ts
Normal 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');
|
||||
});
|
||||
});
|
|
@ -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">↻</b-button>
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue
Block a user