Fix UnicodeError in hyperopt output
This commit is contained in:
parent
6c6efd7214
commit
ca77dbe8da
@ -4,9 +4,9 @@
|
|||||||
This module contains the hyperopt logic
|
This module contains the hyperopt logic
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import locale
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@ -14,10 +14,10 @@ from pprint import pprint
|
|||||||
from typing import Any, Dict, List, Optional
|
from typing import Any, Dict, List, Optional
|
||||||
|
|
||||||
import rapidjson
|
import rapidjson
|
||||||
|
|
||||||
from colorama import init as colorama_init
|
|
||||||
from colorama import Fore, Style
|
from colorama import Fore, Style
|
||||||
from joblib import Parallel, delayed, dump, load, wrap_non_picklable_objects, cpu_count
|
from colorama import init as colorama_init
|
||||||
|
from joblib import (Parallel, cpu_count, delayed, dump, load,
|
||||||
|
wrap_non_picklable_objects)
|
||||||
from pandas import DataFrame
|
from pandas import DataFrame
|
||||||
from skopt import Optimizer
|
from skopt import Optimizer
|
||||||
from skopt.space import Dimension
|
from skopt.space import Dimension
|
||||||
@ -28,8 +28,8 @@ from freqtrade.optimize.backtesting import Backtesting
|
|||||||
# Import IHyperOpt and IHyperOptLoss to allow unpickling classes from these modules
|
# Import IHyperOpt and IHyperOptLoss to allow unpickling classes from these modules
|
||||||
from freqtrade.optimize.hyperopt_interface import IHyperOpt # noqa: F4
|
from freqtrade.optimize.hyperopt_interface import IHyperOpt # noqa: F4
|
||||||
from freqtrade.optimize.hyperopt_loss_interface import IHyperOptLoss # noqa: F4
|
from freqtrade.optimize.hyperopt_loss_interface import IHyperOptLoss # noqa: F4
|
||||||
from freqtrade.resolvers.hyperopt_resolver import HyperOptResolver, HyperOptLossResolver
|
from freqtrade.resolvers.hyperopt_resolver import (HyperOptLossResolver,
|
||||||
|
HyperOptResolver)
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -216,7 +216,7 @@ class Hyperopt:
|
|||||||
if print_all:
|
if print_all:
|
||||||
print(log_str)
|
print(log_str)
|
||||||
else:
|
else:
|
||||||
print('\n' + log_str)
|
print(f'\n{log_str}')
|
||||||
else:
|
else:
|
||||||
print('.', end='')
|
print('.', end='')
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
@ -335,7 +335,9 @@ class Hyperopt:
|
|||||||
|
|
||||||
return (f'{trades:6d} trades. Avg profit {avg_profit: 5.2f}%. '
|
return (f'{trades:6d} trades. Avg profit {avg_profit: 5.2f}%. '
|
||||||
f'Total profit {total_profit: 11.8f} {stake_cur} '
|
f'Total profit {total_profit: 11.8f} {stake_cur} '
|
||||||
f'({profit: 7.2f}Σ%). Avg duration {duration:5.1f} mins.')
|
f'({profit: 7.2f}\N{GREEK CAPITAL LETTER SIGMA}%). '
|
||||||
|
f'Avg duration {duration:5.1f} mins.'
|
||||||
|
).encode(locale.getpreferredencoding(), 'replace').decode('utf-8')
|
||||||
|
|
||||||
def get_optimizer(self, dimensions, cpu_count) -> Optimizer:
|
def get_optimizer(self, dimensions, cpu_count) -> Optimizer:
|
||||||
return Optimizer(
|
return Optimizer(
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# pragma pylint: disable=missing-docstring,W0212,C0103
|
# pragma pylint: disable=missing-docstring,W0212,C0103
|
||||||
|
import locale
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from unittest.mock import MagicMock, PropertyMock
|
from unittest.mock import MagicMock, PropertyMock
|
||||||
@ -565,8 +566,9 @@ def test_generate_optimizer(mocker, default_conf) -> None:
|
|||||||
}
|
}
|
||||||
response_expected = {
|
response_expected = {
|
||||||
'loss': 1.9840569076926293,
|
'loss': 1.9840569076926293,
|
||||||
'results_explanation': ' 1 trades. Avg profit 2.31%. Total profit 0.00023300 BTC '
|
'results_explanation': (' 1 trades. Avg profit 2.31%. Total profit 0.00023300 BTC '
|
||||||
'( 2.31Σ%). Avg duration 100.0 mins.',
|
'( 2.31\N{GREEK CAPITAL LETTER SIGMA}%). Avg duration 100.0 mins.'
|
||||||
|
).encode(locale.getpreferredencoding(), 'replace').decode('utf-8'),
|
||||||
'params': optimizer_param,
|
'params': optimizer_param,
|
||||||
'total_profit': 0.00023300
|
'total_profit': 0.00023300
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user