Private/Get-ClobTrade.ps1

function Get-ClobTrade {
  [CmdletBinding()]
  param (
    [Parameter()]
    [string]$Market,

    [Parameter()]
    [string]$Cursor,

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

  process {
    $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'])

    $params = @{}
    if ($Market) { $params['market'] = $Market }
    if ($Cursor) { $params['cursor'] = $Cursor }

    # The ClobClient needs a GetTrades method.
    # Let's check if it exists in psm1.
    $result = $client.GetAuth("/trades", $params)
    [PolymarketOutput]::Format($result, $Output)
  }
}