Skip to content

Commit

Permalink
livecoin: better status responses on createOrder, cancelOrder; suppor…
Browse files Browse the repository at this point in the history
…t OrderNotFound exception
  • Loading branch information
egorFiNE committed May 23, 2018
1 parent a110d64 commit 6d05812
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions js/livecoin.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,15 @@ module.exports = class livecoin extends Exchange {
if (type === 'limit')
order['price'] = this.priceToPrecision (symbol, price);
let response = await this[method] (this.extend (order, params));
return {
const result = {
'info': response,
'id': response['orderId'].toString (),
};
const success = this.safeValue (response, 'success');
if (success) {
result['status'] = 'open';
}
return result;
}

async cancelOrder (id, symbol = undefined, params = {}) {
Expand All @@ -509,7 +514,10 @@ module.exports = class livecoin extends Exchange {
throw new InvalidOrder (message);
} else if ('cancelled' in response) {
if (response['cancelled']) {
return response;
return {
'status': 'canceled',
'info': response,
};
} else {
throw new OrderNotFound (message);
}
Expand Down Expand Up @@ -602,6 +610,10 @@ module.exports = class livecoin extends Exchange {
// returns status code 200 even if success === false
let success = this.safeValue (response, 'success', true);
if (!success) {
const message = this.safeString (response, 'message', '');
if (message.indexOf ('Cannot find order') >= 0) {
throw new OrderNotFound (this.id + ' ' + body);
}
throw new ExchangeError (this.id + ' ' + body);
}
}
Expand Down

0 comments on commit 6d05812

Please sign in to comment.