plot-profit should use absolute values
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from math import isclose
|
||||
from pathlib import Path
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
@@ -246,7 +247,7 @@ def test_create_cum_profit(testdatadir):
|
||||
"cum_profits", timeframe="5m")
|
||||
assert "cum_profits" in cum_profits.columns
|
||||
assert cum_profits.iloc[0]['cum_profits'] == 0
|
||||
assert cum_profits.iloc[-1]['cum_profits'] == 0.0798005
|
||||
assert isclose(cum_profits.iloc[-1]['cum_profits'], 8.723007518796964e-06)
|
||||
|
||||
|
||||
def test_create_cum_profit1(testdatadir):
|
||||
@@ -264,7 +265,7 @@ def test_create_cum_profit1(testdatadir):
|
||||
"cum_profits", timeframe="5m")
|
||||
assert "cum_profits" in cum_profits.columns
|
||||
assert cum_profits.iloc[0]['cum_profits'] == 0
|
||||
assert cum_profits.iloc[-1]['cum_profits'] == 0.0798005
|
||||
assert isclose(cum_profits.iloc[-1]['cum_profits'], 8.723007518796964e-06)
|
||||
|
||||
with pytest.raises(ValueError, match='Trade dataframe empty.'):
|
||||
create_cum_profit(df.set_index('date'), bt_data[bt_data["pair"] == 'NOTAPAIR'],
|
||||
|
@@ -331,13 +331,13 @@ def test_generate_profit_graph(testdatadir):
|
||||
|
||||
trades = trades[trades['pair'].isin(pairs)]
|
||||
|
||||
fig = generate_profit_graph(pairs, data, trades, timeframe="5m")
|
||||
fig = generate_profit_graph(pairs, data, trades, timeframe="5m", stake_currency='BTC')
|
||||
assert isinstance(fig, go.Figure)
|
||||
|
||||
assert fig.layout.title.text == "Freqtrade Profit plot"
|
||||
assert fig.layout.yaxis.title.text == "Price"
|
||||
assert fig.layout.yaxis2.title.text == "Profit"
|
||||
assert fig.layout.yaxis3.title.text == "Profit"
|
||||
assert fig.layout.yaxis2.title.text == "Profit BTC"
|
||||
assert fig.layout.yaxis3.title.text == "Profit BTC"
|
||||
|
||||
figure = fig.layout.figure
|
||||
assert len(figure.data) == 5
|
||||
@@ -356,7 +356,8 @@ def test_generate_profit_graph(testdatadir):
|
||||
|
||||
with pytest.raises(OperationalException, match=r"No trades found.*"):
|
||||
# Pair cannot be empty - so it's an empty dataframe.
|
||||
generate_profit_graph(pairs, data, trades.loc[trades['pair'].isnull()], timeframe="5m")
|
||||
generate_profit_graph(pairs, data, trades.loc[trades['pair'].isnull()], timeframe="5m",
|
||||
stake_currency='BTC')
|
||||
|
||||
|
||||
def test_start_plot_dataframe(mocker):
|
||||
|
Reference in New Issue
Block a user