Remove OrderedDict
as we're no longer supporting python 3.6
This commit is contained in:
parent
fb4dd6c2ac
commit
eaf0aac77e
@ -1,7 +1,6 @@
|
|||||||
import csv
|
import csv
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
from collections import OrderedDict
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Dict, List
|
from typing import Any, Dict, List
|
||||||
|
|
||||||
@ -154,7 +153,7 @@ def start_list_markets(args: Dict[str, Any], pairs_only: bool = False) -> None:
|
|||||||
pairs_only=pairs_only,
|
pairs_only=pairs_only,
|
||||||
active_only=active_only)
|
active_only=active_only)
|
||||||
# Sort the pairs/markets by symbol
|
# Sort the pairs/markets by symbol
|
||||||
pairs = OrderedDict(sorted(pairs.items()))
|
pairs = dict(sorted(pairs.items()))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise OperationalException(f"Cannot get markets. Reason: {e}") from e
|
raise OperationalException(f"Cannot get markets. Reason: {e}") from e
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
|
|
||||||
import io
|
import io
|
||||||
import logging
|
import logging
|
||||||
from collections import OrderedDict
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Dict, List
|
from typing import Any, Dict, List
|
||||||
|
|
||||||
@ -111,16 +110,9 @@ class HyperoptTools():
|
|||||||
if space in ['buy', 'sell']:
|
if space in ['buy', 'sell']:
|
||||||
result_dict.setdefault('params', {}).update(space_params)
|
result_dict.setdefault('params', {}).update(space_params)
|
||||||
elif space == 'roi':
|
elif space == 'roi':
|
||||||
# TODO: get rid of OrderedDict when support for python 3.6 will be
|
|
||||||
# dropped (dicts keep the order as the language feature)
|
|
||||||
|
|
||||||
# Convert keys in min_roi dict to strings because
|
# Convert keys in min_roi dict to strings because
|
||||||
# rapidjson cannot dump dicts with integer keys...
|
# rapidjson cannot dump dicts with integer keys...
|
||||||
# OrderedDict is used to keep the numeric order of the items
|
result_dict['minimal_roi'] = {str(k): v for k, v in space_params.items()}
|
||||||
# in the dict.
|
|
||||||
result_dict['minimal_roi'] = OrderedDict(
|
|
||||||
(str(k), v) for k, v in space_params.items()
|
|
||||||
)
|
|
||||||
else: # 'stoploss', 'trailing'
|
else: # 'stoploss', 'trailing'
|
||||||
result_dict.update(space_params)
|
result_dict.update(space_params)
|
||||||
|
|
||||||
@ -132,13 +124,9 @@ class HyperoptTools():
|
|||||||
if space == 'stoploss':
|
if space == 'stoploss':
|
||||||
result += f"stoploss = {space_params.get('stoploss')}"
|
result += f"stoploss = {space_params.get('stoploss')}"
|
||||||
elif space == 'roi':
|
elif space == 'roi':
|
||||||
# TODO: get rid of OrderedDict when support for python 3.6 will be
|
minimal_roi_result = rapidjson.dumps({
|
||||||
# dropped (dicts keep the order as the language feature)
|
str(k): v for k, v in space_params.items()
|
||||||
minimal_roi_result = rapidjson.dumps(
|
}, default=str, indent=4, number_mode=rapidjson.NM_NATIVE)
|
||||||
OrderedDict(
|
|
||||||
(str(k), v) for k, v in space_params.items()
|
|
||||||
),
|
|
||||||
default=str, indent=4, number_mode=rapidjson.NM_NATIVE)
|
|
||||||
result += f"minimal_roi = {minimal_roi_result}"
|
result += f"minimal_roi = {minimal_roi_result}"
|
||||||
elif space == 'trailing':
|
elif space == 'trailing':
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ This module load custom strategies
|
|||||||
import logging
|
import logging
|
||||||
import tempfile
|
import tempfile
|
||||||
from base64 import urlsafe_b64decode
|
from base64 import urlsafe_b64decode
|
||||||
from collections import OrderedDict
|
|
||||||
from inspect import getfullargspec
|
from inspect import getfullargspec
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Dict, Optional
|
from typing import Any, Dict, Optional
|
||||||
@ -139,7 +138,7 @@ class StrategyResolver(IResolver):
|
|||||||
|
|
||||||
# Sort and apply type conversions
|
# Sort and apply type conversions
|
||||||
if hasattr(strategy, 'minimal_roi'):
|
if hasattr(strategy, 'minimal_roi'):
|
||||||
strategy.minimal_roi = OrderedDict(sorted(
|
strategy.minimal_roi = dict(sorted(
|
||||||
{int(key): value for (key, value) in strategy.minimal_roi.items()}.items(),
|
{int(key): value for (key, value) in strategy.minimal_roi.items()}.items(),
|
||||||
key=lambda t: t[0]))
|
key=lambda t: t[0]))
|
||||||
if hasattr(strategy, 'stoploss'):
|
if hasattr(strategy, 'stoploss'):
|
||||||
|
Loading…
Reference in New Issue
Block a user