Sub topic 8
Computing Exchange Inflows, Outflows, and Netflow
This chapter assumes you understand blockchain transactions, wallet addresses, and the difference between Bitcoin’s UTXO model and Ethereum’s account model. You should also be able to read basic Python lists, dictionaries, and functions.
The three flow measures
An exchange flow measures assets moving between addresses labeled as belonging to an exchange and addresses outside that exchange. Use the same asset, chain, and time period for every value.
- Inflow is the total amount sent from outside addresses to exchange addresses.
- Outflow is the total amount sent from exchange addresses to outside addresses.
- Netflow is inflow minus outflow.
The sign of netflow gives a quick summary:
| Measure | Formula | Typical interpretation |
|---|---|---|
| Inflow | Sum of transfers into the exchange | Assets became available at exchange-controlled addresses |
| Outflow | Sum of transfers leaving the exchange | Assets left exchange-controlled addresses |
| Netflow | Inflow − outflow | Positive means net movement in; negative means net movement out |
A positive netflow does not prove that users are preparing to sell. Assets may move between exchange wallets, into custody, or to a service address. A negative netflow does not prove buying or withdrawal by customers. You need labels, timing, and other evidence.
Label addresses before calculating
The calculation depends on an address-label set. A label maps an address to an entity such as ExchangeA. One exchange can control many addresses:
- Deposit addresses assigned to individual customers
- Hot wallets used for frequent transactions
- Warm wallets used for operational liquidity
- Cold wallets used for longer-term storage
- Consolidation and routing addresses
If only one of these groups is labeled, the reported flow may be incomplete. More importantly, transfers between two addresses belonging to the same exchange must not count as external inflow or outflow.
For a transfer from address A to address B:
- Count it as inflow if
Bbelongs to the exchange andAdoes not. - Count it as outflow if
Abelongs to the exchange andBdoes not. - Ignore it if both addresses belong to the same exchange.
- Usually ignore it if neither address is labeled.
Implementing the calculation
The following function aggregates labeled transfers by exchange and day. Amounts are assumed to use one consistent unit, such as ETH or USDC.
from collections import defaultdict
def exchange_netflow(transfers, exchange_labels):
"""transfers: dicts with 'day', 'from', 'to', 'amount'.
exchange_labels: maps an address to an exchange name."""
flows = defaultdict(lambda: {"inflow": 0.0, "outflow": 0.0})
for transfer in transfers:
source = exchange_labels.get(transfer["from"])
target = exchange_labels.get(transfer["to"])
if source == target:
continue
if target:
flows[(target, transfer["day"])]["inflow"] += transfer["amount"]
if source:
flows[(source, transfer["day"])]["outflow"] += transfer["amount"]
return {
key: {**values, "netflow": values["inflow"] - values["outflow"]}
for key, values in flows.items()
}
labels = {"addr_ex1": "ExchangeA", "addr_ex2": "ExchangeA"}
transfers = [
{"day": "2026-11-26", "from": "addr_user", "to": "addr_ex1", "amount": 120.0},
{"day": "2026-11-26", "from": "addr_ex1", "to": "addr_ex2", "amount": 500.0},
{"day": "2026-11-26", "from": "addr_ex2", "to": "addr_other", "amount": 30.0},
]
print(exchange_netflow(transfers, labels))The result records 120 units of inflow, 30 units of outflow, and 90 units of netflow. The 500-unit transfer is excluded because both addresses are labeled as ExchangeA.
A daily flow pipeline
Exercise
Exercise
An exchange receives 800 tokens from outside addresses and sends 1,100 tokens to outside addresses on the same day. What is its netflow, and what does the result establish?
Show answer
Netflow is 800 − 1,100 = −300 tokens. It establishes net movement out of labeled exchange addresses, but it does not by itself establish why the tokens moved or what traders will do next.