Skip to content

Commit 793fda9

Browse files
committed
updated version
changed account's trade execution (te) and trade update (tu) handling
1 parent f2d83fe commit 793fda9

File tree

4 files changed

+45
-18
lines changed

4 files changed

+45
-18
lines changed

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2.0.0
2+
-) Implemented Movement endpoints (REST)
3+
-) Fixed unawaited stop
4+
-) Changed account's trade execution (te) and trade update (tu) handling
5+
16
1.3.5
27
-) Implemented Movement endpoints (REST)
38

bfxapi/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
This module contains the current version of the bfxapi lib
33
"""
44

5-
__version__ = '1.3.5'
5+
__version__ = '2.0.0'

bfxapi/websockets/bfx_websocket.py

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
69100
def _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):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
here = path.abspath(path.dirname(__file__))
1212
setup(
1313
name='bitfinex-api-py',
14-
version='1.3.5',
14+
version='2.0.0',
1515
description='Official Bitfinex Python API',
1616
long_description='A Python reference implementation of the Bitfinex API for both REST and websocket interaction',
1717
long_description_content_type='text/markdown',

0 commit comments

Comments
 (0)