n = 100000
date = take(2019.11.07 2019.11.08, n)
time = (09:30:00.000 + rand(2*60*60*1000, n/2)).sort!() join (13:00:00.000 + rand(2*60*60*1000, n/2)).sort!()
timestamp = concatDateTime(date, time)
price = 100+cumsum(rand(0.02, n)-0.01)
volume = rand(1000, n)
symbol = rand(`600519`000001`600000`601766, n)
trade = table(symbol, timestamp, price, volume).sortBy!(`symbol`timestamp)
select
min,
close,
ratios(close) - 1 as pct_change
from (
select last(price) as close
from trade group by bar(timestamp, 1m) as min
)
min close pct_change
----------------------- ------------------- ------------------
2019.11.07T09:30:00.000 100.07555613060947
2019.11.07T09:31:00.000 99.91424092340749 -0.001611934156943
2019.11.07T09:32:00.000 99.881479845819995 -0.000327891973003
2019.11.07T09:33:00.000 99.969592652334824 0.000882173618681