diff --git a/src/trading/portfolio.py b/src/trading/portfolio.py index ac45ae1..c5ec315 100644 --- a/src/trading/portfolio.py +++ b/src/trading/portfolio.py @@ -14,21 +14,30 @@ class Position: @property def current_value(self) -> float: # TODO: Implement real-time price fetching + if self.entry_price is None or self.shares is None: + return 0.0 return self.shares * self.entry_price @property def potential_profit(self) -> float: """Calculate potential profit at target price""" + if self.target_price is None or self.entry_price is None or self.shares is None: + return 0.0 return (self.target_price - self.entry_price) * self.shares @property def potential_loss(self) -> float: """Calculate potential loss at stop loss""" + if self.stop_loss is None or self.entry_price is None or self.shares is None: + return 0.0 return (self.stop_loss - self.entry_price) * self.shares @property def risk_reward_ratio(self) -> float: """Calculate risk/reward ratio""" + if (self.target_price is None or self.entry_price is None or + self.stop_loss is None): + return 0.0 potential_gain = self.target_price - self.entry_price potential_risk = self.entry_price - self.stop_loss return abs(potential_gain / potential_risk) if potential_risk != 0 else 0