Skip to content

Instantly share code, notes, and snippets.

@ganigithub
Created June 27, 2022 15:25
Show Gist options
  • Save ganigithub/40d47cc718cbd1c2a74be5db6158139a to your computer and use it in GitHub Desktop.
Save ganigithub/40d47cc718cbd1c2a74be5db6158139a to your computer and use it in GitHub Desktop.
import datetime
import pandas as pd
def final_data(self, data):
candleinfo = data['data']['candles']
df = pd.DataFrame(candleinfo, columns = ['time','open','high','low','close','volume','openinterest'])
df['time'] = pd.to_datetime(df.time, format = '%Y-%m-%dT%H:%M:%S')
date = datetime.datetime.now()
if len(str(date.day))==1:
d = '0'+str(date.day)
if len(str(date.day))==2:
d = str(date.day)
df = df[df.time.astype('str').str.slice(8,10).str.contains(d)]
df.reset_index(inplace=True, drop=True)
return df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment