Either all return statements in a function should return an expression, or none of them should.
892 return fig
893
894
895def rolling_sortino( 896 returns,
897 benchmark=None,
898 rf=0.0,
Either all return statements in a function should return an expression, or none of them should.
842 return fig
843
844
845def rolling_sharpe( 846 returns,
847 benchmark=None,
848 rf=0.0,
Either all return statements in a function should return an expression, or none of them should.
799 return fig
800
801
802def rolling_volatility( 803 returns,
804 benchmark=None,
805 period=126,
Either all return statements in a function should return an expression, or none of them should.
755 return fig
756
757
758def rolling_beta( 759 returns,
760 benchmark,
761 window1=126,
Either all return statements in a function should return an expression, or none of them should.
717 return fig
718
719
720def drawdowns_periods( 721 returns,
722 periods=5,
723 lw=1.5,
Either all return statements in a function should return an expression, or none of them should.
674 )
675
676
677def drawdown( 678 returns,
679 grayscale=False,
680 figsize=(10, 5),
Either all return statements in a function should return an expression, or none of them should.
595 return fig
596
597
598def distribution( 599 returns,
600 fontname="Arial",
601 grayscale=False,
Either all return statements in a function should return an expression, or none of them should.
533 return fig
534
535
536def yearly_returns( 537 returns,
538 benchmark=None,
539 fontname="Arial",
Either all return statements in a function should return an expression, or none of them should.
488 return fig
489
490
491def daily_returns( 492 returns,
493 benchmark,
494 grayscale=False,
Either all return statements in a function should return an expression, or none of them should.
433 return fig
434
435
436def log_returns( 437 returns,
438 benchmark=None,
439 grayscale=False,
Either all return statements in a function should return an expression, or none of them should.
381 return None
382
383
384def returns( 385 returns,
386 benchmark=None,
387 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)