Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions finam_trade_api/account/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "finam-trade-api"
version = "4.2.5"
version = "4.2.6"
description = "Асинхронный REST-клиент для API Finam"
authors = ["DBoyara <boyarshin.den@yandex.ru>"]
license = "GNU GPL v.3.0"
Expand Down
54 changes: 47 additions & 7 deletions tests/account/test_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down