The FMZ Quant Trading Platform has built-in integration with some common libraries.
The TA
indicator library of FMZ Quant Trading Platform has optimized the commonly-used indicator algorithms to support the call of strategies written in JavaScript
, Python
and C++
.
open source TA library code, API Manual of FMZ Quant Trading Platform.
function main(){
// The length of records, when the length does not meet the parameter calculation requirements of indicator function, an invalid value will be returned
var records = exchange.GetRecords()
var macd = TA.MACD(records)
var atr = TA.ATR(records, 14)
// Print out the last set of indicator values
Log(macd[0][records.length-1], macd[1][records.length-1], macd[2][records.length-1])
Log(atr[atr.length-1])
}
def main():
r = exchange.GetRecords()
macd = TA.MACD(r)
atr = TA.ATR(r, 14)
Log(macd[0][-1], macd[1][-1], macd[2][-1])
Log(atr[-1])
void main() {
auto r = exchange.GetRecords();
auto macd = TA.MACD(r);
auto atr = TA.ATR(r, 14);
Log(macd[0][macd[0].size() - 1], macd[1][macd[1].size() - 1], macd[2][macd[2].size() - 1]);
Log(atr[atr.size() - 1]);
}
The following is CCI
indicator call example code, more talib indicator functions can be found in the API Manual of FMZ Quant Trading Platform
function main() {
var records = exchange.GetRecords()
var cci = talib.CCI(records, 14)
Log(cci)
}
# Python requires a separate installation of the talib library
import talib
def main():
records = exchange.GetRecords()
# The parameter 14 can be defaulted
cci = talib.CCI(records.High, records.Low, records.Close, 14)
Log(cci)
void main() {
auto records = exchange.GetRecords();
auto cci = talib.CCI(records, 14);
Log(cci);
}
// Solve the problem of javascript language data calculation accuracy
function main() {
var x = -1.2
var a = Decimal.abs(x)
var b = new Decimal(x).abs()
Log(a.equals(b)) // true
var y = 2.2
var sum = Decimal.add(x, y)
Log(sum.equals(new Decimal(x).plus(y))) // true
}
function main() {
var sum = _.reduce([1, 2, 3], function(memo, num){return memo + num}, 0)
Log(sum)
}
function main(){
var records = exchange.GetRecords()
// Print all indicator data, and JavaScript written strategies have integrated a talib library on FMZ Quant Trading Platform
Log(talib.MACD(records))
Log(talib.MACD(records, 12, 26, 9))
}
function main() {
// via. https://cdnjs.com/libraries
eval(HttpQuery("https://cdnjs.cloudflare.com/ajax/libs/mathjs/13.2.0/math.min.js"))
Log(math.round(math.e, 3)) // 2.718
Log(math.atan2(3, -3) / math.pi) // 0.75
Log(math.log(10000, 10)) // 4
Log(math.sqrt(-4)) // {"mathjs":"Complex","re":0,"im":2}
}
void main() {
json table = R"({"type": "table", "title": "Position Information", "cols": ["Column1", "Column2"], "rows": [["abc", "def"], ["ABC", "support color #ff0000"]]})"_json;
LogStatus("`" + table.dump() + "`");
LogStatus("Fist line message\n`" + table.dump() + "`\nThird line message");
json arr = R"([])"_json;
arr.push_back(table);
arr.push_back(table);
LogStatus("`" + arr.dump() + "`");
table = R"({
"type" : "table",
"title" : "Position Operation",
"cols" : ["Column1", "Column2", "Action"],
"rows" : [
["abc", "def", {"type": "button", "cmd": "coverAll", "name": "close position"}]
]
})"_json;
LogStatus("`" + table.dump() + "`", "\n`" + R"({"type": "button", "cmd": "coverAll", "name": "close position"})"_json.dump() + "`");
}