# Gradient Descent With Constraints

I'm playing around with some historical stock data and attempting to optimize a portfolio.

I essentially have created a function that generates certain statistics about a portfolio (right now it's composed of a list of equities with corresponding weights). The portfolio is constant and tracked over a historical time range to arrive at some statistics regarding its performance (sharpe ratio, sortini, etc).

Given that the function that generates the Sharpe ratio isn't really smooth, I've decided to approximate the gradient in order to maximize the Sharpe ratio given input weights subject to the constraint that they add up to 1.

What would be the best way to go about doing this? Is this even feasible for this kind of data?

• Welcome to CS.SE! I don't understand your problem. What are you trying to achieve? What is your goal? What are the inputs, and what is the desired output? It sounds like you're trying to maximize some function $f(x_1,\dots,x_n)$, subject to the constraint that $x_1+\dots + x_n=1$. Is that right? If so, what can you tell us about the properties of $f$? Can you give us a formula for $f$? Can you describe its structure or characterize it somehow? Without knowing anything about $f$, it's hard to know what to suggest. – D.W. Jul 1 '17 at 6:15
• Thanks @D.W. The formula for $f$ is dependent on the securities within the input portfolio, as well as their historical performance. – turnt Jul 1 '17 at 17:12
• OK, but that's not really what I was asking. I'm not asking what it depends on; I'm asking how it depends on the inputs $x_1,\dots,x_n$ -- and I was asking how it depends on the weights (which apparently are the values we're free to choose, to make the output as large as possible). Is it continuous? Differentiable? Locally linear? Convex? etc. Also, how large is $n$? (How many input weights are there?) The more information you can give us, the more likely that we can help you. – D.W. Jul 2 '17 at 2:29
• Also, what exactly is your uncertainty? It sounds like you have the idea of trying gradient descent. Have you tried it? What happened? Did it work? Why did you reject that approach? When you say "the best way to go about doing this", what do you mean by "this"? "This" might mean "doing gradient descent" or "approximating the gradient" or any number of other things -- it's hard for me to tell. – D.W. Jul 2 '17 at 2:29