30 lines
940 B
Python
30 lines
940 B
Python
|
|
"""Tests for portfolio tracker."""
|
||
|
|
|
||
|
|
import pytest
|
||
|
|
from src.portfolio.tracker import get_portfolio_tracker, PortfolioTracker
|
||
|
|
|
||
|
|
|
||
|
|
class TestPortfolioTracker:
|
||
|
|
"""Tests for PortfolioTracker."""
|
||
|
|
|
||
|
|
@pytest.fixture
|
||
|
|
def tracker(self):
|
||
|
|
"""Create portfolio tracker instance."""
|
||
|
|
return get_portfolio_tracker()
|
||
|
|
|
||
|
|
@pytest.mark.asyncio
|
||
|
|
async def test_get_current_portfolio(self, tracker):
|
||
|
|
"""Test getting current portfolio."""
|
||
|
|
portfolio = await tracker.get_current_portfolio(paper_trading=True)
|
||
|
|
assert portfolio is not None
|
||
|
|
assert "positions" in portfolio
|
||
|
|
assert "performance" in portfolio
|
||
|
|
|
||
|
|
@pytest.mark.asyncio
|
||
|
|
async def test_update_positions_prices(self, tracker):
|
||
|
|
"""Test updating position prices."""
|
||
|
|
prices = {"BTC/USD": 50000.0}
|
||
|
|
await tracker.update_positions_prices(prices, paper_trading=True)
|
||
|
|
# Should not raise exception
|
||
|
|
|