mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Adjust test to work against usdt values
This commit is contained in:
parent
093fd48cf9
commit
2854186b14
|
@ -494,9 +494,9 @@ def test_rpc_balance_handle_error(default_conf, mocker):
|
|||
def test_rpc_balance_handle(default_conf_usdt, mocker, tickers):
|
||||
mock_balance = {
|
||||
'BTC': {
|
||||
'free': 10.0,
|
||||
'total': 12.0,
|
||||
'used': 2.0,
|
||||
'free': 0.01,
|
||||
'total': 0.012,
|
||||
'used': 0.002,
|
||||
},
|
||||
'ETH': {
|
||||
'free': 1.0,
|
||||
|
@ -504,8 +504,8 @@ def test_rpc_balance_handle(default_conf_usdt, mocker, tickers):
|
|||
'used': 4.0,
|
||||
},
|
||||
'USDT': {
|
||||
'free': 5.0,
|
||||
'total': 10.0,
|
||||
'free': 50.0,
|
||||
'total': 100.0,
|
||||
'used': 5.0,
|
||||
}
|
||||
}
|
||||
|
@ -519,10 +519,10 @@ def test_rpc_balance_handle(default_conf_usdt, mocker, tickers):
|
|||
"maintenanceMargin": 0.0,
|
||||
"maintenanceMarginPercentage": 0.005,
|
||||
"entryPrice": 0.0,
|
||||
"notional": 100.0,
|
||||
"notional": 10.0,
|
||||
"leverage": 5.0,
|
||||
"unrealizedPnl": 0.0,
|
||||
"contracts": 100.0,
|
||||
"contracts": 1.0,
|
||||
"contractSize": 1,
|
||||
"marginRatio": None,
|
||||
"liquidationPrice": 0.0,
|
||||
|
@ -536,9 +536,9 @@ def test_rpc_balance_handle(default_conf_usdt, mocker, tickers):
|
|||
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.rpc.fiat_convert.CoinGeckoAPI',
|
||||
get_price=MagicMock(return_value={'bitcoin': {'usd': 15000.0}}),
|
||||
get_price=MagicMock(return_value={'bitcoin': {'usd': 1.2}}),
|
||||
)
|
||||
mocker.patch('freqtrade.rpc.rpc.CryptoToFiatConverter._find_price', return_value=15000.0)
|
||||
mocker.patch('freqtrade.rpc.rpc.CryptoToFiatConverter._find_price', return_value=1.2)
|
||||
mocker.patch('freqtrade.rpc.telegram.Telegram', MagicMock())
|
||||
mocker.patch.multiple(
|
||||
EXMS,
|
||||
|
@ -559,76 +559,76 @@ def test_rpc_balance_handle(default_conf_usdt, mocker, tickers):
|
|||
result = rpc._rpc_balance(
|
||||
default_conf_usdt['stake_currency'], default_conf_usdt['fiat_display_currency'])
|
||||
|
||||
assert pytest.approx(result['total']) == 2824.83464
|
||||
assert pytest.approx(result['value']) == 2824.83464 * 1.2
|
||||
assert tickers.call_count == 1
|
||||
assert tickers.call_args_list[0][1]['cached'] is True
|
||||
assert 'USD' == result['symbol']
|
||||
assert result['currencies'] == [
|
||||
{
|
||||
'currency': 'BTC',
|
||||
'free': 10.0,
|
||||
'balance': 12.0,
|
||||
'used': 2.0,
|
||||
'bot_owned': 9.9, # available stake - reducing by reserved amount
|
||||
'est_stake': 10.0, # In futures mode, "free" is used here.
|
||||
'est_stake_bot': 9.9,
|
||||
'stake': 'BTC',
|
||||
'is_position': False,
|
||||
'leverage': 1.0,
|
||||
'position': 0.0,
|
||||
'free': 0.01,
|
||||
'balance': 0.012,
|
||||
'used': 0.002,
|
||||
'bot_owned': 0,
|
||||
'est_stake': 103.78464,
|
||||
'est_stake_bot': 0,
|
||||
'stake': 'USDT',
|
||||
'side': 'long',
|
||||
'is_bot_managed': True,
|
||||
'leverage': 1,
|
||||
'position': 0,
|
||||
'is_bot_managed': False,
|
||||
'is_position': False
|
||||
},
|
||||
{
|
||||
'currency': 'ETH',
|
||||
'free': 1.0,
|
||||
'balance': 5.0,
|
||||
'currency': 'ETH',
|
||||
'bot_owned': 0,
|
||||
'est_stake': 0.30794,
|
||||
'est_stake_bot': 0,
|
||||
'used': 4.0,
|
||||
'stake': 'BTC',
|
||||
'is_position': False,
|
||||
'leverage': 1.0,
|
||||
'position': 0.0,
|
||||
'side': 'long',
|
||||
'is_bot_managed': False,
|
||||
},
|
||||
{
|
||||
'free': 5.0,
|
||||
'balance': 10.0,
|
||||
'currency': 'USDT',
|
||||
'bot_owned': 0,
|
||||
'est_stake': 0.0011562404610161968,
|
||||
'est_stake': 2651.05,
|
||||
'est_stake_bot': 0,
|
||||
'used': 5.0,
|
||||
'stake': 'BTC',
|
||||
'is_position': False,
|
||||
'leverage': 1.0,
|
||||
'position': 0.0,
|
||||
'stake': 'USDT',
|
||||
'side': 'long',
|
||||
'leverage': 1,
|
||||
'position': 0,
|
||||
'is_bot_managed': False,
|
||||
'is_position': False
|
||||
},
|
||||
{
|
||||
'currency': 'USDT',
|
||||
'free': 50.0,
|
||||
'balance': 100.0,
|
||||
'used': 5.0,
|
||||
'bot_owned': 49.5,
|
||||
'est_stake': 50.0,
|
||||
'est_stake_bot': 49.5,
|
||||
'stake': 'USDT',
|
||||
'side': 'long',
|
||||
'leverage': 1,
|
||||
'position': 0,
|
||||
'is_bot_managed': True,
|
||||
'is_position': False
|
||||
},
|
||||
{
|
||||
'free': 0.0,
|
||||
'balance': 0.0,
|
||||
'currency': 'ETH/USDT:USDT',
|
||||
'free': 0,
|
||||
'balance': 0,
|
||||
'used': 0,
|
||||
'position': 10.0,
|
||||
'est_stake': 20,
|
||||
'est_stake_bot': 20,
|
||||
'used': 0,
|
||||
'stake': 'BTC',
|
||||
'is_position': True,
|
||||
'stake': 'USDT',
|
||||
'leverage': 5.0,
|
||||
'position': 1000.0,
|
||||
'side': 'short',
|
||||
'is_bot_managed': True,
|
||||
'is_position': True
|
||||
}
|
||||
]
|
||||
assert pytest.approx(result['total_bot']) == 29.9
|
||||
assert pytest.approx(result['total']) == 30.309096
|
||||
assert result['starting_capital'] == 10
|
||||
# Very high starting capital ratio, because the futures position really has the wrong unit.
|
||||
# TODO: improve this test (see comment above)
|
||||
assert result['starting_capital_ratio'] == pytest.approx(1.98999999)
|
||||
assert pytest.approx(result['total_bot']) == 69.5
|
||||
assert pytest.approx(result['total']) == 2824.83464 # ETH stake is missing.
|
||||
assert result['starting_capital'] == 50
|
||||
assert result['starting_capital_ratio'] == pytest.approx(0.3899999)
|
||||
|
||||
|
||||
def test_rpc_start(mocker, default_conf) -> None:
|
||||
|
|
Loading…
Reference in New Issue
Block a user