diff options
author | uvok | 2025-04-13 15:29:56 +0200 |
---|---|---|
committer | uvok | 2025-04-13 15:29:56 +0200 |
commit | 0ae387a8f433defc4af797692b7d1d247ce446ec (patch) | |
tree | 820470f717aa1ac5aa80023f7206e5580c8802c6 /bla.py | |
parent | 87065de467bd5cfc70e2b9a1d895fda76f308758 (diff) |
Better exception
Diffstat (limited to 'bla.py')
-rw-r--r-- | bla.py | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -11,7 +11,10 @@ class FIFOQueue: def remove(self, amount): remaining = amount cost_basis = 0 + while remaining > 0: + if not self.queue: + raise ValueError(f"Insufficient assets in queue to process sale of {amount}.") quantity, price = self.queue[0] if quantity > remaining: cost_basis += remaining * price @@ -21,6 +24,7 @@ class FIFOQueue: cost_basis += quantity * price remaining -= quantity self.queue.popleft() + return cost_basis def process_ledger(file_path): |