API Reference¶
This page contains the automatically generated API reference documentation for the folioman-client library, extracted directly from the Python source docstrings.
Package Root¶
folioman_client ¶
Folioman API Client Package.
Typed asynchronous Python SDK for the Folioman REST API.
ConfiguredDate
module-attribute
¶
ConfiguredDate = Annotated[date, PlainSerializer(lambda x: x.isoformat(), return_type=str, when_used='unless-none')]
Date type serialized to ISO-8601 string (YYYY-MM-DD) unless None.
ConfiguredDatetime
module-attribute
¶
ConfiguredDatetime = Annotated[datetime, PlainSerializer(lambda x: x.isoformat(), return_type=str, when_used='unless-none')]
Datetime type serialized to ISO-8601 string unless None.
ConfiguredDecimal
module-attribute
¶
ConfiguredDecimal = Annotated[Decimal, PlainSerializer(lambda x: float(x), return_type=float, when_used='unless-none')]
Decimal type serialized to float unless None.
JWTAuthManager ¶
Manages JWT authentication state, token storage, and refresh lifecycle.
Keeps tokens private so they are never leaked outside the client.
Source code in src/folioman_client/auth.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
has_tokens
property
¶
True if the manager currently holds an access or refresh token.
__init__ ¶
Initialize JWTAuthManager with API credentials.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_url
|
str
|
Base URL of the Folioman server. |
required |
username
|
str
|
Username for authentication. |
required |
password
|
str
|
Password for authentication. |
required |
Source code in src/folioman_client/auth.py
clear ¶
get_valid_token
async
¶
Return a valid access token, proactively refreshing or authenticating if needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
AsyncClient
|
The httpx AsyncClient transport instance to execute requests. |
required |
Returns:
| Type | Description |
|---|---|
str
|
A valid JWT access token string. |
Raises:
| Type | Description |
|---|---|
FoliomanAuthError
|
If authentication or refresh fails. |
Source code in src/folioman_client/auth.py
force_refresh
async
¶
Force a refresh or re-authentication after receiving a 401.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
AsyncClient
|
The httpx AsyncClient transport instance to execute requests. |
required |
Returns:
| Type | Description |
|---|---|
str
|
A new valid JWT access token string. |
Raises:
| Type | Description |
|---|---|
FoliomanAuthError
|
If renewal or re-authentication fails. |
Source code in src/folioman_client/auth.py
CapitalGainsResource ¶
Bases: _BaseResource
Endpoints for realised capital gains reporting.
Source code in src/folioman_client/client.py
list
async
¶
List realised STCG/LTCG across every financial year with disposals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
investor_id
|
int
|
The ID of the investor. |
required |
include_unreconciled
|
bool
|
Whether to include unreconciled transactions. |
False
|
Returns:
| Type | Description |
|---|---|
list[CapitalGainsFyPoint]
|
List of CapitalGainsFyPoint models summarizing capital gains by financial year. |
Raises:
| Type | Description |
|---|---|
FoliomanNotFoundError
|
If the investor does not exist. |
FoliomanAuthError
|
If authentication fails. |
FoliomanAPIError
|
If the server returns an error response. |
Source code in src/folioman_client/client.py
get
async
¶
Get realised capital gains report for a specific financial year.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
investor_id
|
int
|
The ID of the investor. |
required |
fy
|
str
|
Financial year string, e.g. "2024-25". |
required |
include_unreconciled
|
bool
|
Whether to include unreconciled transactions. |
False
|
Returns:
| Type | Description |
|---|---|
CapitalGainsReport
|
CapitalGainsReport model with detailed lot-level gains. |
Raises:
| Type | Description |
|---|---|
FoliomanNotFoundError
|
If the investor does not exist. |
FoliomanAuthError
|
If authentication fails. |
FoliomanAPIError
|
If the server returns an error response. |
Source code in src/folioman_client/client.py
FoliomanClient ¶
Asynchronous client for interacting with the Folioman API.
Handles authentication, token refresh, and request execution.
Example
Source code in src/folioman_client/client.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 | |
__init__ ¶
__init__(base_url: str | None = None, username: str | None = None, password: str | None = None, timeout: float = 30.0, http_client: AsyncClient | None = None) -> None
Initialize FoliomanClient.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_url
|
str | None
|
Base URL of the Folioman REST API. If None, loaded from settings/environment. |
None
|
username
|
str | None
|
Username for API authentication. If None, loaded from settings/environment. |
None
|
password
|
str | None
|
Password for API authentication. If None, loaded from settings/environment. |
None
|
timeout
|
float
|
Request timeout in seconds. Defaults to 30.0. |
30.0
|
http_client
|
AsyncClient | None
|
Optional custom httpx.AsyncClient instance for custom transport/pooling. |
None
|
Source code in src/folioman_client/client.py
from_settings
classmethod
¶
Create a client instance from a FoliomanSettings object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
FoliomanSettings
|
FoliomanSettings configuration object. |
required |
Returns:
| Type | Description |
|---|---|
FoliomanClient
|
A configured FoliomanClient instance. |
Source code in src/folioman_client/client.py
from_env
classmethod
¶
Create a client instance using environment variables.
Returns:
| Type | Description |
|---|---|
FoliomanClient
|
A configured FoliomanClient instance using environment defaults. |
Source code in src/folioman_client/client.py
__aenter__
async
¶
Enter the async context manager.
Returns:
| Type | Description |
|---|---|
FoliomanClient
|
The FoliomanClient instance. |
__aexit__
async
¶
close
async
¶
request
async
¶
request(method: str, path: str, *, params: dict[str, Any] | None = None, json: Any | None = None, headers: dict[str, str] | None = None, **kwargs: Any) -> Any
Execute an authenticated HTTP request with automatic token refresh and 401 retry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
str
|
HTTP method ("GET", "POST", etc.) |
required |
path
|
str
|
Relative API path (e.g. "/investors/1") |
required |
params
|
dict[str, Any] | None
|
Optional query parameters. |
None
|
json
|
Any | None
|
Optional JSON request payload. |
None
|
headers
|
dict[str, str] | None
|
Optional extra headers. |
None
|
**kwargs
|
Any
|
Additional keyword arguments passed to httpx.AsyncClient.request. |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
Parsed JSON response, or None if status code is 204 or body is empty. |
Raises:
| Type | Description |
|---|---|
FoliomanNotFoundError
|
If response is 404. |
FoliomanAuthError
|
If authentication fails or refresh is rejected. |
FoliomanAPIError
|
If server responds with other 4xx or 5xx status codes. |
Source code in src/folioman_client/client.py
HoldingsResource ¶
Bases: _BaseResource
Endpoints for querying investor holdings and scheme details.
Source code in src/folioman_client/client.py
list
async
¶
List priced holdings for an investor (extracted from portfolio summary).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
investor_id
|
int
|
The ID of the investor. |
required |
as_of
|
date | str | None
|
Optional point-in-time date. |
None
|
Returns:
| Type | Description |
|---|---|
list[Holding]
|
A list of Holding models. |
Raises:
| Type | Description |
|---|---|
FoliomanNotFoundError
|
If the investor does not exist. |
FoliomanAuthError
|
If authentication fails. |
FoliomanAPIError
|
If the server returns an error response. |
Source code in src/folioman_client/client.py
get
async
¶
Get detailed holding/scheme information (NAV history, transactions, folios).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
investor_id
|
int
|
The ID of the investor. |
required |
security_id
|
int
|
The ID of the security/scheme. |
required |
as_of
|
date | str | None
|
Optional point-in-time valuation date. |
None
|
Returns:
| Type | Description |
|---|---|
SchemeDetail
|
SchemeDetail model with full NAV points, folio balances, and transactions. |
Raises:
| Type | Description |
|---|---|
FoliomanNotFoundError
|
If the investor or security does not exist. |
FoliomanAuthError
|
If authentication fails. |
FoliomanAPIError
|
If the server returns an error response. |
Source code in src/folioman_client/client.py
InvestorsResource ¶
Bases: _BaseResource
Endpoints for managing and querying investors.
Source code in src/folioman_client/client.py
list
async
¶
List investors accessible to the authenticated advisor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
family_id
|
int | None
|
Filter by parent family group ID. |
None
|
unaffiliated
|
bool
|
If True, only returns investors not affiliated with any family. |
False
|
Returns:
| Type | Description |
|---|---|
list[Investor]
|
A list of Investor summary models. |
Raises:
| Type | Description |
|---|---|
FoliomanAuthError
|
If authentication fails. |
FoliomanAPIError
|
If the server returns an error response. |
Source code in src/folioman_client/client.py
get
async
¶
Get investor details including masked PAN.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
investor_id
|
int
|
Unique identifier of the investor. |
required |
Returns:
| Type | Description |
|---|---|
InvestorDetail
|
InvestorDetail model containing extended profile information. |
Raises:
| Type | Description |
|---|---|
FoliomanNotFoundError
|
If the investor ID does not exist. |
FoliomanAuthError
|
If authentication fails. |
FoliomanAPIError
|
If the server returns an error response. |
Source code in src/folioman_client/client.py
PortfolioResource ¶
Bases: _BaseResource
Endpoints for investor portfolio summary and allocation.
Source code in src/folioman_client/client.py
get
async
¶
Get the full portfolio summary, metrics, and asset mix for an investor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
investor_id
|
int
|
The ID of the investor. |
required |
as_of
|
date | str | None
|
Optional point-in-time valuation date (YYYY-MM-DD or date object). |
None
|
Returns:
| Type | Description |
|---|---|
PortfolioSummary
|
PortfolioSummary model containing metrics, holdings, and allocation mixes. |
Raises:
| Type | Description |
|---|---|
FoliomanNotFoundError
|
If the investor ID does not exist. |
FoliomanAuthError
|
If authentication fails. |
FoliomanAPIError
|
If the server returns an error response. |
Source code in src/folioman_client/client.py
TransactionsResource ¶
Bases: _BaseResource
Endpoints for querying transaction ledger entries.
Source code in src/folioman_client/client.py
list
async
¶
List all transactions for an investor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
investor_id
|
int
|
The ID of the investor. |
required |
Returns:
| Type | Description |
|---|---|
list[Transaction]
|
List of Transaction ledger entries. |
Raises:
| Type | Description |
|---|---|
FoliomanNotFoundError
|
If the investor does not exist. |
FoliomanAuthError
|
If authentication fails. |
FoliomanAPIError
|
If the server returns an error response. |
Source code in src/folioman_client/client.py
ValuationsResource ¶
Bases: _BaseResource
Endpoints for portfolio net-worth history and valuation status.
Source code in src/folioman_client/client.py
list
async
¶
list(investor_id: int, *, from_date: date | str | None = None, to_date: date | str | None = None, granularity: Literal['daily', 'weekly', 'monthly'] = 'monthly') -> ValueSeries
Get net-worth time series reconstructed from ledger and NAV history.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
investor_id
|
int
|
The ID of the investor. |
required |
from_date
|
date | str | None
|
Start date of series. |
None
|
to_date
|
date | str | None
|
End date of series. |
None
|
granularity
|
Literal['daily', 'weekly', 'monthly']
|
Sampling frequency ('daily', 'weekly', or 'monthly'). |
'monthly'
|
Returns:
| Type | Description |
|---|---|
ValueSeries
|
ValueSeries model containing historical valuation points. |
Raises:
| Type | Description |
|---|---|
FoliomanNotFoundError
|
If the investor does not exist. |
FoliomanAuthError
|
If authentication fails. |
FoliomanAPIError
|
If the server returns an error response. |
Source code in src/folioman_client/client.py
status
async
¶
Get the current valuation calculation readiness status for an investor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
investor_id
|
int
|
The ID of the investor. |
required |
Returns:
| Type | Description |
|---|---|
ValuationStatus
|
ValuationStatus model indicating calculation state and coverage. |
Raises:
| Type | Description |
|---|---|
FoliomanNotFoundError
|
If the investor does not exist. |
FoliomanAuthError
|
If authentication fails. |
FoliomanAPIError
|
If the server returns an error response. |
Source code in src/folioman_client/client.py
FoliomanSettings ¶
Bases: BaseSettings
Folioman client configuration backed by environment variables.
Attributes:
| Name | Type | Description |
|---|---|---|
base_url |
str
|
The base URL of the Folioman REST API service. Defaults to "http://localhost:8000". |
username |
str
|
The username used for HTTP basic or JWT token retrieval. Defaults to "". |
password |
str
|
The password used for HTTP basic or JWT token retrieval. Defaults to "". |
timeout |
float
|
The request timeout in seconds. Defaults to 30.0. |
Source code in src/folioman_client/config.py
FoliomanAPIError ¶
Bases: FoliomanError
Raised when the Folioman API returns an error response (HTTP 4xx/5xx).
Attributes:
| Name | Type | Description |
|---|---|---|
status_code |
The HTTP status code returned by the server. |
|
response_data |
Parsed response payload or raw error details, if available. |
Source code in src/folioman_client/errors.py
__init__ ¶
Initialize FoliomanAPIError with message, status code, and optional payload.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Human-readable description of the error. |
required |
status_code
|
int
|
HTTP response status code (e.g., 400, 500). |
required |
response_data
|
Any | None
|
Deserialized JSON payload or raw text error from the server. |
None
|
Source code in src/folioman_client/errors.py
FoliomanAuthError ¶
Bases: FoliomanError
Raised when authentication fails (invalid credentials, expired/rejected token refresh).
FoliomanError ¶
FoliomanNotFoundError ¶
Bases: FoliomanError
Raised when the requested resource is not found (HTTP 404).
AccessToken ¶
Bases: FoliomanBaseModel
Refreshed access token.
Attributes:
| Name | Type | Description |
|---|---|---|
access |
str
|
Newly minted short-lived JWT bearer token. |
Source code in src/folioman_client/models.py
AllocationBucket ¶
Bases: FoliomanBaseModel
Allocation breakdown row by AMC or category.
Attributes:
| Name | Type | Description |
|---|---|---|
label |
str
|
AMC name or category classification label. |
value_inr |
ConfiguredDecimal
|
Total valuation allocated to this bucket in INR. |
Source code in src/folioman_client/models.py
AssetMixRow ¶
Bases: FoliomanBaseModel
Allocation breakdown row by security type.
Attributes:
| Name | Type | Description |
|---|---|---|
security_type |
str
|
Asset class label (e.g. 'EQUITY', 'DEBT', 'CASH'). |
value_inr |
ConfiguredDecimal
|
Total valuation allocated to this security type in INR. |
Source code in src/folioman_client/models.py
CapitalGainRow ¶
Bases: FoliomanBaseModel
One realised disposal lot in capital gains report.
Attributes:
| Name | Type | Description |
|---|---|---|
security_id |
int | None
|
ID of the security redeemed or sold. |
name |
str
|
Name of the security or mutual fund scheme. |
isin |
str
|
ISIN code of the security. |
units |
ConfiguredDecimal
|
Number of units redeemed or disposed. |
sale_value |
ConfiguredDecimal
|
Realized sale proceeds in INR. |
cost |
ConfiguredDecimal
|
Indexed or purchase cost basis in INR. |
gain |
ConfiguredDecimal
|
Realized capital gain or loss in INR. |
term |
str
|
Classification of gain ('STCG' or 'LTCG'). |
acquired_on |
ConfiguredDate
|
Original purchase date of the lot. |
sold_on |
ConfiguredDate
|
Date of disposal or redemption. |
grandfathering_unavailable |
bool
|
Whether Section 112A grandfathering is unavailable. |
Source code in src/folioman_client/models.py
CapitalGainsFyPoint ¶
Bases: FoliomanBaseModel
Year-over-year capital gains summary point.
Attributes:
| Name | Type | Description |
|---|---|---|
fy |
str
|
Financial year label (e.g., '2023-24'). |
stcg |
ConfiguredDecimal
|
Total realized STCG for the year. |
ltcg |
ConfiguredDecimal
|
Total realized LTCG for the year. |
Source code in src/folioman_client/models.py
CapitalGainsReport ¶
Bases: FoliomanBaseModel
Realised capital gains report for a financial year (CapitalGainsOut).
Attributes:
| Name | Type | Description |
|---|---|---|
fy |
str
|
Financial year label (e.g., '2024-25'). |
stcg_total |
ConfiguredDecimal
|
Total realized Short-Term Capital Gains in INR. |
ltcg_total |
ConfiguredDecimal
|
Total realized Long-Term Capital Gains in INR. |
rows |
list[CapitalGainRow]
|
Detailed breakdown of individual disposal lots. |
disclaimer |
str
|
Legal or regulatory tax disclaimer text. |
Source code in src/folioman_client/models.py
FolioBalance ¶
Bases: FoliomanBaseModel
Balance for one folio holding a security.
Attributes:
| Name | Type | Description |
|---|---|---|
number |
str
|
Folio account number. |
broker |
str
|
Broker / ARN identifier associated with the folio. |
folio_type |
str
|
Type classification of the folio account. |
units |
ConfiguredDecimal
|
Unit balance held under this folio. |
value_inr |
ConfiguredDecimal | None
|
Monetary valuation in INR for this folio. |
Source code in src/folioman_client/models.py
FoliomanBaseModel ¶
Bases: BaseModel
Base model with common configuration for all Folioman models.
Ignores extra keys sent by the API for forward compatibility and supports field population by name.
Source code in src/folioman_client/models.py
Holding ¶
Bases: FoliomanBaseModel
Priced holding row under an investor.
Attributes:
| Name | Type | Description |
|---|---|---|
security_id |
int
|
Unique identifier for the underlying security/scheme. |
name |
str
|
Name of the security or mutual fund scheme. |
security_type |
str
|
Category of the security (e.g., 'MF', 'EQUITY'). |
symbol |
str
|
Ticker symbol or trading identifier. |
amc |
str
|
Asset Management Company name. |
category |
str
|
SEBI category or mutual fund classification. |
units |
ConfiguredDecimal
|
Total quantity of units held. |
value_inr |
ConfiguredDecimal | None
|
Current market valuation in INR. |
invested_inr |
ConfiguredDecimal | None
|
Total invested amount (cost basis) in INR. |
latest_nav |
ConfiguredDecimal | None
|
Latest available Net Asset Value. |
return_pct |
float | None
|
Absolute percentage return. |
xirr |
float | None
|
Extended Internal Rate of Return (annualized). |
day_change_inr |
ConfiguredDecimal | None
|
Monetary change in valuation since the previous trading day. |
day_change_pct |
float | None
|
Percentage change since the previous trading day. |
Source code in src/folioman_client/models.py
Investor ¶
Bases: FoliomanBaseModel
Investor summary representation.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
int
|
Unique numeric identifier of the investor. |
name |
str
|
Full legal name or display name of the investor. |
email |
str
|
Contact email address of the investor. |
is_huf |
bool
|
Whether the investor represents a Hindu Undivided Family. |
relation |
str
|
Relationship description if part of a family group. |
family_id |
int | None
|
ID of the parent family group, if affiliated. |
has_pan |
bool
|
Whether a Permanent Account Number is registered. |
pan_locked |
bool
|
Whether PAN changes are locked for compliance. |
created_at |
ConfiguredDatetime | None
|
Timestamp when the investor record was created. |
updated_at |
ConfiguredDatetime | None
|
Timestamp when the investor record was last updated. |
Source code in src/folioman_client/models.py
InvestorDetail ¶
Bases: Investor
Investor detailed representation with masked PAN.
Attributes:
| Name | Type | Description |
|---|---|---|
pan_masked |
str
|
Masked PAN string (e.g. 'ABCDE****F') protecting sensitive PII. |
Source code in src/folioman_client/models.py
NavPoint ¶
Bases: FoliomanBaseModel
Single date and NAV point.
Attributes:
| Name | Type | Description |
|---|---|---|
date |
ConfiguredDate
|
Valuation date for the NAV point. |
nav |
ConfiguredDecimal
|
Net Asset Value per unit on the specified date. |
Source code in src/folioman_client/models.py
PeriodReturn ¶
Bases: FoliomanBaseModel
Trailing window money-weighted return (1M, 1Y, All, etc.).
Attributes:
| Name | Type | Description |
|---|---|---|
period |
str
|
Label for the trailing window (e.g. '1M', '3M', '1Y', 'ALL'). |
annualized |
float
|
Annualized internal rate of return for the period. |
absolute |
float | None
|
Absolute percentage return for the period. |
days |
int
|
Number of calendar days in the evaluation window. |
Source code in src/folioman_client/models.py
PortfolioSummary ¶
Bases: FoliomanBaseModel
Overall portfolio summary for an investor (InvestorSummaryOut).
Attributes:
| Name | Type | Description |
|---|---|---|
investor_id |
int
|
Unique identifier of the investor. |
as_of |
ConfiguredDate
|
Valuation date of the portfolio summary. |
total_inr |
ConfiguredDecimal
|
Aggregate portfolio valuation in INR. |
is_provisional |
bool
|
Flag indicating if pricing is provisional or final. |
navs_as_of |
ConfiguredDate | None
|
Effective date of NAV points used in this valuation. |
navs_stale |
bool
|
True if latest NAVs have not been updated recently. |
holdings_count |
int
|
Total count of active holdings. |
integrity_unit_count |
int
|
Count of holdings with verified unit balances. |
tax_ready_count |
int
|
Count of holdings with reconciled tax lots. |
needs_attention_count |
int
|
Holdings requiring advisor intervention. |
snapshot_count |
int
|
Number of historical snapshots available. |
stale_count |
int
|
Number of unpriced or stale holdings. |
unpriced_fund_count |
int
|
Number of holdings without available NAV. |
last_import_at |
ConfiguredDatetime | None
|
Timestamp of the most recent data import. |
day_change_inr |
ConfiguredDecimal | None
|
Monetary change since previous business day. |
xirr |
float | None
|
Overall portfolio annualized internal rate of return. |
period_returns |
list[PeriodReturn]
|
Trailing performance metrics across windows. |
asset_mix |
list[AssetMixRow]
|
Asset class breakdown (Equity, Debt, Cash, etc.). |
amc_mix |
list[AllocationBucket]
|
Asset Management Company distribution breakdown. |
category_mix |
list[AllocationBucket]
|
Mutual fund category distribution breakdown. |
top_holdings |
list[Holding]
|
Subset of top holdings by value. |
holdings |
list[Holding]
|
Full list of priced holdings for this investor. |
Source code in src/folioman_client/models.py
SchemeDetail ¶
Bases: FoliomanBaseModel
Detailed scheme view for an investor.
Attributes:
| Name | Type | Description |
|---|---|---|
security |
SchemeRef
|
Scheme metadata reference. |
as_of |
ConfiguredDate
|
Point-in-time calculation date. |
units |
ConfiguredDecimal
|
Total units held across all folios. |
value_inr |
ConfiguredDecimal | None
|
Current market value in INR. |
invested_inr |
ConfiguredDecimal | None
|
Total cost basis in INR. |
return_pct |
float | None
|
Absolute return percentage. |
xirr |
float | None
|
Annualized internal rate of return. |
xirr_status |
str
|
Status indicator for XIRR calculation convergence. |
day_change_inr |
ConfiguredDecimal | None
|
Valuation change compared to previous trading day. |
day_change_pct |
float | None
|
Percentage change compared to previous trading day. |
latest_nav |
ConfiguredDecimal | None
|
Most recent recorded Net Asset Value. |
latest_nav_date |
ConfiguredDate | None
|
Date of the latest NAV record. |
has_transactions |
bool
|
Whether transaction records are available. |
partial_history |
bool
|
Whether historical records are incomplete. |
partial_history_from |
ConfiguredDate | None
|
Starting date of available history if partial. |
folios |
list[FolioBalance]
|
Breakdown of units across individual folios. |
nav_history |
list[NavPoint]
|
Time series of historical NAV points. |
transactions |
list[Transaction]
|
Ledger of historical transactions for this scheme. |
Source code in src/folioman_client/models.py
SchemeRef ¶
Bases: FoliomanBaseModel
Security identity metadata.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
int
|
Unique identifier of the security. |
name |
str
|
Full name of the mutual fund scheme or security. |
isin |
str
|
International Securities Identification Number. |
symbol |
str
|
Ticker symbol if traded on an exchange. |
security_type |
str
|
Type of security (e.g. 'MF', 'EQUITY'). |
amfi_code |
str
|
Association of Mutual Funds in India identifier. |
amc |
str | None
|
Asset Management Company managing the scheme. |
category |
str | None
|
Scheme investment category. |
Source code in src/folioman_client/models.py
TokenPair ¶
Bases: FoliomanBaseModel
Access and refresh token pair returned on authentication.
Attributes:
| Name | Type | Description |
|---|---|---|
access |
str
|
Short-lived JWT bearer token used for authorizing requests. |
refresh |
str
|
Long-lived refresh token used to obtain renewed access tokens. |
Source code in src/folioman_client/models.py
Transaction ¶
Bases: FoliomanBaseModel
Transaction ledger record.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
int
|
Unique numeric identifier for the transaction record. |
investor_id |
int
|
ID of the investor who owns the holding. |
security_id |
int
|
ID of the security being traded. |
folio_id |
int | None
|
ID of the folio account if linked. |
date |
ConfiguredDate
|
Effective transaction date. |
transaction_type |
str
|
Transaction category (e.g., 'PURCHASE', 'REDEMPTION', 'SIP'). |
units |
ConfiguredDecimal
|
Number of units transacted. |
nav_or_price |
ConfiguredDecimal
|
Unit price or NAV at which the transaction was executed. |
amount |
ConfiguredDecimal | None
|
Gross transaction amount in INR. |
fees |
ConfiguredDecimal
|
Fees associated with the transaction. |
stamp_duty |
ConfiguredDecimal
|
Mandatory stamp duty charges. |
brokerage |
ConfiguredDecimal
|
Brokerage commission charged. |
currency |
str
|
ISO currency code (defaults to 'INR'). |
source |
str
|
Ingestion source or platform (e.g., 'CAMS', 'KFintech'). |
narration |
str
|
Descriptive ledger text or note. |
cost_basis_complete |
bool
|
Flag indicating whether cost basis is known. |
via_security |
str | None
|
Auxiliary security reference for switches. |
balance |
ConfiguredDecimal | None
|
Cumulative unit balance following this transaction. |
Source code in src/folioman_client/models.py
ValuationStatus ¶
Bases: FoliomanBaseModel
Valuation calculation readiness status.
Attributes:
| Name | Type | Description |
|---|---|---|
investor_id |
int | None
|
ID of the investor. |
family_id |
int | None
|
ID of the family group if applicable. |
status |
str
|
Engine readiness status (e.g. 'READY', 'COMPUTING', 'ERROR'). |
computed_through |
ConfiguredDate | None
|
Date up to which valuations have been finalized. |
recompute_from |
ConfiguredDate | None
|
Earliest date from which recalculation is needed. |
is_provisional |
bool
|
Whether the current numbers are provisional. |
Source code in src/folioman_client/models.py
ValueSeries ¶
Bases: FoliomanBaseModel
Reconstructed net-worth-over-time time series.
Attributes:
| Name | Type | Description |
|---|---|---|
investor_id |
int | None
|
Optional investor ID filter. |
family_id |
int | None
|
Optional family ID filter. |
start |
ConfiguredDate
|
Start date of the time series. |
end |
ConfiguredDate
|
End date of the time series. |
granularity |
str
|
Sampling frequency ('daily', 'weekly', 'monthly'). |
points |
list[ValueSeriesPoint]
|
Ordered list of valuation time series points. |
Source code in src/folioman_client/models.py
ValueSeriesPoint ¶
Bases: FoliomanBaseModel
Single date point in net worth valuation series.
Attributes:
| Name | Type | Description |
|---|---|---|
date |
ConfiguredDate
|
Valuation point date. |
value_inr |
ConfiguredDecimal
|
Total portfolio value in INR on this date. |
invested_inr |
ConfiguredDecimal
|
Cumulative invested capital in INR on this date. |
stale |
bool
|
Whether the valuation data for this date is stale. |
Source code in src/folioman_client/models.py
options: show_root_heading: true members: - FoliomanClient - FoliomanSettings - settings
Client & Resources¶
folioman_client.client ¶
Folioman API Client.
A thin, async, typed Python client for the Folioman REST API. Handles HTTP transport, JWT token lifecycle (obtain, store, inject, refresh, retry on 401), and response parsing into typed Pydantic models.
InvestorsResource ¶
Bases: _BaseResource
Endpoints for managing and querying investors.
Source code in src/folioman_client/client.py
list
async
¶
List investors accessible to the authenticated advisor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
family_id
|
int | None
|
Filter by parent family group ID. |
None
|
unaffiliated
|
bool
|
If True, only returns investors not affiliated with any family. |
False
|
Returns:
| Type | Description |
|---|---|
list[Investor]
|
A list of Investor summary models. |
Raises:
| Type | Description |
|---|---|
FoliomanAuthError
|
If authentication fails. |
FoliomanAPIError
|
If the server returns an error response. |
Source code in src/folioman_client/client.py
get
async
¶
Get investor details including masked PAN.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
investor_id
|
int
|
Unique identifier of the investor. |
required |
Returns:
| Type | Description |
|---|---|
InvestorDetail
|
InvestorDetail model containing extended profile information. |
Raises:
| Type | Description |
|---|---|
FoliomanNotFoundError
|
If the investor ID does not exist. |
FoliomanAuthError
|
If authentication fails. |
FoliomanAPIError
|
If the server returns an error response. |
Source code in src/folioman_client/client.py
PortfolioResource ¶
Bases: _BaseResource
Endpoints for investor portfolio summary and allocation.
Source code in src/folioman_client/client.py
get
async
¶
Get the full portfolio summary, metrics, and asset mix for an investor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
investor_id
|
int
|
The ID of the investor. |
required |
as_of
|
date | str | None
|
Optional point-in-time valuation date (YYYY-MM-DD or date object). |
None
|
Returns:
| Type | Description |
|---|---|
PortfolioSummary
|
PortfolioSummary model containing metrics, holdings, and allocation mixes. |
Raises:
| Type | Description |
|---|---|
FoliomanNotFoundError
|
If the investor ID does not exist. |
FoliomanAuthError
|
If authentication fails. |
FoliomanAPIError
|
If the server returns an error response. |
Source code in src/folioman_client/client.py
HoldingsResource ¶
Bases: _BaseResource
Endpoints for querying investor holdings and scheme details.
Source code in src/folioman_client/client.py
list
async
¶
List priced holdings for an investor (extracted from portfolio summary).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
investor_id
|
int
|
The ID of the investor. |
required |
as_of
|
date | str | None
|
Optional point-in-time date. |
None
|
Returns:
| Type | Description |
|---|---|
list[Holding]
|
A list of Holding models. |
Raises:
| Type | Description |
|---|---|
FoliomanNotFoundError
|
If the investor does not exist. |
FoliomanAuthError
|
If authentication fails. |
FoliomanAPIError
|
If the server returns an error response. |
Source code in src/folioman_client/client.py
get
async
¶
Get detailed holding/scheme information (NAV history, transactions, folios).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
investor_id
|
int
|
The ID of the investor. |
required |
security_id
|
int
|
The ID of the security/scheme. |
required |
as_of
|
date | str | None
|
Optional point-in-time valuation date. |
None
|
Returns:
| Type | Description |
|---|---|
SchemeDetail
|
SchemeDetail model with full NAV points, folio balances, and transactions. |
Raises:
| Type | Description |
|---|---|
FoliomanNotFoundError
|
If the investor or security does not exist. |
FoliomanAuthError
|
If authentication fails. |
FoliomanAPIError
|
If the server returns an error response. |
Source code in src/folioman_client/client.py
TransactionsResource ¶
Bases: _BaseResource
Endpoints for querying transaction ledger entries.
Source code in src/folioman_client/client.py
list
async
¶
List all transactions for an investor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
investor_id
|
int
|
The ID of the investor. |
required |
Returns:
| Type | Description |
|---|---|
list[Transaction]
|
List of Transaction ledger entries. |
Raises:
| Type | Description |
|---|---|
FoliomanNotFoundError
|
If the investor does not exist. |
FoliomanAuthError
|
If authentication fails. |
FoliomanAPIError
|
If the server returns an error response. |
Source code in src/folioman_client/client.py
ValuationsResource ¶
Bases: _BaseResource
Endpoints for portfolio net-worth history and valuation status.
Source code in src/folioman_client/client.py
list
async
¶
list(investor_id: int, *, from_date: date | str | None = None, to_date: date | str | None = None, granularity: Literal['daily', 'weekly', 'monthly'] = 'monthly') -> ValueSeries
Get net-worth time series reconstructed from ledger and NAV history.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
investor_id
|
int
|
The ID of the investor. |
required |
from_date
|
date | str | None
|
Start date of series. |
None
|
to_date
|
date | str | None
|
End date of series. |
None
|
granularity
|
Literal['daily', 'weekly', 'monthly']
|
Sampling frequency ('daily', 'weekly', or 'monthly'). |
'monthly'
|
Returns:
| Type | Description |
|---|---|
ValueSeries
|
ValueSeries model containing historical valuation points. |
Raises:
| Type | Description |
|---|---|
FoliomanNotFoundError
|
If the investor does not exist. |
FoliomanAuthError
|
If authentication fails. |
FoliomanAPIError
|
If the server returns an error response. |
Source code in src/folioman_client/client.py
status
async
¶
Get the current valuation calculation readiness status for an investor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
investor_id
|
int
|
The ID of the investor. |
required |
Returns:
| Type | Description |
|---|---|
ValuationStatus
|
ValuationStatus model indicating calculation state and coverage. |
Raises:
| Type | Description |
|---|---|
FoliomanNotFoundError
|
If the investor does not exist. |
FoliomanAuthError
|
If authentication fails. |
FoliomanAPIError
|
If the server returns an error response. |
Source code in src/folioman_client/client.py
CapitalGainsResource ¶
Bases: _BaseResource
Endpoints for realised capital gains reporting.
Source code in src/folioman_client/client.py
list
async
¶
List realised STCG/LTCG across every financial year with disposals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
investor_id
|
int
|
The ID of the investor. |
required |
include_unreconciled
|
bool
|
Whether to include unreconciled transactions. |
False
|
Returns:
| Type | Description |
|---|---|
list[CapitalGainsFyPoint]
|
List of CapitalGainsFyPoint models summarizing capital gains by financial year. |
Raises:
| Type | Description |
|---|---|
FoliomanNotFoundError
|
If the investor does not exist. |
FoliomanAuthError
|
If authentication fails. |
FoliomanAPIError
|
If the server returns an error response. |
Source code in src/folioman_client/client.py
get
async
¶
Get realised capital gains report for a specific financial year.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
investor_id
|
int
|
The ID of the investor. |
required |
fy
|
str
|
Financial year string, e.g. "2024-25". |
required |
include_unreconciled
|
bool
|
Whether to include unreconciled transactions. |
False
|
Returns:
| Type | Description |
|---|---|
CapitalGainsReport
|
CapitalGainsReport model with detailed lot-level gains. |
Raises:
| Type | Description |
|---|---|
FoliomanNotFoundError
|
If the investor does not exist. |
FoliomanAuthError
|
If authentication fails. |
FoliomanAPIError
|
If the server returns an error response. |
Source code in src/folioman_client/client.py
FoliomanClient ¶
Asynchronous client for interacting with the Folioman API.
Handles authentication, token refresh, and request execution.
Example
Source code in src/folioman_client/client.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 | |
__init__ ¶
__init__(base_url: str | None = None, username: str | None = None, password: str | None = None, timeout: float = 30.0, http_client: AsyncClient | None = None) -> None
Initialize FoliomanClient.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_url
|
str | None
|
Base URL of the Folioman REST API. If None, loaded from settings/environment. |
None
|
username
|
str | None
|
Username for API authentication. If None, loaded from settings/environment. |
None
|
password
|
str | None
|
Password for API authentication. If None, loaded from settings/environment. |
None
|
timeout
|
float
|
Request timeout in seconds. Defaults to 30.0. |
30.0
|
http_client
|
AsyncClient | None
|
Optional custom httpx.AsyncClient instance for custom transport/pooling. |
None
|
Source code in src/folioman_client/client.py
from_settings
classmethod
¶
Create a client instance from a FoliomanSettings object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
FoliomanSettings
|
FoliomanSettings configuration object. |
required |
Returns:
| Type | Description |
|---|---|
FoliomanClient
|
A configured FoliomanClient instance. |
Source code in src/folioman_client/client.py
from_env
classmethod
¶
Create a client instance using environment variables.
Returns:
| Type | Description |
|---|---|
FoliomanClient
|
A configured FoliomanClient instance using environment defaults. |
Source code in src/folioman_client/client.py
__aenter__
async
¶
Enter the async context manager.
Returns:
| Type | Description |
|---|---|
FoliomanClient
|
The FoliomanClient instance. |
__aexit__
async
¶
close
async
¶
request
async
¶
request(method: str, path: str, *, params: dict[str, Any] | None = None, json: Any | None = None, headers: dict[str, str] | None = None, **kwargs: Any) -> Any
Execute an authenticated HTTP request with automatic token refresh and 401 retry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
str
|
HTTP method ("GET", "POST", etc.) |
required |
path
|
str
|
Relative API path (e.g. "/investors/1") |
required |
params
|
dict[str, Any] | None
|
Optional query parameters. |
None
|
json
|
Any | None
|
Optional JSON request payload. |
None
|
headers
|
dict[str, str] | None
|
Optional extra headers. |
None
|
**kwargs
|
Any
|
Additional keyword arguments passed to httpx.AsyncClient.request. |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
Parsed JSON response, or None if status code is 204 or body is empty. |
Raises:
| Type | Description |
|---|---|
FoliomanNotFoundError
|
If response is 404. |
FoliomanAuthError
|
If authentication fails or refresh is rejected. |
FoliomanAPIError
|
If server responds with other 4xx or 5xx status codes. |
Source code in src/folioman_client/client.py
options: show_root_heading: true
Authentication¶
folioman_client.auth ¶
JWT Authentication Manager for Folioman.
Handles initial token generation, automatic refresh, proactive expiry detection, and concurrency-safe token renewal.
JWTAuthManager ¶
Manages JWT authentication state, token storage, and refresh lifecycle.
Keeps tokens private so they are never leaked outside the client.
Source code in src/folioman_client/auth.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
has_tokens
property
¶
True if the manager currently holds an access or refresh token.
__init__ ¶
Initialize JWTAuthManager with API credentials.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_url
|
str
|
Base URL of the Folioman server. |
required |
username
|
str
|
Username for authentication. |
required |
password
|
str
|
Password for authentication. |
required |
Source code in src/folioman_client/auth.py
clear ¶
get_valid_token
async
¶
Return a valid access token, proactively refreshing or authenticating if needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
AsyncClient
|
The httpx AsyncClient transport instance to execute requests. |
required |
Returns:
| Type | Description |
|---|---|
str
|
A valid JWT access token string. |
Raises:
| Type | Description |
|---|---|
FoliomanAuthError
|
If authentication or refresh fails. |
Source code in src/folioman_client/auth.py
force_refresh
async
¶
Force a refresh or re-authentication after receiving a 401.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
AsyncClient
|
The httpx AsyncClient transport instance to execute requests. |
required |
Returns:
| Type | Description |
|---|---|
str
|
A new valid JWT access token string. |
Raises:
| Type | Description |
|---|---|
FoliomanAuthError
|
If renewal or re-authentication fails. |
Source code in src/folioman_client/auth.py
options: show_root_heading: true
Configuration¶
folioman_client.config ¶
Configuration settings for Folioman Client.
FoliomanSettings ¶
Bases: BaseSettings
Folioman client configuration backed by environment variables.
Attributes:
| Name | Type | Description |
|---|---|---|
base_url |
str
|
The base URL of the Folioman REST API service. Defaults to "http://localhost:8000". |
username |
str
|
The username used for HTTP basic or JWT token retrieval. Defaults to "". |
password |
str
|
The password used for HTTP basic or JWT token retrieval. Defaults to "". |
timeout |
float
|
The request timeout in seconds. Defaults to 30.0. |
Source code in src/folioman_client/config.py
options: show_root_heading: true
Models¶
folioman_client.models ¶
Pydantic models representing Folioman API schemas.
These models mirror the OpenAPI contracts in Folioman (v1). All models use extra="ignore" to remain resilient against future schema extensions.
ConfiguredDate
module-attribute
¶
ConfiguredDate = Annotated[date, PlainSerializer(lambda x: x.isoformat(), return_type=str, when_used='unless-none')]
Date type serialized to ISO-8601 string (YYYY-MM-DD) unless None.
ConfiguredDatetime
module-attribute
¶
ConfiguredDatetime = Annotated[datetime, PlainSerializer(lambda x: x.isoformat(), return_type=str, when_used='unless-none')]
Datetime type serialized to ISO-8601 string unless None.
ConfiguredDecimal
module-attribute
¶
ConfiguredDecimal = Annotated[Decimal, PlainSerializer(lambda x: float(x), return_type=float, when_used='unless-none')]
Decimal type serialized to float unless None.
FoliomanBaseModel ¶
Bases: BaseModel
Base model with common configuration for all Folioman models.
Ignores extra keys sent by the API for forward compatibility and supports field population by name.
Source code in src/folioman_client/models.py
TokenPair ¶
Bases: FoliomanBaseModel
Access and refresh token pair returned on authentication.
Attributes:
| Name | Type | Description |
|---|---|---|
access |
str
|
Short-lived JWT bearer token used for authorizing requests. |
refresh |
str
|
Long-lived refresh token used to obtain renewed access tokens. |
Source code in src/folioman_client/models.py
AccessToken ¶
Bases: FoliomanBaseModel
Refreshed access token.
Attributes:
| Name | Type | Description |
|---|---|---|
access |
str
|
Newly minted short-lived JWT bearer token. |
Source code in src/folioman_client/models.py
Investor ¶
Bases: FoliomanBaseModel
Investor summary representation.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
int
|
Unique numeric identifier of the investor. |
name |
str
|
Full legal name or display name of the investor. |
email |
str
|
Contact email address of the investor. |
is_huf |
bool
|
Whether the investor represents a Hindu Undivided Family. |
relation |
str
|
Relationship description if part of a family group. |
family_id |
int | None
|
ID of the parent family group, if affiliated. |
has_pan |
bool
|
Whether a Permanent Account Number is registered. |
pan_locked |
bool
|
Whether PAN changes are locked for compliance. |
created_at |
ConfiguredDatetime | None
|
Timestamp when the investor record was created. |
updated_at |
ConfiguredDatetime | None
|
Timestamp when the investor record was last updated. |
Source code in src/folioman_client/models.py
InvestorDetail ¶
Bases: Investor
Investor detailed representation with masked PAN.
Attributes:
| Name | Type | Description |
|---|---|---|
pan_masked |
str
|
Masked PAN string (e.g. 'ABCDE****F') protecting sensitive PII. |
Source code in src/folioman_client/models.py
Holding ¶
Bases: FoliomanBaseModel
Priced holding row under an investor.
Attributes:
| Name | Type | Description |
|---|---|---|
security_id |
int
|
Unique identifier for the underlying security/scheme. |
name |
str
|
Name of the security or mutual fund scheme. |
security_type |
str
|
Category of the security (e.g., 'MF', 'EQUITY'). |
symbol |
str
|
Ticker symbol or trading identifier. |
amc |
str
|
Asset Management Company name. |
category |
str
|
SEBI category or mutual fund classification. |
units |
ConfiguredDecimal
|
Total quantity of units held. |
value_inr |
ConfiguredDecimal | None
|
Current market valuation in INR. |
invested_inr |
ConfiguredDecimal | None
|
Total invested amount (cost basis) in INR. |
latest_nav |
ConfiguredDecimal | None
|
Latest available Net Asset Value. |
return_pct |
float | None
|
Absolute percentage return. |
xirr |
float | None
|
Extended Internal Rate of Return (annualized). |
day_change_inr |
ConfiguredDecimal | None
|
Monetary change in valuation since the previous trading day. |
day_change_pct |
float | None
|
Percentage change since the previous trading day. |
Source code in src/folioman_client/models.py
SchemeRef ¶
Bases: FoliomanBaseModel
Security identity metadata.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
int
|
Unique identifier of the security. |
name |
str
|
Full name of the mutual fund scheme or security. |
isin |
str
|
International Securities Identification Number. |
symbol |
str
|
Ticker symbol if traded on an exchange. |
security_type |
str
|
Type of security (e.g. 'MF', 'EQUITY'). |
amfi_code |
str
|
Association of Mutual Funds in India identifier. |
amc |
str | None
|
Asset Management Company managing the scheme. |
category |
str | None
|
Scheme investment category. |
Source code in src/folioman_client/models.py
NavPoint ¶
Bases: FoliomanBaseModel
Single date and NAV point.
Attributes:
| Name | Type | Description |
|---|---|---|
date |
ConfiguredDate
|
Valuation date for the NAV point. |
nav |
ConfiguredDecimal
|
Net Asset Value per unit on the specified date. |
Source code in src/folioman_client/models.py
FolioBalance ¶
Bases: FoliomanBaseModel
Balance for one folio holding a security.
Attributes:
| Name | Type | Description |
|---|---|---|
number |
str
|
Folio account number. |
broker |
str
|
Broker / ARN identifier associated with the folio. |
folio_type |
str
|
Type classification of the folio account. |
units |
ConfiguredDecimal
|
Unit balance held under this folio. |
value_inr |
ConfiguredDecimal | None
|
Monetary valuation in INR for this folio. |
Source code in src/folioman_client/models.py
Transaction ¶
Bases: FoliomanBaseModel
Transaction ledger record.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
int
|
Unique numeric identifier for the transaction record. |
investor_id |
int
|
ID of the investor who owns the holding. |
security_id |
int
|
ID of the security being traded. |
folio_id |
int | None
|
ID of the folio account if linked. |
date |
ConfiguredDate
|
Effective transaction date. |
transaction_type |
str
|
Transaction category (e.g., 'PURCHASE', 'REDEMPTION', 'SIP'). |
units |
ConfiguredDecimal
|
Number of units transacted. |
nav_or_price |
ConfiguredDecimal
|
Unit price or NAV at which the transaction was executed. |
amount |
ConfiguredDecimal | None
|
Gross transaction amount in INR. |
fees |
ConfiguredDecimal
|
Fees associated with the transaction. |
stamp_duty |
ConfiguredDecimal
|
Mandatory stamp duty charges. |
brokerage |
ConfiguredDecimal
|
Brokerage commission charged. |
currency |
str
|
ISO currency code (defaults to 'INR'). |
source |
str
|
Ingestion source or platform (e.g., 'CAMS', 'KFintech'). |
narration |
str
|
Descriptive ledger text or note. |
cost_basis_complete |
bool
|
Flag indicating whether cost basis is known. |
via_security |
str | None
|
Auxiliary security reference for switches. |
balance |
ConfiguredDecimal | None
|
Cumulative unit balance following this transaction. |
Source code in src/folioman_client/models.py
SchemeDetail ¶
Bases: FoliomanBaseModel
Detailed scheme view for an investor.
Attributes:
| Name | Type | Description |
|---|---|---|
security |
SchemeRef
|
Scheme metadata reference. |
as_of |
ConfiguredDate
|
Point-in-time calculation date. |
units |
ConfiguredDecimal
|
Total units held across all folios. |
value_inr |
ConfiguredDecimal | None
|
Current market value in INR. |
invested_inr |
ConfiguredDecimal | None
|
Total cost basis in INR. |
return_pct |
float | None
|
Absolute return percentage. |
xirr |
float | None
|
Annualized internal rate of return. |
xirr_status |
str
|
Status indicator for XIRR calculation convergence. |
day_change_inr |
ConfiguredDecimal | None
|
Valuation change compared to previous trading day. |
day_change_pct |
float | None
|
Percentage change compared to previous trading day. |
latest_nav |
ConfiguredDecimal | None
|
Most recent recorded Net Asset Value. |
latest_nav_date |
ConfiguredDate | None
|
Date of the latest NAV record. |
has_transactions |
bool
|
Whether transaction records are available. |
partial_history |
bool
|
Whether historical records are incomplete. |
partial_history_from |
ConfiguredDate | None
|
Starting date of available history if partial. |
folios |
list[FolioBalance]
|
Breakdown of units across individual folios. |
nav_history |
list[NavPoint]
|
Time series of historical NAV points. |
transactions |
list[Transaction]
|
Ledger of historical transactions for this scheme. |
Source code in src/folioman_client/models.py
AssetMixRow ¶
Bases: FoliomanBaseModel
Allocation breakdown row by security type.
Attributes:
| Name | Type | Description |
|---|---|---|
security_type |
str
|
Asset class label (e.g. 'EQUITY', 'DEBT', 'CASH'). |
value_inr |
ConfiguredDecimal
|
Total valuation allocated to this security type in INR. |
Source code in src/folioman_client/models.py
AllocationBucket ¶
Bases: FoliomanBaseModel
Allocation breakdown row by AMC or category.
Attributes:
| Name | Type | Description |
|---|---|---|
label |
str
|
AMC name or category classification label. |
value_inr |
ConfiguredDecimal
|
Total valuation allocated to this bucket in INR. |
Source code in src/folioman_client/models.py
PeriodReturn ¶
Bases: FoliomanBaseModel
Trailing window money-weighted return (1M, 1Y, All, etc.).
Attributes:
| Name | Type | Description |
|---|---|---|
period |
str
|
Label for the trailing window (e.g. '1M', '3M', '1Y', 'ALL'). |
annualized |
float
|
Annualized internal rate of return for the period. |
absolute |
float | None
|
Absolute percentage return for the period. |
days |
int
|
Number of calendar days in the evaluation window. |
Source code in src/folioman_client/models.py
PortfolioSummary ¶
Bases: FoliomanBaseModel
Overall portfolio summary for an investor (InvestorSummaryOut).
Attributes:
| Name | Type | Description |
|---|---|---|
investor_id |
int
|
Unique identifier of the investor. |
as_of |
ConfiguredDate
|
Valuation date of the portfolio summary. |
total_inr |
ConfiguredDecimal
|
Aggregate portfolio valuation in INR. |
is_provisional |
bool
|
Flag indicating if pricing is provisional or final. |
navs_as_of |
ConfiguredDate | None
|
Effective date of NAV points used in this valuation. |
navs_stale |
bool
|
True if latest NAVs have not been updated recently. |
holdings_count |
int
|
Total count of active holdings. |
integrity_unit_count |
int
|
Count of holdings with verified unit balances. |
tax_ready_count |
int
|
Count of holdings with reconciled tax lots. |
needs_attention_count |
int
|
Holdings requiring advisor intervention. |
snapshot_count |
int
|
Number of historical snapshots available. |
stale_count |
int
|
Number of unpriced or stale holdings. |
unpriced_fund_count |
int
|
Number of holdings without available NAV. |
last_import_at |
ConfiguredDatetime | None
|
Timestamp of the most recent data import. |
day_change_inr |
ConfiguredDecimal | None
|
Monetary change since previous business day. |
xirr |
float | None
|
Overall portfolio annualized internal rate of return. |
period_returns |
list[PeriodReturn]
|
Trailing performance metrics across windows. |
asset_mix |
list[AssetMixRow]
|
Asset class breakdown (Equity, Debt, Cash, etc.). |
amc_mix |
list[AllocationBucket]
|
Asset Management Company distribution breakdown. |
category_mix |
list[AllocationBucket]
|
Mutual fund category distribution breakdown. |
top_holdings |
list[Holding]
|
Subset of top holdings by value. |
holdings |
list[Holding]
|
Full list of priced holdings for this investor. |
Source code in src/folioman_client/models.py
ValueSeriesPoint ¶
Bases: FoliomanBaseModel
Single date point in net worth valuation series.
Attributes:
| Name | Type | Description |
|---|---|---|
date |
ConfiguredDate
|
Valuation point date. |
value_inr |
ConfiguredDecimal
|
Total portfolio value in INR on this date. |
invested_inr |
ConfiguredDecimal
|
Cumulative invested capital in INR on this date. |
stale |
bool
|
Whether the valuation data for this date is stale. |
Source code in src/folioman_client/models.py
ValueSeries ¶
Bases: FoliomanBaseModel
Reconstructed net-worth-over-time time series.
Attributes:
| Name | Type | Description |
|---|---|---|
investor_id |
int | None
|
Optional investor ID filter. |
family_id |
int | None
|
Optional family ID filter. |
start |
ConfiguredDate
|
Start date of the time series. |
end |
ConfiguredDate
|
End date of the time series. |
granularity |
str
|
Sampling frequency ('daily', 'weekly', 'monthly'). |
points |
list[ValueSeriesPoint]
|
Ordered list of valuation time series points. |
Source code in src/folioman_client/models.py
ValuationStatus ¶
Bases: FoliomanBaseModel
Valuation calculation readiness status.
Attributes:
| Name | Type | Description |
|---|---|---|
investor_id |
int | None
|
ID of the investor. |
family_id |
int | None
|
ID of the family group if applicable. |
status |
str
|
Engine readiness status (e.g. 'READY', 'COMPUTING', 'ERROR'). |
computed_through |
ConfiguredDate | None
|
Date up to which valuations have been finalized. |
recompute_from |
ConfiguredDate | None
|
Earliest date from which recalculation is needed. |
is_provisional |
bool
|
Whether the current numbers are provisional. |
Source code in src/folioman_client/models.py
CapitalGainRow ¶
Bases: FoliomanBaseModel
One realised disposal lot in capital gains report.
Attributes:
| Name | Type | Description |
|---|---|---|
security_id |
int | None
|
ID of the security redeemed or sold. |
name |
str
|
Name of the security or mutual fund scheme. |
isin |
str
|
ISIN code of the security. |
units |
ConfiguredDecimal
|
Number of units redeemed or disposed. |
sale_value |
ConfiguredDecimal
|
Realized sale proceeds in INR. |
cost |
ConfiguredDecimal
|
Indexed or purchase cost basis in INR. |
gain |
ConfiguredDecimal
|
Realized capital gain or loss in INR. |
term |
str
|
Classification of gain ('STCG' or 'LTCG'). |
acquired_on |
ConfiguredDate
|
Original purchase date of the lot. |
sold_on |
ConfiguredDate
|
Date of disposal or redemption. |
grandfathering_unavailable |
bool
|
Whether Section 112A grandfathering is unavailable. |
Source code in src/folioman_client/models.py
CapitalGainsReport ¶
Bases: FoliomanBaseModel
Realised capital gains report for a financial year (CapitalGainsOut).
Attributes:
| Name | Type | Description |
|---|---|---|
fy |
str
|
Financial year label (e.g., '2024-25'). |
stcg_total |
ConfiguredDecimal
|
Total realized Short-Term Capital Gains in INR. |
ltcg_total |
ConfiguredDecimal
|
Total realized Long-Term Capital Gains in INR. |
rows |
list[CapitalGainRow]
|
Detailed breakdown of individual disposal lots. |
disclaimer |
str
|
Legal or regulatory tax disclaimer text. |
Source code in src/folioman_client/models.py
CapitalGainsFyPoint ¶
Bases: FoliomanBaseModel
Year-over-year capital gains summary point.
Attributes:
| Name | Type | Description |
|---|---|---|
fy |
str
|
Financial year label (e.g., '2023-24'). |
stcg |
ConfiguredDecimal
|
Total realized STCG for the year. |
ltcg |
ConfiguredDecimal
|
Total realized LTCG for the year. |
Source code in src/folioman_client/models.py
options: show_root_heading: true
Errors¶
folioman_client.errors ¶
Exception hierarchy for the Folioman client.
Keep exceptions focused, practical, and small.
FoliomanError ¶
FoliomanAuthError ¶
Bases: FoliomanError
Raised when authentication fails (invalid credentials, expired/rejected token refresh).
FoliomanNotFoundError ¶
Bases: FoliomanError
Raised when the requested resource is not found (HTTP 404).
FoliomanAPIError ¶
Bases: FoliomanError
Raised when the Folioman API returns an error response (HTTP 4xx/5xx).
Attributes:
| Name | Type | Description |
|---|---|---|
status_code |
The HTTP status code returned by the server. |
|
response_data |
Parsed response payload or raw error details, if available. |
Source code in src/folioman_client/errors.py
__init__ ¶
Initialize FoliomanAPIError with message, status code, and optional payload.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Human-readable description of the error. |
required |
status_code
|
int
|
HTTP response status code (e.g., 400, 500). |
required |
response_data
|
Any | None
|
Deserialized JSON payload or raw text error from the server. |
None
|
Source code in src/folioman_client/errors.py
options: show_root_heading: true
Types¶
folioman_client.types ¶
Reusable Pydantic Annotated types for Folioman models.
ConfiguredDecimal
module-attribute
¶
ConfiguredDecimal = Annotated[Decimal, PlainSerializer(lambda x: float(x), return_type=float, when_used='unless-none')]
Decimal type serialized to float unless None.
ConfiguredDate
module-attribute
¶
ConfiguredDate = Annotated[date, PlainSerializer(lambda x: x.isoformat(), return_type=str, when_used='unless-none')]
Date type serialized to ISO-8601 string (YYYY-MM-DD) unless None.
ConfiguredDatetime
module-attribute
¶
ConfiguredDatetime = Annotated[datetime, PlainSerializer(lambda x: x.isoformat(), return_type=str, when_used='unless-none')]
Datetime type serialized to ISO-8601 string unless None.
options: show_root_heading: true