Either all return statements in a function should return an expression, or none of them should.
887 return fig
888
889
890def rolling_sortino( 891 returns,
892 benchmark=None,
893 rf=0.0,
Either all return statements in a function should return an expression, or none of them should.
837 return fig
838
839
840def rolling_sharpe( 841 returns,
842 benchmark=None,
843 rf=0.0,
Either all return statements in a function should return an expression, or none of them should.
794 return fig
795
796
797def rolling_volatility( 798 returns,
799 benchmark=None,
800 period=126,
Either all return statements in a function should return an expression, or none of them should.
750 return fig
751
752
753def rolling_beta( 754 returns,
755 benchmark,
756 window1=126,
Either all return statements in a function should return an expression, or none of them should.
712 return fig
713
714
715def drawdowns_periods( 716 returns,
717 periods=5,
718 lw=1.5,
Either all return statements in a function should return an expression, or none of them should.
669 )
670
671
672def drawdown( 673 returns,
674 grayscale=False,
675 figsize=(10, 5),
Either all return statements in a function should return an expression, or none of them should.
590 return fig
591
592
593def distribution( 594 returns,
595 fontname="Arial",
596 grayscale=False,
Either all return statements in a function should return an expression, or none of them should.
528 return fig
529
530
531def yearly_returns( 532 returns,
533 benchmark=None,
534 fontname="Arial",
Either all return statements in a function should return an expression, or none of them should.
483 return fig
484
485
486def daily_returns( 487 returns,
488 benchmark,
489 grayscale=False,
Either all return statements in a function should return an expression, or none of them should.
426 return fig
427
428
429def log_returns( 430 returns,
431 benchmark=None,
432 grayscale=False,
Either all return statements in a function should return an expression, or none of them should.
372 return None
373
374
375def returns( 376 returns,
377 benchmark=None,
378 grayscale=False,
Description
According to PEP8, if any return statement returns an expression, any return statements where no value is returned should explicitly state this as return None
, and an explicit return statement should be present at the end of the function (if reachable).
Good:
def foo(x):
if x >= 0:
return math.sqrt(x)
else:
return None
def bar(x):
if x < 0:
return None
return math.sqrt(x)
Bad:
def foo(x):
if x >= 0:
return math.sqrt(x)
def bar(x):
if x < 0:
return
return math.sqrt(x)