I am looking for a formula to calculate the weights of two risky assets that produce the optimal portfolio (i.e highest Sharpe ratio). So far I have found the following formula from a website of University of Missouri However, this formula often produces negative weights. For example, it returns a weight of -24% for Asset A when Risk Free Rate=3%, Ra=5%, STDEVa=15%, Rb=10%, STDEVb=20%, CORRab=50%. It is probably because it allows short selling, making it not applicable in my situation. I need to find non-negative weights. Does anyone know a formula for non-negative weights for a two-asset optimal portfolio that does not allow short selling? Thanks.