IsVirtual
Used to determine whether the strategy's runtime environment is the backtesting system.
IsVirtual()Examples
Log a different message depending on whether it runs in backtest or live.
javascript
function main() {
if (IsVirtual()) {
Log("Running in backtest")
} else {
Log("Running in live trading")
}
// Output: "Running in backtest" in a backtest, "Running in live trading" in live trading
}
python
def main():
if IsVirtual():
Log("Running in backtest")
else:
Log("Running in live trading")
# Output: "Running in backtest" in a backtest, "Running in live trading" in live trading
rust
fn main() {
if IsVirtual() {
Log!("Running in backtest");
} else {
Log!("Running in live trading");
}
// Output: "Running in backtest" in a backtest, "Running in live trading" in live trading
}Returns
| Type | Description |
bool | When the strategy runs in the backtesting system environment, it returns a truthy value, for example: |
See Also
Remarks
Used to determine whether the current runtime environment is the backtesting system, in order to accommodate the differences between the backtesting and live trading environments.