MainDeck Flashcards
Cumulative Returns
The total change in the price of an investment over a set time period
cumulative_return = (price[t] / prince[0] ) - 1
-or-
cumulative_return = (price at end / price the beginning ) - 1 price[t] is any particular day and price[0] is the price at the beginning
Lecture 01-04-12
Bollinger Bands (r)
Bands that are 2 standard deviations above and below the rolling mean.
Rolling mean +/- std deviation * 2
Lecture 01-04-07
Why is data not pristine
- Data is an amalgamation of different sources and prices.
- Not all stocks trade every day.
Lecture 01-05-02
Why does data go missing?
Some stocks stop trading and start trading. Some stock trade under the same ticker but different name. Some stocks trade erratically due to low market cap. 01-05-03
How do you fill gaps when there are gaps in data of a stock.
- Fill forward first,
- fill backwards second
- do not interpolate a trend.
Why are Bollinger Bands important.
The theory states that if the stock crosses the bands then it may be a point to pay attention.
Lecture 01-04-07
Daily Returns
How much did the price go up or down on a particular day.
- daily_return[t] = (price[t] / prince[t-1] ) - 1
- t = day t
Lecture 01-04-10
How do you use a histogram to plot daily returns?
Take the daily return over a plot in time and fill the histogram values based on the number of occurrences of the daily returns.
Lecture 01-06-02
What would you expect a histogram of daily returns to look like?
A normal or Gaussian distribution.
Lecture 01-06-03
Kurtosis
The difference between a normal Gaussian distribution and the distribution of the.
Kurtosis is positive with larger tails and negative with skinny tails.
Lecture 01-06-06
beta (scatter plot)
- When fitting a line to scatter plot, beta the slope of the line..
- This indicates how reactive is the stock to the market.
Lecture 01-06-10
alpha (scatter plot)
- When fitting a line to scatter plot, Alpha is where the line intercepts the vertical axis (y=0).
- This indicates how the stock is returning compared to the market as a whole.

