LIVE
connecting to the live quote stream…
--:--:--UTC
mediumML○
#25

Cross-sectional rank of 34 tickers

mediumMLacceptance —~25 min

Implement cs_rank(values) — the cross-sectional percentile rank of each value among its peers: rank the values ascending from 0 to n - 1, give TIED values the average of the ranks they would occupy, then divide by n - 1 so the result lies in [0, 1].

Ranking forward returns across the 34 names in the basket strips out whatever the whole market did that day — the cross-sectional model in ai quants predicts this rank, not the return. Return the ranks rounded to 4 decimal places.

example 1
input
values=[0.02, -0.01, 0.05, 0.0]
output
[0.6667, 0, 1, 0.3333]
example 2
input
values=[0.02, 0.02, 0.05, -0.01]
output
[0.5, 0.5, 1, 0]
note

Two names tied at 2% share rank 1.5.

constraints
  • 2 ≤ len(values) ≤ 500
teacher · 2 hints · the first is free
↗ read the theory
the chapter this problem is cut from
▶ open in the workbench
run the same math on a real tape
●solution.py· utf-8 · spaces:4
ln 1, col 1tab indent · esc leave editor
python 3.13 · pyodide
+ 6 hidden on submit
input · keyword arguments to cs_rank()
values=[0.02, -0.01, 0.05, 0.0]
expected
[0.6667, 0, 1, 0.3333]

the judge calls cs_rank() with exactly these inputs · outputs are compared to 6 decimal places

● standing bypython 3.13 in your browser · pyodide 0.28.3 · judged on the server to 6 dp⌘↵ run · ⌘⇧↵ submit
paper only · educational · not advice