fixed some stuff in the leverage brackets binance test
This commit is contained in:
parent
57c7926515
commit
dced167ea2
@ -131,7 +131,7 @@ class Binance(Exchange):
|
||||
if self.trading_mode == TradingMode.FUTURES:
|
||||
try:
|
||||
if self._config['dry_run']:
|
||||
leverage_brackets_path = Path('data') / 'leverage_brackets.json'
|
||||
leverage_brackets_path = Path('freqtrade/data') / 'leverage_brackets.json'
|
||||
with open(leverage_brackets_path) as json_file:
|
||||
leverage_brackets = json.load(json_file)
|
||||
else:
|
||||
|
@ -2,6 +2,9 @@ from datetime import datetime, timezone
|
||||
from random import randint
|
||||
from unittest.mock import MagicMock, PropertyMock
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
import ccxt
|
||||
import pytest
|
||||
|
||||
@ -203,58 +206,76 @@ def test_get_max_leverage_binance(default_conf, mocker, pair, nominal_value, max
|
||||
|
||||
def test_fill_leverage_brackets_binance(default_conf, mocker):
|
||||
api_mock = MagicMock()
|
||||
api_mock.load_leverage_brackets = MagicMock(return_value={
|
||||
'ADA/BUSD': [[0.0, 0.025],
|
||||
[100000.0, 0.05],
|
||||
[500000.0, 0.1],
|
||||
[1000000.0, 0.15],
|
||||
[2000000.0, 0.25],
|
||||
[5000000.0, 0.5]],
|
||||
'BTC/USDT': [[0.0, 0.004],
|
||||
[50000.0, 0.005],
|
||||
[250000.0, 0.01],
|
||||
[1000000.0, 0.025],
|
||||
[5000000.0, 0.05],
|
||||
[20000000.0, 0.1],
|
||||
[50000000.0, 0.125],
|
||||
[100000000.0, 0.15],
|
||||
[200000000.0, 0.25],
|
||||
[300000000.0, 0.5]],
|
||||
"ZEC/USDT": [[0.0, 0.01],
|
||||
[5000.0, 0.025],
|
||||
[25000.0, 0.05],
|
||||
[100000.0, 0.1],
|
||||
[250000.0, 0.125],
|
||||
[1000000.0, 0.5]],
|
||||
# api_mock.load_leverage_brackets = MagicMock(return_value={
|
||||
# 'ADA/BUSD': [[0.0, 0.025],
|
||||
# [100000.0, 0.05],
|
||||
# [500000.0, 0.1],
|
||||
# [1000000.0, 0.15],
|
||||
# [2000000.0, 0.25],
|
||||
# [5000000.0, 0.5]],
|
||||
# 'BTC/USDT': [[0.0, 0.004],
|
||||
# [50000.0, 0.005],
|
||||
# [250000.0, 0.01],
|
||||
# [1000000.0, 0.025],
|
||||
# [5000000.0, 0.05],
|
||||
# [20000000.0, 0.1],
|
||||
# [50000000.0, 0.125],
|
||||
# [100000000.0, 0.15],
|
||||
# [200000000.0, 0.25],
|
||||
# [300000000.0, 0.5]],
|
||||
# "ZEC/USDT": [[0.0, 0.01],
|
||||
# [5000.0, 0.025],
|
||||
# [25000.0, 0.05],
|
||||
# [100000.0, 0.1],
|
||||
# [250000.0, 0.125],
|
||||
# [1000000.0, 0.5]],
|
||||
|
||||
})
|
||||
# })
|
||||
exchange = get_patched_exchange(mocker, default_conf, api_mock, id="binance")
|
||||
exchange.trading_mode = TradingMode.FUTURES
|
||||
exchange.fill_leverage_brackets()
|
||||
|
||||
assert exchange._leverage_brackets == {
|
||||
'ADA/BUSD': [[0.0, 0.025],
|
||||
[100000.0, 0.05],
|
||||
[500000.0, 0.1],
|
||||
[1000000.0, 0.15],
|
||||
[2000000.0, 0.25],
|
||||
[5000000.0, 0.5]],
|
||||
'BTC/USDT': [[0.0, 0.004],
|
||||
[50000.0, 0.005],
|
||||
[250000.0, 0.01],
|
||||
[1000000.0, 0.025],
|
||||
[5000000.0, 0.05],
|
||||
[20000000.0, 0.1],
|
||||
[50000000.0, 0.125],
|
||||
[100000000.0, 0.15],
|
||||
[200000000.0, 0.25],
|
||||
[300000000.0, 0.5]],
|
||||
"ZEC/USDT": [[0.0, 0.01],
|
||||
[5000.0, 0.025],
|
||||
[25000.0, 0.05],
|
||||
[100000.0, 0.1],
|
||||
[250000.0, 0.125],
|
||||
[1000000.0, 0.5]],
|
||||
}
|
||||
leverage_brackets_path = Path('freqtrade/data') / 'leverage_brackets.json'
|
||||
with open(leverage_brackets_path) as json_file:
|
||||
leverage_brackets = json.load(json_file)
|
||||
|
||||
for pair, brackets in leverage_brackets.items():
|
||||
leverage_brackets[pair] = [
|
||||
[
|
||||
min_amount,
|
||||
float(margin_req)
|
||||
] for [
|
||||
min_amount,
|
||||
margin_req
|
||||
] in brackets
|
||||
]
|
||||
|
||||
assert exchange._leverage_brackets == leverage_brackets
|
||||
|
||||
# assert exchange._leverage_brackets == {
|
||||
# 'ADA/BUSD': [[0.0, 0.025],
|
||||
# [100000.0, 0.05],
|
||||
# [500000.0, 0.1],
|
||||
# [1000000.0, 0.15],
|
||||
# [2000000.0, 0.25],
|
||||
# [5000000.0, 0.5]],
|
||||
# 'BTC/USDT': [[0.0, 0.004],
|
||||
# [50000.0, 0.005],
|
||||
# [250000.0, 0.01],
|
||||
# [1000000.0, 0.025],
|
||||
# [5000000.0, 0.05],
|
||||
# [20000000.0, 0.1],
|
||||
# [50000000.0, 0.125],
|
||||
# [100000000.0, 0.15],
|
||||
# [200000000.0, 0.25],
|
||||
# [300000000.0, 0.5]],
|
||||
# "ZEC/USDT": [[0.0, 0.01],
|
||||
# [5000.0, 0.025],
|
||||
# [25000.0, 0.05],
|
||||
# [100000.0, 0.1],
|
||||
# [250000.0, 0.125],
|
||||
# [1000000.0, 0.5]],
|
||||
# }
|
||||
|
||||
api_mock = MagicMock()
|
||||
api_mock.load_leverage_brackets = MagicMock()
|
||||
|
Loading…
Reference in New Issue
Block a user