Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .Jules/palette.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
5 changes: 1 addition & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
name: Rust

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

env:
CARGO_TERM_COLOR: always
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@
name: 'Terraform'

on:
push:
branches: [ "main" ]
pull_request:
workflow_dispatch:

permissions:
contents: read
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@
# Python
__pycache__/
*.pyc
target/
25 changes: 23 additions & 2 deletions bitcoin_trading_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -94,21 +98,38 @@ 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']

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

Expand Down