Remove FTX from the price feeds
This commit is contained in:
		
							parent
							
								
									34500f7d47
								
							
						
					
					
						commit
						7c7273b696
					
				@ -1,43 +0,0 @@
 | 
			
		||||
import { query } from '../../utils/axios-query';
 | 
			
		||||
import priceUpdater, { PriceFeed, PriceHistory } from '../price-updater';
 | 
			
		||||
 | 
			
		||||
class FtxApi implements PriceFeed {
 | 
			
		||||
  public name: string = 'FTX';
 | 
			
		||||
  public currencies: string[] = ['USD', 'BRZ', 'EUR', 'JPY', 'AUD'];
 | 
			
		||||
 | 
			
		||||
  public url: string = 'https://ftx.com/api/markets/BTC/';
 | 
			
		||||
  public urlHist: string = 'https://ftx.com/api/markets/BTC/{CURRENCY}/candles?resolution={GRANULARITY}';
 | 
			
		||||
 | 
			
		||||
  constructor() {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public async $fetchPrice(currency): Promise<number> {
 | 
			
		||||
    const response = await query(this.url + currency);
 | 
			
		||||
    return response ? parseInt(response['result']['last'], 10) : -1;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public async $fetchRecentPrice(currencies: string[], type: 'hour' | 'day'): Promise<PriceHistory> {
 | 
			
		||||
    const priceHistory: PriceHistory = {};
 | 
			
		||||
 | 
			
		||||
    for (const currency of currencies) {
 | 
			
		||||
      if (this.currencies.includes(currency) === false) {
 | 
			
		||||
        continue;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      const response = await query(this.urlHist.replace('{GRANULARITY}', type === 'hour' ? '3600' : '86400').replace('{CURRENCY}', currency));
 | 
			
		||||
      const pricesRaw = response ? response['result'] : [];
 | 
			
		||||
 | 
			
		||||
      for (const price of pricesRaw as any[]) {
 | 
			
		||||
        const time = Math.round(price['time'] / 1000);
 | 
			
		||||
        if (priceHistory[time] === undefined) {
 | 
			
		||||
          priceHistory[time] = priceUpdater.getEmptyPricesObj();
 | 
			
		||||
        }
 | 
			
		||||
        priceHistory[time][currency] = price['close'];
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return priceHistory;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default FtxApi;
 | 
			
		||||
@ -1,13 +1,11 @@
 | 
			
		||||
import * as fs from 'fs';
 | 
			
		||||
import path from "path";
 | 
			
		||||
import { Common } from '../api/common';
 | 
			
		||||
import config from '../config';
 | 
			
		||||
import logger from '../logger';
 | 
			
		||||
import PricesRepository from '../repositories/PricesRepository';
 | 
			
		||||
import BitfinexApi from './price-feeds/bitfinex-api';
 | 
			
		||||
import BitflyerApi from './price-feeds/bitflyer-api';
 | 
			
		||||
import CoinbaseApi from './price-feeds/coinbase-api';
 | 
			
		||||
import FtxApi from './price-feeds/ftx-api';
 | 
			
		||||
import GeminiApi from './price-feeds/gemini-api';
 | 
			
		||||
import KrakenApi from './price-feeds/kraken-api';
 | 
			
		||||
 | 
			
		||||
@ -48,7 +46,6 @@ class PriceUpdater {
 | 
			
		||||
    this.latestPrices = this.getEmptyPricesObj();
 | 
			
		||||
 | 
			
		||||
    this.feeds.push(new BitflyerApi()); // Does not have historical endpoint
 | 
			
		||||
    this.feeds.push(new FtxApi());
 | 
			
		||||
    this.feeds.push(new KrakenApi());
 | 
			
		||||
    this.feeds.push(new CoinbaseApi());
 | 
			
		||||
    this.feeds.push(new BitfinexApi());
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user