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

BUG use net liquidation value as the denominator in percent allocation calculation #201

Merged
merged 2 commits into from
Nov 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyfolio/pos.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def get_percent_alloc(values):
Positions and their allocations.
"""
return values.divide(
values.abs().sum(axis='columns'),
values.sum(axis='columns'),
axis='rows'
)

Expand Down Expand Up @@ -162,7 +162,7 @@ def get_sector_exposures(positions, symbol_sector_map):
positions = positions.drop('cash', axis=1)

unmapped_pos = np.setdiff1d(positions.columns.values,
symbol_sector_map.keys())
list(symbol_sector_map.keys()))
if len(unmapped_pos) > 0:
warn_message = """Warning: Symbols {} have no sector mapping.
They will not be included in sector allocations""".format(
Expand Down
3 changes: 1 addition & 2 deletions pyfolio/tests/test_pos.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from pandas.util.testing import (assert_frame_equal)

from numpy import (
absolute,
arange,
zeros_like,
)
Expand Down Expand Up @@ -40,7 +39,7 @@ def test_get_percent_alloc(self):
result = get_percent_alloc(frame)
expected_raw = zeros_like(raw_data)
for idx, row in enumerate(raw_data):
expected_raw[idx] = row / absolute(row).sum()
expected_raw[idx] = row / row.sum()

expected = DataFrame(
expected_raw,
Expand Down