I used this code to extract the data from a CSV file, filter it and even organize it per minute, but I would like your help to create a cycle that allows me to update the information per minute, determining the maximum and the minimum value.
import pandas as pd
import datetime
datos = pd.read_csv('C:/Users/TECNOLOGIA/datos.csv', names=['LocalTime', 'Message', 'MarketTime', 'Symbol', 'Type', 'Price', 'Size', 'Source','Condition','Tick','Mmid','SubMarketId','Date'], usecols=['Type','MarketTime','Price'],index_col='Type')
df=pd.DataFrame(datos)
df=(df.loc['Type=0'])
"""Con el siguiente codigo se eliminan las letras de MarketTime y Price"""
df2 = pd.DataFrame()
df2['MarketTime']=df['MarketTime'].str.extract('((?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d)')
df2['Price']=df['Price'].str.extract('(\d+(?:\.\d+)?)')
"""Con el siguiente codigo se agrupa por minutos"""
df2['MarketTime']=pd.DatetimeIndex(df2['MarketTime'])
df2.set_index(keys='MarketTime', inplace=True)
inicio=datetime.time(11,18)
fin=datetime.time(11,19)
print(df2[['Price']].between_time(inicio,fin))
What I have not been able to do is make this a loop that allows me to determine the highest and lowest value of each minute of the file. This file is being updated constantly, it is important that the code take the new information.
The code generates this output: