Date: January 17, 2024

Topic: Statistics in Dataframes

Recall

Use dataframe operations to calculate statistics across the entire dataframe

Notes

Global Statistics


Split the data into windows, where we calculate the average across a time period and compare it to other data

Rolling Statistics

Untitled

Usage

Pandas (0.20)


<aside> ๐Ÿ“Œ SUMMARY: Dataframe allow us to calculate various statistics, and we can do global or rolling ones.

</aside>


Date: January 17, 2024

Topic: Analysis Tools

Recall

Bollinger bands are a form of technical analysis. If the price crosses the bands, then we might want to take action

Notes

Bollinger Bands

Untitled

Using in code

Untitled

  1. Compute rolling mean
  2. Compute rolling s.d.
  3. Compute upper and lower bands
# Rolling mean
rm = df.rolling(window=20).mean() # Average over 20 days

# Rolling s.d.
rstd = df.rolling(window=20).std()

# Get bands
upper_band = rm + 2*rstd
lower_band = rm - 2*rstd

# Plot the graphs
ax = df['SPY'].plot(title="Bollinger Bands", label='SPY')
rm.plot(label='Rolling mean', ax=ax)
upper_band.plot(label='upper band', ax=ax)
lower_band.plot(label='lower band', ax=ax)

Daily returns is another indicator on how a stock might be performing, with a positive daily return being better.



<aside> ๐Ÿ“Œ SUMMARY: We can use different indicators to help us see what a stockโ€™s performance is, like Bollinger bands, daily returns and cumulative returns

</aside>