Python matplotlib.finance.quotes_historical_yahoo_ochl() Examples
The following are 16
code examples of matplotlib.finance.quotes_historical_yahoo_ochl().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
matplotlib.finance
, or try the search function
.
Example #1
Source File: c7_16_def_sharpe_ratio.py From Python-for-Finance-Second-Edition with MIT License | 6 votes |
def sharpeRatio(ticker,begdate=(2012,1,1),enddate=(2016,12,31)): """Objective: estimate Sharpe ratio for stock ticker : stock symbol begdate : beginning date enddate : ending date Example #1: sharpeRatio("ibm") 0.0068655583807256159 Example #2: date1=(1990,1,1) date2=(2015,12,23) sharpeRatio("ibm",date1,date2) 0.027831010497755326 """ import scipy as sp from matplotlib.finance import quotes_historical_yahoo_ochl as getData p = getData(ticker,begdate, enddate,asobject=True,adjusted=True) ret=p.aclose[1:]/p.aclose[:-1]-1 return sp.mean(ret)/sp.std(ret)
Example #2
Source File: c6_08_dailyReturn_4_annual.py From Python-for-Finance-Second-Edition with MIT License | 5 votes |
def ret_f(ticker,begdate, enddate): p = quotes_historical_yahoo_ochl(ticker, begdate, enddate,asobject=True,adjusted=True) return((p.aclose[1:] - p.aclose[:-1])/p.aclose[:-1]) #
Example #3
Source File: c6_27_get_beta_good.py From Python-for-Finance-Second-Edition with MIT License | 5 votes |
def dailyReturn(ticker,begdate,enddate): p = aa(ticker, begdate,enddate,asobject=True,adjusted=True) return p.aclose[1:]/p.aclose[:-1]-1 #
Example #4
Source File: c4_16_ttest_2stocks.py From Python-for-Finance-Second-Edition with MIT License | 5 votes |
def ret_f(ticker,begdate,enddate): p = getData(ticker,begdate, enddate,asobject=True,adjusted=True) ret=p.aclose[1:] ret=p.aclose[1:]/p.aclose[:-1]-1 return(ret)
Example #5
Source File: c9_32_mean_and_var.py From Python-for-Finance-Second-Edition with MIT License | 5 votes |
def ret_f(ticker,begdate,enddte): x=getData(ticker,begdate,enddate,asobject=True,adjusted=True) ret =x.aclose[1:]/x.aclose[:-1]-1 return ret
Example #6
Source File: c9_44_impact_of_correlation_2stock_portfolio.py From Python-for-Finance-Second-Edition with MIT License | 5 votes |
def ret_annual(ticker,begdate,enddte): x=getData(ticker,begdate,enddate,asobject=True,adjusted=True) logret =sp.log(x.aclose[1:]/x.aclose[:-1]) date=[] d0=x.date for i in range(0,sp.size(logret)): date.append(d0[i].strftime("%Y")) y=pd.DataFrame(logret,date,columns=[ticker]) return sp.exp(y.groupby(y.index).sum())-1
Example #7
Source File: c9_50_efficient_frontier.py From Python-for-Finance-Second-Edition with MIT License | 5 votes |
def ret_monthly(ticker): # function 1 x = getData(ticker,(begYear,1,1),(endYear,12,31),asobject=True,adjusted=True) logret=np.log(x.aclose[1:]/x.aclose[:-1]) date=[] d0=x.date for i in range(0,np.size(logret)): date.append(''.join([d0[i].strftime("%Y"),d0[i].strftime("%m")])) y=pd.DataFrame(logret,date,columns=[ticker]) return y.groupby(y.index).sum() # function 2: objective function
Example #8
Source File: c9_77_Modigliani_m2_performance_measure.py From Python-for-Finance-Second-Edition with MIT License | 5 votes |
def ret_f(ticker): # function 1 x = getData(ticker,begdate,enddate,asobject=True,adjusted=True) ret=x.aclose[1:]/x.aclose[:-1]-1 ddate=x['date'][1:] y=pd.DataFrame(ret,columns=[ticker],index=ddate) return y.groupby(y.index).sum()
Example #9
Source File: c9_18_sharpe_ratio.py From Python-for-Finance-Second-Edition with MIT License | 5 votes |
def ret_annual(ticker,begdate,enddte): x=getData(ticker,begdate,enddate,asobject=True,adjusted=True) logret =sp.log(x.aclose[1:]/x.aclose[:-1]) date=[] d0=x.date for i in range(0,sp.size(logret)): date.append(d0[i].strftime("%Y")) y=pd.DataFrame(logret,date,columns=[ticker]) return sp.exp(y.groupby(y.index).sum())-1 # function 2: estimate portfolio variance
Example #10
Source File: c9_21_optimal_portfolio_based_on_Sortino_ratio.py From Python-for-Finance-Second-Edition with MIT License | 5 votes |
def ret_annual(ticker,begdate,enddte): x=getData(ticker,begdate,enddate,asobject=True,adjusted=True) logret =sp.log(x.aclose[1:]/x.aclose[:-1]) date=[] d0=x.date for i in range(0,sp.size(logret)): date.append(d0[i].strftime("%Y")) y=pd.DataFrame(logret,date,columns=[ticker]) return sp.exp(y.groupby(y.index).sum())-1 # function 2: estimate portfolio beta
Example #11
Source File: c9_23_efficient_based_on_sortino_ratio.py From Python-for-Finance-Second-Edition with MIT License | 5 votes |
def ret_annual(ticker,begdate,enddte): x=getData(ticker,begdate,enddate,asobject=True,adjusted=True) logret =sp.log(x.aclose[1:]/x.aclose[:-1]) date=[] d0=x.date for i in range(0,sp.size(logret)): date.append(d0[i].strftime("%Y")) y=pd.DataFrame(logret,date,columns=[ticker]) return sp.exp(y.groupby(y.index).sum())-1 # function 2: estimate LPSD
Example #12
Source File: c9_52_impact_of_correlation_on_efficient_frontier_notWorking.py From Python-for-Finance-Second-Edition with MIT License | 5 votes |
def ret_monthly(ticker): # function 1 x = getData(ticker,(begYear,1,1),(endYear,12,31),asobject=True,adjusted=True) logret=np.log(x.aclose[1:]/x.aclose[:-1]) date=[] d0=x.date for i in range(0,np.size(logret)): date.append(''.join([d0[i].strftime("%Y"),d0[i].strftime("%m")])) y=pd.DataFrame(logret,date,columns=[ticker]) return y.groupby(y.index).sum()
Example #13
Source File: c8_34_Durbin_Watson_test_CAPM_IBM_residual.py From Python-for-Finance-Second-Edition with MIT License | 5 votes |
def dailyRet(ticker,begdate,enddate): p =getData(ticker, begdate, enddate,asobject=True,adjusted=True) return p.aclose[1:]/p.aclose[:-1]-1
Example #14
Source File: c8_27_test_equal_variances.py From Python-for-Finance-Second-Edition with MIT License | 5 votes |
def ret_f(ticker,begdate,enddate): p = getData(ticker,begdate, enddate,asobject=True,adjusted=True) return p.aclose[1:]/p.aclose[:-1]-1
Example #15
Source File: c15_07_equal_vol_2periods.py From Python-for-Finance-Second-Edition with MIT License | 5 votes |
def ret_f(ticker,begdate,enddate): p =getData(ticker, begdate, enddate,asobject=True, adjusted=True) ret = p.aclose[1:]/p.aclose[:-1]-1 date_=p.date return pd.DataFrame(data=ret,index=date_[1:],columns=['ret']) # # call the above function twice
Example #16
Source File: c11_19_portfolio_VaR.py From Python-for-Finance-Second-Edition with MIT License | 5 votes |
def ret_f(ticker,begdate,enddte): x=getData(ticker,begdate,enddate,asobject=True,adjusted=True) ret=x.aclose[1:]/x.aclose[:-1]-1 d0=x.date[1:] return pd.DataFrame(ret,index=d0,columns=[ticker]) # Step 3