参考代码如下
根据context by,rank的组合去实现
n = 40 date = take(2019.11.07, n) time = (09:30:00.000 + rand(int(6.5*60*60*1000), n)).sort!() timestamp = concatDateTime(date, time) price = 100+cumsum(rand(0.02, n)-0.01) volume = rand(1000, n) symbol = rand(`AAPL`FB`AMZN`MSFT, n) trade = table(symbol, date, time, timestamp, price, volume).sortBy!(`symbol`timestamp) select max(price),atImax(price,timestamp) as max_buyprice01,rank(timestamp,percent=true) as rank1,rank(timestamp,percent=false) as rank2,count(timestamp) from trade as t context by symbol,date