From 673380ac38cf32f8b507e9a8b721c527beec57f6 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 23 Jan 2026 13:14:55 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Palette:=20Improve=20CLI=20outpu?= =?UTF-8?q?t=20with=20colors/emojis=20and=20fix=20README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: - Updated README.md to correctly describe the project as Python-based and added usage instructions. - Added requirements.txt. - Enhanced bitcoin_trading_simulation.py output with ANSI colors and emojis for better readability. - Initialized .Jules/palette.md for UX learnings. --- .Jules/palette.md | 5 +++++ README.md | 30 +++++++++++++++++++++++++++-- bitcoin_trading_simulation.py | 36 +++++++++++++++++++++++++---------- requirements.txt | 2 ++ 4 files changed, 61 insertions(+), 12 deletions(-) create mode 100644 .Jules/palette.md create mode 100644 requirements.txt diff --git a/.Jules/palette.md b/.Jules/palette.md new file mode 100644 index 0000000..6e6378c --- /dev/null +++ b/.Jules/palette.md @@ -0,0 +1,5 @@ +## 2026-01-23 - The Importance of First Impressions + +**Learning:** Documentation is the first interface. A README that misidentifies the language (C++ vs Python) creates immediate friction and distrust. Also, CLI tools often suffer from "wall of text" syndrome. Adding simple visual hierarchy (colors, headers) and status indicators (emojis) transforms a raw script into a polished tool. + +**Action:** Always verify the README matches the actual code. For CLIs, default to using standard ANSI colors for key information (Success/Failure) to reduce cognitive load. diff --git a/README.md b/README.md index a1d5a77..944cf21 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,28 @@ -# code -Programming with C++ code +# Bitcoin Trading Simulation + +A Python-based simulation of Bitcoin trading using a "Golden Cross" strategy (Moving Average Crossover). + +## Features + +- **Simulated Data**: Generates synthetic Bitcoin price data using Geometric Brownian Motion. +- **Trading Strategy**: Implements a Golden Cross strategy (Short MA > Long MA = Buy). +- **Performance Analysis**: Calculates final portfolio value and compares it against a "Buy and Hold" strategy. +- **Visual CLI**: Color-coded output for easy reading of trade actions and performance. + +## Requirements + +- Python 3.x +- pandas +- numpy + +## Quick Start + +1. Install dependencies: + ```bash + pip install -r requirements.txt + ``` + +2. Run the simulation: + ```bash + python bitcoin_trading_simulation.py + ``` diff --git a/bitcoin_trading_simulation.py b/bitcoin_trading_simulation.py index e619723..b954d23 100644 --- a/bitcoin_trading_simulation.py +++ b/bitcoin_trading_simulation.py @@ -1,6 +1,18 @@ import numpy as np import pandas as pd +class Color: + PURPLE = '\033[95m' + CYAN = '\033[96m' + DARKCYAN = '\033[36m' + BLUE = '\033[94m' + GREEN = '\033[92m' + YELLOW = '\033[93m' + RED = '\033[91m' + BOLD = '\033[1m' + UNDERLINE = '\033[4m' + END = '\033[0m' + def simulate_bitcoin_prices(days=60, initial_price=50000, volatility=0.02): """ Simulates Bitcoin prices for a given number of days using Geometric Brownian Motion. @@ -51,7 +63,7 @@ def simulate_trading(signals, initial_cash=10000): portfolio['btc'] = 0.0 portfolio['total_value'] = portfolio['cash'] - print("------ Daily Trading Ledger ------") + print(f"\n{Color.PURPLE}{Color.BOLD}------ Daily Trading Ledger ------{Color.END}") for i, row in signals.iterrows(): if i > 0: portfolio.loc[i, 'cash'] = portfolio.loc[i-1, 'cash'] @@ -62,18 +74,18 @@ def simulate_trading(signals, initial_cash=10000): 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"Day {i}: Buy {btc_to_buy:.4f} BTC at ${row['price']:.2f}") + print(f"{Color.GREEN}🟢 Day {i}: BUY {btc_to_buy:.4f} BTC at ${row['price']:.2f}{Color.END}") # 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"Day {i}: Sell {portfolio.loc[i, 'btc']:.4f} BTC at ${row['price']:.2f}") + print(f"{Color.RED}🔴 Day {i}: SELL {portfolio.loc[i, 'btc']:.4f} BTC at ${row['price']:.2f}{Color.END}") portfolio.loc[i, 'btc'] = 0 portfolio.loc[i, 'total_value'] = portfolio.loc[i, 'cash'] + portfolio.loc[i, 'btc'] * row['price'] - print(f"Day {i}: Portfolio Value: ${portfolio.loc[i, 'total_value']:.2f}, Cash: ${portfolio.loc[i, 'cash']:.2f}, BTC: {portfolio.loc[i, 'btc']:.4f}") + # print(f"Day {i}: Portfolio Value: ${portfolio.loc[i, 'total_value']:.2f}, Cash: ${portfolio.loc[i, 'cash']:.2f}, BTC: {portfolio.loc[i, 'btc']:.4f}") return portfolio @@ -99,9 +111,13 @@ def simulate_trading(signals, initial_cash=10000): buy_and_hold_btc = initial_cash / prices.iloc[0] buy_and_hold_value = buy_and_hold_btc * prices.iloc[-1] - print("\n------ Final Portfolio Performance ------") - print(f"Initial Cash: ${initial_cash:.2f}") - print(f"Final Portfolio Value: ${final_value:.2f}") - print(f"Profit/Loss: ${profit:.2f}") - print(f"Buy and Hold Strategy Value: ${buy_and_hold_value:.2f}") - print("-----------------------------------------") + print(f"\n{Color.PURPLE}{Color.BOLD}------ Final Portfolio Performance ------{Color.END}") + print(f"Initial Cash: ${initial_cash:.2f}") + print(f"Final Portfolio Value: ${final_value:.2f}") + + profit_color = Color.GREEN if profit >= 0 else Color.RED + profit_sign = "+" if profit >= 0 else "" + print(f"Profit/Loss: {profit_color}{profit_sign}${profit:.2f}{Color.END}") + + print(f"Buy and Hold Strategy: ${buy_and_hold_value:.2f}") + print(f"{Color.PURPLE}-----------------------------------------{Color.END}") diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..9dff893 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +pandas +numpy