Hi, I'm new to Stata. Probably this question has already been answered, but I couldn't locate it.
I have a time series, 390 prices each day (1 min) of SPY (ETF). Dataset has the following columns:
1. date (same for each 390 minutes)
2. time (9:30 to 15:59) - 390 each date
3. spy (the closing minute price)
4. Also t, which is just observation number (gen t=_n)
I need to compute simple returns (d.spy/l.spy). I need to do it within each group (date), so that first minute return of the each day would be missing, because we can't compute it based on yesterday's closing price. I tried bysort date, but I'm doing something wrong, cos' it gives me the error 'not sorted':
. by date: generate spy_r = d.spy/l.spy
not sorted
. by date time: generate spy_r = d.spy/l.spy
not sorted
Thank you!
Yuri.
Related Posts with How to compute intraday stock returns
Significance testing bysorting weeks with two groupsDear all, I have a problem with the significance testing of my results. I want to apply non parametr…
Command for GRS test in STATARespected sir, I have time series data on 25 portfolios excess return (dependent variable) and 6 ind…
Aggregating data and creating Fixed Effects and 1-hour lags of quarticsHi! I am currently working on a research project aiming at evaluating the effect of a speed-limit r…
Performing PCA by groupDear all, I an trying to perform a PCA analysis by company on panel data. The goal is to create an…
Augmented dickey fuller test on residuals?Hello, I am writing my bachelor thesis trying to measure the effect of cryptocurrency 'forks' (fork …
Subscribe to:
Post Comments (Atom)
0 Response to How to compute intraday stock returns
Post a Comment