mirror of
https://github.com/freqtrade/freqtrade.git
synced 2026-04-28 21:10:12 +00:00
add calc_profit_combined call
This commit is contained in:
@@ -1152,14 +1152,29 @@ def test_calc_profit(
|
||||
leverage=lev,
|
||||
fee_open=0.0025,
|
||||
fee_close=fee_close,
|
||||
max_stake_amount=60.0,
|
||||
trading_mode=trading_mode,
|
||||
funding_fees=funding_fees
|
||||
)
|
||||
trade.open_order_id = 'something'
|
||||
|
||||
profit_res = trade.calc_profit_combined(close_rate)
|
||||
assert pytest.approx(profit_res['profit_abs']) == round(profit, 8)
|
||||
assert pytest.approx(profit_res['profit_ratio']) == round(profit_ratio, 8)
|
||||
|
||||
assert pytest.approx(profit_res['total_profit']) == round(profit, 8)
|
||||
# assert pytest.approx(profit_res['total_profit_ratio']) == round(profit_ratio, 8)
|
||||
|
||||
assert pytest.approx(trade.calc_profit(rate=close_rate)) == round(profit, 8)
|
||||
assert pytest.approx(trade.calc_profit_ratio(rate=close_rate)) == round(profit_ratio, 8)
|
||||
|
||||
profit_res2 = trade.calc_profit_combined(close_rate, trade.amount, trade.open_rate)
|
||||
assert pytest.approx(profit_res2['profit_abs']) == round(profit, 8)
|
||||
assert pytest.approx(profit_res2['profit_ratio']) == round(profit_ratio, 8)
|
||||
|
||||
assert pytest.approx(profit_res2['total_profit']) == round(profit, 8)
|
||||
# assert pytest.approx(profit_res2['total_profit_ratio']) == round(profit_ratio, 8)
|
||||
|
||||
assert pytest.approx(trade.calc_profit(close_rate, trade.amount,
|
||||
trade.open_rate)) == round(profit, 8)
|
||||
assert pytest.approx(trade.calc_profit_ratio(close_rate, trade.amount,
|
||||
|
||||
Reference in New Issue
Block a user