From f525b224e02c13ae346f04c1391b1eca7c66e526 Mon Sep 17 00:00:00 2001
From: Andrew Campbell <andrew@quantopian.com>
Date: Wed, 11 Nov 2015 11:19:40 -0500
Subject: [PATCH 1/2] BUG use net liquidation value as the denominator in
 percent allocation calculation

---
 pyfolio/pos.py            | 2 +-
 pyfolio/tests/test_pos.py | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/pyfolio/pos.py b/pyfolio/pos.py
index 318c64a4..03d23d68 100644
--- a/pyfolio/pos.py
+++ b/pyfolio/pos.py
@@ -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'
     )
 
diff --git a/pyfolio/tests/test_pos.py b/pyfolio/tests/test_pos.py
index 11df4b73..b7e78201 100644
--- a/pyfolio/tests/test_pos.py
+++ b/pyfolio/tests/test_pos.py
@@ -11,7 +11,6 @@
 from pandas.util.testing import (assert_frame_equal)
 
 from numpy import (
-    absolute,
     arange,
     zeros_like,
 )
@@ -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,

From 1ac5f9ed0c9372e0c6c3b6f46774a7cea1bac9b0 Mon Sep 17 00:00:00 2001
From: Andrew Campbell <andrew@quantopian.com>
Date: Wed, 11 Nov 2015 15:18:53 -0500
Subject: [PATCH 2/2] BUG py3 compatibility for sector mapping

---
 pyfolio/pos.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pyfolio/pos.py b/pyfolio/pos.py
index 03d23d68..89a28ea3 100644
--- a/pyfolio/pos.py
+++ b/pyfolio/pos.py
@@ -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(