Finance Project Flashcards
start = datetime.datetime(2006, 1, 1)
end = datetime.datetime(2016, 1, 1)
Sukuriama pradzios data ir pabaigos
from pandas_datareader import data, wb
import pandas as pd
import numpy as np
import datetime
%matplotlib inline
Reikalingos bibliotekos
BAC = web.DataReader(“BAC”, ‘yahoo’, start, end)
Istraukiame dataframe is web
bank_stocks = pd.concat([BAC, C, GS, JPM, MS, WFC],axis=1,keys=tickers)
Sujungiami duomenys
bank_stocks.xs(key=’Close’,axis=1,level=’Stock Info’).max()
Isfiltruojama didziausia akcijos kaina
for tick in tickers:
returns[tick+’ Return’] = bank_stocks[tick][‘Close’].pct_change()
returns.head()
.xs
Naudojama to grab information from specific columns
import seaborn as sns
sns.pairplot(returns[1:])
Sukuriamas pairplot
returns.idxmin()
Isfiltruoja kai stock turejo didziausia drop
returns.idxmax()
Isfiltruoja kai stock turedejo didziausia gain
returns = pd.DataFrame()
Sukuriame empty data frame
returns.ix[‘2015-01-01’:’2015-12-31’].std()
Grazina tu dienu standart deviation
sns.distplot(returns.ix[‘2015-01-01’:’2015-12-31’][‘MS Return’],color=’green’,bins=100)
Sukuria distplot
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style(‘whitegrid’)
%matplotlib inline
Optional Plotly Method Imports
import plotly
import cufflinks as cf
cf.go_offline()
Importuojamas vizualizaciju bibliotekos
for tick in tickers:
bank_stocks[tick][‘Close’].plot(figsize=(12,4),label=tick)
plt.legend()
Sukuria stocku kainu diagrama