Coding question - Closed end funds with NAV's

Hi All. I’ve been active and inactive with amibroker over the years and now active again. I’m an intermediate level AFL programmer.

I like to look at Closed end funds. Closed end funds are mutual funds that trade throughout the day like securities. They have an associated NAV which is updated daily. Ticker of NAV is USUALLY by the formula: X+Ticker+X. So for example, the CEF PCI’s nav is XPCIX. We can code this in amibroker as the following:

Ticker = “X”+Name()+"X
and then whatever we want to do with Foreign(ticker,etc…)

The problem I am running into is that for some tickers, the names are exceptions. For example,
ADX --> NAV: XADEX
BXMX -> NAV: XBMXX
CHN -> NAV: XXCHNXX

I wanted to do this through a switch statement after checking for presence/Truth of the “X”+Name()+“X” ticker which I think can be done through a IF setforeign(Ticker)==0 (null).
However the Switch(CEF)
{
Case “ADX” : Ticker = “XADEX”;
Break

Default: Ticker = “X”+CEF+“X”;
}
is not possible as it switch/case doesn’t work with strings.

So to avoid a laundry list of IFF’s or If/Then statments, anyone know a better way to do this? In python it would be a dictionary, but I have no idea how to do that in AFL except maybe by using two watchlists - one for the CEF’s and the other for the NAV’s , and that seems more complicated than its worth to me.

Anyone see a more obvious answer I am missing? Thanks

Maybe you could use field Alias from Information
import all alias from ascii file and than retrieve it using function
GetFnData( “Alias” ).

1 Like

That’s actually a pretty useful idea. A lot easier than making 2 watchlists and using strextract on categorygetsymbols() arrays. Thanks. Hadn’t come across that one.

I wonder if AQ extended fundamental data download would overwrite this field or if it is held static. Worth finding out; not like yahoo’s Fundamental data is blowing anyone’s minds these days with its utility.

AmiQuote does not touch Alias field. Generally Alias is totally left for the user.

1 Like