Merge pull request #545 from xmatthias/ccxt_tests_pr1
Fix some tests for ccxt branch
This commit is contained in:
commit
a90e90f577
@ -103,32 +103,40 @@ def ticker_sell_down():
|
|||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def health():
|
def health():
|
||||||
return MagicMock(return_value=[{
|
return MagicMock(return_value={
|
||||||
'Currency': 'BTC',
|
'ETH/BTC': {
|
||||||
'IsActive': True,
|
'Currency': 'BTC',
|
||||||
'LastChecked': '2017-11-13T20:15:00.00',
|
'base': 'ETH',
|
||||||
'Notice': None
|
'quote': 'BTC',
|
||||||
}, {
|
'active': True,
|
||||||
'Currency': 'ETH',
|
'LastChecked': '2017-11-13T20:15:00.00',
|
||||||
'IsActive': True,
|
'Notice': None
|
||||||
'LastChecked': '2017-11-13T20:15:00.00',
|
},
|
||||||
'Notice': None
|
'TRST/BTC': {
|
||||||
}, {
|
'Currency': 'TRST',
|
||||||
'Currency': 'TRST',
|
'base': 'TRST',
|
||||||
'IsActive': True,
|
'quote': 'BTC',
|
||||||
'LastChecked': '2017-11-13T20:15:00.00',
|
'active': True,
|
||||||
'Notice': None
|
'LastChecked': '2017-11-13T20:15:00.00',
|
||||||
}, {
|
'Notice': None
|
||||||
'Currency': 'SWT',
|
},
|
||||||
'IsActive': True,
|
'SWT/BTC': {
|
||||||
'LastChecked': '2017-11-13T20:15:00.00',
|
'Currency': 'SWT',
|
||||||
'Notice': None
|
'base': 'SWT',
|
||||||
}, {
|
'quote': 'BTC',
|
||||||
'Currency': 'BCC',
|
'active': True,
|
||||||
'IsActive': False,
|
'LastChecked': '2017-11-13T20:15:00.00',
|
||||||
'LastChecked': '2017-11-13T20:15:00.00',
|
'Notice': None
|
||||||
'Notice': None
|
},
|
||||||
}])
|
'BCC/BTC': {
|
||||||
|
'Currency': 'BCC',
|
||||||
|
'base': 'BCC',
|
||||||
|
'quote': 'BTC',
|
||||||
|
'active': False,
|
||||||
|
'LastChecked': '2017-11-13T20:15:00.00',
|
||||||
|
'Notice': None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
@ -150,7 +158,7 @@ def limit_buy_order_old():
|
|||||||
return {
|
return {
|
||||||
'id': 'mocked_limit_buy_old',
|
'id': 'mocked_limit_buy_old',
|
||||||
'type': 'LIMIT_BUY',
|
'type': 'LIMIT_BUY',
|
||||||
'pair': 'BTC_ETH',
|
'pair': 'ETH/BTC',
|
||||||
'opened': str(arrow.utcnow().shift(minutes=-601).datetime),
|
'opened': str(arrow.utcnow().shift(minutes=-601).datetime),
|
||||||
'rate': 0.00001099,
|
'rate': 0.00001099,
|
||||||
'amount': 90.99181073,
|
'amount': 90.99181073,
|
||||||
@ -163,7 +171,7 @@ def limit_sell_order_old():
|
|||||||
return {
|
return {
|
||||||
'id': 'mocked_limit_sell_old',
|
'id': 'mocked_limit_sell_old',
|
||||||
'type': 'LIMIT_SELL',
|
'type': 'LIMIT_SELL',
|
||||||
'pair': 'BTC_ETH',
|
'pair': 'ETH/BTC',
|
||||||
'opened': str(arrow.utcnow().shift(minutes=-601).datetime),
|
'opened': str(arrow.utcnow().shift(minutes=-601).datetime),
|
||||||
'rate': 0.00001099,
|
'rate': 0.00001099,
|
||||||
'amount': 90.99181073,
|
'amount': 90.99181073,
|
||||||
@ -176,7 +184,7 @@ def limit_buy_order_old_partial():
|
|||||||
return {
|
return {
|
||||||
'id': 'mocked_limit_buy_old_partial',
|
'id': 'mocked_limit_buy_old_partial',
|
||||||
'type': 'LIMIT_BUY',
|
'type': 'LIMIT_BUY',
|
||||||
'pair': 'BTC_ETH',
|
'pair': 'ETH/BTC',
|
||||||
'opened': str(arrow.utcnow().shift(minutes=-601).datetime),
|
'opened': str(arrow.utcnow().shift(minutes=-601).datetime),
|
||||||
'rate': 0.00001099,
|
'rate': 0.00001099,
|
||||||
'amount': 90.99181073,
|
'amount': 90.99181073,
|
||||||
|
@ -108,7 +108,7 @@ def test_status_handle(default_conf, update, ticker, mocker):
|
|||||||
_status(bot=MagicMock(), update=update)
|
_status(bot=MagicMock(), update=update)
|
||||||
|
|
||||||
assert msg_mock.call_count == 1
|
assert msg_mock.call_count == 1
|
||||||
assert '[BTC_ETH]' in msg_mock.call_args_list[0][0][0]
|
assert '[ETH/BTC]' in msg_mock.call_args_list[0][0][0]
|
||||||
|
|
||||||
|
|
||||||
def test_status_table_handle(default_conf, update, ticker, mocker):
|
def test_status_table_handle(default_conf, update, ticker, mocker):
|
||||||
@ -148,7 +148,7 @@ def test_status_table_handle(default_conf, update, ticker, mocker):
|
|||||||
fields = re.sub('[ ]+', ' ', line[2].strip()).split(' ')
|
fields = re.sub('[ ]+', ' ', line[2].strip()).split(' ')
|
||||||
|
|
||||||
assert int(fields[0]) == 1
|
assert int(fields[0]) == 1
|
||||||
assert fields[1] == 'BTC_ETH'
|
assert fields[1] == 'ETH/BTC'
|
||||||
assert msg_mock.call_count == 1
|
assert msg_mock.call_count == 1
|
||||||
|
|
||||||
|
|
||||||
@ -206,7 +206,7 @@ def test_profit_handle(
|
|||||||
assert '∙ `0.00006217 BTC (6.20%)`' in msg_mock.call_args_list[-1][0][0]
|
assert '∙ `0.00006217 BTC (6.20%)`' in msg_mock.call_args_list[-1][0][0]
|
||||||
assert '∙ `0.933 USD`' in msg_mock.call_args_list[-1][0][0]
|
assert '∙ `0.933 USD`' in msg_mock.call_args_list[-1][0][0]
|
||||||
|
|
||||||
assert '*Best Performing:* `BTC_ETH: 6.20%`' in msg_mock.call_args_list[-1][0][0]
|
assert '*Best Performing:* `ETH/BTC: 6.20%`' in msg_mock.call_args_list[-1][0][0]
|
||||||
|
|
||||||
|
|
||||||
def test_forcesell_handle(default_conf, update, ticker, ticker_sell_up, mocker):
|
def test_forcesell_handle(default_conf, update, ticker, ticker_sell_up, mocker):
|
||||||
@ -239,7 +239,7 @@ def test_forcesell_handle(default_conf, update, ticker, ticker_sell_up, mocker):
|
|||||||
|
|
||||||
assert rpc_mock.call_count == 2
|
assert rpc_mock.call_count == 2
|
||||||
assert 'Selling' in rpc_mock.call_args_list[-1][0][0]
|
assert 'Selling' in rpc_mock.call_args_list[-1][0][0]
|
||||||
assert '[BTC_ETH]' in rpc_mock.call_args_list[-1][0][0]
|
assert '[ETH/BTC]' in rpc_mock.call_args_list[-1][0][0]
|
||||||
assert 'Amount' in rpc_mock.call_args_list[-1][0][0]
|
assert 'Amount' in rpc_mock.call_args_list[-1][0][0]
|
||||||
assert '0.00001172' in rpc_mock.call_args_list[-1][0][0]
|
assert '0.00001172' in rpc_mock.call_args_list[-1][0][0]
|
||||||
assert 'profit: 6.11%, 0.00006126' in rpc_mock.call_args_list[-1][0][0]
|
assert 'profit: 6.11%, 0.00006126' in rpc_mock.call_args_list[-1][0][0]
|
||||||
@ -276,7 +276,7 @@ def test_forcesell_down_handle(default_conf, update, ticker, ticker_sell_down, m
|
|||||||
|
|
||||||
assert rpc_mock.call_count == 2
|
assert rpc_mock.call_count == 2
|
||||||
assert 'Selling' in rpc_mock.call_args_list[-1][0][0]
|
assert 'Selling' in rpc_mock.call_args_list[-1][0][0]
|
||||||
assert '[BTC_ETH]' in rpc_mock.call_args_list[-1][0][0]
|
assert '[ETH/BTC]' in rpc_mock.call_args_list[-1][0][0]
|
||||||
assert 'Amount' in rpc_mock.call_args_list[-1][0][0]
|
assert 'Amount' in rpc_mock.call_args_list[-1][0][0]
|
||||||
assert '0.00001044' in rpc_mock.call_args_list[-1][0][0]
|
assert '0.00001044' in rpc_mock.call_args_list[-1][0][0]
|
||||||
assert 'loss: -5.48%, -0.00005492' in rpc_mock.call_args_list[-1][0][0]
|
assert 'loss: -5.48%, -0.00005492' in rpc_mock.call_args_list[-1][0][0]
|
||||||
@ -294,7 +294,7 @@ def test_exec_forcesell_open_orders(default_conf, ticker, mocker):
|
|||||||
}),
|
}),
|
||||||
cancel_order=cancel_order_mock)
|
cancel_order=cancel_order_mock)
|
||||||
trade = Trade(
|
trade = Trade(
|
||||||
pair='BTC_ETH',
|
pair='ETH/BTC',
|
||||||
open_rate=1,
|
open_rate=1,
|
||||||
exchange='BITTREX',
|
exchange='BITTREX',
|
||||||
open_order_id='123456789',
|
open_order_id='123456789',
|
||||||
@ -403,7 +403,7 @@ def test_performance_handle(
|
|||||||
_performance(bot=MagicMock(), update=update)
|
_performance(bot=MagicMock(), update=update)
|
||||||
assert msg_mock.call_count == 1
|
assert msg_mock.call_count == 1
|
||||||
assert 'Performance' in msg_mock.call_args_list[0][0][0]
|
assert 'Performance' in msg_mock.call_args_list[0][0][0]
|
||||||
assert '<code>BTC_ETH\t6.20% (1)</code>' in msg_mock.call_args_list[0][0][0]
|
assert '<code>ETH/BTC\t6.20% (1)</code>' in msg_mock.call_args_list[0][0][0]
|
||||||
|
|
||||||
|
|
||||||
def test_daily_handle(default_conf, update, ticker, limit_buy_order, limit_sell_order, mocker):
|
def test_daily_handle(default_conf, update, ticker, limit_buy_order, limit_sell_order, mocker):
|
||||||
|
@ -12,22 +12,23 @@ def whitelist_conf():
|
|||||||
'stake_currency': 'BTC',
|
'stake_currency': 'BTC',
|
||||||
'exchange': {
|
'exchange': {
|
||||||
'pair_whitelist': [
|
'pair_whitelist': [
|
||||||
'BTC_ETH',
|
'ETH/BTC',
|
||||||
'BTC_TKN',
|
'TKN/BTC',
|
||||||
'BTC_TRST',
|
'TRST/BTC',
|
||||||
'BTC_SWT',
|
'SWT/BTC',
|
||||||
'BTC_BCC'
|
'BCC/BTC'
|
||||||
],
|
],
|
||||||
'pair_blacklist': [
|
'pair_blacklist': [
|
||||||
'BTC_BLK'
|
'BLK/BTC'
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def get_market_summaries():
|
def get_market_summaries():
|
||||||
return [{
|
return {'TKN/BTC': {
|
||||||
'MarketName': 'BTC-TKN',
|
'symbol': 'TKN/BTC',
|
||||||
|
'MarketName': 'TKN/BTC',
|
||||||
'High': 0.00000919,
|
'High': 0.00000919,
|
||||||
'Low': 0.00000820,
|
'Low': 0.00000820,
|
||||||
'Volume': 74339.61396015,
|
'Volume': 74339.61396015,
|
||||||
@ -40,9 +41,11 @@ def get_market_summaries():
|
|||||||
'OpenSellOrders': 15,
|
'OpenSellOrders': 15,
|
||||||
'PrevDay': 0.00000821,
|
'PrevDay': 0.00000821,
|
||||||
'Created': '2014-03-20T06:00:00',
|
'Created': '2014-03-20T06:00:00',
|
||||||
'DisplayMarketName': ''
|
'DisplayMarketName': '',
|
||||||
}, {
|
'info': {},
|
||||||
'MarketName': 'BTC-ETH',
|
}, 'ETH/BTC': {
|
||||||
|
'symbol': 'ETH/BTC',
|
||||||
|
'MarketName': 'ETH/BTC',
|
||||||
'High': 0.00000072,
|
'High': 0.00000072,
|
||||||
'Low': 0.00000001,
|
'Low': 0.00000001,
|
||||||
'Volume': 166340678.42280999,
|
'Volume': 166340678.42280999,
|
||||||
@ -55,9 +58,11 @@ def get_market_summaries():
|
|||||||
'OpenSellOrders': 18,
|
'OpenSellOrders': 18,
|
||||||
'PrevDay': 0.00000002,
|
'PrevDay': 0.00000002,
|
||||||
'Created': '2014-05-30T07:57:49.637',
|
'Created': '2014-05-30T07:57:49.637',
|
||||||
'DisplayMarketName': ''
|
'DisplayMarketName': '',
|
||||||
}, {
|
'info': {},
|
||||||
'MarketName': 'BTC-BLK',
|
}, 'BLK/BTC': {
|
||||||
|
'symbol': 'BLK/BTC',
|
||||||
|
'MarketName': 'BLK/BTC',
|
||||||
'High': 0.00000072,
|
'High': 0.00000072,
|
||||||
'Low': 0.00000001,
|
'Low': 0.00000001,
|
||||||
'Volume': 166340678.42280999,
|
'Volume': 166340678.42280999,
|
||||||
@ -70,18 +75,21 @@ def get_market_summaries():
|
|||||||
'OpenSellOrders': 18,
|
'OpenSellOrders': 18,
|
||||||
'PrevDay': 0.00000002,
|
'PrevDay': 0.00000002,
|
||||||
'Created': '2014-05-30T07:57:49.637',
|
'Created': '2014-05-30T07:57:49.637',
|
||||||
'DisplayMarketName': ''
|
'DisplayMarketName': '',
|
||||||
}]
|
'info': {},
|
||||||
|
}}
|
||||||
|
|
||||||
|
|
||||||
def get_health():
|
def get_health():
|
||||||
return [{'Currency': 'ETH', 'IsActive': True},
|
return {
|
||||||
{'Currency': 'TKN', 'IsActive': True},
|
'ETH/BTC': {'Currency': 'ETH', 'base': 'ETH', 'quote': 'BTC', 'active': True},
|
||||||
{'Currency': 'BLK', 'IsActive': True}]
|
'TKN/BTC': {'Currency': 'TKN', 'base': 'TKN', 'quote': 'BTC', 'active': True},
|
||||||
|
'BLK/BTC': {'Currency': 'BLK', 'base': 'BLK', 'quote': 'BTC', 'active': True}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def get_health_empty():
|
def get_health_empty():
|
||||||
return []
|
return {}
|
||||||
|
|
||||||
|
|
||||||
def test_refresh_market_pair_not_in_whitelist(mocker):
|
def test_refresh_market_pair_not_in_whitelist(mocker):
|
||||||
@ -90,9 +98,9 @@ def test_refresh_market_pair_not_in_whitelist(mocker):
|
|||||||
mocker.patch.multiple('freqtrade.main.exchange',
|
mocker.patch.multiple('freqtrade.main.exchange',
|
||||||
get_wallet_health=get_health)
|
get_wallet_health=get_health)
|
||||||
refreshedwhitelist = refresh_whitelist(
|
refreshedwhitelist = refresh_whitelist(
|
||||||
conf['exchange']['pair_whitelist'] + ['BTC_XXX'])
|
conf['exchange']['pair_whitelist'] + ['XXX/BTC'])
|
||||||
# List ordered by BaseVolume
|
# List ordered by BaseVolume
|
||||||
whitelist = ['BTC_ETH', 'BTC_TKN']
|
whitelist = ['ETH/BTC', 'TKN/BTC']
|
||||||
# Ensure all except those in whitelist are removed
|
# Ensure all except those in whitelist are removed
|
||||||
assert whitelist == refreshedwhitelist
|
assert whitelist == refreshedwhitelist
|
||||||
|
|
||||||
@ -104,7 +112,7 @@ def test_refresh_whitelist(mocker):
|
|||||||
get_wallet_health=get_health)
|
get_wallet_health=get_health)
|
||||||
refreshedwhitelist = refresh_whitelist(conf['exchange']['pair_whitelist'])
|
refreshedwhitelist = refresh_whitelist(conf['exchange']['pair_whitelist'])
|
||||||
# List ordered by BaseVolume
|
# List ordered by BaseVolume
|
||||||
whitelist = ['BTC_ETH', 'BTC_TKN']
|
whitelist = ['ETH/BTC', 'TKN/BTC']
|
||||||
# Ensure all except those in whitelist are removed
|
# Ensure all except those in whitelist are removed
|
||||||
assert whitelist == refreshedwhitelist
|
assert whitelist == refreshedwhitelist
|
||||||
|
|
||||||
@ -117,7 +125,7 @@ def test_refresh_whitelist_dynamic(mocker):
|
|||||||
mocker.patch.multiple('freqtrade.main.exchange',
|
mocker.patch.multiple('freqtrade.main.exchange',
|
||||||
get_market_summaries=get_market_summaries)
|
get_market_summaries=get_market_summaries)
|
||||||
# argument: use the whitelist dynamically by exchange-volume
|
# argument: use the whitelist dynamically by exchange-volume
|
||||||
whitelist = ['BTC_TKN', 'BTC_ETH']
|
whitelist = ['TKN/BTC', 'ETH/BTC']
|
||||||
refreshedwhitelist = refresh_whitelist(
|
refreshedwhitelist = refresh_whitelist(
|
||||||
gen_pair_whitelist(conf['stake_currency']))
|
gen_pair_whitelist(conf['stake_currency']))
|
||||||
assert whitelist == refreshedwhitelist
|
assert whitelist == refreshedwhitelist
|
||||||
|
@ -113,7 +113,7 @@ def test_get_signal_handles_exceptions(mocker):
|
|||||||
|
|
||||||
def test_parse_ticker_dataframe(ticker_history, ticker_history_without_bv):
|
def test_parse_ticker_dataframe(ticker_history, ticker_history_without_bv):
|
||||||
|
|
||||||
columns = ['close', 'high', 'low', 'open', 'date', 'volume']
|
columns = ['date', 'open', 'high', 'low', 'close', 'volume']
|
||||||
|
|
||||||
# Test file with BV data
|
# Test file with BV data
|
||||||
dataframe = parse_ticker_dataframe(ticker_history)
|
dataframe = parse_ticker_dataframe(ticker_history)
|
||||||
|
@ -4,7 +4,7 @@ import pandas
|
|||||||
import freqtrade.optimize
|
import freqtrade.optimize
|
||||||
from freqtrade import analyze
|
from freqtrade import analyze
|
||||||
|
|
||||||
_pairs = ['BTC_ETH']
|
_pairs = ['ETH/BTC']
|
||||||
|
|
||||||
|
|
||||||
def load_dataframe_pair(pairs):
|
def load_dataframe_pair(pairs):
|
||||||
|
@ -11,7 +11,7 @@ from sqlalchemy import create_engine
|
|||||||
import freqtrade.main as main
|
import freqtrade.main as main
|
||||||
import freqtrade.tests.conftest as tt # test tools
|
import freqtrade.tests.conftest as tt # test tools
|
||||||
from freqtrade import DependencyException, OperationalException
|
from freqtrade import DependencyException, OperationalException
|
||||||
from freqtrade.exchange import Exchanges
|
import freqtrade.exchange as exchange
|
||||||
from freqtrade.main import (_process, check_handle_timedout, create_trade,
|
from freqtrade.main import (_process, check_handle_timedout, create_trade,
|
||||||
execute_sell, get_target_bid, handle_trade, init)
|
execute_sell, get_target_bid, handle_trade, init)
|
||||||
from freqtrade.misc import State, get_state
|
from freqtrade.misc import State, get_state
|
||||||
@ -100,7 +100,7 @@ def test_process_trade_creation(default_conf, ticker, limit_buy_order, health, m
|
|||||||
assert trade.stake_amount == default_conf['stake_amount']
|
assert trade.stake_amount == default_conf['stake_amount']
|
||||||
assert trade.is_open
|
assert trade.is_open
|
||||||
assert trade.open_date is not None
|
assert trade.open_date is not None
|
||||||
assert trade.exchange == Exchanges.BITTREX.name
|
assert trade.exchange == 'BITTREX'
|
||||||
assert trade.open_rate == 0.00001099
|
assert trade.open_rate == 0.00001099
|
||||||
assert trade.amount == 90.99181073703367
|
assert trade.amount == 90.99181073703367
|
||||||
|
|
||||||
@ -174,15 +174,18 @@ def test_create_trade(default_conf, ticker, limit_buy_order, mocker):
|
|||||||
# Save state of current whitelist
|
# Save state of current whitelist
|
||||||
whitelist = copy.deepcopy(default_conf['exchange']['pair_whitelist'])
|
whitelist = copy.deepcopy(default_conf['exchange']['pair_whitelist'])
|
||||||
|
|
||||||
|
exchange.init(default_conf)
|
||||||
|
|
||||||
init(default_conf, create_engine('sqlite://'))
|
init(default_conf, create_engine('sqlite://'))
|
||||||
create_trade(0.001, int(default_conf['ticker_interval']))
|
create_trade(0.001, int(default_conf['ticker_interval']))
|
||||||
|
|
||||||
trade = Trade.query.first()
|
trade = Trade.query.first()
|
||||||
|
|
||||||
assert trade is not None
|
assert trade is not None
|
||||||
assert trade.stake_amount == 0.001
|
assert trade.stake_amount == 0.001
|
||||||
assert trade.is_open
|
assert trade.is_open
|
||||||
assert trade.open_date is not None
|
assert trade.open_date is not None
|
||||||
assert trade.exchange == Exchanges.BITTREX.name
|
assert trade.exchange == exchange.get_name().upper()
|
||||||
|
|
||||||
# Simulate fulfilled LIMIT_BUY order for trade
|
# Simulate fulfilled LIMIT_BUY order for trade
|
||||||
trade.update(limit_buy_order)
|
trade.update(limit_buy_order)
|
||||||
@ -250,8 +253,8 @@ def test_create_trade_no_pairs_after_blacklist(default_conf, ticker, mocker):
|
|||||||
|
|
||||||
with pytest.raises(DependencyException, match=r'.*No pair in whitelist.*'):
|
with pytest.raises(DependencyException, match=r'.*No pair in whitelist.*'):
|
||||||
conf = copy.deepcopy(default_conf)
|
conf = copy.deepcopy(default_conf)
|
||||||
conf['exchange']['pair_whitelist'] = ["BTC_ETH"]
|
conf['exchange']['pair_whitelist'] = ["ETH/BTC"]
|
||||||
conf['exchange']['pair_blacklist'] = ["BTC_ETH"]
|
conf['exchange']['pair_blacklist'] = ["ETH/BTC"]
|
||||||
mocker.patch.dict('freqtrade.main._CONF', conf)
|
mocker.patch.dict('freqtrade.main._CONF', conf)
|
||||||
create_trade(default_conf['stake_amount'], int(default_conf['ticker_interval']))
|
create_trade(default_conf['stake_amount'], int(default_conf['ticker_interval']))
|
||||||
|
|
||||||
@ -454,7 +457,7 @@ def test_check_handle_timedout_buy(default_conf, ticker, limit_buy_order_old, mo
|
|||||||
init(default_conf, create_engine('sqlite://'))
|
init(default_conf, create_engine('sqlite://'))
|
||||||
|
|
||||||
trade_buy = Trade(
|
trade_buy = Trade(
|
||||||
pair='BTC_ETH',
|
pair='ETH/BTC',
|
||||||
open_rate=0.00001099,
|
open_rate=0.00001099,
|
||||||
exchange='BITTREX',
|
exchange='BITTREX',
|
||||||
open_order_id='123456789',
|
open_order_id='123456789',
|
||||||
@ -503,7 +506,7 @@ def test_check_handle_timedout_sell(default_conf, ticker, limit_sell_order_old,
|
|||||||
init(default_conf, create_engine('sqlite://'))
|
init(default_conf, create_engine('sqlite://'))
|
||||||
|
|
||||||
trade_sell = Trade(
|
trade_sell = Trade(
|
||||||
pair='BTC_ETH',
|
pair='ETH/BTC',
|
||||||
open_rate=0.00001099,
|
open_rate=0.00001099,
|
||||||
exchange='BITTREX',
|
exchange='BITTREX',
|
||||||
open_order_id='123456789',
|
open_order_id='123456789',
|
||||||
@ -552,7 +555,7 @@ def test_check_handle_timedout_partial(default_conf, ticker, limit_buy_order_old
|
|||||||
init(default_conf, create_engine('sqlite://'))
|
init(default_conf, create_engine('sqlite://'))
|
||||||
|
|
||||||
trade_buy = Trade(
|
trade_buy = Trade(
|
||||||
pair='BTC_ETH',
|
pair='ETH/BTC',
|
||||||
open_rate=0.00001099,
|
open_rate=0.00001099,
|
||||||
exchange='BITTREX',
|
exchange='BITTREX',
|
||||||
open_order_id='123456789',
|
open_order_id='123456789',
|
||||||
@ -617,7 +620,7 @@ def test_execute_sell_up(default_conf, ticker, ticker_sell_up, mocker):
|
|||||||
|
|
||||||
assert rpc_mock.call_count == 2
|
assert rpc_mock.call_count == 2
|
||||||
assert 'Selling' in rpc_mock.call_args_list[-1][0][0]
|
assert 'Selling' in rpc_mock.call_args_list[-1][0][0]
|
||||||
assert '[BTC_ETH]' in rpc_mock.call_args_list[-1][0][0]
|
assert '[ETH/BTC]' in rpc_mock.call_args_list[-1][0][0]
|
||||||
assert 'Amount' in rpc_mock.call_args_list[-1][0][0]
|
assert 'Amount' in rpc_mock.call_args_list[-1][0][0]
|
||||||
assert 'Profit' in rpc_mock.call_args_list[-1][0][0]
|
assert 'Profit' in rpc_mock.call_args_list[-1][0][0]
|
||||||
assert '0.00001172' in rpc_mock.call_args_list[-1][0][0]
|
assert '0.00001172' in rpc_mock.call_args_list[-1][0][0]
|
||||||
@ -655,7 +658,7 @@ def test_execute_sell_down(default_conf, ticker, ticker_sell_down, mocker):
|
|||||||
|
|
||||||
assert rpc_mock.call_count == 2
|
assert rpc_mock.call_count == 2
|
||||||
assert 'Selling' in rpc_mock.call_args_list[-1][0][0]
|
assert 'Selling' in rpc_mock.call_args_list[-1][0][0]
|
||||||
assert '[BTC_ETH]' in rpc_mock.call_args_list[-1][0][0]
|
assert '[ETH/BTC]' in rpc_mock.call_args_list[-1][0][0]
|
||||||
assert 'Amount' in rpc_mock.call_args_list[-1][0][0]
|
assert 'Amount' in rpc_mock.call_args_list[-1][0][0]
|
||||||
assert '0.00001044' in rpc_mock.call_args_list[-1][0][0]
|
assert '0.00001044' in rpc_mock.call_args_list[-1][0][0]
|
||||||
assert 'loss: -5.48%, -0.00005492' in rpc_mock.call_args_list[-1][0][0]
|
assert 'loss: -5.48%, -0.00005492' in rpc_mock.call_args_list[-1][0][0]
|
||||||
@ -688,7 +691,7 @@ def test_execute_sell_without_conf_sell_down(default_conf, ticker, ticker_sell_d
|
|||||||
|
|
||||||
assert rpc_mock.call_count == 2
|
assert rpc_mock.call_count == 2
|
||||||
assert 'Selling' in rpc_mock.call_args_list[-1][0][0]
|
assert 'Selling' in rpc_mock.call_args_list[-1][0][0]
|
||||||
assert '[BTC_ETH]' in rpc_mock.call_args_list[-1][0][0]
|
assert '[ETH/BTC]' in rpc_mock.call_args_list[-1][0][0]
|
||||||
assert '0.00001044' in rpc_mock.call_args_list[-1][0][0]
|
assert '0.00001044' in rpc_mock.call_args_list[-1][0][0]
|
||||||
assert 'loss: -5.48%, -0.00005492' in rpc_mock.call_args_list[-1][0][0]
|
assert 'loss: -5.48%, -0.00005492' in rpc_mock.call_args_list[-1][0][0]
|
||||||
|
|
||||||
@ -719,7 +722,7 @@ def test_execute_sell_without_conf_sell_up(default_conf, ticker, ticker_sell_up,
|
|||||||
|
|
||||||
assert rpc_mock.call_count == 2
|
assert rpc_mock.call_count == 2
|
||||||
assert 'Selling' in rpc_mock.call_args_list[-1][0][0]
|
assert 'Selling' in rpc_mock.call_args_list[-1][0][0]
|
||||||
assert '[BTC_ETH]' in rpc_mock.call_args_list[-1][0][0]
|
assert '[ETH/BTC]' in rpc_mock.call_args_list[-1][0][0]
|
||||||
assert 'Amount' in rpc_mock.call_args_list[-1][0][0]
|
assert 'Amount' in rpc_mock.call_args_list[-1][0][0]
|
||||||
assert '0.00001172' in rpc_mock.call_args_list[-1][0][0]
|
assert '0.00001172' in rpc_mock.call_args_list[-1][0][0]
|
||||||
assert '(profit: 6.11%, 0.00006126)' in rpc_mock.call_args_list[-1][0][0]
|
assert '(profit: 6.11%, 0.00006126)' in rpc_mock.call_args_list[-1][0][0]
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
import os
|
import os
|
||||||
import pytest
|
import pytest
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
from freqtrade.exchange import Exchanges
|
|
||||||
from freqtrade.persistence import Trade, init, clean_dry_run_db
|
from freqtrade.persistence import Trade, init, clean_dry_run_db
|
||||||
|
|
||||||
|
|
||||||
@ -117,10 +116,10 @@ def test_update_with_bittrex(limit_buy_order, limit_sell_order):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
trade = Trade(
|
trade = Trade(
|
||||||
pair='BTC_ETH',
|
pair='ETH/BTC',
|
||||||
stake_amount=0.001,
|
stake_amount=0.001,
|
||||||
fee=0.0025,
|
fee=0.0025,
|
||||||
exchange=Exchanges.BITTREX,
|
exchange="BITTREX",
|
||||||
)
|
)
|
||||||
assert trade.open_order_id is None
|
assert trade.open_order_id is None
|
||||||
assert trade.open_rate is None
|
assert trade.open_rate is None
|
||||||
@ -144,10 +143,10 @@ def test_update_with_bittrex(limit_buy_order, limit_sell_order):
|
|||||||
|
|
||||||
def test_calc_open_close_trade_price(limit_buy_order, limit_sell_order):
|
def test_calc_open_close_trade_price(limit_buy_order, limit_sell_order):
|
||||||
trade = Trade(
|
trade = Trade(
|
||||||
pair='BTC_ETH',
|
pair='ETH/BTC',
|
||||||
stake_amount=0.001,
|
stake_amount=0.001,
|
||||||
fee=0.0025,
|
fee=0.0025,
|
||||||
exchange=Exchanges.BITTREX,
|
exchange="BITTREX",
|
||||||
)
|
)
|
||||||
|
|
||||||
trade.open_order_id = 'something'
|
trade.open_order_id = 'something'
|
||||||
@ -166,10 +165,10 @@ def test_calc_open_close_trade_price(limit_buy_order, limit_sell_order):
|
|||||||
|
|
||||||
def test_calc_close_trade_price_exception(limit_buy_order):
|
def test_calc_close_trade_price_exception(limit_buy_order):
|
||||||
trade = Trade(
|
trade = Trade(
|
||||||
pair='BTC_ETH',
|
pair='ETH/BTC',
|
||||||
stake_amount=0.001,
|
stake_amount=0.001,
|
||||||
fee=0.0025,
|
fee=0.0025,
|
||||||
exchange=Exchanges.BITTREX,
|
exchange="BITTREX",
|
||||||
)
|
)
|
||||||
|
|
||||||
trade.open_order_id = 'something'
|
trade.open_order_id = 'something'
|
||||||
@ -179,10 +178,10 @@ def test_calc_close_trade_price_exception(limit_buy_order):
|
|||||||
|
|
||||||
def test_update_open_order(limit_buy_order):
|
def test_update_open_order(limit_buy_order):
|
||||||
trade = Trade(
|
trade = Trade(
|
||||||
pair='BTC_ETH',
|
pair='ETH/BTC',
|
||||||
stake_amount=1.00,
|
stake_amount=1.00,
|
||||||
fee=0.1,
|
fee=0.1,
|
||||||
exchange=Exchanges.BITTREX,
|
exchange="BITTREX",
|
||||||
)
|
)
|
||||||
|
|
||||||
assert trade.open_order_id is None
|
assert trade.open_order_id is None
|
||||||
@ -201,10 +200,10 @@ def test_update_open_order(limit_buy_order):
|
|||||||
|
|
||||||
def test_update_invalid_order(limit_buy_order):
|
def test_update_invalid_order(limit_buy_order):
|
||||||
trade = Trade(
|
trade = Trade(
|
||||||
pair='BTC_ETH',
|
pair='ETH/BTC',
|
||||||
stake_amount=1.00,
|
stake_amount=1.00,
|
||||||
fee=0.1,
|
fee=0.1,
|
||||||
exchange=Exchanges.BITTREX,
|
exchange="BITTREX"
|
||||||
)
|
)
|
||||||
limit_buy_order['type'] = 'invalid'
|
limit_buy_order['type'] = 'invalid'
|
||||||
with pytest.raises(ValueError, match=r'Unknown order type'):
|
with pytest.raises(ValueError, match=r'Unknown order type'):
|
||||||
@ -213,10 +212,10 @@ def test_update_invalid_order(limit_buy_order):
|
|||||||
|
|
||||||
def test_calc_open_trade_price(limit_buy_order):
|
def test_calc_open_trade_price(limit_buy_order):
|
||||||
trade = Trade(
|
trade = Trade(
|
||||||
pair='BTC_ETH',
|
pair='ETH/BTC',
|
||||||
stake_amount=0.001,
|
stake_amount=0.001,
|
||||||
fee=0.0025,
|
fee=0.0025,
|
||||||
exchange=Exchanges.BITTREX,
|
exchange="BITTREX",
|
||||||
)
|
)
|
||||||
trade.open_order_id = 'open_trade'
|
trade.open_order_id = 'open_trade'
|
||||||
trade.update(limit_buy_order) # Buy @ 0.00001099
|
trade.update(limit_buy_order) # Buy @ 0.00001099
|
||||||
@ -230,10 +229,10 @@ def test_calc_open_trade_price(limit_buy_order):
|
|||||||
|
|
||||||
def test_calc_close_trade_price(limit_buy_order, limit_sell_order):
|
def test_calc_close_trade_price(limit_buy_order, limit_sell_order):
|
||||||
trade = Trade(
|
trade = Trade(
|
||||||
pair='BTC_ETH',
|
pair='ETH/BTC',
|
||||||
stake_amount=0.001,
|
stake_amount=0.001,
|
||||||
fee=0.0025,
|
fee=0.0025,
|
||||||
exchange=Exchanges.BITTREX,
|
exchange="BITTREX",
|
||||||
)
|
)
|
||||||
trade.open_order_id = 'close_trade'
|
trade.open_order_id = 'close_trade'
|
||||||
trade.update(limit_buy_order) # Buy @ 0.00001099
|
trade.update(limit_buy_order) # Buy @ 0.00001099
|
||||||
@ -251,10 +250,10 @@ def test_calc_close_trade_price(limit_buy_order, limit_sell_order):
|
|||||||
|
|
||||||
def test_calc_profit(limit_buy_order, limit_sell_order):
|
def test_calc_profit(limit_buy_order, limit_sell_order):
|
||||||
trade = Trade(
|
trade = Trade(
|
||||||
pair='BTC_ETH',
|
pair='ETH/BTC',
|
||||||
stake_amount=0.001,
|
stake_amount=0.001,
|
||||||
fee=0.0025,
|
fee=0.0025,
|
||||||
exchange=Exchanges.BITTREX,
|
exchange="BITTREX",
|
||||||
)
|
)
|
||||||
trade.open_order_id = 'profit_percent'
|
trade.open_order_id = 'profit_percent'
|
||||||
trade.update(limit_buy_order) # Buy @ 0.00001099
|
trade.update(limit_buy_order) # Buy @ 0.00001099
|
||||||
@ -285,10 +284,10 @@ def test_calc_profit(limit_buy_order, limit_sell_order):
|
|||||||
|
|
||||||
def test_calc_profit_percent(limit_buy_order, limit_sell_order):
|
def test_calc_profit_percent(limit_buy_order, limit_sell_order):
|
||||||
trade = Trade(
|
trade = Trade(
|
||||||
pair='BTC_ETH',
|
pair='ETH/BTC',
|
||||||
stake_amount=0.001,
|
stake_amount=0.001,
|
||||||
fee=0.0025,
|
fee=0.0025,
|
||||||
exchange=Exchanges.BITTREX,
|
exchange="BITTREX",
|
||||||
)
|
)
|
||||||
trade.open_order_id = 'profit_percent'
|
trade.open_order_id = 'profit_percent'
|
||||||
trade.update(limit_buy_order) # Buy @ 0.00001099
|
trade.update(limit_buy_order) # Buy @ 0.00001099
|
||||||
|
Loading…
Reference in New Issue
Block a user