Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7701317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:57:17+00:00 2026-05-31T22:57:17+00:00

Summary Below is the full question (a bit complicated in its full form) here’s

  • 0

Summary

Below is the full question (a bit complicated in its full form) here’s a super simplified version (which is the heart of what I’m asking). If I told you to give me the weights of 49 and 17, you would take 66 (49+17) and divide each number by 66 (49/66=74% and 17/66=26%). My question is, if I added a negative number -27 to the above numbers, how would you weight them (if I couldn’t use a negative weight)?

I somehow need to represent the negative number in the overall weight but the negative weight is throwing my numbers off. 39(49 + 17 + -27), causes 39/39=1.25%, 17/39=44%, and -27/39=-69%. So in the example below, if this were stocks and I gave you $100 how would you know how much to buy?

Detailed question

I’m having a bit of trouble figuring out an algorithm (or the logic how to do this).

Stock       percent of return              Return
Blue        .98                            50       
Red         .85                            20       
Black       .90                           -30      

It’s basically providing us with a report saying we want .98% of the return of 50%, 85% of the return from 20% and 90% of the returns from -30 (the total in this case is 39%). I’m unsure how to translate this into an actual portfolio (like how much to buy to get this amount if I do not hold the fund already)?

I’m starting to feel this is not possible, but I’m basically asking if I gave you the above table (name,return and % of return I want to capture) and $100 how can you make that portfolio? If I only gave you one stock that was 50% and said I wanted 100% of its returns you could easily just buy $100 of that single stock.With two stocks you could add the total returns/weights and get the weight but how do you deal with negative returns you want to capture?

I don’t think I’m getting this right but here’s my logic so far (If this is totally wrong, please ignore and suggest anything you like).

Get list of data
total_return = multiple percent_of_return and return (do this as a recursion for all stocks in the list)
take total of all items in total_return (using absolute numbers..no negatives so above 39 equals 42) and figure out the weight of each from that.
multiply these weights by stock price and divide by total to give weight.

The result of this is (note:the total changed from 39% to 93%):

Blue 0.52688172
red 0.182795699
black 0.290322581

The problem, which I’m really unsure if is converting a negative weight into a absolute (positive) weight. I’m not good with math (and worst with finance) but I’m unsure how to ‘buy’ a percent of negative returns (the two data points I’m given, but I can enrich it with other data if needed like stock price, etc.). Also, just to make it clear, I do not own these portfolios already so I can’t just take these weights against an existing portfolios, I am using the above information as guidance to create a new one (just need to figure out an algo to do that).

Update

I always learn from code so here’s my code (in Python) and some test cases (it’s horribly ugly as I’m prototyping just to understand the logic of how to do this):

overall_total_value = []
def test(data_return, datacoeff, data_value):
    total_results = 0
    data_total_of_return = {}
    for x in data_return:
        current_value = data_return[x] * (datacoeff[x]*.001)
        data_total_of_return[x] = current_value
        total_results = total_results + current_value

    #abs
    abs_total_value = 0
    for x in data_total_of_return:
        #print x, '=', abs(data_total_of_return[x])
        abs_total_value = abs_total_value + abs(data_total_of_return[x])
    
    print abs_total_value
    weight = {}
    for x in data_total_of_return:
        weight[x] = abs(data_total_of_return[x]/abs_total_value)
    
    total_value = 0
    for x in weight:
        valuer = weight[x] * data_value[x]
        print x, weight[x], '=', valuer
        total_value = total_value + valuer
    
    print 'ABS total % return: ',total_results
    print total_value
    overall_total_value.append(total_value)
    
    print "*"*30
    
    
data_return = {'Blue':50, 'Red':20, 'Black':-30}
data_value = {'Blue':10.4, 'Red':4, 'Black':8}

