Using JavaScript Eval for Live Strategy Debugging
Summary
This tutorial shows how to use a strategy interface to modify and inspect a running JavaScript trading program. The strategy polls an API for a command, extracts the text after a delimiter, logs the submitted expression, and passes it to JavaScript’s eval function. A try-catch block logs errors so malformed input does not go unreported.
The example initializes two global variables, repeatedly checks for interface commands, and pauses between checks. The tutorial says the method can be used to change those variables while the strategy is running, and describes an interface configured with controls for sending commands. It illustrates an operational debugging technique rather than a trading signal or market-tested strategy. The document offers no safeguards for evaluating arbitrary code, no discussion of command validation, and no evidence about reliability or suitability in live trading; its example is limited to basic variable updates and error logging.
Key ideas
- A running strategy can poll an interface API for user commands.
- The example extracts submitted JavaScript and evaluates it at runtime.
- Logging and exception handling make submitted commands and errors visible.
- The demonstration updates global variables in a loop with a pause between checks.
- The tutorial does not discuss validation or security controls for evaluated input.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.