2017-09-08 17:25:12 +00:00
|
|
|
from unittest.mock import patch
|
2017-09-08 13:51:00 +00:00
|
|
|
|
2017-09-28 21:26:28 +00:00
|
|
|
from freqtrade.exchange import Exchange
|
|
|
|
from freqtrade.persistence import Trade
|
2017-09-08 13:51:00 +00:00
|
|
|
|
|
|
|
|
2017-10-01 08:02:47 +00:00
|
|
|
def test_1_exec_sell_order():
|
|
|
|
with patch('freqtrade.main.exchange.sell', side_effect='mocked_order_id') as api_mock:
|
|
|
|
trade = Trade(
|
|
|
|
pair='BTC_ETH',
|
|
|
|
stake_amount=1.00,
|
|
|
|
open_rate=0.50,
|
|
|
|
amount=10.00,
|
|
|
|
exchange=Exchange.BITTREX,
|
|
|
|
open_order_id='mocked'
|
|
|
|
)
|
|
|
|
profit = trade.exec_sell_order(1.00, 10.00)
|
|
|
|
api_mock.assert_called_once_with('BTC_ETH', 1.0, 10.0)
|
|
|
|
assert profit == 100.0
|
|
|
|
assert trade.close_rate == 1.0
|
|
|
|
assert trade.close_profit == profit
|
|
|
|
assert trade.close_date is not None
|