@@ -67,6 +67,38 @@ def _parse_trade(tData, symbol):
6767 }
6868
6969
70+ def _parse_user_trade (tData ):
71+ return {
72+ 'id' : tData [0 ],
73+ 'symbol' : tData [1 ],
74+ 'mts_create' : tData [2 ],
75+ 'order_id' : tData [3 ],
76+ 'exec_amount' : tData [4 ],
77+ 'exec_price' : tData [5 ],
78+ 'order_type' : tData [6 ],
79+ 'order_price' : tData [7 ],
80+ 'maker' : tData [8 ],
81+ 'cid' : tData [11 ],
82+ }
83+
84+
85+ def _parse_user_trade_update (tData ):
86+ return {
87+ 'id' : tData [0 ],
88+ 'symbol' : tData [1 ],
89+ 'mts_create' : tData [2 ],
90+ 'order_id' : tData [3 ],
91+ 'exec_amount' : tData [4 ],
92+ 'exec_price' : tData [5 ],
93+ 'order_type' : tData [6 ],
94+ 'order_price' : tData [7 ],
95+ 'maker' : tData [8 ],
96+ 'fee' : tData [9 ],
97+ 'fee_currency' : tData [10 ],
98+ 'cid' : tData [11 ],
99+ }
100+
101+
70102def _parse_deriv_status_update (sData , symbol ):
71103 return {
72104 'symbol' : symbol ,
@@ -141,6 +173,7 @@ class BfxWebsocket(GenericWebsocket):
141173 - `funding_credit_snapshot` (array): Opening funding credit balances
142174 - `balance_update` (array): When the state of a balance is changed
143175 - `new_trade` (array): A new trade on the market has been executed
176+ - `new_user_trade` (array): A new - your - trade has been executed
144177 - `new_ticker` (Ticker|FundingTicker): A new ticker update has been published
145178 - `new_funding_ticker` (FundingTicker): A new funding ticker update has been published
146179 - `new_trading_ticker` (Ticker): A new trading ticker update has been published
@@ -284,6 +317,11 @@ async def _trade_update_handler(self, data):
284317 symbol = self .subscriptionManager .get (data [0 ]).symbol
285318 tradeObj = _parse_trade (tData , symbol )
286319 self ._emit ('trade_update' , tradeObj )
320+ else :
321+ # user trade
322+ # [0,"tu",[738045455,"tTESTBTC:TESTUSD",1622169615771,66635385225,0.001,38175,"EXCHANGE LIMIT",39000,-1,-0.000002,"TESTBTC",1622169615685]]
323+ tradeObj = _parse_user_trade_update (tData )
324+ self ._emit ('user_trade_update' , tradeObj )
287325
288326 async def _trade_executed_handler (self , data ):
289327 tData = data [2 ]
@@ -292,6 +330,11 @@ async def _trade_executed_handler(self, data):
292330 symbol = self .subscriptionManager .get (data [0 ]).symbol
293331 tradeObj = _parse_trade (tData , symbol )
294332 self ._emit ('new_trade' , tradeObj )
333+ else :
334+ # user trade
335+ # [0, 'te', [37558151, 'tBTCUSD', 1643542688513, 1512164914, 0.0001, 30363, 'EXCHANGE MARKET', 100000, -1, None, None, 1643542688390]]
336+ tradeObj = _parse_user_trade (tData )
337+ self ._emit ('new_user_trade' , tradeObj )
295338
296339 async def _wallet_update_handler (self , data ):
297340 # [0,"wu",["exchange","USD",89134.66933283,0]]
0 commit comments