Python Forum
day HIGH/LOW studies on 1-min S&P futures data.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
day HIGH/LOW studies on 1-min S&P futures data.
#1
I am trying to do a day HIGH/LOW studies on 1-min S&P futures data.

I have 2 questions.

1) How could I print the day HIGH / LOW for each day
2) How could I print the day HIGH / LOW for the first hour of trading


Thanks a lot in advance.

[Image: 49979016508_ac2c704a2f_c.jpg]
Reply
#2
What are column types (date and time)?

If they are of DateTime dtype (datetime64[ns]), you can do this using groupby, e.g.

df.groupby('date')['high'].max() # get max values of 'high' column for each day
df.groupby('date')['high'].min() # get min values of 'high' column for each day

df.groupby([df.date, df.time.dt.hour])['high'].max() # get max values of 'high' column for each hour (during the day)
Reply
#3
(Jun-07-2020, 10:13 AM)scidam Wrote: What are column types (date and time)?

If they are of DateTime dtype (datetime64[ns]), you can do this using groupby, e.g.

df.groupby('date')['high'].max() # get max values of 'high' column for each day
df.groupby('date')['high'].min() # get min values of 'high' column for each day

df.groupby([df.date, df.time.dt.hour])['high'].max() # get max values of 'high' column for each hour (during the day)

Thanks scidam for your quick reply.

I am kind of stuck here. I want to have the output displayed all in 2 lines day by day like the following.


Date, Time, High
Date, Time, Low



How could I write it in such a way to achieve that ? many thanks. I went thru many Youtube videos on groupby, but I am not able to find groupby with multiple columns outputs with different calculation criteria(Max of High and Min of Low in this case.)

[Image: 49979772158_557aed747e_z.jpg]

data type originally

[Image: 49980331116_33822ee0e8_z.jpg]

Then I converted the Date and Time to datetime64 format. Not sure if I made it better or worse?

[Image: 49980598277_9b1e927e59_c.jpg]
Reply
#4
I need to print the day HIGH / LOW for each day and the time it occurred. I can't find a way to retrieve the corresponding time using the groupby function.

Can someone please help ?
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020