API functions: Rank
API functions for rank operations
Rank Functions | |
---|---|
rank_ranks | This operation allows you to retrieve rank data from a ranking system for a specific universe. |
rank_perf | This operation lets you run bucket performance tests of multifactor ranking systems. |
rank_update | This operation updates the "API ranking system" called ApiRankingSystem. |
Rank Functions
rank_ranks()
Wrapper for POST /rank/ranks
This operation allows you to retrieve rank data from a ranking system for a specific universe.
p123api.Client().rank_ranks({
'rankingSystem': 'Ranking name',
'asOfDt': 'yyyy-mm-dd',
'universe': 'Universe name',
#
# Optional parameters,
'pitMethod': 'Prelim' | 'Complete',
'precision': 2 | 3 | 4,
'rankingMethod': 2, # 2-Percentile NAs Negative, 4-Percentile NAs Neutral
# Filter for specific stocks
'tickers': 'IBM,MSFT',
'includeNames': False,
'includeNaCnt': False,
'includeFinalStmt': False,
'nodeDetails': 'composite' | 'factor',
'currency': 'USD' | 'CAD' | 'CHF' | 'EUR' | 'GBP' | 'NOK' | 'PLN' | 'SEK' | 'TRY',
'additionalData': ['formula1','formula2',...]
# Example: ['Close(0)', 'mktcap', "ZScore(`Pr2SalesQ`,#All)"]
},True) # True - output to Pandas DataFrame | [False] to JSON.
rank_perf()
Wrapper for POST /rank/performance
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.
p123api.Client().rank_perf({
'rankingSystem': 'Rank Name',
'startDt': 'yyyy-mm-dd',
#
# Optional parameters
'endDt': 'yyyy-mm-dd',
'pitMethod': 'Prelim' | 'Complete',
'precision': 2 | 3 | 4,
'universe': 'Universe name',
'transType': 'Long' | 'Short',
'rankingMethod': 2, # 2 NAs Negative | 4 NAs Neutral
'numBuckets': 10,
'minPrice': 5,
'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()
Wrapper for POST /rank
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.
p123api.Client().rank_update({
# 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
# ranking system id.
# If missing the ranking system 'ApiRankingSystem' is updated
'id': 123
'rankingMethod': 2, # 2 NAs Negative, 4 NAs Neutral
'currency': 'USD' | 'CAD' | 'CHF' | 'EUR' | 'GBP' | 'NOK' | 'PLN' | 'SEK' | 'TRY'
})
Go to:
All p123api functions
Technical API reference
Did this answer your question?