LIVE·WAITING…
connecting to the live quote stream…
--:--:--UTC
#24
Feature matrix: RSI, MACD, returns
easyMLacceptance —~20 min
Implement features(closes, window) — the feature row for the LAST bar: [ret1, momentum, vol] where ret1 = closes[-1] / closes[-2] - 1, momentum = closes[-1] / closes[-1 - window] - 1 (the return over exactly window bars), and vol is the population standard deviation of the last window one-bar simple returns.
Every model in the ai quants folder starts from a table like this — aligned, leak-free, one row per bar. Return the three values rounded to 4 decimal places.
example 1
input
closes=[100.0, 100.0, 100.0, 103.0, 102.0, 104.0], window=4
output
[0.0196, 0.04, 0.0157]
example 2
input
closes=[100.0, 98.0, 101.0, 103.0, 102.0, 104.0], window=4
output
[0.0196, 0.0612, 0.015]
constraints
- window + 1 ≤ len(closes) ≤ 10_000
- every close > 0
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 features()
closes=[100.0, 100.0, 100.0, 103.0, 102.0, 104.0], window=4
expected
[0.0196, 0.04, 0.0157]
the judge calls features() 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