From 50836950cd3399c33cfc11e58fad36698fde2cd4 Mon Sep 17 00:00:00 2001 From: Sam Germain Date: Mon, 27 Sep 2021 22:40:27 -0600 Subject: [PATCH 1/6] Added fetchIndexOHLCV to ftx --- js/ftx.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/js/ftx.js b/js/ftx.js index c2c9f09121de..032eb5e2ec1a 100644 --- a/js/ftx.js +++ b/js/ftx.js @@ -698,6 +698,8 @@ module.exports = class ftx extends Exchange { 'resolution': this.timeframes[timeframe], 'market_name': marketId, }; + const price = this.safeString (params, 'price'); + params = this.omit (params, 'price'); // max 1501 candles, including the current candle when since is not specified limit = (limit === undefined) ? 1501 : limit; if (since === undefined) { @@ -709,7 +711,18 @@ module.exports = class ftx extends Exchange { request['limit'] = limit; request['end_time'] = this.sum (request['start_time'], limit * this.parseTimeframe (timeframe)); } - const response = await this.publicGetMarketsMarketNameCandles (this.extend (request, params)); + let response = {}; + if (price === 'index') { + if (symbol in this.markets) { + request['market_name'] = market['baseId']; + } else { + const currency = this.currency (symbol); + request['market_name'] = currency['id']; + } + response = await this.publicGetIndexesMarketNameCandles (this.extend (request, params)); + } else { + response = await this.publicGetMarketsMarketNameCandles (this.extend (request, params)); + } // // { // "success": true, @@ -739,6 +752,13 @@ module.exports = class ftx extends Exchange { return this.parseOHLCVs (result, market, timeframe, since, limit); } + async fetchIndexOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) { + const request = { + 'index': true, + }; + return await this.fetchOHLCV (symbol, timeframe, since, limit, this.extend (request, params)); + } + parseTrade (trade, market = undefined) { // // fetchTrades (public) From 9ac0a6fea1171dba6ae400b738a083eecad43d56 Mon Sep 17 00:00:00 2001 From: Sam Germain Date: Mon, 27 Sep 2021 22:46:17 -0600 Subject: [PATCH 2/6] Added has properties for fetchIndexOHLCV and fetchMarkOHLCV --- js/binance.js | 2 ++ js/ftx.js | 1 + 2 files changed, 3 insertions(+) diff --git a/js/binance.js b/js/binance.js index 7210b1089658..0df4d62dc56e 100644 --- a/js/binance.js +++ b/js/binance.js @@ -34,6 +34,8 @@ module.exports = class binance extends Exchange { 'fetchFundingHistory': true, 'fetchFundingRate': true, 'fetchFundingRates': true, + 'fetchIndexOHLCV': true, + 'fetchMarkOHLCV': true, 'fetchIsolatedPositions': true, 'fetchMarkets': true, 'fetchMyTrades': true, diff --git a/js/ftx.js b/js/ftx.js index 032eb5e2ec1a..f9107dccfbd6 100644 --- a/js/ftx.js +++ b/js/ftx.js @@ -44,6 +44,7 @@ module.exports = class ftx extends Exchange { 'fetchDepositAddress': true, 'fetchDeposits': true, 'fetchFundingFees': false, + 'fetchIndexOHLCV': true, 'fetchMarkets': true, 'fetchMyTrades': true, 'fetchOHLCV': true, From 263122e73e4ec3ae8a3ffef38bf6b33569ccefd3 Mon Sep 17 00:00:00 2001 From: Sam Germain Date: Mon, 27 Sep 2021 22:49:27 -0600 Subject: [PATCH 3/6] organized code in ftx.fetchOHLCV --- js/ftx.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/js/ftx.js b/js/ftx.js index f9107dccfbd6..3dfd478fb3e1 100644 --- a/js/ftx.js +++ b/js/ftx.js @@ -713,17 +713,14 @@ module.exports = class ftx extends Exchange { request['end_time'] = this.sum (request['start_time'], limit * this.parseTimeframe (timeframe)); } let response = {}; + let method = 'publicGetMarketsMarketNameCandles'; if (price === 'index') { if (symbol in this.markets) { request['market_name'] = market['baseId']; - } else { - const currency = this.currency (symbol); - request['market_name'] = currency['id']; } - response = await this.publicGetIndexesMarketNameCandles (this.extend (request, params)); - } else { - response = await this.publicGetMarketsMarketNameCandles (this.extend (request, params)); + method = 'publicGetIndexesMarketNameCandles'; } + response = await this[method] (this.extend (request, params)); // // { // "success": true, From 27524210304e33ad8c1dcdd3bb4c656d1dfd3cab Mon Sep 17 00:00:00 2001 From: Igor Kroitor Date: Tue, 28 Sep 2021 07:51:07 +0300 Subject: [PATCH 4/6] ftx minor edit --- js/ftx.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/js/ftx.js b/js/ftx.js index 3dfd478fb3e1..36b0c1a797ac 100644 --- a/js/ftx.js +++ b/js/ftx.js @@ -712,7 +712,6 @@ module.exports = class ftx extends Exchange { request['limit'] = limit; request['end_time'] = this.sum (request['start_time'], limit * this.parseTimeframe (timeframe)); } - let response = {}; let method = 'publicGetMarketsMarketNameCandles'; if (price === 'index') { if (symbol in this.markets) { @@ -720,7 +719,7 @@ module.exports = class ftx extends Exchange { } method = 'publicGetIndexesMarketNameCandles'; } - response = await this[method] (this.extend (request, params)); + const response = await this[method] (this.extend (request, params)); // // { // "success": true, From 1f1eb17b7f2eba716dd506dc98db2ddd718fbad8 Mon Sep 17 00:00:00 2001 From: Igor Kroitor Date: Tue, 28 Sep 2021 08:04:13 +0300 Subject: [PATCH 5/6] ftx fetchIndexOHLCV minor fix --- js/ftx.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/ftx.js b/js/ftx.js index 36b0c1a797ac..b958835b9216 100644 --- a/js/ftx.js +++ b/js/ftx.js @@ -751,7 +751,7 @@ module.exports = class ftx extends Exchange { async fetchIndexOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) { const request = { - 'index': true, + 'price': 'index', }; return await this.fetchOHLCV (symbol, timeframe, since, limit, this.extend (request, params)); } From af056fa8db6d6aabf97fd4b1706b5bc5f2aaf6e2 Mon Sep 17 00:00:00 2001 From: Sam Germain Date: Mon, 27 Sep 2021 23:06:58 -0600 Subject: [PATCH 6/6] fixed request bug in fetchIndexOHLCV and fetchMarkOHLCV --- js/binance.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/binance.js b/js/binance.js index 0df4d62dc56e..210a03053c63 100644 --- a/js/binance.js +++ b/js/binance.js @@ -1834,14 +1834,14 @@ module.exports = class binance extends Exchange { async fetchMarkOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) { const request = { - 'mark': true, + 'price': 'mark', }; return await this.fetchOHLCV (symbol, timeframe, since, limit, this.extend (request, params)); } async fetchIndexOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) { const request = { - 'index': true, + 'price': 'index', }; return await this.fetchOHLCV (symbol, timeframe, since, limit, this.extend (request, params)); }