This workflow computes a price-return pipeline from a series of prices:
Period returns: s.pct_change(periods=lag) — the percentage change over
lag periods. The first lag values are None (NaN).
Cumulative returns: (1 + s.pct_change(periods=lag)).cumprod() - 1 —
the compounded return from the start of the series. The first lag values
are also None.
Both outputs are rounded to 8 decimal places. NaN values become None.
Original Code
The original workflow is in workspace/solution.py. Study it carefully.
Your Task
Port the workflow in workspace/solution.py to Modal.
Create /app/solution/modal_app.py with:
A module-level app object
A module-level Modal Function named run_case
The verifier will call run_caseremote invocation (case) for each test case and compare
the result against the original Python output.
pct_returns and cumulative_returns are lists of the same length as
prices. Leading lag values are null.
All non-null values are rounded to 8 decimal places.
Notes
Your Modal image must include pandas.
The function_call_graph concept suggests splitting the pipeline into
multiple Modal functions (e.g., one to compute pct_change, another to
compute cumprod) and composing them with remote invocation calls.
Do not embed expected outputs; the verifier computes the expected result
from the original code at run time.
Capability contract
Expose the workflow as a single Modal remote function: define run_case as an @app.function so the harness can invoke it with run_case.remote(case).