diff --git a/.Jules/palette.md b/.Jules/palette.md index 96bd45d..68e442d 100644 --- a/.Jules/palette.md +++ b/.Jules/palette.md @@ -5,3 +5,7 @@ ## 2025-02-28 - Structured CLI Reports **Learning:** Dense numerical data in CLI output is hard to parse. Using ASCII box-drawing characters and alignment to create a "dashboard" or "invoice" style summary significantly improves readability and perceived quality. **Action:** When summarizing simulation or batch job results, always format the final report as a structured table or box rather than a list of print statements. + +## 2026-02-28 - Interactive Progress Bars for Suppressed Logs +**Learning:** When users pass a '--quiet' flag to suppress verbose logging in a CLI app, long-running processes can appear frozen or broken, causing confusion. +**Action:** When suppressing daily or detailed logs, implement a dynamic, single-line progress bar (guarded by checking if stdout is a TTY) to provide visual assurance that the process is still running. diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9fd45e0..2ba6a9d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,10 +1,7 @@ name: Rust on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] + workflow_dispatch: env: CARGO_TERM_COLOR: always diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 540e804..6e852b1 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -45,9 +45,7 @@ name: 'Terraform' on: - push: - branches: [ "main" ] - pull_request: + workflow_dispatch: permissions: contents: read diff --git a/.gitignore b/.gitignore index 907591b..808de52 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,4 @@ # Python __pycache__/ *.pyc +target/ diff --git a/bitcoin_trading_simulation.py b/bitcoin_trading_simulation.py index cb07d20..5b55983 100644 --- a/bitcoin_trading_simulation.py +++ b/bitcoin_trading_simulation.py @@ -84,6 +84,10 @@ def simulate_trading(signals, initial_cash=10000, quiet=False): if not quiet: print(f"\n{Colors.HEADER}{Colors.BOLD}------ Daily Trading Ledger ------{Colors.ENDC}") + + total_signals = len(signals) + last_printed_progress = -1 + for i, row in signals.iterrows(): if i > 0: portfolio.loc[i, 'cash'] = portfolio.loc[i-1, 'cash'] @@ -94,14 +98,16 @@ def simulate_trading(signals, initial_cash=10000, quiet=False): btc_to_buy = portfolio.loc[i, 'cash'] / row['price'] portfolio.loc[i, 'btc'] += btc_to_buy portfolio.loc[i, 'cash'] -= btc_to_buy * row['price'] - print(f"{Colors.GREEN}🟢 Day {i}: Buy {btc_to_buy:.4f} BTC at ${row['price']:.2f}{Colors.ENDC}") + if not quiet: + print(f"{Colors.GREEN}🟢 Day {i}: Buy {btc_to_buy:.4f} BTC at ${row['price']:.2f}{Colors.ENDC}") # Sell signal elif row['positions'] == -2.0: if portfolio.loc[i, 'btc'] > 0: cash_received = portfolio.loc[i, 'btc'] * row['price'] portfolio.loc[i, 'cash'] += cash_received - print(f"{Colors.FAIL}🔴 Day {i}: Sell {portfolio.loc[i, 'btc']:.4f} BTC at ${row['price']:.2f}{Colors.ENDC}") + if not quiet: + print(f"{Colors.FAIL}🔴 Day {i}: Sell {portfolio.loc[i, 'btc']:.4f} BTC at ${row['price']:.2f}{Colors.ENDC}") portfolio.loc[i, 'btc'] = 0 portfolio.loc[i, 'total_value'] = portfolio.loc[i, 'cash'] + portfolio.loc[i, 'btc'] * row['price'] @@ -109,6 +115,21 @@ def simulate_trading(signals, initial_cash=10000, quiet=False): if not quiet: print(f"Day {i}: Portfolio Value: ${portfolio.loc[i, 'total_value']:.2f}, " f"Cash: ${portfolio.loc[i, 'cash']:.2f}, BTC: {portfolio.loc[i, 'btc']:.4f}") + elif sys.stdout.isatty(): + current_idx = signals.index.get_loc(i) + # Only update the progress bar at 1% increments to avoid excessive I/O + current_progress = int((current_idx + 1) * 100 / total_signals) + if current_progress > last_printed_progress or current_idx == total_signals - 1: + progress_ratio = (current_idx + 1) / total_signals + bar_length = 40 + filled_length = int(bar_length * progress_ratio) + bar = '█' * filled_length + '-' * (bar_length - filled_length) + sys.stdout.write(f'\r{Colors.BLUE}Simulating: |{bar}| {progress_ratio:.0%} Complete{Colors.ENDC}') + sys.stdout.flush() + last_printed_progress = current_progress + + if quiet and sys.stdout.isatty(): + print() return portfolio