Created
June 27, 2022 15:25
-
-
Save ganigithub/40d47cc718cbd1c2a74be5db6158139a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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