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
Measuring Overeducation with Marsh CPS DataDear all, i'm trying to compute the level of education to occupation mismatch for the individuals …
Understanding interactions between 2 multi-categorical variablesDear community, In an experiment I conducted where i implemented different gamification strategies …
Hypothesis testingIm having trouble calculating the p value for paired values this is the question I am using two va…
Plotting results from nonlinear effectsI am looking at how my outcome y evolves over time assuming such evolution may differ by x (binary).…
Creating table with results from regressionsHello! I'm a student working on my master thesis and not very familiar with STATA's advanced syntax.…
Subscribe to:
Post Comments (Atom)
0 Response to How to compute intraday stock returns
Post a Comment