Welcome to FMZ Quant Trading Platform
Programming Languages
Key Security
Live Trading
Strategy Library
Docker
Exchange
Strategy Editor
Backtesting System
Backtesting System Modes
Impact of Backtest Data Granularity on Backtesting
Backtesting System Supports Multiple Programming Languages
Exchanges Supported by Backtesting System
Backtest System Parameter Optimization
Save Backtest Settings
Custom Data Source
Local Backtesting Engine
Backtest Page Shortcuts
Backtest Data Download
Backtest System Sharpe Ratio Algorithm
Strategy Entry Functions
Strategy Framework and API Functions
Template Library
Strategy Parameters
Interactive Controls
Options Trading
C++ Strategy Writing Guide
JavaScript Strategy Writing Guide
Web3
Built-in Libraries
Extended API Interface
MCP Service
Trading Terminal
Data Explorer
Alpha Factor Analysis Tool
General Protocol
Debugging Tool
Remote Editing
Import and Export of Complete Strategies
Multi-language Support
Live Trading and Strategy Grouping
Live Trading Display
Strategy Sharing and Renting
Live Trading Message Push
Common Causes of Live Trading Errors and Abnormal Exits
Exchange-Specific Notes
Impact of Backtest Data Granularity on Backtesting
The following test code will exhibit different performance for different data granularities (A. Live trading level backtest, B. Simulation level backtest (smaller underlying K-line period), C. Simulation level backtest (larger underlying K-line period), etc.). Both the number of trades and profit/loss results will vary. When backtesting, the smallest possible data granularity should be maintained. While backtesting may be faster with larger data granularity, the results obtained may lack objectivity.
javascript
/*backtest
start: 2025-04-01 08:00:00
end: 2025-04-18 00:00:00
period: 1m
exchanges: [{"eid":"Binance","currency":"BTC_USDT","balance":1000000}]
mode: 1
*/
var delta = 50
var lotSize = 0.001
var lastPrice = null
var direction = null
function main() {
while (true) {
var ticker = _C(exchange.GetTicker)
if (!lastPrice) {
lastPrice = ticker.Last
}
var diff = ticker.Last - lastPrice
if ((!direction || direction == "long") && diff >= delta) {
// Price rises above threshold -> Go short
exchange.Sell(ticker.Last, lotSize)
Log("Short @", ticker.Last)
direction = "short"
} else if ((!direction || direction == "short") && diff <= -delta) {
// Price falls below threshold -> Go long
exchange.Buy(ticker.Last, lotSize)
Log("Long @", ticker.Last)
direction = "long"
}
// Should be as short as possible in Tick mode, no impact in K-line backtest
Sleep(100)
}
}