Skip to content

Commit 85433bd

Browse files
committed
del useless params in full tear sheet. add and adjust return_fig
1 parent b830357 commit 85433bd

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

pyfolio/tears.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,6 @@ def create_full_tear_sheet(returns,
6666
cone_std=(1.0, 1.5, 2.0),
6767
bootstrap=False,
6868
unadjusted_returns=None,
69-
style_factors=None,
70-
sectors=None,
71-
caps=None,
72-
shares_held=None,
73-
volumes=None,
74-
percentile=None,
7569
turnover_denom='AGB',
7670
set_context=True,
7771
factor_returns=None,
@@ -603,8 +597,8 @@ def create_returns_tear_sheet(returns, positions=None,
603597
@plotting.customize
604598
def create_position_tear_sheet(returns, positions,
605599
show_and_plot_top_pos=2, hide_positions=False,
606-
return_fig=False, sector_mappings=None,
607-
transactions=None, estimate_intraday='infer'):
600+
sector_mappings=None, transactions=None,
601+
estimate_intraday='infer', return_fig=False):
608602
"""
609603
Generate a number of plots for analyzing a
610604
strategy's positions and holdings.
@@ -627,8 +621,6 @@ def create_position_tear_sheet(returns, positions,
627621
hide_positions : bool, optional
628622
If True, will not output any symbol names.
629623
Overrides show_and_plot_top_pos to 0 to suppress text output.
630-
return_fig : boolean, optional
631-
If True, returns the figure that was plotted on.
632624
sector_mappings : dict or pd.Series, optional
633625
Security identifier to sector mapping.
634626
Security ids as keys, sectors as values.
@@ -638,6 +630,8 @@ def create_position_tear_sheet(returns, positions,
638630
estimate_intraday: boolean or str, optional
639631
Approximate returns for intraday strategies.
640632
See description in create_full_tear_sheet.
633+
return_fig : boolean, optional
634+
If True, returns the figure that was plotted on.
641635
"""
642636

643637
positions = utils.check_intraday(estimate_intraday, returns,
@@ -956,7 +950,8 @@ def create_capacity_tear_sheet(returns, positions, transactions,
956950
trade_daily_vol_limit=0.05,
957951
last_n_days=utils.APPROX_BDAYS_PER_MONTH * 6,
958952
days_to_liquidate_limit=1,
959-
estimate_intraday='infer'):
953+
estimate_intraday='infer',
954+
return_fig=False):
960955
"""
961956
Generates a report detailing portfolio size constraints set by
962957
least liquid tickers. Plots a "capacity sweep," a curve describing
@@ -993,6 +988,8 @@ def create_capacity_tear_sheet(returns, positions, transactions,
993988
estimate_intraday: boolean or str, optional
994989
Approximate returns for intraday strategies.
995990
See description in create_full_tear_sheet.
991+
return_fig : boolean, optional
992+
If True, returns the figure that was plotted on.
996993
"""
997994

998995
positions = utils.check_intraday(estimate_intraday, returns,
@@ -1046,14 +1043,17 @@ def create_capacity_tear_sheet(returns, positions, transactions,
10461043
llt[llt['max_pct_bar_consumed'] > trade_daily_vol_limit * 100])
10471044

10481045
bt_starting_capital = positions.iloc[0].sum() / (1 + returns.iloc[0])
1049-
_, ax_capacity_sweep = plt.subplots(figsize=(14, 6))
1046+
fig, ax_capacity_sweep = plt.subplots(figsize=(14, 6))
10501047
plotting.plot_capacity_sweep(returns, transactions, market_data,
10511048
bt_starting_capital,
10521049
min_pv=100000,
10531050
max_pv=300000000,
10541051
step_size=1000000,
10551052
ax=ax_capacity_sweep)
10561053

1054+
if return_fig:
1055+
return fig
1056+
10571057

10581058
@plotting.customize
10591059
def create_perf_attrib_tear_sheet(returns,
@@ -1062,8 +1062,8 @@ def create_perf_attrib_tear_sheet(returns,
10621062
factor_loadings,
10631063
transactions=None,
10641064
pos_in_dollars=True,
1065-
return_fig=False,
1066-
factor_partitions=FACTOR_PARTITIONS):
1065+
factor_partitions=FACTOR_PARTITIONS,
1066+
return_fig=False):
10671067
"""
10681068
Generate plots and tables for analyzing a strategy's performance.
10691069
@@ -1093,15 +1093,15 @@ def create_perf_attrib_tear_sheet(returns,
10931093
Flag indicating whether `positions` are in dollars or percentages
10941094
If True, positions are in dollars.
10951095
1096-
return_fig : boolean, optional
1097-
If True, returns the figure that was plotted on.
1098-
10991096
factor_partitions : dict
11001097
dict specifying how factors should be separated in factor returns
11011098
and risk exposures plots
11021099
- Example:
11031100
{'style': ['momentum', 'size', 'value', ...],
11041101
'sector': ['technology', 'materials', ... ]}
1102+
1103+
return_fig : boolean, optional
1104+
If True, returns the figure that was plotted on.
11051105
"""
11061106
portfolio_exposures, perf_attrib_data = perf_attrib.perf_attrib(
11071107
returns, positions, factor_returns, factor_loadings, transactions,

0 commit comments

Comments
 (0)