Difference between revisions of "Manipulating Financial Data in Python"

From Quantitative Analysis Software Courses
Jump to navigation Jump to search
 
(57 intermediate revisions by 4 users not shown)
Line 1: Line 1:
==Module 1: Reading, Slicing and Plotting Stock Data==
+
==Lesson 1: Reading, slicing and plotting stock data==
* Overview of data we'll be working with: AAPL.csv, SPY.csv (note date order)
+
*Overview of the data we'll be working with (from Yahoo!)
** Meaning of various columns
+
*Introduction to our primary library: Pandas
* The Pandas dataframe
+
*Reading CSV data into Pandas
* Read CSV into a dataframe (AAPL example)
+
*Filtering to specific dates
* Slice according to dates
+
*Plotting
* [quiz: read SPY.csv and slice against different dates]
 
* Plot (note date order wrong)
 
* Sort
 
* Plot
 
  
==Module 2: Building and plotting a dataframe with lots of stocks==
+
Reading: "Python for Finance", Chapter 6: Financial time series
* Overview of what we want to end up with: Rows: Dates, Columns: Symbols
 
* Step by step how to build it
 
* SPY.csv will be our reference -- it trades every day the market is open.
 
* Read SPY.csv, slice to date range, sort
 
* Read AAPL.csv, merge() into existing dataframe
 
* Repeat with GLD, IBM, GOOG
 
* Plot and display legend
 
* Observe: Scale not good, let's normalize
 
* Print some of the numbers
 
* Plot after normalization
 
* [quiz: normalize at a different date]
 
  
==Module 3: Numpy Fundamentals==
+
==Lesson 2: Working with many stocks at once==
*Creating Arrays
+
*Our target data frame structure
*Basic Indexing and Slicing
+
*Address reverse order issue
*Data Processing using Arrays
+
*Reading data for multiple stocks into the structure
 +
*Date slicing
 +
*Symbol slicing
 +
*Plotting
 +
*Normalizing
  
==Module 2: Pandas DS- Series==
+
==Lesson 3: The power of Numpy==
*Working with index
+
*What is Numpy and how it relates to Pandas
*Operations
+
*Why is Numpy powerful/important?
*Filtering
+
*Creating Numpy arrays
*Handling Incomplete Data
+
*Indexing and slicing Numpy arrays
 +
*Important data processing on Numpy arrays
 +
*Example use with pandas too
  
==Module 3: Pandas DS- Data Frame==
+
Reading: "Python for Finance", Chapter 4: Data types and structures
*Creating Data frame
 
*Operations
 
*Columns and rows
 
*Essential Function
 
*Reindexing
 
*Indexing and Filtering
 
  
==Module 4: Data Analysis- Reading/Writing Data==
+
==Lesson 4: Statistical analysis of time series==
*Importing Data using Pandas
+
*Gross statistics on dataframes
*Importing data without pandas
+
*Rolling statistics on dataframes
*Saving and exporting data using pandas
+
*Plotting a technical indicator (Bollinger Bands)
*Saving and exporting data without pandas
 
  
==Module 5==
+
Reading: "Python for Finance", Chapter 6: Financial time series
*Pre-processing Data
 
*Statistical Functions for Analysis
 
  
==Module 6: Date And Time==
+
==Lesson 5: Incomplete data==
*Creating Date and Time
+
*How incomplete data arises in financial data
*Date Mathematics
+
*Different approaches to dealing with it
*Time Series Plotting
 
  
==Module 7: Graphs Part I==
+
==Lesson 6: Histograms and scatter plots==
  
==Module 8: Graphs Part II==
+
* Histogram of daily returns
 +
* Compare SPY with XOM
 +
* Scatter plots
 +
* Correlation is not slope!
 +
* Compare SPY vs XOM, with SPY vs GLD scatter plots
 +
 
 +
Reading: "Python for Finance", Chapter 5: Data Visualization
 +
 
 +
==Lesson 7: Sharpe ratio & other portfolio statistics==
 +
*Speed up reading data by memoizing
 +
*Average daily return
 +
*Volatility: stddev of daily return (don't count first day)
 +
*Cumulative return
 +
*Relationship between cumulative and daily
 +
*Sharpe Ratio
 +
*How to model a buy and hold portfolio
 +
 
 +
==Lesson 8: Optimizers: Building a parameterized model==
 +
*What does an optimizer do?
 +
*Syntax of optimizer use
 +
*Problem statement for an optimizer (inputs, outputs, assumptions)
 +
*How to find X that minimizes f(X) with a minimizer
 +
*How to build a parameterized polynomial model from real data using an optimizer
 +
 
 +
==Lesson 9: Optimizers: How to optimize a portfolio==
 +
*What does it mean to "optimize" a portfolio
 +
*Framing the problem for an optimizer
 +
*Constraints on X for an optimizer
 +
*Ranges on X for an optimizer
 +
 
 +
Reading: "Python for Finance", Chapter 11: Statistics-Portfolio Optimization

Latest revision as of 19:10, 24 August 2016

Lesson 1: Reading, slicing and plotting stock data

  • Overview of the data we'll be working with (from Yahoo!)
  • Introduction to our primary library: Pandas
  • Reading CSV data into Pandas
  • Filtering to specific dates
  • Plotting

Reading: "Python for Finance", Chapter 6: Financial time series

Lesson 2: Working with many stocks at once

  • Our target data frame structure
  • Address reverse order issue
  • Reading data for multiple stocks into the structure
  • Date slicing
  • Symbol slicing
  • Plotting
  • Normalizing

Lesson 3: The power of Numpy

  • What is Numpy and how it relates to Pandas
  • Why is Numpy powerful/important?
  • Creating Numpy arrays
  • Indexing and slicing Numpy arrays
  • Important data processing on Numpy arrays
  • Example use with pandas too

Reading: "Python for Finance", Chapter 4: Data types and structures

Lesson 4: Statistical analysis of time series

  • Gross statistics on dataframes
  • Rolling statistics on dataframes
  • Plotting a technical indicator (Bollinger Bands)

Reading: "Python for Finance", Chapter 6: Financial time series

Lesson 5: Incomplete data

  • How incomplete data arises in financial data
  • Different approaches to dealing with it

Lesson 6: Histograms and scatter plots

  • Histogram of daily returns
  • Compare SPY with XOM
  • Scatter plots
  • Correlation is not slope!
  • Compare SPY vs XOM, with SPY vs GLD scatter plots

Reading: "Python for Finance", Chapter 5: Data Visualization

Lesson 7: Sharpe ratio & other portfolio statistics

  • Speed up reading data by memoizing
  • Average daily return
  • Volatility: stddev of daily return (don't count first day)
  • Cumulative return
  • Relationship between cumulative and daily
  • Sharpe Ratio
  • How to model a buy and hold portfolio

Lesson 8: Optimizers: Building a parameterized model

  • What does an optimizer do?
  • Syntax of optimizer use
  • Problem statement for an optimizer (inputs, outputs, assumptions)
  • How to find X that minimizes f(X) with a minimizer
  • How to build a parameterized polynomial model from real data using an optimizer

Lesson 9: Optimizers: How to optimize a portfolio

  • What does it mean to "optimize" a portfolio
  • Framing the problem for an optimizer
  • Constraints on X for an optimizer
  • Ranges on X for an optimizer

Reading: "Python for Finance", Chapter 11: Statistics-Portfolio Optimization