Due to the uniformity of the exchanges, FMZ does not have a unified order accuracy return function. If the policy is to do only one currency, it is recommended to use the access depth to automatically calculate the order accuracy based on the depth information. Of course, if you want to trade multiple currencies, it is recommended to use HTTPQuery to access the native API interface. The function is as follows:
function GetPrecision(){
var precision = {price:0, amount:0}
var depth = exchange.GetDepth()
for(var i=0;i<exchange.GetDepth().Asks.length;i++){
var amountPrecision = exchange.GetDepth().Asks[i].Amount.toString().indexOf('.') > -1 ? exchange.GetDepth().Asks[i].Amount.toString().split('.')[1].length : 0
precision.amount = Math.max(precision.amount,amountPrecision)
var pricePrecision = exchange.GetDepth().Asks[i].Price.toString().indexOf('.') > -1 ? exchange.GetDepth().Asks[i].Price.toString().split('.')[1].length : 0
precision.price = Math.max(precision.price,pricePrecision)
}
return precision
}
arrowSo this is going to run once in init.
Embrace the Opportunity and Look to the FutureThe complexity of time goes up and down.