> ## Documentation Index
> Fetch the complete documentation index at: https://docs.simmer.markets/llms.txt
> Use this file to discover all available pages before exploring further.

# Copytrading Execute

> Execute copytrading: mirror positions from target wallets.

This wraps the existing copytrading_strategy.py logic for SDK/skills usage.
Fetches target wallet positions via Dome API, calculates rebalance trades,
and executes via SDK trade flow.

Flow:
1. Fetch positions from all target wallets
2. Calculate size-weighted allocations (larger wallets = more influence)
3. Skip markets with conflicting positions
4. Apply Top N filter (concentrate on highest-conviction positions)
5. Match to Simmer database (auto-import missing markets)
6. Get user's current Polymarket positions (track which are from copytrading)
7. Calculate rebalance trades
8. Filter to buy-only if buy_only=True (default: prevents selling positions from other strategies)
9. Detect whale exits if detect_whale_exits=True (sell positions whales no longer hold)
10. Execute trades (unless dry_run=True)

Parameters:
- wallets: List of wallet addresses to copy
- top_n: Number of positions to mirror (None = auto based on balance)
- max_usd_per_position: Max USD per position (default: 50)
- dry_run: If true, return signals without executing
- buy_only: If true (default), only buy to match targets. This prevents
  copytrading from selling positions opened by other strategies (weather, etc.)
  Set to false for full rebalancing mode.
- detect_whale_exits: If true, sell positions that whales no longer hold.
  Only affects positions originally opened by copytrading (tracks via source field).
  Use with buy_only=True to accumulate + follow whale exits.

Requires API key in Authorization header (rate limited: 30/minute).

<Warning>This endpoint executes real trades. Always test with `venue=sim` first.</Warning>


## OpenAPI

````yaml /openapi.json post /api/sdk/copytrading/execute
openapi: 3.1.0
info:
  title: Simmer API
  description: Agent-native trading infrastructure for prediction markets.
  version: 1.0.0
servers:
  - url: https://api.simmer.markets
security: []
paths:
  /api/sdk/copytrading/execute:
    post:
      summary: Copytrading Execute
      description: >-
        Execute copytrading: mirror positions from target wallets.


        This wraps the existing copytrading_strategy.py logic for SDK/skills
        usage.

        Fetches target wallet positions via Dome API, calculates rebalance
        trades,

        and executes via SDK trade flow.


        Flow:

        1. Fetch positions from all target wallets

        2. Calculate size-weighted allocations (larger wallets = more influence)

        3. Skip markets with conflicting positions

        4. Apply Top N filter (concentrate on highest-conviction positions)

        5. Match to Simmer database (auto-import missing markets)

        6. Get user's current Polymarket positions (track which are from
        copytrading)

        7. Calculate rebalance trades

        8. Filter to buy-only if buy_only=True (default: prevents selling
        positions from other strategies)

        9. Detect whale exits if detect_whale_exits=True (sell positions whales
        no longer hold)

        10. Execute trades (unless dry_run=True)


        Parameters:

        - wallets: List of wallet addresses to copy

        - top_n: Number of positions to mirror (None = auto based on balance)

        - max_usd_per_position: Max USD per position (default: 50)

        - dry_run: If true, return signals without executing

        - buy_only: If true (default), only buy to match targets. This prevents
          copytrading from selling positions opened by other strategies (weather, etc.)
          Set to false for full rebalancing mode.
        - detect_whale_exits: If true, sell positions that whales no longer
        hold.
          Only affects positions originally opened by copytrading (tracks via source field).
          Use with buy_only=True to accumulate + follow whale exits.

        Requires API key in Authorization header (rate limited: 30/minute).
      operationId: api_sdk_copytrading_execute_api_sdk_copytrading_execute_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SDKCopytradingRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SDKCopytradingResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    SDKCopytradingRequest:
      properties:
        wallets:
          items:
            type: string
          type: array
          title: Wallets
        top_n:
          anyOf:
            - type: integer
            - type: 'null'
          title: Top N
        max_usd_per_position:
          type: number
          title: Max Usd Per Position
          default: 50
        dry_run:
          type: boolean
          title: Dry Run
          default: false
        buy_only:
          type: boolean
          title: Buy Only
          default: true
        detect_whale_exits:
          type: boolean
          title: Detect Whale Exits
          default: false
        max_trades:
          anyOf:
            - type: integer
            - type: 'null'
          title: Max Trades
        venue:
          anyOf:
            - type: string
            - type: 'null'
          title: Venue
        market_ids:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Market Ids
      type: object
      required:
        - wallets
      title: SDKCopytradingRequest
      description: Request for copytrading execute endpoint.
    SDKCopytradingResponse:
      properties:
        success:
          type: boolean
          title: Success
        wallets_analyzed:
          type: integer
          title: Wallets Analyzed
        positions_found:
          type: integer
          title: Positions Found
        conflicts_skipped:
          type: integer
          title: Conflicts Skipped
        top_n_used:
          type: integer
          title: Top N Used
        markets_matched:
          type: integer
          title: Markets Matched
          default: 0
        user_positions:
          type: integer
          title: User Positions
          default: 0
        trades_needed:
          type: integer
          title: Trades Needed
        trades_executed:
          type: integer
          title: Trades Executed
        trades_filtered_buy_only:
          type: integer
          title: Trades Filtered Buy Only
          default: 0
        buys_skipped_min_shares:
          type: integer
          title: Buys Skipped Min Shares
          default: 0
        buys_skipped_min_value:
          type: integer
          title: Buys Skipped Min Value
          default: 0
        whale_exits_detected:
          type: integer
          title: Whale Exits Detected
          default: 0
        failed_markets_skipped:
          type: integer
          title: Failed Markets Skipped
          default: 0
        drift_filtered:
          type: integer
          title: Drift Filtered
          default: 0
        stale_filtered:
          type: integer
          title: Stale Filtered
          default: 0
        low_conviction_positions:
          type: integer
          title: Low Conviction Positions
          default: 0
        scope_filtered:
          type: integer
          title: Scope Filtered
          default: 0
        trades:
          items:
            $ref: '#/components/schemas/SDKCopytradingTradeResult'
          type: array
          title: Trades
        skipped_markets:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Skipped Markets
          default: []
        summary:
          type: string
          title: Summary
        errors:
          items:
            type: string
          type: array
          title: Errors
          default: []
      type: object
      required:
        - success
        - wallets_analyzed
        - positions_found
        - conflicts_skipped
        - top_n_used
        - trades_needed
        - trades_executed
        - trades
        - summary
      title: SDKCopytradingResponse
      description: Response from copytrading execute endpoint.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    SDKCopytradingTradeResult:
      properties:
        market_id:
          type: string
          title: Market Id
        market_title:
          type: string
          title: Market Title
        action:
          type: string
          title: Action
        side:
          type: string
          title: Side
        shares:
          type: number
          title: Shares
        estimated_price:
          type: number
          title: Estimated Price
        estimated_cost:
          type: number
          title: Estimated Cost
        success:
          type: boolean
          title: Success
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
      type: object
      required:
        - market_id
        - market_title
        - action
        - side
        - shares
        - estimated_price
        - estimated_cost
        - success
      title: SDKCopytradingTradeResult
      description: Result of a single copytrading trade.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````