code: def place_orders(
      context, amount, buying_price, selling_price, action
  ):
      """
      This method will always place two orders of the same amount to keep
      the currency position the same as it moves between the two exchanges.
  
      :param context: TradingAlgorithm
      :param amount: float
          The trading pair amount to trade on both exchanges.
      :param buying_price: float
          The current trading pair price on the buying exchange.
      :param selling_price: float
          The current trading pair price on the selling exchange.
      :param action: string
          "enter": buys on the buying exchange and sells on the selling exchange
          "exit": buys on the selling exchange and sells on the buying exchange
  
      :return:
      """
      if action == "enter":
          enter_exchange = context.buying_exchange
          entry_price = buying_price
  
          exit_exchange = context.selling_exchange
          exit_price = selling_price
  
      elif action == "exit":
          enter_exchange = context.selling_exchange
          entry_price = selling_price
  
          exit_exchange = context.buying_exchange
          exit_price = buying_price
  
      else:
          raise ValueError("invalid order action")
  
      quote_currency = enter_exchange.quote_currency
      quote_currency_amount = enter_exchange.portfolio.cash
  
      exit_balances = exit_exchange.get_balances()
      exit_currency = context.trading_pairs[
          context.selling_exchange
      ].quote_currency
  
      if exit_currency in exit_balances:
          quote_currency_amount = exit_balances[exit_currency]
      else:
          log.warn(
              "the selling exchange {exchange_name} does not hold "
              "currency {currency}".format(
                  exchange_name=exit_exchange.name,
                  currency=exit_currency,
              )
          )
          return
  
      if quote_currency_amount < (amount * entry_price):
          adj_amount = quote_currency_amount / entry_price
          log.warn(
              "not enough {quote_currency} ({quote_currency_amount}) to buy "
              "{amount}, adjusting the amount to {adj_amount}".format(
                  quote_currency=quote_currency,
                  quote_currency_amount=quote_currency_amount,
                  amount=amount,
                  adj_amount=adj_amount,
              )
          )
          amount = adj_amount
  
      elif quote_currency_amount < amount:
          log.warn(
              "not enough {currency} ({currency_amount}) to sell "
              "{amount}, aborting".format(
                  currency=exit_currency,
                  currency_amount=quote_currency_amount,
                  amount=amount,
              )
          )
          return
  
      adj_buy_price = entry_price * (1 + context.SLIPPAGE_ALLOWED)
      log.info(
          "buying {amount} {trading_pair} on {exchange_name} with price "
          "limit {limit_price}".format(
              amount=amount,
              trading_pair=context.trading_pair_symbol,
              exchange_name=enter_exchange.name,
              limit_price=adj_buy_price,
          )
      )
      order(
          asset=context.trading_pairs[enter_exchange],
          amount=amount,
          limit_price=adj_buy_price,
      )
  
      adj_sell_price = exit_price * (1 - context.SLIPPAGE_ALLOWED)
      log.info(
          "selling {amount} {trading_pair} on {exchange_name} with price "
          "limit {limit_price}".format(
              amount=-amount,
              trading_pair=context.trading_pair_symbol,
              exchange_name=exit_exchange.name,
              limit_price=adj_sell_price,
          )
      )
      order(
          asset=context.trading_pairs[exit_exchange],
          amount=-amount,
          limit_price=adj_sell_price,
      )
      pass
  
file_path: catalyst/catalyst/examples/arbitrage_with_interface.py
imports: from logbook import Logger
  from catalyst.api import record, order, symbol
  from catalyst.exchange.utils.stats_utils import get_pretty_stats
  from catalyst.utils.run_algo import run_algorithm
label_desc: Use image node_id 2 for calling a global function with example usage: place_orders(context, amount, buying_price, selling_price, action) without return types