pareeohnos / ktrade

A simple UI for managing your trades
MIT License
7 stars 5 forks source link

Trim buttons let you go into a short position (if youre long and visa versa) #14

Closed Dolivent closed 3 years ago

Dolivent commented 3 years ago

Trim buttons should be able to sell no more than the shares you own. Even if you submit a trim order, it hasn't been filled, and you click the button again (for whatever reason). A scenario where this is critical is if someone accidentally double clicks and submits sell orders in total in excess of what they have available to sell

pareeohnos commented 3 years ago

hmm damn I thought I'd protected against this already. Apparently I messed it up, but definitely need this!

Dolivent commented 3 years ago

Tested again (1/2 trim button):

  1. I buy 14 shares
  2. I rapidly click Trim 1/2 x 2 times, I have 0 shares, but a stop of -7 shares remains
  3. I rapidly click Trim 1/2 x 3 times, then I end up with -14 shares
  4. I rapidly click Trim 1/2 x 4 times, then I end up with -21 shares.

Tested again (1/3 trim button):

  1. I buy 14 shares
  2. I rapidly click Trim 1/3 x 2 times, I have 4 shares, but a stop of -9 shares remains.
  3. I rapidly click Trim 1/3 x 3 times, then I end up with -10 shares
  4. I rapidly click Trim 1/3 x 4 times, then I end up with -15 shares.

The app appears to update the stop for the first click and not the subsequent clicks. Should also prompt user in case they accidentally double click the trim button