Skip to content

Trading

Trading Resource

composer.resources.trading.Trading

Resource for trading-related endpoints.

Source code in composer/resources/trading.py
class Trading:
    """Resource for trading-related endpoints."""

    def __init__(self, http_client):
        self._client = http_client

    def get_trading_period(self) -> TradingPeriodResponse:
        """
        Get the trading period for the authenticated user.

        Returns
        -------
            Trading period information for CRYPTO, EQUITIES, and OPTIONS
        """
        response = self._client.get("/api/v1/trading-period")
        return TradingPeriodResponse.model_validate(response)

    def get_order_requests(
        self,
        account_id: str,
        limit: int | None = None,
        status: str | None = None,
    ) -> OrderRequestsResponse:
        """
        Get order requests for an account.

        Args:
            account_id: Unique identifier (UUID) of the account
            limit: Maximum number of results
            status: Filter by status (e.g., 'QUEUED,OPEN,IN_PROGRESS')

        Returns
        -------
            List of order requests
        """
        params = {}
        if limit is not None:
            params["limit"] = limit
        if status:
            params["status"] = status
        response = self._client.get(
            f"/api/v1/trading/accounts/{account_id}/order-requests",
            params=params if params else None,
        )
        return OrderRequestsResponse.model_validate(response)

    def get_order_request(
        self,
        account_id: str,
        order_request_id: str,
    ) -> OrderRequest:
        """
        Get a single order request.

        Args:
            account_id: Unique identifier (UUID) of the account
            order_request_id: Unique identifier for the order request

        Returns
        -------
            Details of the specified order request
        """
        response = self._client.get(
            f"/api/v1/trading/accounts/{account_id}/order-requests/{order_request_id}"
        )
        return OrderRequest.model_validate(response)

    def create_order_request(
        self,
        account_id: str,
        type: OrderType | str,
        symbol: str,
        time_in_force: TimeInForce | str,
        notional: float | None = None,
        quantity: float | None = None,
        position_intent: PositionIntent | str | None = None,
        limit_price: float | None = None,
        stop_price: float | None = None,
        client_order_id: str | None = None,
    ) -> CreateOrderResponse:
        """
        Create a new order request.

        Args:
            account_id: Unique identifier (UUID) of the account
            type: Order type (MARKET, LIMIT, STOP, STOP_LIMIT, TRAILING_STOP)
            symbol: Symbol to trade
            time_in_force: Time in force (GTC, DAY, IOC, FOK, OPG, CLS)
            notional: Notional amount (required if quantity not provided)
            quantity: Quantity (required if notional not provided)
            position_intent: Position intent for options (BUY_TO_OPEN, etc.)
            limit_price: Limit price for limit orders
            stop_price: Stop price for stop orders
            client_order_id: Optional client-generated order ID

        Returns
        -------
            Created order details
        """
        request = CreateOrderRequest(
            type=type if isinstance(type, OrderType) else OrderType(type),
            symbol=symbol,
            time_in_force=time_in_force
            if isinstance(time_in_force, TimeInForce)
            else TimeInForce(time_in_force),
            notional=notional,
            quantity=quantity,
            position_intent=position_intent
            if position_intent is None or isinstance(position_intent, PositionIntent)
            else PositionIntent(position_intent),
            limit_price=limit_price,
            stop_price=stop_price,
            client_order_id=client_order_id,
        )
        response = self._client.post(
            f"/api/v1/trading/accounts/{account_id}/order-requests",
            json=request.model_dump(exclude_none=True),
        )
        return CreateOrderResponse.model_validate(response)

    def delete_order_request(
        self,
        account_id: str,
        order_request_id: str,
    ) -> None:
        """
        Cancel an order request that has not executed yet.

        Args:
            account_id: Unique identifier (UUID) of the account
            order_request_id: Unique identifier for the order request
        """
        self._client.delete(
            f"/api/v1/trading/accounts/{account_id}/order-requests/{order_request_id}"
        )

    def modify_order_request(
        self,
        account_id: str,
        order_request_id: str,
        client_order_id: str | None = None,
        limit_price: float | None = None,
        quantity: float | None = None,
    ) -> None:
        """
        Modify an existing order request that has not executed yet.

        Args:
            account_id: Unique identifier (UUID) of the account
            order_request_id: Unique identifier for the order request
            client_order_id: ID for replacement order (idempotency key)
            limit_price: New limit price
            quantity: New quantity
        """
        request = ModifyOrderRequest(
            client_order_id=client_order_id,
            limit_price=limit_price,
            quantity=quantity,
        )
        self._client.patch(
            f"/api/v1/trading/accounts/{account_id}/order-requests/{order_request_id}",
            json=request.model_dump(exclude_none=True),
        )

    def exercise_option(
        self,
        account_id: str,
        symbol: str,
    ) -> ExerciseResponse:
        """
        Exercise an option contract position.

        Args:
            account_id: Unique identifier (UUID) of the account
            symbol: Option symbol (e.g., OPTIONS::AAPL1234567890PC20240119//USD)

        Returns
        -------
            Exercise result
        """
        response = self._client.post(
            f"/api/v1/trading/accounts/{account_id}/options/exercise",
            json={"symbol": symbol},
        )
        return ExerciseResponse.model_validate(response)

    def preview_exercise_option(
        self,
        account_id: str,
        symbol: str,
    ) -> ExercisePreviewResponse:
        """
        Preview exercise of an option contract position.

        Args:
            account_id: Unique identifier (UUID) of the account
            symbol: Option symbol (e.g., OPTIONS::AAPL1234567890PC20240119//USD)

        Returns
        -------
            Exercise preview
        """
        response = self._client.post(
            f"/api/v1/trading/accounts/{account_id}/options/exercise/preview",
            json={"symbol": symbol},
        )
        return ExercisePreviewResponse.model_validate(response)

    def preview_order_request(
        self,
        account_id: str,
        type: str,
        symbol: str,
        time_in_force: str,
        notional: float | None = None,
        quantity: float | None = None,
        position_intent: str | None = None,
        limit_price: float | None = None,
        stop_price: float | None = None,
    ) -> ExercisePreviewResponse:
        """
        Preview an order request before placing it.

        Args:
            account_id: Unique identifier (UUID) of the account
            type: Order type (MARKET, LIMIT, STOP, STOP_LIMIT, TRAILING_STOP)
            symbol: Symbol to trade
            time_in_force: Time in force (GTC, DAY, IOC, FOK, OPG, CLS)
            notional: Notional amount (required if quantity not provided)
            quantity: Quantity (required if notional not provided)
            position_intent: Position intent for options (BUY_TO_OPEN, etc.)
            limit_price: Limit price for limit orders
            stop_price: Stop price for stop orders

        Returns
        -------
            Order preview
        """
        request = CreateOrderRequest(
            type=type if isinstance(type, OrderType) else OrderType(type),
            symbol=symbol,
            time_in_force=time_in_force
            if isinstance(time_in_force, TimeInForce)
            else TimeInForce(time_in_force),
            notional=notional,
            quantity=quantity,
            position_intent=position_intent
            if position_intent is None or isinstance(position_intent, PositionIntent)
            else PositionIntent(position_intent),
            limit_price=limit_price,
            stop_price=stop_price,
            client_order_id=None,
        )
        response = self._client.post(
            f"/api/v1/trading/accounts/{account_id}/order-requests/preview",
            json=request.model_dump(exclude_none=True),
        )
        return ExercisePreviewResponse.model_validate(response)

