Optimizing buying and selling point for a stock

1.1k Views Asked by At

I am working on a problem and I need help getting started. Any pointers would be greatly appreciate it

My problem: Given a $50,000 purse and 20/20 hindsight, and a particular stock, what are the best buying and selling points if the the only requirement is to maximize net profit. The stock is a daily chart going back 12 months and there can be as many or as little buying and selling.

Added Clarification:

Commission and slippage: 0.5% Minimum holding period: 2 days Shorts not allowed. No margin allowed.

How can I approach this problem? What algorithms can I use to solve this problem? At this point, I am looking for pointers to then google them or youtube them. I use Matlab.

Thanks a lot for your help.

2

There are 2 best solutions below

1
On BEST ANSWER

You can use dynamic programming for this. See http://en.wikipedia.org/wiki/Dynamic_programming. In the terminology of the section entitled "Dynamic programming in mathematical optimization", the decision step is whether to buy or sell at any given time. The state has three components: first, whether you hold the stock at the given moment, second, whether it has been less that two days since you bought the stock, and, third, if the first two components are true, how long it has been since you bought the stock. The gain from a decision is of course the gain from the transaction at that instant, if any. You'll have to pick some finite time interval to discretize the problem. Then just solve the Bellman equation, and take home your profits!

2
On

You want to own the stock any day it goes up and not on any day it goes down, assuming you are not worrying about commissions. So take the difference between today and tomorrow and use the sign of it to decide whether to buy or sell.