bist-quant 0.3.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.
- bist_quant-0.3.3/.gitignore +81 -0
- bist_quant-0.3.3/CONTRIBUTING.md +94 -0
- bist_quant-0.3.3/LICENSE +162 -0
- bist_quant-0.3.3/PKG-INFO +124 -0
- bist_quant-0.3.3/README.md +77 -0
- bist_quant-0.3.3/docs/contributing.md +60 -0
- bist_quant-0.3.3/docs/examples/basic-backtest.md +68 -0
- bist_quant-0.3.3/docs/examples/custom-signals.md +86 -0
- bist_quant-0.3.3/docs/examples/portfolio-optimization.md +68 -0
- bist_quant-0.3.3/docs/getting-started/configuration.md +112 -0
- bist_quant-0.3.3/docs/getting-started/installation.md +78 -0
- bist_quant-0.3.3/docs/getting-started/quickstart.md +111 -0
- bist_quant-0.3.3/docs/index.md +75 -0
- bist_quant-0.3.3/docs/plans/2026-03-04-phase0-contract-freeze.md +149 -0
- bist_quant-0.3.3/docs/plans/2026-03-05-phase4-parity-review.md +56 -0
- bist_quant-0.3.3/docs/plans/2026-03-05-phase4-streamlit-parity-matrix.md +26 -0
- bist_quant-0.3.3/docs/plans/artifacts/2026-03-05-phase4-regression-evidence.md +68 -0
- bist_quant-0.3.3/docs/plans/artifacts/2026-03-05-phase5-verification-evidence.md +94 -0
- bist_quant-0.3.3/docs/plans/artifacts/phase0-canonical-samples.json +2008 -0
- bist_quant-0.3.3/docs/plans/artifacts/phase0-contract-manifest.json +1080 -0
- bist_quant-0.3.3/docs/plans/artifacts/phase3-visual-consistency-checklist.md +33 -0
- bist_quant-0.3.3/docs/plans/bist-quant-ui-enhancement-plan.md +236 -0
- bist_quant-0.3.3/docs/user-guide/backtesting.md +88 -0
- bist_quant-0.3.3/docs/user-guide/multi-asset.md +73 -0
- bist_quant-0.3.3/docs/user-guide/portfolio.md +69 -0
- bist_quant-0.3.3/docs/user-guide/risk.md +90 -0
- bist_quant-0.3.3/docs/user-guide/signals.md +145 -0
- bist_quant-0.3.3/mkdocs.yml +61 -0
- bist_quant-0.3.3/pyproject.toml +255 -0
- bist_quant-0.3.3/src/bist_quant/README.md +116 -0
- bist_quant-0.3.3/src/bist_quant/__init__.py +164 -0
- bist_quant-0.3.3/src/bist_quant/_cli.py +175 -0
- bist_quant-0.3.3/src/bist_quant/analytics/README.md +136 -0
- bist_quant-0.3.3/src/bist_quant/analytics/__init__.py +14 -0
- bist_quant-0.3.3/src/bist_quant/analytics/advanced.py +1376 -0
- bist_quant-0.3.3/src/bist_quant/analytics/core_metrics.py +1036 -0
- bist_quant-0.3.3/src/bist_quant/analytics/portfolio_metrics.py +927 -0
- bist_quant-0.3.3/src/bist_quant/analytics/professional.py +940 -0
- bist_quant-0.3.3/src/bist_quant/api/__init__.py +5 -0
- bist_quant-0.3.3/src/bist_quant/api/errors.py +154 -0
- bist_quant-0.3.3/src/bist_quant/api/jobs.py +209 -0
- bist_quant-0.3.3/src/bist_quant/api/main.py +689 -0
- bist_quant-0.3.3/src/bist_quant/api/routers/__init__.py +19 -0
- bist_quant-0.3.3/src/bist_quant/api/routers/analytics.py +211 -0
- bist_quant-0.3.3/src/bist_quant/api/routers/compliance.py +146 -0
- bist_quant-0.3.3/src/bist_quant/api/routers/factors.py +92 -0
- bist_quant-0.3.3/src/bist_quant/api/routers/optimization.py +75 -0
- bist_quant-0.3.3/src/bist_quant/api/routers/professional.py +132 -0
- bist_quant-0.3.3/src/bist_quant/api/routers/screener.py +105 -0
- bist_quant-0.3.3/src/bist_quant/api/routers/signal_construction.py +89 -0
- bist_quant-0.3.3/src/bist_quant/api/schemas.py +268 -0
- bist_quant-0.3.3/src/bist_quant/cli/README.md +53 -0
- bist_quant-0.3.3/src/bist_quant/cli/__init__.py +5 -0
- bist_quant-0.3.3/src/bist_quant/cli/cache_cli.py +581 -0
- bist_quant-0.3.3/src/bist_quant/cli/validate_data.py +164 -0
- bist_quant-0.3.3/src/bist_quant/clients/README.md +128 -0
- bist_quant-0.3.3/src/bist_quant/clients/__init__.py +0 -0
- bist_quant-0.3.3/src/bist_quant/clients/borsapy_adapter.py +610 -0
- bist_quant-0.3.3/src/bist_quant/clients/borsapy_client.py +1500 -0
- bist_quant-0.3.3/src/bist_quant/clients/crypto_client.py +372 -0
- bist_quant-0.3.3/src/bist_quant/clients/derivatives_provider.py +573 -0
- bist_quant-0.3.3/src/bist_quant/clients/economic_calendar_provider.py +371 -0
- bist_quant-0.3.3/src/bist_quant/clients/fixed_income_provider.py +542 -0
- bist_quant-0.3.3/src/bist_quant/clients/fund_analyzer.py +505 -0
- bist_quant-0.3.3/src/bist_quant/clients/fx_commodities_client.py +621 -0
- bist_quant-0.3.3/src/bist_quant/clients/fx_enhanced_provider.py +583 -0
- bist_quant-0.3.3/src/bist_quant/clients/macro_adapter.py +120 -0
- bist_quant-0.3.3/src/bist_quant/clients/macro_events.py +651 -0
- bist_quant-0.3.3/src/bist_quant/clients/update_prices.py +606 -0
- bist_quant-0.3.3/src/bist_quant/clients/us_stock_client.py +536 -0
- bist_quant-0.3.3/src/bist_quant/common/README.md +242 -0
- bist_quant-0.3.3/src/bist_quant/common/__init__.py +179 -0
- bist_quant-0.3.3/src/bist_quant/common/backtest_services.py +525 -0
- bist_quant-0.3.3/src/bist_quant/common/backtester.py +440 -0
- bist_quant-0.3.3/src/bist_quant/common/benchmarking.py +390 -0
- bist_quant-0.3.3/src/bist_quant/common/cache_config.py +90 -0
- bist_quant-0.3.3/src/bist_quant/common/config_manager.py +470 -0
- bist_quant-0.3.3/src/bist_quant/common/data_loader.py +1620 -0
- bist_quant-0.3.3/src/bist_quant/common/data_manager.py +286 -0
- bist_quant-0.3.3/src/bist_quant/common/data_paths.py +374 -0
- bist_quant-0.3.3/src/bist_quant/common/disk_cache.py +292 -0
- bist_quant-0.3.3/src/bist_quant/common/enums.py +29 -0
- bist_quant-0.3.3/src/bist_quant/common/market_cap_utils.py +57 -0
- bist_quant-0.3.3/src/bist_quant/common/panel_cache.py +61 -0
- bist_quant-0.3.3/src/bist_quant/common/portfolio_analytics.py +369 -0
- bist_quant-0.3.3/src/bist_quant/common/report_generator.py +819 -0
- bist_quant-0.3.3/src/bist_quant/common/risk_manager.py +251 -0
- bist_quant-0.3.3/src/bist_quant/common/staleness.py +212 -0
- bist_quant-0.3.3/src/bist_quant/common/utils.py +708 -0
- bist_quant-0.3.3/src/bist_quant/configs/README.md +100 -0
- bist_quant-0.3.3/src/bist_quant/configs/__init__.py +47 -0
- bist_quant-0.3.3/src/bist_quant/configs/strategies.yaml +849 -0
- bist_quant-0.3.3/src/bist_quant/data_pipeline/README.md +176 -0
- bist_quant-0.3.3/src/bist_quant/data_pipeline/__init__.py +66 -0
- bist_quant-0.3.3/src/bist_quant/data_pipeline/errors.py +29 -0
- bist_quant-0.3.3/src/bist_quant/data_pipeline/fetcher.py +398 -0
- bist_quant-0.3.3/src/bist_quant/data_pipeline/freshness.py +199 -0
- bist_quant-0.3.3/src/bist_quant/data_pipeline/logging_utils.py +47 -0
- bist_quant-0.3.3/src/bist_quant/data_pipeline/merge.py +123 -0
- bist_quant-0.3.3/src/bist_quant/data_pipeline/normalize.py +276 -0
- bist_quant-0.3.3/src/bist_quant/data_pipeline/pipeline.py +559 -0
- bist_quant-0.3.3/src/bist_quant/data_pipeline/provenance.py +103 -0
- bist_quant-0.3.3/src/bist_quant/data_pipeline/schemas.py +218 -0
- bist_quant-0.3.3/src/bist_quant/data_pipeline/types.py +96 -0
- bist_quant-0.3.3/src/bist_quant/engines/README.md +149 -0
- bist_quant-0.3.3/src/bist_quant/engines/__init__.py +49 -0
- bist_quant-0.3.3/src/bist_quant/engines/errors.py +23 -0
- bist_quant-0.3.3/src/bist_quant/engines/factor_lab.py +1228 -0
- bist_quant-0.3.3/src/bist_quant/engines/signal_construction.py +1691 -0
- bist_quant-0.3.3/src/bist_quant/engines/stock_filter.py +1740 -0
- bist_quant-0.3.3/src/bist_quant/engines/technical_scanner.py +217 -0
- bist_quant-0.3.3/src/bist_quant/engines/types.py +36 -0
- bist_quant-0.3.3/src/bist_quant/fetcher/__init__.py +5 -0
- bist_quant-0.3.3/src/bist_quant/fetcher/update_prices.py +5 -0
- bist_quant-0.3.3/src/bist_quant/fetchers/README.md +60 -0
- bist_quant-0.3.3/src/bist_quant/fetchers/fetch_gold_prices.py +108 -0
- bist_quant-0.3.3/src/bist_quant/fetchers/fetch_indices.py +122 -0
- bist_quant-0.3.3/src/bist_quant/jobs/README.md +110 -0
- bist_quant-0.3.3/src/bist_quant/jobs/__init__.py +25 -0
- bist_quant-0.3.3/src/bist_quant/jobs/executor.py +106 -0
- bist_quant-0.3.3/src/bist_quant/jobs/manager.py +120 -0
- bist_quant-0.3.3/src/bist_quant/jobs/models.py +77 -0
- bist_quant-0.3.3/src/bist_quant/jobs/progress.py +48 -0
- bist_quant-0.3.3/src/bist_quant/observability/README.md +75 -0
- bist_quant-0.3.3/src/bist_quant/observability/__init__.py +12 -0
- bist_quant-0.3.3/src/bist_quant/observability/logging.py +83 -0
- bist_quant-0.3.3/src/bist_quant/observability/metrics.py +109 -0
- bist_quant-0.3.3/src/bist_quant/observability/telemetry.py +59 -0
- bist_quant-0.3.3/src/bist_quant/persistence/README.md +63 -0
- bist_quant-0.3.3/src/bist_quant/persistence/__init__.py +6 -0
- bist_quant-0.3.3/src/bist_quant/persistence/job_store.py +180 -0
- bist_quant-0.3.3/src/bist_quant/persistence/run_store.py +287 -0
- bist_quant-0.3.3/src/bist_quant/portfolio.py +1327 -0
- bist_quant-0.3.3/src/bist_quant/py.typed +0 -0
- bist_quant-0.3.3/src/bist_quant/realtime/README.md +91 -0
- bist_quant-0.3.3/src/bist_quant/realtime/__init__.py +41 -0
- bist_quant-0.3.3/src/bist_quant/realtime/portfolio.py +116 -0
- bist_quant-0.3.3/src/bist_quant/realtime/quotes.py +327 -0
- bist_quant-0.3.3/src/bist_quant/realtime/streaming.py +507 -0
- bist_quant-0.3.3/src/bist_quant/realtime/ticks.py +208 -0
- bist_quant-0.3.3/src/bist_quant/regime/README.md +90 -0
- bist_quant-0.3.3/src/bist_quant/regime/__init__.py +26 -0
- bist_quant-0.3.3/src/bist_quant/regime/macro_features.py +754 -0
- bist_quant-0.3.3/src/bist_quant/regime/simple_regime.py +510 -0
- bist_quant-0.3.3/src/bist_quant/runtime.py +174 -0
- bist_quant-0.3.3/src/bist_quant/security/README.md +94 -0
- bist_quant-0.3.3/src/bist_quant/security/__init__.py +12 -0
- bist_quant-0.3.3/src/bist_quant/security/auth.py +149 -0
- bist_quant-0.3.3/src/bist_quant/security/rate_limiter.py +53 -0
- bist_quant-0.3.3/src/bist_quant/security/sanitization.py +33 -0
- bist_quant-0.3.3/src/bist_quant/services/README.md +115 -0
- bist_quant-0.3.3/src/bist_quant/services/__init__.py +42 -0
- bist_quant-0.3.3/src/bist_quant/services/core_service.py +1695 -0
- bist_quant-0.3.3/src/bist_quant/services/realtime_service.py +756 -0
- bist_quant-0.3.3/src/bist_quant/services/realtime_stream.py +518 -0
- bist_quant-0.3.3/src/bist_quant/services/system_service.py +445 -0
- bist_quant-0.3.3/src/bist_quant/settings/README.md +77 -0
- bist_quant-0.3.3/src/bist_quant/settings/__init__.py +44 -0
- bist_quant-0.3.3/src/bist_quant/settings/environment.py +51 -0
- bist_quant-0.3.3/src/bist_quant/settings/settings.py +148 -0
- bist_quant-0.3.3/src/bist_quant/signals/README.md +186 -0
- bist_quant-0.3.3/src/bist_quant/signals/__init__.py +75 -0
- bist_quant-0.3.3/src/bist_quant/signals/_context.py +87 -0
- bist_quant-0.3.3/src/bist_quant/signals/accrual_signals.py +244 -0
- bist_quant-0.3.3/src/bist_quant/signals/adx_signals.py +87 -0
- bist_quant-0.3.3/src/bist_quant/signals/asset_growth_signals.py +143 -0
- bist_quant-0.3.3/src/bist_quant/signals/atr_signals.py +64 -0
- bist_quant-0.3.3/src/bist_quant/signals/axis_cache.py +114 -0
- bist_quant-0.3.3/src/bist_quant/signals/betting_against_beta_signals.py +136 -0
- bist_quant-0.3.3/src/bist_quant/signals/borsapy_indicators.py +1075 -0
- bist_quant-0.3.3/src/bist_quant/signals/breakout_value_signals.py +82 -0
- bist_quant-0.3.3/src/bist_quant/signals/composite.py +370 -0
- bist_quant-0.3.3/src/bist_quant/signals/consistent_momentum_signals.py +161 -0
- bist_quant-0.3.3/src/bist_quant/signals/debug_utils.py +77 -0
- bist_quant-0.3.3/src/bist_quant/signals/dividend_rotation_signals.py +289 -0
- bist_quant-0.3.3/src/bist_quant/signals/donchian_signals.py +80 -0
- bist_quant-0.3.3/src/bist_quant/signals/earnings_quality_signals.py +281 -0
- bist_quant-0.3.3/src/bist_quant/signals/ema_signals.py +59 -0
- bist_quant-0.3.3/src/bist_quant/signals/factor_axes.py +692 -0
- bist_quant-0.3.3/src/bist_quant/signals/factor_builders.py +1214 -0
- bist_quant-0.3.3/src/bist_quant/signals/factory.py +115 -0
- bist_quant-0.3.3/src/bist_quant/signals/five_factor_pipeline.py +1750 -0
- bist_quant-0.3.3/src/bist_quant/signals/five_factor_rotation_signals.py +1390 -0
- bist_quant-0.3.3/src/bist_quant/signals/fscore_reversal_signals.py +330 -0
- bist_quant-0.3.3/src/bist_quant/signals/ichimoku_signals.py +93 -0
- bist_quant-0.3.3/src/bist_quant/signals/investment_signals.py +249 -0
- bist_quant-0.3.3/src/bist_quant/signals/low_volatility_signals.py +184 -0
- bist_quant-0.3.3/src/bist_quant/signals/macd_signals.py +74 -0
- bist_quant-0.3.3/src/bist_quant/signals/macro_hedge_signals.py +243 -0
- bist_quant-0.3.3/src/bist_quant/signals/momentum.py +151 -0
- bist_quant-0.3.3/src/bist_quant/signals/momentum_asset_growth_signals.py +214 -0
- bist_quant-0.3.3/src/bist_quant/signals/momentum_reversal_volatility_signals.py +171 -0
- bist_quant-0.3.3/src/bist_quant/signals/momentum_signals.py +211 -0
- bist_quant-0.3.3/src/bist_quant/signals/obv_signals.py +60 -0
- bist_quant-0.3.3/src/bist_quant/signals/orthogonalization.py +145 -0
- bist_quant-0.3.3/src/bist_quant/signals/pairs_trading_signals.py +258 -0
- bist_quant-0.3.3/src/bist_quant/signals/parabolic_sar_signals.py +80 -0
- bist_quant-0.3.3/src/bist_quant/signals/profitability_signals.py +170 -0
- bist_quant-0.3.3/src/bist_quant/signals/protocol.py +15 -0
- bist_quant-0.3.3/src/bist_quant/signals/quality.py +104 -0
- bist_quant-0.3.3/src/bist_quant/signals/quality_momentum_signals.py +232 -0
- bist_quant-0.3.3/src/bist_quant/signals/quality_value_signals.py +343 -0
- bist_quant-0.3.3/src/bist_quant/signals/residual_momentum_signals.py +213 -0
- bist_quant-0.3.3/src/bist_quant/signals/roa_signals.py +162 -0
- bist_quant-0.3.3/src/bist_quant/signals/sector_rotation_signals.py +230 -0
- bist_quant-0.3.3/src/bist_quant/signals/short_term_reversal_signals.py +136 -0
- bist_quant-0.3.3/src/bist_quant/signals/signal_exporter.py +71 -0
- bist_quant-0.3.3/src/bist_quant/signals/size_rotation_momentum_signals.py +197 -0
- bist_quant-0.3.3/src/bist_quant/signals/size_rotation_quality_signals.py +216 -0
- bist_quant-0.3.3/src/bist_quant/signals/size_rotation_signals.py +538 -0
- bist_quant-0.3.3/src/bist_quant/signals/sma_signals.py +63 -0
- bist_quant-0.3.3/src/bist_quant/signals/small_cap_momentum_signals.py +183 -0
- bist_quant-0.3.3/src/bist_quant/signals/small_cap_signals.py +254 -0
- bist_quant-0.3.3/src/bist_quant/signals/sovereign_risk_signals.py +163 -0
- bist_quant-0.3.3/src/bist_quant/signals/standalone_factors/FACTOR_REFERENCE.py +388 -0
- bist_quant-0.3.3/src/bist_quant/signals/standalone_factors/README.md +178 -0
- bist_quant-0.3.3/src/bist_quant/signals/standalone_factors/__init__.py +81 -0
- bist_quant-0.3.3/src/bist_quant/signals/standalone_factors/base.py +388 -0
- bist_quant-0.3.3/src/bist_quant/signals/standalone_factors/beta_signal.py +297 -0
- bist_quant-0.3.3/src/bist_quant/signals/standalone_factors/carry_signal.py +321 -0
- bist_quant-0.3.3/src/bist_quant/signals/standalone_factors/defensive_signal.py +343 -0
- bist_quant-0.3.3/src/bist_quant/signals/standalone_factors/fundamental_momentum_signal.py +292 -0
- bist_quant-0.3.3/src/bist_quant/signals/standalone_factors/investment_signal.py +422 -0
- bist_quant-0.3.3/src/bist_quant/signals/standalone_factors/liquidity_signal.py +252 -0
- bist_quant-0.3.3/src/bist_quant/signals/standalone_factors/momentum_signal.py +264 -0
- bist_quant-0.3.3/src/bist_quant/signals/standalone_factors/profitability_signal.py +312 -0
- bist_quant-0.3.3/src/bist_quant/signals/standalone_factors/quality_signal.py +365 -0
- bist_quant-0.3.3/src/bist_quant/signals/standalone_factors/sentiment_signal.py +301 -0
- bist_quant-0.3.3/src/bist_quant/signals/standalone_factors/size_signal.py +180 -0
- bist_quant-0.3.3/src/bist_quant/signals/standalone_factors/trading_intensity_signal.py +265 -0
- bist_quant-0.3.3/src/bist_quant/signals/standalone_factors/value_signal.py +271 -0
- bist_quant-0.3.3/src/bist_quant/signals/supertrend_signals.py +74 -0
- bist_quant-0.3.3/src/bist_quant/signals/ta_consensus_signals.py +334 -0
- bist_quant-0.3.3/src/bist_quant/signals/technical.py +241 -0
- bist_quant-0.3.3/src/bist_quant/signals/trend_following_signals.py +182 -0
- bist_quant-0.3.3/src/bist_quant/signals/trend_value_signals.py +125 -0
- bist_quant-0.3.3/src/bist_quant/signals/value.py +121 -0
- bist_quant-0.3.3/src/bist_quant/signals/value_signals.py +325 -0
- bist_quant-0.3.3/src/bist_quant/signals/xu100_signals.py +51 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
*.egg-info/
|
|
7
|
+
*.egg
|
|
8
|
+
dist/
|
|
9
|
+
build/
|
|
10
|
+
.eggs/
|
|
11
|
+
|
|
12
|
+
# Virtual environments
|
|
13
|
+
venv/
|
|
14
|
+
env/
|
|
15
|
+
.env/
|
|
16
|
+
|
|
17
|
+
# IDE
|
|
18
|
+
.vscode/
|
|
19
|
+
.idea/
|
|
20
|
+
*.swp
|
|
21
|
+
*.swo
|
|
22
|
+
*~
|
|
23
|
+
|
|
24
|
+
# ===== DATA EXCLUSIONS =====
|
|
25
|
+
|
|
26
|
+
data
|
|
27
|
+
|
|
28
|
+
# ===== GENERATED OUTPUT EXCLUSIONS =====
|
|
29
|
+
|
|
30
|
+
outputs
|
|
31
|
+
|
|
32
|
+
# ===== ML ARTIFACTS =====
|
|
33
|
+
*.pkl
|
|
34
|
+
*.pt
|
|
35
|
+
*.pth
|
|
36
|
+
*.h5
|
|
37
|
+
*.onnx
|
|
38
|
+
|
|
39
|
+
# ===== MISC =====
|
|
40
|
+
.DS_Store
|
|
41
|
+
Thumbs.db
|
|
42
|
+
*.log
|
|
43
|
+
*.backup
|
|
44
|
+
|
|
45
|
+
# ===== ENVIRONMENT / SECRETS =====
|
|
46
|
+
.env
|
|
47
|
+
.env.*
|
|
48
|
+
*.env
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
# ===== WEB APP BUILD =====
|
|
52
|
+
.next/
|
|
53
|
+
node_modules/
|
|
54
|
+
.claude/
|
|
55
|
+
.yfinance_cache/
|
|
56
|
+
*.db
|
|
57
|
+
|
|
58
|
+
# ===== TEST / RUNTIME CACHES =====
|
|
59
|
+
.hypothesis/
|
|
60
|
+
.pytest_cache/
|
|
61
|
+
.ruff_cache/
|
|
62
|
+
logs/
|
|
63
|
+
|
|
64
|
+
# ===== RUNTIME ARTIFACTS =====
|
|
65
|
+
temp_*.html
|
|
66
|
+
.coverage
|
|
67
|
+
# ===== AI AGENT TOOLING =====
|
|
68
|
+
.agent/
|
|
69
|
+
.agents/
|
|
70
|
+
skills-lock.json
|
|
71
|
+
claude.md
|
|
72
|
+
AGENTS.md
|
|
73
|
+
tasks/
|
|
74
|
+
|
|
75
|
+
# ===== NON-LIBRARY APP / DEV SURFACES =====
|
|
76
|
+
.streamlit/
|
|
77
|
+
frontend/
|
|
78
|
+
app/
|
|
79
|
+
deploy/
|
|
80
|
+
playwright-report/
|
|
81
|
+
test-results/
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Contributing to BIST Quant
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to BIST Quant. This document outlines the recommended workflow.
|
|
4
|
+
|
|
5
|
+
## Development Setup
|
|
6
|
+
|
|
7
|
+
1. Fork the repository.
|
|
8
|
+
2. Clone your fork:
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
git clone https://github.com/YOUR_USERNAME/BIST.git
|
|
12
|
+
cd BIST
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
3. Create and activate a virtual environment:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
python -m venv .venv
|
|
19
|
+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
4. Install development dependencies:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install -e ".[dev]"
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
5. Install pre-commit hooks:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pre-commit install
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Development Workflow
|
|
35
|
+
|
|
36
|
+
1. Create a feature branch:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
git checkout -b feature/your-feature-name
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
2. Make code changes and add tests.
|
|
43
|
+
3. Run tests:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pytest tests/ -v
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
4. Run linting and type checks:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
ruff check bist_quant
|
|
53
|
+
black --check bist_quant
|
|
54
|
+
mypy bist_quant --ignore-missing-imports
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
5. Commit your changes:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
git commit -m "feat: add your feature description"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
6. Push your branch:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
git push origin feature/your-feature-name
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
7. Open a Pull Request.
|
|
70
|
+
|
|
71
|
+
## Code Style
|
|
72
|
+
|
|
73
|
+
- Formatting: Black
|
|
74
|
+
- Linting: Ruff
|
|
75
|
+
- Type hints: required for public APIs
|
|
76
|
+
- Docstrings: Google style for public functions/classes
|
|
77
|
+
|
|
78
|
+
## Testing
|
|
79
|
+
|
|
80
|
+
- Add tests for all new behavior.
|
|
81
|
+
- Keep project coverage at or above 50 percent.
|
|
82
|
+
- Reuse fixtures from `tests/conftest.py` where possible.
|
|
83
|
+
|
|
84
|
+
## Pull Request Guidelines
|
|
85
|
+
|
|
86
|
+
- Use a Conventional Commits style title.
|
|
87
|
+
- Include a clear summary and testing notes.
|
|
88
|
+
- Link related issues.
|
|
89
|
+
- Ensure CI checks pass before merge.
|
|
90
|
+
|
|
91
|
+
## Questions
|
|
92
|
+
|
|
93
|
+
- Open an issue for questions or proposals.
|
|
94
|
+
- Check existing docs and previous discussions first.
|
bist_quant-0.3.3/LICENSE
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and
|
|
10
|
+
distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
|
13
|
+
owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities
|
|
16
|
+
that control, are controlled by, or are under common control with that entity.
|
|
17
|
+
For the purposes of this definition, "control" means (i) the power, direct or
|
|
18
|
+
indirect, to cause the direction or management of such entity, whether by
|
|
19
|
+
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
20
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
21
|
+
|
|
22
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
|
23
|
+
permissions granted by this License.
|
|
24
|
+
|
|
25
|
+
"Source" form shall mean the preferred form for making modifications, including
|
|
26
|
+
but not limited to software source code, documentation source, and
|
|
27
|
+
configuration files.
|
|
28
|
+
|
|
29
|
+
"Object" form shall mean any form resulting from mechanical transformation or
|
|
30
|
+
translation of a Source form, including but not limited to compiled object code,
|
|
31
|
+
generated documentation, and conversions to other media types.
|
|
32
|
+
|
|
33
|
+
"Work" shall mean the work of authorship, whether in Source or Object form,
|
|
34
|
+
made available under the License, as indicated by a copyright notice that is
|
|
35
|
+
included in or attached to the work (an example is provided in the Appendix
|
|
36
|
+
below).
|
|
37
|
+
|
|
38
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that
|
|
39
|
+
is based on (or derived from) the Work and for which the editorial revisions,
|
|
40
|
+
annotations, elaborations, or other modifications represent, as a whole, an
|
|
41
|
+
original work of authorship. For the purposes of this License, Derivative Works
|
|
42
|
+
shall not include works that remain separable from, or merely link (or bind by
|
|
43
|
+
name) to the interfaces of, the Work and Derivative Works thereof.
|
|
44
|
+
|
|
45
|
+
"Contribution" shall mean any work of authorship, including the original version
|
|
46
|
+
of the Work and any modifications or additions to that Work or Derivative Works
|
|
47
|
+
thereof, that is intentionally submitted to Licensor for inclusion in the Work
|
|
48
|
+
by the copyright owner or by an individual or Legal Entity authorized to submit
|
|
49
|
+
on behalf of the copyright owner. For the purposes of this definition,
|
|
50
|
+
"submitted" means any form of electronic, verbal, or written communication sent
|
|
51
|
+
to the Licensor or its representatives, including but not limited to
|
|
52
|
+
communication on electronic mailing lists, source code control systems, and
|
|
53
|
+
issue tracking systems that are managed by, or on behalf of, the Licensor for
|
|
54
|
+
the purpose of discussing and improving the Work, but excluding communication
|
|
55
|
+
that is conspicuously marked or otherwise designated in writing by the copyright
|
|
56
|
+
owner as "Not a Contribution."
|
|
57
|
+
|
|
58
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
|
59
|
+
of whom a Contribution has been received by Licensor and subsequently
|
|
60
|
+
incorporated within the Work.
|
|
61
|
+
|
|
62
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this
|
|
63
|
+
License, each Contributor hereby grants to You a perpetual, worldwide,
|
|
64
|
+
non-exclusive, no-charge, royalty-free, irrevocable copyright license to
|
|
65
|
+
reproduce, prepare Derivative Works of, publicly display, publicly perform,
|
|
66
|
+
sublicense, and distribute the Work and such Derivative Works in Source or
|
|
67
|
+
Object form.
|
|
68
|
+
|
|
69
|
+
3. Grant of Patent License. Subject to the terms and conditions of this License,
|
|
70
|
+
each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
|
|
71
|
+
no-charge, royalty-free, irrevocable (except as stated in this section) patent
|
|
72
|
+
license to make, have made, use, offer to sell, sell, import, and otherwise
|
|
73
|
+
transfer the Work, where such license applies only to those patent claims
|
|
74
|
+
licensable by such Contributor that are necessarily infringed by their
|
|
75
|
+
Contribution(s) alone or by combination of their Contribution(s) with the Work
|
|
76
|
+
to which such Contribution(s) was submitted. If You institute patent litigation
|
|
77
|
+
against any entity (including a cross-claim or counterclaim in a lawsuit)
|
|
78
|
+
alleging that the Work or a Contribution incorporated within the Work
|
|
79
|
+
constitutes direct or contributory patent infringement, then any patent licenses
|
|
80
|
+
granted to You under this License for that Work shall terminate as of the date
|
|
81
|
+
such litigation is filed.
|
|
82
|
+
|
|
83
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or
|
|
84
|
+
Derivative Works thereof in any medium, with or without modifications, and in
|
|
85
|
+
Source or Object form, provided that You meet the following conditions:
|
|
86
|
+
|
|
87
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of
|
|
88
|
+
this License; and
|
|
89
|
+
|
|
90
|
+
(b) You must cause any modified files to carry prominent notices stating that
|
|
91
|
+
You changed the files; and
|
|
92
|
+
|
|
93
|
+
(c) You must retain, in the Source form of any Derivative Works that You
|
|
94
|
+
distribute, all copyright, patent, trademark, and attribution notices from
|
|
95
|
+
the Source form of the Work, excluding those notices that do not pertain to
|
|
96
|
+
any part of the Derivative Works; and
|
|
97
|
+
|
|
98
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then
|
|
99
|
+
any Derivative Works that You distribute must include a readable copy of the
|
|
100
|
+
attribution notices contained within such NOTICE file, excluding those
|
|
101
|
+
notices that do not pertain to any part of the Derivative Works, in at least
|
|
102
|
+
one of the following places: within a NOTICE text file distributed as part
|
|
103
|
+
of the Derivative Works; within the Source form or documentation, if
|
|
104
|
+
provided along with the Derivative Works; or, within a display generated by
|
|
105
|
+
the Derivative Works, if and wherever such third-party notices normally
|
|
106
|
+
appear. The contents of the NOTICE file are for informational purposes only
|
|
107
|
+
and do not modify the License. You may add Your own attribution notices
|
|
108
|
+
within Derivative Works that You distribute, alongside or as an addendum to
|
|
109
|
+
the NOTICE text from the Work, provided that such additional attribution
|
|
110
|
+
notices cannot be construed as modifying the License.
|
|
111
|
+
|
|
112
|
+
You may add Your own copyright statement to Your modifications and may provide
|
|
113
|
+
additional or different license terms and conditions for use, reproduction, or
|
|
114
|
+
distribution of Your modifications, or for any such Derivative Works as a whole,
|
|
115
|
+
provided Your use, reproduction, and distribution of the Work otherwise complies
|
|
116
|
+
with the conditions stated in this License.
|
|
117
|
+
|
|
118
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any
|
|
119
|
+
Contribution intentionally submitted for inclusion in the Work by You to the
|
|
120
|
+
Licensor shall be under the terms and conditions of this License, without any
|
|
121
|
+
additional terms or conditions. Notwithstanding the above, nothing herein shall
|
|
122
|
+
supersede or modify the terms of any separate license agreement you may have
|
|
123
|
+
executed with Licensor regarding such Contributions.
|
|
124
|
+
|
|
125
|
+
6. Trademarks. This License does not grant permission to use the trade names,
|
|
126
|
+
trademarks, service marks, or product names of the Licensor, except as required
|
|
127
|
+
for reasonable and customary use in describing the origin of the Work and
|
|
128
|
+
reproducing the content of the NOTICE file.
|
|
129
|
+
|
|
130
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
|
|
131
|
+
writing, Licensor provides the Work (and each Contributor provides its
|
|
132
|
+
Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
133
|
+
KIND, either express or implied, including, without limitation, any warranties
|
|
134
|
+
or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
135
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
136
|
+
appropriateness of using or redistributing the Work and assume any risks
|
|
137
|
+
associated with Your exercise of permissions under this License.
|
|
138
|
+
|
|
139
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in
|
|
140
|
+
tort (including negligence), contract, or otherwise, unless required by
|
|
141
|
+
applicable law (such as deliberate and grossly negligent acts) or agreed to in
|
|
142
|
+
writing, shall any Contributor be liable to You for damages, including any
|
|
143
|
+
direct, indirect, special, incidental, or consequential damages of any character
|
|
144
|
+
arising as a result of this License or out of the use or inability to use the
|
|
145
|
+
Work (including but not limited to damages for loss of goodwill, work stoppage,
|
|
146
|
+
computer failure or malfunction, or any and all other commercial damages or
|
|
147
|
+
losses), even if such Contributor has been advised of the possibility of such
|
|
148
|
+
damages.
|
|
149
|
+
|
|
150
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or
|
|
151
|
+
Derivative Works thereof, You may choose to offer, and charge a fee for,
|
|
152
|
+
acceptance of support, warranty, indemnity, or other liability obligations
|
|
153
|
+
and/or rights consistent with this License. However, in accepting such
|
|
154
|
+
obligations, You may act only on Your own behalf and on Your sole
|
|
155
|
+
responsibility, not on behalf of any other Contributor, and only if You agree to
|
|
156
|
+
indemnify, defend, and hold each Contributor harmless for any liability
|
|
157
|
+
incurred by, or claims asserted against, such Contributor by reason of your
|
|
158
|
+
accepting any such warranty or additional liability.
|
|
159
|
+
|
|
160
|
+
END OF TERMS AND CONDITIONS
|
|
161
|
+
|
|
162
|
+
Copyright 2024 BIST Quant Team
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bist-quant
|
|
3
|
+
Version: 0.3.3
|
|
4
|
+
Summary: Quantitative trading library for BIST
|
|
5
|
+
Project-URL: Homepage, https://github.com/Safa675/BIST
|
|
6
|
+
Project-URL: Documentation, https://safa675.github.io/BIST
|
|
7
|
+
Project-URL: Repository, https://github.com/Safa675/BIST
|
|
8
|
+
Project-URL: Issues, https://github.com/Safa675/BIST/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/Safa675/BIST/blob/main/CHANGELOG.md
|
|
10
|
+
Author-email: Safa Öksüz <safa.okksuz@gmail.com>
|
|
11
|
+
License: Apache-2.0
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: BIST,backtesting,factor investing,portfolio optimization,quantitative finance,trading strategies
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
17
|
+
Classifier: Intended Audience :: Science/Research
|
|
18
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Classifier: Programming Language :: Python :: 3
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
25
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
26
|
+
Requires-Python: >=3.10
|
|
27
|
+
Requires-Dist: borsapy>=0.8.3
|
|
28
|
+
Requires-Dist: httpx>=0.27.0
|
|
29
|
+
Requires-Dist: numpy>=1.24.0
|
|
30
|
+
Requires-Dist: pandas>=2.0.0
|
|
31
|
+
Requires-Dist: pyarrow>=12.0.0
|
|
32
|
+
Requires-Dist: python-dateutil>=2.8.0
|
|
33
|
+
Requires-Dist: pyyaml>=6.0
|
|
34
|
+
Requires-Dist: scipy>=1.10.0
|
|
35
|
+
Requires-Dist: tqdm>=4.65.0
|
|
36
|
+
Requires-Dist: yfinance>=0.2.0
|
|
37
|
+
Provides-Extra: dev
|
|
38
|
+
Requires-Dist: black==26.3.0; extra == 'dev'
|
|
39
|
+
Requires-Dist: build>=1.0.0; extra == 'dev'
|
|
40
|
+
Requires-Dist: mypy>=1.4.0; extra == 'dev'
|
|
41
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
|
|
42
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
|
|
43
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
44
|
+
Requires-Dist: ruff>=0.0.280; extra == 'dev'
|
|
45
|
+
Requires-Dist: tomli>=2.0.0; (python_version < '3.11') and extra == 'dev'
|
|
46
|
+
Description-Content-Type: text/markdown
|
|
47
|
+
|
|
48
|
+
# bist_quant
|
|
49
|
+
|
|
50
|
+
**Quantitative research and backtesting library for Borsa Istanbul (BIST).** Version 0.3.3.
|
|
51
|
+
|
|
52
|
+
`bist_quant` is a Python library for factor research, signal construction, backtesting, portfolio analytics, and BIST-focused data workflows. It is designed to be usable from notebooks, scripts, dashboards, and external applications without requiring a repo checkout.
|
|
53
|
+
|
|
54
|
+
## Install
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pip install bist-quant
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Quick Start
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from bist_quant import DataLoader, DataPaths, PortfolioEngine
|
|
64
|
+
|
|
65
|
+
paths = DataPaths()
|
|
66
|
+
loader = DataLoader(data_paths=paths)
|
|
67
|
+
engine = PortfolioEngine(
|
|
68
|
+
data_loader=loader,
|
|
69
|
+
options={"use_regime_filter": False},
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
result = engine.run_factor("momentum")
|
|
73
|
+
print(f"Sharpe: {result['sharpe']:.2f}")
|
|
74
|
+
print(f"CAGR: {result['cagr']:.1%}")
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
By default the library uses user-scoped directories:
|
|
78
|
+
|
|
79
|
+
- data: `~/.local/share/bist-quant/data`
|
|
80
|
+
- regime outputs: `~/.local/share/bist-quant/regime/simple_regime`
|
|
81
|
+
- cache: `~/.cache/bist-quant`
|
|
82
|
+
|
|
83
|
+
Override them with `BIST_DATA_DIR`, `BIST_REGIME_DIR`, and `BIST_CACHE_DIR` when needed.
|
|
84
|
+
If you are working from local parquet/CSV files, set `BIST_DATA_SOURCE=local`.
|
|
85
|
+
|
|
86
|
+
## What Ships in the Library
|
|
87
|
+
|
|
88
|
+
- `portfolio.py` - `PortfolioEngine` and backtest entry points
|
|
89
|
+
- `signals/` - factor and signal builders
|
|
90
|
+
- `analytics/` - performance analytics and metrics
|
|
91
|
+
- `clients/` - built-in data-provider integrations
|
|
92
|
+
- `common/` - data loading, backtester, risk, and shared helpers
|
|
93
|
+
- `configs/` - strategy registry and configuration loaders
|
|
94
|
+
- `regime/` - regime classification helpers
|
|
95
|
+
- `realtime/` - quote and market snapshot helpers
|
|
96
|
+
|
|
97
|
+
## Data Setup
|
|
98
|
+
|
|
99
|
+
The package does not ship datasets. Point it at an existing dataset directory or seed data into the default user-scoped location.
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
export BIST_DATA_DIR="$HOME/.local/share/bist-quant/data"
|
|
103
|
+
python -m bist_quant.fetchers.fetch_gold_prices
|
|
104
|
+
python -m bist_quant.fetchers.fetch_indices
|
|
105
|
+
python -m bist_quant.clients.update_prices
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Documentation
|
|
109
|
+
|
|
110
|
+
- [Installation](docs/getting-started/installation.md)
|
|
111
|
+
- [Quick Start](docs/getting-started/quickstart.md)
|
|
112
|
+
- [Configuration](docs/getting-started/configuration.md)
|
|
113
|
+
- [Signals Guide](docs/user-guide/signals.md)
|
|
114
|
+
- [Backtesting Guide](docs/user-guide/backtesting.md)
|
|
115
|
+
- [Portfolio & Risk](docs/user-guide/portfolio.md)
|
|
116
|
+
- [Multi-Asset Guide](docs/user-guide/multi-asset.md)
|
|
117
|
+
|
|
118
|
+
## Development
|
|
119
|
+
|
|
120
|
+
Contributor setup lives in `CONTRIBUTING.md`. App-stack deployment notes remain in `deploy/README.md`, but they are out of scope for the published library package.
|
|
121
|
+
|
|
122
|
+
## License
|
|
123
|
+
|
|
124
|
+
Apache License 2.0 - see `LICENSE`.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# bist_quant
|
|
2
|
+
|
|
3
|
+
**Quantitative research and backtesting library for Borsa Istanbul (BIST).** Version 0.3.3.
|
|
4
|
+
|
|
5
|
+
`bist_quant` is a Python library for factor research, signal construction, backtesting, portfolio analytics, and BIST-focused data workflows. It is designed to be usable from notebooks, scripts, dashboards, and external applications without requiring a repo checkout.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install bist-quant
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from bist_quant import DataLoader, DataPaths, PortfolioEngine
|
|
17
|
+
|
|
18
|
+
paths = DataPaths()
|
|
19
|
+
loader = DataLoader(data_paths=paths)
|
|
20
|
+
engine = PortfolioEngine(
|
|
21
|
+
data_loader=loader,
|
|
22
|
+
options={"use_regime_filter": False},
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
result = engine.run_factor("momentum")
|
|
26
|
+
print(f"Sharpe: {result['sharpe']:.2f}")
|
|
27
|
+
print(f"CAGR: {result['cagr']:.1%}")
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
By default the library uses user-scoped directories:
|
|
31
|
+
|
|
32
|
+
- data: `~/.local/share/bist-quant/data`
|
|
33
|
+
- regime outputs: `~/.local/share/bist-quant/regime/simple_regime`
|
|
34
|
+
- cache: `~/.cache/bist-quant`
|
|
35
|
+
|
|
36
|
+
Override them with `BIST_DATA_DIR`, `BIST_REGIME_DIR`, and `BIST_CACHE_DIR` when needed.
|
|
37
|
+
If you are working from local parquet/CSV files, set `BIST_DATA_SOURCE=local`.
|
|
38
|
+
|
|
39
|
+
## What Ships in the Library
|
|
40
|
+
|
|
41
|
+
- `portfolio.py` - `PortfolioEngine` and backtest entry points
|
|
42
|
+
- `signals/` - factor and signal builders
|
|
43
|
+
- `analytics/` - performance analytics and metrics
|
|
44
|
+
- `clients/` - built-in data-provider integrations
|
|
45
|
+
- `common/` - data loading, backtester, risk, and shared helpers
|
|
46
|
+
- `configs/` - strategy registry and configuration loaders
|
|
47
|
+
- `regime/` - regime classification helpers
|
|
48
|
+
- `realtime/` - quote and market snapshot helpers
|
|
49
|
+
|
|
50
|
+
## Data Setup
|
|
51
|
+
|
|
52
|
+
The package does not ship datasets. Point it at an existing dataset directory or seed data into the default user-scoped location.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
export BIST_DATA_DIR="$HOME/.local/share/bist-quant/data"
|
|
56
|
+
python -m bist_quant.fetchers.fetch_gold_prices
|
|
57
|
+
python -m bist_quant.fetchers.fetch_indices
|
|
58
|
+
python -m bist_quant.clients.update_prices
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Documentation
|
|
62
|
+
|
|
63
|
+
- [Installation](docs/getting-started/installation.md)
|
|
64
|
+
- [Quick Start](docs/getting-started/quickstart.md)
|
|
65
|
+
- [Configuration](docs/getting-started/configuration.md)
|
|
66
|
+
- [Signals Guide](docs/user-guide/signals.md)
|
|
67
|
+
- [Backtesting Guide](docs/user-guide/backtesting.md)
|
|
68
|
+
- [Portfolio & Risk](docs/user-guide/portfolio.md)
|
|
69
|
+
- [Multi-Asset Guide](docs/user-guide/multi-asset.md)
|
|
70
|
+
|
|
71
|
+
## Development
|
|
72
|
+
|
|
73
|
+
Contributor setup lives in `CONTRIBUTING.md`. App-stack deployment notes remain in `deploy/README.md`, but they are out of scope for the published library package.
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
Apache License 2.0 - see `LICENSE`.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
See the full guidelines in [CONTRIBUTING.md](https://github.com/Safa675/bist-quant/blob/main/CONTRIBUTING.md).
|
|
4
|
+
|
|
5
|
+
## Quick Reference
|
|
6
|
+
|
|
7
|
+
### Code Conventions
|
|
8
|
+
|
|
9
|
+
- `from __future__ import annotations` at the top of every file
|
|
10
|
+
- `frozen=True` for all config and path dataclasses
|
|
11
|
+
- No bare `except:` — always catch a specific exception type
|
|
12
|
+
- Atomic writes: write to `.tmp` then `os.replace()` (never partial writes)
|
|
13
|
+
- All secret comparisons use `hmac.compare_digest` (never `==`)
|
|
14
|
+
- 252-day annualization everywhere (not 250 or 365)
|
|
15
|
+
|
|
16
|
+
### Data Rules
|
|
17
|
+
|
|
18
|
+
- **borsapy is the only data source inside the library core.** yfinance is only allowed in `fetchers/` scripts.
|
|
19
|
+
- Never use `yfinance` in `clients/`, `signals/`, `engines/`, or `services/`.
|
|
20
|
+
- Period columns use `"YYYY/MM"` string format (not `pd.Period`).
|
|
21
|
+
- DatetimeIndex must be timezone-naive and floored to midnight before any join.
|
|
22
|
+
- `UFRS_TICKERS` in `clients/borsapy_client.py` governs which tickers use the alternate isyatirim endpoint.
|
|
23
|
+
|
|
24
|
+
### Signal Rules
|
|
25
|
+
|
|
26
|
+
- Every signal must call `validate_signal_panel_schema()` before returning.
|
|
27
|
+
- Output shape: `(dates × tickers)`, dtype `float64`, higher = more attractive.
|
|
28
|
+
- `NaN` means exclude — never substitute 0.0 for a missing signal.
|
|
29
|
+
- `signal_lag_days=1` is mandatory (anti-lookahead). Never skip.
|
|
30
|
+
- Turkish fundamental reporting lags: **Q4 = 70 days**, **Q1-Q3 = 40 days**.
|
|
31
|
+
|
|
32
|
+
### Analytics Rules
|
|
33
|
+
|
|
34
|
+
- `core_metrics.py` must remain dependency-free (no numpy, no pandas).
|
|
35
|
+
- The `list[SeriesPoint]` interface is the boundary — do not accept DataFrames.
|
|
36
|
+
- PRNG in analytics uses `_Xorshift32` — do not switch to `random.random()` or numpy.
|
|
37
|
+
|
|
38
|
+
### Regime Classifier
|
|
39
|
+
|
|
40
|
+
- MA window = **50** (tuned for BIST). Do not change to 200.
|
|
41
|
+
- Regime labels: `Bull`, `Bear`, `Recovery`, `Stress`. Do not add new labels without updating all downstream consumers.
|
|
42
|
+
|
|
43
|
+
### Testing
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pytest tests/
|
|
47
|
+
pytest tests/unit/
|
|
48
|
+
pytest tests/integration/
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Pre-Commit Checklist
|
|
52
|
+
|
|
53
|
+
1. `from __future__ import annotations` present
|
|
54
|
+
2. BIST data source is borsapy (not yfinance) in library core
|
|
55
|
+
3. `validate_signal_panel_schema()` called before signal return
|
|
56
|
+
4. `signal_lag_days=1` applied
|
|
57
|
+
5. Atomic writes used for any file output
|
|
58
|
+
6. No hardcoded paths (`DataPaths` for all paths)
|
|
59
|
+
7. `frozen=True` on new dataclasses
|
|
60
|
+
8. Tests pass
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Basic Backtest Example
|
|
2
|
+
|
|
3
|
+
This example runs a momentum factor backtest with the current API.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
from bist_quant import PortfolioEngine, DataLoader, DataPaths
|
|
9
|
+
|
|
10
|
+
paths = DataPaths()
|
|
11
|
+
loader = DataLoader(data_paths=paths)
|
|
12
|
+
engine = PortfolioEngine(data_loader=loader, options={"use_regime_filter": False})
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Run a Factor
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
result = engine.run_factor("momentum")
|
|
19
|
+
|
|
20
|
+
print(f"CAGR: {result['cagr']:.1%}")
|
|
21
|
+
print(f"Sharpe: {result['sharpe']:.2f}")
|
|
22
|
+
print(f"Sortino: {result['sortino']:.2f}")
|
|
23
|
+
print(f"Max Drawdown: {result['max_drawdown']:.1%}")
|
|
24
|
+
print(f"Calmar: {result['calmar']:.2f}")
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Inspect Holdings
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
# Daily returns
|
|
31
|
+
print(result["returns"].describe())
|
|
32
|
+
|
|
33
|
+
# Holdings snapshot
|
|
34
|
+
print(result["holdings_history"].tail(20))
|
|
35
|
+
|
|
36
|
+
# Regime periods
|
|
37
|
+
print(result["regime_performance"].keys())
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Compare Multiple Strategies
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
strategies = ["momentum", "value", "quality", "composite"]
|
|
44
|
+
results = {name: engine.run_factor(name) for name in strategies}
|
|
45
|
+
|
|
46
|
+
for name, res in results.items():
|
|
47
|
+
print(f"{name:15s} Sharpe={res['sharpe']:.2f} CAGR={res['cagr']:.1%}")
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Custom Options
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from bist_quant import get_default_options
|
|
54
|
+
|
|
55
|
+
options = get_default_options()
|
|
56
|
+
options.update({
|
|
57
|
+
"top_n": 10,
|
|
58
|
+
"use_regime_filter": False,
|
|
59
|
+
"use_vol_targeting": True,
|
|
60
|
+
"target_downside_vol": 0.15,
|
|
61
|
+
"use_slippage": True,
|
|
62
|
+
"slippage_bps": 5.0,
|
|
63
|
+
"rebalance_frequency": "quarterly",
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
result = engine.run_factor("momentum", override_config={"portfolio_options": options})
|
|
67
|
+
print({k: result[k] for k in ("cagr", "sharpe", "max_drawdown")})
|
|
68
|
+
```
|