Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 Oct 26, 2025
af12d1a
feat: Reorder imports in benchmark_factors.py
adityacosmos24 Oct 26, 2025
327c549
feat: refactor volatility factors for production readiness
adityacosmos24 Oct 26, 2025
18fe964
remove unused import of warnings module
adityacosmos24 Oct 26, 2025
a4fecd2
feat: fixed errors
adityacosmos24 Oct 26, 2025
e6456f6
Merge branch 'aditya' of https://github.com/adityacosmos24/QuantResea…
adityacosmos24 Oct 26, 2025
33626dc
remove unused import in volatility.py
adityacosmos24 Oct 26, 2025
e0436fb
errors
adityacosmos24 Oct 26, 2025
485151d
Merge branch 'aditya' of https://github.com/adityacosmos24/QuantResea…
adityacosmos24 Oct 26, 2025
8c54477
errors
adityacosmos24 Oct 26, 2025
7dbdd60
fix: sort imports with Ruff
adityacosmos24 Oct 26, 2025
b70d514
format code with black
adityacosmos24 Oct 26, 2025
83f8e31
feat: added setuptools poetry entrypoint
adityacosmos24 Oct 27, 2025
badb979
chore: update readme with new command syntax and paths
adityacosmos24 Oct 27, 2025
c8c5596
Merge branch 'main' into aditya
adityacosmos24 Oct 27, 2025
50f717d
chore: updated gitignore
adityacosmos24 Oct 27, 2025
cfe2ec9
Merge branch 'aditya' of https://github.com/adityacosmos24/QuantResea…
adityacosmos24 Oct 27, 2025
dd8b845
docs: duplicates removed
ayushkrtiwari Oct 27, 2025
77b56b6
docs: fix typo error
ayushkrtiwari Oct 27, 2025
e140970
docs: added description
ayushkrtiwari Oct 27, 2025
2f2bf84
docs: fixed path issue
ayushkrtiwari Oct 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ node_modules
__pycache__/
*.py[cod]
*$py.class
src/quant_research_starter.egg-info/PKG-INFO
39 changes: 32 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,29 @@ pip install -e ".[dev]"
pip install streamlit plotly
```

### Quick CLI Usage

After installation, you can use the CLI in two ways:

**Option 1: Direct command (if PATH is configured)**
```bash
qrs --help
# generate synthetic sample price series
qrs generate-data -o data_sample/sample_prices.csv -s 5 -d 365
# compute example factors
qrs compute-factors -d data_sample/sample_prices.csv -f momentum -f value -o output/factors.csv
# run a backtest
qrs backtest -d data_sample/sample_prices.csv -s output/factors.csv -o output/backtest_results.json
```

**Option 2: Python module (always works)**
```bash
python -m quant_research_starter.cli --help
python -m quant_research_starter.cli generate-data -o data_sample/sample_prices.csv -s 5 -d 365
python -m quant_research_starter.cli compute-factors -d data_sample/sample_prices.csv -f momentum -f value
python -m quant_research_starter.cli backtest -d data_sample/sample_prices.csv -s output/factors.csv -o output/backtest_results.json
```

### Demo (one-line)

```bash
Expand All @@ -63,13 +86,13 @@ make demo

