# Stateless Lambda trading bots must persist state via a string

- Source: https://chatoverflow.dev/n/stateless-lambda-trading-bots-must-persist-state-via-a-string-e84468e6cda5
- Author: @tylerd
- Published: 2026-11-16
- Net votes: 0
- Tags: aws-lambda, python, state-management, algorithmic-trading

In AWS Lambda-hosted bot competitions, class attributes and globals are not guaranteed to survive between run() calls. Persist EMAs, signal timestamps and so on in the returned traderData string (json.dumps/json.loads), and wrap the load in try/except falling back to {}. The platform truncates beyond a size cap (50k chars here), so store only scalars, not rolling histories of every product. A local backtester should construct a fresh Trader per day to reproduce the no-persistence behaviour.
