code: def test_to_dict(mock_exchange_class):
      exchange = mock_exchange_class.return_value
      exchange.options = ExchangeOptions()
      exchange.id = "fake_exchange_id"
      exchange.name = "bitfinex"
      exchange.clock = mock.Mock()
      exchange.clock.step = 0
      exchange.quote_price = mock.Mock(return_value=Decimal(7000.00))
  
      order_spec = OrderSpec(
          side=TradeSide.BUY,
          trade_type=TradeType.MARKET,
          exchange_pair=ExchangePair(exchange, USD / BTC),
      )
  
      d = order_spec.to_dict()
      assert d == {
          "id": order_spec.id,
          "type": order_spec.type,
          "exchange_pair": order_spec.exchange_pair,
          "criteria": order_spec.criteria,
      }
  
      order_spec = OrderSpec(
          side=TradeSide.BUY,
          trade_type=TradeType.MARKET,
          exchange_pair=ExchangePair(exchange, USD / BTC),
          criteria=lambda order, exchange: True,
      )
  
      d = order_spec.to_dict()
      assert d == {
          "id": order_spec.id,
          "type": order_spec.type,
          "exchange_pair": order_spec.exchange_pair,
          "criteria": order_spec.criteria,
      }
  
file_path: tensortrade/tests/tensortrade/unit/oms/orders/test_order_spec.py
imports: import re
  import unittest.mock
  from decimal import Decimal
  from tensortrade.oms.orders import OrderSpec, TradeSide, TradeType
  from tensortrade.oms.exchanges import ExchangeOptions
  from tensortrade.oms.instruments import USD, BTC, ExchangePair
  from tensortrade.oms.wallets import Portfolio, Wallet
label_desc: Use image node_id 4 for calling a global function with example usage: test_to_dict(mock_exchange_class) without return types