Instantiate a new CalculatedAccountState from a dict (generally from
        loading a JSON response). The data used to instantiate the
        CalculatedAccountState is a shallow copy of the dict passed in, with
        any complex child types instantiated appropriately.

def from_dict(data, ctx):
        """
        Instantiate a new CalculatedAccountState from a dict (generally from
        loading a JSON response). The data used to instantiate the
        CalculatedAccountState is a shallow copy of the dict passed in, with
        any complex child types instantiated appropriately.
        """

        data = data.copy()

        if data.get('unrealizedPL') is not None:
            data['unrealizedPL'] = ctx.convert_decimal_number(
                data.get('unrealizedPL')
            )

        if data.get('NAV') is not None:
            data['NAV'] = ctx.convert_decimal_number(
                data.get('NAV')
            )

        if data.get('marginUsed') is not None:
            data['marginUsed'] = ctx.convert_decimal_number(
                data.get('marginUsed')
            )

        if data.get('marginAvailable') is not None:
            data['marginAvailable'] = ctx.convert_decimal_number(
                data.get('marginAvailable')
            )

        if data.get('positionValue') is not None:
            data['positionValue'] = ctx.convert_decimal_number(
                data.get('positionValue')
            )

        if data.get('marginCloseoutUnrealizedPL') is not None:
            data['marginCloseoutUnrealizedPL'] = ctx.convert_decimal_number(
                data.get('marginCloseoutUnrealizedPL')
            )

        if data.get('marginCloseoutNAV') is not None:
            data['marginCloseoutNAV'] = ctx.convert_decimal_number(
                data.get('marginCloseoutNAV')
            )

        if data.get('marginCloseoutMarginUsed') is not None:
            data['marginCloseoutMarginUsed'] = ctx.convert_decimal_number(
                data.get('marginCloseoutMarginUsed')
            )

        if data.get('marginCloseoutPercent') is not None:
            data['marginCloseoutPercent'] = ctx.convert_decimal_number(
                data.get('marginCloseoutPercent')
            )

        if data.get('marginCloseoutPositionValue') is not None:
            data['marginCloseoutPositionValue'] = ctx.convert_decimal_number(
                data.get('marginCloseoutPositionValue')
            )

        if data.get('withdrawalLimit') is not None:
            data['withdrawalLimit'] = ctx.convert_decimal_number(
                data.get('withdrawalLimit')
            )

        if data.get('marginCallMarginUsed') is not None:
            data['marginCallMarginUsed'] = ctx.convert_decimal_number(
                data.get('marginCallMarginUsed')
            )

        if data.get('marginCallPercent') is not None:
            data['marginCallPercent'] = ctx.convert_decimal_number(
                data.get('marginCallPercent')
            )

        return CalculatedAccountState(**data)