2023-9-20交易日志报错排查分析
1、下单失败:
名词解释:
NOTIONAL 名义价值 来源:https://binance-docs.github.io/apidocs/spot/cn/#cc81fff589
名义价值过滤器(NOTIONAL)定义了订单在一个交易对上可以下单的名义价值区间.
applyMinToMarket 定义了 minNotional 是否适用于市价单(MARKET)
applyMaxToMarket 定义了 maxNotional 是否适用于市价单(MARKET).
要通过此过滤器, 订单的名义价值 (单价 x 数量, price * quantity) 需要满足如下条件:
price * quantity <= maxNotional
price * quantity >= minNotional
对于市价单(MARKET), 用于计算的价格采用的是在 avgPriceMins 定义的时间之内的平均价.
如果 avgPriceMins 为 0, 则采用最新的价格.
日志:
查找日志中关键字,并输出其前后10行内容:
cat log.log | grep -C 10 "ERROR"
2023-09-20 02:22:57.257[INFO ][Exchange]com.example.Market - 430分钟WMA加权移动平均线值0.061224
2023-09-20 02:22:57.991[INFO ][Exchange]com.example.OrderUtil - 账户余额: {"btcFree":1.0016E-4,"btcLocked":0,"ethFree":18.19893,"ethLocked":0}
2023-09-20 02:22:57.991[INFO ][Exchange]com.example.Trader - ======>豆畜子交易员开始操作...
2023-09-20 02:22:58.087[ERROR][Exchange]com.example.OrderUtil - 下单失败: {"code":-1013,"msg":"Filter failure: NOTIONAL"}
2023-09-20 02:22:58.087[INFO ][Exchange]com.example.Trader - ======>430分钟WMA:0.061224, 买入:0.0016 eth, 价格:0.06096600, 订单号:0
2023-09-20 02:22:59.488[INFO ][Exchange]com.example.OrderUtil - 账户余额: {"btcFree":1.0016E-4,"btcLocked":0,"ethFree":18.19893,"ethLocked":0}
2023-09-20 02:22:59.488[INFO ][Exchange]com.example.Trader - ======>当前资产, btc:[26200.56]1.0016E-4, eth:[1631.54]18.19893, 市值:29694.9065002896
======>430分钟WMA:0.059121, 买入:18.4829 eth, 价格:0.05851000, 订单号:538961
原因分析:
怀疑是精度问题,下单成功的订单价格是小数点后5尾数,报错"Filter failure: NOTIONAL"的是小数点后6位数精度的。
2、下单失败:
日志:
2023-09-20 03:00:55.235[INFO ][Exchange]com.example.Market - 430分钟WMA加权移动平均线值0.061610
2023-09-20 03:00:55.643[INFO ][Exchange]com.example.OrderUtil - 账户余额: {"btcFree":7.4E-7,"btcLocked":0,"ethFree":18.36322,"ethLocked":0}
2023-09-20 03:00:55.643[INFO ][Exchange]com.example.Trader - ======>豆畜子交易员开始操作...
2023-09-20 03:00:55.768[ERROR][Exchange]com.example.OrderUtil - 下单失败: {"code":-1013,"msg":"Invalid quantity."}
2023-09-20 03:00:55.768[INFO ][Exchange]com.example.Trader - ======>430分钟WMA:0.061610, 买入:0.0000 eth, 价格:0.06089800, 订单号:0
2023-09-20 03:00:56.622[INFO ][Exchange]com.example.OrderUtil - 账户余额: {"btcFree":7.4E-7,"btcLocked":0,"ethFree":18.36322,"ethLocked":0}
2023-09-20 03:00:56.622[INFO ][Exchange]com.example.Trader - ======>当前资产, btc:[26053.25]7.4E-7, eth:[1644.31]18.36322, 市值:30194.845557604996
原因分析:
下单的quantity为0, 设定的精度下四舍五入就是0了,换句话说剩余的btc太少、能买入的eth约等于0