How do I know if there are lost packets? As in, what happens then?
If you have a good Internet connection there will be no packet loss, but if you use 3G, GPRS etc.. it does.
On Mt.Gox if you press Buy, or rule will be executed to buy something, then program will send one http request to buy and it will wait for response, if there will be no response during 3 seconds it send another same packet and repeat this until delivered.
Problem with Bitstamp is in situation when request was send and timeout is reached, but server was got this request, there will be two requests to buy, so if requested to buy 0.2BTC then server will receive request to buy 0.4BTC.
Duplicated requests are ignored on Mt.Gox and BTC-e.
So this is a Bitstamp API problem.
Currently Qt Bitcoin Trader send only one request to buy and sell and this helps to prevent duplicated requests but retry on packet loss works for cancel order request, because it is not critical.
You may can ask me: "Why not set timeout to 10 or more seconds?"
I'll answer, there is both way issue. To complete one buy/sell request there is two packets needed.
1) Client->Server (request to buy..)
2) Server->Client (confirmation)
So if 2) confirmation packet will be lost but 1) request will be delivered, then timeout of 10 seconds or more will not helps to prevent duplicated order be happend.
And there is no ID available to associate request with opened order list to verify delivery.
When Bitstamp will release new api that uses parameter "nonce" to identify duplicated packages then I'll update API client engine.