datacoeff = { "Blue": 78 , "Red": 0 , "Black": 0 , }
test(data_return, datacoeff, data_value)
datacoeff = { "Blue": 48 , "Red": 75 , "Black": 0 , }
test(data_return, datacoeff, data_value)
datacoeff = { "Blue": 46 , "Red": 80 , "Black": 0 , }
test(data_return, datacoeff, data_value)
datacoeff = { "Blue": 38 , "Red": 100 , "Black": 0 , }
test(data_return, datacoeff, data_value)
datacoeff = { "Blue": 62 , "Red": 100 , "Black": 40 , }
test(data_return, datacoeff, data_value)
datacoeff = { "Blue": 100 , "Red": 20 , "Black": 50 , }
test(data_return, datacoeff, data_value)
datacoeff = { "Blue": 98 , "Red": 55 , "Black": 70 , }
test(data_return, datacoeff, data_value)
datacoeff = { "Blue": 90 , "Red": 75 , "Black": 70 , }
test(data_return, datacoeff, data_value)
datacoeff = { "Blue": 100 , "Red": 65 , "Black": 80 , }
test(data_return, datacoeff, data_value)
datacoeff = { "Blue": 98 , "Red": 70 , "Black": 80 , }
test(data_return, datacoeff, data_value)
datacoeff = { "Blue": 96 , "Red": 75 , "Black": 80 , }
test(data_return, datacoeff, data_value)
datacoeff = { "Blue": 94 , "Red": 80 , "Black": 80 , }
test(data_return, datacoeff, data_value)
datacoeff = { "Blue": 92 , "Red": 85 , "Black": 80 , }
test(data_return, datacoeff, data_value)
datacoeff = { "Blue": 90 , "Red": 90 , "Black": 80 , }
test(data_return, datacoeff, data_value)
datacoeff = { "Blue": 88 , "Red": 95 , "Black": 80 , }
test(data_return, datacoeff, data_value)
test(data_return, datacoeff, data_value)
datacoeff = { "Blue": 98 , "Red": 100 , "Black": 100 , }
test(data_return, datacoeff, data_value)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T22:57:18+00:00Added an answer on May 31, 2026 at 10:57 pm

    You are getting this all wrong in my opinion (or there’s some confusion in your data).
    I assume that the return column is something you don’t have in advance, otherwise you could engage in arbitrage, which is nonsense.
    Basic theory: some stocks have positive beta coefficients (they go with the market), others have negative beta coefficients (they go against the market). In the situation you have proposed the first two stocks have (probably) a beta coefficient with the same sign and the remaining one a beta coefficient of the opposite sign. Therefore, since you are trying to reduce your losses it’s normal for one of your stocks to have negative returns, as the loss is offset by the gains in the other two stocks.

    Let’s assume for sake of simplicity that you are trying to invest 100$.

    You want to get .98 of the returns of the first stock (whatever they are).

    You want to get .85 of the returns of the second stock (whatever they are).

    You want to get .90 of the returns of the third stock (whatever they are).

    Now let’s normalize the desired returns so that they sum to 1 (and by maintaining the proportions!).

    For each $ in your portfolio you want to buy:

    .98/(.98+.85+.90) = 0.358974358974359$ of the first stock

    .85/(.98+.85+.90) = 0.31135531135531136$ of the second stock

    .90/(.98+.85+.90) = 0.32967032967032966$ of the third stock

    Therefore considering your endowment of 100$ and assuming that you can freely buy portions of stocks you’ll invest respectively:

    $35.90, $31.14, $32.96

    And finally, (and this is not the case!) whenever you find a minus sign in the desired returns (first column) it actually means that you’re short selling that stock (i.e. borrowing the underlying asset to sell it in the future at a -hopefully- higher price).

    >>> desired_returns = [.98,.85,.9]
    >>> real_weights = [i/sum([abs(j) for j in desired_returns]) for i in desired_returns]
    >>> real_weights
    [0.358974358974359, 0.31135531135531136, 0.32967032967032966]
    >>> cash_available=100
    >>> labels=['blue','red','green']
    >>> for i in range(len(desired_returns)):
    ...     if desired_returns[i]>=0:
    ...          print "Buy %s$ of the stock %s" % (cash_available*real_weights[i],labels[i])
    ...     else:
    ...           print "Short sell %s$ of the stock %s" % (abs(cash_available*real_weights[i]),labels[i])
    Buy 35.8974358974$ of the stock blue
    Buy 31.1355311355$ of the stock red
    Buy 32.967032967$ of the stock green
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Summary of my question: Does NSURLConnection retain its delegate? Detailed question and scenario: I
Author post-edit: Chosen solution (Original question remains below this box) SUMMARY: You SHOULD NOT
I have the following problem: here it is...output summary is below. Output Summary: Test
Question summary: How do I modify the code below so that untrusted, dynamically-loaded code
Summary So I have 3 tables, which I have screenshots below. Every user will
http://jsfiddle.net/FS4zT/ If you visit the above link you see what am describing below. Summary:
I have a performance bottleneck on a DataView.Sort. The code is below. /// <summary>
Summary: How should the UIViewController know the size of its UIView instance when initialising
Summary: I periodically get a .NET Fatal Execution Engine Error on an application which
EDIT 3: I am maintaining the original question below for historical reasons. However, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.