Position size formula based on relative yield of SPY and IEF.

Hi All,

I’m trying to create a simple 2-ETF (SPY, IEF) portfolio that positions itself based on relative yield of SPY and treasuries. The position size formula I have is:
#SPYieldBlend/##UST5YRTicker(“SPY”) +##UST5YR/#SPYieldBlendTicker(“IEF”)

Buy and Sell rules are both TRUE and “Allow immediate buyback” is also TRUE.

Unfortunately this creates a simulated portfolio that does not change it’s weightings through time.

Any ideas?

Thanks
Malcolm

try using GetSeries

Smaug, I don’t think (but honestly, I have never tried) you can mathematically multiply a value times ‘Ticker’. I would guess that P123’s complier does not know how to parse that statement. P123 would know of course.
If you are trying to buy/sell SPY or IEF when certain conditions are true and false in a boolean fashion, then I would recommend you use EVAL statements in your buy/sell rules. I have used that for an allocator between SPY/IEF myself for some rules I came up with and it seems to work. But it only works in a true/false way, not in an incremental one.

Multiplying weight by ticker does work in the formula - some one had posted the technique and I have tried it
for example the following will work
70 * Ticker(“spy”)+ 30*Ticker(“IEI”)

It will work, meaning that it won’t throw an error, but probably it’s not doing what you’re thinking.

Ticker is looking at each stock/ETF’s ticker and then it will return a 1 if it’s true (it matches) and a zero if it’s not. So 70Ticker(“SPY”)+30Ticker(“IEI”) will return 70 for SPY, 30 for IEI and zero for everything else.

The way that we generally get a value on the site is with the Close function. I think that this is what you’re really looking for:

70*Close(0,GetSeries("SPY"))+30*Close(0,GetSeries("IEI"))

That will return a 70/30 mix of the prices of SPY and IEI.

Thank you both. I did not know that.

Thanks for the suggestions. It works with Close() rather than GetSeries():
Close(0, #SPYieldBlend)/Close(0, ##UST5YR)*Ticker(“SPY”) + Close(0, ##UST5YR)/Close(0, #SPYieldBlend)*Ticker(“IEF”)

This first iteration is a slight improvement over buy-and-hold, with a higher return in backtesting and lower drawdown. At the end of September, allocation to SPY was 79% and has now increased to 87%, so it seems to be doing what was intended.