Add some tests for Trade mode

closes #18
This commit is contained in:
Matthias 2022-09-04 17:11:18 +02:00
parent 484ed8aa5d
commit e70197c803
11 changed files with 605 additions and 1 deletions

View File

@ -23,6 +23,6 @@ export function defaultMocks() {
cy.intercept('GET', '**/api/v1/ping', { fixture: 'ping.json' }).as('Ping'); cy.intercept('GET', '**/api/v1/ping', { fixture: 'ping.json' }).as('Ping');
cy.intercept('GET', '**/api/v1/show_config', { cy.intercept('GET', '**/api/v1/show_config', {
fixture: 'backtest/show_config_backtest.json', fixture: 'show_config.json',
}).as('ShowConf'); }).as('ShowConf');
} }

37
cypress/e2e/trade.cy.ts Normal file
View File

@ -0,0 +1,37 @@
import { setLoginInfo, defaultMocks } from './helpers';
function tradeMocks() {
cy.intercept('GET', '**/api/v1/status', { fixture: 'status_empty.json' }).as('Status');
cy.intercept('GET', '**/api/v1/profit', { fixture: 'profit.json' }).as('Profit');
cy.intercept('GET', '**/api/v1/trades*', { fixture: 'trades.json' }).as('Trades');
cy.intercept('GET', '**/api/v1/balance', { fixture: 'balance.json' }).as('Balance');
cy.intercept('GET', '**/api/v1/whitelist', { fixture: 'whitelist.json' }).as('Whitelist');
cy.intercept('GET', '**/api/v1/blacklist', { fixture: 'blacklist.json' }).as('Blacklist');
cy.intercept('GET', '**/api/v1/locks', { fixture: 'locks_empty.json' }).as('Locks');
cy.intercept('GET', '**/api/v1/performance', { fixture: 'performance.json' }).as('Performance');
}
describe('Trade', () => {
it('Trade view', () => {
defaultMocks();
tradeMocks();
setLoginInfo();
cy.visit('/trade');
cy.wait('@Ping');
cy.wait('@Status');
cy.wait('@Profit');
cy.wait('@Balance');
cy.wait('@Trades');
cy.wait('@Whitelist');
cy.wait('@Blacklist');
cy.wait('@Locks');
cy.wait('@Performance');
cy.get('button').should('contain', 'BTC/USDT');
cy.get('button').should('contain', 'ETH/USDT').should('be.visible');
cy.get('button').contains('ETH/USDT').should('be.visible');
cy.get('a[role="tab"]').contains('General').click();
cy.get('button').contains('ETH/USDT').should('not.be.visible');
});
});

View File

@ -0,0 +1,27 @@
{
"currencies": [
{
"currency": "USDT",
"free": 766.8545525,
"balance": 766.8545525,
"used": 0.0,
"est_stake": 766.8545525,
"stake": "USDT",
"side": "long",
"leverage": 1.0,
"is_position": false,
"position": 0.0
}
],
"total": 766.8545525,
"symbol": "USD",
"value": 767.6214070524999,
"stake": "USDT",
"note": "Simulated balances",
"starting_capital": 1000.0,
"starting_capital_ratio": -0.2331454475,
"starting_capital_pct": -23.31,
"starting_capital_fiat": 1000.9999999999999,
"starting_capital_fiat_ratio": -0.2331454475,
"starting_capital_fiat_pct": -23.31
}

View File

