feat: adds loading bar#33
feat: adds loading bar#33Satvik-Singh192 wants to merge 1 commit intoOPCODE-Open-Spring-Fest:mainfrom
Conversation
|
@ayushkrtiwari Please review my PR |
There was a problem hiding this comment.
Pull Request Overview
This pull request adds progress tracking functionality using the tqdm library throughout the quantitative research starter codebase. The changes enhance user experience by providing visual feedback during long-running operations such as data generation, factor computation, and backtesting.
- Integrates
tqdmprogress bars across factor computations (value, momentum, bollinger), data operations (downloaders, sample generation), and backtesting - Updates CLI commands to include progress tracking and enhanced console output with emoji indicators
- Refactors existing computation logic to be wrapped in progress context managers
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
src/quant_research_starter/factors/value.py |
Wraps value factor computation steps in a tqdm progress bar with 5 steps |
src/quant_research_starter/factors/momentum.py |
Adds progress tracking to momentum factor calculation and cross-sectional normalization |
src/quant_research_starter/factors/bollinger.py |
Implements progress bar for Bollinger band z-score computation |
src/quant_research_starter/data/synthetic.py |
Imports tqdm (preparation for future use) |
src/quant_research_starter/data/sample_loader.py |
Adds progress tracking for symbol-by-symbol sample data generation |
src/quant_research_starter/data/downloaders.py |
Implements progress bars for Yahoo and Alpha Vantage data downloads |
src/quant_research_starter/cli.py |
Wraps CLI operations in progress contexts and adds emoji indicators to output messages |
src/quant_research_starter/backtest/vectorized.py |
Adds progress tracking for backtesting iterations and performance calculations |
Comments suppressed due to low confidence (2)
src/quant_research_starter/factors/momentum.py:37
- Variable n_days is not used.
n_days = len(prices)
src/quant_research_starter/factors/momentum.py:68
- Variable n_days is not used.
n_days = len(raw_momentum)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| np.random.seed(hash(symbol) % 2**32) | ||
| prices = 100 + np.cumsum(np.random.randn(len(dates)) * 0.5) | ||
| data[symbol] = prices | ||
| with tqdm(total=len(symbols),desc="Downloading Yahoo data", unit="symbol") as pbar: |
There was a problem hiding this comment.
Missing space after comma in function arguments. Should be total=len(symbols), desc="Downloading Yahoo data", unit="symbol" with a space after the comma following len(symbols).
| with tqdm(total=len(symbols),desc="Downloading Yahoo data", unit="symbol") as pbar: | |
| with tqdm(total=len(symbols), desc="Downloading Yahoo data", unit="symbol") as pbar: |
|
|
||
| # Append current weights (maintain between rebalances) | ||
| weights_list.append(current_weights) | ||
| with tqdm(len(returns_df.index),desc="Backtesting", unit="day") as pbar: |
There was a problem hiding this comment.
Missing space after comma in function arguments. Should be tqdm(total=len(returns_df.index), desc="Backtesting", unit="day") with a space after the comma following len(returns_df.index).
| with tqdm(len(returns_df.index),desc="Backtesting", unit="day") as pbar: | |
| with tqdm(len(returns_df.index), desc="Backtesting", unit="day") as pbar: |
| ) | ||
| prev_rebalance_date = date | ||
| pbar.set_postfix(rebalance="✓", refresh=False) | ||
| else : |
There was a problem hiding this comment.
Incorrect spacing in else : - there should be no space before the colon. Should be else: according to PEP 8.
| else : | |
| else: |
|
|
||
| # Append current weights (maintain between rebalances) | ||
| weights_list.append(current_weights) | ||
| with tqdm(len(returns_df.index),desc="Backtesting", unit="day") as pbar: |
There was a problem hiding this comment.
The tqdm constructor is called with a positional argument for total, but this should use the total parameter name. Change tqdm(len(returns_df.index),desc="Backtesting", unit="day") to tqdm(total=len(returns_df.index), desc="Backtesting", unit="day").
| with tqdm(len(returns_df.index),desc="Backtesting", unit="day") as pbar: | |
| with tqdm(total=len(returns_df.index), desc="Backtesting", unit="day") as pbar: |
| # Z-score normalization cross-sectionally | ||
| z_scores = raw_momentum.sub(raw_momentum.mean(axis=1), axis=0) | ||
| z_scores = z_scores.div(raw_momentum.std(axis=1), axis=0) | ||
| n_days = len(raw_momentum) |
There was a problem hiding this comment.
The variable n_days is computed but never used in the subsequent code. Consider removing this unused variable.
| n_days = len(raw_momentum) |
| shifted_prices = prices.shift(self.skip_period) | ||
| momentum = (shifted_prices / shifted_prices.shift(self.lookback)) - 1 | ||
| n_symbols = len(prices.columns) | ||
| n_days = len(prices) |
There was a problem hiding this comment.
The variable n_days is computed but never used. It was used in the previous version as days but is no longer needed. Consider removing this unused variable.
| n_days = len(prices) |
|
|
||
| # Generate plots with progress | ||
| if plot or plotly: | ||
| with tqdm(total=plot + plotly, desc="Generating Visualizations") as pbar: |
There was a problem hiding this comment.
Incorrect use of boolean values in arithmetic expression. The expression plot + plotly will add boolean values (True=1, False=0), which works but is not clear or idiomatic. Instead, use int(plot) + int(plotly) or sum([plot, plotly]) for clarity.
| with tqdm(total=plot + plotly, desc="Generating Visualizations") as pbar: | |
| with tqdm(total=int(plot) + int(plotly), desc="Generating Visualizations") as pbar: |
|
|
||
| import numpy as np | ||
| import pandas as pd | ||
| from tqdm import tqdm |
There was a problem hiding this comment.
Import of 'tqdm' is not used.
| from tqdm import tqdm |
Description
This PR implements
tqdm-based loading bars individually across multiple modules to improve the user experience during long-running operations.Issue #32 requested visible progress indicators for heavy tasks like:
✅ I added progress bars directly inside each file responsible for a long-running task, ensuring accurate, module-specific feedback during execution.
✅ Semver Changes
✅ Related Issue
Closes #32
Behavior:
✅ Checklist
✅ Notes
Progress bars were deliberately implemented individually in each file to maintain separation of concerns and prevent unnecessary cross-module dependencies.
This approach ensures each component displays its own accurate and independent progress indicator.