# Labeling Returns in 5 categories based on BL view approach

I have to label a time series of returns into 5 categories based on the Black Litterman view approach.

The categories should look as follows:

• very bullish: + 2 std. dev.
• bullish: + 1 std. dev.
• neutral: near 0 std. dev.
• bearish: -1 std. dev.
• very bearish: -2 std. dev.

I also have generated the past vola time series, but now I can not find any scheme to apply to get to these categorical labeling accoring to BL.

Does anyone have an idea how to approach this in python? The code blow does not work properly and output is 0. Am I missing something?

zscore = (data["Returns"] - data["Returns"].mean()) / data["vola_ind"]

#defining limits
oneposSD = data["Returns"].mean() + 1 * data["Returns"].std()
twoposSD = data["Returns"].mean() + 2 * data["Returns"].std()
neuposSD = data["Returns"].mean() + 0.1 * data["Returns"].std()
onenegSD = data["Returns"].mean() - 1 * data["Returns"].std()
twonegSD = data["Returns"].mean() - 1 * data["Returns"].std()
neunegSD = data["Returns"].mean() - 0.1 * data["Returns"].std()

#looping over data
for i in zscore:
if i > twoposSD:
data["Pred"] = 3.0
elif i > oneposSD:
data["Pred"] = 2.0
elif i > neuposSD:
data["Pred"] = 1.0
elif i > neunegSD:
data["Pred"] = 0.0
elif i > onenegSD:
data["Pred"] = -1.0
elif i > twonegSD:
data["Pred"] = -2.0
elif i < twonegSD:
data["Pred"] = -3.0

• What is your expected answer? A code template? And what difference do you have in mind between the BL view and the 5 categories you propose? – Vitomir Jul 12 '19 at 9:56
• I want to implement this in python and that I get from a return time series to a list of ordinal numbers {-2, -1, 0, +1, +2} based on the standard deviation limits. Is there an efficient way or function? I hope it is a little bit clearer. I only can provide a list of returns which I want to transform. – smartquant Jul 12 '19 at 12:43
• Calculate standard deviations of returns. Then implement an elif statement with 5 mutually exclusively outcomes as you have described. – Vitomir Jul 12 '19 at 14:46