币安Binance API Websocket
本文介绍币安Binance API Websocket
General WSS information
- The base endpoint is: wss://stream.binance.com:9443
- Streams can be access either in a single raw stream or a combined stream
- Raw streams are accessed at /ws/<streamName>
- Combined streams are accessed at /stream?streams=<streamName1>/<streamName2>/<streamName3>
- Combined stream events are wrapped as follows: {"stream":"<streamName>","data":<rawPayload>}
- All symbols for streams are lowercase
- A single connection to stream.binance.com is only valid for 24 hours; expect to be disconnected at the 24 hour mark
Detailed Stream information
Aggregate Trade Streams
The Aggregate Trade Streams push trade information that is aggregated for a single taker order.
Stream Name: <symbol>@aggTrade
Payload:
{ "e": "aggTrade", // Event type "E": 123456789, // Event time "s": "BNBBTC", // Symbol "a": 12345, // Aggregate trade ID "p": "0.001", // Price "q": "100", // Quantity "f": 100, // First trade ID "l": 105, // Last trade ID "T": 123456785, // Trade time "m": true, // Is the buyer the market maker? "M": true // Ignore }
Trade Streams
The Trade Streams push raw trade information; each trade has a unique buyer and seller.
Stream Name: <symbol>@trade
Payload:
{ "e": "trade", // Event type "E": 123456789, // Event time "s": "BNBBTC", // Symbol "t": 12345, // Trade ID "p": "0.001", // Price "q": "100", // Quantity "b": 88, // Buyer order ID "a": 50, // Seller order ID "T": 123456785, // Trade time "m": true, // Is the buyer the market maker? "M": true // Ignore }
Kline/Candlestick Streams
The Kline/Candlestick Stream push updates to the current klines/candlestick every second.
Kline/Candlestick chart intervals:
m -> minutes; h -> hours; d -> days; w -> weeks; M -> months
- 1m
- 3m
- 5m
- 15m
- 30m
- 1h
- 2h
- 4h
- 6h
- 8h
- 12h
- 1d
- 3d
- 1w
- 1M
Stream Name: <symbol>@kline_<interval>
Payload:
{ "e": "kline", // Event type "E": 123456789, // Event time "s": "BNBBTC", // Symbol "k": { "t": 123400000, // Kline start time "T": 123460000, // Kline close time "s": "BNBBTC", // Symbol "i": "1m", // Interval "f": 100, // First trade ID "L": 200, // Last trade ID "o": "0.0010", // Open price "c": "0.0020", // Close price "h": "0.0025", // High price "l": "0.0015", // Low price "v": "1000", // Base asset volume "n": 100, // Number of trades "x": false, // Is this kline closed? "q": "1.0000", // Quote asset volume "V": "500", // Taker buy base asset volume "Q": "0.500", // Taker buy quote asset volume "B": "123456" // Ignore } }
Individual Symbol Mini Ticker Stream
24hr Mini Ticker statistics for a single symbol pushed every second.
Stream Name: <symbol>@miniTicker
Payload:
{ "e": "24hrMiniTicker", // Event type "E": 123456789, // Event time "s": "BNBBTC", // Symbol "c": "0.0025", // Current day's close price "o": "0.0010", // Open price "h": "0.0025", // High price "l": "0.0010", // Low price "v": "10000", // Total traded base asset volume "q": "18" // Total traded quote asset volume }
All Market Mini Tickers Stream
24hr Mini Ticker statistics for all symbols that changed in an array pushed every second.
Stream Name: !miniTicker@arr
Payload:
[ { // Same as \<symbol\>@miniTicker payload } ]
Individual Symbol Ticker Streams
24hr Ticker statistics for a single symbol pushed every second.
Stream Name: <symbol>@ticker
Payload:
{ "e": "24hrTicker", // Event type "E": 123456789, // Event time "s": "BNBBTC", // Symbol "p": "0.0015", // Price change "P": "250.00", // Price change percent "w": "0.0018", // Weighted average price "x": "0.0009", // Previous day's close price "c": "0.0025", // Current day's close price "Q": "10", // Close trade's quantity "b": "0.0024", // Best bid price "B": "10", // Best bid quantity "a": "0.0026", // Best ask price "A": "100", // Best ask quantity "o": "0.0010", // Open price "h": "0.0025", // High price "l": "0.0010", // Low price "v": "10000", // Total traded base asset volume "q": "18", // Total traded quote asset volume "O": 0, // Statistics open time "C": 86400000, // Statistics close time "F": 0, // First trade ID "L": 18150, // Last trade Id "n": 18151 // Total number of trades }
All Market Tickers Stream
24hr Ticker statistics for all symbols that changed in an array pushed every second.
Stream Name: !ticker@arr
Payload:
[ { // Same as <symbol>@ticker payload } ]
Partial Book Depth Streams
Top <levels> bids and asks, pushed every second. Valid <levels> are 5, 10, or 20.
Stream Name: <symbol>@depth<levels>
Payload:
{ "lastUpdateId": 160, // Last update ID "bids": [ // Bids to be updated [ "0.0024", // Price level to be updated "10", // Quantity [] // Ignore ] ], "asks": [ // Asks to be updated [ "0.0026", // Price level to be updated "100", // Quantity [] // Ignore ] ] }
Diff. Depth Stream
Order book price and quantity depth updates used to locally manage an order book pushed every second.
Stream Name: <symbol>@depth
Payload:
{ "e": "depthUpdate", // Event type "E": 123456789, // Event time "s": "BNBBTC", // Symbol "U": 157, // First update ID in event "u": 160, // Final update ID in event "b": [ // Bids to be updated [ "0.0024", // Price level to be updated "10", [] // Ignore ] ], "a": [ // Asks to be updated [ "0.0026", // Price level to be updated "100", // Quantity [] // Ignore ] ] }
How to manage a local order book correctly
- Open a stream to wss://stream.binance.com:9443/ws/bnbbtc@depth
- Buffer the events you receive from the stream
- Get a depth snapshot from https://www.binance.com/api/v1/depth?symbol=BNBBTC&limit=1000
- Drop any event where
u
is <=lastUpdateId
in the snapshot - The first processed should have
U
<=lastUpdateId
+1 ANDu
>=lastUpdateId
+1 - While listening to the stream, each new event's
U
should be equal to the previous event'su
+1 - The data in each event is the absolute quantity for a price level
- If the quantity is 0, remove the price level
- Receiving an event that removes a price level that is not in your local order book can happen and is normal.
币安Binance API Websocket的更多相关文章
- 币安Binance API
本文介绍币安Binance API General API Information The base endpoint is: https://api.binance.com All endpoint ...
- 火币Huobi API Websocket
本文介绍火币Huobi API Websocket WebSocket API简介 WebSocket协议是基于TCP的一种新的网络协议.它实现了客户端与服务器之间在单个 tcp 连接上的全双工通信, ...
- OKEX API(Websocket)
本文介绍OKEX API Websocket WebSocket API for SPOT 开始使用 WebSocket是HTML5一种新的协议(Protocol).它实现了客户端与服务器全双工通信, ...
- ImCash:币安下架BSV之辩:规则、中立与去中心化
一种看法是:一个引用价格数据和执行交易的加密货币交易所,其业务决策往往是在链外发生的,不受制于严格的.类似于准宪法的链上规则的约束,加密货币交易所可以拒绝任何人喜欢的价格和交易,而且这样做并不会损害底 ...
- python安装包API文档
在python开发过程中,经常会使用第三方包,或者内置的包. 那么这些包,具体有哪些选项,有哪些方法,你知道吗?下面介绍一种万能方法. 使用命令:<注意,命令里python显示的API版本是根据 ...
- 在线聊天室的实现(1)--websocket协议和javascript版的api
前言: 大家刚学socket编程的时候, 往往以聊天室作为学习DEMO, 实现简单且上手容易. 该Demo被不同语言实现和演绎, 网上相关资料亦不胜枚举. 以至于很多技术书籍在讲解网络相关的编程时, ...
- 各大知名区块链交易所链接及API文档链接
区块链交易所链接 火币网(Huobi):https://www.huobi.br.com/zh-cn/ API文档:https://github.com/huobiapi/API_Docs/wiki ...
- webSocket详解
WebSocket 实战http://www.ibm.com/developerworks/cn/java/j-lo-WebSocket/index.html 转自IBMdeveloperWorks ...
- WebSocket 实战
http://www.ibm.com/developerworks/cn/java/j-lo-WebSocket/ 本文介绍了 HTML5 WebSocket 的由来,运作机制及客户端和服务端的 AP ...
随机推荐
- springJdbc in 查询,Spring namedParameterJdbcTemplate in查询
springJdbc in 查询,Spring namedParameterJdbcTemplate in查询, SpringJdbc命名参数in查询,namedParameterJdbcTempla ...
- 【AI】卷积
一 边界补充 1 补零填充 2 边界复制填充 3 镜像填充 4 块填充 二 卷积核 1 平滑均值滤波 2 高斯平滑 3 图像锐化 4 梯度Prewitt 5 Soble边缘检测:垂直梯度水平梯度 6 ...
- iOS开发-编译出错 duplicate symbols for architecture x86_64
今天对原来项目文件进行重新整理,根据文件内容进行分类,结果复制粘贴时没注意把一个文件复制了两遍 编译的时候就出现Duplicate Symbol Error 在网上搜素了一圈发现也有人遇到过这个问题, ...
- Nginx 访问日志
配置访问日志: [root@localhost ~]$ cat /usr/local/nginx/conf/nginx.conf http { log_format main '$remote_add ...
- [Ubuntu] 如何在 Lubuntu 安装 python-spidermonkey
SpiderMonkey 是由 Mozilla 开发的 Javascript 引擎,它由 C/C++ 编写而成.Mozilla 在其多个产品中使用了该引擎,包括 Firefox 浏览器. python ...
- Mac终端解压命令集合
tar 解包:tar xvf FileName.tar 打包:tar cvf FileName.tar DirName (注:tar是打包,不是压缩!) ——————————————— .gz 解压1 ...
- Github上star和fork比较高的vim配置方案
https://github.com/amix/vimrchttps://github.com/humiaozuzu/dot-vimrchttps://github.com/spf13/spf13-v ...
- 【规范】alibaba编码规范阅读
一.编程规范 (一)命名规范 1.代码中的命名均不能以下划线或美元符号开始,也不能以下划线或美元符号结束 2.代码中的命名严禁使用评语与英文混合的方式,更不允许直接使用中文的方式 3.类名使用Uppe ...
- 安装ORACLE_RAC遇到的问题与解决方法
while running: /u01/app/oracle/product/10.2.0/db_1/root.sh Checking to see if Oracle CRS stack is al ...
- UVA 1335 Beijing Guards(二分答案)
入口: https://cn.vjudge.net/problem/UVA-1335 [题意] 有n个人为成一个圈,其中第i个人想要r[i]种不同的礼物,相邻的两个人可以聊天,炫耀自己的礼物.如果两个 ...