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

def from_dict(data, ctx):
        """
        Instantiate a new CalculatedTradeState from a dict (generally from
        loading a JSON response). The data used to instantiate the
        CalculatedTradeState 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('marginUsed') is not None:
            data['marginUsed'] = ctx.convert_decimal_number(
                data.get('marginUsed')
            )

        return CalculatedTradeState(**data)