Skip to content

Commit

Permalink
Merge pull request #10071 from samgermain/ohlcv-index-ftx
Browse files Browse the repository at this point in the history
Added fetchIndexOHLCV to ftx
  • Loading branch information
kroitor committed Sep 28, 2021
2 parents 8034110 + 0481ecc commit 6fdc58c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions js/binance.js
Expand Up @@ -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,
Expand Down
19 changes: 18 additions & 1 deletion js/ftx.js
Expand Up @@ -44,6 +44,7 @@ module.exports = class ftx extends Exchange {
'fetchDepositAddress': true,
'fetchDeposits': true,
'fetchFundingFees': false,
'fetchIndexOHLCV': true,
'fetchMarkets': true,
'fetchMyTrades': true,
'fetchOHLCV': true,
Expand Down Expand Up @@ -698,6 +699,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) {
Expand All @@ -709,7 +712,14 @@ 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 method = 'publicGetMarketsMarketNameCandles';
if (price === 'index') {
if (symbol in this.markets) {
request['market_name'] = market['baseId'];
}
method = 'publicGetIndexesMarketNameCandles';
}
const response = await this[method] (this.extend (request, params));
//
// {
// "success": true,
Expand Down Expand Up @@ -739,6 +749,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 = {
'price': 'index',
};
return await this.fetchOHLCV (symbol, timeframe, since, limit, this.extend (request, params));
}

parseTrade (trade, market = undefined) {
//
// fetchTrades (public)
Expand Down

0 comments on commit 6fdc58c

Please sign in to comment.