Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sharpe ratio #874

Closed
wants to merge 2 commits into from
Closed

Fix sharpe ratio #874

wants to merge 2 commits into from

Conversation

twiecki
Copy link
Contributor

@twiecki twiecki commented Nov 25, 2015

@ehebert
Copy link
Contributor

ehebert commented Nov 25, 2015

@twiecki looks like some tests are failing due to change to the parameters to sharpe_ratio.

======================================================================
ERROR: test_mavg_4_minute (tests.test_transforms.TransformTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/miniconda/envs/testenv/lib/python2.7/site-packages/nose_parameterized/parameterized.py", line 365, in standalone_func
    return func(*(a + p.args), **p.kwargs)
  File "/home/travis/build/quantopian/zipline/tests/test_transforms.py", line 108, in wrapper
    algo.run(source)
  File "/home/travis/build/quantopian/zipline/zipline/algorithm.py", line 592, in run
    for perf in self.gen:
  File "/home/travis/build/quantopian/zipline/zipline/gens/tradesimulation.py", line 125, in transform
    for message in messages:
  File "/home/travis/build/quantopian/zipline/zipline/gens/tradesimulation.py", line 364, in generate_messages
    self.algo.perf_tracker.handle_minute_close(dt)
  File "/home/travis/build/quantopian/zipline/zipline/finance/performance/tracker.py", line 445, in handle_minute_close
    account)
  File "/home/travis/build/quantopian/zipline/zipline/finance/risk/cumulative.py", line 286, in update
    self.sharpe[dt_loc] = self.calculate_sharpe()
  File "/home/travis/build/quantopian/zipline/zipline/finance/risk/cumulative.py", line 396, in calculate_sharpe
    self.daily_treasury[self.latest_dt.date()])
TypeError: sharpe_ratio() takes exactly 2 arguments (3 given)

return (algorithm_return - treasury_return) / algorithm_volatility
# compute daily returns from provided annual treasury yields
if treasury_return != 0:
treasury_return_daily = (1 + treasury_return)**(1/252) - 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This module currently doesn't include __future__ import division, so I believe this value will always be 0 in Python 2. (With 1/252 being 0 followed by (1 + treasury_return)**0 equaling 1.)

@twiecki twiecki mentioned this pull request Nov 25, 2015
@twiecki
Copy link
Contributor Author

twiecki commented Nov 25, 2015

New PR #877

@twiecki twiecki closed this Nov 25, 2015
@twiecki twiecki deleted the fix_sharpe branch November 26, 2015 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants