cap_cpu
What happened
A script runs with a limit on the CPU time it may use. When it goes over, the sandbox stops it and answers with this code. detail names the cap that tripped (cpu_ms), how much the script used and how much was allowed. The caps differ for a chart and for a run, and the code sandbox section of the Limits page lists them.
What to do
Do less work per call: compute over fewer bars, and avoid Python loops over every bar where a built-in indicator or a series operation does the same job.
Example
json
{
"request_id": "7d2b1c44-95a0-4e3b-8a6f-1c0d9e2f5a37",
"ok": false,
"error": {
"code": "cap_cpu",
"message": "The script used more CPU time than allowed.",
"detail": {
"cap": "cpu_ms",
"used": 2310,
"allowed": 2000
}
}
}