Type/to search

干货-下单量精度和价格精度-适用各个交易所

Tool
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 amountPrecision
Comment
All comments (15)

    花了个多钟才搞出来,没想到上来一查,早就有现成的了.....

    4 years ago

    哈,多搜索下,挺多资源的

    4 years ago

    有JS版本的吗

    4 years ago

    有的,但是js的代码比较长,你加我,我私发给你

    4 years ago

    怎么用到策略里面呢

    4 years ago

    直接用函数就行了

    4 years ago

    谢谢

    4 years ago

    不错,从挂单量数据来得出小数位的方法,有没有直接用API取到最低价格,最高价格,步长数据后在实盘中对下单价格进行修正的示例?

    5 years ago

    最低价格和最高价格好像是有一个固定的百分比的,是现价的10%还是5%忘记了,步长数据是不是就是价格精度?

    5 years ago

    这个是交易所打新策略吗

    5 years ago

    不是呢,获取交易对的价格精度和下单量精度的函数,在开发策略中,经常用到的

    5 years ago

    有交易所打新策略吗

    5 years ago

    不好意思,没有呢。有现货策略和合约策略

    5 years ago

    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

    牛逼

    5 years ago
  • 1
iPhone Download
Forums
PINE Language
© 2015 - ∞ INVENTOR PTE LTD (SG)