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
Question about the command --localp-- @Nick CoxNick Cox Dear Nick, I have a question about your command --localp--.I want to plot two graphs in one…
Proper treatment of the variables that have unit root when System GMM is usedDear everyone, I have a doubt with respect to the need of first differencing the variables cointain…
Creating a wave identifier - observations wrongly mappedHello, I am quite new to Stata and this is my first post and I would really appreciate any help. I …
Calculate the median and store it as an scalar.Good morning, I would like to calculate the median of a variable, let's call X and after store that…
Suest command: unable to generate scores error with different regression modelsDear all, I have a following problem. Firstly, I am calculating 2 regressions for for two groups of…
Subscribe to:
Post Comments (Atom)
0 Response to How to compute intraday stock returns
Post a Comment