Hi.I am very new to Q, and am working on some challenges that have beenset for me by my instructor.I am stuck on the final task, which requires me to follow a stockmarket index, and work out the daily returns as if investing in eachstock. So essentially I have a table keyed by date and by stock symbolwith closing prices as well as weightings, etc.The problem is is that on occasion a symbol in the index gets switchedout, meaning that although at any one time there are 30 constituentsin the index, there are overall 33 distinct symbols. If a switchoccurs I am meant to close the position in the index, and “re-buy” atthe opening price on that day. Additionally, if the weighting or sharecount changes I need to do the same.I originally used C++ and to me this begs to use a loop, but i don’tthink this is the “Q way”. I was wondering if anyone has any ideas ofhow to approach this? One idea I had was to have a separate errorcolumn, which would be true if a change had appeared, and falseotherwise.I would appreciate any help.
Related topics
Topic | Replies | Views | Activity | |
---|---|---|---|---|
looping in Q KDB | 11 | 0 | February 25, 2014 | |
kdb equivalent of pandas groupby | 2 | 0 | November 22, 2021 | |
using sub-processes to work around 32-bit limit | 1 | 0 | January 12, 2015 | |
Re: [personal kdb+] Moving weigthed average in q | 1 | 0 | September 11, 2012 | |
help on update | 2 | 0 | March 18, 2013 |