Skip to content

Commit cce6e1d

Browse files
author
Thomas Schmelzer
committed
proper interpolation
1 parent 9686a3c commit cce6e1d

File tree

4 files changed

+1521
-254
lines changed

4 files changed

+1521
-254
lines changed

book/docs/notebooks/cla.ipynb

Lines changed: 1302 additions & 54 deletions
Large diffs are not rendered by default.

book/docs/notebooks/data/prices.csv

Lines changed: 0 additions & 5 deletions
This file was deleted.

cvx/cla/types.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def interpolate(self, num=100):
9595
"""
9696

9797
def _interpolate():
98-
for w_left, w_right in zip(self.weights[0:-1], self.weights[1:]):
98+
for w_right, w_left in zip(self.weights[0:-1], self.weights[1:]):
9999
for lamb in np.linspace(0, 1, num):
100100
if lamb > 0:
101101
yield FrontierPoint(
@@ -217,14 +217,22 @@ def neg_sharpe(alpha, w_left, w_right):
217217

218218
return sharpe_ratio_right, w_right
219219

220-
def plot(self):
220+
def plot(self, volatility=False, markers=True):
221221
"""
222222
Plot the frontier
223223
"""
224-
fig = px.line(
225-
x=self.variance,
226-
y=self.returns,
227-
markers=True,
228-
labels={"x": "Expected variance", "y": "Expected Return"},
229-
)
224+
if not volatility:
225+
fig = px.line(
226+
x=self.variance,
227+
y=self.returns,
228+
markers=markers,
229+
labels={"x": "Expected variance", "y": "Expected Return"},
230+
)
231+
else:
232+
fig = px.line(
233+
x=self.volatility,
234+
y=self.returns,
235+
markers=markers,
236+
labels={"x": "Expected volatility", "y": "Expected Return"},
237+
)
230238
return fig

0 commit comments

Comments
 (0)