Jbays / crypto-calculator

Calculates profitability for crypto assets
0 stars 0 forks source link

balance table issues #25

Closed Jbays closed 6 years ago

Jbays commented 6 years ago

The balance table needs a one-to-one relationship with the coins_index table.

For each unique crypto, I should only have one balance. Otherwise knowing the actual balance for each unique crypto necessitates another query to the balance table -- summing up those entries.

This will block #24.

Annoying is that I'll have to change the schema -- yet again. :/

Jbays commented 6 years ago

For each unique cryptocurrency, the balance table may only have one entry. The balance table now has one-to-one relationship with the coins_index table.

26

To accomplish, I wrote balance2.js -- a script that correctly updates the balance table while taking into account all adjustments from all trades.

The process to fully update the balance table: Run script updateBalancePurchase.js THEN balance2.js

Then balance table will show all available units for each crypto-currency.

NOTES: I suspect balance2.js could:

  1. Calculate the weighted_usd_per_unit for all trades.
  2. Calculate the balance from purchases table.