Skip to main content

Market Making

TrexWallet includes automated market making for configured trading pairs. When enabled, it places and manages liquidity orders according to the operator's pair and spread settings.

How It Works

Automated market making

├── Reads aggregated rates from /markets/v1/get_rates
├── Calculates target prices with spread
├── Places buy/sell orders on the order book
├── Adjusts positions based on market conditions
└── Manages broker wallet balances

External rates are supplied by the configured rate service through GET /markets/v1/get_rates. As of v1.2.0 supported sources include Binance, Kraken, WhiteBit, Bitfinex, Huobi, Yobit, Bybit, Bestchange, and CoinGecko. Operators manage sources and update cadence in /MarketsAdmin/.

The Market Maker operates from a designated broker wallet and places limit orders at calculated price levels.

Configuration

Market Maker settings are configured through the admin panel at /TrexAdmin/MarketMaker:

SettingDescription
Trading pairsWhich currency pairs to provide liquidity for
SpreadPrice difference between buy and sell (fee margin)
Order sizeAmount per order level
LevelsNumber of price levels to maintain
Update intervalHow often to recalculate and adjust orders
EnabledToggle market making on/off per pair

Operation Cycle

  1. Rate fetch — pull the latest aggregated rates through get_rates.
  2. Price calculation — apply spread to determine bid/ask prices.
  3. Order management — cancel stale orders, place new ones at target prices.
  4. Balance check — ensure broker wallet has sufficient liquidity.
  5. Repeat — cycle runs continuously in the background.

Broker Wallet

The Market Maker uses a dedicated system wallet (broker) for all operations:

  • Orders are placed from the broker wallet
  • Matched orders credit/debit the broker wallet
  • The broker wallet must be funded with both currencies in each trading pair
  • Balance monitoring alerts when liquidity is low

Market Directions

Each trading pair has two directions:

DirectionExampleDescription
BuyBTC → USDTMarket maker buys BTC, sells USDT
SellUSDT → BTCMarket maker sells BTC, buys USDT

Each direction can have independent settings (spread, size, enabled status).

Integration with Exchange

Market Maker orders participate in the standard order book:

  • User places a market order → matches against Market Maker's limit orders
  • User places a limit order → may match if Market Maker has orders at that price
  • Market Maker orders are indistinguishable from user orders on the book

Rate Sources

The configured rate service returns a unified get_rates payload, so market making does not depend on one particular exchange being available.

Cross-rates are calculated when direct pairs aren't available:

  • Via USDT: TOKEN/USDT × USDT/TARGET
  • Via BTC: TOKEN/BTC × BTC/TARGET

Admin Panel

Manage the Market Maker at /TrexAdmin/MarketMaker:

  • View active trading pairs and their status
  • Configure spread, order sizes, and levels
  • Monitor broker wallet balances
  • Enable/disable individual pairs
  • View order history and fill rates

Monitoring

Market Maker activity is tracked through:

  • Application logs — order placement, cancellation, errors
  • Admin panel — real-time status and balance monitoring
  • OpenTelemetry — metrics and tracing (if configured)

Key metrics to watch:

  • Broker wallet balance per currency
  • Order fill rate
  • Spread effectiveness
  • Rate source availability