Extend create_mock_trades to create 4 trades
2 closed, and 2 open trades
This commit is contained in:
parent
0f18b2a0d4
commit
8300eb59d4
@ -1089,7 +1089,7 @@ def test_show_trades(mocker, fee, capsys, caplog):
|
|||||||
pargs = get_args(args)
|
pargs = get_args(args)
|
||||||
pargs['config'] = None
|
pargs['config'] = None
|
||||||
start_show_trades(pargs)
|
start_show_trades(pargs)
|
||||||
assert log_has("Printing 3 Trades: ", caplog)
|
assert log_has("Printing 4 Trades: ", caplog)
|
||||||
captured = capsys.readouterr()
|
captured = capsys.readouterr()
|
||||||
assert "Trade(id=1" in captured.out
|
assert "Trade(id=1" in captured.out
|
||||||
assert "Trade(id=2" in captured.out
|
assert "Trade(id=2" in captured.out
|
||||||
|
@ -199,6 +199,20 @@ def create_mock_trades(fee):
|
|||||||
)
|
)
|
||||||
Trade.session.add(trade)
|
Trade.session.add(trade)
|
||||||
|
|
||||||
|
trade = Trade(
|
||||||
|
pair='XRP/BTC',
|
||||||
|
stake_amount=0.001,
|
||||||
|
amount=123.0,
|
||||||
|
fee_open=fee.return_value,
|
||||||
|
fee_close=fee.return_value,
|
||||||
|
open_rate=0.05,
|
||||||
|
close_rate=0.06,
|
||||||
|
close_profit=0.01,
|
||||||
|
exchange='bittrex',
|
||||||
|
is_open=False,
|
||||||
|
)
|
||||||
|
Trade.session.add(trade)
|
||||||
|
|
||||||
# Simulate prod entry
|
# Simulate prod entry
|
||||||
trade = Trade(
|
trade = Trade(
|
||||||
pair='ETC/BTC',
|
pair='ETC/BTC',
|
||||||
|
@ -43,7 +43,7 @@ def test_load_trades_from_db(default_conf, fee, mocker):
|
|||||||
|
|
||||||
trades = load_trades_from_db(db_url=default_conf['db_url'])
|
trades = load_trades_from_db(db_url=default_conf['db_url'])
|
||||||
assert init_mock.call_count == 1
|
assert init_mock.call_count == 1
|
||||||
assert len(trades) == 3
|
assert len(trades) == 4
|
||||||
assert isinstance(trades, DataFrame)
|
assert isinstance(trades, DataFrame)
|
||||||
assert "pair" in trades.columns
|
assert "pair" in trades.columns
|
||||||
assert "open_time" in trades.columns
|
assert "open_time" in trades.columns
|
||||||
|
@ -4090,7 +4090,7 @@ def test_cancel_all_open_orders(mocker, default_conf, fee, limit_buy_order, limi
|
|||||||
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
||||||
create_mock_trades(fee)
|
create_mock_trades(fee)
|
||||||
trades = Trade.query.all()
|
trades = Trade.query.all()
|
||||||
assert len(trades) == 3
|
assert len(trades) == 4
|
||||||
freqtrade.cancel_all_open_orders()
|
freqtrade.cancel_all_open_orders()
|
||||||
assert buy_mock.call_count == 1
|
assert buy_mock.call_count == 1
|
||||||
assert sell_mock.call_count == 1
|
assert sell_mock.call_count == 1
|
||||||
|
@ -989,7 +989,7 @@ def test_get_overall_performance(fee):
|
|||||||
create_mock_trades(fee)
|
create_mock_trades(fee)
|
||||||
res = Trade.get_overall_performance()
|
res = Trade.get_overall_performance()
|
||||||
|
|
||||||
assert len(res) == 1
|
assert len(res) == 2
|
||||||
assert 'pair' in res[0]
|
assert 'pair' in res[0]
|
||||||
assert 'profit' in res[0]
|
assert 'profit' in res[0]
|
||||||
assert 'count' in res[0]
|
assert 'count' in res[0]
|
||||||
@ -1004,5 +1004,5 @@ def test_get_best_pair(fee):
|
|||||||
create_mock_trades(fee)
|
create_mock_trades(fee)
|
||||||
res = Trade.get_best_pair()
|
res = Trade.get_best_pair()
|
||||||
assert len(res) == 2
|
assert len(res) == 2
|
||||||
assert res[0] == 'ETC/BTC'
|
assert res[0] == 'XRP/BTC'
|
||||||
assert res[1] == 0.005
|
assert res[1] == 0.01
|
||||||
|
Loading…
Reference in New Issue
Block a user