I currently use the resample function to lower the data frequency, as shown in the following script:
def agg_k_longer(ticker){
klday get_adjust_klday(ticker)
rule = "W"
return select
indexedSeries(date,date).resample(rule,last) as date,
indexedSeries(date,code).resample(rule,last) as code,
indexedSeries(date,open).resample(rule,first) as open,
indexedSeries(date,high).resample(rule,max) as high,
indexedSeries(date,low).resample(rule,min) as low,
indexedSeries(date,close).resample(rule,last) as close,
indexedSeries(date,volume).resample(rule,sum) as volume,
indexedseries(date amount).resample(rule,sum) as amount
from k1daycontext by code
}
agg_k_1 onger(`600519.SH`300750.SZ)
Is there a better way?
The
intervalfunction can be used for ordinary upsampling and downsampling, but the time unit 'w' of the parameter duration can only group data by 7 days. To modify data frequency based on the rule of 'weekEnd', you can use thetransFreqfunction as shown in the following script: