Type/to search
Built-in Functions
Global
Version
IsVirtual
GetOS
GetPid
GetMeta
Sleep
Unix
UnixNano
_D
GetCommand
GetLastError
SetErrorFilter
_N
_C
_Cross
JSON.parse
JSON.stringify
Encode
MD5
UUID
Log
Market
Trade
Account
Futures
Exchange
IO
Network
Storage
Threads
TA
Talib
OS
Structures
Built-in Variables and Constants
Conventions
Exchanges

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

TypeDescription

bool

When the strategy runs in the backtesting system environment, it returns a truthy value, for example: true; when the strategy runs in the live trading environment, it returns a falsy value, for example: false.

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.