ruff format: Update conftest_trades files

This commit is contained in:
Matthias
2024-05-12 15:30:28 +02:00
parent 7090950db6
commit 53947732a0
2 changed files with 398 additions and 394 deletions

View File

@@ -20,29 +20,29 @@ def direc(is_short: bool):
def mock_order_usdt_1(is_short: bool):
return {
'id': f'prod_entry_1_{direc(is_short)}',
'symbol': 'LTC/USDT',
'status': 'closed',
'side': entry_side(is_short),
'type': 'limit',
'price': 10.0,
'amount': 2.0,
'filled': 2.0,
'remaining': 0.0,
"id": f"prod_entry_1_{direc(is_short)}",
"symbol": "LTC/USDT",
"status": "closed",
"side": entry_side(is_short),
"type": "limit",
"price": 10.0,
"amount": 2.0,
"filled": 2.0,
"remaining": 0.0,
}
def mock_order_usdt_1_exit(is_short: bool):
return {
'id': f'prod_exit_1_{direc(is_short)}',
'symbol': 'LTC/USDT',
'status': 'open',
'side': exit_side(is_short),
'type': 'limit',
'price': 8.0,
'amount': 2.0,
'filled': 0.0,
'remaining': 2.0,
"id": f"prod_exit_1_{direc(is_short)}",
"symbol": "LTC/USDT",
"status": "open",
"side": exit_side(is_short),
"type": "limit",
"price": 8.0,
"amount": 2.0,
"filled": 0.0,
"remaining": 2.0,
}
@@ -51,7 +51,7 @@ def mock_trade_usdt_1(fee, is_short: bool):
Simulate prod entry with open sell order
"""
trade = Trade(
pair='LTC/USDT',
pair="LTC/USDT",
stake_amount=20.0,
amount=2.0,
amount_requested=2.0,
@@ -64,44 +64,45 @@ def mock_trade_usdt_1(fee, is_short: bool):
close_rate=8.0,
close_profit=-0.2,
close_profit_abs=-4.09,
exchange='binance',
strategy='SampleStrategy',
exchange="binance",
strategy="SampleStrategy",
timeframe=5,
is_short=is_short,
)
o = Order.parse_from_ccxt_object(mock_order_usdt_1(is_short), 'LTC/USDT', entry_side(is_short))
o = Order.parse_from_ccxt_object(mock_order_usdt_1(is_short), "LTC/USDT", entry_side(is_short))
trade.orders.append(o)
o = Order.parse_from_ccxt_object(mock_order_usdt_1_exit(is_short),
'LTC/USDT', exit_side(is_short))
o = Order.parse_from_ccxt_object(
mock_order_usdt_1_exit(is_short), "LTC/USDT", exit_side(is_short)
)
trade.orders.append(o)
return trade
def mock_order_usdt_2(is_short: bool):
return {
'id': f'1235_{direc(is_short)}',
'symbol': 'NEO/USDT',
'status': 'closed',
'side': entry_side(is_short),
'type': 'limit',
'price': 2.0,
'amount': 100.0,
'filled': 100.0,
'remaining': 0.0,
"id": f"1235_{direc(is_short)}",
"symbol": "NEO/USDT",
"status": "closed",
"side": entry_side(is_short),
"type": "limit",
"price": 2.0,
"amount": 100.0,
"filled": 100.0,
"remaining": 0.0,
}
def mock_order_usdt_2_exit(is_short: bool):
return {
'id': f'12366_{direc(is_short)}',
'symbol': 'NEO/USDT',
'status': 'open',
'side': exit_side(is_short),
'type': 'limit',
'price': 2.05,
'amount': 100.0,
'filled': 0.0,
'remaining': 100.0,
"id": f"12366_{direc(is_short)}",
"symbol": "NEO/USDT",
"status": "open",
"side": exit_side(is_short),
"type": "limit",
"price": 2.05,
"amount": 100.0,
"filled": 0.0,
"remaining": 100.0,
}
@@ -110,7 +111,7 @@ def mock_trade_usdt_2(fee, is_short: bool):
Closed trade...
"""
trade = Trade(
pair='NEO/USDT',
pair="NEO/USDT",
stake_amount=200.0,
amount=100.0,
amount_requested=100.0,
@@ -120,50 +121,51 @@ def mock_trade_usdt_2(fee, is_short: bool):
close_rate=2.05,
close_profit=0.05,
close_profit_abs=3.9875,
exchange='binance',
exchange="binance",
is_open=False,
strategy='StrategyTestV2',
strategy="StrategyTestV2",
timeframe=5,
enter_tag='TEST1',
exit_reason='exit_signal',
enter_tag="TEST1",
exit_reason="exit_signal",
open_date=datetime.now(tz=timezone.utc) - timedelta(minutes=20),
close_date=datetime.now(tz=timezone.utc) - timedelta(minutes=2),
is_short=is_short,
)
o = Order.parse_from_ccxt_object(mock_order_usdt_2(is_short), 'NEO/USDT', entry_side(is_short))
o = Order.parse_from_ccxt_object(mock_order_usdt_2(is_short), "NEO/USDT", entry_side(is_short))
trade.orders.append(o)
o = Order.parse_from_ccxt_object(
mock_order_usdt_2_exit(is_short), 'NEO/USDT', exit_side(is_short))
mock_order_usdt_2_exit(is_short), "NEO/USDT", exit_side(is_short)
)
trade.orders.append(o)
return trade
def mock_order_usdt_3(is_short: bool):
return {
'id': f'41231a12a_{direc(is_short)}',
'symbol': 'XRP/USDT',
'status': 'closed',
'side': entry_side(is_short),
'type': 'limit',
'price': 1.0,
'amount': 30.0,
'filled': 30.0,
'remaining': 0.0,
"id": f"41231a12a_{direc(is_short)}",
"symbol": "XRP/USDT",
"status": "closed",
"side": entry_side(is_short),
"type": "limit",
"price": 1.0,
"amount": 30.0,
"filled": 30.0,
"remaining": 0.0,
}
def mock_order_usdt_3_exit(is_short: bool):
return {
'id': f'41231a666a_{direc(is_short)}',
'symbol': 'XRP/USDT',
'status': 'closed',
'side': exit_side(is_short),
'type': 'stop_loss_limit',
'price': 1.1,
'average': 1.1,
'amount': 30.0,
'filled': 30.0,
'remaining': 0.0,
"id": f"41231a666a_{direc(is_short)}",
"symbol": "XRP/USDT",
"status": "closed",
"side": exit_side(is_short),
"type": "stop_loss_limit",
"price": 1.1,
"average": 1.1,
"amount": 30.0,
"filled": 30.0,
"remaining": 0.0,
}
@@ -172,7 +174,7 @@ def mock_trade_usdt_3(fee, is_short: bool):
Closed trade
"""
trade = Trade(
pair='XRP/USDT',
pair="XRP/USDT",
stake_amount=30.0,
amount=30.0,
amount_requested=30.0,
@@ -182,35 +184,36 @@ def mock_trade_usdt_3(fee, is_short: bool):
close_rate=1.1,
close_profit=0.1,
close_profit_abs=2.8425,
exchange='binance',
exchange="binance",
is_open=False,
strategy='StrategyTestV2',
strategy="StrategyTestV2",
timeframe=5,
enter_tag='TEST3',
exit_reason='roi',
enter_tag="TEST3",
exit_reason="roi",
open_date=datetime.now(tz=timezone.utc) - timedelta(minutes=20),
close_date=datetime.now(tz=timezone.utc),
is_short=is_short,
)
o = Order.parse_from_ccxt_object(mock_order_usdt_3(is_short), 'XRP/USDT', entry_side(is_short))
o = Order.parse_from_ccxt_object(mock_order_usdt_3(is_short), "XRP/USDT", entry_side(is_short))
trade.orders.append(o)
o = Order.parse_from_ccxt_object(mock_order_usdt_3_exit(is_short),
'XRP/USDT', exit_side(is_short))
o = Order.parse_from_ccxt_object(
mock_order_usdt_3_exit(is_short), "XRP/USDT", exit_side(is_short)
)
trade.orders.append(o)
return trade
def mock_order_usdt_4(is_short: bool):
return {
'id': f'prod_buy_12345_{direc(is_short)}',
'symbol': 'NEO/USDT',
'status': 'open',
'side': entry_side(is_short),
'type': 'limit',
'price': 2.0,
'amount': 10.0,
'filled': 0.0,
'remaining': 30.0,
"id": f"prod_buy_12345_{direc(is_short)}",
"symbol": "NEO/USDT",
"status": "open",
"side": entry_side(is_short),
"type": "limit",
"price": 2.0,
"amount": 10.0,
"filled": 0.0,
"remaining": 30.0,
}
@@ -219,7 +222,7 @@ def mock_trade_usdt_4(fee, is_short: bool):
Simulate prod entry
"""
trade = Trade(
pair='NEO/USDT',
pair="NEO/USDT",
stake_amount=20.0,
amount=10.0,
amount_requested=10.01,
@@ -228,41 +231,41 @@ def mock_trade_usdt_4(fee, is_short: bool):
open_date=datetime.now(tz=timezone.utc) - timedelta(minutes=14),
is_open=True,
open_rate=2.0,
exchange='binance',
strategy='StrategyTestV2',
exchange="binance",
strategy="StrategyTestV2",
timeframe=5,
is_short=is_short,
)
o = Order.parse_from_ccxt_object(mock_order_usdt_4(is_short), 'NEO/USDT', entry_side(is_short))
o = Order.parse_from_ccxt_object(mock_order_usdt_4(is_short), "NEO/USDT", entry_side(is_short))
trade.orders.append(o)
return trade
def mock_order_usdt_5(is_short: bool):
return {
'id': f'prod_buy_3455_{direc(is_short)}',
'symbol': 'XRP/USDT',
'status': 'closed',
'side': entry_side(is_short),
'type': 'limit',
'price': 2.0,
'amount': 10.0,
'filled': 10.0,
'remaining': 0.0,
"id": f"prod_buy_3455_{direc(is_short)}",
"symbol": "XRP/USDT",
"status": "closed",
"side": entry_side(is_short),
"type": "limit",
"price": 2.0,
"amount": 10.0,
"filled": 10.0,
"remaining": 0.0,
}
def mock_order_usdt_5_stoploss(is_short: bool):
return {
'id': f'prod_stoploss_3455_{direc(is_short)}',
'symbol': 'XRP/USDT',
'status': 'open',
'side': exit_side(is_short),
'type': 'stop_loss_limit',
'price': 2.0,
'amount': 10.0,
'filled': 0.0,
'remaining': 30.0,
"id": f"prod_stoploss_3455_{direc(is_short)}",
"symbol": "XRP/USDT",
"status": "open",
"side": exit_side(is_short),
"type": "stop_loss_limit",
"price": 2.0,
"amount": 10.0,
"filled": 0.0,
"remaining": 30.0,
}
@@ -271,7 +274,7 @@ def mock_trade_usdt_5(fee, is_short: bool):
Simulate prod entry with stoploss
"""
trade = Trade(
pair='XRP/USDT',
pair="XRP/USDT",
stake_amount=20.0,
amount=10.0,
amount_requested=10.01,
@@ -280,43 +283,43 @@ def mock_trade_usdt_5(fee, is_short: bool):
open_date=datetime.now(tz=timezone.utc) - timedelta(minutes=12),
is_open=True,
open_rate=2.0,
exchange='binance',
strategy='SampleStrategy',
exchange="binance",
strategy="SampleStrategy",
timeframe=5,
is_short=is_short,
)
o = Order.parse_from_ccxt_object(mock_order_usdt_5(is_short), 'XRP/USDT', entry_side(is_short))
o = Order.parse_from_ccxt_object(mock_order_usdt_5(is_short), "XRP/USDT", entry_side(is_short))
trade.orders.append(o)
o = Order.parse_from_ccxt_object(mock_order_usdt_5_stoploss(is_short), 'XRP/USDT', 'stoploss')
o = Order.parse_from_ccxt_object(mock_order_usdt_5_stoploss(is_short), "XRP/USDT", "stoploss")
trade.orders.append(o)
return trade
def mock_order_usdt_6(is_short: bool):
return {
'id': f'prod_entry_6_{direc(is_short)}',
'symbol': 'LTC/USDT',
'status': 'closed',
'side': entry_side(is_short),
'type': 'limit',
'price': 10.0,
'amount': 2.0,
'filled': 2.0,
'remaining': 0.0,
"id": f"prod_entry_6_{direc(is_short)}",
"symbol": "LTC/USDT",
"status": "closed",
"side": entry_side(is_short),
"type": "limit",
"price": 10.0,
"amount": 2.0,
"filled": 2.0,
"remaining": 0.0,
}
def mock_order_usdt_6_exit(is_short: bool):
return {
'id': f'prod_exit_6_{direc(is_short)}',
'symbol': 'LTC/USDT',
'status': 'open',
'side': exit_side(is_short),
'type': 'limit',
'price': 12.0,
'amount': 2.0,
'filled': 0.0,
'remaining': 2.0,
"id": f"prod_exit_6_{direc(is_short)}",
"symbol": "LTC/USDT",
"status": "open",
"side": exit_side(is_short),
"type": "limit",
"price": 12.0,
"amount": 2.0,
"filled": 0.0,
"remaining": 2.0,
}
@@ -325,7 +328,7 @@ def mock_trade_usdt_6(fee, is_short: bool):
Simulate prod entry with open sell order
"""
trade = Trade(
pair='LTC/USDT',
pair="LTC/USDT",
stake_amount=20.0,
amount=2.0,
amount_requested=2.0,
@@ -334,36 +337,37 @@ def mock_trade_usdt_6(fee, is_short: bool):
fee_close=fee.return_value,
is_open=True,
open_rate=10.0,
exchange='binance',
strategy='SampleStrategy',
exchange="binance",
strategy="SampleStrategy",
timeframe=5,
is_short=is_short,
)
o = Order.parse_from_ccxt_object(mock_order_usdt_6(is_short), 'LTC/USDT', entry_side(is_short))
o = Order.parse_from_ccxt_object(mock_order_usdt_6(is_short), "LTC/USDT", entry_side(is_short))
trade.orders.append(o)
o = Order.parse_from_ccxt_object(mock_order_usdt_6_exit(is_short),
'LTC/USDT', exit_side(is_short))
o = Order.parse_from_ccxt_object(
mock_order_usdt_6_exit(is_short), "LTC/USDT", exit_side(is_short)
)
trade.orders.append(o)
return trade
def mock_order_usdt_7(is_short: bool):
return {
'id': f'1234_{direc(is_short)}',
'symbol': 'ADA/USDT',
'status': 'closed',
'side': entry_side(is_short),
'type': 'limit',
'price': 2.0,
'amount': 10.0,
'filled': 10.0,
'remaining': 0.0,
"id": f"1234_{direc(is_short)}",
"symbol": "ADA/USDT",
"status": "closed",
"side": entry_side(is_short),
"type": "limit",
"price": 2.0,
"amount": 10.0,
"filled": 10.0,
"remaining": 0.0,
}
def mock_trade_usdt_7(fee, is_short: bool):
trade = Trade(
pair='ADA/USDT',
pair="ADA/USDT",
stake_amount=20.0,
amount=10.0,
amount_requested=10.0,
@@ -372,11 +376,11 @@ def mock_trade_usdt_7(fee, is_short: bool):
is_open=True,
open_date=datetime.now(tz=timezone.utc) - timedelta(minutes=17),
open_rate=2.0,
exchange='binance',
strategy='StrategyTestV2',
exchange="binance",
strategy="StrategyTestV2",
timeframe=5,
is_short=is_short,
)
o = Order.parse_from_ccxt_object(mock_order_usdt_7(is_short), 'ADA/USDT', entry_side(is_short))
o = Order.parse_from_ccxt_object(mock_order_usdt_7(is_short), "ADA/USDT", entry_side(is_short))
trade.orders.append(o)
return trade