Aggregating Balances from Multiple Crypto Exchanges in a Mobile App
A trader holds assets on Binance, Bybit, and OKX — each exchange requires opening a separate app or browser tab. This wastes time and increases the risk of errors when manually calculating the total position. For a large trader, manual data collection can take up to 2 hours per day, and ticker conversion mistakes cost hundreds of dollars monthly. We solve this by creating a unified dashboard (crypto portfolio) directly in the mobile app. The user sees the total position per token and a per-exchange breakdown on one screen. Our team specializes in exchange API integration: we have delivered over 20 such projects for iOS and Android. This approach reduces data collection time by an average of 85% compared to manual monitoring, saving the trader up to $500 per month.
How the Aggregation Architecture Works
Each exchange is a separate adapter implementing a common protocol. This pattern allows adding new exchanges without modifying the aggregator's business logic. Here’s an example in Kotlin for Android:
// Android, Kotlin
interface ExchangeAdapter {
suspend fun fetchSpotBalances(): Result<List<Balance>>
suspend fun fetchFuturesBalances(): Result<List<Balance>>
val exchangeId: String
}
data class Balance(
val ticker: String,
val available: BigDecimal,
val locked: BigDecimal,
val exchangeId: String
)
class BinanceAdapter(private val apiKey: String, private val secret: String) : ExchangeAdapter {
override val exchangeId = "binance"
override suspend fun fetchSpotBalances(): Result<List<Balance>> = runCatching {
val timestamp = System.currentTimeMillis()
val queryString = "timestamp=$timestamp&recvWindow=5000"
val signature = HmacSHA256.sign(queryString, secret)
val response = apiClient.get("/api/v3/account?$queryString&signature=$signature")
response.balances
.filter { it.free.toBigDecimal() > BigDecimal.ZERO || it.locked.toBigDecimal() > BigDecimal.ZERO }
.map { Balance(it.asset, it.free.toBigDecimal(), it.locked.toBigDecimal(), exchangeId) }
}
}
The aggregator runs all adapters in parallel using async/await (Kotlin coroutines or Swift TaskGroup), collects results, and collapses positions by ticker. In practice, with 10 exchanges, aggregation takes less than 2 seconds — 4x faster than sequential collection.
class BalanceAggregator(private val adapters: List<ExchangeAdapter>) {
suspend fun aggregate(): AggregatedPortfolio = coroutineScope {
val results = adapters.map { adapter ->
async { adapter.fetchSpotBalances() }
}.awaitAll()
val allBalances = results.flatMap { it.getOrElse { emptyList() } }
// Group by ticker, sum
val byTicker = allBalances.groupBy { it.ticker }
val aggregated = byTicker.map { (ticker, positions) ->
AggregatedPosition(
ticker = ticker,
totalAvailable = positions.sumOf { it.available },
byExchange = positions.associateBy { it.exchangeId }
)
}
AggregatedPortfolio(positions = aggregated, fetchedAt = Instant.now())
}
}
Why Error Isolation Matters
Errors from one exchange must not bring down the whole. If Bybit returns a 503, the user should see data from Binance and OKX with a label "Bybit: data unavailable". Hence Result<T> is mandatory — not optional — as the return type. On the UI: each source exchange shows a status (green/red/gray). This async aggregator yields up to 4x time savings compared to sequential collection.
Problems We Solve
Different ticker formats. Binance calls Tether USDT, some exchanges use USDT, others USDt. OKX uses TON-USDT as the trading pair for TON, with the base asset TON. Normalization is needed: an alias table and a canonical ticker for each asset. Incorrect conversion can lead to deposit loss — we eliminate this risk.
API keys and security. The user adds multiple key pairs. Each pair is encrypted separately via Android Keystore / iOS Keychain, tied to biometrics. When making a request to an exchange, the key is decrypted in memory, used, and not kept in the heap longer than necessary.
Clock drift. Binance and Bybit require the timestamp to be close to server time (±5 seconds). On the first request to each exchange, we synchronize time via their /time endpoint and keep an offset.
How It Looks in the UI
The main screen shows a list of assets with total positions. Tapping an asset reveals a per-exchange breakdown. An additional screen provides a breakdown by exchange: how much in USD on each. Updates via pull-to-refresh and automatically every 5 minutes while the app is active.
Exchange Protocol Comparison
| Exchange | Endpoint | Authorization | Notes |
|---|---|---|---|
| Binance | /api/v3/account |
HMAC-SHA256 | recvWindow, clock sync |
| Bybit V5 | /v5/account/wallet-balance |
HMAC-SHA256 | accountType: UNIFIED |
| OKX | /api/v5/account/balance |
HMAC + passphrase | 3 auth headers |
| Gate.io | /api/v4/spot/accounts |
HMAC-SHA512 | — |
Aggregation Approach Comparison
| Approach | Speed | Error Isolation | Ease of Adding Exchange |
|---|---|---|---|
| Ours (adapters + async aggregator) | High (parallel requests) | Full (Result<T> per adapter) | Low (single protocol) |
| Sequential collection | Low (wait for each response) | Partial (error breaks the chain) | Medium (logic in one place) |
| Single API gateway | Medium (network hop) | Depends on implementation | High (gateway must be maintained) |
How to Add a New Exchange: Step-by-Step
- Study the exchange documentation: endpoints, authorization, limits.
- Implement a class that implements
ExchangeAdapterin Swift (iOS) or Kotlin (Android). - Add ticker normalization to the common alias table.
- Test with the real API.
- Integrate into the UI and release an update.
How Long Does Aggregation Take?
With 4 exchanges, the full aggregation cycle takes about 1 second. The user can force an update via pull-to-refresh at any time.
Why Choose Our Implementation
- Over 5 years of experience in financial mobile app development.
- We guarantee security: all API keys are encrypted on the device, never transmitted to the server.
- Certified engineers with experience on cryptocurrency projects (iOS, Android, Flutter).
What’s Included
- Development of adapters for 4 exchanges (or your specified list).
- Secure key storage setup.
- Customizable UI dashboard.
- Push notification integration for balance changes.
- Aggregator API documentation and user instructions.
- One month of support after delivery.
Timeline and How to Order
Integration of three exchanges with aggregation and UI takes between 5 and 8 working days. Each additional exchange adds 1 day. Pricing is determined individually after requirements analysis. Contact us to discuss your project and get an accurate estimate. Get a consultation — just reach out. We also offer extended support and customizations upon request.
More about security
All API keys are stored only on the user’s device. On first launch, an encryption key is generated and tied to the biometric sensor. Decryption happens immediately before sending the request, after which the key is wiped. No data is transmitted to our servers.
Source: App Store Review Guidelines — sections 4.2 and 5.1 cover security and app functionality.







