<commit_before>{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Imports"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2016-09-07T21:54:56.754552",
     "start_time": "2016-09-07T21:54:55.144746"
    },
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "\"\"\" Ignore Warnings \"\"\"\n",
    "def warn(*args, **kwargs):\n",
    "    pass\n",
    "import warnings\n",
    "warnings.warn = warn\n",
    "\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "\n",
    "import pandas_datareader.data as web\n",
    "import datetime\n",
    "\n",
    "from pysharperratio import estimateSNR"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2016-09-07T21:57:14.207874",
     "start_time": "2016-09-07T21:57:14.205196"
    }
   },
   "source": [
    "# Set parameters"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2016-09-07T22:08:13.580586",
     "start_time": "2016-09-07T22:08:13.576367"
    },
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# The sample series length\n",
    "N = 302\n",
    "\n",
    "# Number of permutations\n",
    "permutations = 1000"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Get sample data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2016-09-07T22:12:27.127331",
     "start_time": "2016-09-07T22:12:26.908734"
    },
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Get some sample data\n",
    "spy = web.DataReader('SPY', 'yahoo', datetime.date(2000,1,1))['Adj Close']\n",
    "\n",
    "# Take the most recent N+1 values\n",
    "spy = spy[-N-1:]\n",
    "sample = spy.copy()\n",
    "log_rets = np.log(spy) - np.log(spy.shift(1))\n",
    "log_rets = log_rets.dropna().values"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Compute sharpeRratio"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.023311558594394634"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "estimateSNR(log_rets,permutations)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    ""
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3.0
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}<commit_msg>moved data to the example folder and updated example.ipynb<commit_after>{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Imports"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2016-09-07T21:54:56.754552",
     "start_time": "2016-09-07T21:54:55.144746"
    },
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "\n",
    "from scipy.interpolate.interpolate import interp1d as sint\n",
    "\n",
    "import pandas_datareader.data as web\n",
    "import datetime\n",
    "\n",
    "from pysharperratio import estimateSNR"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2016-09-07T21:57:14.207874",
     "start_time": "2016-09-07T21:57:14.205196"
    }
   },
   "source": [
    "# Set parameters"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2016-09-07T22:08:13.580586",
     "start_time": "2016-09-07T22:08:13.576367"
    },
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [],
   "source": [
    "# The sample series length\n",
    "N = 302\n",
    "\n",
    "# Number of permutations\n",
    "permutations = 10000"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Get sample data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2016-09-07T22:12:27.127331",
     "start_time": "2016-09-07T22:12:26.908734"
    },
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [],
   "source": [
    "# Get some sample data\n",
    "spy = web.DataReader('SPY', 'yahoo', datetime.date(2000,1,1))['Adj Close']\n",
    "\n",
    "# Take the most recent N+1 values\n",
    "spy = spy[-N-1:]\n",
    "sample = spy.copy()\n",
    "log_rets = np.log(spy) - np.log(spy.shift(1))\n",
    "log_rets = log_rets.dropna().values"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Compute sharpeRratio"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [],
   "source": [
    "spline_data = pd.read_csv('spline_data.csv',index_col=0).values\n",
    "spline = sint(spline_data[:,0],spline_data[:,1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3.981116583235542e-05"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "estimateSNR(log_rets,spline,permutations)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
{'fraction_non_alphanumeric': 0.21596385542168675, 'fraction_numerical': 0.06445783132530121, 'mean_word_length': 2.5100422832980973, 'pattern_counts': {'":': 168, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4971931', 'n_tokens_mistral': 2969, 'n_tokens_neox': 2694, 'n_words': 426}