Quantitative Finance Stack Exchange is a question and answer site for finance professionals and academics. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Let's say we have a stock which our only actions are buy, sell and hold (with or without shorting).

If we have sufficient past data of the stock, how can you determine the optimal trading action every time-stamp in the past in an efficient or even optimal way? Transaction costs, bid-ask spread and slippage would definitely have to be included.

I can think of this as a black-box optimization problem, but the search space is large, so the search would be inefficient.

I tried to search the literature for pointers, but nothing came out of it. Has anyone researched good ways to do this?

share|improve this question
You're kidding, right? – Dan Bron Jun 3 '14 at 23:24
@DanBron This isn't a silly question, as it's not as simple as finding the local min/max. – user2763361 Jun 4 '14 at 7:41
Dan, if it is so easy, why don't you make it clear? Indeed, if we had no kind of transaction costs, it would be something like buying at local minimums and selling at local maximums. With transaction costs it's a little bit more complicated. And then if you think that not all profitable trades were good actions (due to risk and volatility), you have a really hard problem! – Pedro Tabacof Jun 4 '14 at 13:52
You need to clarify the question. You could mean two things. (1) How do you determine what would have worked best if you had know the price path in advance, given some model of slippage and transaction costs, etc, or: (2) How do I use this information in research to determine a good strategy for the future. (1) is an interesting question, (2) does not belong here. – user2763361 Jun 4 '14 at 14:34
My question is definitely (1). – Pedro Tabacof Jun 4 '14 at 14:54
up vote 1 down vote accepted

The specific procedure depends on details of the problem such as

  1. What is the objective function? Sharpe ratio? Terminal wealth?
  2. What is the model of transaction costs?
  3. What is the data resolution? (If it's very high the problem may become challenging computationally).

There are many papers, e.g. this one, that solve various problems of this sort. These are most certainly not black-box optimization problems. There are specific, and well-motivated objective functions, constraints, and dynamics. You should understand that, in general, the size of the search space is not a good guide as to whether the problem can be solved efficiently or not. Brute force exhaustive search is almost never utilized for non-trivial optimization problems. It is often the case that a problem over an infinite set (e.g a linear program) is much easier than a problem over a finite set (e.g. an integer program).

share|improve this answer

I think what you're trying to do is to construct a portfolio from inside out, i.e. picking stocks based on idiosyncratic factors. I have never heard anyone (within the industry) succeed with this, and, to my knowledge, the literature in this direction is pretty slim.

The main reason is that in finance, the Markowitz approach is dominant to this day. Put simply, because a portfolio holds a variety of stocks, you always have to consider how they interact, that is, consider their correlation. As volatility is not additive (partly due to correlation), you should not invest in stocks by looking at them individually, but consider the entire portfolio. If a stock is negatively correlated with another, their movements will cancel out, so if your knowledge of the future is incomplete, it will enhance the portfolio as a whole.

The closest thing to what you intend would probably be fundamental analysis, but the research does not show consistent outperformance afaik. Alternatively, look into smart beta asset allocation, which considers underlying risk factors for portfolio consruction.

share|improve this answer

you can smooth your data and then find the zeros of the slope of the smoothed data. You can adjust for the costs with the degree of smoothing.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.