I need your opinions on how to solve this matter
I have a small data subset from a large data set.
My subset and my original data set follow this format:
here it is written out:
Stock Date Price
Pfizer 18-Aug-2009 18.8
Yahoo 19-Aug-2012 27.1
Facebook 20-Aug-2014 77.14
Amazon 21-Aug-2014 683.66
Merck 22-Aug-2005 22.9
Ford 23-Aug-2003 20.1
Let’s say my subset, is a set that I specifically selected.
I want to take this subset and let’s name it (MoneyFA). I want to set the prices in the MoneyFA to be T0. And let’s say the highest price in the previous year is T-1, and the year before that is t-2. And the price the year after is T1, and the year after is T2.
Now, how do I program a program that takes my subset which has variable dates and then it starts searching against the main data set (which has tons of data and let's name it Moneypool) for T values. And let say our window is 10 years before and 10 years after T0. (Keep in mind, a year might have several prices in the main data set for a certain company. We need it to select the highest price in that year)
I want it to give me a table or matrix similar to this (if there’s no value in the main data set, it could be kept empty or NA) :
Here it is written out:
Stock T-10 T-9 T-8 T-7 T-6 T-5 T-4 T-3 T-2 T-1 T0 T+1 T+2 T+3 T+4 T+5 T+6 T+7 T+8 T+9 T+10
Pfizer 37.12 24.9 19.23 27.01 21.05 17.12 19.88 17.9 18.8 20.91 23.4 24.9
Yahoo 9.8 18.9 19.7 12.5 22.6 15.8 27.1
Facebook 35.86 49.62 63.38 77.14 90.9
Amazon 208.9 533.42 558.46 600.2 608.54 700.1 658.62 683.66 708.7 733.74 809.11
Merck 41.1 39.28 37.46 35.64 33.82 32 30.18 28.36 26.54 38.7 22.9 21.08 29.8
Ford 66.1 61.5 56.9 52.3 47.7 43.1 38.5 33.9 29.3 24.7 20.1 15.5 10.9 6.3 1.7 4.2 7.3 8.9 10.5 12.1 11.8