Either all return statements in a function should return an expression, or none of them should.
885 return fig
886
887
888def rolling_sortino( 889 returns,
890 benchmark=None,
891 rf=0.0,
Either all return statements in a function should return an expression, or none of them should.
835 return fig
836
837
838def rolling_sharpe( 839 returns,
840 benchmark=None,
841 rf=0.0,
Either all return statements in a function should return an expression, or none of them should.
792 return fig
793
794
795def rolling_volatility( 796 returns,
797 benchmark=None,
798 period=126,
Either all return statements in a function should return an expression, or none of them should.
748 return fig
749
750
751def rolling_beta( 752 returns,
753 benchmark,
754 window1=126,
Either all return statements in a function should return an expression, or none of them should.
710 return fig
711
712
713def drawdowns_periods( 714 returns,
715 periods=5,
716 lw=1.5,
Either all return statements in a function should return an expression, or none of them should.
667 )
668
669
670def drawdown( 671 returns,
672 grayscale=False,
673 figsize=(10, 5),
Either all return statements in a function should return an expression, or none of them should.
588 return fig
589
590
591def distribution( 592 returns,
593 fontname="Arial",
594 grayscale=False,
Either all return statements in a function should return an expression, or none of them should.
526 return fig
527
528
529def yearly_returns( 530 returns,
531 benchmark=None,
532 fontname="Arial",
Either all return statements in a function should return an expression, or none of them should.
481 return fig
482
483
484def daily_returns( 485 returns,
486 benchmark,
487 grayscale=False,
Either all return statements in a function should return an expression, or none of them should.
424 return fig
425
426
427def log_returns( 428 returns,
429 benchmark=None,
430 grayscale=False,
Either all return statements in a function should return an expression, or none of them should.
370 return None
371
372
373def returns( 374 returns,
375 benchmark=None,
376 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)