00 Info - Python For Finance Web Links
00 Info - Python For Finance Web Links
Why Python?
The answer is simple: it is powerful yet very accessible. Python has become the most popular
programming language for data science because it allows us to forget about the tedious parts
of programming and offers us an environment where we can quickly jot down our ideas and
put concepts directly into action.
1. Installing Python 3.9.8 (or higher) and packages from the Python Package Index
Python is available for all three major operating systems - Microsoft Windows, mac OS, and
Linux - and the installer, as well as the documentation, can be downloaded from the official
Python website: https://www.python.org/downloads/. It is recommended you use the most
recent version of Python 3 that is currently available.
The additional packages can be installed via the pip installer program, which has been part of
the Python standard library since Python 3.3. More information about pip can be found at
https://docs.python.org/3/installing/index.html.
After we have successfully installed Python, we can execute pip from the open command
prompt [windows + X /run] to install additional Python packages:
C:\Users\user\AppData\...\...\...\Python\Python39\python -m pip install package_name
package_name = matplotlib, yfinance, pandas, pandas-datareader, numpy, beautifulsoup4,
scikit-learn, scipy, seaborn
Already installed packages can be updated via the --upgrade flag:
C:\Users\user\AppData\...\...\...\Python\Python39\python -m pip install --upgrade
package_name
1
Web Resources:
https://www.python.org/doc/
http://wiki.python.org/moin/BeginnersGuide/
2
Courses in Codecademy: (https://www.codecademy.com/)
• Learn Python 3
https://www.codecademy.com/learn/learn-python-3
• Introduction to Python
https://www.datacamp.com/courses/intro-to-python-for-data-science
Books:
• Brooker, Phillip, (2019), Programming with Python for Social Scientists, SAGE
Publications.
• Dixon, Matthew F., Igor Halperin, Paul Bilokon, (2020), Machine Learning in Finance:
From Theory to Practice, 1st Edition, Springer.
• Hilpisch, Yves, (2015), Python for Finance, O’Reilly.
• Hull, John C., (2021), Machine Learning in Business: An Introduction to the World of
Data Science, 3rd Edition, Independently published.
• Lopez de Prado, Marcos, (2018), Advances in Financial Machine Learning, Wiley.
• Lopez de Prado, Marcos, (2020), Machine Learning for Asset Managers, Cambridge
University Press.
• Nagel, Stefan, (2021), Machine Learning in Asset Pricing, Princeton University Press.
• Weiming, James Ma, (2019), Mastering Python for Finance: Implement advanced state-of-
the-art financial statistical application using Python, 2nd Edition, Packt Publishing.
• Yuxing, Yan, (2017), Python for Finance: Apply Powerful Finance Models and
Quantitative Analysis, 2nd Edition, Packt Publishing.
3
Example 1: (01 FinData_from_Yahoo)
#First, make sure to have available all necessary libraries:
import datetime as dt
import matplotlib.pyplot as plt
from matplotlib import style
import pandas as pd
import yfinance as yf
style.use('ggplot')
print (df.head())
print(df.head(10))
print(df.tail())
print(df.tail(10))
#Plot data:
df.plot()
plt.show()
df['Adj Close'].plot()
plt.show()
print(df[['Open', 'High']].head())
4
Example 3: (03 FinData_Firms_and_Indeces)
#First, make sure to have available all necessary modules:
import datetime as dt
import matplotlib.pyplot as plt
from matplotlib import style
import pandas as pd
import yfinance as yf
import numpy as np
style.use('ggplot')
symbols = ["GOOGL","FB","MSFT","AAPL","IBM","^DJI","^GSPC"]
print(data.head())
print(data.tail())
#plot data
data[['GOOGL','FB','MSFT','AAPL','IBM']].plot()
plt.show()
data[['FB','MSFT','AAPL','IBM']].plot()
plt.show()
5
print(df.head())
print(df.tail())
print(df.head())
print(df.tail())