Imports


In [5]:
import numpy as np
import pandas as pd

from scipy.interpolate.interpolate import interp1d as sint

import pandas_datareader.data as web
import datetime

from pysharperratio import estimateSNR

Set parameters


In [23]:
# The sample series length
N = 302

# Number of permutations
permutations = 10000

Get sample data


In [3]:
# Get some sample data
spy = web.DataReader('SPY', 'yahoo', datetime.date(2000,1,1))['Adj Close']

# Take the most recent N+1 values
spy = spy[-N-1:]
sample = spy.copy()
log_rets = np.log(spy) - np.log(spy.shift(1))
log_rets = log_rets.dropna().values

Compute sharpeRratio


In [24]:
spline_data = pd.read_csv('spline_data.csv',index_col=0).values
spline = sint(spline_data[:,0],spline_data[:,1])

In [25]:
estimateSNR(log_rets,spline,permutations)


Out[25]:
3.981116583235542e-05

In [ ]: