qis 3.1.1__tar.gz → 3.1.3__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.
Files changed (149) hide show
  1. {qis-3.1.1 → qis-3.1.3}/PKG-INFO +1 -1
  2. {qis-3.1.1 → qis-3.1.3}/pyproject.toml +1 -1
  3. {qis-3.1.1 → qis-3.1.3}/qis/file_utils.py +30 -11
  4. {qis-3.1.1 → qis-3.1.3}/qis/settings.yaml +0 -2
  5. {qis-3.1.1 → qis-3.1.3}/LICENSE.txt +0 -0
  6. {qis-3.1.1 → qis-3.1.3}/README.md +0 -0
  7. {qis-3.1.1 → qis-3.1.3}/qis/__init__.py +0 -0
  8. {qis-3.1.1 → qis-3.1.3}/qis/examples/best_returns.py +0 -0
  9. {qis-3.1.1 → qis-3.1.3}/qis/examples/bond_futures_portfolio.py +0 -0
  10. {qis-3.1.1 → qis-3.1.3}/qis/examples/bootstrap_analysis.py +0 -0
  11. {qis-3.1.1 → qis-3.1.3}/qis/examples/boxplot_conditional_returns.py +0 -0
  12. {qis-3.1.1 → qis-3.1.3}/qis/examples/btc_asset_corr.py +0 -0
  13. {qis-3.1.1 → qis-3.1.3}/qis/examples/constant_notional.py +0 -0
  14. {qis-3.1.1 → qis-3.1.3}/qis/examples/constant_weight_portfolios.py +0 -0
  15. {qis-3.1.1 → qis-3.1.3}/qis/examples/core/perf_bbg_prices.py +0 -0
  16. {qis-3.1.1 → qis-3.1.3}/qis/examples/core/price_plots.py +0 -0
  17. {qis-3.1.1 → qis-3.1.3}/qis/examples/core/us_election.py +0 -0
  18. {qis-3.1.1 → qis-3.1.3}/qis/examples/credit_spreads.py +0 -0
  19. {qis-3.1.1 → qis-3.1.3}/qis/examples/credit_trackers.py +0 -0
  20. {qis-3.1.1 → qis-3.1.3}/qis/examples/europe_futures.py +0 -0
  21. {qis-3.1.1 → qis-3.1.3}/qis/examples/factsheets/multi_assets.py +0 -0
  22. {qis-3.1.1 → qis-3.1.3}/qis/examples/factsheets/multi_strategy.py +0 -0
  23. {qis-3.1.1 → qis-3.1.3}/qis/examples/factsheets/pyblogs_reports.py +0 -0
  24. {qis-3.1.1 → qis-3.1.3}/qis/examples/factsheets/strategy.py +0 -0
  25. {qis-3.1.1 → qis-3.1.3}/qis/examples/factsheets/strategy_benchmark.py +0 -0
  26. {qis-3.1.1 → qis-3.1.3}/qis/examples/generate_option_rolls.py +0 -0
  27. {qis-3.1.1 → qis-3.1.3}/qis/examples/interpolation_infrequent_returns.py +0 -0
  28. {qis-3.1.1 → qis-3.1.3}/qis/examples/leveraged_strategies.py +0 -0
  29. {qis-3.1.1 → qis-3.1.3}/qis/examples/long_short.py +0 -0
  30. {qis-3.1.1 → qis-3.1.3}/qis/examples/momentum_indices.py +0 -0
  31. {qis-3.1.1 → qis-3.1.3}/qis/examples/ohlc_vol_analysis.py +0 -0
  32. {qis-3.1.1 → qis-3.1.3}/qis/examples/overnight_returns.py +0 -0
  33. {qis-3.1.1 → qis-3.1.3}/qis/examples/perf_external_assets.py +0 -0
  34. {qis-3.1.1 → qis-3.1.3}/qis/examples/perp_pricing.py +0 -0
  35. {qis-3.1.1 → qis-3.1.3}/qis/examples/readme_performances.py +0 -0
  36. {qis-3.1.1 → qis-3.1.3}/qis/examples/risk_return_frontier.py +0 -0
  37. {qis-3.1.1 → qis-3.1.3}/qis/examples/rolling_performance.py +0 -0
  38. {qis-3.1.1 → qis-3.1.3}/qis/examples/seasonality.py +0 -0
  39. {qis-3.1.1 → qis-3.1.3}/qis/examples/sharpe_vs_sortino.py +0 -0
  40. {qis-3.1.1 → qis-3.1.3}/qis/examples/simulate_quant_strats.py +0 -0
  41. {qis-3.1.1 → qis-3.1.3}/qis/examples/test_ewm.py +0 -0
  42. {qis-3.1.1 → qis-3.1.3}/qis/examples/test_scatter.py +0 -0
  43. {qis-3.1.1 → qis-3.1.3}/qis/examples/try_pybloqs.py +0 -0
  44. {qis-3.1.1 → qis-3.1.3}/qis/examples/universe_corrs.py +0 -0
  45. {qis-3.1.1 → qis-3.1.3}/qis/examples/vix_beta_to_equities_bonds.py +0 -0
  46. {qis-3.1.1 → qis-3.1.3}/qis/examples/vix_conditional_returns.py +0 -0
  47. {qis-3.1.1 → qis-3.1.3}/qis/examples/vix_spy_by_year.py +0 -0
  48. {qis-3.1.1 → qis-3.1.3}/qis/examples/vix_tenor_analysis.py +0 -0
  49. {qis-3.1.1 → qis-3.1.3}/qis/examples/vol_without_weekends.py +0 -0
  50. {qis-3.1.1 → qis-3.1.3}/qis/local_path.py +0 -0
  51. {qis-3.1.1 → qis-3.1.3}/qis/models/README.md +0 -0
  52. {qis-3.1.1 → qis-3.1.3}/qis/models/__init__.py +0 -0
  53. {qis-3.1.1 → qis-3.1.3}/qis/models/linear/__init__.py +0 -0
  54. {qis-3.1.1 → qis-3.1.3}/qis/models/linear/auto_corr.py +0 -0
  55. {qis-3.1.1 → qis-3.1.3}/qis/models/linear/corr_cov_matrix.py +0 -0
  56. {qis-3.1.1 → qis-3.1.3}/qis/models/linear/ewm.py +0 -0
  57. {qis-3.1.1 → qis-3.1.3}/qis/models/linear/ewm_convolution.py +0 -0
  58. {qis-3.1.1 → qis-3.1.3}/qis/models/linear/ewm_factors.py +0 -0
  59. {qis-3.1.1 → qis-3.1.3}/qis/models/linear/ewm_winsor_outliers.py +0 -0
  60. {qis-3.1.1 → qis-3.1.3}/qis/models/linear/pca.py +0 -0
  61. {qis-3.1.1 → qis-3.1.3}/qis/models/linear/plot_correlations.py +0 -0
  62. {qis-3.1.1 → qis-3.1.3}/qis/models/linear/ra_returns.py +0 -0
  63. {qis-3.1.1 → qis-3.1.3}/qis/models/stats/__init__.py +0 -0
  64. {qis-3.1.1 → qis-3.1.3}/qis/models/stats/bootstrap.py +0 -0
  65. {qis-3.1.1 → qis-3.1.3}/qis/models/stats/ohlc_vol.py +0 -0
  66. {qis-3.1.1 → qis-3.1.3}/qis/models/stats/rolling_stats.py +0 -0
  67. {qis-3.1.1 → qis-3.1.3}/qis/models/stats/test_bootstrap.py +0 -0
  68. {qis-3.1.1 → qis-3.1.3}/qis/perfstats/README.md +0 -0
  69. {qis-3.1.1 → qis-3.1.3}/qis/perfstats/__init__.py +0 -0
  70. {qis-3.1.1 → qis-3.1.3}/qis/perfstats/cond_regression.py +0 -0
  71. {qis-3.1.1 → qis-3.1.3}/qis/perfstats/config.py +0 -0
  72. {qis-3.1.1 → qis-3.1.3}/qis/perfstats/desc_table.py +0 -0
  73. {qis-3.1.1 → qis-3.1.3}/qis/perfstats/fx_ops.py +0 -0
  74. {qis-3.1.1 → qis-3.1.3}/qis/perfstats/perf_stats.py +0 -0
  75. {qis-3.1.1 → qis-3.1.3}/qis/perfstats/regime_classifier.py +0 -0
  76. {qis-3.1.1 → qis-3.1.3}/qis/perfstats/returns.py +0 -0
  77. {qis-3.1.1 → qis-3.1.3}/qis/perfstats/timeseries_bfill.py +0 -0
  78. {qis-3.1.1 → qis-3.1.3}/qis/plots/README.md +0 -0
  79. {qis-3.1.1 → qis-3.1.3}/qis/plots/__init__.py +0 -0
  80. {qis-3.1.1 → qis-3.1.3}/qis/plots/bars.py +0 -0
  81. {qis-3.1.1 → qis-3.1.3}/qis/plots/boxplot.py +0 -0
  82. {qis-3.1.1 → qis-3.1.3}/qis/plots/contour.py +0 -0
  83. {qis-3.1.1 → qis-3.1.3}/qis/plots/derived/__init__.py +0 -0
  84. {qis-3.1.1 → qis-3.1.3}/qis/plots/derived/data_timeseries.py +0 -0
  85. {qis-3.1.1 → qis-3.1.3}/qis/plots/derived/desc_table.py +0 -0
  86. {qis-3.1.1 → qis-3.1.3}/qis/plots/derived/drawdowns.py +0 -0
  87. {qis-3.1.1 → qis-3.1.3}/qis/plots/derived/perf_table.py +0 -0
  88. {qis-3.1.1 → qis-3.1.3}/qis/plots/derived/prices.py +0 -0
  89. {qis-3.1.1 → qis-3.1.3}/qis/plots/derived/regime_class_table.py +0 -0
  90. {qis-3.1.1 → qis-3.1.3}/qis/plots/derived/regime_data.py +0 -0
  91. {qis-3.1.1 → qis-3.1.3}/qis/plots/derived/regime_pdf.py +0 -0
  92. {qis-3.1.1 → qis-3.1.3}/qis/plots/derived/regime_scatter.py +0 -0
  93. {qis-3.1.1 → qis-3.1.3}/qis/plots/derived/returns_heatmap.py +0 -0
  94. {qis-3.1.1 → qis-3.1.3}/qis/plots/derived/returns_scatter.py +0 -0
  95. {qis-3.1.1 → qis-3.1.3}/qis/plots/errorbar.py +0 -0
  96. {qis-3.1.1 → qis-3.1.3}/qis/plots/heatmap.py +0 -0
  97. {qis-3.1.1 → qis-3.1.3}/qis/plots/histogram.py +0 -0
  98. {qis-3.1.1 → qis-3.1.3}/qis/plots/histplot2d.py +0 -0
  99. {qis-3.1.1 → qis-3.1.3}/qis/plots/lineplot.py +0 -0
  100. {qis-3.1.1 → qis-3.1.3}/qis/plots/pie.py +0 -0
  101. {qis-3.1.1 → qis-3.1.3}/qis/plots/qqplot.py +0 -0
  102. {qis-3.1.1 → qis-3.1.3}/qis/plots/reports/__init__.py +0 -0
  103. {qis-3.1.1 → qis-3.1.3}/qis/plots/reports/econ_data_single.py +0 -0
  104. {qis-3.1.1 → qis-3.1.3}/qis/plots/reports/gantt_data_history.py +0 -0
  105. {qis-3.1.1 → qis-3.1.3}/qis/plots/reports/price_history.py +0 -0
  106. {qis-3.1.1 → qis-3.1.3}/qis/plots/reports/utils.py +0 -0
  107. {qis-3.1.1 → qis-3.1.3}/qis/plots/scatter.py +0 -0
  108. {qis-3.1.1 → qis-3.1.3}/qis/plots/stackplot.py +0 -0
  109. {qis-3.1.1 → qis-3.1.3}/qis/plots/table.py +0 -0
  110. {qis-3.1.1 → qis-3.1.3}/qis/plots/time_series.py +0 -0
  111. {qis-3.1.1 → qis-3.1.3}/qis/plots/utils.py +0 -0
  112. {qis-3.1.1 → qis-3.1.3}/qis/portfolio/README.md +0 -0
  113. {qis-3.1.1 → qis-3.1.3}/qis/portfolio/__init__.py +0 -0
  114. {qis-3.1.1 → qis-3.1.3}/qis/portfolio/backtester.py +0 -0
  115. {qis-3.1.1 → qis-3.1.3}/qis/portfolio/ewm_portfolio_risk.py +0 -0
  116. {qis-3.1.1 → qis-3.1.3}/qis/portfolio/multi_portfolio_data.py +0 -0
  117. {qis-3.1.1 → qis-3.1.3}/qis/portfolio/portfolio_data.py +0 -0
  118. {qis-3.1.1 → qis-3.1.3}/qis/portfolio/reports/__init__.py +0 -0
  119. {qis-3.1.1 → qis-3.1.3}/qis/portfolio/reports/brinson_attribution.py +0 -0
  120. {qis-3.1.1 → qis-3.1.3}/qis/portfolio/reports/config.py +0 -0
  121. {qis-3.1.1 → qis-3.1.3}/qis/portfolio/reports/multi_assets_factsheet.py +0 -0
  122. {qis-3.1.1 → qis-3.1.3}/qis/portfolio/reports/multi_strategy_factseet_pybloqs.py +0 -0
  123. {qis-3.1.1 → qis-3.1.3}/qis/portfolio/reports/multi_strategy_factsheet.py +0 -0
  124. {qis-3.1.1 → qis-3.1.3}/qis/portfolio/reports/strategy_benchmark_factsheet.py +0 -0
  125. {qis-3.1.1 → qis-3.1.3}/qis/portfolio/reports/strategy_benchmark_factsheet_pybloqs.py +0 -0
  126. {qis-3.1.1 → qis-3.1.3}/qis/portfolio/reports/strategy_factsheet.py +0 -0
  127. {qis-3.1.1 → qis-3.1.3}/qis/portfolio/reports/strategy_signal_factsheet.py +0 -0
  128. {qis-3.1.1 → qis-3.1.3}/qis/portfolio/strats/__init__.py +0 -0
  129. {qis-3.1.1 → qis-3.1.3}/qis/portfolio/strats/quant_strats_delta1.py +0 -0
  130. {qis-3.1.1 → qis-3.1.3}/qis/portfolio/strats/seasonal_strats.py +0 -0
  131. {qis-3.1.1 → qis-3.1.3}/qis/sql_engine.py +0 -0
  132. {qis-3.1.1 → qis-3.1.3}/qis/test_data.py +0 -0
  133. {qis-3.1.1 → qis-3.1.3}/qis/utils/README.md +0 -0
  134. {qis-3.1.1 → qis-3.1.3}/qis/utils/__init__.py +0 -0
  135. {qis-3.1.1 → qis-3.1.3}/qis/utils/dates.py +0 -0
  136. {qis-3.1.1 → qis-3.1.3}/qis/utils/df_agg.py +0 -0
  137. {qis-3.1.1 → qis-3.1.3}/qis/utils/df_cut.py +0 -0
  138. {qis-3.1.1 → qis-3.1.3}/qis/utils/df_freq.py +0 -0
  139. {qis-3.1.1 → qis-3.1.3}/qis/utils/df_groups.py +0 -0
  140. {qis-3.1.1 → qis-3.1.3}/qis/utils/df_melt.py +0 -0
  141. {qis-3.1.1 → qis-3.1.3}/qis/utils/df_ops.py +0 -0
  142. {qis-3.1.1 → qis-3.1.3}/qis/utils/df_str.py +0 -0
  143. {qis-3.1.1 → qis-3.1.3}/qis/utils/df_to_scores.py +0 -0
  144. {qis-3.1.1 → qis-3.1.3}/qis/utils/df_to_weights.py +0 -0
  145. {qis-3.1.1 → qis-3.1.3}/qis/utils/generic.py +0 -0
  146. {qis-3.1.1 → qis-3.1.3}/qis/utils/np_ops.py +0 -0
  147. {qis-3.1.1 → qis-3.1.3}/qis/utils/ols.py +0 -0
  148. {qis-3.1.1 → qis-3.1.3}/qis/utils/sampling.py +0 -0
  149. {qis-3.1.1 → qis-3.1.3}/qis/utils/struct_ops.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: qis
