diff --git a/finam_trade_api/account/model.py b/finam_trade_api/account/model.py index 26a3732..b39cf8b 100644 --- a/finam_trade_api/account/model.py +++ b/finam_trade_api/account/model.py @@ -7,12 +7,12 @@ class Position(BaseModel): symbol: str - quantity: str - average_price: str - current_price: str - maintenance_margin: str - daily_pnl: str - unrealized_pnl: str + quantity: FinamDecimal + average_price: FinamDecimal + current_price: FinamDecimal + maintenance_margin: FinamDecimal | None = None + daily_pnl: FinamDecimal + unrealized_pnl: FinamDecimal class GetAccountResponse(BaseModel): diff --git a/pyproject.toml b/pyproject.toml index 31255d5..6eb83b4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "finam-trade-api" -version = "4.2.5" +version = "4.2.6" description = "Асинхронный REST-клиент для API Finam" authors = ["DBoyara "] license = "GNU GPL v.3.0" diff --git a/tests/account/test_account.py b/tests/account/test_account.py index 8ec8ed7..510dd7c 100644 --- a/tests/account/test_account.py +++ b/tests/account/test_account.py @@ -24,15 +24,55 @@ def account_client(token_manager): @pytest.mark.asyncio async def test_get_account_info_success(account_client): account_id = "account123" - # Создаем данные-заглушку на основе модели GetAccountResponse + # finam example response_data = { "account_id": account_id, - "type": "broker", - "status": "active", - "equity": {"value": "1000.0"}, - "unrealized_profit": {"value": "50.0"}, - "positions": [], - "cash": [], + "type": "UNION", + "status": "ACCOUNT_ACTIVE", + "equity": { + "value": "989.38" + }, + "unrealized_profit": { + "value": "0.4" + }, + "positions": [ + { + "symbol": "AFLT@MISX", + "quantity": { + "value": "10.0" + }, + "average_price": { + "value": "62.72" + }, + "current_price": { + "value": "62.76" + }, + "daily_pnl": { + "value": "0.4" + }, + "unrealized_pnl": { + "value": "0.4" + } + } + ], + "cash": [ + { + "currency_code": "RUB", + "units": "361", + "nanos": 7800000 + } + ], + "portfolio_mc": { + "available_cash": { + "value": "361.78" + }, + "initial_margin": { + "value": "627.6" + }, + "maintenance_margin": { + "value": "313.8" + } + }, "open_account_date": "2025-01-29T14:20:44Z", "first_trade_date": "2025-01-29T14:20:44Z", "first_non_trade_date": "2025-01-29T14:20:44Z",