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

工具
创建日期: 2021-07-02 19:24:39 最后修改: 2021-09-25 10:25:30
复制: 33 点击次数: 2867
avatar of 陈皮 陈皮
3
关注
53
关注者
策略源码
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

def GetPricePrecision():
    depth = _C(exchange.GetDepth)    
    pricePrecisions = []
    for ask in depth["Asks"]:
        j = ask["Price"]
        pricePrecision = 0
        if str(j).count('.') == 1:
            pricePrecision = len(str(j).split(".")[1])
        pricePrecisions.append(pricePrecision)
    pricePrecision = Counter(pricePrecisions).most_common(1)[0][0]
    return pricePrecision
相关推荐
全部留言
avatar of czruiq
czruiq
花了个多钟才搞出来,没想到上来一查,早就有现成的了.....
2022-07-04 18:30:10
avatar of 陈皮
陈皮
哈,多搜索下,挺多资源的
2022-07-04 19:52:56
avatar of 77924998
77924998
有JS版本的吗
2022-02-12 01:51:42
avatar of 陈皮
陈皮
有的,但是js的代码比较长,你加我,我私发给你
2022-02-12 10:57:13
avatar of 77924998
77924998
怎么用到策略里面呢
2022-01-07 22:38:15
avatar of 77924998
77924998
谢谢
2022-02-12 01:51:56
avatar of 陈皮
陈皮
直接用函数就行了
2022-01-15 00:52:02
avatar of lcgs005
lcgs005
不错,从挂单量数据来得出小数位的方法,有没有直接用API取到最低价格,最高价格,步长数据后在实盘中对下单价格进行修正的示例?
2021-10-31 01:01:27
avatar of 陈皮
陈皮
最低价格和最高价格好像是有一个固定的百分比的,是现价的10%还是5%忘记了,步长数据是不是就是价格精度?
2021-10-31 22:41:17
avatar of gg50933064
gg50933064
这个是交易所打新策略吗
2021-10-07 22:10:50
avatar of 陈皮
陈皮
不好意思,没有呢。有现货策略和合约策略
2021-10-07 22:40:22
avatar of gg50933064
gg50933064
有交易所打新策略吗
2021-10-07 22:38:22
avatar of 陈皮
陈皮
不是呢,获取交易对的价格精度和下单量精度的函数,在开发策略中,经常用到的
2021-10-07 22:12:53
avatar of btcrobot
btcrobot
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 }
2021-07-06 23:30:54
avatar of 韬奋量化
韬奋量化
牛逼
2021-07-28 14:21:35