pkmnct / robinhood-mint-sync-chrome

A browser extension that allows you to sync Robinhood and Mint
https://pkmnct.github.io/robinhood-mint-sync-chrome/
MIT License
53 stars 7 forks source link

"cash_available_from_instant_deposits" can increase 'stock' value unintentionally. #50

Open chris14991 opened 3 years ago

chris14991 commented 3 years ago

'cash_available_from_instant_deposits' appears to always return from Robinhood as the entire initial deposit and does not subtract any usage of that deposit ('instant_allocated' appears to be the amount used) This can result in 'cash' ending up as a negative number creating the addition of ''cash_available_from_instant_deposits' to 'stock'

Removing the subtraction of 'cash' from 'stock' and 'request.cash_available_from_instant_deposits' from 'uninvested_cash` resolves this issue for me locally, but i assume there is a case unknown to me where this subtraction is necessary.

For example what is happening with my current account. cash = 1 - 1000 // -999 stock = 1000 - ( -999 ) // 1999

      if (request.uninvested_cash) {
        cash = parseFloat(request.uninvested_cash) - parseFloat(request.cash_available_from_instant_deposits);
      }
      if (request.equities) {
        stocks = parseFloat(request.equities) - cash;
      }
billvsd commented 3 years ago

@chris14991 this subtraction was a change as a result of the Robinhood Cash balance being set as the cash balance + buying power that I reported in issue #44.

Currently, my Robinhood Cash Balance is not being correctly recorded with the extension because of the calculation cash = parseFloat(request.uninvested_cash) - parseFloat(request.cash_available_from_instant_deposits); results in a negative number.

@pkmnct I believe the following changes will fix this issue.

content/robinhood/main.ts : _add instant_allocated to returnValue_ if (json.instant_allocated && json.instant_allocated.amount) { returnValue.instant_allocated = json.instant_allocated.amount; }

content/mint/properties/update.js: _subtract cash_available_from_instant_deposits from instant_allocated_ if (request.uninvested_cash) { cash = parseFloat(request.uninvested_cash) - (parseFloat(request.cash_available_from_instant_deposits) - parseFloat(request.instant_allocated) ); }

This screenshot from Robinhood shows the "Instant Available" image

In my case, the current values are:

The current calculation was 0 - 10, resulting in -10.

By subtracting the instant_allocated, the calculation becomes 0 - (10 - 10) which is the correct result. The Mint UI does not allow negative numbers which is why my cash balance was stuck at an incorrect value.