3
Follow
61
Followers
Source
Python
from collections import Counter
def GetAmountPrecision():
depth = _C(exchange.GetDepth)
amountPrecisions = []
for ask in depth["Asks"]:
i = ask["Amount"]
amountPrecision = 0
if str(i).count('.') == 1:
amountPrecision = len(str(i).split(".")[1])
amountPrecisions.append(amountPrecision)
amountPrecision = max(amountPrecisions)
return amountPrecisionRelated strategies
Comment
All comments (15)
function GetPrecision(){
if(IsVirtual()){
return {price:6, amount:6}
}
var precision = {price:0, amount:0}
var depth = exchange.GetDepth()
if(!depth){
throw '无法连接交易所行情,需要海外托管者'
}
for(var i=0;i<depth.Asks.length;i++){
var amountPrecision = depth.Asks[i].Amount.toString().indexOf('.') > -1 ? depth.Asks[i].Amount.toString().split('.')[1].length : 0
precision.amount = Math.max(precision.amount,amountPrecision)
var pricePrecision = depth.Asks[i].Price.toString().indexOf('.') > -1 ? depth.Asks[i].Price.toString().split('.')[1].length : 0
precision.price = Math.max(precision.price,pricePrecision)
}
return precision
}
5 years ago
- 1


