Problems testing a stock trading strategy

dafunkyfalcon

New Member
Joined
Jul 7, 2011
Messages
6
Hi all!

First of all, I apologize if I'm unclear and for potential abuse of the English language.

I want to test a trading strategy called momentum where you buy/sell stocks based on their past performance. Using historical data, I'm supposed to "buy/sell" the previously best/worst 10% performing stocks, a procedure which is repeated each month. These portfolios are then held for a period whereafter I calculate the portfolio return.

Since the number of available stocks vary, I'm struggling to come up with a good method.

Do you have any suggestions as to how I can include 10% of the stocks into a portfolio when the number of stocks vary? I have to use integers, so rounding off to the closest integer is neccessary.

I hope you are able to understand my problem and that you can offer me some help.

Regards
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
im assuming you know how many stocks there are at any time, and have a method to work out a way of ranking them (average value change for instance)


psudocode:
Code:
dim x as integer
dim number of stocks as integer 
 
x = numberofStocks /10
 
{some code to buy the top x shares from your ranked list}
 
{some code to see if you have any of the bottom x from your ranked list, and to sell any you have}
<SOME top list ranked your from stocks x the purchace to function>

ZP<SOME stocks x the to function them sell then and own you bottom of which see other>
 
Last edited:
Upvote 0
Hi!

Thank you for your help. Yes, I know how many stocks there are and how to rank them. My biggest problem is finding a way of putting the best performing stocks into one portfolio and vice versa, when the total number varies. Another problem is that I'm a total novice when it comes to VBA.

Is it possible to create some sort of threshold that varies depending on the number of stocks? (In this case, <10% and >90%). And could the percentile function be of any use in this case?

Regards
 
Upvote 0

Forum statistics

Threads
1,224,596
Messages
6,179,807
Members
452,944
Latest member
2558216095

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top