create_order_request(account_id, type, symbol, time_in_force, notional=None, quantity=None, position_intent=None, limit_price=None, stop_price=None, client_order_id=None)

Create a new order request.

Parameters:

Name Type Description Default
account_id str

Unique identifier (UUID) of the account

required
type OrderType | str

Order type (MARKET, LIMIT, STOP, STOP_LIMIT, TRAILING_STOP)

required
symbol str

Symbol to trade

required
time_in_force TimeInForce | str

Time in force (GTC, DAY, IOC, FOK, OPG, CLS)

required
notional float | None

Notional amount (required if quantity not provided)

None
quantity float | None

Quantity (required if notional not provided)

None
position_intent PositionIntent | str | None

Position intent for options (BUY_TO_OPEN, etc.)

None
limit_price float | None

Limit price for limit orders

None
stop_price float | None

Stop price for stop orders

None
client_order_id str | None

Optional client-generated order ID

None
Returns
Created order details
Source code in composer/resources/trading.py
def create_order_request(
    self,
    account_id: str,
    type: OrderType | str,
    symbol: str,
    time_in_force: TimeInForce | str,
    notional: float | None = None,
    quantity: float | None = None,
    position_intent: PositionIntent | str | None = None,
    limit_price: float | None = None,
    stop_price: float | None = None,
    client_order_id: str | None = None,
) -> CreateOrderResponse:
    """
    Create a new order request.

    Args:
        account_id: Unique identifier (UUID) of the account
        type: Order type (MARKET, LIMIT, STOP, STOP_LIMIT, TRAILING_STOP)
        symbol: Symbol to trade
        time_in_force: Time in force (GTC, DAY, IOC, FOK, OPG, CLS)
        notional: Notional amount (required if quantity not provided)
        quantity: Quantity (required if notional not provided)
        position_intent: Position intent for options (BUY_TO_OPEN, etc.)
        limit_price: Limit price for limit orders
        stop_price: Stop price for stop orders
        client_order_id: Optional client-generated order ID

    Returns
    -------
        Created order details
    """
    request = CreateOrderRequest(
        type=type if isinstance(type, OrderType) else OrderType(type),
        symbol=symbol,
        time_in_force=time_in_force
        if isinstance(time_in_force, TimeInForce)
        else TimeInForce(time_in_force),
        notional=notional,
        quantity=quantity,
        position_intent=position_intent
        if position_intent is None or isinstance(position_intent, PositionIntent)
        else PositionIntent(position_intent),
        limit_price=limit_price,
        stop_price=stop_price,
        client_order_id=client_order_id,
    )
    response = self._client.post(
        f"/api/v1/trading/accounts/{account_id}/order-requests",
        json=request.model_dump(exclude_none=True),
    )
    return CreateOrderResponse.model_validate(response)

