3
Follow
1513
Followers
Resolva o problema de precisão da ordem obtendo a profundidade
Created 2020-03-20 09:10:52 Updated 2020-03-20 09:11:16
2
1869
Devido à falta de uniformidade entre as plataformas, a FMZ não tem uma função de precisão de retorno de pedidos uniforme. Se a estratégia for apenas uma moeda, é bom, se for compatível com vários pares de negociação, também compatível com várias plataformas, é recomendável usar a profundidade de aquisição, com base na informação de profundidade para calcular automaticamente a precisão de pedidos.
A função é a seguinte:
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
}
Related Recommendations
Advanced Tutorial for FMZ Quant platform Strategy WritingElementary Tutorial for FMZ Quant platform Strategy WritingGet Started with FMZ Quant PlatformSECURITY BUGI keep getting error: Exchange_GetAccount: Invalid ContractTypeWe have an incredibly profitable market making algorithm for sideways markets on Bitmex - but need expert to help eliminate wait times during downward volatility in the marketError with deribitLimitations of the backtesting engineHow to install ta-lib on linux docker?5.5 Trading strategy optimization
