Supported Languages and Exchanges
Which programming languages and exchanges the backtest system supports, and where strategies in each language are backtested.
Programming languages
The backtesting system supports strategies written in JavaScript, Python, Rust, PINE, MyLanguage and Workflow.
- JavaScript strategies are backtested in the browser, where the backtest engine runs as WebAssembly; nothing needs to be installed. JavaScript strategies can be debugged with Chrome DevTools during a backtest, see this guide.
- Rust strategies are compiled by the platform's servers; third-party crates declared in the strategy's frontmatter are fetched at compile time, so no local toolchain is needed. The backtest node defaults to "Cloud" (runs on the platform's servers); you can also choose "Local", which runs in the browser.
- For Python strategies the backtest node defaults to "Cloud" (the platform's public servers); you can also choose your own docker, or "Local: Python3" to backtest in the browser (run with Pyodide). A backtest on a docker, like live trading, uses the Python 3 environment of the docker's system; install the third-party libraries you need yourself. The public servers only provide common libraries.
- Workflow strategies show each node's execution state and data flow visually during a backtest.
Exchanges
Backtests use the platform's historical data; the exchanges selectable on the backtest page are the ones that can be backtested (the MCP tool list_exchanges also shows this: exchanges with backtest set to true have history data).
-
Cryptocurrency: spot and futures of major exchanges, e.g.
BinanceandFutures_Binance,OKXandFutures_OKX,HTXandFutures_HTX,BybitandFutures_Bybit,BitgetandFutures_Bitget,GateIOandFutures_GateIO, with all symbols of the exchange.These are the exchange IDs used for backtesting (the
eidin the/*backtest*/configuration and in the MCP toolrun_backtest, matching the names of the history data server). For most exchanges they equal whatexchange.GetName()returns in live trading, but a few differ: backtestOKXandFutures_OKXcorrespond to liveOKEXandFutures_OKCoin(OKX futures); backtestHTXandFutures_HTXcorrespond to liveHuobiandFutures_HuobiDM(HTX futures). If a strategy branches on the exchange name, handle both spellings. -
Futu Securities (
Futures_Futu): Hong Kong, US and other stock markets. Only daily data is available for backtesting; setcurrencytoSTOCKand select the stock code in the strategy withexchange.SetContractType():
javascript
/*backtest
start: 2024-05-01 00:00:00
end: 2025-02-17 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Futu","currency":"STOCK","fee":[0.03,0.03]}]
*/
function main() {
// Set the stock code: Tesla
var info = exchange.SetContractType("TSLA.US")
// Contract info: InstrumentID, PriceTick, LotTick, VolumeMultiple, ...
Log("info:", info)
// Daily market data at the current backtest time
Log(exchange.GetTicker())
}