Type/to search
3
Follow
1513
Followers
Résolvez le problème de précision de la commande en obtenant la profondeur
FAQ
Created 2020-03-20 09:10:52  Updated 2020-03-20 09:11:16
 2
 1869

En raison de l'inhomogénéité des échanges, FMZ n'a pas de fonction de retour de précision de commande uniforme. Si la stratégie est de ne faire qu'une seule monnaie, il est préférable d'utiliser la profondeur d'acquisition, qui permet de calculer automatiquement la précision de commande en fonction de l'information de profondeur.
La fonction est la suivante:

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
Comment
All comments (2)

    这个放在init里边跑一次还是不错的

    5 years ago

    时间复杂度噌噌噌往上跑

    6 years ago
  • 1
Forums
PINE Language
Get the app
iPhone Download
© 2015 - ∞ INVENTOR PTE LTD (SG)