# Rebalancing order on trading pairs

I'm working on a program to rebalance my portfolio among a set of crypto assets. Though I'm a bit confused on how to best order the buys in sells among the various pairs. Consider the following example. I'm using an equal weight strategy.

  BTC  : $$6 : BTC/USDT USDT :$$3  : BTC/USDT
ETH  : $$7 : ETH/BTC LTC :$$5  : LTC/BTC
TRX  : $$4 : TRX/ETH -- Total$$25 / I
Ideal Per coin: $5 (or %5)  In very simplistic terms, to rebalance to 5% for each coin. BTC : -$$1 USDT : +$$2 ETH : -$2
LTC  : 0
TRX  : +1


Two issues with this would be that USDT and TRX, although the math is right, because of the trading pairs the buys and sells would improperly balance the portfolio.

How might one recommend ordering the trades to rebalance properly?

Rebalancing based on percentage is simple, but this is confusing the heck out of me to get right.