made leveraged test names unique

test_adjust_stop_loss_short, test_update_market_order_shortpasses
This commit is contained in:
Sam Germain 2021-07-05 22:01:46 -06:00
parent 1b202ca22e
commit 3328707a1d
3 changed files with 36 additions and 36 deletions

View File

@ -15,7 +15,7 @@ from tests.conftest import create_mock_trades_with_leverage, log_has, log_has_re
@pytest.mark.usefixtures("init_persistence")
def test_interest_kraken(market_leveraged_buy_order, fee):
def test_interest_kraken_lev(market_leveraged_buy_order, fee):
"""
Market trade on Kraken at 3x and 5x leverage
Short trade
@ -82,7 +82,7 @@ def test_interest_kraken(market_leveraged_buy_order, fee):
@pytest.mark.usefixtures("init_persistence")
def test_interest_binance(market_leveraged_buy_order, fee):
def test_interest_binance_lev(market_leveraged_buy_order, fee):
"""
Market trade on Kraken at 3x and 5x leverage
Short trade
@ -148,7 +148,7 @@ def test_interest_binance(market_leveraged_buy_order, fee):
@pytest.mark.usefixtures("init_persistence")
def test_update_open_order(limit_leveraged_buy_order):
def test_update_open_order_lev(limit_leveraged_buy_order):
trade = Trade(
pair='ETH/BTC',
stake_amount=1.00,
@ -172,7 +172,7 @@ def test_update_open_order(limit_leveraged_buy_order):
@pytest.mark.usefixtures("init_persistence")
def test_calc_open_trade_value(market_leveraged_buy_order, fee):
def test_calc_open_trade_value_lev(market_leveraged_buy_order, fee):
"""
10 minute leveraged market trade on Kraken at 3x leverage
Short trade
@ -213,7 +213,7 @@ def test_calc_open_trade_value(market_leveraged_buy_order, fee):
@pytest.mark.usefixtures("init_persistence")
def test_calc_open_close_trade_price(limit_leveraged_buy_order, limit_leveraged_sell_order, fee):
def test_calc_open_close_trade_price_lev(limit_leveraged_buy_order, limit_leveraged_sell_order, fee):
"""
5 hour leveraged trade on Binance
@ -266,7 +266,7 @@ def test_calc_open_close_trade_price(limit_leveraged_buy_order, limit_leveraged_
@pytest.mark.usefixtures("init_persistence")
def test_trade_close(fee):
def test_trade_close_lev(fee):
"""
5 hour leveraged market trade on Kraken at 3x leverage
fee: 0.25% base
@ -325,7 +325,7 @@ def test_trade_close(fee):
@pytest.mark.usefixtures("init_persistence")
def test_calc_close_trade_price(market_leveraged_buy_order, market_leveraged_sell_order, fee):
def test_calc_close_trade_price_lev(market_leveraged_buy_order, market_leveraged_sell_order, fee):
"""
10 minute leveraged market trade on Kraken at 3x leverage
Short trade
@ -373,7 +373,7 @@ def test_calc_close_trade_price(market_leveraged_buy_order, market_leveraged_sel
@pytest.mark.usefixtures("init_persistence")
def test_update_limit_order(limit_leveraged_buy_order, limit_leveraged_sell_order, fee, caplog):
def test_update_limit_order_lev(limit_leveraged_buy_order, limit_leveraged_sell_order, fee, caplog):
"""
10 minute leveraged limit trade on binance at 3x leverage
@ -444,7 +444,7 @@ def test_update_limit_order(limit_leveraged_buy_order, limit_leveraged_sell_orde
@pytest.mark.usefixtures("init_persistence")
def test_update_market_order(market_leveraged_buy_order, market_leveraged_sell_order, fee, caplog):
def test_update_market_order_lev(market_leveraged_buy_order, market_leveraged_sell_order, fee, caplog):
"""
10 minute leveraged market trade on Kraken at 3x leverage
Short trade
@ -516,7 +516,7 @@ def test_update_market_order(market_leveraged_buy_order, market_leveraged_sell_o
@pytest.mark.usefixtures("init_persistence")
def test_calc_close_trade_price_exception(limit_leveraged_buy_order, fee):
def test_calc_close_trade_price_exception_lev(limit_leveraged_buy_order, fee):
trade = Trade(
pair='ETH/BTC',
stake_amount=0.001,
@ -535,7 +535,7 @@ def test_calc_close_trade_price_exception(limit_leveraged_buy_order, fee):
@pytest.mark.usefixtures("init_persistence")
def test_calc_profit(market_leveraged_buy_order, market_leveraged_sell_order, fee):
def test_calc_profit_lev(market_leveraged_buy_order, market_leveraged_sell_order, fee):
"""
# TODO: Update this one
Leveraged trade on Kraken at 3x leverage

View File

@ -15,7 +15,7 @@ from tests.conftest import create_mock_trades_with_leverage, log_has, log_has_re
@pytest.mark.usefixtures("init_persistence")
def test_interest_kraken(market_short_order, fee):
def test_interest_kraken_short(market_short_order, fee):
"""
Market trade on Kraken at 3x and 8x leverage
Short trade
@ -80,7 +80,7 @@ def test_interest_kraken(market_short_order, fee):
@ pytest.mark.usefixtures("init_persistence")
def test_interest_binance(market_short_order, fee):
def test_interest_binance_short(market_short_order, fee):
"""
Market trade on Binance at 3x and 5x leverage
Short trade
@ -143,7 +143,7 @@ def test_interest_binance(market_short_order, fee):
@ pytest.mark.usefixtures("init_persistence")
def test_calc_open_trade_value(market_short_order, fee):
def test_calc_open_trade_value_short(market_short_order, fee):
trade = Trade(
pair='ETH/BTC',
stake_amount=0.001,
@ -168,7 +168,7 @@ def test_calc_open_trade_value(market_short_order, fee):
@ pytest.mark.usefixtures("init_persistence")
def test_update_open_order(limit_short_order):
def test_update_open_order_short(limit_short_order):
trade = Trade(
pair='ETH/BTC',
stake_amount=1.00,
@ -193,7 +193,7 @@ def test_update_open_order(limit_short_order):
@ pytest.mark.usefixtures("init_persistence")
def test_calc_close_trade_price_exception(limit_short_order, fee):
def test_calc_close_trade_price_exception_short(limit_short_order, fee):
trade = Trade(
pair='ETH/BTC',
stake_amount=0.001,
@ -213,7 +213,7 @@ def test_calc_close_trade_price_exception(limit_short_order, fee):
@ pytest.mark.usefixtures("init_persistence")
def test_calc_close_trade_price(market_short_order, market_exit_short_order, fee):
def test_calc_close_trade_price_short(market_short_order, market_exit_short_order, fee):
"""
10 minute short market trade on Kraken at 3x leverage
Short trade
@ -257,7 +257,7 @@ def test_calc_close_trade_price(market_short_order, market_exit_short_order, fee
@ pytest.mark.usefixtures("init_persistence")
def test_calc_open_close_trade_price(limit_short_order, limit_exit_short_order, fee):
def test_calc_open_close_trade_price_short(limit_short_order, limit_exit_short_order, fee):
"""
5 hour short trade on Binance
Short trade
@ -311,7 +311,7 @@ def test_calc_open_close_trade_price(limit_short_order, limit_exit_short_order,
@ pytest.mark.usefixtures("init_persistence")
def test_trade_close(fee):
def test_trade_close_short(fee):
"""
Five hour short trade on Kraken at 3x leverage
Short trade
@ -375,7 +375,7 @@ def test_trade_close(fee):
@ pytest.mark.usefixtures("init_persistence")
def test_update_with_binance(limit_short_order, limit_exit_short_order, fee, caplog):
def test_update_with_binance_short(limit_short_order, limit_exit_short_order, fee, caplog):
"""
10 minute short limit trade on binance
@ -449,7 +449,7 @@ def test_update_with_binance(limit_short_order, limit_exit_short_order, fee, cap
@ pytest.mark.usefixtures("init_persistence")
def test_update_market_order(
def test_update_market_order_short(
market_short_order,
market_exit_short_order,
fee,
@ -506,7 +506,6 @@ def test_update_market_order(
assert trade.close_profit is None
assert trade.close_date is None
assert trade.interest_rate == 0.0005
# TODO: Uncomment the next assert and make it work.
# The logger also has the exact same but there's some spacing in there
assert log_has_re(r"MARKET_SELL has been fulfilled for Trade\(id=1, "
r"pair=ETH/BTC, amount=275.97543219, open_rate=0.00004173, open_since=.*\).",
@ -519,16 +518,16 @@ def test_update_market_order(
assert trade.close_rate == 0.00004099
assert trade.close_profit == 0.03685505
assert trade.close_date is not None
# TODO: The amount should maybe be the opening amount + the interest
# TODO: Uncomment the next assert and make it work.
# TODO-mg: The amount should maybe be the opening amount + the interest
# TODO-mg: Uncomment the next assert and make it work.
# The logger also has the exact same but there's some spacing in there
assert log_has_re(r"MARKET_SELL has been fulfilled for Trade\(id=1, "
r"pair=ETH/BTC, amount=275.97543219, open_rate=0.00004099, open_since=.*\).",
assert log_has_re(r"MARKET_BUY has been fulfilled for Trade\(id=1, "
r"pair=ETH/BTC, amount=275.97543219, open_rate=0.00004173, open_since=.*\).",
caplog)
@ pytest.mark.usefixtures("init_persistence")
def test_calc_profit(market_short_order, market_exit_short_order, fee):
def test_calc_profit_short(market_short_order, market_exit_short_order, fee):
"""
Market trade on Kraken at 3x leverage
Short trade
@ -624,7 +623,7 @@ def test_calc_profit(market_short_order, market_exit_short_order, fee):
# assert trade.calc_profit_ratio(fee=0.003) == 0.06147824
def test_adjust_stop_loss(fee):
def test_adjust_stop_loss_short(fee):
trade = Trade(
pair='ETH/BTC',
stake_amount=0.001,
@ -650,23 +649,24 @@ def test_adjust_stop_loss(fee):
assert trade.initial_stop_loss_pct == 0.05
# Get percent of profit with a custom rate (Higher than open rate)
trade.adjust_stop_loss(0.7, 0.1)
assert round(trade.stop_loss, 8) == 1.17 # TODO-mg: What is this test?
# If the price goes down to 0.7, with a trailing stop of 0.1, the new stoploss at 0.1 above 0.7 would be 0.7*0.1 higher
assert round(trade.stop_loss, 8) == 0.77
assert trade.stop_loss_pct == 0.1
assert trade.initial_stop_loss == 1.05
assert trade.initial_stop_loss_pct == 0.05
# current rate lower again ... should not change
trade.adjust_stop_loss(0.8, -0.1)
assert round(trade.stop_loss, 8) == 1.17 # TODO-mg: What is this test?
assert round(trade.stop_loss, 8) == 0.77
assert trade.initial_stop_loss == 1.05
assert trade.initial_stop_loss_pct == 0.05
# current rate higher... should raise stoploss
trade.adjust_stop_loss(0.6, -0.1)
assert round(trade.stop_loss, 8) == 1.26 # TODO-mg: What is this test?
assert round(trade.stop_loss, 8) == 0.66
assert trade.initial_stop_loss == 1.05
assert trade.initial_stop_loss_pct == 0.05
# Initial is true but stop_loss set - so doesn't do anything
trade.adjust_stop_loss(0.3, -0.1, True)
assert round(trade.stop_loss, 8) == 1.26 # TODO-mg: What is this test?
assert round(trade.stop_loss, 8) == 0.66 # TODO-mg: What is this test?
assert trade.initial_stop_loss == 1.05
assert trade.initial_stop_loss_pct == 0.05
assert trade.stop_loss_pct == 0.1
@ -677,7 +677,7 @@ def test_adjust_stop_loss(fee):
@ pytest.mark.usefixtures("init_persistence")
@ pytest.mark.parametrize('use_db', [True, False])
def test_get_open(fee, use_db):
def test_get_open_short(fee, use_db):
Trade.use_db = use_db
Trade.reset_trades()
create_mock_trades_with_leverage(fee, use_db)
@ -685,7 +685,7 @@ def test_get_open(fee, use_db):
Trade.use_db = True
def test_stoploss_reinitialization(default_conf, fee):
def test_stoploss_reinitialization_short(default_conf, fee):
# TODO-mg: I don't understand this at all, I was just going in the opposite direction as the matching function form test_persistance.py
init_db(default_conf['db_url'])
trade = Trade(
@ -743,7 +743,7 @@ def test_stoploss_reinitialization(default_conf, fee):
@ pytest.mark.usefixtures("init_persistence")
@ pytest.mark.parametrize('use_db', [True, False])
def test_total_open_trades_stakes(fee, use_db):
def test_total_open_trades_stakes_short(fee, use_db):
Trade.use_db = use_db
Trade.reset_trades()
res = Trade.total_open_trades_stakes()
@ -755,7 +755,7 @@ def test_total_open_trades_stakes(fee, use_db):
@ pytest.mark.usefixtures("init_persistence")
def test_get_best_pair(fee):
def test_get_best_pair_short(fee):
res = Trade.get_best_pair()
assert res is None
create_mock_trades_with_leverage(fee)