3
- Version: 3.1.1
3
+ Version: 3.1.3
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
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "qis"
3
- version = "3.1.1"
3
+ version = "3.1.3"
4
4
  description = "Implementation of visualisation and reporting analytics for Quantitative Investment Strategies"
5
5
  license = "LICENSE.txt"
6
6
  authors = ["Artur Sepp <artursepp@gmail.com>"]
@@ -231,14 +231,14 @@ def save_df_to_excel(data: Union[pd.DataFrame, List[pd.DataFrame], Dict[str, pd.
231
231
  if sheet_names is None:
232
232
  sheet_names = [f"Sheet {n+1}" for n, _ in enumerate(data)]
233
233
  for df, name in zip(data, sheet_names):
234
- if df is not None:
234
+ if df is not None and isinstance(df, pd.DataFrame):
235
235
  df = delocalize_df(df)
236
236
  if transpose:
237
237
  df = df.T
238
238
  df.to_excel(excel_writer=excel_writer, sheet_name=name)
239
239
  elif isinstance(data, dict): # publish with sheet names
240
240
  for key, df in data.items():
241
- if df is not None:
241
+ if df is not None and isinstance(df, pd.DataFrame):
242
242
  df = delocalize_df(df)
243
243
  if transpose:
244
244
  df = df.T
@@ -482,7 +482,7 @@ def save_df_dict_to_csv(datasets: Dict[Union[str, Enum, NamedTuple], pd.DataFram
482
482
  file_name = f"{file_name}_{pd.Timestamp.now().strftime(DATE_FORMAT)}"
483
483
 
484
484
  for key, data in datasets.items():
485
- if data is not None:
485
+ if data is not None and isinstance(data, pd.DataFrame):
486
486
  file_path = get_local_file_path(file_name=file_name,
487
487
  file_type=FileTypes.CSV,
488
488
  local_path=local_path,
@@ -535,16 +535,32 @@ def save_df_dict_to_sql(engine: Engine,
535
535
  table_name: str,
536
536
  dfs: Dict[Union[str, Enum, NamedTuple], pd.DataFrame],
537
537
  schema: Optional[str] = None,
538
- index_col: Optional[str] = INDEX_COLUMN
538
+ index_col: Optional[str] = INDEX_COLUMN,
539
+ if_exists: Literal["fail", "replace", "append"] | Literal["truncate-append"] = "fail",
539
540
  ) -> None:
540
541
  """
541
542
  save pandas dict to sql engine
542
543
  """
543
544
  for key, df in dfs.items():
544
- if df is not None:
545
+ if df is not None and isinstance(df, pd.DataFrame):
545
546
  if index_col is not None:
546
547
  df = df.reset_index(names=index_col)
547
- df.to_sql(f"{table_name}_{key}", engine, schema=schema, if_exists='replace')
548
+ if if_exists == "truncate-append":
549
+ schema_str = f"{schema}." if schema else ""
550
+ with engine.connect() as con:
551
+ statement = text(f"TRUNCATE TABLE {schema_str}{table_name}_{key}")
552
+ con.execute(statement)
553
+ con.commit()
554
+ df.to_sql(
555
+ f"{table_name}_{key}",
556
+ engine,
557
+ schema=schema,
558
+ if_exists='append',
559
+ method='multi',
560
+ chunksize=1000
561
+ )
562
+ else:
563
+ df.to_sql(f"{table_name}_{key}", engine, schema=schema, if_exists=if_exists)
548
564
 
549
565
 
550
566
  @timer
@@ -553,19 +569,22 @@ def load_df_dict_from_sql(engine: Engine,
553
569
  dataset_keys: List[Union[str, Enum, NamedTuple]],
554
570
  schema: Optional[str] = None,
555
571
  index_col: Optional[str] = INDEX_COLUMN,
556
- columns: Optional[List[str]] = None
572
+ columns: Optional[List[str]] = None,
573
+ drop_sql_index: bool = True
557
574
  ) -> Dict[str, pd.DataFrame]:
558
575
  """
559
576
  pandas dict from csv files
560
577
  """
561
578
  pandas_dict = {}
562
579
  for key in dataset_keys:
580
+ # df will have index set by index_col with added column 'index' from sql
563
581
  df = pd.read_sql_table(table_name=f"{table_name}_{key}", con=engine, schema=schema,
564
582
  index_col=index_col,
565
583
  columns=columns)
566
- if index_col is not None and index_col in df.columns:
567
- df[index_col] = pd.to_datetime(df[index_col])
568
- df = df.set_index(index_col)
584
+ if drop_sql_index:
585
+ df = df.drop('index', axis=1)
586
+ # df[index_col] = pd.to_datetime(df[index_col])
587
+ # df = df.set_index(index_col, drop=True)
569
588
  pandas_dict[key] = df
570
589
  return pandas_dict
571
590
 
@@ -672,7 +691,7 @@ def save_df_dict_to_feather(dfs: Dict[Union[str, Enum, NamedTuple], pd.DataFrame
672
691
  pandas dict to csv files
673
692
  """
674
693
  for key, df in dfs.items():
675
- if df is not None:
694
+ if df is not None and isinstance(df, pd.DataFrame):
676
695
  file_path = get_local_file_path(file_name=file_name,
677
696
  file_type=FileTypes.FEATHER,
678
697
  local_path=local_path,
@@ -4,7 +4,6 @@
4
4
  # git rm -r --cached setting.yaml
5
5
 
6
6
 
7
-
8
7
  RESOURCE_PATH:
9
8
  "..\\"
10
9
 
@@ -19,4 +18,3 @@ OUTPUT_PATH:
19
18
 
20
19
  AWS_POSTGRES:
21
20
  ""
22
-
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