Announcement

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

  • Trading Calendar and missing date for non-traded stocks

    Hi,

    I have a dataset with daily stock prices that only records a price if the stock was traded that day. I also have a file containing all trading days. I would like to combine the 2 datasets (I'm hesitant to say merge in this context...) in a way that I create missing price observations if the stock was not traded. How can I do that?

    Here is a sample:
    Code:
    trading_days
    02/01/2014
    03/01/2014
    06/01/2014
    07/01/2014
    08/01/2014
    09/01/2014
    10/01/2014
    13/01/2014
    14/01/2014
    15/01/2014
    16/01/2014
    17/01/2014
    20/01/2014
    21/01/2014
    22/01/2014
    23/01/2014
    24/01/2014
    28/01/2014
    29/01/2014
    30/01/2014
    31/01/2014
    03/02/2014
    04/02/2014
    05/02/2014
    06/02/2014
    07/02/2014
    10/02/2014
    11/02/2014
    12/02/2014
    13/02/2014
    14/02/2014
    17/02/2014
    18/02/2014
    19/02/2014
    20/02/2014
    21/02/2014
    24/02/2014
    25/02/2014
    26/02/2014
    27/02/2014
    28/02/2014
    Sample a stock for which dates are missing:
    Code:
    ticker    date    lasttradefortheday
    atp    02/01/2014    .064
    atp    06/01/2014    .067
    atp    08/01/2014    .062
    atp    10/01/2014    .064
    atp    13/01/2014    .064
    atp    14/01/2014    .065
    atp    15/01/2014    .059
    atp    17/01/2014    .059
    atp    20/01/2014    .066
    atp    21/01/2014    .065
    atp    22/01/2014    .065
    atp    23/01/2014    .062
    atp    24/01/2014    .059
    atp    28/01/2014    .059
    atp    29/01/2014    .06
    atp    30/01/2014    .06
    atp    31/01/2014    .06
    atp    03/02/2014    .058
    atp    04/02/2014    .06
    atp    05/02/2014    .06
    atp    06/02/2014    .06
    atp    07/02/2014    .06
    atp    10/02/2014    .06
    atp    12/02/2014    .06
    atp    13/02/2014    .06
    atp    14/02/2014    .06
    atp    17/02/2014    .06
    atp    18/02/2014    .06
    atp    20/02/2014    .059
    atp    24/02/2014    .063
    atp    25/02/2014    .061
    atp    26/02/2014    .062
    atp    27/02/2014    .065
    atp    28/02/2014    .063
    I have 100s of stocks. I'd need to create these missing obervations for each of them. Thanks!

  • #2
    Still thinking about that: Should I merge the trading calendar with every single stock through a loop, and then concatenate? Is there anything easier and more efficient? Thanks!

    Comment


    • #3
      Is there anyone that can help me "merging" the calendar with my dataset? Thank you in advance!

      Comment


      • #4
        Dear Francois,

        is this the same question as this one?

        If yes: Double or cross posting will not increase Statalisters' capability nor desire to answer your question.

        Please read the FAQ (also linked at the top of each page here) on how to post data examples (using -dataex-). I assume you did not receive an answer (yet) because most Statalist users do not fully understand your problem. At least this is the case for me: It remains unclear what the target data format you like to achieve looks like.

        Can you provide an example on how the destination data should look like? I assume the command you're looking for is -joinby-, but without understanding what you want to achieve it is hard to tell.

        Regards
        Bela

        Comment

        Working...
        X