PDA

View Full Version : Financial Mathematic : Bull & Bear ratio



Gaius Marius
2011-03-30, 01:20 PM
Hello everyone,

I am currently designing a nice little function in VBA to easily calculate bull and bear ratio for stream of returns of a manager and an index. However, I am the kind of guy who likes to program all eventuallities, and I hit a knot.

When the index's return is above 0%, the (1+%manager)/(1+%Index) ratio influences the Bull Ratio, while if it's below 0%, it'll influence the Bear ratio.

What happens if the index's return is EXACTLY 0%? If, for a period, the return give happens to be nil, but my manager is either + or - in %?


It's an unlikely occurance, but I need to cut the apple someplace, and I was hoping someone here would know.

DeadManSleeping
2011-03-30, 03:53 PM
http://2.bp.blogspot.com/_4MUf6T4VzPw/SlO_VH20d5I/AAAAAAAAKPU/8URvxjF0Vzk/s320/warcraft-tauren-bear-papercraft.jpg

Although I guess your code might have trouble returning that.

Telonius
2011-03-30, 03:55 PM
Hello everyone,

I am currently designing a nice little function in VBA to easily calculate bull and bear ratio for stream of returns of a manager and an index. However, I am the kind of guy who likes to program all eventuallities, and I hit a knot.

When the index's return is above 0%, the (1+%manager)/(1+%Index) ratio influences the Bull Ratio, while if it's below 0%, it'll influence the Bear ratio.

What happens if the index's return is EXACTLY 0%? If, for a period, the return give happens to be nil, but my manager is either + or - in %?


It's an unlikely occurance, but I need to cut the apple someplace, and I was hoping someone here would know.

Can you add in an additional function? Something like, "If the month is an even number, it's positive 1; if the month is an odd number, it's negative 1?" It won't be 100% accurate, but it would most likely even out over time, given enough of a sample.

Gaius Marius
2011-03-30, 04:22 PM
Can you add in an additional function? Something like, "If the month is an even number, it's positive 1; if the month is an odd number, it's negative 1?" It won't be 100% accurate, but it would most likely even out over time, given enough of a sample.

That's going to make it too random. I need a hard-fast rule, but I wonder if either way is appropriate. I'll have to check with our compliance department, apparently...

Thanks for the help, even if it was only a bear pic! :smallwink:

Spartacus
2011-03-31, 07:04 AM
I have absolutely no idea what bull and bear ratios are, but I like the fact that you program for every eventuality. In Java programming class in high school, when we made a little menu where you type 1 to do this, type 2 to do that, etc., I always programmed it so if you typed something it wasn't looking for (a number that wasn't in the menu, a letter, etc.) it would tell you to put in a valid number, instead of just crashing like the rest of the classes did.

I got 98% in that course :D

Gaius Marius
2011-03-31, 08:11 AM
I have absolutely no idea what bull and bear ratios are, but I like the fact that you program for every eventuality. In Java programming class in high school, when we made a little menu where you type 1 to do this, type 2 to do that, etc., I always programmed it so if you typed something it wasn't looking for (a number that wasn't in the menu, a letter, etc.) it would tell you to put in a valid number, instead of just crashing like the rest of the classes did.

I got 98% in that course :D

Well, I try to think of the classic error that might come up in the programming so the person using the function would know what's wrong.

But yhea, there is the default "something gone wrong, please call Gaius Marius or dig the VBA function if he left/lost his job" :smallbiggrin:

Valameer
2011-03-31, 08:56 AM
If the previous return was bull, consider the 0% a bull (don't pop the trend - yet). If the previous return was bear, then consider the 0% a bear. Simple enough?

I haven't programmed for years, but I hope ^that^ is a useful way to break apart the problem.

Edit: There's still a problem if the very first return is 0. In that case, just consider it bear and be on with it.

Douglas
2011-03-31, 09:51 AM
I have absolutely no idea what bull and bear ratios are, but I like the fact that you program for every eventuality. In Java programming class in high school, when we made a little menu where you type 1 to do this, type 2 to do that, etc., I always programmed it so if you typed something it wasn't looking for (a number that wasn't in the menu, a letter, etc.) it would tell you to put in a valid number, instead of just crashing like the rest of the classes did.

I got 98% in that course :D
I've heard of a teacher who would test student programs by mashing the keyboard at random. If the program couldn't handle that in some kind of sensible manner, the student's grade on the assignment would be penalized heavily even if it handled "correct" input perfectly.

BlackSheep
2011-03-31, 12:16 PM
I would either ignore the input entirely, or else define bullish as >= 0 or bearish as <= 0.

Spartacus
2011-03-31, 03:09 PM
I've heard of a teacher who would test student programs by mashing the keyboard at random. If the program couldn't handle that in some kind of sensible manner, the student's grade on the assignment would be penalized heavily even if it handled "correct" input perfectly.

Yeah, I've learned to take stuff as Strings and then parse as Int. If it cannot parse as an Int, I output a request for a proper input. If it does parse as an Int, I check to make sure the menu has an option for that number. If not, back to asking for a proper input. It seems to work well enough for simple menus, and other programs just go through a few other filters to make sure the string input actually works.

1nfinite zer0
2011-04-02, 08:09 PM
I was secretly hoping this thread was about some sort of esoteric fantasy farm needing advice on how to keep these two large mammal stocks co-operative
<.<
>.>

Form
2011-04-03, 04:10 AM
When the index's return is above 0%, the (1+%manager)/(1+%Index) ratio influences the Bull Ratio, while if it's below 0%, it'll influence the Bear ratio.


Erhm, if you allow %Index to be below zero, won't your program run into a 'divide by zero' problem at %Index=-1 if it includes a (1+%manager)/(1+%Index) factor?

Douglas
2011-04-03, 10:41 AM
Erhm, if you allow %Index to be below zero, won't your program run into a 'divide by zero' problem at %Index=-1 if it includes a (1+%manager)/(1+%Index) factor?
If %Index means what I think it does, that would only happen in an absolute TOTAL crash where the value of the index's stocks drops literally all the way to nothing. If that happens, we'll all have a lot more to worry about than one analysis program dividing by 0.