Midterm Flashcards
(102 cards)
What are Bollinger Bands?
+/- 2 sigma from the rolling mean. When you see excursions outside of these limits it may be a buy or sell signal. Specifically, when you break through and then come back within that limit. Outside to inside, back toward the moving avg.
What are Daily Returns and how do you calculate it?
One of the most important stats.
( price[t] / price[t-1] ) - 1
It’s a percentage return for each day.
Most revealing when comparing daily returns against multiple stocks.
What are cumulative returns?
Total % change in stock from the beginning to some point in time.
cum_return[t] = (price[t] / price[0]) - 1
(todays price / price at the beginning) - 1
What methods are there to fill in missing data?
- Fill forward. Use the last known value and fill it forward until the next known value. At the beginning, fill backwards. (fill forward first, fill backward second)
- We do this because interpolating would be like peeking into the future.
- So the process is always fill forward first, and then fill backwards.
What type of distribution do stocks typically show?
A gaussian distribution.
What is kurtosis and how is it useful?
It’s a comparison of your distribution of data to a gaussian distribution. A positive value indicates that your tails are ‘fat’, meaning higher than a normal gaussian would look like. Negative kurtosis would indicate fewer excursions at the tails.
Summary:
- Positive value: fat tails
- Negative value: skinny tails
What is alpha and beta (with respect to a linear line fit of scatterplot data)?
Beta - slope - how reactive is the stock?
Alpha - y-intercept. > 0 means stock on Y axis is doing better than stock on X axis, generally.
This is generally compared to SPY, or ‘the market’, but it can be compared against any other stock.
How does the slope (beta) correlate two stocks?
It doesn’t! Slope is just the slope. Correlation is a measure of how tightly the data fits the line (like an R squared value)
How do you calculate your portfolio value?
- Start with DF with rows = days and columns = ticker
- DF = DF / DF[0] -> normalize each column. First row is now 1.0 for each column
- DF = DF * alloc -> multiple each col by it’s allocation. First row is now allocation
- DF = DF * Start value -> This gives the value of each stock on each day, based on the allocation (position values)
- df.sum(axis = 1) - Gives total portfolio value each day
What are the four key stats for a portfolio?
They are based on the daily returns (don’t forget to remove the first row after calc daily returns b/c it’s 0!)
- Cumulative return
- Avg Daily Return
- Std Daily Return
- Sharp Ratio
How do you calculate the avg daily return?
daily returns.mean()
How do you calculate the std daily return?
daily returns.std()
What is and how do you calculate the sharp ratio?
A metric that adjusts return for risk (eg, volatility). All else being equal:
- lower risk is better
- higher return is better
A higher sharpe ratio is better.
Sharp ratio also considers risk free rate of return: interest rate on your money in a risk free asset like bank account or short term treasury bonds.
Expected(Portfolio Return - Risk Free Return) / std(portfolio - risk)
mean(daily_returns - daily_risk_free) / std(daily_returns - daily_risk_free)
B/c the daily_risk_free shortcut evaluates to a constant, you can remove that value from the std and the final equation becomes:
SR_sampled = mean(daily_returns - dail_risk_free) / std(daily_returns)
… Then you finally add in the annual adjustment factor to get:
SR_annual = sqrt(# samples per year) * SR_sampled
Where can you get the values of the Risk Free Rate?
- LIBOR
- 3month T-Bill
- 0% …
Typically the daily risk free rate is calculated as follows:
daily_risk_free = root252(1 + APY) - 1
How many trading days are there for year?
252
Does it matter how frequently you calculate the sharp ratio?
Yes! It ill vary wildly depending on how often you sample. It was envisioned to be calculated annually.
- SR_annualized = K*SR
- K = sqrt(# samples per year)
So:
daily_k = sqrt(252)
weekly_k = sqrt(52)
monthly_k = sqrt(12)
It doesn’t matter how many data points you have! only the sample frequency!
daily, weekly, monthly
What is a basis point?
1/10000
so 10 bps = 0.001
What can you do with an optimizer?
- Find minimum values of functions
- Build parameterized models based on data (eg, find the optimum parameters for a model)
- Refine allocations to stocks in portfolios
What are convex problems?
If you can draw a line between any two points and there is a segment of the function above the line between the points, it’s non-convex.
It’s only convex if all function values between any two points lie below a line between those two points.
For function to be convex, it must have one local minima (eg, global minima). It should also have no flat spots.
Not guaranteed to find the global minima if it’s a non convex problem.
What is instance based vs parametric learning?
Parametric - Finds parameters for a model (linear regression). You don’t need the original data. Training is slow, but prediction is fast.
Instance Based - KNN - you store all the data and consult it for a solution. Training is fast (you just store data), but prediction is slow.
What is backtesting?
You role back time and test your system, provide some training data and then test how your system would trade, knowing what the stock prices actually did. This process repeats over and over.
Usually performance in the real world isn’t as good as what is shown in back testing.
What are the problems with regression?
- Noisy and uncertain
- challenging to estimate confidence
- holding time (how long you should hold), allocation
What is out of sample testing?
You test on data that you did not train on.
How does cross validation work?
Split data into N chunks, then 1 chunk is test and the rest is train. Then swap which chunk is the test chunk. Repeat this until you’ve tested all chunks. Take an average of the results.
This isn’t necessarily a good method for financial data though, because you can be peeking into the future.