Coverage for src/finbot/portfolio/position.py: 100%

12 statements  

« prev     ^ index     » next       coverage.py v7.15.4, created at 2026-08-21 17:12 +0000

1from dataclasses import dataclass 

2 

3 

4@dataclass 

5class Position: 

6 symbol: str 

7 quantity: float = 0.0 

8 average_entry_price: float = 0.0 

9 realized_pnl: float = 0.0 

10 entry_fees: float = 0.0 

11 

12 def market_value(self, market_price: float) -> float: 

13 return self.quantity * market_price 

14 

15 def unrealized_pnl(self, market_price: float) -> float: 

16 return (market_price - self.average_entry_price) * self.quantity