コード例 #1
0
def _validate_order_types(conf: Dict[str, Any]) -> None:

    order_types = conf.get('order_types', {})
    old_order_types = [
        'buy', 'sell', 'emergencysell', 'forcebuy', 'forcesell',
        'emergencyexit', 'forceexit', 'forceentry'
    ]
    if any(x in order_types for x in old_order_types):
        if conf.get('trading_mode', TradingMode.SPOT) != TradingMode.SPOT:
            raise OperationalException(
                "Please migrate your order_types settings to use the new wording."
            )
        else:
            logger.warning(
                "DEPRECATED: Using 'buy' and 'sell' for order_types is deprecated."
                "Please migrate your order_types settings to use 'entry' and 'exit' wording."
            )
            for o, n in [
                ('buy', 'entry'),
                ('sell', 'exit'),
                ('emergencysell', 'emergency_exit'),
                ('forcesell', 'force_exit'),
                ('forcebuy', 'force_entry'),
                ('emergencyexit', 'emergency_exit'),
                ('forceexit', 'force_exit'),
                ('forceentry', 'force_entry'),
            ]:

                process_deprecated_setting(conf, 'order_types', o,
                                           'order_types', n)
コード例 #2
0
def _validate_pricing_rules(conf: Dict[str, Any]) -> None:

    if conf.get('ask_strategy') or conf.get('bid_strategy'):
        if conf.get('trading_mode', TradingMode.SPOT) != TradingMode.SPOT:
            raise OperationalException(
                "Please migrate your pricing settings to use the new wording.")
        else:

            logger.warning(
                "DEPRECATED: Using 'ask_strategy' and 'bid_strategy' is deprecated."
                "Please migrate your settings to use 'entry_pricing' and 'exit_pricing'."
            )
            conf['entry_pricing'] = {}
            for obj in list(conf.get('bid_strategy', {}).keys()):
                if obj == 'ask_last_balance':
                    process_deprecated_setting(conf, 'bid_strategy', obj,
                                               'entry_pricing',
                                               'price_last_balance')
                else:
                    process_deprecated_setting(conf, 'bid_strategy', obj,
                                               'entry_pricing', obj)
            del conf['bid_strategy']

            conf['exit_pricing'] = {}
            for obj in list(conf.get('ask_strategy', {}).keys()):
                if obj == 'bid_last_balance':
                    process_deprecated_setting(conf, 'ask_strategy', obj,
                                               'exit_pricing',
                                               'price_last_balance')
                else:
                    process_deprecated_setting(conf, 'ask_strategy', obj,
                                               'exit_pricing', obj)
            del conf['ask_strategy']
コード例 #3
0
def _strategy_settings(conf: Dict[str, Any]) -> None:

    process_deprecated_setting(conf, None, 'use_sell_signal', None,
                               'use_exit_signal')
    process_deprecated_setting(conf, None, 'sell_profit_only', None,
                               'exit_profit_only')
    process_deprecated_setting(conf, None, 'sell_profit_offset', None,
                               'exit_profit_offset')
    process_deprecated_setting(conf, None, 'ignore_roi_if_buy_signal', None,
                               'ignore_roi_if_entry_signal')
コード例 #4
0
def _validate_time_in_force(conf: Dict[str, Any]) -> None:

    time_in_force = conf.get('order_time_in_force', {})
    if 'buy' in time_in_force or 'sell' in time_in_force:
        if conf.get('trading_mode', TradingMode.SPOT) != TradingMode.SPOT:
            raise OperationalException(
                "Please migrate your time_in_force settings to use 'entry' and 'exit'."
            )
        else:
            logger.warning(
                "DEPRECATED: Using 'buy' and 'sell' for time_in_force is deprecated."
                "Please migrate your time_in_force settings to use 'entry' and 'exit'."
            )
            process_deprecated_setting(conf, 'order_time_in_force', 'buy',
                                       'order_time_in_force', 'entry')

            process_deprecated_setting(conf, 'order_time_in_force', 'sell',
                                       'order_time_in_force', 'exit')
コード例 #5
0
def test_process_deprecated_setting(mocker, default_conf, caplog):
    patched_configuration_load_config_file(mocker, default_conf)

    # Create sections for new and deprecated settings
    # (they may not exist in the config)
    default_conf['sectionA'] = {}
    default_conf['sectionB'] = {}
    # Assign deprecated setting
    default_conf['sectionB']['deprecated_setting'] = 'valB'

    # Both new and deprecated settings exists
    process_deprecated_setting(default_conf,
                               'sectionB', 'deprecated_setting',
                               'sectionA', 'new_setting')
    assert log_has_re('DEPRECATED', caplog)
    # The value of the new setting shall have been set to the
    # value of the deprecated one
    assert default_conf['sectionA']['new_setting'] == 'valB'

    caplog.clear()

    # Delete new setting (deprecated exists)
    del default_conf['sectionA']['new_setting']
    process_deprecated_setting(default_conf,
                               'sectionB', 'deprecated_setting',
                               'sectionA', 'new_setting')
    assert log_has_re('DEPRECATED', caplog)
    # The value of the new setting shall have been set to the
    # value of the deprecated one
    assert default_conf['sectionA']['new_setting'] == 'valB'

    caplog.clear()

    # Assign new setting
    default_conf['sectionA']['new_setting'] = 'valA'
    # Delete deprecated setting
    del default_conf['sectionB']['deprecated_setting']
    process_deprecated_setting(default_conf,
                               'sectionB', 'deprecated_setting',
                               'sectionA', 'new_setting')
    assert not log_has_re('DEPRECATED', caplog)
    assert default_conf['sectionA']['new_setting'] == 'valA'

    caplog.clear()
    # Test moving to root
    default_conf['sectionB']['deprecated_setting2'] = "DeadBeef"
    process_deprecated_setting(default_conf,
                               'sectionB', 'deprecated_setting2',
                               None, 'new_setting')

    assert log_has_re('DEPRECATED', caplog)
    assert default_conf['new_setting']
コード例 #6
0
def _validate_unfilledtimeout(conf: Dict[str, Any]) -> None:
    unfilledtimeout = conf.get('unfilledtimeout', {})
    if any(x in unfilledtimeout for x in ['buy', 'sell']):
        if conf.get('trading_mode', TradingMode.SPOT) != TradingMode.SPOT:
            raise OperationalException(
                "Please migrate your unfilledtimeout settings to use the new wording."
            )
        else:

            logger.warning(
                "DEPRECATED: Using 'buy' and 'sell' for unfilledtimeout is deprecated."
                "Please migrate your unfilledtimeout settings to use 'entry' and 'exit' wording."
            )
            for o, n in [
                ('buy', 'entry'),
                ('sell', 'exit'),
            ]:

                process_deprecated_setting(conf, 'unfilledtimeout', o,
                                           'unfilledtimeout', n)