delete_order_request(account_id, order_request_id)

Cancel an order request that has not executed yet.

Parameters:

Name Type Description Default
account_id str

Unique identifier (UUID) of the account

required
order_request_id str

Unique identifier for the order request

required
Source code in composer/resources/trading.py
def delete_order_request(
    self,
    account_id: str,
    order_request_id: str,
) -> None:
    """
    Cancel an order request that has not executed yet.

    Args:
        account_id: Unique identifier (UUID) of the account
        order_request_id: Unique identifier for the order request
    """
    self._client.delete(
        f"/api/v1/trading/accounts/{account_id}/order-requests/{order_request_id}"
    )

exercise_option(account_id, symbol)

Exercise an option contract position.

Parameters:

Name Type Description Default
account_id str

Unique identifier (UUID) of the account

required
symbol str

Option symbol (e.g., OPTIONS::AAPL1234567890PC20240119//USD)

required
Returns
Exercise result
Source code in composer/resources/trading.py
def exercise_option(
    self,
    account_id: str,
    symbol: str,
) -> ExerciseResponse:
    """
    Exercise an option contract position.

    Args:
        account_id: Unique identifier (UUID) of the account
        symbol: Option symbol (e.g., OPTIONS::AAPL1234567890PC20240119//USD)

    Returns
    -------
        Exercise result
    """
    response = self._client.post(
        f"/api/v1/trading/accounts/{account_id}/options/exercise",
        json={"symbol": symbol},
    )
    return ExerciseResponse.model_validate(response)

get_order_request(account_id, order_request_id)

Get a single order request.

Parameters:

Name Type Description Default
account_id str

Unique identifier (UUID) of the account

required
order_request_id str

Unique identifier for the order request

required
Returns
Details of the specified order request
Source code in composer/resources/trading.py
def get_order_request(
    self,
    account_id: str,
    order_request_id: str,
) -> OrderRequest:
    """
    Get a single order request.

    Args:
        account_id: Unique identifier (UUID) of the account
        order_request_id: Unique identifier for the order request

    Returns
    -------
        Details of the specified order request
    """
    response = self._client.get(
        f"/api/v1/trading/accounts/{account_id}/order-requests/{order_request_id}"
    )
    return OrderRequest.model_validate(response)

get_order_requests(account_id, limit=None, status=None)

Get order requests for an account.

Parameters:

Name Type Description Default
account_id str

Unique identifier (UUID) of the account

required
limit int | None

Maximum number of results

None
status str | None

Filter by status (e.g., 'QUEUED,OPEN,IN_PROGRESS')

None
Returns
List of order requests
Source code in composer/resources/trading.py
def get_order_requests(
    self,
    account_id: str,
    limit: int | None = None,
    status: str | None = None,
) -> OrderRequestsResponse:
    """
    Get order requests for an account.

    Args:
        account_id: Unique identifier (UUID) of the account
        limit: Maximum number of results
        status: Filter by status (e.g., 'QUEUED,OPEN,IN_PROGRESS')

    Returns
    -------
        List of order requests
    """
    params = {}
    if limit is not None:
        params["limit"] = limit
    if status:
        params["status"] = status
    response = self._client.get(
        f"/api/v1/trading/accounts/{account_id}/order-requests",
        params=params if params else None,
    )
    return OrderRequestsResponse.model_validate(response)

get_trading_period()

Get the trading period for the authenticated user.

Returns
Trading period information for CRYPTO, EQUITIES, and OPTIONS
Source code in composer/resources/trading.py
def get_trading_period(self) -> TradingPeriodResponse:
    """
    Get the trading period for the authenticated user.

    Returns
    -------
        Trading period information for CRYPTO, EQUITIES, and OPTIONS
    """
    response = self._client.get("/api/v1/trading-period")
    return TradingPeriodResponse.model_validate(response)

modify_order_request(account_id, order_request_id, client_order_id=None, limit_price=None, quantity=None)

Modify an existing order request that has not executed yet.

Parameters:

Name Type Description Default
account_id str

Unique identifier (UUID) of the account

required
order_request_id str

Unique identifier for the order request

required
client_order_id str | None

ID for replacement order (idempotency key)

None
limit_price float | None

New limit price

None
quantity float | None

New quantity

None
Source code in composer/resources/trading.py
def modify_order_request(
    self,
    account_id: str,
    order_request_id: str,
    client_order_id: str | None = None,
    limit_price: float | None = None,
    quantity: float | None = None,
) -> None:
    """
    Modify an existing order request that has not executed yet.

    Args:
        account_id: Unique identifier (UUID) of the account
        order_request_id: Unique identifier for the order request
        client_order_id: ID for replacement order (idempotency key)
        limit_price: New limit price
        quantity: New quantity
    """
    request = ModifyOrderRequest(
        client_order_id=client_order_id,
        limit_price=limit_price,
        quantity=quantity,
    )
    self._client.patch(
        f"/api/v1/trading/accounts/{account_id}/order-requests/{order_request_id}",
        json=request.model_dump(exclude_none=True),
    )

preview_exercise_option(account_id, symbol)

Preview exercise of an option contract position.

Parameters:

Name Type Description Default
account_id str

Unique identifier (UUID) of the account

required
symbol str

Option symbol (e.g., OPTIONS::AAPL1234567890PC20240119//USD)

required
Returns
Exercise preview
Source code in composer/resources/trading.py
def preview_exercise_option(
    self,
    account_id: str,
    symbol: str,
) -> ExercisePreviewResponse:
    """
    Preview exercise of an option contract position.

    Args:
        account_id: Unique identifier (UUID) of the account
        symbol: Option symbol (e.g., OPTIONS::AAPL1234567890PC20240119//USD)

    Returns
    -------
        Exercise preview
    """
    response = self._client.post(
        f"/api/v1/trading/accounts/{account_id}/options/exercise/preview",
        json={"symbol": symbol},
    )
    return ExercisePreviewResponse.model_validate(response)

preview_order_request(account_id, type, symbol, time_in_force, notional=None, quantity=None, position_intent=None, limit_price=None, stop_price=None)

Preview an order request before placing it.

Parameters:

Name Type Description Default
account_id str

Unique identifier (UUID) of the account

required
type str

Order type (MARKET, LIMIT, STOP, STOP_LIMIT, TRAILING_STOP)

required
symbol str

Symbol to trade

required
time_in_force str

Time in force (GTC, DAY, IOC, FOK, OPG, CLS)

required
notional float | None

Notional amount (required if quantity not provided)

None
quantity float | None

Quantity (required if notional not provided)

None
position_intent str | None

Position intent for options (BUY_TO_OPEN, etc.)

None
limit_price float | None

Limit price for limit orders

None
stop_price float | None

Stop price for stop orders

None
Returns
Order preview
Source code in composer/resources/trading.py
def preview_order_request(
    self,
    account_id: str,
    type: str,
    symbol: str,
    time_in_force: str,
    notional: float | None = None,
    quantity: float | None = None,
    position_intent: str | None = None,
    limit_price: float | None = None,
    stop_price: float | None = None,
) -> ExercisePreviewResponse:
    """
    Preview an order request before placing it.

    Args:
        account_id: Unique identifier (UUID) of the account
        type: Order type (MARKET, LIMIT, STOP, STOP_LIMIT, TRAILING_STOP)
        symbol: Symbol to trade
        time_in_force: Time in force (GTC, DAY, IOC, FOK, OPG, CLS)
        notional: Notional amount (required if quantity not provided)
        quantity: Quantity (required if notional not provided)
        position_intent: Position intent for options (BUY_TO_OPEN, etc.)
        limit_price: Limit price for limit orders
        stop_price: Stop price for stop orders

    Returns
    -------
        Order preview
    """
    request = CreateOrderRequest(
        type=type if isinstance(type, OrderType) else OrderType(type),
        symbol=symbol,
        time_in_force=time_in_force
        if isinstance(time_in_force, TimeInForce)
        else TimeInForce(time_in_force),
        notional=notional,
        quantity=quantity,
        position_intent=position_intent
        if position_intent is None or isinstance(position_intent, PositionIntent)
        else PositionIntent(position_intent),
        limit_price=limit_price,
        stop_price=stop_price,
        client_order_id=None,
    )
    response = self._client.post(
        f"/api/v1/trading/accounts/{account_id}/order-requests/preview",
        json=request.model_dump(exclude_none=True),
    )
    return ExercisePreviewResponse.model_validate(response)

Deploy Resource

composer.resources.deploy.DeployResource

Resource for deploy-related endpoints.

Source code in composer/resources/deploy.py
class DeployResource:
    """Resource for deploy-related endpoints."""

    def __init__(self, http_client):
        self._client = http_client

    def get_market_hours(self) -> MarketHoursResponse:
        """
        Get market hours schedule for the upcoming week.

        Returns
        -------
            Market hours schedule including open/close times for each day
        """
        response = self._client.get("/api/v1/deploy/market-hours")
        return MarketHoursResponse.model_validate(response)

    def get_deploy_symphonies(
        self,
        account_id: str,
        asset_class: str | None = None,
    ) -> DeploySymphoniesResponse:
        """
        Get metadata for symphonies which have new invests pending.

        Args:
            account_id: Unique identifier (UUID) of the account
            asset_class: Deprecated.

        Returns
        -------
            List of symphonies with pending invests
        """
        params = {}
        if asset_class:
            params["asset_class"] = asset_class
        response = self._client.get(
            f"/api/v1/deploy/accounts/{account_id}/deploy-symphonies",
            params=params if params else None,
        )
        return DeploySymphoniesResponse.model_validate(response)

    def get_deploys(
        self,
        account_id: str,
        status: str | None = None,
        limit: int | None = None,
    ) -> DeploysResponse:
        """
        Get all deploy details for an account.

        Args:
            account_id: Unique identifier (UUID) of the account
            status: Filter by status (QUEUED, CANCELED, SUCCEEDED, FAILED, REJECTED, EXPIRED)
            limit: Maximum number of results

        Returns
        -------
            List of deploys for the account
        """
        params = {}
        if status:
            params["status"] = status
        if limit is not None:
            params["limit"] = limit
        response = self._client.get(
            f"/api/v1/deploy/accounts/{account_id}/deploys",
            params=params if params else None,
        )
        return DeploysResponse.model_validate(response)

    def get_deploy(
        self,
        account_id: str,
        deploy_id: str,
    ) -> DeployModel:
        """
        Get a specific deploy's details.

        Args:
            account_id: Unique identifier (UUID) of the account
            deploy_id: Unique identifier for the deployment operation

        Returns
        -------
            Details of the specified deploy
        """
        response = self._client.get(f"/api/v1/deploy/accounts/{account_id}/deploys/{deploy_id}")
        return DeployModel.model_validate(response)

    def delete_deploy(
        self,
        account_id: str,
        deploy_id: str,
    ) -> None:
        """
        Cancel a pending deploy.

        Args:
            account_id: Unique identifier (UUID) of the account
            deploy_id: Unique identifier for the deployment operation
        """
        self._client.delete(f"/api/v1/deploy/accounts/{account_id}/deploys/{deploy_id}")

    def go_to_cash(
        self,
        account_id: str,
        symphony_id: str,
    ) -> DeployActionResponse:
        """
        Sell all assets in a symphony, leaving proceeds in cash.

        Args:
            account_id: Unique identifier (UUID) of the account
            symphony_id: Unique identifier for the Symphony

        Returns
        -------
            Information about the deploy
        """
        response = self._client.post(
            f"/api/v1/deploy/accounts/{account_id}/symphonies/{symphony_id}/go-to-cash"
        )
        return DeployActionResponse.model_validate(response)

    def invest(
        self,
        account_id: str,
        symphony_id: str,
        amount: float,
    ) -> DeployActionResponse:
        """
        Invest cash into a Symphony.

        Args:
            account_id: Unique identifier (UUID) of the account
            symphony_id: Unique identifier for the Symphony
            amount: Amount of cash to invest (in USD)

        Returns
        -------
            Information about the deploy
        """
        response = self._client.post(
            f"/api/v1/deploy/accounts/{account_id}/symphonies/{symphony_id}/invest",
            json={"amount": amount},
        )
        return DeployActionResponse.model_validate(response)

    def liquidate(
        self,
        account_id: str,
        symphony_id: str,
    ) -> DeployActionResponse:
        """
        Liquidate a symphony entirely.

        Args:
            account_id: Unique identifier (UUID) of the account
            symphony_id: Unique identifier for the Symphony

        Returns
        -------
            Information about the deploy
        """
        response = self._client.post(
            f"/api/v1/deploy/accounts/{account_id}/symphonies/{symphony_id}/liquidate"
        )
        return DeployActionResponse.model_validate(response)

    def rebalance(
        self,
        account_id: str,
        symphony_id: str,
        rebalance_request_uuid: str,
    ) -> DeployActionResponse:
        """
        Rebalance a symphony NOW.

        Args:
            account_id: Unique identifier (UUID) of the account
            symphony_id: Unique identifier for the Symphony
            rebalance_request_uuid: UUID for the rebalance request

        Returns
        -------
            Information about the deploy
        """
        response = self._client.post(
            f"/api/v1/deploy/accounts/{account_id}/symphonies/{symphony_id}/rebalance",
            json={"rebalance_request_uuid": rebalance_request_uuid},
        )
        return DeployActionResponse.model_validate(response)

    def skip_automated_rebalance(
        self,
        account_id: str,
        symphony_id: str,
        skip: bool,
    ) -> None:
        """
        Skip automated rebalancing.

        Args:
            account_id: Unique identifier (UUID) of the account
            symphony_id: Unique identifier for the Symphony
            skip: Whether to skip the next automated rebalance
        """
        self._client.post(
            f"/api/v1/deploy/accounts/{account_id}/symphonies/{symphony_id}/skip-automated-rebalance",
            json={"skip": skip},
        )

    def withdraw(
        self,
        account_id: str,
        symphony_id: str,
        amount: float,
    ) -> DeployActionResponse:
        """
        Withdraw cash from a Symphony.

        Args:
            account_id: Unique identifier (UUID) of the account
            symphony_id: Unique identifier for the Symphony
            amount: Amount of cash to withdraw (in USD)

        Returns
        -------
            Information about the deploy
        """
        response = self._client.post(
            f"/api/v1/deploy/accounts/{account_id}/symphonies/{symphony_id}/withdraw",
            json={"amount": amount},
        )
        return DeployActionResponse.model_validate(response)

delete_deploy(account_id, deploy_id)

Cancel a pending deploy.

Parameters:

Name Type Description Default
account_id str

Unique identifier (UUID) of the account

required
deploy_id str

Unique identifier for the deployment operation

required
Source code in composer/resources/deploy.py
def delete_deploy(
    self,
    account_id: str,
    deploy_id: str,
) -> None:
    """
    Cancel a pending deploy.

    Args:
        account_id: Unique identifier (UUID) of the account
        deploy_id: Unique identifier for the deployment operation
    """
    self._client.delete(f"/api/v1/deploy/accounts/{account_id}/deploys/{deploy_id}")

get_deploy(account_id, deploy_id)

Get a specific deploy's details.

Parameters:

Name Type Description Default
account_id str

Unique identifier (UUID) of the account

required
deploy_id str

Unique identifier for the deployment operation

required
Returns
Details of the specified deploy
Source code in composer/resources/deploy.py
def get_deploy(
    self,
    account_id: str,
    deploy_id: str,
) -> DeployModel:
    """
    Get a specific deploy's details.

    Args:
        account_id: Unique identifier (UUID) of the account
        deploy_id: Unique identifier for the deployment operation

    Returns
    -------
        Details of the specified deploy
    """
    response = self._client.get(f"/api/v1/deploy/accounts/{account_id}/deploys/{deploy_id}")
    return DeployModel.model_validate(response)

get_deploy_symphonies(account_id, asset_class=None)

Get metadata for symphonies which have new invests pending.

Parameters:

Name Type Description Default
account_id str

Unique identifier (UUID) of the account

required
asset_class str | None

Deprecated.

None
Returns
List of symphonies with pending invests
Source code in composer/resources/deploy.py
def get_deploy_symphonies(
    self,
    account_id: str,
    asset_class: str | None = None,
) -> DeploySymphoniesResponse:
    """
    Get metadata for symphonies which have new invests pending.

    Args:
        account_id: Unique identifier (UUID) of the account
        asset_class: Deprecated.

    Returns
    -------
        List of symphonies with pending invests
    """
    params = {}
    if asset_class:
        params["asset_class"] = asset_class
    response = self._client.get(
        f"/api/v1/deploy/accounts/{account_id}/deploy-symphonies",
        params=params if params else None,
    )
    return DeploySymphoniesResponse.model_validate(response)

get_deploys(account_id, status=None, limit=None)

Get all deploy details for an account.

Parameters:

Name Type Description Default
account_id str

Unique identifier (UUID) of the account

required
status str | None

Filter by status (QUEUED, CANCELED, SUCCEEDED, FAILED, REJECTED, EXPIRED)

None
limit int | None

Maximum number of results

None
Returns
List of deploys for the account
Source code in composer/resources/deploy.py
def get_deploys(
    self,
    account_id: str,
    status: str | None = None,
    limit: int | None = None,
) -> DeploysResponse:
    """
    Get all deploy details for an account.

    Args:
        account_id: Unique identifier (UUID) of the account
        status: Filter by status (QUEUED, CANCELED, SUCCEEDED, FAILED, REJECTED, EXPIRED)
        limit: Maximum number of results

    Returns
    -------
        List of deploys for the account
    """
    params = {}
    if status:
        params["status"] = status
    if limit is not None:
        params["limit"] = limit
    response = self._client.get(
        f"/api/v1/deploy/accounts/{account_id}/deploys",
        params=params if params else None,
    )
    return DeploysResponse.model_validate(response)

get_market_hours()

Get market hours schedule for the upcoming week.

Returns
Market hours schedule including open/close times for each day
Source code in composer/resources/deploy.py
def get_market_hours(self) -> MarketHoursResponse:
    """
    Get market hours schedule for the upcoming week.

    Returns
    -------
        Market hours schedule including open/close times for each day
    """
    response = self._client.get("/api/v1/deploy/market-hours")
    return MarketHoursResponse.model_validate(response)

go_to_cash(account_id, symphony_id)

Sell all assets in a symphony, leaving proceeds in cash.

Parameters:

Name Type Description Default
account_id str

Unique identifier (UUID) of the account

required
symphony_id str

Unique identifier for the Symphony

required
Returns
Information about the deploy
Source code in composer/resources/deploy.py
def go_to_cash(
    self,
    account_id: str,
    symphony_id: str,
) -> DeployActionResponse:
    """
    Sell all assets in a symphony, leaving proceeds in cash.

    Args:
        account_id: Unique identifier (UUID) of the account
        symphony_id: Unique identifier for the Symphony

    Returns
    -------
        Information about the deploy
    """
    response = self._client.post(
        f"/api/v1/deploy/accounts/{account_id}/symphonies/{symphony_id}/go-to-cash"
    )
    return DeployActionResponse.model_validate(response)

invest(account_id, symphony_id, amount)

Invest cash into a Symphony.

Parameters:

Name Type Description Default
account_id str

Unique identifier (UUID) of the account

required
symphony_id str

Unique identifier for the Symphony

required
amount float

Amount of cash to invest (in USD)

required
Returns
Information about the deploy
Source code in composer/resources/deploy.py
def invest(
    self,
    account_id: str,
    symphony_id: str,
    amount: float,
) -> DeployActionResponse:
    """
    Invest cash into a Symphony.

    Args:
        account_id: Unique identifier (UUID) of the account
        symphony_id: Unique identifier for the Symphony
        amount: Amount of cash to invest (in USD)

    Returns
    -------
        Information about the deploy
    """
    response = self._client.post(
        f"/api/v1/deploy/accounts/{account_id}/symphonies/{symphony_id}/invest",
        json={"amount": amount},
    )
    return DeployActionResponse.model_validate(response)

liquidate(account_id, symphony_id)

Liquidate a symphony entirely.

Parameters:

Name Type Description Default
account_id str

Unique identifier (UUID) of the account

required
symphony_id str

Unique identifier for the Symphony

required
Returns
Information about the deploy
Source code in composer/resources/deploy.py
def liquidate(
    self,
    account_id: str,
    symphony_id: str,
) -> DeployActionResponse:
    """
    Liquidate a symphony entirely.

    Args:
        account_id: Unique identifier (UUID) of the account
        symphony_id: Unique identifier for the Symphony

    Returns
    -------
        Information about the deploy
    """
    response = self._client.post(
        f"/api/v1/deploy/accounts/{account_id}/symphonies/{symphony_id}/liquidate"
    )
    return DeployActionResponse.model_validate(response)

rebalance(account_id, symphony_id, rebalance_request_uuid)

Rebalance a symphony NOW.

Parameters:

Name Type Description Default
account_id str

Unique identifier (UUID) of the account

required
symphony_id str

Unique identifier for the Symphony

required
rebalance_request_uuid str

UUID for the rebalance request

required
Returns
Information about the deploy
Source code in composer/resources/deploy.py
def rebalance(
    self,
    account_id: str,
    symphony_id: str,
    rebalance_request_uuid: str,
) -> DeployActionResponse:
    """
    Rebalance a symphony NOW.

    Args:
        account_id: Unique identifier (UUID) of the account
        symphony_id: Unique identifier for the Symphony
        rebalance_request_uuid: UUID for the rebalance request

    Returns
    -------
        Information about the deploy
    """
    response = self._client.post(
        f"/api/v1/deploy/accounts/{account_id}/symphonies/{symphony_id}/rebalance",
        json={"rebalance_request_uuid": rebalance_request_uuid},
    )
    return DeployActionResponse.model_validate(response)

skip_automated_rebalance(account_id, symphony_id, skip)

Skip automated rebalancing.

Parameters:

Name Type Description Default
account_id str

Unique identifier (UUID) of the account

required
symphony_id str

Unique identifier for the Symphony

required
skip bool

Whether to skip the next automated rebalance

required
Source code in composer/resources/deploy.py
def skip_automated_rebalance(
    self,
    account_id: str,
    symphony_id: str,
    skip: bool,
) -> None:
    """
    Skip automated rebalancing.

    Args:
        account_id: Unique identifier (UUID) of the account
        symphony_id: Unique identifier for the Symphony
        skip: Whether to skip the next automated rebalance
    """
    self._client.post(
        f"/api/v1/deploy/accounts/{account_id}/symphonies/{symphony_id}/skip-automated-rebalance",
        json={"skip": skip},
    )

withdraw(account_id, symphony_id, amount)

Withdraw cash from a Symphony.

Parameters:

Name Type Description Default
account_id str

Unique identifier (UUID) of the account

required
symphony_id str

Unique identifier for the Symphony

required
amount float

Amount of cash to withdraw (in USD)

required
Returns
Information about the deploy
Source code in composer/resources/deploy.py
def withdraw(
    self,
    account_id: str,
    symphony_id: str,
    amount: float,
) -> DeployActionResponse:
    """
    Withdraw cash from a Symphony.

    Args:
        account_id: Unique identifier (UUID) of the account
        symphony_id: Unique identifier for the Symphony
        amount: Amount of cash to withdraw (in USD)

    Returns
    -------
        Information about the deploy
    """
    response = self._client.post(
        f"/api/v1/deploy/accounts/{account_id}/symphonies/{symphony_id}/withdraw",
        json={"amount": amount},
    )
    return DeployActionResponse.model_validate(response)

Dry Run Resource

composer.resources.dry_run.DryRun

Resource for dry-run endpoints.

Source code in composer/resources/dry_run.py
class DryRun:
    """Resource for dry-run endpoints."""

    def __init__(self, http_client):
        self._client = http_client

    def create_dry_run(
        self,
        send_segment_event: bool = False,
        account_uuids: list[str] | None = None,
    ) -> list[AccountDryRunResult]:
        """
        Dry run rebalances for a specific user.

        Args:
            send_segment_event: Whether to send segment events
            account_uuids: Optional list of specific account UUIDs

        Returns
        -------
            List of dry run results for each account
        """
        request = DryRunRequest(
            account_uuids=account_uuids,
            send_segment_event=send_segment_event,
        )
        response = self._client.post(
            "/api/v1/dry-run",
            json=request.model_dump(exclude_none=True),
        )
        return [AccountDryRunResult.model_validate(r) for r in response]

    def create_trade_preview(
        self,
        symphony_id: str,
        amount: float | None = None,
        broker_account_uuid: str | None = None,
    ) -> TradePreviewResult:
        """
        Generate trade preview for a single symphony.

        Args:
            symphony_id: Unique identifier for the Symphony
            amount: Optional amount to preview
            broker_account_uuid: Optional specific account UUID

        Returns
        -------
            Trade preview result
        """
        request = TradePreviewRequest(
            amount=amount,
            broker_account_uuid=broker_account_uuid,
        )
        response = self._client.post(
            f"/api/v1/dry-run/trade-preview/{symphony_id}",
            json=request.model_dump(exclude_none=True),
        )
        return TradePreviewResult.model_validate(response)

create_dry_run(send_segment_event=False, account_uuids=None)

Dry run rebalances for a specific user.

Parameters:

Name Type Description Default
send_segment_event bool

Whether to send segment events

False
account_uuids list[str] | None

Optional list of specific account UUIDs

None
Returns
List of dry run results for each account
Source code in composer/resources/dry_run.py
def create_dry_run(
    self,
    send_segment_event: bool = False,
    account_uuids: list[str] | None = None,
) -> list[AccountDryRunResult]:
    """
    Dry run rebalances for a specific user.

    Args:
        send_segment_event: Whether to send segment events
        account_uuids: Optional list of specific account UUIDs

    Returns
    -------
        List of dry run results for each account
    """
    request = DryRunRequest(
        account_uuids=account_uuids,
        send_segment_event=send_segment_event,
    )
    response = self._client.post(
        "/api/v1/dry-run",
        json=request.model_dump(exclude_none=True),
    )
    return [AccountDryRunResult.model_validate(r) for r in response]

create_trade_preview(symphony_id, amount=None, broker_account_uuid=None)

Generate trade preview for a single symphony.

Parameters:

Name Type Description Default
symphony_id str

Unique identifier for the Symphony

required
amount float | None

Optional amount to preview

None
broker_account_uuid str | None

Optional specific account UUID

None
Returns
Trade preview result
Source code in composer/resources/dry_run.py
def create_trade_preview(
    self,
    symphony_id: str,
    amount: float | None = None,
    broker_account_uuid: str | None = None,
) -> TradePreviewResult:
    """
    Generate trade preview for a single symphony.

    Args:
        symphony_id: Unique identifier for the Symphony
        amount: Optional amount to preview
        broker_account_uuid: Optional specific account UUID

    Returns
    -------
        Trade preview result
    """
    request = TradePreviewRequest(
        amount=amount,
        broker_account_uuid=broker_account_uuid,
    )
    response = self._client.post(
        f"/api/v1/dry-run/trade-preview/{symphony_id}",
        json=request.model_dump(exclude_none=True),
    )
    return TradePreviewResult.model_validate(response)