@Jamie L., That question must be answered by your exploration of python. Python is easily the most misleading language out there. Return results from methods are never what they seem (initially). One looks at that equation:
z = ((closes - means) / sigmas)
and one thinks, "that z there is just a single number right?"
Your eyes will lie to you over and over while you learn what is truly being created and manipulated here. Below I take you through what is actually in that "z" object there. But to assist you (and myself) in understanding the objects in python I've recently been forcing myself to use this syntax with history:
closeDeck = history(15, "1d", "close_price").dropna(axis=1)
as it reminds me that what comes back from history is way more complex than just a list of prices. It's a massive data object akin, in my mind, to a deck of cards. The word "dataframe" means nothing to me so I use the word "deck" as I visualize what's in that object "closeDeck" as a deck of cards, each card having a table of rows and columns in which the close prices are represented; [one card per SID (security) found in the data object that the history method used to build the closeDeck.]
If you want just one of the cards (containing the close prices for just one security) then you have to ask the deck for just that one card.
closeDeck = history(15, "1d", "close_price").dropna(axis=1)
spyCard = closeDeck[context.SPY]
But that one card is still not what you want, read on...
In addition when you manipulate decks and ask decks for things like means and stddevs and such, you may not get back just single numbers, one for each card (depending on what you asked the desk). No, what you'll generally get back is another stack of cards and on each card is a series, in this case a two column table, datetime and "value".
sigmas = closeDeck.apply(talib.STDDEV, timeperiod = 14)
will give you another deck of cards and on each card is a series of datetime, values with each value being the standard deviation up to that point in time as calculated by the talib.STDDEV.
Therefore, this call
zScores = ((closeDeck - means) / sigmas)
if we look a the types used looks more like this:
dataframe = ((dataframe - dataframe) / dataframe)
or
zScoreDeck = ((closeDeck - meanDeck) / sigmaDeck)
And if you debug your code and stop and take a look at zScoreDeck after that equation you'll find that zScoreDeck is a deck of cards (a dataframe), with each card, one per security, containing a time Series of values, with ONLY THE LAST one being what you are thinking is the "Z" score.
Bottom line, in order to get this last value from that zScoreDeck, you need to ask both the deck for the card AND ask the card for its last value
lastSPYZScore = zScoreDeck[context.SPY].iloc[-1]
lastSPYZScore will be a single value that you can now plot.