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:
|
if self.trading_mode == TradingMode.FUTURES:
|
||||||
try:
|
try:
|
||||||
if self._config['dry_run']:
|
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:
|
with open(leverage_brackets_path) as json_file:
|
||||||
leverage_brackets = json.load(json_file)
|
leverage_brackets = json.load(json_file)
|
||||||
else:
|
else:
|
||||||
|
@ -2,6 +2,9 @@ from datetime import datetime, timezone
|
|||||||
from random import randint
|
from random import randint
|
||||||
from unittest.mock import MagicMock, PropertyMock
|
from unittest.mock import MagicMock, PropertyMock
|
||||||
|
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
import ccxt
|
import ccxt
|
||||||
import pytest
|
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):
|
def test_fill_leverage_brackets_binance(default_conf, mocker):
|
||||||
api_mock = MagicMock()
|
api_mock = MagicMock()
|
||||||
api_mock.load_leverage_brackets = MagicMock(return_value={
|
# api_mock.load_leverage_brackets = MagicMock(return_value={
|
||||||
'ADA/BUSD': [[0.0, 0.025],
|
# 'ADA/BUSD': [[0.0, 0.025],
|
||||||
[100000.0, 0.05],
|
# [100000.0, 0.05],
|
||||||
[500000.0, 0.1],
|
# [500000.0, 0.1],
|
||||||
[1000000.0, 0.15],
|
# [1000000.0, 0.15],
|
||||||
[2000000.0, 0.25],
|
# [2000000.0, 0.25],
|
||||||
[5000000.0, 0.5]],
|
# [5000000.0, 0.5]],
|
||||||
'BTC/USDT': [[0.0, 0.004],
|
# 'BTC/USDT': [[0.0, 0.004],
|
||||||
[50000.0, 0.005],
|
# [50000.0, 0.005],
|
||||||
[250000.0, 0.01],
|
# [250000.0, 0.01],
|
||||||
[1000000.0, 0.025],
|
# [1000000.0, 0.025],
|
||||||
[5000000.0, 0.05],
|
# [5000000.0, 0.05],
|
||||||
[20000000.0, 0.1],
|
# [20000000.0, 0.1],
|
||||||
[50000000.0, 0.125],
|
# [50000000.0, 0.125],
|
||||||
[100000000.0, 0.15],
|
# [100000000.0, 0.15],
|
||||||
[200000000.0, 0.25],
|
# [200000000.0, 0.25],
|
||||||
[300000000.0, 0.5]],
|
# [300000000.0, 0.5]],
|
||||||
"ZEC/USDT": [[0.0, 0.01],
|
# "ZEC/USDT": [[0.0, 0.01],
|
||||||
[5000.0, 0.025],
|
# [5000.0, 0.025],
|
||||||
[25000.0, 0.05],
|
# [25000.0, 0.05],
|
||||||
[100000.0, 0.1],
|
# [100000.0, 0.1],
|
||||||
[250000.0, 0.125],
|
# [250000.0, 0.125],
|
||||||
[1000000.0, 0.5]],
|
# [1000000.0, 0.5]],
|
||||||
|
|
||||||
})
|
# })
|
||||||
exchange = get_patched_exchange(mocker, default_conf, api_mock, id="binance")
|
exchange = get_patched_exchange(mocker, default_conf, api_mock, id="binance")
|
||||||
|
exchange.trading_mode = TradingMode.FUTURES
|
||||||
exchange.fill_leverage_brackets()
|
exchange.fill_leverage_brackets()
|
||||||
|
|
||||||
assert exchange._leverage_brackets == {
|
leverage_brackets_path = Path('freqtrade/data') / 'leverage_brackets.json'
|
||||||
'ADA/BUSD': [[0.0, 0.025],
|
with open(leverage_brackets_path) as json_file:
|
||||||
[100000.0, 0.05],
|
leverage_brackets = json.load(json_file)
|
||||||
[500000.0, 0.1],
|
|
||||||
[1000000.0, 0.15],
|
for pair, brackets in leverage_brackets.items():
|
||||||
[2000000.0, 0.25],
|
leverage_brackets[pair] = [
|
||||||
[5000000.0, 0.5]],
|
[
|
||||||
'BTC/USDT': [[0.0, 0.004],
|
min_amount,
|
||||||
[50000.0, 0.005],
|
float(margin_req)
|
||||||
[250000.0, 0.01],
|
] for [
|
||||||
[1000000.0, 0.025],
|
min_amount,
|
||||||
[5000000.0, 0.05],
|
margin_req
|
||||||
[20000000.0, 0.1],
|
] in brackets
|
||||||
[50000000.0, 0.125],
|
]
|
||||||
[100000000.0, 0.15],
|
|
||||||
[200000000.0, 0.25],
|
assert exchange._leverage_brackets == leverage_brackets
|
||||||
[300000000.0, 0.5]],
|
|
||||||
"ZEC/USDT": [[0.0, 0.01],
|
# assert exchange._leverage_brackets == {
|
||||||
[5000.0, 0.025],
|
# 'ADA/BUSD': [[0.0, 0.025],
|
||||||
[25000.0, 0.05],
|
# [100000.0, 0.05],
|
||||||
[100000.0, 0.1],
|
# [500000.0, 0.1],
|
||||||
[250000.0, 0.125],
|
# [1000000.0, 0.15],
|
||||||
[1000000.0, 0.5]],
|
# [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 = MagicMock()
|
||||||
api_mock.load_leverage_brackets = MagicMock()
|
api_mock.load_leverage_brackets = MagicMock()
|
||||||
|
Loading…
Reference in New Issue
Block a user