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:
Sample a stock for which dates are missing:
I have 100s of stocks. I'd need to create these missing obervations for each of them. Thanks!
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
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
Comment