```bash
# generate synthetic sample price series
qrs generate-data -o data_sample/sample_prices.csv -s 5 -d 365
python -m quant_research_starter.cli generate-data -o data_sample/sample_prices.csv -s 5 -d 365

# compute example factors
qrs compute-factors -d data_sample/sample_prices.csv -f momentum -f value -o output/factors.csv
python -m quant_research_starter.cli compute-factors -d data_sample/sample_prices.csv -f momentum -f value -o output/factors.csv

# run a backtest
qrs backtest -d data_sample/sample_prices.csv -s output/factors.csv -o output/backtest_results.json
python -m quant_research_starter.cli backtest -d data_sample/sample_prices.csv -s output/factors.csv -o output/backtest_results.json

# optional: start the Streamlit dashboard
streamlit run src/quant_research_starter/dashboard/streamlit_app.py
Expand Down Expand Up @@ -123,11 +146,13 @@ Supported frequencies:

## CLI reference

Run `qrs --help` or `qrs <command> --help` for full usage. Main commands include:
Run `python -m quant_research_starter.cli --help` or `python -m quant_research_starter.cli <command> --help` for full usage. Main commands include:

* `python -m quant_research_starter.cli generate-data` β€” create synthetic price series or download data from adapters
* `python -m quant_research_starter.cli compute-factors` β€” calculate and export factor scores
* `python -m quant_research_starter.cli backtest` β€” run the vectorized backtest and export results

* `qrs generate-data` β€” create synthetic price series or download data from adapters
* `qrs compute-factors` β€” calculate and export factor scores
* `qrs backtest` β€” run the vectorized backtest and export results
**Note:** If you have the `qrs` command in your PATH, you can use `qrs` instead of `python -m quant_research_starter.cli`.

---

Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ qrs = "quant_research_starter.cli:cli"
requires = ["setuptools>=45", "wheel"]
build-backend = "setuptools.build_meta"

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools.package-dir]
"" = "src"

[tool.black]
line-length = 88
target-version = ['py310']
Expand Down
107 changes: 107 additions & 0 deletions test_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#!/usr/bin/env python3
"""
Simple test script for QuantResearch CLI
This demonstrates all the CLI functionality
"""

import subprocess
import sys
from pathlib import Path


def run_command(cmd):
"""Run a command and print the result"""
print(f"\n{'='*60}")
print(f"Running: {cmd}")
print('='*60)
result = subprocess.run(cmd, shell=True, capture_output=True, text=True)

if result.stdout:
print(result.stdout)
if result.stderr and result.returncode != 0:
print(f"ERROR: {result.stderr}")
return False

return result.returncode == 0


def main():
"""Run all CLI tests"""
print("\nπŸ§ͺ Testing QuantResearch CLI")
print("="*60)

# Define test directories
test_data_dir = Path("test_data")
test_output_dir = Path("test_output")

# Create test directories
test_data_dir.mkdir(exist_ok=True)
test_output_dir.mkdir(exist_ok=True)

# Test 1: Show help
success = run_command("python -m quant_research_starter.cli --help")
if not success:
print("\n❌ Test 1 FAILED: Help command")
sys.exit(1)

# Test 2: Generate data
success = run_command(
"python -m quant_research_starter.cli generate-data "
"-o test_data/data.csv -s 5 -d 100"
)
if not success:
print("\n❌ Test 2 FAILED: Generate data")
sys.exit(1)

# Test 3: Compute factors
success = run_command(
"python -m quant_research_starter.cli compute-factors "
"-d test_data/data.csv -f momentum -f value -o test_output/factors.csv"
)
if not success:
print("\n❌ Test 3 FAILED: Compute factors")
sys.exit(1)

# Test 4: Run backtest
success = run_command(
"python -m quant_research_starter.cli backtest "
"-d test_data/data.csv -s test_output/factors.csv "
"-o test_output/backtest_results.json"
)
if not success:
print("\n❌ Test 4 FAILED: Run backtest")
sys.exit(1)

# Verify output files exist
print("\nπŸ“ Checking output files...")
files_to_check = [
test_data_dir / "data.csv",
test_output_dir / "factors.csv",
test_output_dir / "backtest_results.json",
test_output_dir / "backtest_plot.png"
]

all_exist = True
for file_path in files_to_check:
if file_path.exists():
print(f"βœ… {file_path} exists ({file_path.stat().st_size} bytes)")
else:
print(f"❌ {file_path} missing!")
all_exist = False

if not all_exist:
print("\n❌ Some output files are missing")
sys.exit(1)

# Summary
print("\n" + "="*60)
print("βœ… ALL TESTS PASSED!")
print("="*60)
print(f"\nπŸ“‚ Test files created in:")
print(f" - {test_data_dir}/")
print(f" - {test_output_dir}/")
print("\nπŸ’‘ You can view the results and plots in the test_output directory.")


if __name__ == "__main__":
main()
Loading