NoDays not working properly?

Hopefully this is just a mistake on my part but I’ve been running into problems on a weekly sim with the following sell rule:

NoDays > 365 & Rank < 101

Intention is to hold the target stocks for a year and then rebalance (I plan to add timing rules as well to exit the market under certain conditions but haven’t put any of those on yet). Unfortunately when I run the sim it sells all the stocks at the first weekly rebalance (doesn’t seem like the NoDays rule is working at all). Any ideas?

David

As an additional note I do not seem to encounter the same problem with NoBars.

Hi David,

there is no issue with this combination. The only exception is when:

  • the rank is not available
  • merger is not allowed in your sim
    (see below example).

Furthermore, this rule would also not work if you use a sim with intermittent hedge and the hedge kicks in before the 365 days.

hth,
Florian


I’ve seen people use Rank<101 to mean true. I would note two things: First, if you just use:

True

it does the same thing.

And in this case

NoDays > 365 & Rank < 101

should be exactly equivalent to

NoDays > 365

I bring this up because when you’re trying to figure out why something isn’t working right, removing unnecessary moving parts is only going to help.

As Florian noted, if Rank returns NA funny things happen.

The ‘<’ test returns NA which makes sense. But NA anded with NA, True or False returns 0 (i.e. False).

It’s a bit surprising that True & NA returns 0 (i.e. False). I was expecting NA. Of course, that just delays the question of whether NA should be considered True or False within the Sell rules.

Walter

EDIT: Rank returning NA doesn’t seem to the root cause of the problem described in the OP.

David , my quick test worked. Which sim? Thanks

Hi Marco - thanks for looking into it - for whatever reason when I tried to put the sim back and reproduce the problem tonight I couldn’t. So may have just been an error on my part - I’ll let you know if I run into it again.

Florian, Walter interesting point on the merger / NA detail - I don’t think that was a factor in my case but good thing to keep in mind.

I guess that’s another reason to exclude the (mostly) redundant Rank < 101 as Paul points out. :slight_smile:

Thanks,

David