ohlc

Pandas: find nearest higher high (OHLC)

非 Y 不嫁゛ 提交于 2021-01-28 09:07:27
问题 I'm trying to find the fastest solution to iterate over each row of Open High Low Close data and count out how many rows exist between the current row's high and the next high that’s greater than or equal to the original. Here is a shortened code example which I think explains it well (I'd be trying to find the final value of _next ): for i in df.index: while df.loc[i, 'high'] > df.loc[_next, 'high']: _next += 1 I think I need to use a lambda function inside apply but I can't seem to get it

select max and min values every x amount of rows-postgresql

戏子无情 提交于 2020-05-17 08:51:06
问题 I'm trying to create OHLC bars in postgresql starting from tick data. I want to create bars every 1000 ticks or every 500 ticks. Or every X amount of ticks. The database I'm saving has the bid/ask and a timestamp. I know that I could do a groupby and group them by timestamp, but the desired output is using the amount of ticks. One tick is composed by a timestamp, a bid price and an ask price. The tick database looks something like this: ------------------------------------------------- | date