qis 3.2.3__tar.gz → 3.2.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {qis-3.2.3 → qis-3.2.5}/PKG-INFO +1 -1
- {qis-3.2.3 → qis-3.2.5}/pyproject.toml +1 -1
- {qis-3.2.3 → qis-3.2.5}/qis/examples/core/perf_bbg_prices.py +34 -5
- {qis-3.2.3 → qis-3.2.5}/qis/models/linear/ewm.py +2 -1
- {qis-3.2.3 → qis-3.2.5}/qis/plots/derived/returns_heatmap.py +1 -1
- {qis-3.2.3 → qis-3.2.5}/qis/portfolio/reports/config.py +3 -3
- {qis-3.2.3 → qis-3.2.5}/qis/portfolio/reports/multi_assets_factsheet.py +6 -3
- {qis-3.2.3 → qis-3.2.5}/qis/settings.yaml +0 -1
- qis-3.2.3/qis/examples/bond_futures_portfolio.py +0 -49
- qis-3.2.3/qis/examples/credit_trackers.py +0 -42
- qis-3.2.3/qis/examples/perp_pricing.py +0 -56
- {qis-3.2.3 → qis-3.2.5}/LICENSE.txt +0 -0
- {qis-3.2.3 → qis-3.2.5}/README.md +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/__init__.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/best_returns.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/bootstrap_analysis.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/boxplot_conditional_returns.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/btc_asset_corr.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/constant_notional.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/constant_weight_portfolios.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/core/price_plots.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/core/us_election.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/credit_spreads.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/europe_futures.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/factsheets/multi_assets.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/factsheets/multi_strategy.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/factsheets/pyblogs_reports.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/factsheets/strategy.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/factsheets/strategy_benchmark.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/generate_option_rolls.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/interpolation_infrequent_returns.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/leveraged_strategies.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/long_short.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/momentum_indices.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/ohlc_vol_analysis.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/overnight_returns.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/perf_external_assets.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/readme_performances.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/risk_return_frontier.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/rolling_performance.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/seasonality.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/sharpe_vs_sortino.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/simulate_quant_strats.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/test_ewm.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/test_scatter.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/try_pybloqs.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/universe_corrs.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/vix_beta_to_equities_bonds.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/vix_conditional_returns.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/vix_spy_by_year.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/vix_tenor_analysis.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/examples/vol_without_weekends.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/file_utils.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/local_path.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/models/README.md +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/models/__init__.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/models/linear/__init__.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/models/linear/auto_corr.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/models/linear/corr_cov_matrix.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/models/linear/ewm_convolution.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/models/linear/ewm_factors.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/models/linear/ewm_winsor_outliers.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/models/linear/pca.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/models/linear/plot_correlations.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/models/linear/ra_returns.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/models/stats/__init__.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/models/stats/bootstrap.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/models/stats/ohlc_vol.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/models/stats/rolling_stats.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/models/stats/test_bootstrap.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/perfstats/README.md +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/perfstats/__init__.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/perfstats/cond_regression.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/perfstats/config.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/perfstats/desc_table.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/perfstats/fx_ops.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/perfstats/perf_stats.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/perfstats/regime_classifier.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/perfstats/returns.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/perfstats/timeseries_bfill.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/README.md +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/__init__.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/bars.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/boxplot.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/contour.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/derived/__init__.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/derived/data_timeseries.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/derived/desc_table.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/derived/drawdowns.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/derived/perf_table.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/derived/prices.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/derived/regime_class_table.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/derived/regime_data.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/derived/regime_pdf.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/derived/regime_scatter.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/derived/returns_scatter.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/errorbar.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/heatmap.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/histogram.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/histplot2d.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/lineplot.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/pie.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/qqplot.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/reports/__init__.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/reports/econ_data_single.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/reports/gantt_data_history.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/reports/price_history.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/reports/utils.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/scatter.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/stackplot.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/table.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/time_series.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/plots/utils.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/portfolio/README.md +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/portfolio/__init__.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/portfolio/backtester.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/portfolio/ewm_portfolio_risk.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/portfolio/multi_portfolio_data.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/portfolio/portfolio_data.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/portfolio/reports/__init__.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/portfolio/reports/brinson_attribution.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/portfolio/reports/multi_strategy_factseet_pybloqs.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/portfolio/reports/multi_strategy_factsheet.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/portfolio/reports/strategy_benchmark_factsheet.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/portfolio/reports/strategy_benchmark_factsheet_pybloqs.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/portfolio/reports/strategy_factsheet.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/portfolio/reports/strategy_signal_factsheet.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/portfolio/strats/__init__.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/portfolio/strats/quant_strats_delta1.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/portfolio/strats/seasonal_strats.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/sql_engine.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/test_data.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/utils/README.md +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/utils/__init__.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/utils/dates.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/utils/df_agg.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/utils/df_cut.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/utils/df_freq.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/utils/df_groups.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/utils/df_melt.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/utils/df_ops.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/utils/df_str.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/utils/df_to_scores.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/utils/df_to_weights.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/utils/generic.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/utils/np_ops.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/utils/ols.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/utils/sampling.py +0 -0
- {qis-3.2.3 → qis-3.2.5}/qis/utils/struct_ops.py +0 -0
{qis-3.2.3 → qis-3.2.5}/PKG-INFO
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: qis
|
3
|
-
Version: 3.2.
|
3
|
+
Version: 3.2.5
|
4
4
|
Summary: Implementation of visualisation and reporting analytics for Quantitative Investment Strategies
|
5
5
|
License: LICENSE.txt
|
6
6
|
Keywords: quantitative,investing,portfolio optimization,systematic strategies,volatility
|
@@ -22,15 +22,44 @@ def run_report():
|
|
22
22
|
'BNPXOV3U Index': 'BNP 3M Long DHhedged Puts'
|
23
23
|
}
|
24
24
|
|
25
|
+
benchmark = 'SPTR Index'
|
26
|
+
tickers = {
|
27
|
+
benchmark: benchmark,
|
28
|
+
'BNPIV1EE Index': 'BNP Europe 1Y Volatility',
|
29
|
+
'BNPIV1UE Index': 'BNP US 1Y Volatility',
|
30
|
+
'BNPXVO3A Index': 'BNP VOLA 3 Index',
|
31
|
+
'AIJPVT1U Index': 'JPM Volatility Trend Following',
|
32
|
+
'JPOSLVUS Index': 'JPM US Long Variance',
|
33
|
+
'JPOSPRU2 Index': 'JPM US Put Ratio',
|
34
|
+
'JPOSTUDN Index': 'JPM US Equity Tail Hedge',
|
35
|
+
'JPRC85BE Index': 'JPM Dynamic 85% Rolling Collar EU',
|
36
|
+
'JPRC85BU Index': 'JPM Dynamic 85% Rolling Collar US',
|
37
|
+
'JPUSVXCR Index': 'JPM US Volatility Call Ratio'
|
38
|
+
}
|
39
|
+
|
40
|
+
benchmark = 'HYG US Equity'
|
41
|
+
tickers = {
|
42
|
+
benchmark: benchmark,
|
43
|
+
'NMVVR1EL Index': 'IRVING1 EUR',
|
44
|
+
'NMVVR1UL Index': 'IRVING1 USD',
|
45
|
+
'NMVVR1L Index': 'IRVING1',
|
46
|
+
'BNPXLVRE Index': 'BNP Long Rates Vol EUR',
|
47
|
+
'BNPXLVRU Index': 'BNP Long Rates Vol USD',
|
48
|
+
'BXIIULSV Index': 'Barclays Long Rates Vol',
|
49
|
+
'BXIIUGNT Index': 'Barclays Gamma Neutral Vol',
|
50
|
+
'BXIIUENT Index': 'Barclays Triangle Vol'
|
51
|
+
}
|
52
|
+
|
25
53
|
prices = fetch_field_timeseries_per_tickers(tickers=tickers, freq='B', field='PX_LAST').ffill()
|
26
54
|
print(prices)
|
27
|
-
qis.save_df_to_csv(df=prices, file_name='qis_vol_indices', local_path=qis.get_output_path())
|
55
|
+
# qis.save_df_to_csv(df=prices, file_name='qis_vol_indices', local_path=qis.get_output_path())
|
28
56
|
|
29
|
-
time_period = qis.TimePeriod('
|
30
|
-
kwargs = qis.fetch_default_report_kwargs(time_period=time_period, add_rates_data=False)
|
57
|
+
time_period = qis.TimePeriod('31Dec2024', '07Apr2025')
|
58
|
+
#kwargs = qis.fetch_default_report_kwargs(time_period=time_period, add_rates_data=False)
|
59
|
+
kwargs = qis.fetch_factsheet_config_kwargs(factsheet_config=qis.FACTSHEET_CONFIG_DAILY_DATA_SHORT_PERIOD)
|
31
60
|
|
32
61
|
fig = qis.generate_multi_asset_factsheet(prices=prices,
|
33
|
-
benchmark=
|
62
|
+
benchmark=benchmark,
|
34
63
|
time_period=time_period,
|
35
64
|
**kwargs)
|
36
65
|
qis.save_figs_to_pdf(figs=[fig],
|
@@ -70,7 +99,7 @@ def run_unit_test(unit_test: UnitTests):
|
|
70
99
|
|
71
100
|
if __name__ == '__main__':
|
72
101
|
|
73
|
-
unit_test = UnitTests.
|
102
|
+
unit_test = UnitTests.REPORT
|
74
103
|
|
75
104
|
is_run_all_tests = False
|
76
105
|
if is_run_all_tests:
|
@@ -690,6 +690,7 @@ def compute_ewm_newey_west_vol(data: Union[pd.DataFrame, pd.Series, np.ndarray],
|
|
690
690
|
if mean_adj_type != MeanAdjType.NONE:
|
691
691
|
a = compute_rolling_mean_adj(data=a,
|
692
692
|
mean_adj_type=mean_adj_type,
|
693
|
+
span=span,
|
693
694
|
ewm_lambda=ewm_lambda,
|
694
695
|
init_type=init_type,
|
695
696
|
nan_backfill=nan_backfill)
|
@@ -819,7 +820,7 @@ def compute_rolling_mean_adj(data: Union[pd.DataFrame, pd.Series, np.ndarray],
|
|
819
820
|
mean_adj_type: MeanAdjType = MeanAdjType.EWMA,
|
820
821
|
span: Union[float, np.ndarray] = None,
|
821
822
|
ewm_lambda: Union[float, np.ndarray] = 0.94,
|
822
|
-
init_type: InitType = InitType.
|
823
|
+
init_type: InitType = InitType.X0,
|
823
824
|
init_value: Union[float, np.ndarray, None] = None,
|
824
825
|
nan_backfill: NanBackfill = NanBackfill.FFILL
|
825
826
|
) -> Union[pd.DataFrame, pd.Series, np.ndarray]:
|
@@ -82,9 +82,9 @@ class FactsheetConfig(NamedTuple):
|
|
82
82
|
# create enumerations
|
83
83
|
FACTSHEET_CONFIG_DAILY_DATA_LONG_PERIOD = FactsheetConfig()
|
84
84
|
|
85
|
-
FACTSHEET_CONFIG_DAILY_DATA_SHORT_PERIOD = FactsheetConfig(heatmap_freq='
|
86
|
-
x_date_freq='
|
87
|
-
freq_regime='
|
85
|
+
FACTSHEET_CONFIG_DAILY_DATA_SHORT_PERIOD = FactsheetConfig(heatmap_freq='ME',
|
86
|
+
x_date_freq='ME',
|
87
|
+
freq_regime='W-WED',
|
88
88
|
freq_reg='W-WED',
|
89
89
|
alpha_an_factor=52
|
90
90
|
)
|
@@ -60,6 +60,8 @@ class MultiAssetsReport:
|
|
60
60
|
prices = pd.concat([self.benchmark_prices[benchmark], self.prices], axis=1)
|
61
61
|
else:
|
62
62
|
prices = self.prices
|
63
|
+
# check in case
|
64
|
+
prices = prices.loc[:, ~prices.columns.duplicated(keep='first')]
|
63
65
|
if time_period is not None:
|
64
66
|
prices = time_period.locate(prices)
|
65
67
|
return prices
|
@@ -68,7 +70,7 @@ class MultiAssetsReport:
|
|
68
70
|
regime_benchmark: str,
|
69
71
|
data_df: pd.DataFrame,
|
70
72
|
time_period: TimePeriod = None,
|
71
|
-
regime_params: BenchmarkReturnsQuantileRegimeSpecs =
|
73
|
+
regime_params: BenchmarkReturnsQuantileRegimeSpecs = None
|
72
74
|
) -> None:
|
73
75
|
if isinstance(self.benchmark_prices, pd.Series):
|
74
76
|
pivot_prices = self.benchmark_prices
|
@@ -83,7 +85,7 @@ class MultiAssetsReport:
|
|
83
85
|
data_df=data_df,
|
84
86
|
pivot_prices=pivot_prices,
|
85
87
|
benchmark=regime_benchmark,
|
86
|
-
regime_params=regime_params)
|
88
|
+
regime_params=regime_params or self.regime_params)
|
87
89
|
|
88
90
|
def plot_ra_perf_table(self,
|
89
91
|
benchmark: str,
|
@@ -334,6 +336,7 @@ class MultiAssetsReport:
|
|
334
336
|
roll_freq=freq_sharpe,
|
335
337
|
legend_stats=legend_stats,
|
336
338
|
regime_benchmark=regime_benchmark,
|
339
|
+
regime_params=self.regime_params,
|
337
340
|
ax=ax,
|
338
341
|
**kwargs)
|
339
342
|
return fig
|
@@ -417,7 +420,7 @@ def generate_multi_asset_factsheet(prices: pd.DataFrame,
|
|
417
420
|
heatmap_freq: str = 'YE',
|
418
421
|
time_period: TimePeriod = None, # time period for reporting
|
419
422
|
figsize: Tuple[float, float] = (8.3, 11.7), # A4 for portrait
|
420
|
-
fontsize: int =
|
423
|
+
fontsize: int = 4,
|
421
424
|
factsheet_name: str = None,
|
422
425
|
performance_bars: Tuple[PerfStat, PerfStat] = (PerfStat.SHARPE_RF0, PerfStat.MAX_DD),
|
423
426
|
drop_1y_ra_perf_table: bool = True,
|
@@ -1,49 +0,0 @@
|
|
1
|
-
import pandas as pd
|
2
|
-
import numpy as np
|
3
|
-
import matplotlib.pyplot as plt
|
4
|
-
from enum import Enum
|
5
|
-
import qis as qis
|
6
|
-
|
7
|
-
import futures_strats.local_path as lp
|
8
|
-
|
9
|
-
output_path = lp.OUTPUT_PATH
|
10
|
-
local_path = lp.LOCAL_PATH
|
11
|
-
# futures_strats
|
12
|
-
from futures_strats import (compute_strategy_portfolio_data_with_costs,
|
13
|
-
compute_multi_strategy_data_from_blocks,
|
14
|
-
compute_marginal_perfs_for_strategy)
|
15
|
-
from futures_strats.data.universes.futures.bbg_futures import Universes
|
16
|
-
from futures_strats.data.providers.bloomberg.assets_bbg import AssetsBBG
|
17
|
-
from futures_strats.research.cross_trend import (CSTF_RB_TRACKER,
|
18
|
-
CSTF_EXACT_TRACKER,
|
19
|
-
CSTF_RB_AC_TRACKER)
|
20
|
-
from futures_strats.research.trackers import (CSTF_GOLDMAN_TRACKER_AC,
|
21
|
-
GOLDMAN_UNIVERSE)
|
22
|
-
|
23
|
-
strategy_universe = Universes.BBG_FUTURES_INVESTABLE.load_universe_data(local_path=local_path)
|
24
|
-
prices = strategy_universe.get_prices(freq='B')[['UXY1 Comdty', 'US1 Comdty', 'WN1 Comdty']].ffill().dropna()
|
25
|
-
prices = prices[prices.columns[::-1]]
|
26
|
-
qis.plot_prices_with_dd(prices=prices)
|
27
|
-
|
28
|
-
portfolio_data = qis.backtest_model_portfolio(prices=prices,
|
29
|
-
weights=np.array([-1.0, 2.0, -1.0]),
|
30
|
-
rebalancing_freq='ME',
|
31
|
-
ticker='Butterly'
|
32
|
-
)
|
33
|
-
|
34
|
-
time_period = qis.TimePeriod('31Dec2015', None)
|
35
|
-
figs = qis.generate_strategy_factsheet(portfolio_data=portfolio_data,
|
36
|
-
benchmark_prices=prices.iloc[:, -1],
|
37
|
-
is_grouped=False,
|
38
|
-
add_current_position_var_risk_sheet=False,
|
39
|
-
add_weights_turnover_sheet=False,
|
40
|
-
add_grouped_exposures=False,
|
41
|
-
add_grouped_cum_pnl=False,
|
42
|
-
time_period=time_period,
|
43
|
-
**qis.fetch_default_report_kwargs(time_period=time_period,
|
44
|
-
add_rates_data=False))
|
45
|
-
|
46
|
-
qis.save_figs_to_pdf(figs=figs, file_name=f"butterfly", orientation='landscape',
|
47
|
-
local_path=output_path)
|
48
|
-
|
49
|
-
plt.show()
|
@@ -1,42 +0,0 @@
|
|
1
|
-
|
2
|
-
import pandas as pd
|
3
|
-
import matplotlib.pyplot as plt
|
4
|
-
import seaborn as sns
|
5
|
-
import qis as qis
|
6
|
-
from bbg_fetch import fetch_field_timeseries_per_tickers
|
7
|
-
|
8
|
-
|
9
|
-
tickers = {'CICMCE5B Index': 'ITRAXX Main 5Y',
|
10
|
-
'CICMCE1B Index': 'ITRAXX Main 10Y',
|
11
|
-
'CICMCX5B Index': 'ITRAXX Xover 5Y',
|
12
|
-
'CICMCI5B Index': 'CDX NA IG 5Y',
|
13
|
-
'CICMCI1B Index': 'CDX NA IG 10Y',
|
14
|
-
'CICMCH5B Index': 'CDX NA HY 5Y',
|
15
|
-
'CICMCG05 Index': 'UK CDS 5Y',
|
16
|
-
'CICMCK05 Index': 'South Korea CDS 5Y',
|
17
|
-
'CICMCJ05 Index': 'Japan CDS 5Y',
|
18
|
-
'CICMCU05 Index': 'US CDS 5Y',
|
19
|
-
'CICMCE05 Index': 'Germany CDS 5Y'
|
20
|
-
}
|
21
|
-
|
22
|
-
tickers = {'UISYMH5S Index': 'UBS_CDX_HY',
|
23
|
-
'CICMCH5B Index': 'CITI_CDX_HY',
|
24
|
-
'CH5LMER5 Index': 'GS_CDX_HY',
|
25
|
-
'UISYMI5S Index': 'UBS_IG_5Y',
|
26
|
-
'CICMCI5B Index': 'CITI_IG_5Y',
|
27
|
-
'CI5LMER5 Index': 'GS_IG_5Y'}
|
28
|
-
|
29
|
-
prices = fetch_field_timeseries_per_tickers(tickers=tickers, freq='B', field='PX_LAST').ffill()
|
30
|
-
print(prices)
|
31
|
-
benchmark_prices = fetch_field_timeseries_per_tickers(tickers={'LGDRTRUU Index': 'Agg IG'}, freq='B', field='PX_LAST').ffill()
|
32
|
-
|
33
|
-
time_period = qis.TimePeriod('01Jan2008', pd.Timestamp.today())
|
34
|
-
kwargs = qis.fetch_default_report_kwargs(time_period=time_period, add_rates_data=False)
|
35
|
-
|
36
|
-
fig = qis.generate_multi_asset_factsheet(prices=prices,
|
37
|
-
benchmark_prices=benchmark_prices,
|
38
|
-
time_period=time_period,
|
39
|
-
**kwargs)
|
40
|
-
qis.save_figs_to_pdf(figs=[fig],
|
41
|
-
file_name=f"credit_trackers_report", orientation='landscape',
|
42
|
-
local_path=qis.local_path.get_output_path())
|
@@ -1,56 +0,0 @@
|
|
1
|
-
import pandas as pd
|
2
|
-
import numpy as np
|
3
|
-
import matplotlib.pyplot as plt
|
4
|
-
import seaborn as sns
|
5
|
-
import qis as qis
|
6
|
-
from bbg_fetch import fetch_field_timeseries_per_tickers, fetch_index_members_weights, fetch_bonds_info
|
7
|
-
|
8
|
-
|
9
|
-
index_ticker = 'I31415US Index'
|
10
|
-
|
11
|
-
end_dates = ['20180101', '20190101', '20200101', '20210101', '20220101', '20230101', '20240101', '20250101', '20250106']
|
12
|
-
|
13
|
-
data_out = {}
|
14
|
-
weighted_resets = []
|
15
|
-
for idx, end_date in enumerate(end_dates):
|
16
|
-
if idx > 0:
|
17
|
-
members = fetch_index_members_weights(index_ticker, END_DATE_OVERRIDE=end_dates[idx-1])
|
18
|
-
corp_index = [f"{x} corp" for x in members.index]
|
19
|
-
members.index = corp_index
|
20
|
-
"""
|
21
|
-
amt_outstanding = fetch_bonds_info(isins=members.index.to_list(), fields=['amt_outstanding'],
|
22
|
-
END_DATE_OVERRIDE=end_dates[idx-1])['amt_outstanding']
|
23
|
-
amt_outstanding = amt_outstanding.loc[members.index]
|
24
|
-
amt_outstanding.index = corp_index
|
25
|
-
"""
|
26
|
-
prices = fetch_field_timeseries_per_tickers(tickers=corp_index,
|
27
|
-
start_date=pd.Timestamp(end_dates[idx-1]),
|
28
|
-
end_date=pd.Timestamp(end_date),
|
29
|
-
freq='B')
|
30
|
-
prices = prices.resample('W-WED').last()
|
31
|
-
# market_value = prices.multiply(amt_outstanding, axis=1)
|
32
|
-
#market_value.divide(np.nansum(market_value, axis=1, keepdims=True), axis=1)
|
33
|
-
is_reset = (prices > 100).astype(float)
|
34
|
-
market_weights = members.iloc[:, 0]
|
35
|
-
weighted_reset = is_reset.multiply(market_weights, axis=1)
|
36
|
-
weighted_reset = weighted_reset.sum(1)
|
37
|
-
weighted_resets.append(weighted_reset)
|
38
|
-
data_out[f"{end_dates[idx-1]} members"] = members
|
39
|
-
data_out[f"{end_date} prices"] = prices
|
40
|
-
data_out[f"{end_date} is_reset"] = is_reset
|
41
|
-
|
42
|
-
weighted_resets = pd.concat(weighted_resets)
|
43
|
-
weighted_resets = weighted_resets.loc[~weighted_resets.index.duplicated(keep='first')]
|
44
|
-
weighted_resets = weighted_resets.to_frame('weighted_par_reset %')
|
45
|
-
print(weighted_resets)
|
46
|
-
|
47
|
-
data_out['weighted_resets'] = weighted_resets
|
48
|
-
qis.save_df_to_excel(data=data_out, file_name='perp_pricing')
|
49
|
-
|
50
|
-
with sns.axes_style("darkgrid"):
|
51
|
-
fig, ax = plt.subplots(1, 1, figsize=(15, 8), tight_layout=True)
|
52
|
-
qis.plot_time_series(weighted_resets,
|
53
|
-
title='weighted_par_reset',
|
54
|
-
ax=ax)
|
55
|
-
|
56
|
-
plt.show()
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|