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.

## 2025-03-01 - Defensive CLI Design
**Learning:** Users often mistype arguments (e.g., negative numbers). Without validation, this leads to confusing output or crashes. Friendly error messages with actionable feedback are crucial for CLI usability.
**Action:** Always implement explicit validation for CLI arguments and provide colored, clear error messages before starting any heavy processing.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
22 changes: 0 additions & 22 deletions .github/workflows/rust.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
pull-requests: write

steps:
- uses: actions/stale@v5
- uses: actions/stale@v9
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'Stale issue message'
Expand Down
13 changes: 13 additions & 0 deletions bitcoin_trading_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,19 @@ def countdown(quiet=False):
if args.no_color:
Colors.disable()

if args.days <= 0:
print(f"{Colors.FAIL}Error: --days must be a positive integer.{Colors.ENDC}")
sys.exit(1)
if args.initial_cash <= 0:
print(f"{Colors.FAIL}Error: --initial-cash must be a positive amount.{Colors.ENDC}")
sys.exit(1)
if args.initial_price <= 0:
print(f"{Colors.FAIL}Error: --initial-price must be a positive amount.{Colors.ENDC}")
sys.exit(1)
if args.volatility < 0:
print(f"{Colors.FAIL}Error: --volatility must be non-negative.{Colors.ENDC}")
sys.exit(1)

# Simulate prices
prices = simulate_bitcoin_prices(days=args.days, initial_price=args.initial_price, volatility=args.volatility)

Expand Down
31 changes: 31 additions & 0 deletions test_cli_args.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import subprocess
import sys


def run_cli(args):
return subprocess.run(
[sys.executable, "bitcoin_trading_simulation.py"] + args,
capture_output=True,
text=True
)


def test_negative_days_error():
"""Negative days should fail with a helpful error message."""
result = run_cli(["--days", "-5", "--quiet"])
assert result.returncode == 1
assert "Error: --days must be a positive integer" in result.stdout


def test_negative_cash_error():
"""Negative cash should fail with a helpful error message."""
result = run_cli(["--initial-cash", "-100", "--quiet"])
assert result.returncode == 1
assert "Error: --initial-cash must be a positive amount" in result.stdout


def test_negative_volatility_error():
"""Negative volatility should fail with a helpful error message."""
result = run_cli(["--volatility", "-0.1", "--quiet"])
assert result.returncode == 1
assert "Error: --volatility must be non-negative" in result.stdout
Loading