Good morning,
i am in the middle of developing my own stock exchange system and have implemented limit orders (basics) matching. The system is just a DIY solution for my own purposes and for fun mainly. The whole system is utilising my own text protocol for traders to be able to login/place orders/receive notifications. This is done for BTC exchange.
However i am stuck when it comes to calculations of the traders wallets.
I don't think i know exactly what is going on behind the scenes therefore i would really appreciate if somebody could shed a bit of light on it for me.
I believe wallets are updated only in 3 places:
- New Order is placed: What happens with trader wallet when he places order (buy/sell)
- Cancel order is placed: What happens with trader wallet when he places cancel order (buy/sell)
- Match is made and a Trade is generated (full/partial) - what happens with te wallets of both traders?
What i am trying to understand is what happens with the BTC's and USD's in Traders wallets when orders are placed/cancelled/matched and how is this handled.
Thank you very much for your input into this.