Lecture 01-06-10
How do you use a scatter plot to plot daily returns?
When comparing two stocks, take the daily returns of two stocks and plot (x, y) as (stock_a, stock_b).
Using linear regression plot the mean as a line to find beta and alpha.
E.G. when comparing a stock against the market as a whole
Lecture 01-06-09
Slope vs correlation.
Correlation is how tight the points are to the mean, where as the slope is just the slope of the line.
Lecture 01-07-11
What is a portfolio?
Allocation of funds to a set of stocks
Lecture 01-07-01
How do you calculate the total value of the portfolio day by day?
- normalize the prices
- multiply normalized values x portfolio allocations
- Take that and multiply it by starting values
- sum each row
Lecture 01-07-02
Sharpe Ratio
Risk adjusted Return
- Lower Risk is better
- Higher return is better
(Rp - Rf) / σp
ex ante E[Rp - Rf] / STD[Rp]
- Rp: portfolio return
- Rf: risk free rate of return
- σp: Standard Deviation of portfolio return
Lectures 01-07-05; 01-07-06
What is Risk free rate of return and where can you get it?
Return if you put your money into a bank
Can get it from
- LIBOR
- 3 Month Tbill
- or Just use 0%
Lecture 01-07-05; 01-07-11
How do you calculate daily risk free rate if using Libor or 3 month tbill.
- Take the APR of the risk free option, (Libor, tbill)
- Add 1 to the APR
- Take the 252 root of that sum
- subtract 1
Lecture 01-07-07
What is the annualized version of the sharpe ratio.
Since it was intended to be an annual measurement but can change based on frequencey of the sample SR
- Annualized Sharpe Ratio = K * SR
- K = sqrt(# of samples per year)
- Daily K = sqrt(252)
- Weekly K = sqrt(52)
- Monthly K = sqrt(12)
Lecture 01-07-11
What is an optimizer?
- Finds minimum Values of functions using convex polyogns
- Build parameterized models based on data.
- Refine allocations to stocks in portfolios.
Lecture 01-08-01
How to use an optimizer?
- Provide a function to minimize
- Provide an initial guess
- Optimizer searches for the minima
Lecture 01-08-01
What are the methods do minimizers use?
Gradient Descent…
Lecture 01-08-02
How can minimizers be defeated?
- Lines with no gradient
- Many local minima
- More than 1 global minimal
- discontinuous lines
Lecture 01-08-03; 01-08-04
What are the easiest type of problems for minimizers and why?
Convex Problems
Lecture 01-08-05
What is a convex function?
In mathematics, a real-valued function defined on an n-dimensional interval is called convex (or convex downward or concave upward) if the line segment between any two points on the graph of the function lies above or on the graph. Must have one minima.
- Wiki https://en.wikipedia.org/wiki/Convex_function*
- Lecture 01-08-06*
What is a parameterized model?
A model that take parameters or coefficients.
Lecture 01-08-07
What is a good error metric for models?
- sum of all abs error
- sum of square error
Lecture 01-08-08, 01-08-09
What is portfolio optimization?
- Given a set of assets and a time period.
- Find an allocation of funds to assets that maximizes performance.
Lecture 01-09-01
How do you measure performance in portfolio optimization?
- Cumulative return
- Volatility or risk
- Sharpe Ratio (Risk adjusted return)
Lecture 01-09-01
How can historical reference help a portfolio going forward?
Optimize for Sharpe ratio month by month.
Lecture 01-09-01
How to optimize for sharpe ratio?
Since minimizer focus on minimizing a metric you can optimize for SharpeRatio * -1 (negative sharpeRatio)
Lecture 01-09-05
What Ranges or constraints should be set when optimizing for sharpe ratio?
- Ranges: Limit x between 0 - 1 since x allocations a distribution of funds.
- Constraints: Sum of allocations must = 1.0
Compare Sharpe Ratio to Cumulative Return
Sharpe Ratio is a better measure since it takes volatility into account. SR is a risk adjusted return.
Lecture 01-07-05
What are rolling statistics?
Snapshot of stats (mean, median, std), that follows but lags the actual value
- rolling mean is the simple moving average
- where stock crosses rolling mean is a technical indicator
ETF
Exchange Traded Fund
- Tied to an index
- Buy Sell like stocks
- Baskets of stocks
- Transparent
Lecture 02-01-03
Mutual Funds
A fund that pools money from many investors and invests the money in securities such as stocks, bonds, and short-term debt
- Buy / Sell at end of day.
- Quarterly disclosure
- Less Transparent than ETFs
Lecture 02-01-03
Hedge Fund
a limited partnership of investors that uses high risk methods, such as investing with borrowed money, in hopes of realizing large capital gains.
- Buy / Sell by agreement
- No disclosure
- Not transparent
- Small groups of wealth investors
Lecture 02-01-03
Liquid
The ease at which one buy or sell shares in a particular holding.
Lecture 02-01-04
Capitalization (Large Cap / Small cap)
How much is the company worth, according to the [# of outstanding shares] * [price of the stock].
Lecture 02-01-04
Assets Under Management
How much money is being managed by the fund.
Lecture 02-01-06
Expense Ratio
A percentage of the fund used for compensating the manager.
Lecture 02-01-06
How are fund managers compensated.
- ETF: Expense Ratio 0.01% -> 1.00%
- Mutual Fund: Expense Ratio 0.5% -> 3.00%
- Hedge Fund: e.g. Two and Twenty (2% of AUM, 20% of Profit)
Lecture 02-01-06
How are fund investors compensated.
Based on the value of the fund. Similar to any stock.
Lecture 02-01-06
Who are hedge fund investors?
- Individuals - Wealthy folks
- Institutions - Large retirement funds, Harvard university foundation.
- Funds of Funds -A fund that has several hedge funds.
Lecture 02-01-09
Why would someone want to invest in a particular hedge fund?
- Track record of success. 5yrs.
- Simulations and story to prove Track record.
- Good portfolio fit, or how it fits within their portfolio.
Lecture 02-01-09
What are the primary hedge fund goals?
- Beat a benchmark, e.g. beat SP500 Absolute return
- Provide positive return no matter what. Slow gradual positive return.
Lecture 02-01-10
What are the metrics for a hedge fund?
- Cumulative return
- Volatility
- Risk / Reward (Sharpe ratio)
Lecture 02-01-10
What are X and Y in machine learning
- x is a vector of features (factors)
- y (labels) is a prediction
- discreet value for classification
- continuous value for regression
Lecture 03-01-02
Regression
Numerical approximation based on the mean.
Lecture 03-01-02
Supervised Learning
Providing both data (x) and labels (y) while training
Lecture 03-01-02
Backtesting
Testing against a historical reference e.g. rolling back time and test the system against the data from that time.
Lecture 03-01-09
Problems with regression
- Noisy and uncertain
- hard to estimate confidence, holding time, allocations, etc..
Lecture 03-01-11
Linear Regression / Parametric models
Fitting a Linear or polynomial line to the data.
Lecture 03-02-02
KNN
K Nearest Neighbor
- Instance learner
- Find K nearest points based on distance metric
- Take the mean of K neighbors
Lecture 03-02-03; 03-02-04
How do you create test/train sets in financial data.
Use older data for training and newer data for testing to avoid possible look ahead bias.
Lecture 03-02-07
How does the value of K impact KNN
- Lower K greater likelihood of overfitting.
- Higher K greater likelihood of underfitting.
Lecture 03-03-02
Hows does D impact a parametric model.
D is the order of polynomial.
Higher D fits the line closer to the data increasing likelihood of overfitting.
Lecture 03-03-04
RMSE
Root Mean Squared Error.
sqrt( sum(y_test - y_predict) ^2 / n)
Lecture 03-03-05
Out of sample error
Error from a test or hold out set not included in the training set.
Lecture 03-03-06
Cross Validation
- Break the data into n chunks
- train on n-1 chunks and test on 1.
- Repeat this over the whole dataset slowly rolling forward.
Lecture 03-03-08
Roll Forward Cross Validation
Similar to standard cross validation, but ensuring that the training data is always before the testing data in time.
Lecture 03-03-09
Correlation
How close the data fits the line or model.
Lecture 03-03-10
Overfitting
- In sample error is decreasing and out of sample error is increasing
- Model is fit exactly to the data and cannot generalize data it has not yet seen.
Lecture 03-03-12
Ensemble Learner
A set of weak learners combined to form a strong learner.
Lecture 03-04-01
What is an order?
An order is Buying or Selling a particular stock Symbol for a #Shares at Limit or Market Price
Lecture 02-02-02
Limit Order
Transaction occurs at a specified price limit
Lecture 02-02-02
Market Order
Transaction occurs at market value
Lecture 02-02-02
Order Book
A list of Asks to buy and Bids to sell stock.
Items are queued up. As bids and asks meet requirements then those transactions are completed
Lecture 02-02-05
How to get orders to the exchange.
- User requests order from broker.
- Broker Requests from exchange with the best price.
- or -
If another user with the same broker has a counter order they could facilitate without going to the exchange, as long as the price is in line with the exchange.
Lecture 02-02-06
Dark Pool
- An intermediary between brokerages and exchanges.
- Pay the brokers to look at the data, and take advantageous trades without going to the exchange.
Lecture 02-02-06
Order Book Exploit
- Hedge fund observes the order book
- Hedge fund buys the stock
- Users buys the stock.
- In milliseconds the price goes up
- Hedgefund sells the stock at profit.
Lecture 02-02-07
Geographic Arbitrage Exploit
- Hedgefund locates at two exchanges
- Watches for differences between two exchanges
- Buys at lower price exchange
- Sells at higher price exchange
Lecture 02-02-07
Stop Loss
When the stock reaches a certain price (lower) sell it
Lecture 02-02-08
Stop Gain
When the stock reaches a higher price sell it.
Lecture 02-02-08
Trailing Stop
Stop loss that moves with the price.
Lecture 02-02-08
Selling Short
- Take a negative position on the stock through a broker.
- Borrow shares
- Sell them to someone else
- Exit by Buying shares back and giving them back
Lecture 02-02-08
Why Company value matters
- In general the value of a company goes up monotonically.
- The stock market evaluates the price will deviate from true value.
- This can lead to trading strategies that capitalize on that difference.
Lecture 02-03-03
Value of a future Dollar
P.V. = F.V./(1+IR)^i
Present Value = Future Value / (1 + Interest Rate)^ how far into the future.
Lecture 02-03-05
Discount Rate
- Similar to Interest Rate on the value of a dollar
- Higher if a company is trustd less or risky
- Lower if the company is trusted or less risky
Lecture 02-03-06
Instrinsic Value of a Company
The value of all future dividends that it will be paid.
Infinite sum 1/n^i = FV/
Lecture 02-03-06
Book Value of a company.
Total assets minus intangible assets and liabilities.
Count Tangible Assets, Ignore intangible assets and subtracy liabilities.
Lecture 02-03-08
Market Capitalization
Number of shares * price
Why does information affects stock price?
It could reduce the expected value of dividend which could lead investors to believe that the intrinsic value of a company will go down.
- Company Specific - Information about the company.
- Sector Specific - information about companies in the same sector
- Market Wide information that impact all companies
Lecture 02-03-10
Portfolio
A weighted set of assets.
Lecture 02-04-02
Returns of a portfolio
rp(t) = Σiwiri(t)
- wi : portion of funds in asset i
- required that Σiabs(wi) = 1.0
- t = timeframe
Lecture 02-04-03
Market Portfolio
An index that covers a large set of stocks.
SP500, FTA, TOPIX
Cap Weighted
wi = mktcap i / Σj MarketCapsj
Lecture 02-04-04
CAPM
Capital Assets Pricing Model
ri(t)=ßi rm (t) + ai(t)
- ri(t) = Return for an individual stock
- ßi rm (t) = beta * return on the market for that day
- ai(t) = plus alpha of that stock on that day
- CAPM expects this to be 0
CAPM vs Active Management
- CAPM (passive) : buy index and hold
- Says alpha is random and expected value is 0
- Active : pick individual stocks
- Believe alpha can be predicted.
What is the implication of CAPM
Since the efficient markets hypothesis says you cannot predict the markeys, then beta is irrelevant. Since capm relies only on beta, CAPM is stating that you cannot beat the market.
Lecture 02-04-10
Arbitrage Pricing Theory
Breaking out the beta to compare individual sectors.
What is Technical Analysis
- Using historical price and volume
- Compute statistics called idicators
- indicators are heuristics.
Why might techincal analysis work
- There is information in price.
- Heuristics work in other AI domains.
Where is technical analysis effective
- Individual indicators are weak where as combining them create stronger signals.
- Look for constrasts.
- Workse better over shorter time periods.
Momentum
Direction of change over a period of time.
momentum[t] = price[t] / pricne[t-n] + 1
Simple moving average (n-day)
Rolling average over N days
SMA[t] = price[t] / price[t-n:t].mean()
Bollinger(t) Band - Indicator
BB[t] = price[t] - SMA[t] / 2* STD[t]
Normalization of indicators
normed = values - mean / values.std()