Giter VIP home page Giter VIP logo

pysharperratio's Introduction

pySharpeRratio

Description

This package implements a moment-free estimator of the Sharpe (signal-to-noise) ratio. The algorithm does not require the computation of any moments by estimating the Sharpe ratio based on the cumulative sum of (i.i.d.) increments or returns. This algorithm is much more precise (efficient) when increments are heavy-tailed.

The estimator computes the difference between the drawdown and drawup durations. First, the cumulative sum of x (e.g. prices) is computed, then the total drawdown and drawup durations are computed. Precision is improved by averaging the estimator on several random permutations of x.

Note

The data used to fit the spline is saved as spline_data.csv in the data folder.

Installation

The current implementation only supports Python 3.

pip install --no-cache-dir pysharperratio

Author: Amir Sani

Maintainers: Amir Sani & Damien Challet

Reference

Challet, Damien. "Sharper asset ranking from total drawdown durations." arXiv preprint arXiv:1505.01333 (2015).

Preprint available at http://arxiv.org/abs/1505.01333

Bibtex

@article{challet2015sharper, title={Sharper asset ranking from total drawdown durations}, author={Challet, Damien}, journal={arXiv preprint arXiv:1505.01333}, year={2015} }

Copyright (c) 2017, Amir Sani

DOI

pysharperratio's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pysharperratio's Issues

File "spline_data.csv"

Hey tanks for this lib !

I try to test it, but I think there is a mistake in with a .csv file :

Code :

import numpy as np
from pysharperratio import estimateSNR

x = np.random.rand(100)

snr,r0bar,n = estimateSNR(x,1000)

Ouput :

---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)
<ipython-input-34-95aa56a81496> in <module>()
----> 1 snr,r0bar,n = estimateSNR(x,1000)

/Users/babou/anaconda/lib/python2.7/site-packages/pysharperratio/__init__.pyc in estimateSNR(x, permutations)
     87 #    cwd = os.getcwd()
     88 #    spline_file = os.path.join(cwd, 'spline_data.csv')
---> 89     a_data = pd.read_csv('spline_data.csv',index_col=0)
     90 
     91     # Estimate Spline

/Users/babou/anaconda/lib/python2.7/site-packages/pandas/io/parsers.pyc in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, escapechar, comment, encoding, dialect, tupleize_cols, error_bad_lines, warn_bad_lines, skip_footer, doublequote, delim_whitespace, as_recarray, compact_ints, use_unsigned, low_memory, buffer_lines, memory_map, float_precision)
    560                     skip_blank_lines=skip_blank_lines)
    561 
--> 562         return _read(filepath_or_buffer, kwds)
    563 
    564     parser_f.__name__ = name

/Users/babou/anaconda/lib/python2.7/site-packages/pandas/io/parsers.pyc in _read(filepath_or_buffer, kwds)
    313 
    314     # Create the parser.
--> 315     parser = TextFileReader(filepath_or_buffer, **kwds)
    316 
    317     if (nrows is not None) and (chunksize is not None):

/Users/babou/anaconda/lib/python2.7/site-packages/pandas/io/parsers.pyc in __init__(self, f, engine, **kwds)
    643             self.options['has_index_names'] = kwds['has_index_names']
    644 
--> 645         self._make_engine(self.engine)
    646 
    647     def close(self):

/Users/babou/anaconda/lib/python2.7/site-packages/pandas/io/parsers.pyc in _make_engine(self, engine)
    797     def _make_engine(self, engine='c'):
    798         if engine == 'c':
--> 799             self._engine = CParserWrapper(self.f, **self.options)
    800         else:
    801             if engine == 'python':

/Users/babou/anaconda/lib/python2.7/site-packages/pandas/io/parsers.pyc in __init__(self, src, **kwds)
   1211         kwds['allow_leading_cols'] = self.index_col is not False
   1212 
-> 1213         self._reader = _parser.TextReader(src, **kwds)
   1214 
   1215         # XXX

pandas/parser.pyx in pandas.parser.TextReader.__cinit__ (pandas/parser.c:3427)()

pandas/parser.pyx in pandas.parser.TextReader._setup_parser_source (pandas/parser.c:6861)()

IOError: File spline_data.csv does not exist

I don't understand why there is this .csv File here.

If I could help, don't hesitate !

A.

interpolator.pkl not found

Hi,

While running the example notebook I got

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-14-029c9380f2ed> in <module>()
----> 1 estimateSNR(log_rets,permutations)
      2 
/pysharperratio/__init__.py in estimateSNR(x, permutations)
     85 
     86     # Load spline
---> 87     with open('interpolator.pkl', 'rb') as f:
     88         f_a = pickle.load(f)
     89 

FileNotFoundError: [Errno 2] No such file or directory: 'interpolator.pkl' 

I made a fix to it here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.