@@ -66,6 +66,37 @@ def _parse_trade(tData, symbol):
6666 'symbol' : symbol
6767 }
6868
69+ def _parse_account_trade (tData ):
70+ return {
71+ 'id' : tData [0 ],
72+ 'symbol' : tData [1 ],
73+ 'mts_create' : tData [2 ],
74+ 'order_id' : tData [3 ],
75+ 'exec_amount' : tData [4 ],
76+ 'exec_price' : tData [5 ],
77+ 'order_type' : tData [6 ],
78+ 'order_price' : tData [7 ],
79+ 'maker' : tData [8 ],
80+ 'cid' : tData [11 ],
81+ }
82+
83+
84+ def _parse_account_trade_update (tData ):
85+ return {
86+ 'id' : tData [0 ],
87+ 'symbol' : tData [1 ],
88+ 'mts_create' : tData [2 ],
89+ 'order_id' : tData [3 ],
90+ 'exec_amount' : tData [4 ],
91+ 'exec_price' : tData [5 ],
92+ 'order_type' : tData [6 ],
93+ 'order_price' : tData [7 ],
94+ 'maker' : tData [8 ],
95+ 'fee' : tData [9 ],
96+ 'fee_currency' : tData [10 ],
97+ 'cid' : tData [11 ],
98+ }
99+
69100def _parse_deriv_status_update (sData , symbol ):
70101 return {
71102 'symbol' : symbol ,
@@ -278,19 +309,15 @@ async def _system_auth_handler(self, socketId, data):
278309
279310 async def _trade_update_handler (self , data ):
280311 tData = data [2 ]
281- # [209, 'tu', [312372989, 1542303108930, 0.35, 5688.61834032]]
282- if self .subscriptionManager .is_subscribed (data [0 ]):
283- symbol = self .subscriptionManager .get (data [0 ]).symbol
284- tradeObj = _parse_trade (tData , symbol )
285- self ._emit ('trade_update' , tradeObj )
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 )
286315
287316 async def _trade_executed_handler (self , data ):
288317 tData = data [2 ]
289- # [209, 'te', [312372989, 1542303108930, 0.35, 5688.61834032]]
290- if self .subscriptionManager .is_subscribed (data [0 ]):
291- symbol = self .subscriptionManager .get (data [0 ]).symbol
292- tradeObj = _parse_trade (tData , symbol )
293- self ._emit ('new_trade' , tradeObj )
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 )
294321
295322 async def _wallet_update_handler (self , data ):
296323 # [0,"wu",["exchange","USD",89134.66933283,0]]
@@ -409,12 +436,7 @@ async def _trade_handler(self, data):
409436 # connection
410437 data .reverse ()
411438 for t in data :
412- trade = {
413- 'mts' : t [1 ],
414- 'amount' : t [2 ],
415- 'price' : t [3 ],
416- 'symbol' : symbol
417- }
439+ trade = _parse_trade (t , symbol )
418440 self ._emit ('seed_trade' , trade )
419441
420442 async def _candle_handler (self , data ):
0 commit comments