C++
written strategy and JavaScript
written strategy is the returned data differences of FMZ Quant Trading Platform API function, such as the exchange.GetTicker()
function:JavaScript
exchange.GetTicker()
returns an object if the call succeeds, or returns null
if the call fails (due to the exchange server problems or network problems, etc.).
function main() {
var ticker = exchange.GetTicker()
// Determine if the call to "exchange.GetTicker" function failed, and return "null" when it failed
if (ticker){
Log(ticker)
}
}
C++
exchange.GetTicker()
returns an object when the call succeeds. If the call fails, the returned object is still an object, which is distinguished from the normal returned object by the attribute Valid
.
void main() {
auto ticker = exchange.GetTicker();
// Determine if the call to "exchange.GetTicker()" function failed and if the "Valid" attribute of the returned object is "false"
if (ticker.Valid) {
Log(ticker);
}
}
main()
function in the C++
written strategy and the main()
function in the standard C11:
The return value of the C++
program’s entry function main()
in C11 is of int
type. In the C++
written strategy on FMZ platform, the startup function of the strategy is also the function main()
.
But these two are not the same function, just with the same name. On FMZ platform, the return value of the main()
function in the C++
strategy is of void
type.void main() {
// Use "Test" function to test
if (!Test("c++")) {
// Show an exception to stop the program
Panic("Please download the latest-versioned docker");
}
// Determine if the return of all objects is valid with "Valid"
LogProfitReset();
LogReset();
Log(_N(9.12345, 2));
Log("use _C", _C(exchange.GetTicker), _C(exchange.GetAccount));
}
Options Trading
JavaScript Strategy Writing Instructions