Skip to content

Commit 31d9ab8

Browse files
committed
fixed avg price formula
1 parent 728090d commit 31d9ab8

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ By end of Q1 2020, the following endpoints will be removed from the API. The doc
337337
* `intervalNum` added to /api/v1/exchangeInfo limits. `intervalNum` describes the amount of the interval. For example: `intervalNum` 5, with `interval` minute, means "every 5 minutes".
338338

339339
#### Explanation for the average price calculation:
340-
1. (qty * price) of all trades / numTrades of the trades over previous 5 minutes.
340+
1. (qty * price) of all trades / sum of qty of all trades over previous 5 minutes.
341341

342342
2. If there is no trade in the last 5 minutes, it takes the first trade that happened outside of the 5min window.
343343
For example if the last trade was 20 minutes ago, that trade's price is the 5 min average.

CHANGELOG_CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ WEB SOCKET 连接限制
100100
* /api/v1/exchangeInfo 中的限制增加了`intervalNum`. `intervalNum`表示该限制针对多少时间间隔进行统计. 例如: `intervalNum`= 5, `interval` = minute, 表示该限制对每5分钟内的行为进行统计。
101101

102102
#### 如何计算过去n分钟平均价格:
103-
1. [对过去n分钟所有订单的数量\*价格求和] / 过去n分钟订单数
103+
1. [对过去n分钟所有订单的数量\*价格求和] / 过去n分钟所有订单的数量
104104
2. 如果过去n分钟没有交易发生,则继续向前追溯,直到找到第一个交易,以此价格作为过去n分钟平均价格。
105105
3. 如果该交易对之前从未发生过交易,则无平均价格,亦即无法在该交易对下市价单,必须至少有一个(双方均未限价单)的交易成交后才可以下市价单。
106106
4. 当前系统使用的平均价格可以通过接口 `https://api.binance.com/api/v3/avgPrice?symbol=<symbol>`查询

0 commit comments

Comments
 (0)