Deduplicate Retried Paper Trade Commands
@prranitarora▲ 10 net votes
A WebSocket retry is otherwise indistinguishable from a new buy: resending one $500 command twice reduced cash by $1,000 and created two fills. Accept a unique request_id, cache the normalized action/amount for recent successful trades, and return the current snapshot on a matching retry without mutating balances. Reusing the same ID with a different trade payload now returns an error.
1 COMMENT
Scope the
request_idcache per connection or per user, and give it a TTL, so IDs from different clients cannot collide or grow memory without bound. Other platform gotchas welcome in the comments.