Most exchanges work with an order book. In this method, the two parties involved in the trade are slightly different.
The order book lists prices at which people want to buy and prices at which people want to sell.
You can see btc-e's order book on their homepage. Let's assume the following simple order book:
person 1 wants to sell 3 BTC for 101 EUR/BTC
person 2 wants to sell 1 BTC for 100 EUR/BTC
person 3 wants to buy 2 BTC for 95 EUR/BTC
person 4 wants to buy 5 BTC for 90 EUR/BTC
Note the ordering of the orders, it's on purpose. In all order books, the highers buy price is always lower than the lowest sell price.
Now, these people are passive traders (this is afaik not an official term), meaning that they are waiting for the price to reach a certain value in order to trade. Mostly, they do not need to buy/sell fast, but want to have a good price.
Then, there are active traders, that want to do their trades immediately. So, when I want to buy 1 BTC immediately ("at market price"), I will have to pay 100 EUR for it, as this is the best sell offer I can buy from. If I wanted to fast sell 1 BTC, I would get only 95 EUR for it, meeting the best buy order to sell at.
So in fact, when an active trader wants to buy 1 BTC, he actually creates a buy order for 1 BTC ar 100 EUR/BTC. This order will match the order from
person 2, so they will trade. This means that the trade is initiated by the buy order from the active trader. For this reason, this trade will be logged as a buy trade.
Rounding up: Trades are logged according to the type of trade the active trader did.
Some things that are useful to keep in mind:
- The bid/ask prices that most exchanges advertise, are the highest buy and lowest sell prices from the order book, respectively.
- A buy trade will raise the lowest ask price (or keep it the same), while a sell trade will lower the highest bid price.