Add losing trade to usdt_mock_trades

This commit is contained in:
Matthias 2022-02-06 16:02:18 +01:00
parent 303b12efd8
commit c19f3950da
2 changed files with 61 additions and 1 deletions

View File

@ -25,7 +25,8 @@ from freqtrade.worker import Worker
from tests.conftest_trades import (mock_trade_1, mock_trade_2, mock_trade_3, mock_trade_4,
mock_trade_5, mock_trade_6)
from tests.conftest_trades_usdt import (mock_trade_usdt_1, mock_trade_usdt_2, mock_trade_usdt_3,
mock_trade_usdt_4, mock_trade_usdt_5, mock_trade_usdt_6)
mock_trade_usdt_4, mock_trade_usdt_5, mock_trade_usdt_6,
mock_trade_usdt_7)
logging.getLogger('').setLevel(logging.INFO)
@ -258,6 +259,8 @@ def create_mock_trades_usdt(fee, use_db: bool = True):
trade = mock_trade_usdt_6(fee)
add_trade(trade)
trade = mock_trade_usdt_7(fee)
add_trade(trade)
if use_db:
Trade.commit()

View File

@ -303,3 +303,60 @@ def mock_trade_usdt_6(fee):
o = Order.parse_from_ccxt_object(mock_order_usdt_6_sell(), 'LTC/USDT', 'sell')
trade.orders.append(o)
return trade
def mock_order_usdt_7():
return {
'id': 'prod_buy_7',
'symbol': 'LTC/USDT',
'status': 'closed',
'side': 'buy',
'type': 'limit',
'price': 10.0,
'amount': 2.0,
'filled': 2.0,
'remaining': 0.0,
}
def mock_order_usdt_7_sell():
return {
'id': 'prod_sell_7',
'symbol': 'LTC/USDT',
'status': 'closed',
'side': 'sell',
'type': 'limit',
'price': 8.0,
'amount': 2.0,
'filled': 2.0,
'remaining': 0.0,
}
def mock_trade_usdt_7(fee):
"""
Simulate prod entry with open sell order
"""
trade = Trade(
pair='LTC/USDT',
stake_amount=20.0,
amount=2.0,
amount_requested=2.0,
open_date=datetime.now(tz=timezone.utc) - timedelta(minutes=5),
fee_open=fee.return_value,
fee_close=fee.return_value,
is_open=False,
open_rate=10.0,
close_rate=8.0,
close_profit=-0.2,
close_profit_abs=-4.0,
exchange='binance',
strategy='SampleStrategy',
open_order_id="prod_sell_6",
timeframe=5,
)
o = Order.parse_from_ccxt_object(mock_order_usdt_7(), 'LTC/USDT', 'buy')
trade.orders.append(o)
o = Order.parse_from_ccxt_object(mock_order_usdt_7_sell(), 'LTC/USDT', 'sell')
trade.orders.append(o)
return trade