Skip to content

Portfolio history - connector filter is accepted but ignored in returned snapshots #180

Description

@rapcmia

Describe the bug

This issue was noticed while checking the portfolio API routes during #178 tests. The expected behavior was that /portfolio/history would return only the connector requested in connector_names, just like /portfolio/state and /portfolio/distribution already do. Instead, the history route accepted the filter, echoed it back in the pagination metadata, but still returned balances from other connectors in the same account snapshot.

curl -s -u XXX:XXX -X POST http://localhost:8000/portfolio/history \
  -H "Content-Type: application/json" \
  -d '
{
  "account_names": ["master_account"],
  "connector_names": ["gate_io"],
  "limit": 1,
  "interval": "5m"
}' | jq

{
  "data": [
    {
      "state": {
        "master_account": {
          "gate_io": ["GT", "BTC", "SOL", "NOT", "HYPE", "GRAM", "XRP", "ETH", "USDT", "POLIS", "TLOS"],
          "hyperliquid": ["USDC", "LQNA", "HYPE"],
          "hyperliquid_perpetual": ["USD"]
        }
      }
    }
  ],
  "pagination": {
    "filters": {
      "connector_names": ["gate_io"]
    }
  }
}

It also appears to exist in the main branch when compared. In routers/portfolio.py, the history route tries to filter a nested connectors field, but the actual returned history structure stores connector names directly under each account inside state. That mismatch likely causes the connector filter to be ignored for the returned history data.

Steps to reproduce bug

Assuming you have added multiple connectors including gate_io

  1. Call POST /portfolio/history with a real account name and a single connector in connector_names, such as ["gate_io"].
  2. Check the returned data[] object for that account.
  3. Confirm that the response still includes other connectors even though the pagination filters echo back only the requested connector.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions