Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Keep time within a range from DateTime

    Hi Everyone!

    I am writing my dissertation which is on "The Impact of Macroeconomic Announcements on Exchange Rate Volatility".
    My first set of data is a time-series 5-minute currency returns dataset spanning from 03/01/2016 to 12/30/2016 (MDY):

    . list in 1/15

    DateTime R_EURUSD R_GBPUSD R_EURGBP |

    1. | 01/03/2016 22:00:00 .1311489 -.0122156 .0908478 |
    2. | 01/03/2016 22:05:00 -.0128725 .067159 -.0996606 |
    3. | 01/03/2016 22:10:00 -.0321995 -.0250904 -.0020376 |
    4. | 01/03/2016 22:15:00 -.0009214 -.017639 .0189995 |
    5. | 01/03/2016 22:20:00 -.0059892 -.0074658 .0033791 |
    6. | 01/03/2016 22:25:00 .0114955 .0196783 -.0115282 |
    7. | 01/03/2016 22:30:00 .009213 -.002038 .0217053 |
    8. | 01/03/2016 22:35:00 -.0009213 -.0050871 .000679 |
    9. | 01/03/2016 22:40:00 -.0096628 -.004408 -.0027078 |
    10. | 01/03/2016 22:45:00 -.0115067 -.0050957 -.0135645 |
    11. | 01/03/2016 22:50:00 .0009215 .0020383 .0054163 |
    12. | 01/03/2016 22:55:00 -.0013822 -.018314 .0142427 |
    13. | 01/03/2016 23:00:00 -.1058711 -.006456 -.0936091 |
    14. | 01/03/2016 23:05:00 -.0018449 -.010858 .0108566 |
    15. | 01/03/2016 23:10:00 .0230149 .0010195 .0203589 |

    I have already Removed the Weekends and some Holidays, but I also need to remove the times from each day from 22:00:00 to 08:00:00 (Open and Close of the UK and US markets) to get the intraday return pattern for each day and consequently the average intraday return. I have attempted to get the Dates back into Strings, then split them and remove the times between the time described above, but this did not work.
    Is there a way in which I can remove the times within a range for each day?

    Best,

    Marc

  • #2
    Absolutely no need for, and no point in, converting back to string. The function hh() will extract hours from a date-time and you just need therefore to ignore results >=22 or < 8 (I would leave times 8:00:00 in the dataset.)

    Here is an immediate example.

    Code:
    . di  hh(clock("6 March 2019 05:00:00", "DMY hms"))
    5
    5 am this morning was (or in some cases will be) 5 hours after midnight.

    Comment


    • #3
      Thank you very much Nick!

      Solved it!

      Comment

      Working...
      X