Skip to Content
精通区块链
book

精通区块链

by Lorne Lantz, Daniel Cawrey
March 2022
Intermediate to advanced
293 pages
5h 31m
Chinese
China Electric Power Press Ltd.
Content preview from 精通区块链
市场基础设施 171
6.7.3 REST
WebSocket
速度是构建高质量交易机器人的重要因素,这样机器人才能在别人之前读懂
市场并执行交易。在使用
REST API
时,交易机器人必须不断地轮询
API
查看市场的最新状态,这往往会导致市场发生变化和交易机器人看到该变化
之间的时间间隔。当交易机器人受到速率限制而必须等待一瞬间才能发出有
效的请求时,这些间隔会大大增加。
交易机器人查看当前市场状态的更快方法是订阅
WebSocket
。通过这种设置,
一旦市场发生变化,交易所的服务器就会向
WebSocket
的所有订阅者推送通
知。然后,所有订阅
WebSocket
的交易机器人将在同一时间收到相同的信息,
不需要发送额外
API
请求。
对交易者来说,找出交易所托管其
API
服务器的确切位置,并将他们的交易
机器人托管在同一地点,可能会有帮助。例如,如果交易所的
API
服务器托
管在北弗吉尼亚地区的
AWS
上,交易者可以在同一地区的
AWS
上托管他
们的机器人,以确保更快的通信。
6.7.4
在沙盒中进行测试
当开发者在测试交易机器人的各种功能时,理想情况下应该使用假钱在沙盒
sandbox
)环境中进行测试。如果交易所的
API
没有沙盒环境,开发者就不
得不使用真钱来测试出功能,这往往限制了交易机器人的测试能力。使用真
钱测试新功能通常风险太大,很容易因为
bug
而损失。
6.7.5
市场汇总器
有一些服务(如
CoinMarketCap
CoinGecko
)从数百家交易所汇总市场价格,
并将这些数据打包到
API
中。这种
API
的优点是可以让交易机器人很容易地 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

人工智能技术与大数据

人工智能技术与大数据

Posts & Telecom Press, Anand Deshpande, Manish Kumar
Python和NLTK实现自然语言处理

Python和NLTK实现自然语言处理

Posts & Telecom Press, Nitin Hardeniya
Python机器学习案例精解

Python机器学习案例精解

Posts & Telecom Press, Yuxi (Hayden) Liu
编写整洁的Python代码(第2版)

编写整洁的Python代码(第2版)

Posts & Telecom Press, Mariano Anaya

Publisher Resources

ISBN: 9787519863166