code: def test_complete_complex_order(
      mock_trade_class, 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))
  
      wallets = [
          Wallet(exchange, 10000 * USD),
          Wallet(exchange, 0 * BTC),
      ]
      portfolio = Portfolio(USD, wallets)
  
      side = TradeSide.BUY
  
      order = Order(
          step=0,
          exchange_pair=ExchangePair(exchange, USD / BTC),
          side=TradeSide.BUY,
          trade_type=TradeType.MARKET,
          quantity=5200.00 * USD,
          portfolio=portfolio,
          price=Decimal(7000.00),
      )
  
      risk_criteria = Stop("down", 0.03) ^ Stop("up", 0.02)
  
      risk_management = OrderSpec(
          side=TradeSide.SELL
          if side == TradeSide.BUY
          else TradeSide.BUY,
          trade_type=TradeType.MARKET,
          exchange_pair=ExchangePair(exchange, USD / BTC),
          criteria=risk_criteria,
      )
  
      order.add_order_spec(risk_management)
  
      order.execute()
  
      # Execute fake trade
      price = Decimal(7010.00)
      scale = order.price / price
      commission = 3.00 * USD
  
      base_size = scale * order.size - commission.size
  
      trade = mock_trade_class.return_value
      trade.size = Decimal(base_size)
      trade.quantity = base_size * USD
      trade.price = price
      trade.commission = commission
  
      base_wallet = portfolio.get_wallet(exchange.id, USD)
      quote_wallet = portfolio.get_wallet(exchange.id, BTC)
  
      base_size = trade.size + trade.commission.size
      quote_size = (order.price / trade.price) * (
          trade.size / trade.price
      )
  
      base_wallet.withdraw(
          quantity=Quantity(USD, size=base_size, path_id=order.path_id),
          reason="test",
      )
      quote_wallet.deposit(
          quantity=Quantity(
              BTC, size=quote_size, path_id=order.path_id
          ),
          reason="test",
      )
  
      # Fill fake trade
      order.fill(trade)
  
      assert (
          order.path_id in portfolio.get_wallet(exchange.id, USD).locked
      )
  
      assert order.status == OrderStatus.PARTIALLY_FILLED
      next_order = order.complete()
      assert order.status == OrderStatus.FILLED
  
      assert next_order
      assert next_order.path_id == order.path_id
      assert next_order.size
      assert next_order.status == OrderStatus.PENDING
      assert next_order.side == TradeSide.SELL
      assert next_order.exchange_pair == ExchangePair(
          exchange, USD / BTC
      )
  
imports: import re
  import unittest.mock
  from decimal import Decimal
  from tensortrade.oms.instruments import *
  from tensortrade.oms.orders import Order, OrderStatus, OrderSpec, TradeSide, TradeType
  from tensortrade.oms.orders.criteria import Stop
  from tensortrade.oms.exchanges import ExchangeOptions
  from tensortrade.oms.wallets import Wallet, Portfolio
label_desc: Use image node_id 11 for calling a global function with example usage: test_complete_complex_order(mock_trade_class, mock_exchange_class) without return types