这些API基本就是go through一遍,然后开始写。
Books章节的说法使用所有的ws接口,发request先收到response,再收到snapshot作为过去的总结,然后是update。trades和book的snapshot与book不一样,可能是snapshot里包含了过去的多个update.
After receiving the response, you will receive a snapshot of the book,
followed by updates upon any changes to the book.
ticker
https://bitfinex.readme.io/v2/reference#ws-public-ticker
相当于SymbolContext;
包括bid/ask, last trade price, daily volume, price move from last day
从这里就可以看到snapshot和update几乎完全相同;
const ws = require('ws') 获取类
const w = new ws('wss://api.bitfinex.com/ws/2') new obj
w.on('message', (msg) => console.log(msg)) 输出msg
let msg = JSON.stringify({ 发request
event: 'subscribe',
channel: 'ticker',
symbol: 'tBTCUSD'
})
w.on('open', () => w.send(msg)) 什么open?
request/response
// request这个和上面的JSON.stringify一模一样
Snapshot/Update
BID, Price of last highest bid,和Book差不多
DAILY_CHANGE, 以昨天的收盘价为基准,到目前的px change.
DAILY_CHANGE_PERC, px change 百分比
// Trading pairs trading和funding有什么区别?funding多了以下内容,难道是做融资?
FRR, Flash Return Rate - average of all fixed rate funding over the last hour,不明白
BID_PERIOD, Bid period covered in days,不是很明白
trades https://bitfinex.readme.io/v2/reference#ws-public-trades
sends a trade msg whenever a trade occurs at Bitfinex, includes all pertinent details. 既然是public,应该是别人trade,我这里收到。
应该是aggressive side决定整个trade是buy/sell
// response Funding 整体上感觉不是很规范,但也能用
Snapshot中的省略号应该是多个list并列?
// on funding currencies (ex. fUSD),应该是融资无疑了
RATE, Rate at which funding transaction occurred借贷利率
PERIOD Amount of time the funding transaction was for 相当于借贷从发起到成交的时间?
Books https://bitfinex.readme.io/v2/reference#ws-public-order-books
order book, price aggregated basis, customizable precision,
ticker只有bid/ask;book才具有深度信息;Snapshot/Update区别仅在于是否是一串信息;相较于以前,加了prec, freq, len等信息
Frequency of updates (F0, F1).
F0=realtime / F1=2sec. 既然是string格式,应该就是F0/F1
Number of price points ("25", "100") [default="25"] 这是啥?
Stream Fields
Rate level 应该是借贷了
Period level 借贷时间长
count与amount有什么区别?一个是at price level,一个是aviable at price level,所以amount具有累加效应?比如我发一个buy@10时候可能有1000,buy@9就只有300了?
Raw Books https://bitfinex.readme.io/v2/reference#ws-public-raw-order-books
可以用来构造自己的book,相当于具体到每个order的price/amount?
PRICE = 0 means that you have to remove the order from your book.
Trading: if AMOUNT > 0 then bid else ask; Funding: if AMOUNT < 0 then bid else ask;
相较于book,Request prec="R0"确定,Request/Response都没有frequency。
可以认为,update的frequency会非常高,来适应order的速度;每个order update都会有一个feed?
Candles https://bitfinex.readme.io/v2/reference#ws-public-candle
蜡烛图。。。应该是为了方便前端展示了
key: "trade:1m:tBTCUSD"
key这里同时给出了symbol和timeframe表示刷新频率