所有的historical orders/offers/credits/loans应该是历史上曾经用过的API,现在官方给出了更新的版本。
positions, wallets, margin info, funding info中有些fields需要临时计算,如果new calculated value not yet available, 返回null, 在发这种request之前,需要先发送一个calc input request. 见 https://docs.bitfinex.com/v2/docs/changelog#section--calc-input-message
Authenticated Channels https://bitfinex.readme.io/v2/docs/ws-auth
request parameter, event="auth"
apiKey/apiSecret 应该就是那些read/write的key/secret
const authSig = crypto 应该是基于payload, apiSecret和加密算法一起算出
.HmacSHA384(authPayload, apiSecret)
.toString(crypto.enc.Hex)
authNonce=Date.now() * 1000
authPayload= 'AUTH' + authNonce
request, authSig: signature, 包括了apiSecret
response,
chanId: 0, 通常account info channel ID=0
caps: '{"orders": {"read": "1", "write": "0"}, "account": {"read": "1", "write": "0"}, "funding": {"read": "1", "write": "1"}, "history": {"read": "1", "write": "0"}, "wallets": {"read": "1", "write": "1"}, "withdraw": {"read": "0", "write": "1"}, "positions": {"read": "1", "write": "1"}}' } 这个说的是权限?
Channel filters https://bitfinex.readme.io/v2/docs/ws-auth#section-channel-filters
过滤某些channel,应该不需要,在RTMD那里过滤好了
filter参数是不需要的还是需要的?
Trades https://bitfinex.readme.io/v2/reference#ws-auth-trades
收到te trade executed之后,会再收到一个tu trade execution updated包含real trade id(TRD_ID)和相应的fields.
Trades应该是triggered by client,所以没有snapshot/update,因为不会一直trade...
应该是由trades返回orders
ORDER_TYPE应该就是Orders https://bitfinex.readme.io/v2/reference#ws-auth-orders 里面的type
Orders https://bitfinex.readme.io/v2/reference#ws-auth-orders
new/replace/cancel.
GID/CID分别是什么?ORDER_STATUS中的EXECUTED应该是fully filled. OCO应该是order cancel other,即有一种order类型是一次发两个,成交任意一个就会cancel另外一个。PLACED_ID应该是如果order1被order2取消,则被设置为order2的ID.
flag Hidden是类似于dark pool吗?Close时取消这个order? Post Only时只与后来的orders cross?
Update里面的NOTIFY/HIDDEN在historical orders里面讲;
Positions https://bitfinex.readme.io/v2/reference#ws-auth-position
orders表示一个具体的order,positions则表示持仓
MARGIN_FUNDING_TYPE term是什么意思呢?
PRICE_LIQ float Liquidation price 这是什么?当前价格?
Snapshot::FLAG 这是flag还是flags?都要实验代码看一下!Update里并没有这个内容
Funding Offers https://bitfinex.readme.io/v2/reference#ws-auth-offers
借款或提供融资。
RATE_REAL |
float |
the calculated rate for FRR and FRRDELTAFIX |
FRR和FRRDELTAFIX分别是什么意思?
Funding Credits https://bitfinex.readme.io/v2/reference#ws-auth-credits
融资额度,Funds used in active positions在持仓中用到的融资额度,比funding offers多了以下fields
MTS_OPENING
MTS_LAST_PAYOUT
NO_CLOSE,应该就是如果清仓是否还钱
POSITION_PAIR,这笔融资用在了哪个标的上
Funding Loans https://bitfinex.readme.io/v2/reference#ws-auth-loans
Funds not used in active positions 借了钱,但是没有用。比funding credit在snapshot/update stream fields里面少了
POSITION_PAIR 这一项。
理论上,funding offers=funding credits + funding loans ?
Wallets https://bitfinex.readme.io/v2/reference#ws-auth-wallets
WALLET_TYPE wallet name, exchange是什么?margin是利润还是保证金?funding应该是融资余额,可以是借出,也可以是借入?
BALANCE_AVAILABLE, amount not tied up in active orderes, positions or funding(null if the value is not fresh enough) 能用的资金,应该是除去已发送但还没有成交order的占资,持仓,融资外的所有余额
Balance Info https://bitfinex.readme.io/v2/reference#ws-auth-balance
total assets和net assets,应该是包括所有的可用资金,持仓,资金占用,利润和unsettled interest。
Margin Info https://bitfinex.readme.io/v2/reference#ws-auth-margin
保证金账户
USER_SWAPS 还有swaps?
TRADABLE_BALANCE, your buying power(how large a position you can obtain) 和wallets::balance_available有什么区别?这里限定为融资账户?
MARGIN_BALANCE 保证金融资账户的余额;MARGIN_NET 除去P&L之后的余额
Update里面,miu=margin information udpate,base calc, symbol calc分别是什么?GROSS_BALANCE与TRADEABLE_BALANCE对应?
Funding Info
https://bitfinex.readme.io/v2/reference#ws-auth-funding
Funding Info https://bitfinex.readme.io/v2/reference#ws-auth-funding
账户的融资信息,
yield_loan/lend应该是平均利率;duration_loan/lend平均久期。
Funding Trades https://bitfinex.readme.io/v2/reference#ws-auth-funding-trades
Stream fileds里面说是SYMBOL,Update里面说是currency,因为这里是表示法币,所以相同。
RATE/PERIOD应该是久期。
MAKER Whether the offer took liquidity off the funding book;maker/taker?
Notifications https://bitfinex.readme.io/v2/reference#ws-auth-notifications
MTS只表示update,没有create;
TYPE有on-req new order request, oc-req order cancel request
uca ,
fon-req, new funding order request
foc-req, cancel funding order request
可能以后使用CODE而不是STATUS.
uca/price里面的direction是什么?trading order >0, buy, < 0 sell; funding offer, >0 sell, < 0 buy
A custom notification will be broadcasted to every channel that the user is subscribed to.
New Order https://bitfinex.readme.io/v2/reference#ws-input-order-new
新order, You will receive a message of the appropriated type on the "account info" channel
cid int45 Must be unique in the day (UTC)
这个应该是client发的clOrdID,保证unique in the whole day.
price_oco_stop 另外一个order的stop price
下面的Close flag类似于cancel order?呃。。。并不是
Cancel order https://bitfinex.readme.io/v2/reference#ws-input-order-cancel
收到oc表示ACK order status change;也会受到一个notification表示使用oc-req进行cancel.
Internal Order ID/ Client Order ID,
Cancel multi order https://bitfinex.readme.io/v2/reference#ws-input-order-cancel-multi
使用oc_multi;可以使用ID/ClOrdID+ID Date/GID+ID_MAX的组合
但是这个list的组织方式实在是清奇
Order Multi-OP https://bitfinex.readme.io/v2/reference#ws-input-order-multi-op
看例子吧。。。
Calc https://bitfinex.readme.io/v2/reference#ws-input-calc
客户需要时候才会计算
• margin_sym_SYMBOL,如margin_sym_tBTCUSD
• funding_sym_SYMBOL
• position_SYMBOL,如position_tBTCUSD
• wallet_WALLET-TYPE_CURRENCY,如wallet_margin_BTC/wallet_funding_USD
发送过去一个list,但是一次最多30个;