Countries trade different amounts of goods that are inherently imbalanced. How do currency traders resolve these imbalances in the demand for different currencies? For example....
Imagine we have two countries, Oilonia whose primary export is oil, and Chocolatonia whose primary export is chocolate. In Oilonia the currency is oilinos and the main moneychanger is Bancoilio. In Chocolatonia the currency is chocolatinos and the main money changer is Chocolatanza.
Imagine that in the year they first encounter each other there is a candy dealer in Oilonia who wants to import 1000 pounds of chocolate from Chocolatonia, and there is an oil dealer in Chocolatonia who would like to import as much as 10,000 tonnes of oil from Oilonia. The price of chocolate in Chocolatonia is 4 chocolatinos per pound and the price of oil in Oilonia is 400 oilinos per tonne.
The two dealers go to the money changers in their country and tell them their needs. The currency brokers at the two money changers then talk and one says "I need 4000 chocolatinos" and the other says "What a coincidence, I need 4 million oilinos." Now, if both changers have these amounts in inventory they might do a direct trade, 4000 chocolatinos for 4 million oilinos, and everybody is happy, but this trade would be unbalanced. For example, if Chocolatanza advertised an exchange rate of 1000 to 1 for oilinos, they would have people lined up at the door to take that deal, but nobody in Oilonia would want to do the corresponding deal at Bancoilio. So, if that deal got done, it would be a one-time event.
More likely, the two money changers would not sell currency out of their inventory at all, but would only do the deal so far as they could lay it off immediately. So, what would happen is that the candy dealer would tell Bancoilio, "I am willing to pay 5000 oilinos for the 4000 chocolatinos because I know I can sell the 1000 pounds of chocolate here for 9000 oilinos which would be a good profit for me." Meanwhile, in Chocolatonia, the oil dealer would tell Chocolatanza, "I am willing to pay 7 million chocolatinos for 4 million oilinos, because I know I can sell the 10,000 tonnes of oil for much more than that." So, now what happens is that Bancoilio goes to Chocolatanza, adds in their own profit, and says, "We are willing to buy 4000 chocolatinos for 4500 oilinos." Chocolatanza answers, "That rate sounds great to us and we will happily make that deal, but we would like to buy 4 million oilinos at that rate, not just 4500." Bancoilio will then say "Sorry, we only have a need for 4500 chocolatinos right now."
So, they are at an impasse. The rate is profitable for both of them, but due to the difference in trade demand, one side is unable to get the amount of currency they want.
Chocolatanza could try to break the impasse by asking to borrow the oilinos. "Could we borrow the 4 million oilinos?" but Bancoilio will be reluctant to do this because they know that Chocolatanza will only be able to acquire a few thousand oilinos every year through the chocolate trade, so it will take a very long time before they could pay the loan back.
So, in this situation, how is progress made? How do real banks solve this problem?
I have abstracted the problem into the above described case, so I will not consider as "answers" generic descriptions of currency trading which I know very well. I would like to know the solution as it applies to the abstracted example. So, a valid answer would be something like "In the real world Chocolatanza would do X, Y and Z, then Bancolio would do P an d Q" or whatever. For the purpose of the problem there are no other intermediary countries, nor are there any other non-monetary goods to trade (or if there are other goods, assume that the prices of those goods makes it infeasible to trade them between the two countries).