def METHOD_NAME(payload: ExchangeModePayloadMixin, config_loc: Config):
    """
    Handle exchange and trading mode payload.
    Updates the configuration with the payload values.
    """
    if payload.exchange:
        config_loc['exchange']['name'] = payload.exchange
    if payload.trading_mode:
        config_loc['trading_mode'] = payload.trading_mode
        config_loc['candle_type_def'] = CandleType.get_default(
            config_loc.get('trading_mode', 'spot') or 'spot')
    if payload.margin_mode:
        config_loc['margin_mode'] = payload.margin_mode