Skip to content

Commit

Permalink
fix portfolio docs
Browse files Browse the repository at this point in the history
  • Loading branch information
theOGognf committed Mar 10, 2024
1 parent 869112f commit ce72817
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/finagg/portfolio.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def buy(self, cost: float, quantity: float, /) -> float:
>>> pos = Position(100.0, 1)
>>> pos.buy(50.0, 1)
50.0
>>> pos.cost_basis_total
>>> pos.total_cost_basis
150.0
>>> pos.average_cost_basis
75.0
Expand Down Expand Up @@ -117,7 +117,7 @@ def sell(self, cost: float, quantity: float, /) -> float:
>>> pos = Position(100.0, 2)
>>> pos.sell(50.0, 1)
50.0
>>> pos.cost_basis_total
>>> pos.total_cost_basis
100.0
>>> pos.average_cost_basis
100.0
Expand Down Expand Up @@ -268,7 +268,7 @@ def buy(self, symbol: str, cost: float, quantity: float, /) -> float:
>>> port.buy("AAPL", 100.0, 1)
100.0
>>> pos = port["AAPL"]
>>> pos.cost_basis_total
>>> pos.total_cost_basis
100.0
>>> pos.average_cost_basis
100.0
Expand Down Expand Up @@ -321,7 +321,7 @@ def sell(self, symbol: str, cost: float, quantity: float, /) -> float:
>>> port.sell("AAPL", 50.0, 1)
50.0
>>> pos = port["AAPL"]
>>> pos.cost_basis_total
>>> pos.total_cost_basis
100.0
>>> pos.average_cost_basis
100.0
Expand Down Expand Up @@ -379,11 +379,11 @@ def total_dollar_value(self, costs: dict[str, float], /) -> float:
950.0
"""
dollar_value_total = self._cash
total_dollar_value = self._cash
for symbol, cost in costs.items():
if symbol in self.positions:
dollar_value_total += Decimal(cost) * self.positions[symbol]._quantity
return float(dollar_value_total)
total_dollar_value += Decimal(cost) * self.positions[symbol]._quantity
return float(total_dollar_value)

def total_log_change(self, costs: dict[str, float], /) -> float:
"""Compute the total log change relative to the total
Expand Down

0 comments on commit ce72817

Please sign in to comment.