Will I pay BID price or lowest necessary amount? I was wondering about how ASKs and BIDs are matched:

Say I set up two separate trading accounts on mtgox.

On my first account, I offer to sell 1 BTC for 1000 USD

...Nobody will buy it (at current rates) so a sell will not happen.

Now, on my second account I offer to buy 1 BTC at 1000 USD.

I guess everyone will take that offer, and the buy will happen.

But will I get the 1000 USD that my first account is willing to pay (being the highest match), or what will happen?

I have a feeling this is a 'stupid' question, but I have no experience in how trading systems work.
First account gets nothing.

Second account buys them starting from the lowest offer, going up.

Such as, there are sells:


0.30 units @ a price of 100
0.10 @ 150
0.40 @ 650
0.80 @ 850
1.00 @ 1000 (your first offer)


You post a limit order to buy 1.00 unit @ a maximum price of 1000, you get:


0.30 @ 100 (total spent 30)
0.10 @ 150 (total 45)
0.40 @ 650 (total 305)
0.20 @ 850 (total 475)


You got the amount requested (1.00 units), spending 475 instead of 1000 (the maximum you were willing to spend).

The new market depth will be:


0.60 @ 850
1.00 @ 1000 (your first offer)