# Sort the df by that index df.sort_index(inplace=True) # Convert dates to num for matplotlib df['mpldate'] = df['transactTime'].map(mdates.date2num) # Delete the old transactTime column del df['transactTime'] df = df[start_datetime:end_datetime] ############################################################ """ Get some bitcoin price data """ finex = BFX() if start_datetime == None: start_datetime = pd.to_datetime(df.index.values[0]).to_pydatetime() now = datetime.now().replace(hour=0, minute=0, second=0, microsecond=0) if (end_datetime == None) or (end_datetime > now): end_datetime = now logger.info('Querying candles between: ' + str(start_datetime) + ' and ' + str(end_datetime)) candles = finex.api_request_candles('1D', 'BTCUSD', start_datetime, end_datetime)
df.set_index(df['transactTime'], inplace=True) # Sort the df by that index df.sort_index(inplace=True) # Convert dates to num for matplotlib df['mpldate'] = df['transactTime'].map(mdates.date2num) # Delete the old transactTime column del df['transactTime'] ############################################################ """ Get some bitcoin price data """ finex = BFX() start_datetime = pd.to_datetime(df.index.values[0]).to_pydatetime() end_datetime = datetime.now().replace(hour=0, minute=0, second=0, microsecond=0) candles_json = finex.api_request_candles('1D', start_datetime) last_returned_from_api = datetime.utcfromtimestamp( candles_json[len(candles_json) - 1][0] / 1000.0) while last_returned_from_api < end_datetime: # New api start date = the last returned date + 1 period new_api_start_date = last_returned_from_api + datetime_timedelta(