{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/stocktrends-com/json-schema/stocktrends-com-stock-trends-portfolio-closed-positions-response-schema.json",
  "title": "StockTrendsPortfolioClosedPositionsResponse",
  "x-generated": "2026-11-26",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/stocktrends-com-openapi.json#/components/schemas/StockTrendsPortfolioClosedPositionsResponse",
  "properties": {
    "request_id": {
      "type": "string",
      "title": "Request Id"
    },
    "port_id": {
      "type": "integer",
      "title": "Port Id"
    },
    "portfolio": {
      "$ref": "#/$defs/StockTrendsPortfolioReturnsPortfolio"
    },
    "count": {
      "type": "integer",
      "title": "Count"
    },
    "positions": {
      "items": {
        "$ref": "#/$defs/StockTrendsPortfolioClosedPosition"
      },
      "type": "array",
      "title": "Positions"
    }
  },
  "type": "object",
  "required": [
    "request_id",
    "port_id",
    "portfolio",
    "count",
    "positions"
  ],
  "$defs": {
    "StockTrendsPortfolioClosedPosition": {
      "properties": {
        "position_id": {
          "type": "integer",
          "title": "Position Id",
          "description": "Official Stock Trends closed-position identifier."
        },
        "symbol": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Symbol",
          "description": "Security ticker symbol."
        },
        "exchange": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Exchange",
          "description": "Stock Trends exchange code."
        },
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Name",
          "description": "Security name."
        },
        "date_in": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Date In",
          "description": "Position entry date."
        },
        "price_in": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Price In",
          "description": "Position entry price."
        },
        "qty": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Qty",
          "description": "Position share quantity."
        },
        "transaction_cost_in": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Transaction Cost In",
          "description": "Entry transaction cost."
        },
        "cost_adjustments": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Cost Adjustments",
          "description": "Entry-side cost adjustments."
        },
        "total_cost": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Total Cost",
          "description": "Total entry cost."
        },
        "stop_loss": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Stop Loss",
          "description": "Recorded stop-loss level."
        },
        "date_out": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Date Out",
          "description": "Position close date."
        },
        "weeks_held": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Weeks Held",
          "description": "Number of weeks the position was held."
        },
        "sell_trigger": {
          "type": "string",
          "title": "Sell Trigger",
          "description": "Historical close trigger. Empty live-position triggers are excluded."
        },
        "price_out": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Price Out",
          "description": "Position close price."
        },
        "transaction_cost_out": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Transaction Cost Out",
          "description": "Exit transaction cost."
        },
        "sell_adjustments": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Sell Adjustments",
          "description": "Exit-side sale adjustments."
        },
        "total_proceeds": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Total Proceeds",
          "description": "Total close proceeds."
        },
        "gain_loss": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Gain Loss",
          "description": "Realized gain or loss."
        },
        "gain_loss_percent": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Gain Loss Percent",
          "description": "Realized gain or loss percentage."
        },
        "weekdate": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Weekdate",
          "description": "Week-ending date associated with the closed position."
        }
      },
      "type": "object",
      "required": [
        "position_id",
        "sell_trigger"
      ],
      "title": "StockTrendsPortfolioClosedPosition"
    },
    "StockTrendsPortfolioReturnsPortfolio": {
      "properties": {
        "port_id": {
          "type": "integer",
          "title": "Port Id",
          "description": "Official Stock Trends portfolio identifier."
        },
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Name",
          "description": "Official Stock Trends portfolio name."
        },
        "selection_universe": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Selection Universe",
          "description": "Stock Trends strategy selection/filter universe configured for the portfolio."
        }
      },
      "type": "object",
      "required": [
        "port_id"
      ],
      "title": "StockTrendsPortfolioReturnsPortfolio"
    }
  }
}