My math skills are rusty(at best) and I was wondering if I could pick people's here brains on trying to figure out how to approach what I'm doing. My problem is a bit domain specific so I found a proxy problem that matches perfectly and hopefully is simpler to explain(just excuse any inaccuraties related to investing).
Say you have all the prices of all the stocks in the stock market, the percent change and your trying to research a specific return target(in percent). I then try to see how much percent of each stock returns equal the target percent. It works okay because each item is bound by 100(%) but because its alot of data I'm trying to see if there's a way to do it based on a value and not percent(say no stock can equal more than 50% of my basket of stocks then I cut processing down by half). I'm not sure how to convert the percent to value and get the same results.
Here's a example: stock market contains stocks with these returns: 10%,15%,30%, dollar values of 10,5,2(respectively), and we want to find all the ways to get 1% return.
10 * .10 = 1 10 * .07 + 15 * .02 = 1 10 * .04 + 15 * .04 = 1 10 * .01 + 15 * .06 = 1 10 * .07 + 30 * .01 = 1 10 * .04 + 15 * .02 + 30 * .01 = 1 10 * .01 + 15 * .04 + 30 * .01 = 1 10 * .04 + 30 * .02 = 1 10 * .01 + 15 * .02 + 30 * .02 = 1 10 * .01 + 30 * .03 = 1
This is a bad example because the highest percent of the value is .10 but it can go up to 100%. We would then take the percent of the returns(second column) and multiple it against the value of the stocks and figure out the weight of each stock in our basket. In our actual problem it seems to give the results we want but processing time is crazy when maybe we want no stock to exceed 10% but we have no way of knowing how much 10% of our basket will be without converting the above method into an actual basket.
Here's how the conversation part works(sorry copying from excel, might look ugly).
percent weight value weight weight overall a 10.00% 1 100.00% b c total 1 100.00% percent weight value weight weight overall a 1.00% 0.1 41.67% b 2.00% 0.1 41.67% c 2.00% 0.04 16.67% total 0.24 100.00%
Just to recap, steps are:
- figure out how much percent of returns are needed to meet target percent
- convert percent of percent returns to actual values by multiplying against actual values
- using actual values figure out weight and discard ones that exceed our specific threshold
Is it possible to somehow normalize the initial return & target percent so I can derive the same result but from the value itself without having to go through the 100 possibles per item(100%) when we may really only care about a 20% threshold per value of item? Doing it the current way does not seem possible since what its saying its 'you need x% of this stocks return' and then we have to convert to see how much that equals to in a basket. As I mentioned above, we are checking AFTER which to me is a waste of cpu power, I want to see if we can know before hand and not pursue results that we don't need.
I hope I explained it correctly but if there's any confusion please let me know. Thanks!
p.s. for the last two days I've been in python/excel trying to figure this out, my idea was to take the percents and multiply them against a base value(say 100) and try to convert it to the value but I'm having trouble because the above calculation are derived from percents of returns and target. I haven't had any success. There's a few problems with converting, how can I get the same results if I do not know the total in advance(when converting, I'm multiplying my new generated percent against the values then weighting the sum to get the individual weights)?