Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
DogsTailFarmer committed Feb 4, 2023
1 parent de5b7dc commit c218fed
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 16 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## v1.2.9-2 - 2023-01-xx
## v1.2.9-2 - 2023-02-04
### Fixed
* Fix DogsTailFarmer/martin-binance#50

### Update
* Remove unnecessary shebang

Expand Down
58 changes: 58 additions & 0 deletions exchanges_wrapper/c_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,61 @@ def generate_signature(exchange, api_secret, data):
else:
sig = hmac.new(api_secret.encode("utf-8"), data.encode("utf-8"), hashlib.sha256).hexdigest()
return sig


def order(res: {}, response_type=None) -> {}:
if response_type:
binance_order = {
"symbol": res.get('symbol'),
"origClientOrderId": res.get('origClientOrderId'),
"orderId": res.get('orderId'),
"orderListId": res.get('orderListId'),
"clientOrderId": res.get('clientOrderId'),
"transactTime": res.get('time'),
"price": res.get('price'),
"origQty": res.get('origQty'),
"executedQty": res.get('executedQty'),
"cummulativeQuoteQty": res.get('cummulativeQuoteQty'),
"status": res.get('status'),
"timeInForce": res.get('timeInForce'),
"type": res.get('type'),
"side": res.get('side'),
}
elif response_type is None:
binance_order = {
"symbol": res.get('symbol'),
"orderId": res.get('orderId'),
"orderListId": res.get('orderListId'),
"clientOrderId": res.get('clientOrderId'),
"price": res.get('price'),
"origQty": res.get('origQty'),
"executedQty": res.get('executedQty'),
"cummulativeQuoteQty": res.get('cummulativeQuoteQty'),
"status": res.get('status'),
"timeInForce": res.get('timeInForce'),
"type": res.get('type'),
"side": res.get('side'),
"stopPrice": res.get('stopPrice'),
"icebergQty": res.get('icebergQty'),
"time": res.get('time'),
"updateTime": res.get('updateTime'),
"isWorking": res.get('isWorking'),
"origQuoteOrderQty": res.get('origQuoteOrderQty'),
}
else:
binance_order = {
"symbol": res.get('symbol'),
"orderId": res.get('orderId'),
"orderListId": res.get('orderListId'),
"clientOrderId": res.get('clientOrderId'),
"price": res.get('price'),
"origQty": res.get('origQty'),
"executedQty": res.get('executedQty'),
"cummulativeQuoteQty": res.get('cummulativeQuoteQty'),
"status": res.get('status'),
"timeInForce": res.get('timeInForce'),
"type": res.get('type'),
"side": res.get('side'),
}
# print(f"order.binance_order: {binance_order}")
return binance_order
17 changes: 2 additions & 15 deletions exchanges_wrapper/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import exchanges_wrapper.bitfinex_parser as bfx
import exchanges_wrapper.huobi_parser as hbp
import exchanges_wrapper.okx_parser as okx
from exchanges_wrapper.c_structures import order as binance_order_transform

logger = logging.getLogger('exch_srv_logger')

Expand Down Expand Up @@ -817,20 +818,7 @@ async def fetch_order( # lgtm [py/similar-function]
params=params,
signed=True,
)
binance_res = {
"symbol": res.get('symbol'),
"orderId": res.get('orderId'),
"orderListId": res.get('orderListId'),
"clientOrderId": res.get('clientOrderId'),
"price": res.get('price'),
"origQty": res.get('origQty'),
"executedQty": res.get('executedQty'),
"cummulativeQuoteQty": res.get('cummulativeQuoteQty'),
"status": res.get('status'),
"timeInForce": res.get('timeInForce'),
"type": res.get('type'),
"side": res.get('side'),
}
binance_res = binance_order_transform(res, response_type=response_type)
elif self.exchange == 'bitfinex':
params = {'id': [order_id]}
res = await self.http.send_api_call(
Expand All @@ -846,7 +834,6 @@ async def fetch_order( # lgtm [py/similar-function]
signed=True,
**params
)
logger.debug(f"fetch_order(closed).res: {res}")
if res:
binance_res = bfx.order(res[0], response_type=response_type)
elif self.exchange == 'huobi':
Expand Down

0 comments on commit c218fed

Please sign in to comment.