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-03-05 - Dynamic CLI Progress in Quiet Mode
**Learning:** For long-running CLI processes that suppress verbose logging (e.g., `--quiet`), users still need system status visibility. Without it, the application appears frozen.
**Action:** Implement a dynamic progress bar using `\r` conditional on `sys.stdout.isatty()` to provide system status visibility without polluting standard output logs.
2 changes: 1 addition & 1 deletion .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:

# Install the latest version of Terraform CLI and configure the Terraform CLI configuration file with a Terraform Cloud user API token
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
uses: hashicorp/setup-terraform@v3
with:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}

Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@
# Python
__pycache__/
*.pyc
target/

target/
223 changes: 223 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 20 additions & 3 deletions bitcoin_trading_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,20 @@ def simulate_trading(signals, initial_cash=10000, quiet=False):
portfolio['btc'] = 0.0
portfolio['total_value'] = float(initial_cash)

total_days = len(signals)

if not quiet:
print(f"\n{Colors.HEADER}{Colors.BOLD}------ Daily Trading Ledger ------{Colors.ENDC}")
for i, row in signals.iterrows():

for idx, (i, row) in enumerate(signals.iterrows()):
if quiet and sys.stdout.isatty():
progress = (idx + 1) / total_days
bar_len = 30
filled = int(bar_len * progress)
bar = 'β–ˆ' * filled + '-' * (bar_len - filled)
sys.stdout.write(f'\r{Colors.CYAN}Simulating: [{bar}] {progress:.0%}{Colors.ENDC}')
sys.stdout.flush()

if i > 0:
portfolio.loc[i, 'cash'] = portfolio.loc[i-1, 'cash']
portfolio.loc[i, 'btc'] = portfolio.loc[i-1, 'btc']
Expand All @@ -94,14 +105,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']
Expand All @@ -110,6 +123,10 @@ def simulate_trading(signals, initial_cash=10000, quiet=False):
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}")

if quiet and sys.stdout.isatty():
sys.stdout.write('\r' + ' ' * 60 + '\r')
sys.stdout.flush()

return portfolio


Expand Down
Empty file added main.tf
Empty file.
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fn main() { println!("Hello from lab!"); }