@@ -66,7 +66,8 @@ def _parse_trade(tData, symbol):
6666 'symbol' : symbol
6767 }
6868
69- def _parse_account_trade (tData ):
69+
70+ def _parse_user_trade (tData ):
7071 return {
7172 'id' : tData [0 ],
7273 'symbol' : tData [1 ],
@@ -81,7 +82,7 @@ def _parse_account_trade(tData):
8182 }
8283
8384
84- def _parse_account_trade_update (tData ):
85+ def _parse_user_trade_update (tData ):
8586 return {
8687 'id' : tData [0 ],
8788 'symbol' : tData [1 ],
@@ -97,6 +98,7 @@ def _parse_account_trade_update(tData):
9798 'cid' : tData [11 ],
9899 }
99100
101+
100102def _parse_deriv_status_update (sData , symbol ):
101103 return {
102104 'symbol' : symbol ,
@@ -171,6 +173,7 @@ class BfxWebsocket(GenericWebsocket):
171173 - `funding_credit_snapshot` (array): Opening funding credit balances
172174 - `balance_update` (array): When the state of a balance is changed
173175 - `new_trade` (array): A new trade on the market has been executed
176+ - `new_user_trade` (array): A new - your - trade has been executed
174177 - `new_ticker` (Ticker|FundingTicker): A new ticker update has been published
175178 - `new_funding_ticker` (FundingTicker): A new funding ticker update has been published
176179 - `new_trading_ticker` (Ticker): A new trading ticker update has been published
@@ -309,15 +312,29 @@ async def _system_auth_handler(self, socketId, data):
309312
310313 async def _trade_update_handler (self , data ):
311314 tData = data [2 ]
312- # [0,"tu",[738045455,"tTESTBTC:TESTUSD",1622169615771,66635385225,0.001,38175,"EXCHANGE LIMIT",39000,-1,-0.000002,"TESTBTC",1622169615685]]
313- tradeObj = _parse_account_trade_update (tData )
314- self ._emit ('trade_update' , tradeObj )
315+ # [209, 'tu', [312372989, 1542303108930, 0.35, 5688.61834032]]
316+ if self .subscriptionManager .is_subscribed (data [0 ]):
317+ symbol = self .subscriptionManager .get (data [0 ]).symbol
318+ tradeObj = _parse_trade (tData , symbol )
319+ 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 )
315325
316326 async def _trade_executed_handler (self , data ):
317327 tData = data [2 ]
318- # [0,"te",[738045455,"tTESTBTC:TESTUSD",1622169615771,66635385225,0.001,38175,"EXCHANGE LIMIT",39000,-1,null,null,1622169615685]]
319- tradeObj = _parse_account_trade (tData )
320- self ._emit ('new_trade' , tradeObj )
328+ # [209, 'te', [312372989, 1542303108930, 0.35, 5688.61834032]]
329+ if self .subscriptionManager .is_subscribed (data [0 ]):
330+ symbol = self .subscriptionManager .get (data [0 ]).symbol
331+ tradeObj = _parse_trade (tData , symbol )
332+ 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 )
321338
322339 async def _wallet_update_handler (self , data ):
323340 # [0,"wu",["exchange","USD",89134.66933283,0]]
@@ -436,7 +453,12 @@ async def _trade_handler(self, data):
436453 # connection
437454 data .reverse ()
438455 for t in data :
439- trade = _parse_trade (t , symbol )
456+ trade = {
457+ 'mts' : t [1 ],
458+ 'amount' : t [2 ],
459+ 'price' : t [3 ],
460+ 'symbol' : symbol
461+ }
440462 self ._emit ('seed_trade' , trade )
441463
442464 async def _candle_handler (self , data ):
0 commit comments