Skip to content

Conversation

@Satvik-Singh192
Copy link
Contributor

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:

  • Data downloads
  • Backtest iterations
  • Factor generation
  • Price file processing

✅ I added progress bars directly inside each file responsible for a long-running task, ensuring accurate, module-specific feedback during execution.


✅ Semver Changes

  • Minor (new features, no breaking changes)

✅ Related Issue

Closes #32


Behavior:

  • Progress bars appear automatically for long loops
  • No function signatures were changed
  • No breaking API changes
  • Progress adapts dynamically to input data sizes

✅ Checklist

  • Added tqdm progress bars to long-running loops
  • Verified correctness of outputs
  • Tested output generation end-to-end
  • Kept file-specific implementations clean and self-contained

✅ 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.

@Satvik-Singh192
Copy link
Contributor Author

@ayushkrtiwari Please review my PR

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 tqdm progress 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:
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
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:

Copilot uses AI. Check for mistakes.

# Append current weights (maintain between rebalances)
weights_list.append(current_weights)
with tqdm(len(returns_df.index),desc="Backtesting", unit="day") as pbar:
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
with tqdm(len(returns_df.index),desc="Backtesting", unit="day") as pbar:
with tqdm(len(returns_df.index), desc="Backtesting", unit="day") as pbar:

Copilot uses AI. Check for mistakes.
)
prev_rebalance_date = date
pbar.set_postfix(rebalance="✓", refresh=False)
else :
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect spacing in else : - there should be no space before the colon. Should be else: according to PEP 8.

Suggested change
else :
else:

Copilot uses AI. Check for mistakes.

# Append current weights (maintain between rebalances)
weights_list.append(current_weights)
with tqdm(len(returns_df.index),desc="Backtesting", unit="day") as pbar:
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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").

Suggested change
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:

Copilot uses AI. Check for mistakes.
# 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)
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable n_days is computed but never used in the subsequent code. Consider removing this unused variable.

Suggested change
n_days = len(raw_momentum)

Copilot uses AI. Check for mistakes.
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)
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
n_days = len(prices)

Copilot uses AI. Check for mistakes.

# Generate plots with progress
if plot or plotly:
with tqdm(total=plot + plotly, desc="Generating Visualizations") as pbar:
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
with tqdm(total=plot + plotly, desc="Generating Visualizations") as pbar:
with tqdm(total=int(plot) + int(plotly), desc="Generating Visualizations") as pbar:

Copilot uses AI. Check for mistakes.

import numpy as np
import pandas as pd
from tqdm import tqdm
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'tqdm' is not used.

Suggested change
from tqdm import tqdm

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant