Skip to content

models_helpers

mainsequence.client.models_helpers

AccountLatestHoldings

Bases: AccountHistoricalHoldingsMixin, BaseObjectOrm, BasePydanticModel

Same as Account HistoricalHoldings but Does not include related account

AssetCategory

Bases: BaseObjectOrm, BasePydanticModel

append_assets(asset_ids)

Append the given asset IDs to this category. Expects a payload: {"assets": [, , ...]}

remove_assets(asset_ids)

Remove the given asset IDs from this category. Expects a payload: {"assets": [, , ...]}

AssetMixin

Bases: BaseObjectOrm, BasePydanticModel

filter_with_asset_class(timeout=None, include_relationship_details_depth=None, *args, **kwargs) classmethod

Filters assets and returns instances with their correct asset class,

pretty_print()

Print all asset properties in a neat, aligned table.

AssetTranslationTable

Bases: BaseObjectOrm, BasePydanticModel

Mirrors the Django model 'AssetTranslationTableModel' in the backend.

add_rules(rules, open_for_everyone=False)

Add each rule to the translation table by calling the backend's 'add_rule' endpoint. Prevents local duplication. If the server also rejects a duplicate, it returns an error which we silently ignore.

remove_rules(rules)

Remove each rule from the translation table by calling the backend's 'remove_rule' endpoint. Once successfully removed on the server, remove it from the local list self.rules. If a rule is not found on the server, we skip silently.

BaseObjectOrm

filter(timeout=None, **kwargs) classmethod

Fetches all pages from a DRF-paginated endpoint. Accumulates results from each page until 'next' is None.

Returns a list of cls objects (not just one page).

DRF's typical paginated response looks like: { "count": , "next": , "previous": , "results": [ ...items... ] }

get(pk=None, timeout=None, **filters) classmethod

Retrieves exactly one object by primary key: GET /base_url// Raises DoesNotExist if 404 or the response is empty. Raises Exception if multiple or unexpected data is returned.

HistoricalWeights

Bases: BaseObjectOrm, BasePydanticModel

add_from_time_serie(local_time_serie_id, positions_list, weights_date, comments=None, timeout=None) classmethod

:param session: :return:

Order

Bases: BaseObjectOrm, BasePydanticModel

create_or_update(order_time_stamp, *args, **kwargs) classmethod

Args: order_time: timestamp args: *kwargs:

Returns:

TranslationError

Bases: RuntimeError

Raised when no translation rule (or more than one) matches an asset.

get_model_class(model_class)

Reverse look from model class by name