Skip to content

update Position model#87

Merged
DBoyara merged 2 commits into
DBoyara:masterfrom
a-popovkin:master
Feb 11, 2026
Merged

update Position model#87
DBoyara merged 2 commits into
DBoyara:masterfrom
a-popovkin:master

Conversation

@a-popovkin

Copy link
Copy Markdown
Contributor

Судя по всему, баг. В текущей реализации запрос GetAccount падает на десериализации. Обновил, чтобы соответствовало описанию из https://tradeapi.finam.ru/docs/guides/rest/accounts_service/GetAccount

Traceback (most recent call last):
  File "/Users/popovkin/Code/3dparty/FinamTradeApiPy/examples/account.py", line 34, in <module>
    asyncio.run(main())
  File "/Users/popovkin/.pyenv/versions/3.11.13/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/Users/popovkin/.pyenv/versions/3.11.13/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/popovkin/.pyenv/versions/3.11.13/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/Users/popovkin/Code/3dparty/FinamTradeApiPy/examples/account.py", line 16, in main
    pprint(await client.account.get_account_info(account_id))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/popovkin/Code/3dparty/FinamTradeApiPy/finam_trade_api/account/account.py", line 57, in get_account_info
    return GetAccountResponse(**response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/popovkin/Library/Caches/pypoetry/virtualenvs/finam-trade-api-d2aXmdeK-py3.11/lib/python3.11/site-packages/pydantic/main.py", line 250, in __init__
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 18 validation errors for GetAccountResponse
positions.0.quantity
  Input should be a valid string [type=string_type, input_value={'value': '1.0'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/string_type
positions.0.average_price
  Input should be a valid string [type=string_type, input_value={'value': '302.02'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/string_type
positions.0.current_price
  Input should be a valid string [type=string_type, input_value={'value': '301.73'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/string_type
positions.0.maintenance_margin
  Field required [type=missing, input_value={'symbol': 'SBER@MISX', '...nl': {'value': '-0.29'}}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/missing
positions.0.daily_pnl
  Input should be a valid string [type=string_type, input_value={'value': '-0.54'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/string_type
positions.0.unrealized_pnl
  Input should be a valid string [type=string_type, input_value={'value': '-0.29'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/string_type
positions.1.quantity
  Input should be a valid string [type=string_type, input_value={'value': '-1.0'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/string_type
positions.1.average_price
  Input should be a valid string [type=string_type, input_value={'value': '2786.8'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/string_type
positions.1.current_price
  Input should be a valid string [type=string_type, input_value={'value': '2786.65'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/string_type
positions.1.maintenance_margin
  Field required [type=missing, input_value={'symbol': 'MMH6@RTSX', '..._pnl': {'value': '1.5'}}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/missing
positions.1.daily_pnl
  Input should be a valid string [type=string_type, input_value={'value': '0.0'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/string_type
positions.1.unrealized_pnl
  Input should be a valid string [type=string_type, input_value={'value': '1.5'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/string_type
positions.2.quantity
  Input should be a valid string [type=string_type, input_value={'value': '1056.0'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/string_type
positions.2.average_price
  Input should be a valid string [type=string_type, input_value={'value': '1.6832'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/string_type
positions.2.current_price
  Input should be a valid string [type=string_type, input_value={'value': '1.9171'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/string_type
positions.2.maintenance_margin
  Field required [type=missing, input_value={'symbol': 'LQDT@MISX', '...l': {'value': '246.96'}}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/missing
positions.2.daily_pnl
  Input should be a valid string [type=string_type, input_value={'value': '1.44'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/string_type
positions.2.unrealized_pnl
  Input should be a valid string [type=string_type, input_value={'value': '246.96'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/string_type

@DBoyara

DBoyara commented Feb 9, 2026

Copy link
Copy Markdown
Owner

Поменяй, пожалуйста, в pyproject.toml версию на version = "4.2.6"

@a-popovkin

Copy link
Copy Markdown
Contributor Author

@DBoyara долил комит с апом версии

@DBoyara DBoyara merged commit bf99150 into DBoyara:master Feb 11, 2026
7 checks passed
@DBoyara

DBoyara commented Feb 11, 2026

Copy link
Copy Markdown
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants