API functions: Rank

Portfolio123
Written by Portfolio123Last updated 3 days ago

Rank Functions

API Credits

rank_create (new)

1

Create a new ranking system

rank_get (new)

1

Get the ranks for the id or named ranking system

rank_ranks

1 per 100K points
Minimum of 2.

This operation allows you to retrieve rank data from a ranking system for a specific universe.

rank_perf

3

This operation lets you run bucket performance tests of multifactor ranking systems.

rank_touch

1

Forces a flush of all cached ranks

rank_update

1

This operation updates the "API ranking system" called ApiRankingSystem.

rank_create(name, nodes, rankingMethod, type, currency)

Create a new ranking system

Creates a ranking system based on the provided nodes and configuration parameters.

Args:
    name: Ranking system name.
    nodes: Ranking system nodes XML.
    rankingMethod: Ranking method to be used.
    type: Ranking method type. Use "Stock" or "ETF".
    currency: Ranking method currency.

Returns:
    An object containing the new ranking system's id.

Examples:
    >>> client.rank_create(
    ...     'New Ranking System',
    ...     '<RankingSystem RankType="Higher">...</RankingSystem>',
    ...     rankingMethod=RankingMethod.PERCENTILE_NA_NEGATIVE,
    ...     type='Stock',
    ...     currency='USD'
    ... )
    IdResult(id=98765)

rank_get(name | id)

Get the ranks for the id or named ranking system

Retrieves the details for a given ranking system by name.

Args:
    name: The name of the ranking system.
    or
    id: The id of a ranking systme

Returns:
    An object containing the ranking system's details.

Examples:
            >>> client.rank_get(name='My Ranking System')
            RankInfoResult(
                name='My Ranking System',
                id=12345,
                xml='<RankingSystem,...</RankingSystem>',
                currency='USD',
                rankingMethod=<RankingMethod.PERCENTILE_NA_NEGATIVE: 2>,
                type='Stock',
                groupUid=100,
                resolveGroupUid=200
            )

rank_ranks(params, to_pandas)

This operation allows you to retrieve rank data from a ranking system for a specific universe.

Args:
    params: {
      'rankingSystem': 'Ranking name',
      'asOfDt': 'yyyy-mm-dd',
      'universe': 'Universe name',
      # Optional parameters,
      'pitMethod': 'Complete' | 'Prelim'',
      'precision': 2 | 3 | 4,
      'rankingMethod': 2, # 2:NAs Negative, 4:NAs Neutral
      # Filter for specific stocks
      'tickers': 'IBM,MSFT',
      'includeNames': False,
      'includeNaCnt': False,
      'includeFinalStmt': False,
      'nodeDetails': 'composite' | 'factor',
      'currency': currency code,
      'additionalData': ['formula1','formula2',...]
       # Example: ['Close(0)', 'mktcap', "ZScore(`Pr2SalesQ`,#All)"]
    to_pandas: True

rank_perf(params)

This operation lets you run bucket performance tests of multifactor ranking systems. You can use one of your existing ranking systems or a Portfolio123 ranking system. This includes your ApiRankingSystem which can be modified using the rank_update endpoint. Other specific settings include the number of buckets, minimum price, transaction slippage (expressed in %), sector, benchmark and output type.

Args:
    params: {
      'rankingSystem': 'Rank Name',
      'startDt': 'yyyy-mm-dd',
      #
      # Optional parameters
      'endDt': 'yyyy-mm-dd',
      'pitMethod': 'Complete' | 'Prelim',
      'precision': 2 | 3 | 4,
      'universe': 'Universe name',
      'transType': 'Long' | 'Short',
      'rankingMethod': 2, # 2 NAs Negative | 4 NAs Neutral
      'numBuckets': 20,
      'maxNAs': 999,
      'minPrice': 3,
      'minLiquidity': 5000,
      'maxReturn': 200,
      'rebalFreq': 'Every 4 Weeks' | 'Every Week' | 
                   'Every N Weeks' (2,3,4,6,8,13,26,52),
       'slippage': 0,
       'benchmark': 'SPY',
       'outputType': 'ann' | 'perf'
    }

rank_update(params)

This operation updates the "API ranking system" called ApiRankingSystem. If you don’t have this ranking system already saved in the platform, it will be created automatically.

Args:
    params: {
    # For 'nodes' use the same XML format you see when you 
    # click 'Text Editor' in the page Ranking System->Factors 
    'nodes': 'node definition',
    'type': 'stock' | 'etf',
    # Optional parameters
    # If id is missing the ranking system 'ApiRankingSystem' is updated
    'id': 123 
    'rankingMethod': 2,  # 2 NAs Negative, 4 NAs Neutral
    'currency': currency code
    }

Go to:

Did this article help you solve your issue?

Portfolio123 - Help Center

© 2026 Portfolio123 - Help Center. All rights reserved.

Knowledge Base Software by Customerly