docstr: Map a frequency value between CCXT and Catalyst
  
  Parameters
  ----------
  value: str
  source: str
  raise_error: bool
  
  Returns
  -------
  
  Notes
  -----
  The Pandas offset aliases supported by Catalyst:
  Alias   Description
  W       weekly frequency
  M       month end frequency
  D       calendar day frequency
  H       hourly frequency
  T, min  minutely frequency
  
  The CCXT timeframes:
  '1m': '1minute',
  '1h': '1hour',
  '1d': '1day',
  '1w': '1week',
  '1M': '1month',
  '1y': '1year',
docstr_tok: ["Map","a","frequency","value","between","CCXT","and","Catalyst","Parameters","--","--","--","--","--","value",":","str","source",":","str","raise_error",":","bool","Returns","--","--","--","-","Notes","--","--","-","The","Pandas","offset","aliases","supported","by","Catalyst",":","Alias","Description","W","weekly","frequency","M","month","end","frequency","D","calendar","day","frequency","H","hourly","frequency","T",",","min","minutely","frequency","The","CCXT","timeframes",":","'1m","'",":","'1minute","'",",","'1h","'",":","'1hour","'",",","'1d","'",":","'1day","'",",","'1w","'",":","'1week","'",",","'1M","'",":","'1month","'",",","'1y","'",":","'1year","'",","]
code: def map_frequency(value, source="ccxt", raise_error=True):
      """
      Map a frequency value between CCXT and Catalyst
  
      Parameters
      ----------
      value: str
      source: str
      raise_error: bool
  
      Returns
      -------
  
      Notes
      -----
      The Pandas offset aliases supported by Catalyst:
      Alias	Description
      W	weekly frequency
      M	month end frequency
      D	calendar day frequency
      H	hourly frequency
      T, min	minutely frequency
  
      The CCXT timeframes:
      '1m': '1minute',
      '1h': '1hour',
      '1d': '1day',
      '1w': '1week',
      '1M': '1month',
      '1y': '1year',
      """
      match = re.match(
          r"([0-9].*)?(m|M|d|D|h|H|T|w|W|min)", value, re.M | re.I
      )
      if match:
          candle_size = int(match.group(1)) if match.group(1) else 1
  
          unit = match.group(2)
  
      else:
          raise ValueError("Unable to parse frequency or timeframe")
  
      if source == "ccxt":
          if unit == "d":
              result = "{}D".format(candle_size)
  
          elif unit == "m":
              result = "{}T".format(candle_size)
  
          elif unit == "h":
              result = "{}H".format(candle_size)
  
          elif unit == "w":
              result = "{}W".format(candle_size)
  
          elif unit == "M":
              result = "{}M".format(candle_size)
  
          elif raise_error:
              raise InvalidHistoryTimeframeError(timeframe=value)
  
      else:
          if unit == "D":
              result = "{}d".format(candle_size)
  
          elif unit == "min" or unit == "T":
              result = "{}m".format(candle_size)
  
          elif unit == "H":
              result = "{}h".format(candle_size)
  
          elif unit == "W":
              result = "{}w".format(candle_size)
  
          elif unit == "M":
              result = "{}M".format(candle_size)
  
          elif raise_error:
              raise InvalidHistoryFrequencyError(frequency=value)
  
      return result
  
imports: import copy
  import json
  import os
  import re
  from collections import defaultdict
  import ccxt
  import pandas
  import six
  from ccxt import InvalidOrder, NetworkError, ExchangeError, RequestTimeout
  from logbook import Logger
  from six import string_types
  from catalyst.algorithm import MarketOrder
  from catalyst.assets._assets import TradingPair
  from catalyst.constants import LOG_LEVEL
  from catalyst.exchange.exchange import Exchange
  from catalyst.exchange.exchange_bundle import ExchangeBundle
  from catalyst.exchange.exchange_errors import InvalidHistoryFrequencyError, ExchangeSymbolsNotFound, ExchangeRequestError, InvalidOrderStyle, ExchangeNotFoundError, CreateOrderError, InvalidHistoryTimeframeError, UnsupportedHistoryFrequencyError
  from catalyst.exchange.exchange_execution import ExchangeLimitOrder
  from catalyst.exchange.utils.exchange_utils import mixin_market_params, get_exchange_folder, get_catalyst_symbol, get_exchange_auth
  from catalyst.exchange.utils.datetime_utils import from_ms_timestamp, get_epoch, get_periods_range
  from catalyst.finance.order import Order, ORDER_STATUS
  from catalyst.finance.transaction import Transaction
  from redo import retry
label_desc: Use image node_id 10 for calling the CCXT obj's underlying member method code with example usage: obj.map_frequency(value, source, raise_error) and returns: result