code: def encode_to_json(order_or_history):
      
      if isinstance(order_or_history, MarketOrderList):
          return orders.encode_to_json(order_or_history)
      elif isinstance(order_or_history, MarketHistoryList):
          return history.encode_to_json(order_or_history)
      else:
          raise Exception("Must be one of MarketOrderList or MarketHistoryList.")
docs: Given an order or history entry, encode it to JSON and return.
  
      :type order_or_history: MarketOrderList or MarketHistoryList
      :param order_or_history: A MarketOrderList or MarketHistoryList instance to
          encode to JSON.
      :rtype: str
      :return: The encoded JSON string.