From a0ce43cf4d8f2a993b9943fdadbb161c6e866454 Mon Sep 17 00:00:00 2001 From: sc0vu Date: Mon, 12 Dec 2022 15:18:39 +0800 Subject: [PATCH 1/5] woo: add endpoints to edit order --- js/woo.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/js/woo.js b/js/woo.js index b39c0a48cda7..b5c955a867c3 100644 --- a/js/woo.js +++ b/js/woo.js @@ -200,6 +200,12 @@ module.exports = class woo extends Exchange { 'post': { 'algo/order': 5, }, + 'put': { + 'order/{oid}': 2, + 'order/client/{oid}': 2, + 'algo/order/{oid}': 2, + 'algo/order/client/{oid}': 2, + }, 'delete': { 'algo/order/{oid}': 1, 'algo/orders/pending': 1, From 2b482e427705bed7cb3ad642d383754e69e2d0e9 Mon Sep 17 00:00:00 2001 From: sc0vu Date: Mon, 12 Dec 2022 15:51:19 +0800 Subject: [PATCH 2/5] woo: add editOrder --- js/woo.js | 52 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/js/woo.js b/js/woo.js index b5c955a867c3..2112ff12cc19 100644 --- a/js/woo.js +++ b/js/woo.js @@ -779,6 +779,50 @@ module.exports = class woo extends Exchange { ); } + async editOrder (id, symbol, type, side, amount, price = undefined, params = {}) { + /** + * @method + * @name woo#editOrder + * @description edit a trade order + * @param {string} id order id + * @param {string} symbol unified symbol of the market to create an order in + * @param {string} type 'market' or 'limit' + * @param {string} side 'buy' or 'sell' + * @param {float} amount how much of currency you want to trade in units of base currency + * @param {float|undefined} price the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders + * @param {object} params extra parameters specific to the woo api endpoint + * @returns {object} an [order structure]{@link https://docs.ccxt.com/en/latest/manual.html#order-structure} + */ + await this.loadMarkets (); + const market = this.market (symbol); + const request = { + 'oid': id, + // 'quantity': this.amountToPrecision (symbol, amount), + // 'price': this.priceToPrecision (symbol, price), + }; + if (price !== undefined) { + request['price'] = this.priceToPrecision (symbol, price); + } + if (amount !== undefined) { + request['quantity'] = this.amountToPrecision (symbol, amount); + } + const response = await this.v3PrivatePutOrderOid (this.extend (request, params)); + // + // { + // "code": 0, + // "data": { + // "status": "string", + // "success": true + // }, + // "message": "string", + // "success": true, + // "timestamp": 0 + // } + // + const data = this.safeValue (response, 'data', {}); + return this.parseOrder (data, market); + } + async cancelOrder (id, symbol = undefined, params = {}) { /** * @method @@ -1795,24 +1839,24 @@ module.exports = class woo extends Exchange { sign (path, section = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { const version = section[0]; const access = section[1]; + const pathWithParams = this.implodeParams (path, params); let url = this.implodeHostname (this.urls['api'][access]); url += '/' + version + '/'; - path = this.implodeParams (path, params); params = this.omit (params, this.extractParams (path)); params = this.keysort (params); if (access === 'public') { - url += access + '/' + path; + url += access + '/' + pathWithParams; if (Object.keys (params).length) { url += '?' + this.urlencode (params); } } else { this.checkRequiredCredentials (); - url += path; + url += pathWithParams; const ts = this.nonce ().toString (); let auth = this.urlencode (params); if (version === 'v3' && (method === 'POST')) { body = auth; - auth = ts + method + '/' + version + '/' + path + body; + auth = ts + method + '/' + version + '/' + pathWithParams + body; } else { if (method === 'POST' || method === 'DELETE') { body = auth; From 9487ea0932dfc4eec49ccf1486e86a4f7e511809 Mon Sep 17 00:00:00 2001 From: sc0vu Date: Mon, 12 Dec 2022 16:01:46 +0800 Subject: [PATCH 3/5] woo: update --- js/woo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/woo.js b/js/woo.js index 2112ff12cc19..0097fc3f4b1e 100644 --- a/js/woo.js +++ b/js/woo.js @@ -1854,7 +1854,7 @@ module.exports = class woo extends Exchange { url += pathWithParams; const ts = this.nonce ().toString (); let auth = this.urlencode (params); - if (version === 'v3' && (method === 'POST')) { + if (version === 'v3' && (method === 'POST' || method === 'PUT')) { body = auth; auth = ts + method + '/' + version + '/' + pathWithParams + body; } else { From f7d163356a6a176540d85a1b62191ecb7c4dd85a Mon Sep 17 00:00:00 2001 From: sc0vu Date: Tue, 13 Dec 2022 18:53:52 +0800 Subject: [PATCH 4/5] woo: update signature --- js/woo.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/js/woo.js b/js/woo.js index 0097fc3f4b1e..18bb645fccb3 100644 --- a/js/woo.js +++ b/js/woo.js @@ -1851,27 +1851,29 @@ module.exports = class woo extends Exchange { } } else { this.checkRequiredCredentials (); - url += pathWithParams; + let auth = ''; const ts = this.nonce ().toString (); - let auth = this.urlencode (params); - if (version === 'v3' && (method === 'POST' || method === 'PUT')) { + url += path; + headers = { + 'x-api-key': this.apiKey, + 'x-api-timestamp': ts, + }; + if (version === 'v3' && (method === 'POST' || method === 'PUT' || method === 'DELETE')) { + auth = this.json (params); body = auth; - auth = ts + method + '/' + version + '/' + pathWithParams + body; + auth = ts + method + '/' + version + '/' + path + body; + headers['content-type'] = 'application/json'; } else { - if (method === 'POST' || method === 'DELETE') { + auth = this.urlencode (params); + if (method === 'POST' || method === 'PUT' || method === 'DELETE') { body = auth; } else { url += '?' + auth; } auth += '|' + ts; + headers['content-type'] = 'application/x-www-form-urlencoded'; } - const signature = this.hmac (this.encode (auth), this.encode (this.secret), 'sha256'); - headers = { - 'x-api-key': this.apiKey, - 'x-api-signature': signature, - 'x-api-timestamp': ts, - 'Content-Type': 'application/x-www-form-urlencoded', - }; + headers['x-api-signature'] = this.hmac (this.encode (auth), this.encode (this.secret), 'sha256'); } return { 'url': url, 'method': method, 'body': body, 'headers': headers }; } From f9d575c7cb2d942efe06094c5b677acea6f9b83c Mon Sep 17 00:00:00 2001 From: sc0vu Date: Wed, 14 Dec 2022 19:52:44 +0800 Subject: [PATCH 5/5] woo: update signature --- js/woo.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/woo.js b/js/woo.js index 18bb645fccb3..28353da929ab 100644 --- a/js/woo.js +++ b/js/woo.js @@ -1853,7 +1853,7 @@ module.exports = class woo extends Exchange { this.checkRequiredCredentials (); let auth = ''; const ts = this.nonce ().toString (); - url += path; + url += pathWithParams; headers = { 'x-api-key': this.apiKey, 'x-api-timestamp': ts, @@ -1861,7 +1861,7 @@ module.exports = class woo extends Exchange { if (version === 'v3' && (method === 'POST' || method === 'PUT' || method === 'DELETE')) { auth = this.json (params); body = auth; - auth = ts + method + '/' + version + '/' + path + body; + auth = ts + method + '/' + version + '/' + pathWithParams + body; headers['content-type'] = 'application/json'; } else { auth = this.urlencode (params);