@ -0,0 +1,51 @@
{
"blacklist": [
"BNB/BTC",
"BNB/BUSD",
"BNB/ETH",
"BNB/EUR",
"BNB/NGN",
"BNB/PAX",
"BNB/RUB",
"BNB/TRY",
"BNB/TUSD",
"BNB/USDC",
"BNB/USDS",
"BNB/USDT",
"BUSD/USDT",
"EUR/USDT",
"NGN/USDT",
"PAX/USDT",
"RUB/USDT",
"TRY/USDT",
"TUSD/USDT",
"USDC/USDT",
"USDS/USDT",
"USDT/USDT"
],
"blacklist_expanded": [
"BNB/BTC",
"BNB/BUSD",
"BNB/ETH",
"BNB/EUR",
"BNB/NGN",
"BNB/PAX",
"BNB/RUB",
"BNB/TRY",
"BNB/TUSD",
"BNB/USDC",
"BNB/USDS",
"BNB/USDT",
"BUSD/USDT",
"EUR/USDT",
"PAX/USDT",
"TUSD/USDT",
"USDC/USDT",
"USDS/USDT"
],
"errors": {},
"length": 22,
"method": [
"StaticPairList"
]
}

View File

@ -0,0 +1,4 @@
{
"lock_count": 0,
"locks": []
}

View File

@ -0,0 +1,58 @@
[
{
"pair": "LTC/USDT",
"profit": 0.45,
"profit_ratio": 0.004545904027666401,
"profit_pct": 0.45,
"profit_abs": 0.10887519000000001,
"count": 2
},
{
"pair": "ETC/USDT",
"profit": 0.29,
"profit_ratio": 0.0028783330753339572,
"profit_pct": 0.29,
"profit_abs": 0.1440453,
"count": 1
},
{
"pair": "TRX/USDT",
"profit": 0.17,
"profit_ratio": 0.00167518,
"profit_pct": 0.17,
"profit_abs": 0.83674944,
"count": 1
},
{
"pair": "BTC/USDT",
"profit": -1.47,
"profit_ratio": -0.014713809081536511,
"profit_pct": -1.47,
"profit_abs": -3.81200005,
"count": 9
},
{
"pair": "ETH/USDT",
"profit": -2.43,
"profit_ratio": -0.024289884285767328,
"profit_pct": -2.43,
"profit_abs": -6.150283,
"count": 8
},
{
"pair": "DOT/USDT",
"profit": 13.31,
"profit_ratio": 0.13306229586612298,
"profit_pct": 13.31,
"profit_abs": -97.83082590000001,
"count": 54
},
{
"pair": "XRP/USDT",
"profit": -34.21,
"profit_ratio": -0.342123315582023,
"profit_pct": -34.21,
"profit_abs": -124.26266862000003,
"count": 74
}
]

View File

@ -0,0 +1,34 @@
{
"profit_closed_coin": -233.1454475,
"profit_closed_percent_mean": -0.17,
"profit_closed_ratio_mean": -0.0017259337596389544,
"profit_closed_percent_sum": -25.72,
"profit_closed_ratio_sum": -0.25716413018620427,
"profit_closed_percent": -23.31,
"profit_closed_ratio": -0.2331454475,
"profit_closed_fiat": -233.37859294749995,
"profit_all_coin": -233.1454475,
"profit_all_percent_mean": -0.17,
"profit_all_ratio_mean": -0.0017259337596389544,
"profit_all_percent_sum": -25.72,
"profit_all_ratio_sum": -0.25716413018620427,
"profit_all_percent": -23.31,
"profit_all_ratio": -0.2331454475,
"profit_all_fiat": -233.37859294749995,
"trade_count": 149,
"closed_trade_count": 149,
"first_trade_date": "a year ago",
"first_trade_timestamp": 1626021644985,
"latest_trade_date": "5 days ago",
"latest_trade_timestamp": 1661828800529,
"avg_duration": "7:59:54",
"best_pair": "DOT/USDT",
"best_rate": 13.31,
"best_pair_profit_ratio": 0.13306229586612298,
"winning_trades": 6,
"losing_trades": 143,
"profit_factor": 0.2556546553155618,
"max_drawdown": 0.254347411553074,
"max_drawdown_abs": 261.57955258000004,
"trading_volume": 100575.40924053731
}

View File

