Private/New-ClobMarketOrder.ps1

function New-ClobMarketOrder {
  [CmdletBinding(SupportsShouldProcess)]
  param (
    [Parameter(Mandatory = $true)]
    [string]$Token,

    [Parameter(Mandatory = $true)]
    [string]$Amount,

    [Parameter()]
    [ValidateSet('buy', 'sell')]
    [string]$Side = 'buy',

    [Parameter()]
    [ValidateSet('FOK', 'FAK')]
    [string]$OrderType = 'FOK',

    [Parameter()]
    [ValidateSet('table', 'json')]
    [string]$Output = 'table'
  )

  process {
    if ($PSCmdlet.ShouldProcess("Market Order on $Token", "Create $Side market order for $Amount")) {
      $client = [ClobClient]::new()
      $config = [PolymarketConfig]::Load()
      if (!$config.ContainsKey('api_key')) { throw "API credentials not found." }
      $client.SetCredentials($config['api_key'], $config['api_secret'], $config['api_passphrase'])

      $order = @{
        token_id   = $Token
        amount     = $Amount
        side       = $Side
        order_type = $OrderType
      }

      $result = $client.PostOrder($order)
      [PolymarketOutput]::Format($result, $Output)
    }
  }
}