-
Notifications
You must be signed in to change notification settings - Fork 5
Add CLI Entrypoint for QuantResearch #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ayushkrtiwari
merged 21 commits into
OPCODE-Open-Spring-Fest:main
from
adityacosmos24:aditya
Oct 27, 2025
Merged
Changes from 13 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
9f99632
feat: optimize idiosyncratic volatility factor using vectorized covarβ¦
adityacosmos24 af12d1a
feat: Reorder imports in benchmark_factors.py
adityacosmos24 327c549
feat: refactor volatility factors for production readiness
adityacosmos24 18fe964
remove unused import of warnings module
adityacosmos24 a4fecd2
feat: fixed errors
adityacosmos24 e6456f6
Merge branch 'aditya' of https://github.com/adityacosmos24/QuantReseaβ¦
adityacosmos24 33626dc
remove unused import in volatility.py
adityacosmos24 e0436fb
errors
adityacosmos24 485151d
Merge branch 'aditya' of https://github.com/adityacosmos24/QuantReseaβ¦
adityacosmos24 8c54477
errors
adityacosmos24 7dbdd60
fix: sort imports with Ruff
adityacosmos24 b70d514
format code with black
adityacosmos24 83f8e31
feat: added setuptools poetry entrypoint
adityacosmos24 badb979
chore: update readme with new command syntax and paths
adityacosmos24 c8c5596
Merge branch 'main' into aditya
adityacosmos24 50f717d
chore: updated gitignore
adityacosmos24 cfe2ec9
Merge branch 'aditya' of https://github.com/adityacosmos24/QuantReseaβ¦
adityacosmos24 dd8b845
docs: duplicates removed
ayushkrtiwari 77b56b6
docs: fix typo error
ayushkrtiwari e140970
docs: added description
ayushkrtiwari 2f2bf84
docs: fixed path issue
ayushkrtiwari File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/quant_research_starter/examples/benchmark/benchmark_factors.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| """ | ||
| Benchmark script to compare performance of factor computations. | ||
|
|
||
| Usage: | ||
| python examples/benchmarks/benchmark_factors.py | ||
| """ | ||
|
|
||
| import time | ||
|
|
||
| import numpy as np | ||
| import pandas as pd | ||
|
|
||
| from quant_research_starter.factors import ( | ||
| BollingerBandsFactor, | ||
| IdiosyncraticVolatility, | ||
| MomentumFactor, | ||
| SizeFactor, | ||
| ValueFactor, | ||
| VolatilityFactor, | ||
| ) | ||
|
|
||
|
|
||
| def generate_synthetic_prices( | ||
| n_assets: int = 500, n_days: int = 252 * 3 | ||
| ) -> pd.DataFrame: | ||
| """Generate synthetic random walk price data for testing.""" | ||
| np.random.seed(42) | ||
| returns = np.random.normal(0, 0.01, size=(n_days, n_assets)) | ||
| prices = 100 * np.exp(np.cumsum(returns, axis=0)) | ||
| dates = pd.date_range(end=pd.Timestamp.today(), periods=n_days, freq="B") | ||
| tickers = [f"Stock_{i:03d}" for i in range(n_assets)] | ||
| return pd.DataFrame(prices, index=dates, columns=tickers) | ||
|
|
||
|
|
||
| def benchmark_factor(factor, prices: pd.DataFrame): | ||
| """Benchmark runtime of a given factor.""" | ||
| start = time.time() | ||
| _ = factor.compute(prices) | ||
| end = time.time() | ||
| elapsed = end - start | ||
| print( | ||
| f"{factor.name:<25} | Lookback: {factor.lookback:<5} | Time: {elapsed:.3f} sec" | ||
| ) | ||
|
|
||
|
|
||
| def main(): | ||
| print("Generating synthetic data...") | ||
| prices = generate_synthetic_prices(n_assets=500, n_days=252 * 3) | ||
| print(f"Data shape: {prices.shape}") | ||
|
|
||
| print("\nRunning factor benchmarks...\n") | ||
|
|
||
| factors = [ | ||
| MomentumFactor(lookback=63), | ||
| ValueFactor(), | ||
| SizeFactor(), | ||
| VolatilityFactor(lookback=21), | ||
| IdiosyncraticVolatility(lookback=63), | ||
| BollingerBandsFactor(lookback=20), | ||
| ] | ||
|
|
||
| for factor in factors: | ||
| benchmark_factor(factor, prices) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.