资源加载中... loading...

JavaScript Library

  • http://mikemcl.github.io/decimal.js/
    // 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    
    }
    
  • http://underscorejs.org/
    function main() {
        var sum = _.reduce([1, 2, 3], function(memo, num){return memo + num}, 0)
        Log(sum)
    }
    
  • http://ta-lib.org/
    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))
    }
    
  • Loading JavaScript libraries dynamically If you need to use other third-party JavaScript libraries, you can use the following method to load them dynamically:
    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}
    } 
    
talib Indicator Library C++ Library