Trades can have validation rules, as I described in the whitepaper.
The default setup I outlined would make it so that, after the miner puts his first tx ("purchase 10,000 A") in front of yours, your trade ("purchase 500 A") would be invalid. Meanwhile, other nodes would likely have picked up your transaction and the miner's first transaction. Because these two tx's would likely have similar transaction fees, who knows which would "win" (be in the next block). The miner's would almost certainly cost more overall and therefore have a larger trading fee, and might win out (even though it likely propagated slightly later), but the miner is only wasting his money (to tx and trading fees) with such large and pointless transactions.