jakub-mrow / AMS-backend

0 stars 0 forks source link

Rebuild StockBalance history #65

Closed dawids21 closed 11 months ago

dawids21 commented 12 months ago

Implement the mechanism of rebuilding the history of StockBalance whenever any transaction, whose date is before last_save_date for a stock, is added.

The process and the necessary steps are presented on the diagram:

  1. Get StockBalanceHistory before the rebuild.
  2. Get all transactions after the moment of rebuild sorted by date
  3. Create StockBalance from history
  4. For each day until yesterday apply the transactions and save the StockBalance in history.
  5. Apply transactions from today.
  6. Calculate XIRR for stock.
  7. Save StockBalance

Waiting for: