3
Follow
1513
Followers
Giải quyết vấn đề độ chính xác của thứ tự bằng cách lấy độ sâu
Created 2020-03-20 09:10:52 Updated 2020-03-20 09:11:16
2
1869
Do các sàn giao dịch không thống nhất, FMZ không có chức năng trả về độ chính xác đơn đặt hàng thống nhất. Nếu chiến lược chỉ làm một đồng tiền thì tốt hơn, nếu tương thích với nhiều cặp giao dịch thì tương thích với nhiều sàn giao dịch, ở đây nên sử dụng độ sâu lấy, tự động tính toán độ chính xác đơn đặt hàng dựa trên thông tin độ sâu. Tất nhiên, nếu giao dịch nhiều đồng tiền, cũng nên sử dụng HttpQuery để truy cập giao diện API gốc.
Hàm như sau:
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
