1.19 Order-based computation: filter by comparing with the next row
Get records whose closing prices are increased by 3% based on the following stock transaction table.
Date | Open | Close | Amount |
---|---|---|---|
2019/12/31 | 3036.3858 | 3050.124 | 2.27E11 |
2019/12/30 | 2998.1689 | 3040.0239 | 2.67E11 |
2019/12/27 | 3006.8517 | 3005.0355 | 2.58E11 |
2019/12/26 | 2981.2485 | 3007.3546 | 1.96E11 |
2019/12/25 | 2980.4276 | 2981.8805 | 1.9E11 |
… | … | … | … |
To do this, we need to compare the closing price of the current row with that of the previous row.
SPL script:
A | |
---|---|
1 | =T(“000001.csv”) |
2 | =A1.select(year(Date)==2019).sort(Date) |
3 | =A2.select(Close/Close[-1]>1.03) |
A1 Import the original data file;
A2 Select records of the year 2019 and sort them by date;
A3 Get records whose closing prices are increased by 3%. Close[-1] represents the Close field value in the previous record.
SPL Official Website 👉 https://www.scudata.com
SPL Feedback and Help 👉 https://www.reddit.com/r/esProc_SPL
SPL Learning Material 👉 https://c.scudata.com
SPL Source Code and Package 👉 https://github.com/SPLWare/esProc
Discord 👉 https://discord.gg/cFTcUNs7
Youtube 👉 https://www.youtube.com/@esProc_SPL