@ -0,0 +1,64 @@
{
"version": "2022.8",
"strategy_version": "1.1.5",
"api_version": 2.17,
"dry_run": true,
"trading_mode": "spot",
"short_allowed": false,
"stake_currency": "USDT",
"stake_amount": "50",
"available_capital": 1000.0,
"stake_currency_decimals": 3,
"max_open_trades": 3,
"minimal_roi": {
"0": 0.05
},
"stoploss": -0.005,
"trailing_stop": true,
"trailing_stop_positive": 0.01,
"trailing_stop_positive_offset": 0.015,
"trailing_only_offset_is_reached": false,
"unfilledtimeout": {
"entry": 10,
"exit": 10,
"unit": "seconds",
"exit_timeout_count": 2000
},
"order_types": {
"entry": "limit",
"exit": "limit",
"emergency_exit": "limit",
"force_exit": null,
"force_entry": null,
"stoploss": "limit",
"stoploss_on_exchange": false,
"stoploss_on_exchange_interval": 60
},
"use_custom_stoploss": false,
"timeframe": "1m",
"timeframe_ms": 60000,
"timeframe_min": 1,
"exchange": "binance",
"strategy": "NoActionStrategy",
"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": "running",
"runmode": "dry_run",
"position_adjustment_enable": true,
"max_entry_position_adjustment": 3
}

View File

@ -0,0 +1 @@
[]

View File

@ -0,0 +1,314 @@
{
"trades": [
{
"trade_id": 1,
"pair": "BTC/USDT",
"base_currency": "BTC",
"quote_currency": "USDT",
"is_open": false,
"exchange": "binance",
"amount": 0.014727,
"amount_requested": 0.014727,
"stake_amount": 499.97620101,
"strategy": "BuyEvenSellOdd",
"buy_tag": null,
"enter_tag": null,
"timeframe": 5,
"fee_open": 0.001,
"fee_open_cost": 0.49997620100999995,
"fee_open_currency": "USDT",
"fee_close": 0.001,
"fee_close_cost": 0.49998017730000005,
"fee_close_currency": "USDT",
"open_date": "2021-07-11 18:40:44",
"open_timestamp": 1626028844985,
"open_rate": 33949.63,
"open_rate_requested": 33949.63,
"open_trade_value": 500.47617721,
"close_date": "2021-07-11 18:41:06",
"close_timestamp": 1626028866776,
"realized_profit": 0.0,
"close_rate": 33949.9,
"close_rate_requested": 33949.9,
"close_profit": -0.00199006,
"close_profit_pct": -0.2,
"close_profit_abs": -0.99598009,
"trade_duration_s": 21,
"trade_duration": 0,
"profit_ratio": -0.00199006,
"profit_pct": -0.2,
"profit_abs": -0.99598009,
"sell_reason": "exit_signal",
"exit_reason": "exit_signal",
"exit_order_status": "closed",
"stop_loss_abs": 32252.490499999996,
"stop_loss_ratio": -0.05,
"stop_loss_pct": -5.0,
"stoploss_order_id": "dry_run_sell_1626028846.472568",
"stoploss_last_update": "2021-07-11 18:40:56",
"stoploss_last_update_timestamp": 1626028856756,
"initial_stop_loss_abs": 32252.148499999996,
"initial_stop_loss_ratio": -0.05,
"initial_stop_loss_pct": -5.0,
"min_rate": 33949.63,
"max_rate": 33949.99,
"leverage": 1.0,
"interest_rate": 0.0,
"liquidation_price": null,
"is_short": false,
"trading_mode": null,
"funding_fees": 0.0,
"open_order_id": null,
"orders": [
{
"amount": 0.014727,
"safe_price": 33949.63,
"ft_order_side": "buy",
"order_filled_timestamp": 1626028844986,
"ft_is_entry": true,
"pair": "BTC/USDT",
"order_id": "dry_run_buy_1626028844.471467",
"status": "closed",
"average": 33949.63,
"cost": 499.97620100999995,
"filled": 0.014727,
"is_open": false,
"order_date": "2021-07-11 18:40:44",
"order_timestamp": 1626028844000,
"order_filled_date": "2021-07-11 18:40:44",
"order_type": "limit",
"price": 33949.63,
"remaining": 0.0
},
{
"amount": 0.014727,
"safe_price": 33949.9,
"ft_order_side": "sell",
"order_filled_timestamp": 1626028866759,
"ft_is_entry": false,
"pair": "BTC/USDT",
"order_id": "dry_run_sell_1626028861.900895",
"status": "closed",
"average": 33949.9,
"cost": 499.98017730000004,
"filled": 0.014727,
"is_open": false,
"order_date": "2021-07-11 18:41:01",
"order_timestamp": 1626028861000,
"order_filled_date": "2021-07-11 18:41:06",
"order_type": "limit",
"price": 33949.9,
"remaining": 0.0
}
]
},
{
"trade_id": 2,
"pair": "ETH/USDT",
"base_currency": "ETH",
"quote_currency": "USDT",
"is_open": false,
"exchange": "binance",
"amount": 0.00001,
"amount_requested": 0.00001,
"stake_amount": 0.0214229,
"strategy": "BuyEvenSellOdd",
"buy_tag": null,
"enter_tag": null,
"timeframe": 5,
"fee_open": 0.001,
"fee_open_cost": 0.0000214229,
"fee_open_currency": "USDT",
"fee_close": 0.001,
"fee_close_cost": 0.000021420300000000002,
"fee_close_currency": "USDT",
"open_date": "2021-07-11 18:40:46",
"open_timestamp": 1626028846003,
"open_rate": 2142.29,
"open_rate_requested": 2142.29,
"open_trade_value": 0.02144432,
"close_date": "2021-07-11 18:41:03",
"close_timestamp": 1626028863481,
"realized_profit": 0.0,
"close_rate": 2142.03,
"close_rate_requested": 2142.03,
"close_profit": -0.00211912,
"close_profit_pct": -0.21,
"close_profit_abs": -0.00004544,
"trade_duration_s": 17,
"trade_duration": 0,
"profit_ratio": -0.00211912,
"profit_pct": -0.21,
"profit_abs": -0.00004544,
"sell_reason": "exit_signal",
"exit_reason": "exit_signal",
"exit_order_status": "closed",
"stop_loss_abs": 2035.1754999999998,
"stop_loss_ratio": -0.05,
"stop_loss_pct": -5.0,
"stoploss_order_id": "dry_run_sell_1626028846.830455",
"stoploss_last_update": "2021-07-11 18:40:47",
"stoploss_last_update_timestamp": 1626028847303,
"initial_stop_loss_abs": 2035.1754999999998,
"initial_stop_loss_ratio": -0.05,
"initial_stop_loss_pct": -5.0,
"min_rate": 2142.02,
"max_rate": 2142.29,
"leverage": 1.0,
"interest_rate": 0.0,
"liquidation_price": null,
"is_short": false,
"trading_mode": null,
"funding_fees": 0.0,
"open_order_id": null,
"orders": [
{
"amount": 0.00001,
"safe_price": 2142.29,
"ft_order_side": "buy",
"order_filled_timestamp": 1626028846004,
"ft_is_entry": true,
"pair": "ETH/USDT",
"order_id": "dry_run_buy_1626028845.495227",
"status": "closed",
"average": 2142.29,
"cost": 0.0214229,
"filled": 0.00001,
"is_open": false,
"order_date": "2021-07-11 18:40:45",
"order_timestamp": 1626028845000,
"order_filled_date": "2021-07-11 18:40:46",
"order_type": "limit",
"price": 2142.29,
"remaining": 0.0
},
{
"amount": 0.00001,
"safe_price": 2142.03,
"ft_order_side": "sell",
"order_filled_timestamp": 1626028863465,
"ft_is_entry": false,
"pair": "ETH/USDT",
"order_id": "dry_run_sell_1626028863.01613",
"status": "closed",
"average": 2142.03,
"cost": 0.021420300000000003,
"filled": 0.00001,
"is_open": false,
"order_date": "2021-07-11 18:41:03",
"order_timestamp": 1626028863000,
"order_filled_date": "2021-07-11 18:41:03",
"order_type": "limit",
"price": 2142.03,
"remaining": 0.0
}
]
},
{
"trade_id": 3,
"pair": "TRX/USDT",
"base_currency": "TRX",
"quote_currency": "USDT",
"is_open": false,
"exchange": "binance",
"amount": 8070.5,
"amount_requested": 8070.5,
"stake_amount": 498.999015,
"strategy": "BuyEvenSellOdd",
"buy_tag": null,
"enter_tag": null,
"timeframe": 5,
"fee_open": 0.001,
"fee_open_cost": 0.49899901500000005,
"fee_open_currency": "USDT",
"fee_close": 0.001,
"fee_close_cost": 0.499160425,
"fee_close_currency": "USDT",
"open_date": "2021-07-11 18:42:02",
"open_timestamp": 1626028922311,
"open_rate": 0.06183,
"open_rate_requested": 0.06183,
"open_trade_value": 499.49801402,
"close_date": "2021-07-11 18:43:02",
"close_timestamp": 1626028982533,
"realized_profit": 0.0,
"close_rate": 0.06185,
"close_rate_requested": 0.06185,
"close_profit": -0.00167518,
"close_profit_pct": -0.17,
"close_profit_abs": -0.83674944,
"trade_duration_s": 60,
"trade_duration": 1,
"profit_ratio": -0.00167518,
"profit_pct": -0.17,
"profit_abs": -0.83674944,
"sell_reason": "exit_signal",
"exit_reason": "exit_signal",
"exit_order_status": "closed",
"stop_loss_abs": 0.058776499999999995,
"stop_loss_ratio": -0.05,
"stop_loss_pct": -5.0,
"stoploss_order_id": "dry_run_sell_1626028926.680114",
"stoploss_last_update": "2021-07-11 18:42:17",
"stoploss_last_update_timestamp": 1626028937046,
"initial_stop_loss_abs": 0.0587385,
"initial_stop_loss_ratio": -0.05,
"initial_stop_loss_pct": -5.0,
"min_rate": 0.06182,
"max_rate": 0.06187,
"leverage": 1.0,
"interest_rate": 0.0,
"liquidation_price": null,
"is_short": false,
"trading_mode": null,
"funding_fees": 0.0,
"open_order_id": null,
"orders": [
{
"amount": 8070.5,
"safe_price": 0.06183,
"ft_order_side": "buy",
"order_filled_timestamp": 1626028922311,
"ft_is_entry": true,
"pair": "TRX/USDT",
"order_id": "dry_run_buy_1626028921.88793",
"status": "closed",
"average": 0.06183,
"cost": 498.99901500000004,
"filled": 8070.5,
"is_open": false,
"order_date": "2021-07-11 18:42:01",
"order_timestamp": 1626028921000,
"order_filled_date": "2021-07-11 18:42:02",
"order_type": "limit",
"price": 0.06183,
"remaining": 0.0
},
{
"amount": 8070.5,
"safe_price": 0.06185,
"ft_order_side": "sell",
"order_filled_timestamp": 1626028982507,
"ft_is_entry": false,
"pair": "TRX/USDT",
"order_id": "dry_run_sell_1626028981.900712",
"status": "closed",
"average": 0.06185,
"cost": 499.16042500000003,
"filled": 8070.5,
"is_open": false,
"order_date": "2021-07-11 18:43:01",
"order_timestamp": 1626028981000,
"order_filled_date": "2021-07-11 18:43:02",
"order_type": "limit",
"price": 0.06185,
"remaining": 0.0
}
]
}
],
"trades_count": 3,
"offset": 0,
"total_trades": 3
}

View File

@ -0,0 +1,14 @@
{
"whitelist": [
"BTC/USDT",
"ETH/USDT",
"XRP/USDT",
"DOT/USDT",
"LTC/USDT",
"ETC/USDT"
],
"length": 6,
"method": [
"StaticPairList"
]
}