• Thanks for posting this. It's a blast from the past for me because I was tasked with doing the same about 20 years ago and all I had to work with was C-language. Relational databases at that time were not suitable for such work. As I recall my exercise also involved taking it a step further and attempting to optimize asset weighting so asto minimize portfolio variance for a required rate of return. In any event, SQL is way way more efficient approach to doing this stuff, at least from the programming standpoint, and you demonstrated that.