<s> """<STR_LIT>""" <EOL> from statsmodels . compat . python import lzip <EOL> import numpy as np <EOL> import matplotlib . finance as fin <EOL> import matplotlib . pyplot as plt <EOL> import datetime as dt <EOL> import pandas as pa <EOL> def getquotes ( symbol , start , end ) : <EOL> quotes = fin . quotes_historical_yahoo ( symbol , start , end ) <EOL> dates , open , close , high , low , volume = lzip ( * quotes ) <EOL> data = { <EOL> '<STR_LIT>' : open , <EOL> '<STR_LIT>' : close , <EOL> '<STR_LIT>' : high , <EOL> '<STR_LIT>' : low , <EOL> '<STR_LIT>' : volume <EOL> } <EOL> dates = pa . Index ( [ dt . datetime . fromordinal ( int ( d ) ) for d in dates ] ) <EOL> return pa . DataFrame ( data , index = dates ) <EOL> start_date = dt . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> end_date = dt . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> mysym = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> indexsym = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> dmall = { } <EOL> for sy in mysym : <EOL> dmall [ sy ] = getquotes ( sy , start_date , end_date ) <EOL> pawp = pa . WidePanel . fromDict ( dmall ) <EOL> print ( pawp . values . shape ) <EOL> paclose = pawp . getMinorXS ( '<STR_LIT>' ) <EOL> paclose_ratereturn = paclose . apply ( np . log ) . diff ( ) <EOL> plt . figure ( ) <EOL> paclose_ratereturn . plot ( ) <EOL> plt . title ( '<STR_LIT>' ) <EOL> paclose_ratereturn_vol = paclose_ratereturn . apply ( lambda x : np . power ( x , <NUM_LIT:2> ) ) <EOL> plt . figure ( ) <EOL> plt . title ( '<STR_LIT>' ) <EOL> paclose_ratereturn_vol . plot ( ) <EOL> paclose_ratereturn_vol_mov = paclose_ratereturn_vol . apply ( <EOL> lambda x : np . convolve ( x , np . ones ( <NUM_LIT:5> ) / <NUM_LIT> , '<STR_LIT>' ) ) <EOL> paclose_ratereturn_vol_mov . plot ( ) </s>
