def get_starting_time(self, symbol: str): # hard-code few common symbols if symbol == 'BTCUSD': return jh.date_to_timestamp('2015-08-01') elif symbol == 'ETHUSD': return jh.date_to_timestamp('2016-01-01') payload = { 'sort': 1, 'limit': 5000, } response = requests.get(self.endpoint + '/trade:1D:t{}/hist'.format(symbol), params=payload) if response.status_code != 200: raise Exception(response.content) data = response.json() # wrong symbol entered if not len(data): raise exceptions.SymbolNotFound( "No candle exists for {} in Bitfinex. You're probably misspelling the symbol name." .format(symbol)) first_timestamp = int(data[0][0]) second_timestamp = first_timestamp + 60_000 * 1440 return second_timestamp
def get_starting_time(self, symbol: str): dashless_symbol = jh.dashless_symbol(symbol) # hard-code few common symbols if symbol == 'BTC-USD': return jh.date_to_timestamp('2015-08-01') elif symbol == 'ETH-USD': return jh.date_to_timestamp('2016-01-01') payload = { 'sort': 1, 'limit': 5000, } response = requests.get(f"{self.endpoint}/trade:1D:t{dashless_symbol}/hist", params=payload) if response.status_code != 200: raise Exception(response.content) data = response.json() # wrong symbol entered if not len(data): raise exceptions.SymbolNotFound( f"No candle exists for {symbol} in Bitfinex. You're probably misspelling the symbol name." ) # since the first timestamp doesn't include all the 1m # candles, let's start since the second day then first_timestamp = int(data[0][0]) second_timestamp = first_timestamp + 60_000 * 1440 return second_timestamp