Update tests to always provide rate to profit calculations
This commit is contained in:
parent
575b4ead1a
commit
76cae8e8e3
@ -852,8 +852,8 @@ def test_api_performance(botclient, fee):
|
|||||||
close_rate=0.265441,
|
close_rate=0.265441,
|
||||||
|
|
||||||
)
|
)
|
||||||
trade.close_profit = trade.calc_profit_ratio()
|
trade.close_profit = trade.calc_profit_ratio(trade.close_rate)
|
||||||
trade.close_profit_abs = trade.calc_profit()
|
trade.close_profit_abs = trade.calc_profit(trade.close_rate)
|
||||||
Trade.query.session.add(trade)
|
Trade.query.session.add(trade)
|
||||||
|
|
||||||
trade = Trade(
|
trade = Trade(
|
||||||
@ -868,8 +868,8 @@ def test_api_performance(botclient, fee):
|
|||||||
fee_open=fee.return_value,
|
fee_open=fee.return_value,
|
||||||
close_rate=0.391
|
close_rate=0.391
|
||||||
)
|
)
|
||||||
trade.close_profit = trade.calc_profit_ratio()
|
trade.close_profit = trade.calc_profit_ratio(trade.close_rate)
|
||||||
trade.close_profit_abs = trade.calc_profit()
|
trade.close_profit_abs = trade.calc_profit(trade.close_rate)
|
||||||
|
|
||||||
Trade.query.session.add(trade)
|
Trade.query.session.add(trade)
|
||||||
Trade.commit()
|
Trade.commit()
|
||||||
|
@ -2151,7 +2151,7 @@ def test_handle_trade(
|
|||||||
|
|
||||||
assert trade.close_rate == 2.0 if is_short else 2.2
|
assert trade.close_rate == 2.0 if is_short else 2.2
|
||||||
assert trade.close_profit == close_profit
|
assert trade.close_profit == close_profit
|
||||||
assert trade.calc_profit() == 5.685
|
assert trade.calc_profit(trade.close_rate) == 5.685
|
||||||
assert trade.close_date is not None
|
assert trade.close_date is not None
|
||||||
assert trade.exit_reason == 'sell_signal1'
|
assert trade.exit_reason == 'sell_signal1'
|
||||||
|
|
||||||
|
@ -606,9 +606,9 @@ def test_calc_open_close_trade_price(
|
|||||||
trade.close_rate = 2.2
|
trade.close_rate = 2.2
|
||||||
trade.recalc_open_trade_value()
|
trade.recalc_open_trade_value()
|
||||||
assert isclose(trade._calc_open_trade_value(), open_value)
|
assert isclose(trade._calc_open_trade_value(), open_value)
|
||||||
assert isclose(trade.calc_close_trade_value(), close_value)
|
assert isclose(trade.calc_close_trade_value(trade.close_rate), close_value)
|
||||||
assert isclose(trade.calc_profit(), round(profit, 8))
|
assert isclose(trade.calc_profit(trade.close_rate), round(profit, 8))
|
||||||
assert pytest.approx(trade.calc_profit_ratio()) == profit_ratio
|
assert pytest.approx(trade.calc_profit_ratio(trade.close_rate)) == profit_ratio
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.usefixtures("init_persistence")
|
@pytest.mark.usefixtures("init_persistence")
|
||||||
@ -660,7 +660,7 @@ def test_calc_close_trade_price_exception(limit_buy_order_usdt, fee):
|
|||||||
trade.open_order_id = 'something'
|
trade.open_order_id = 'something'
|
||||||
oobj = Order.parse_from_ccxt_object(limit_buy_order_usdt, 'ADA/USDT', 'buy')
|
oobj = Order.parse_from_ccxt_object(limit_buy_order_usdt, 'ADA/USDT', 'buy')
|
||||||
trade.update_trade(oobj)
|
trade.update_trade(oobj)
|
||||||
assert trade.calc_close_trade_value() == 0.0
|
assert trade.calc_close_trade_value(trade.close_rate) == 0.0
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.usefixtures("init_persistence")
|
@pytest.mark.usefixtures("init_persistence")
|
||||||
|
Loading…
Reference in New Issue
Block a user